CDTruthifier Class Reference

#include <CDTruthifier.h>

List of all members.

Public Member Functions

 CDTruthifier ()
 ~CDTruthifier ()
void GetTruthHitInfo (const MomNavigator *mom, TClonesArray *infoarray)
Int_t PdgCode2CalDetParticleType (Int_t pdgCode) const
void RecoStdHep (const MomNavigator *mom, CDPIDInfo *pidInfo) const
Float_t ParticleMomentum (const MomNavigator *mom) const

Private Member Functions

void ExtractAllDigiScintHits (const MomNavigator *mom)
void ExtractAllCandStripHandles (const MomNavigator *mom)
void InitialiseVariables ()
void MakeCompleteStripList (const MomNavigator *mom)

Private Attributes

std::multimap< Int_t,
DigiScintHit * > 
fAllDigiScintHits
std::map< Int_t,
CandStripHandle * > 
fAllCandStripHandles
std::map< Int_t, Int_t > fCompleteStripList

Detailed Description

Definition at line 27 of file CDTruthifier.h.


Constructor & Destructor Documentation

CDTruthifier::CDTruthifier (  ) 

Definition at line 32 of file CDTruthifier.cxx.

00033 {
00034   this->InitialiseVariables();
00035 }

CDTruthifier::~CDTruthifier (  ) 

Definition at line 39 of file CDTruthifier.cxx.

00040 {
00041   //nothing
00042 }


Member Function Documentation

void CDTruthifier::ExtractAllCandStripHandles ( const MomNavigator mom  )  [private]

Definition at line 685 of file CDTruthifier.cxx.

References fAllCandStripHandles, CandRecord::FindCandHandle(), MomNavigator::FragmentIter(), CandHandle::GetDaughterIterator(), Msg::kError, Msg::kFatal, Msg::kVerbose, and MSG.

Referenced by MakeCompleteStripList().

00686 {
00687   //clear the map
00688   fAllCandStripHandles.clear();
00689 
00690   CandRecord* candRecord=0;
00691   TObject* tobj=0;
00692   TIter fragiter=mom->FragmentIter();
00693 
00694   // Get the candRecord.
00695   while( ( tobj = fragiter.Next() ) ) {
00696     candRecord = dynamic_cast<CandRecord*>(tobj);
00697     if(candRecord) break;
00698   }
00699 
00700   // Verify there IS a candRecord.
00701   if(!candRecord) {
00702     MSG("CDTruthifier",Msg::kError)<<"No CandRecord found"<<endl;
00703     return;
00704   }
00705 
00706   //Get CandStripListHandle
00707   CandStripListHandle *cslh = dynamic_cast<CandStripListHandle*>
00708     (candRecord->FindCandHandle("CandStripListHandle"));
00709 
00710   //verify there is a cslh
00711   if(cslh==0) {
00712     MSG("CDTruthifier", Msg::kFatal) 
00713       << "No CandStripListHandle in MOM" << endl;
00714     return;
00715   }
00716 
00717   //Loop over all candstrips in list
00718   TIter stripItr(cslh->GetDaughterIterator());
00719   //TObject* obj;
00720   while(CandStripHandle* csh=dynamic_cast<CandStripHandle*>
00721         (stripItr.Next())){ 
00722     //get the key
00723     Int_t key=csh->GetStripEndId().Build18BitPlnStripKey();
00724 
00725     //add the csh to the map
00726     fAllCandStripHandles.insert(pair<Int_t,CandStripHandle*>(key,csh));
00727   }
00728 
00729   MSG("CDTruthifier",Msg::kVerbose)
00730     <<"cshs size="<<fAllCandStripHandles.size()<<endl;
00731 
00732 }

void CDTruthifier::ExtractAllDigiScintHits ( const MomNavigator mom  )  [private]

Definition at line 622 of file CDTruthifier.cxx.

References PlexStripEndId::Build18BitPlnStripKey(), fAllDigiScintHits, RecDataRecord< T >::FindComponent(), MomNavigator::FragmentIter(), Msg::kError, Msg::kInfo, Msg::kVerbose, MSG, DigiScintHit::Plane(), and DigiScintHit::StripEndId().

Referenced by MakeCompleteStripList().

