NtpSRBleachFiller Class Reference

#include <NtpSRBleachFiller.h>

List of all members.

Public Member Functions

 NtpSRBleachFiller (const CandRecord *cndrec)
virtual ~NtpSRBleachFiller ()
double GetEventDuration (const CandEventHandle *cndevt)
double GetFixedWindowPH (const CandEventHandle *cndevt, const CandRecord *cndrec)
float GetlateBucketPHFraction (const CandEventHandle *cndevt, const RawRecord *rawrec)
float GetstraightPHFraction (const CandEventHandle *evt)

Private Member Functions

bool initStraightPHFraction (const CandRecord *cndrec)

Private Attributes

bool fInitOkay
Int_t * fStripArray
std::map< Int_t, Int_t > fUIDMap

Detailed Description

Definition at line 20 of file NtpSRBleachFiller.h.


Constructor & Destructor Documentation

NtpSRBleachFiller::NtpSRBleachFiller ( const CandRecord cndrec  ) 

Definition at line 33 of file NtpSRBleachFiller.cxx.

References fInitOkay, initStraightPHFraction(), Msg::kDebug, and MSG.

00033                                                              : 
00034    fInitOkay(false), fStripArray(NULL) {
00035   // Constructor
00036 
00037   MSG("NtpSR",Msg::kDebug) << "NtpSRBleachFiller::ctor @" << this << std::endl;
00038 
00039   fInitOkay = initStraightPHFraction(cndrec);
00040 
00041   
00042 }

NtpSRBleachFiller::~NtpSRBleachFiller (  )  [virtual]

Definition at line 45 of file NtpSRBleachFiller.cxx.

References fStripArray, Msg::kDebug, and MSG.

00045                                       {
00046   // Destructor
00047 
00048   MSG("NtpSR",Msg::kDebug) << "NtpSRBleachFiller::dtor @" << this << std::endl;
00049 
00050   if ( fStripArray ) delete [] fStripArray;
00051 
00052 }


Member Function Documentation

double NtpSRBleachFiller::GetEventDuration ( const CandEventHandle cndevt  ) 

Definition at line 55 of file NtpSRBleachFiller.cxx.

References CandHandle::GetDaughterIterator(), VldContext::GetDetector(), CandHandle::GetVldContext(), Detector::kNear, Msg::kWarning, and MSG.

00055                                                                         {
00056   //
00057   // Purpose: Calculate event duration from first and last strip time in 
00058   //          event. 
00059   //
00060   // Arguments: CandEventHandle ptr.
00061   // 
00062   // Return: event duration in nsec.
00063   //
00064   // Author: Tobias Raufer (tobias.raufer@physics.ox.ac.uk) 
00065   //
00066   // Creation Date: 11/05
00067 
00068   Double_t result = -1;
00069   if (!cndevt){
00070     MSG("NtpSR",Msg::kWarning) 
00071       << "No CandEventHandle Found, will return the default value"<<endl;
00072     return result;
00073   }
00074 
00075   const VldContext* vldc = cndevt->GetVldContext();
00076   Detector::Detector_t fDetType = vldc->GetDetector();
00077   if (fDetType!=Detector::kNear) return result;
00078 
00079   // loop over all strips and find earliest and latest strip time
00080   Double_t evtStart = 99999;
00081   Double_t evtEnd = -1;
00082   CandStripHandleItr stpItr(cndevt->GetDaughterIterator());
00083   while (CandStripHandle* strip=dynamic_cast<CandStripHandle*>(stpItr())){
00084    
00085     if (strip->GetTime() < evtStart) {
00086       evtStart = strip->GetTime();
00087     }
00088     if (strip->GetTime() > evtEnd) {
00089       evtEnd = strip->GetTime();
00090     }
00091  }
00092   result = (evtEnd - evtStart)*1e9; // result is in nsec
00093   return result;
00094 }

double NtpSRBleachFiller::GetFixedWindowPH ( const CandEventHandle cndevt,
const CandRecord cndrec 
)

Definition at line 97 of file NtpSRBleachFiller.cxx.

References CandRecord::FindCandHandle(), CandHandle::GetDaughterIterator(), VldContext::GetDetector(), RecMinos::GetHeader(), CandEventHandle::GetPrimaryTrack(), RecMinosHdr::GetVldContext(), CandRecoHandle::GetVtxPlane(), Detector::kNear, CalDigitType::kSigCorr, Msg::kWarning, max, min, and MSG.

