SimPmtM64CrosstalkTable Class Reference

#include <SimPmtM64CrosstalkTable.h>

List of all members.

Public Member Functions

 SimPmtM64CrosstalkTable (const VldContext &vc)
 ~SimPmtM64CrosstalkTable ()
void Reset (const VldContext &vc)
const SimPmtM64CrosstalkGetRow (Int_t injPix, Int_t xPix)
const VldContext GetContext () const

Protected Attributes

float fOptTotProb [65]
float fOptDist [65][65]
float fElecFrac [65][65]
float fElecK [65][65]

Private Member Functions

void RebuildCache ()
 ClassDef (SimPmtM64CrosstalkTable, 0)

Private Attributes

VldContext fContext
VldRange fLastRange
const SimPmtM64Crosstalk ** fCache
DbiResultPtr< SimPmtM64CrosstalkfResPtr

Friends

class SimPmtM64


Detailed Description

Definition at line 19 of file SimPmtM64CrosstalkTable.h.


Constructor & Destructor Documentation

SimPmtM64CrosstalkTable::SimPmtM64CrosstalkTable ( const VldContext vc  ) 

Definition at line 9 of file SimPmtM64CrosstalkTable.cxx.

References Msg::kDebug, and MSG.

00010     : fContext(vc),
00011       fCache(0),
00012       fResPtr(vc)
00013 {
00014   // Zero arrays.
00015   for(int i=0;i<65;i++) {
00016     fOptTotProb[i]=0;
00017     for(int j=0;j<65;j++) {
00018       fOptDist[i][j] = 0;
00019       fElecFrac[i][j] = 0;
00020       fElecK[i][j] = 0;
00021     }
00022   }
00023 
00024   RebuildCache();
00025   MSG("DetSim",Msg::kDebug) << "Creating SimPmtM64CrosstalkTable.\n";
00026 }

SimPmtM64CrosstalkTable::~SimPmtM64CrosstalkTable (  )  [inline]

Definition at line 25 of file SimPmtM64CrosstalkTable.h.

References fCache.

00025 { if(fCache) delete [] fCache; };


Member Function Documentation

SimPmtM64CrosstalkTable::ClassDef ( SimPmtM64CrosstalkTable  ,
 
) [private]

const VldContext SimPmtM64CrosstalkTable::GetContext ( void   )  const [inline]

Definition at line 30 of file SimPmtM64CrosstalkTable.h.

References fContext.

00030 { return fContext; };

const SimPmtM64Crosstalk * SimPmtM64CrosstalkTable::GetRow ( Int_t  injPix,
Int_t  xPix 
)

Definition at line 49 of file SimPmtM64CrosstalkTable.cxx.

References fCache, Msg::kError, and MSG.

Referenced by RebuildCache().

00050 {
00051   Int_t index = injPix*100 + xPix;
00052   //  return fResPtr.GetRowByIndex(index);
00053 
00054   if(!fCache) {
00055     MSG("DetSim",Msg::kError) << "Crosstalk cache not yet built!" << endl;
00056     return 0;
00057   }
00058 
00059   return fCache[index];
00060 }

void SimPmtM64CrosstalkTable::RebuildCache (  )  [private]

Definition at line 62 of file SimPmtM64CrosstalkTable.cxx.

References Munits::fC, fCache, fElecFrac, fElecK, fOptDist, fOptTotProb, fResPtr, SimPmtM64Crosstalk::GetElecFrac(), SimPmtM64Crosstalk::GetElecK(), DbiResultPtr< T >::GetNumRows(), SimPmtM64Crosstalk::GetOptProb(), GetRow(), DbiResultPtr< T >::GetRowByIndex(), Msg::kError, and MSG.

Referenced by Reset().