00623 {
00624   //clear the multimap
00625   fAllDigiScintHits.clear();
00626 
00627   SimSnarlRecord* simsnarl=0;
00628   TObject* tobj=0;
00629   TIter fragiter=mom->FragmentIter();
00630   
00631   // Get the simsnarl.
00632   while( ( tobj = fragiter.Next() ) ) {
00633     simsnarl = dynamic_cast<SimSnarlRecord*>(tobj);
00634     if(simsnarl) break;
00635   }
00636   
00637   // Verify there IS a simsnarl.
00638   if(!simsnarl) {
00639     MSG("CDTruthifier",Msg::kError)<<"No SimSnarl found"<<endl;
00640     return;
00641   }
00642 
00643   // Get the DigiScintHits.
00644   const TObjArray* hitList=dynamic_cast<const TObjArray*>
00645     (simsnarl->FindComponent(0,"DigiScintHits"));
00646   if(hitList==0) {
00647     MSG("CDTruthifier",Msg::kError) << "Can't find scint hit array.\n"; 
00648   }
00649 
00650   MSG("CDTruthifier",Msg::kVerbose)
00651     <<"Found digiScintHits, size="<<hitList->GetSize()<<endl;
00652 
00653   for (Int_t i=0;i<hitList->GetSize();i++){
00654     DigiScintHit* hit=0;
00655     if ((hit=dynamic_cast<DigiScintHit*>(hitList->At(i)))){
00656       
00657       MSG("CDTruthifier",Msg::kVerbose)
00658         <<"i="<<i<<", plane="<<hit->Plane()<<endl;
00659 
00660       //get the key
00661       Int_t key=hit->StripEndId().Build18BitPlnStripKey();
00662 
00663       fAllDigiScintHits.insert(pair<Int_t,DigiScintHit*>(key,hit));
00664     }
00665   }  
00666 
00667   MSG("CDTruthifier",Msg::kVerbose)
00668     <<"mm size="<<fAllDigiScintHits.size()<<endl;
00669 
00670   Int_t counter=0;
00671   for (multimap<Int_t,DigiScintHit*>::iterator digiScintHit=
00672          fAllDigiScintHits.equal_range(40).first;
00673        digiScintHit!=fAllDigiScintHits.equal_range(40).second;
00674        ++digiScintHit){
00675     counter++;
00676     MSG("CDTruthifier",Msg::kInfo)
00677       <<"i="<<counter<<", plane="<<digiScintHit->second->Plane()
00678       <<", DE="<<digiScintHit->second->DE()
00679       <<", PID="<<digiScintHit->second->ParticleId()<<endl;
00680   }
00681 }

void CDTruthifier::GetTruthHitInfo ( const MomNavigator mom,
TClonesArray *  infoarray 
)

Definition at line 53 of file CDTruthifier.cxx.

References bfld::AsString(), bitsPlexIdStrip, DigiScintHit::DE(), DigiScintHit::DS(), MuELoss::e, fAllCandStripHandles, fAllDigiScintHits, fCompleteStripList, CandHandle::GetDaughterIterator(), Truthifier::Instance(), Msg::kDebug, StripEnd::kEast, DigiSignal::kGenuine, Msg::kInfo, DigiSignal::kUnknown, Msg::kVerbose, Msg::kWarning, StripEnd::kWest, MakeCompleteStripList(), MSG, DigiScintHit::ParticleEnergy(), DigiScintHit::ParticleId(), DigiScintHit::Plane(), CDTruthHitInfo::SetEarliestT1(), CDTruthHitInfo::SetLatestT2(), CDTruthHitInfo::SetMainPartEn(), CDTruthHitInfo::SetMainParticle(), CDTruthHitInfo::SetMainPathLength(), CDTruthHitInfo::SetMainT1(), CDTruthHitInfo::SetMainT2(), CDTruthHitInfo::SetMainX1(), CDTruthHitInfo::SetMainX2(), CDTruthHitInfo::SetMainY1(), CDTruthHitInfo::SetMainY2(), CDTruthHitInfo::SetMainZ1(), CDTruthHitInfo::SetMainZ2(), CDTruthHitInfo::SetNumDigiScintHits(), CDTruthHitInfo::SetPmtTruth1(), CDTruthHitInfo::SetPmtTruth2(), CDTruthHitInfo::SetTotalEnDep(), CDTruthHitInfo::SetVaChip1(), CDTruthHitInfo::SetVaChip2(), DigiScintHit::Strip(), DigiScintHit::T1(), DigiScintHit::T2(), DigiScintHit::TrackId(), DigiScintHit::X1(), DigiScintHit::X2(), DigiScintHit::Y1(), DigiScintHit::Y2(), DigiScintHit::Z1(), and DigiScintHit::Z2().

Referenced by CDTrackerModule::Ana().