00098                                                                      {
00099   //
00100   // Purpose: Calculate predicted afterpulsing ph in a fixed window around
00101   //          the event vertex.
00102   //
00103   // Arguments: CandEventHandle ptr, CandRecord ptr.
00104   // 
00105   // Return: fixed window ph.
00106   //
00107   // Author: Tobias Raufer (tobias.raufer@physics.ox.ac.uk) 
00108   //
00109   // Creation Date: 11/05
00110 
00111   Double_t result = -1;
00112   if (!cndevt){
00113     MSG("NtpSR",Msg::kWarning) 
00114       << "No CandEventHandle Found, will return the default value"<<endl;
00115     return result;
00116   }
00117   if (!cndrec){
00118     MSG("NtpSR",Msg::kWarning) 
00119       << "No CandRecord Found, will return the default value"<<endl;
00120     return result;
00121   }
00122 
00123   VldContext vldc = cndrec->GetHeader()->GetVldContext();
00124   Detector::Detector_t fDetType = vldc.GetDetector();
00125   if (fDetType!=Detector::kNear) return result;
00126 
00127   // construct a NtpSRNDAPPlaneHistory object for each plane
00128   // this class contains the exponential model for the afterpulsing
00129   // based on the previous activity in the snarl
00130   map<Int_t,NtpSRNDAPPlaneHistory> planeHistMap; 
00131   
00132   for (Int_t plane=1; plane<282; plane++) {
00133     NtpSRNDAPPlaneHistory h(plane);
00134     planeHistMap.insert(std::pair<Int_t,NtpSRNDAPPlaneHistory>(plane,h));
00135   }
00136 
00137   // loop over all strips and fill NtpSRNDAPPlaneHistory objects
00138   const CandStripListHandle *striplisthandle 
00139     = dynamic_cast <const CandStripListHandle*> 
00140     (cndrec->FindCandHandle("CandStripListHandle"));
00141   if ( !striplisthandle ) {
00142     MSG("NtpSR",Msg::kWarning) 
00143       << "No strip list found in CandRecord. "
00144       << "Will return the default value " << endl;
00145     return result; // no strips => done
00146   }
00147 
00148   TIter stripItr(striplisthandle->GetDaughterIterator());
00149   while ( CandStripHandle* strip=dynamic_cast<CandStripHandle*>(stripItr())) {
00150     
00151     Int_t plane = strip->GetPlane();
00152 
00153     // add strip to NtpSRNDAPPlaneHistory object
00154     map<Int_t,NtpSRNDAPPlaneHistory>::iterator pos;    
00155     pos = planeHistMap.find(plane);
00156     if (pos!=planeHistMap.end())
00157       pos->second.AddStrip(strip->GetTime(),
00158                            strip->GetCharge(CalDigitType::kSigCorr));  
00159     else 
00160       MSG("NtpSR",Msg::kWarning) 
00161         << "No NtpSRNDAPPlaneHistory object for plane " << plane 
00162         << ". Not using this strip!" << endl;
00163   }
00164 
00165   // calculate pred. afterpulsing in 33 plane window around the vertex
00166   
00167   // find vertex plane; if track exists, use track vertex
00168   Int_t vtxPlane = -1; 
00169   const CandTrackHandle* trk = cndevt->GetPrimaryTrack();
00170   if (trk) 
00171     vtxPlane = trk->GetVtxPlane();
00172   else vtxPlane = cndevt->GetVtxPlane();
00173   
00174   Int_t minPlane = max(vtxPlane-2,1);
00175   Int_t maxPlane = min(vtxPlane+30,281);
00176 
00177   Double_t evtTime = 9999; // get event time from first strip in event
00178   CandStripHandleItr stpItr(cndevt->GetDaughterIterator());
00179   while (CandStripHandle* strip=dynamic_cast<CandStripHandle*>(stpItr())){
00180     if (strip->GetTime() < evtTime) {
00181       evtTime = strip->GetTime();
00182     }
00183   }
00184 
00185   Double_t APsum= 0;
00186   for (Int_t pl = minPlane; pl<maxPlane;pl++) {
00187     map<Int_t,NtpSRNDAPPlaneHistory>::iterator pos;    
00188     pos = planeHistMap.find(pl);
00189     if (pos!=planeHistMap.end())
00190       APsum +=
00191         pos->second.APPrediction(evtTime);
00192     else 
00193       MSG("NtpSR",Msg::kWarning) 
00194         << "No NtpSRNDAPPlaneHistory object for plane " << pl 
00195         << ". Not adding afterpulsing prediction for this plane!" 
00196         << endl;
00197   }
00198   result = APsum;
00199   return result;
00200 }

float NtpSRBleachFiller::GetlateBucketPHFraction ( const CandEventHandle cndevt,
const RawRecord rawrec 
)

Definition at line 203 of file NtpSRBleachFiller.cxx.