00063 {
00064   if(fResPtr.GetNumRows()==0) return; // No data to cache.
00065 
00066   const int kCacheSize = 6500;
00067   if(fCache) delete [] fCache;
00068   fCache = new const SimPmtM64Crosstalk*[kCacheSize];
00069   for(int i=0; i<kCacheSize; i++) {
00070     fCache[i] = fResPtr.GetRowByIndex(i);
00071   }
00072 
00073   for(int inj=1;inj<=64;inj++) {
00074     fOptTotProb[inj] = 0;
00075 
00076     for(int xpix=1; xpix<=64; xpix++) {
00077       fOptDist[inj][xpix] = 0;
00078       fElecFrac[inj][xpix] = 0;
00079       fElecK[inj][xpix] = 0;    
00080       
00081       const SimPmtM64Crosstalk* row = GetRow(inj,xpix);
00082       if((row)&&(inj!=xpix)) {
00083         float optprob = row->GetOptProb();
00084         if(optprob < 0) optprob = 0; // No negative optical crosstalk.
00085         fOptTotProb[inj] += optprob;
00086 
00087         fElecFrac[inj][xpix] = row->GetElecFrac();
00088         fElecK[inj][xpix] = row->GetElecK()*Munits::fC; //convert from fC.      
00089       }
00090       fOptDist[inj][xpix] = fOptTotProb[inj]; // Cumulative probability.        
00091     }
00092 
00093     // Normalize the opt distribution.
00094     // .. protect against floating point error. When the FD is simualted,
00095     // the M64 model gets initialized too, even though there's no Xtalk table.
00096     float norm = 1.0;
00097     if(fOptTotProb[inj]<=0) 
00098       MSG("DetSim",Msg::kError) << "Got zero total opt xtalk on pixel " << inj << ".. that shouldn't happen."<< endl;
00099     else 
00100       norm = 1.0/fOptTotProb[inj];
00101     
00102     for(int xpix=1; xpix<=64; xpix++) {
00103       fOptDist[inj][xpix] *= norm;
00104     }
00105   }
00106 }

void SimPmtM64CrosstalkTable::Reset ( const VldContext vc  ) 

Definition at line 28 of file SimPmtM64CrosstalkTable.cxx.

References fContext, fLastRange, fResPtr, VldRange::GetDetectorMask(), VldRange::GetSimMask(), VldRange::GetTimeEnd(), VldRange::GetTimeStart(), DbiResultPtr< T >::GetValidityRec(), DbiValidityRec::GetVldRange(), DbiResultPtr< T >::NewQuery(), and RebuildCache().

Referenced by SimPmtM64::Reset().

00029 {
00030   if(fContext==vc) return;
00031   fResPtr.NewQuery(vc);
00032 
00033   VldRange newrange = fResPtr.GetValidityRec()->GetVldRange();
00034 
00035   if( (newrange.GetTimeStart()!=fLastRange.GetTimeStart()) ||
00036       (newrange.GetTimeEnd()!=fLastRange.GetTimeEnd()) ||
00037       ( newrange.GetDetectorMask()!=fLastRange.GetDetectorMask()) ||
00038       ( newrange.GetSimMask()!=fLastRange.GetSimMask()) ) {
00039     
00040     // The vld range has changed, indicating the table has been reloaded.
00041     fLastRange = newrange;
00042     RebuildCache();
00043   }
00044     
00045   fContext=vc;
00046 }


Friends And Related Function Documentation

friend class SimPmtM64 [friend]

Definition at line 21 of file SimPmtM64CrosstalkTable.h.


Member Data Documentation

const SimPmtM64Crosstalk* * SimPmtM64CrosstalkTable::fCache [private]

Definition at line 47 of file SimPmtM64CrosstalkTable.h.

Referenced by GetRow(), RebuildCache(), and ~SimPmtM64CrosstalkTable().

VldContext SimPmtM64CrosstalkTable::fContext [private]

Definition at line 45 of file SimPmtM64CrosstalkTable.h.

Referenced by GetContext(), and Reset().

float SimPmtM64CrosstalkTable::fElecFrac[65][65] [protected]

Definition at line 37 of file SimPmtM64CrosstalkTable.h.

Referenced by SimPmtM64::GenElectricalCrosstalk(), and RebuildCache().

float SimPmtM64CrosstalkTable::fElecK[65][65] [protected]

Definition at line 38 of file SimPmtM64CrosstalkTable.h.

Referenced by SimPmtM64::GenElectricalCrosstalk(), and RebuildCache().

VldRange SimPmtM64CrosstalkTable::fLastRange [private]

Definition at line 46 of file SimPmtM64CrosstalkTable.h.

Referenced by Reset().

float SimPmtM64CrosstalkTable::fOptDist[65][65] [protected]

Definition at line 35 of file SimPmtM64CrosstalkTable.h.

Referenced by RebuildCache().

float SimPmtM64CrosstalkTable::fOptTotProb[65] [protected]

Definition at line 30 of file SimPmtM64CrosstalkTable.h.

Referenced by RebuildCache(), and SimPmtM64::SimulateOpticalXtalk().

DbiResultPtr<SimPmtM64Crosstalk> SimPmtM64CrosstalkTable::fResPtr [private]

Definition at line 50 of file SimPmtM64CrosstalkTable.h.

Referenced by RebuildCache(), and Reset().


The documentation for this class was generated from the following files:
Generated on Thu Apr 10 23:03:43 2014 for loon by  doxygen 1.4.7