00055 { 
00056   TClonesArray &truthInfo=*tca;   //clonesarray to be filled
00057   Int_t caCounter=0;
00058   
00059   //get the relations between all the data and truth information for MC
00060   Truthifier truth=Truthifier::Instance(mom);
00061 
00062   //make the complete strip list
00063   this->MakeCompleteStripList(mom);
00064   //protect against empty lists
00065   if (fCompleteStripList.empty()){
00066     MSG("CDTruthifier",Msg::kWarning)
00067       <<"No strips in the CompleteStripList, can't get TruthHitInfo"
00068       <<endl;
00069     return;
00070   }
00071 
00072   //Standard pdg codes
00073   //Int_t electron=11;
00074   Int_t muon=13;
00075 
00076   //loop over the complete strip list (dsh and/or csh)
00077   for (map<Int_t,Int_t>::iterator sl=fCompleteStripList.begin();
00078        sl!=fCompleteStripList.end();++sl){
00079 
00080     //get the key, plane and strip
00081     Int_t key=sl->first;
00082     //Build18BitPlnStripKey=(GetPlane()<<bitsPlexIdStrip) | GetStrip();
00083     Int_t bitsPlexIdStrip=8;
00084     Int_t mask=static_cast<Int_t>(pow(2.,bitsPlexIdStrip)-1);
00085     Int_t strip=mask & key;
00086     Int_t plane=key>>bitsPlexIdStrip;
00087 
00088     //create a new CDTruthHitInfo in the TClonesArray
00089     new(truthInfo[caCounter]) CDTruthHitInfo(plane,strip);
00090 
00091     MSG("CDTruthifier",Msg::kVerbose)
00092       <<"pl="<<plane<<", st="<<strip<<endl;
00093 
00094     Double_t totalEnergyDep=0;
00095     Int_t mainParticle=0;
00096     Double_t mainPathLength=0;
00097     Double_t mainParticleEnergy=-1;
00098     Int_t digiScintHitCounter=0;
00099     Double_t mainT1=0;
00100     Double_t mainX1=0;
00101     Double_t mainY1=0;
00102     Double_t mainZ1=0;
00103     Double_t mainT2=0;
00104     Double_t mainX2=0;
00105     Double_t mainY2=0;
00106     Double_t mainZ2=0;
00107     Double_t initialEarliestT1=1e50;
00108     Double_t earliestT1=initialEarliestT1;
00109     Double_t latestT2=-1e-9;
00110     Bool_t foundFirstMainParticle=false;
00111     Bool_t foundFirstParticle=false;
00112 
00113     //loop over the digiScintHits
00114     for (multimap<Int_t,DigiScintHit*>::iterator hitIter=
00115            fAllDigiScintHits.equal_range(key).first;
00116          hitIter!=fAllDigiScintHits.equal_range(key).second;
00117          ++hitIter){
00118 
00119       //count the digiScintHits
00120       digiScintHitCounter++;
00121 
00122       //get the pointer to the dsh
00123       DigiScintHit* dsh=hitIter->second;
00124 
00125       //sanity check the digiScintHits actually belong to the strip
00126       //and are not just connected by shared pmts or something
00127       if (!(plane==dsh->Plane() &&
00128             strip==dsh->Strip())) {
00129         MSG("CDTruthifier",Msg::kWarning)
00130           <<"Ahhhhhhhh, wrong plane and strip"<<endl;
00131       }
00132       
00133       //get the dsh info
00134       const Double_t energyDep=dsh->DE();
00135       const Double_t pathLength=dsh->DS();
00136       const Double_t energyParticle=dsh->ParticleEnergy();
00137       const Int_t particleId=dsh->ParticleId();
00138       const Int_t trackId=dsh->TrackId();
00139       const Double_t T1=dsh->T1();
00140       const Double_t T2=dsh->T2();
00141       
00142       //sum up the energy depositions of the different particles
00143       //in this strip
00144       totalEnergyDep+=energyDep;
00145 
00146       //look for particles other than electrons and muons
00147       if (particleId!=11 && particleId!=-11 && 
00148           particleId!=13 && particleId!=-13 &&
00149           particleId!=211 && particleId!=-211 && //pi 
00150           particleId!=2212 && particleId!=-2212 && //proton
00151           particleId!=1002001000 && //what is this???
00152           particleId!=1003001000 && //what is this???
00153           particleId!=1004001000 && //what is this???
00154           particleId!=1004002000){ //what is this??? alpha nucleus?
00155         MSG("CDTruthifier",Msg::kInfo)
00156           <<endl<<endl
00157           <<"Found particles other than expected"<<endl
00158           <<digiScintHitCounter
00159           <<" DE="<<energyDep*1000
00160           <<", DS="<<pathLength*100
00161           <<", pId="<<particleId
00162           <<", pEn="<<energyParticle*1000
00163           <<", tEn="<<totalEnergyDep*1000
00164           <<", tId="<<trackId
00165           <<", mP="<<mainParticle
00166           <<", mPL="<<mainPathLength*100<<endl<<endl;
00167       }
00168 
00169       //set the times
00170       //check if earliest or latest
00171       if (T1<earliestT1) earliestT1=T1;
00172       if (T2>latestT2) latestT2=T2;
00173 
00174       //this section sets the variables in the case where there
00175       //is no main particle
00176       //they are set to the first particle in the list, dodgy???        
00177       if (!foundFirstParticle){
00178         foundFirstParticle=true;
00179 
00180         //set main particle and energy
00181         mainParticle=particleId;
00182         mainParticleEnergy=energyParticle;
00183         
00184         //set the ?1s
00185         mainT1=dsh->T1();
00186         mainX1=dsh->X1();
00187         mainY1=dsh->Y1();
00188         mainZ1=dsh->Z1();
00189         
00190         //set the path length
00191         mainPathLength=pathLength;
00192         //set the ?2s
00193         mainT2=dsh->T2();
00194         mainX2=dsh->X2();
00195         mainY2=dsh->Y2();
00196         mainZ2=dsh->Z2();
00197       }
00198 
00199       //check if the "main" particle
00200       //need a better way to do this! Need to know the mother particle
00201       if (abs(particleId)==muon){
00202 
00203         static Int_t firstPlane=-1;
00204         static Int_t firstStrip=-1;
00205 
00206         //for a given particle you can get multiple DigiScintHits 
00207         //per strip so need to be smart in how this is handled
00208         if (!foundFirstMainParticle){
00209           foundFirstMainParticle=true;
00210  
00211           //only set main particle and energy once
00212           mainParticle=particleId;
00213           mainParticleEnergy=energyParticle;
00214 
00215           //only set the ?1s once too
00216           mainT1=dsh->T1();
00217           mainX1=dsh->X1();
00218           mainY1=dsh->Y1();
00219           mainZ1=dsh->Z1();
00220 
00221           //set the path length
00222           //in the case of multiple hits this will be summed below
00223           mainPathLength=pathLength;
00224           //set the ?2s
00225           mainT2=dsh->T2();
00226           mainX2=dsh->X2();
00227           mainY2=dsh->Y2();
00228           mainZ2=dsh->Z2();
00229 
00230           //set control variables
00231           firstPlane=plane;
00232           firstStrip=strip;
00233         }
00234         else{
00235 
00236           //set the message level variable
00237           Msg::LogLevel_t msgLevel=Msg::kDebug;
00238 
00239           //check that the plane and strip are the same as the
00240           //first muon
00241           if (!(plane==firstPlane && strip==firstStrip)){
00242             //set the message level so the next message prints
00243             msgLevel=Msg::kWarning;
00244             MSG("CDTruthifier",Msg::kWarning)
00245               <<endl
00246               <<"Plane and strip are not the same as the first main"
00247               <<"particle, First (pl,st)=("<<firstPlane<<","<<firstStrip
00248               <<") New=("<<plane<<","<<strip<<")"
00249               <<endl;
00250           }
00251 
00252           MSG("CDTruthifier",msgLevel)
00253             <<"Values already set:"<<endl
00254             <<"DigiScintHit="<<digiScintHitCounter
00255             <<endl
00256             <<"  Current:"
00257             <<" (pl,st)=("<<plane<<","<<strip<<")"
00258             <<" PL="<<mainPathLength*100
00259             <<", PE="<<mainParticleEnergy*1000
00260             <<endl
00261             <<"  T1="<<mainT1*1e9
00262             <<", X1="<<mainX1*100
00263             <<", Y1="<<mainY1*100
00264             <<", Z1="<<mainZ1*100
00265             <<endl
00266             <<"  T2="<<mainT2*1e9
00267             <<", X2="<<mainX2*100
00268             <<", Y2="<<mainY2*100
00269             <<", Z2="<<mainZ2*100
00270             <<endl
00271             <<"  New:"
00272             <<" (pl,st)=("<<dsh->Plane()<<","<<dsh->Strip()<<")"
00273             <<" PL="<<pathLength*100
00274             <<", PE="<<energyParticle*1000
00275             <<", tEnDep="<<totalEnergyDep*1000<<"("<<energyDep*1000<<")"
00276             <<", partId="<<particleId
00277             <<", trkId="<<trackId
00278             <<endl
00279             <<"  T1="<<dsh->T1()*1e9
00280             <<"  X1="<<dsh->X1()*100
00281             <<", Y1="<<dsh->Y1()*100
00282             <<", Z1="<<dsh->Z1()*100
00283             <<endl
00284             <<"  T2="<<dsh->T2()*1e9
00285             <<"  X2="<<dsh->X2()*100
00286             <<", Y2="<<dsh->Y2()*100
00287             <<", Z2="<<dsh->Z2()*100
00288             <<endl;
00289 
00290           //only change the values of those below if on same strip
00291           //and plane as the first main particle to be found
00292           if (plane==firstPlane && strip==firstStrip){
00293             //this is not an "else" of the above because of the 
00294             //large message
00295 
00296             MSG("CDTruthifier",Msg::kDebug)
00297               <<"Comparing path length for multiple DigiScintHits"<<endl
00298               <<" for a single particle in a single strip:"<<endl
00299               <<"DigiScintHit="<<digiScintHitCounter
00300               <<endl
00301               <<"  Current:"
00302               <<" (pl,st)=("<<plane<<","<<strip<<")"
00303               <<" PL="<<mainPathLength*100
00304               <<endl
00305               <<"  New:"
00306               <<" (pl,st)=("<<dsh->Plane()<<","<<dsh->Strip()<<")"
00307               <<" PL="<<(mainPathLength+pathLength)*100
00308               <<"("<<pathLength*100<<")"
00309               <<endl;
00310 
00311             //set the path length
00312             //in the case of multiple hits it is summed
00313             mainPathLength+=pathLength;
00314             
00315             //the ?2s should be set to those of the last dsh  
00316             //assuming ordered in time
00317             if (mainT2<=dsh->T2()){
00318               mainT2=dsh->T2();
00319               mainX2=dsh->X2();
00320               mainY2=dsh->Y2();
00321               mainZ2=dsh->Z2();
00322             }
00323             else{
00324               MSG("CDTruthifier",Msg::kWarning)
00325                 <<endl
00326                 <<"(pl,st)=("<<dsh->Plane()<<","<<dsh->Strip()<<")"
00327                 <<" Multiple dsh for particle in given strip"<<endl
00328                 <<" are not time ordered, this may give false"
00329                 <<" reconstruction. Beware!"<<endl;
00330             }
00331           }
00332         }
00333       }
00334 
00335       //general message
00336       MSG("CDTruthifier",Msg::kVerbose)
00337         <<digiScintHitCounter
00338         <<" DE="<<energyDep*1000
00339         <<", DS="<<pathLength*100
00340         <<", pId="<<particleId
00341         <<", pEn="<<energyParticle*1000
00342         <<", tEn="<<totalEnergyDep*1000
00343         <<", tId="<<trackId
00344         <<", mP="<<mainParticle
00345         <<", mPL="<<mainPathLength*100<<endl;
00346     }
00347 
00348     Int_t finalPmtTruth1=DigiSignal::kUnknown;
00349     Int_t finalPmtTruth2=DigiSignal::kUnknown;
00350     Int_t vaChip1=-1;
00351     Int_t vaChip2=-1;
00352 
00353     //create a pointer for current csh
00354     CandStripHandle* csh=0;
00355 
00356     //check that csh exists (it often will not)
00357     if ((csh=fAllCandStripHandles[key])){
00358 
00359       //get iterator over csh daughters
00360       TIter cshItr(csh->GetDaughterIterator());
00361       
00362       //counter for the digits
00363       Int_t digitCounter=0;
00364 
00365       //now loop over the canddigits
00366       while(CandDigitHandle* cdh=dynamic_cast<CandDigitHandle*>
00367             (cshItr.Next())){
00368         //count the digits
00369         digitCounter++;
00370         
00371         DigiSignal::DigiPmtTruth_t pmtTruth=truth.
00372           GetSignalTruthFlags(*cdh);
00373         
00374         //set the final pmt truth
00375         //this is hard to deal on a whole strip basis
00376         //you could have crosstalk on one end but genuine on 
00377         //the other
00378         //this just sets all the bits that it finds
00379         //how to interpret it can be done in the analysis
00380         if (cdh->GetPlexSEIdAltL().GetEnd()==StripEnd::kEast){
00381           finalPmtTruth1|=pmtTruth;//OR it with itself
00382           vaChip1=cdh->GetChannelId().GetVaChip();
00383         }
00384         else if (cdh->GetPlexSEIdAltL().GetEnd()==StripEnd::kWest){
00385           finalPmtTruth2|=pmtTruth;
00386           vaChip2=cdh->GetChannelId().GetVaChip();
00387         }
00388         
00389         //stop assigning the value of 65535
00390         if (vaChip2>2) vaChip2=-2;//use -2 to distinguish between when
00391         if (vaChip1>2) vaChip1=-2;//not set at all and when qie
00392         
00393         MSG("CDTruthifier",Msg::kVerbose)
00394           <<"Dig="<<digitCounter
00395           <<", va1="<<vaChip1
00396           <<", va2="<<vaChip2
00397           <<", pmtTr="<<pmtTruth
00398           <<", T="<<cdh->GetTime()*1e9
00399           <<", el="<<ElecType::AsString(cdh->GetChannelId().
00400                                         GetElecType())
00401           <<endl;
00402       }//end of while
00403       
00404       //reset all the energies if there is no genuine hit
00405       //you can get given the energy on a strip that caused a 
00406       //crosstalk hit, thus double counting
00407       //NOTE: This must be inside the "if csh" since
00408       //might have genuine digiScintHit but no digitisation
00409       //start by taking the OR of the two stripends
00410       if (!(((finalPmtTruth1 | finalPmtTruth2) & 
00411              DigiSignal::kGenuine)==DigiSignal::kGenuine)){
00412         mainParticle=0;
00413         mainParticleEnergy=-1;
00414         mainPathLength=0;
00415         mainT1=0;
00416         mainX1=0;
00417         mainY1=0;
00418         mainZ1=0;
00419         mainT2=0;
00420         mainX2=0;
00421         mainY2=0;
00422         mainZ2=0;
00423         totalEnergyDep=0;
00424       }
00425 
00426     }//end of if csh
00427     else{
00428       //set truth as genuine for strips with no digitisation
00429       finalPmtTruth1=DigiSignal::kGenuine;
00430       finalPmtTruth2=DigiSignal::kGenuine;
00431 
00432       //leave the vaChips as initialised, no need to do it here
00433       //vaChip1=-1;
00434       //vaChip2=-1;
00435     }
00436 
00437     MSG("CDTruthifier",Msg::kVerbose)
00438       <<"Final:"
00439       <<", part="<<mainParticle
00440       <<", pmtTr1="<<finalPmtTruth1
00441       <<", pmtTr2="<<finalPmtTruth2
00442       <<", mainPartEn="<<mainParticleEnergy*1000
00443       <<", totEn="<<totalEnergyDep*1000
00444       <<endl;
00445     
00446     //change the earliest time to some
00447     if (earliestT1==initialEarliestT1) earliestT1=-1e-9;
00448 
00449     //get a pointer to the current thi in the tclonesarray
00450     CDTruthHitInfo* thi=(CDTruthHitInfo*)(truthInfo.At(caCounter));
00451 
00452     //fill the current CDTruthHitInfo 
00453     thi->SetPmtTruth1(finalPmtTruth1);
00454     thi->SetPmtTruth2(finalPmtTruth2);
00455     thi->SetMainParticle(mainParticle);
00456     thi->SetTotalEnDep(totalEnergyDep);
00457     thi->SetMainPartEn(mainParticleEnergy);
00458     thi->SetMainPathLength(mainPathLength);
00459     thi->SetVaChip1(vaChip1);
00460     thi->SetVaChip2(vaChip2);
00461     thi->SetMainT1(mainT1);
00462     thi->SetMainX1(mainX1);
00463     thi->SetMainY1(mainY1);
00464     thi->SetMainZ1(mainZ1);
00465     thi->SetMainT2(mainT2);
00466     thi->SetMainX2(mainX2);
00467     thi->SetMainY2(mainY2);
00468     thi->SetMainZ2(mainZ2);
00469     thi->SetEarliestT1(earliestT1);
00470     thi->SetLatestT2(latestT2);
00471     thi->SetNumDigiScintHits(digiScintHitCounter);
00472 
00473     //increment the clones array counter
00474     caCounter++;
00475   }
00476   //kUnknown          = 0x00, // Can happen: known cause is 0 charge
00477   // but random noise passes sparsification thresh.
00478   //kGenuine          = 0x01, //A real hit from real gosh-darn physics.
00479   //kDarkNoise        = 0x02, // Dark noise from the tube.
00480   //kFibreLight       = 0x04, // Random [singles] from a fibre. 
00481   //kCrosstalk        = 0x08, // A generic crosstalk hit.
00482   //kCrosstalkOptical = 0x10, // A crosstalk hit, specifically from
00483 //kLeakFromNextBucket = 0x20, // The next bucket leaked charge back to this one
00484 //kLeakFromPrevBucket = 0x40  // The prev bucket leaked charge forward to this one
00485 }