References RawDigitDataBlock::At(), digit(), RawRecord::FindRawBlock(), RawDigit::GetADC(), CandRecoHandle::GetCharge(), CandHandle::GetDaughterIterator(), VldContext::GetDetector(), RecMinos::GetHeader(), RawDigit::GetTDC(), RecMinosHdr::GetVldContext(), Detector::kNear, CalStripType::kSigLin, Msg::kWarning, and MSG.

00204                                                                           {
00205   //
00206   // Purpose: Calculate late bucket ph fraction for each event.
00207   //
00208   // Arguments: CandEventHandle ptr, RawRecord ptr.
00209   // 
00210   // Return: late bucket ph fraction. -1 if error.
00211   //
00212   // Authors: Tingjun Yang (tjyang@stanford.edu) 
00213   //          Jiajie Ling  (ling@barney.physics.sc.edu)
00214   //
00215   // Creation date: 11/05 
00216 
00217   float ratio = -1;
00218   if (!cndevt){
00219     MSG("NtpSR",Msg::kWarning) 
00220       << "No CandEventHandle Found, will return the default value"<<endl;
00221     return ratio;
00222   }
00223   if (!rawrec){
00224     MSG("NtpSR",Msg::kWarning) 
00225       << "No RawRecord Found, will return the default value"<<endl;
00226     return ratio;
00227   }
00228 
00229   VldContext vldc = rawrec->GetHeader()->GetVldContext();
00230   Detector::Detector_t fDetType = vldc.GetDetector();
00231   if (fDetType!=Detector::kNear) return ratio;
00232 
00233   const RawDigitDataBlock *rddb = dynamic_cast<const RawDigitDataBlock *>
00234                                   (rawrec->FindRawBlock("RawDigitDataBlock"));
00235 
00236   if (!rddb){
00237     MSG("NtpSR",Msg::kWarning) 
00238       << "No RawDigitDataBlock Found, will return the default value"<<endl;
00239     return ratio;
00240   }
00241 
00242   int firstbucket = 999999999; //the first time bucket in the current event
00243   int firstbucket_corr = 999999999; //corrected firstbucket after removing early digits
00244  
00245   CandStripHandleItr stripItr(cndevt->GetDaughterIterator());
00246   while (CandStripHandle* strip=dynamic_cast<CandStripHandle*>(stripItr())){
00247     CandDigitHandleItr digitItr(strip->GetDaughterIterator());
00248     while (CandDigitHandle *digit = dynamic_cast<CandDigitHandle*>(digitItr())){
00249       const RawDigit* rd=dynamic_cast<const RawDigit*>(rddb->At(digit->GetRawDigitIndex()));
00250       if(rd->GetTDC()<firstbucket) firstbucket = rd->GetTDC();
00251       if(rd->GetTDC()<firstbucket_corr && rd->GetADC()>0.01*cndevt->GetCharge(CalStripType::kSigLin)){//get rid of early digit(s) with low ph (less than 1% of total ADC)
00252         firstbucket_corr = rd->GetTDC();
00253       }
00254     }
00255   }
00256   if (firstbucket_corr == 999999999) firstbucket_corr = firstbucket;
00257 
00258   float totadc = 0;  //total ADC in the current event
00259   float lateadc = 0; //total ADC after first 3 time buckets
00260   CandStripHandleItr stripItr2(cndevt->GetDaughterIterator());
00261   while (CandStripHandle* strip=dynamic_cast<CandStripHandle*>(stripItr2())){
00262     CandDigitHandleItr digitItr(strip->GetDaughterIterator());
00263     while (CandDigitHandle *digit = dynamic_cast<CandDigitHandle*>(digitItr())){
00264       const RawDigit* rd=dynamic_cast<const RawDigit*>(rddb->At(digit->GetRawDigitIndex()));
00265       totadc += rd->GetADC();
00266       if (rd->GetTDC()>=firstbucket_corr+3){
00267         lateadc += rd->GetADC();
00268       }      
00269     }
00270   }
00271 
00272   if (totadc) ratio = lateadc/totadc;
00273 
00274   return ratio;
00275 }

float NtpSRBleachFiller::GetstraightPHFraction ( const CandEventHandle evt  ) 

Definition at line 278 of file NtpSRBleachFiller.cxx.

References fInitOkay, fStripArray, fUIDMap, CandHandle::GetDaughterIterator(), Msg::kDebug, Msg::kWarning, and MSG.