void CDTruthifier::InitialiseVariables (  )  [private]

Definition at line 46 of file CDTruthifier.cxx.

00047 {
00048   //nothing
00049 }

void CDTruthifier::MakeCompleteStripList ( const MomNavigator mom  )  [private]

Definition at line 736 of file CDTruthifier.cxx.

References ExtractAllCandStripHandles(), ExtractAllDigiScintHits(), fAllCandStripHandles, fAllDigiScintHits, fCompleteStripList, Msg::kDebug, and MSG.

Referenced by GetTruthHitInfo().

00737 {
00738   //clear the list from previous events
00739   fCompleteStripList.clear();
00740   
00741   //extract the digiScintHits and csh from mom
00742   this->ExtractAllDigiScintHits(mom);
00743   this->ExtractAllCandStripHandles(mom);
00744   
00745   //loop over all the digiScintHits
00746   //could try and speed this up by jumping to the end of each
00747   //key section using upper_bound(key)
00748   Int_t lastKey=-1;
00749   for (multimap<Int_t,DigiScintHit*>::iterator digiScintHit=
00750          fAllDigiScintHits.begin();
00751        digiScintHit!=fAllDigiScintHits.end();
00752        ++digiScintHit){
00753 
00754     //get the key
00755     Int_t key=digiScintHit->first;
00756 
00757     //check if key has already been added to map
00758     //doing this is quicker than searching the map
00759     //everytime
00760     if (static_cast<Int_t>(key)==lastKey) continue;
00761     lastKey=static_cast<Int_t>(key);
00762     
00763     //add it to the list or just increment the number of times
00764     //it was accessed
00765     fCompleteStripList[key]++;
00766   }
00767 
00768   //loop over all the csh
00769   for (map<Int_t,CandStripHandle*>::iterator cshIter=
00770          fAllCandStripHandles.begin();
00771        cshIter!=fAllCandStripHandles.end();
00772        ++cshIter){
00773 
00774     //get the key
00775     Int_t key=cshIter->first;
00776 
00777     //add it to the list or just increment the number of times
00778     //it was accessed
00779     fCompleteStripList[key]++;
00780   }
00781 
00782   MSG("CDTruthifier",Msg::kDebug)
00783     <<"Complete list size="<<fCompleteStripList.size()
00784     <<", all csh size="<<fAllCandStripHandles.size()
00785     <<", all dsh size="<<fAllDigiScintHits.size()<<endl;
00786 }

Float_t CDTruthifier::ParticleMomentum ( const MomNavigator mom  )  const

Definition at line 546 of file CDTruthifier.cxx.

References RecDataRecord< T >::FindComponent(), MomNavigator::GetFragment(), Msg::kVerbose, Msg::kWarning, and MSG.

Referenced by CDTrackerModule::Ana().

00547 {
00548   //get the sim snarl record
00549   SimSnarlRecord *ssr= 
00550     dynamic_cast<SimSnarlRecord*>(mom->GetFragment("SimSnarlRecord"));
00551 
00552   Float_t particleMomentum=0;
00553   
00554   if (ssr){ 
00555     const TClonesArray* ctca=dynamic_cast<const TClonesArray*>
00556       (ssr->FindComponent("TClonesArray","StdHep"));
00557     
00558     Int_t num=ctca->GetEntries();
00559     MSG("CDTruthifier",Msg::kVerbose)
00560       <<"StdHep Entries="<<num<<endl;
00561 
00562     for(Int_t i=0;i<num;i++){
00563       TParticle* part=dynamic_cast<TParticle*>((*ctca)[i]);
00564       
00565       MSG("CDTruthifier",Msg::kVerbose)
00566         <<"i="<<i<<", status code="<<part->GetStatusCode()
00567         <<", pdg code="<<part->GetPdgCode()
00568         <<", en="<<part->Energy()<<", P="<<part->P()<<endl;
00569 
00570       //set the variables
00571       particleMomentum=part->P();
00572 
00573       if (i==1){
00574         MSG("CDTruthifier",Msg::kWarning)
00575           <<"More than one particle in simsnarlrecord"<<endl
00576           <<"i="<<i<<", status code="<<part->GetStatusCode()
00577           <<", pdg code="<<part->GetPdgCode()
00578           <<", en="<<part->Energy()<<", P="<<part->P()<<endl;
00579       }
00580     }
00581   }
00582   else{
00583     MSG("CDTruthifier",Msg::kWarning)
00584       <<"No simsnarl record found"<<endl;
00585   }
00586   
00587   return particleMomentum;
00588 }