00278                                                                         {
00279   //
00280   // Purpose: Calculate the fraction of hits in an event that have previous
00281   //          activity in them.
00282   //
00283   // Arguments: CandEventHandle ptr
00284   // 
00285   // Return: straight ph fraction. -1 if error.
00286   //
00287   // Authors: Tom Osiecki (osiecki@mail.hep.utexas.edu)
00288   //
00289   // Creation date: 11/05 
00290   // Modified: 7/10 S. Kasahara to fill striparray,uidmap in constructor
00291   //                initialization to improve performance.
00292   //
00293 
00294   if(!evt) {
00295     MSG("NtpSR",Msg::kWarning) 
00296     << "No CandEventHandle Found in GetstraightPHFraction" << endl;
00297     return -1.0;
00298   }
00299 
00300   if ( !fInitOkay ) {
00301     MSG("NtpSR",Msg::kWarning)
00302       << "Initialized Failed. Cannot GetstraightPHFraction." << std::endl;
00303     return -1.0;
00304   }
00305 
00306   Int_t nstp = 0, nstpevt = 0;
00307   CandStripHandleItr evtstripItr(evt->GetDaughterIterator());
00308   while (CandStripHandle* strip 
00309          = dynamic_cast<CandStripHandle*> (evtstripItr())) {
00310     nstpevt++;
00311     if(fStripArray[fUIDMap[strip -> GetUidInt()]] > -1.0) nstp++;
00312   }
00313 
00314   Float_t ratio = (float) nstp / nstpevt;
00315   MSG("NtpSR",Msg::kDebug) << "GetstraightPHFraction ratio = " << ratio 
00316                            << endl;
00317 
00318   return ratio;
00319 }

bool NtpSRBleachFiller::initStraightPHFraction ( const CandRecord cndrec  )  [private]

Definition at line 323 of file NtpSRBleachFiller.cxx.

References CandRecord::FindCandHandle(), fStripArray, fUIDMap, CandHandle::GetDaughterIterator(), CandHandle::GetNDaughters(), VHS::GetPlane(), VHS::GetStrip(), Msg::kWarning, and MSG.

Referenced by NtpSRBleachFiller().

00323                                                                     {
00324   //
00325   // Purpose: Private method to initialize variables used by 
00326   //          GetstraightPHFraction
00327   //
00328   // Arguments: CandRecord ptr.
00329   // 
00330   // Return: true if success, false if error.
00331   //
00332 
00333   if(!crec) {
00334     MSG("NtpSR",Msg::kWarning) 
00335     << "No CandRecord Found in initStraightPHFraction" << endl;
00336     return false;
00337   }
00338 
00339   const CandStripListHandle *striplisthandle 
00340    = dynamic_cast <const CandStripListHandle*> 
00341     (crec->FindCandHandle("CandStripListHandle"));
00342 
00343   const CandStripListHandle *striplisthandle2 
00344    = dynamic_cast <const CandStripListHandle*> 
00345     (crec->FindCandHandle("CandStripListHandle"));
00346 
00347   if(!striplisthandle) return false;
00348 
00349   TIter stripItr(striplisthandle->GetDaughterIterator());
00350   TIter stripItr2(striplisthandle2->GetDaughterIterator());
00351   
00352   int totalstrips = striplisthandle->GetNDaughters();      
00353   fStripArray = new Int_t[totalstrips];
00354 
00355   for(int zeroout = 0; zeroout < totalstrips; zeroout++) {
00356     fStripArray[zeroout] = -1;
00357   }
00358  
00359   Int_t index = 0;
00360   while(CandStripHandle* strip = dynamic_cast<CandStripHandle*> (stripItr())) {
00361     Int_t uid = strip -> GetUidInt();
00362     
00363     stripItr2.Reset();
00364     while(CandStripHandle* strip2 
00365           = dynamic_cast<CandStripHandle*> (stripItr2())) {
00366       Int_t uid2 = strip2 -> GetUidInt();
00367           
00368       if(uid != uid2 && 
00369          strip -> GetStrip() == strip2 -> GetStrip() && 
00370          strip -> GetPlane() == strip2 -> GetPlane()) {
00371       
00372         if((strip -> GetTime() - strip2 -> GetTime())*1.0e9 > 0.0) {
00373           fStripArray[index]++; 
00374           fUIDMap[uid] = index;
00375         }
00376         
00377       } // Don't compare the same strip to itself.
00378     }
00379     index++;
00380   }
00381 
00382   return true;
00383 }


Member Data Documentation

Definition at line 37 of file NtpSRBleachFiller.h.

Referenced by GetstraightPHFraction(), and NtpSRBleachFiller().

std::map<Int_t, Int_t> NtpSRBleachFiller::fUIDMap [private]

Definition at line 39 of file NtpSRBleachFiller.h.

Referenced by GetstraightPHFraction(), and initStraightPHFraction().


The documentation for this class was generated from the following files:

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1