Int_t CDTruthifier::PdgCode2CalDetParticleType ( Int_t  pdgCode  )  const

Definition at line 592 of file CDTruthifier.cxx.

References CalDetParticleType::kElectron, CalDetParticleType::kKaon, CalDetParticleType::kMuon, CalDetParticleType::kPion, CalDetParticleType::kProton, CalDetParticleType::kUnknown, Msg::kWarning, and MSG.

Referenced by RecoStdHep().

00593 {
00594   Int_t cdParticleType=CalDetParticleType::kUnknown;
00595 
00596   if (abs(pdgCode)==13){
00597     cdParticleType=CalDetParticleType::kMuon;
00598   }
00599   else if (abs(pdgCode)==211){
00600     cdParticleType=CalDetParticleType::kPion;
00601   }
00602   else if (abs(pdgCode)==11){
00603     cdParticleType=CalDetParticleType::kElectron;
00604   }
00605   else if (abs(pdgCode)==2211){
00606     cdParticleType=CalDetParticleType::kProton;
00607   }
00608   else if (abs(pdgCode)==321){
00609     cdParticleType=CalDetParticleType::kKaon;
00610   }
00611   else{
00612     cdParticleType=CalDetParticleType::kUnknown;
00613     MSG("CDTruthifier",Msg::kWarning)
00614       <<"Particle PDG code not recognised="<<pdgCode<<endl;
00615   }
00616     
00617   return cdParticleType;
00618 }

void CDTruthifier::RecoStdHep ( const MomNavigator mom,
CDPIDInfo pidInfo 
) const

Definition at line 490 of file CDTruthifier.cxx.

References RecDataRecord< T >::FindComponent(), MomNavigator::GetFragment(), Msg::kVerbose, Msg::kWarning, MSG, PdgCode2CalDetParticleType(), CDPIDInfo::SetPIDType(), and CDPIDInfo::SetTrueParticleMomentum().

Referenced by CDTrackerModule::Ana().

00492 {
00493   //get the sim snarl record
00494   SimSnarlRecord *ssr= 
00495     dynamic_cast<SimSnarlRecord*>(mom->GetFragment("SimSnarlRecord"));
00496   if (ssr){ 
00497     const TClonesArray* ctca=dynamic_cast<const TClonesArray*>
00498       (ssr->FindComponent("TClonesArray","StdHep"));
00499     
00500     Int_t num=ctca->GetEntries();
00501     MSG("CDTruthifier",Msg::kVerbose)
00502       <<"StdHep Entries="<<num<<endl;
00503 
00504     Int_t pdgCode=0;
00505     Float_t particleMomentum=0;
00506 
00507     for(Int_t i=0;i<num;i++){
00508       TParticle* part=dynamic_cast<TParticle*>((*ctca)[i]);
00509       
00510       MSG("CDTruthifier",Msg::kVerbose)
00511         <<"i="<<i<<", status code="<<part->GetStatusCode()
00512         <<", pdg code="<<part->GetPdgCode()
00513         <<", en="<<part->Energy()<<", P="<<part->P()<<endl;
00514 
00515       //set the variables
00516       pdgCode=part->GetPdgCode();
00517       particleMomentum=part->P();
00518 
00519       if (i==1){
00520         MSG("CDTruthifier",Msg::kWarning)
00521           <<"More than one particle in simsnarlrecord"<<endl
00522           <<"i="<<i<<", status code="<<part->GetStatusCode()
00523           <<", pdg code="<<part->GetPdgCode()
00524           <<", en="<<part->Energy()<<", P="<<part->P()<<endl;
00525       }
00526     }
00527 
00528     //set the pid info
00529     if (pidInfo){
00530       pidInfo->SetTrueParticleMomentum(particleMomentum);
00531       pidInfo->SetPIDType(this->PdgCode2CalDetParticleType(pdgCode));
00532     }
00533     else{
00534       MSG("CDTruthifier",Msg::kWarning)
00535         <<"CDPIDInfo pointer="<<pidInfo<<", can't set truth info"<<endl;
00536     }
00537   }
00538   else{
00539     MSG("CDTruthifier",Msg::kWarning)
00540       <<"CDTruthifier::RecoStdHep:: No simsnarl record found"<<endl;
00541   }
00542 }


Member Data Documentation

std::multimap<Int_t,DigiScintHit*> CDTruthifier::fAllDigiScintHits [private]

Definition at line 50 of file CDTruthifier.h.

Referenced by ExtractAllDigiScintHits(), GetTruthHitInfo(), and MakeCompleteStripList().

std::map<Int_t,Int_t> CDTruthifier::fCompleteStripList [private]

Definition at line 52 of file CDTruthifier.h.

Referenced by GetTruthHitInfo(), and MakeCompleteStripList().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1