TruthHelper Class Reference
[DataUtil]

#include <TruthHelper.h>

List of all members.

Public Member Functions

 TruthHelper ()
 TruthHelper (const MomNavigator *mom)
 ~TruthHelper ()
Bool_t IsPrimaryShowerPart (const TParticle *part)
Int_t GetNeuId (Int_t trackId)
Int_t GetNextNeuId (Int_t trackId)
Int_t GetNeuKinIndex (Int_t trackId)
const Float_t * GetP4Neu (Int_t neuId)
const Float_t * GetP4Shw (Int_t neuId)
const Float_t * GetP4Mu1 (Int_t neuId)
const Float_t * GetP4Mu2 (Int_t neuId)
const Float_t * GetP4El1 (Int_t neuId)
Int_t Stripxtalk (CandStripHandle *csh)
Int_t GetBestTrackIdMatch (CandTrackHandle &cth)
Float_t TrackPurity (CandTrackHandle &cth, Int_t trackId)
Float_t TrackCompleteness (CandTrackHandle &cth, CandSliceHandle &csh)
Float_t TrackCompleteness (CandTrackHandle &cth)
Float_t StripPurity (CandStripHandle *csh)
Int_t GetStripNeuIndex (CandStripHandle *csh)
Int_t GetBestNeuMatch (const CandDigitHandle &cdh)
Int_t GetBestNeuMatch (const CandStripHandle &csh)
Int_t GetBestShowerNeuMatch (CandShowerHandle &csh)
Float_t ShowerPurity (CandShowerHandle &csh, Int_t neuId)
Float_t ShowerCompleteness (CandShowerHandle &cshwh, CandSliceHandle &csh)
 Shower completeness within the given slice.
Float_t ShowerCompleteness (CandShowerHandle &cshwh)
 Shower completeness within the whole snarl.
Float_t ShowerCompletenessAllStrips (CandShowerHandle &cshwh, CandSliceHandle &csh)
 Shower completeness within the given slice, with no pulse height cut.
Float_t ShowerCompletenessAllStrips (CandShowerHandle &cshwh)
 Shower completeness within the whole snarl, with no pulse height cut.
Int_t GetClosestNeuVtx (CandRecoHandle &crh)
Int_t SliceTrueStrip (CandSliceHandle &csh)
Int_t TruthSliceNum ()
Double_t TrueNeuE (CandSliceHandle &csh)
Int_t GetBestSliceNeuMatch (CandSliceHandle &csh)
Int_t GetBestEventNeuMatch (CandEventHandle &ceh)
Float_t EventPurity (CandEventHandle &ceh, Int_t neuId)
Float_t EventCompleteness (CandEventHandle &cevth, CandSliceHandle &csh)
 Event completeness within the given slice.
Float_t EventCompleteness (CandEventHandle &cevth)
 Event completeness within the whole snarl.
Float_t EventCompletenessAllStrips (CandEventHandle &cevth, CandSliceHandle &csh)
 Event completeness within the given slice, with no pulse height cut.
Float_t EventCompletenessAllStrips (CandEventHandle &cevth)
 Event completeness within the whole snarl, with no pulse height cut.
Float_t secondNEU (CandSliceHandle &csh)
Int_t NumNeu (CandSliceHandle &csh)
Float_t SliceCompleteness (CandSliceHandle &csh)
Float_t SlicePurity (CandSliceHandle &csh)
Float_t SliceCompleteness_xtalk (CandSliceHandle &csh)
Float_t SlicePurity_xtalk (CandSliceHandle &csh)
Float_t SliceCompleteness_MaxTimeGap (CandSliceHandle &csh, Int_t mincharge)
Float_t SlicePurity_MaxTimeGap (CandSliceHandle &csh, Int_t mincharge)
Int_t SliceTrueStripxtalk (CandSliceHandle &csh)
Float_t GetTrackMaxE (CandTrackHandle &cth)
Float_t GetTrackMinE (CandTrackHandle &cth)
Float_t GetTrackMaxE2 (CandTrackHandle &cth)
Float_t GetTrackMinE2 (CandTrackHandle &cth)

Static Public Member Functions

static Bool_t IsNeutrino (const TParticle *part)
static Bool_t IsMuon (const TParticle *part)
static Bool_t IsPion (const TParticle *part)
static Bool_t IsP0 (const TParticle *part)
static Bool_t IsGamma (const TParticle *part)
static Bool_t IsProton (const TParticle *part)
static Bool_t IsNeutron (const TParticle *part)
static Bool_t IsElectron (const TParticle *part)
static Bool_t IsDocStatus (const TParticle *part)

Private Member Functions

Float_t EventCompletenessImp (CandEventHandle &ceh, CandSliceHandle *csh, bool useAllStrips)
 Event completeness implementation.
Float_t ShowerCompletenessImp (CandShowerHandle &cshwh, CandSliceHandle *csh, bool useAllStrips)
 Shower completeness implementation.

Private Attributes

const MomNavigatorfMom
Float_t m_p4Neu [4]
Float_t m_p4Mu1 [4]
Float_t m_p4Mu2 [4]
Float_t m_p4El1 [4]
Float_t m_p4Shw [4]

Detailed Description

Author:
(last to touch it)
Author
rodriges
Version:
Revision
1.12
Date:
Date
2008/11/05 17:42:27

Contact: musser

Created on:

Id
TruthHelper.h,v 1.12 2008/11/05 17:42:27 rodriges Exp

Definition at line 42 of file TruthHelper.h.


Constructor & Destructor Documentation

TruthHelper::TruthHelper (  ) 

Definition at line 33 of file TruthHelper.cxx.

00034 {
00035 }

TruthHelper::TruthHelper ( const MomNavigator mom  ) 

Definition at line 37 of file TruthHelper.cxx.

00038   :fMom(mom)
00039 {
00040 }

TruthHelper::~TruthHelper (  ) 

Definition at line 42 of file TruthHelper.cxx.

00043 {
00044 }


Member Function Documentation

Float_t TruthHelper::EventCompleteness ( CandEventHandle cevth  ) 

Event completeness within the whole snarl.

Returns the completeness of event cevth defined over the strips in the whole snarl. The value returned is:

(PE in reco event) / (PE in true event ending up in strips above PE cut)

ie, Only slice strips with charge greater than the minimum required for event reconstruction are used in the denominator

The value of the PE cut is taken from the primary shower in the event. If there is no shower, the value used is zero, ie the denominator is formed from all strips

Definition at line 426 of file TruthHelper.cxx.

References EventCompletenessImp().

00427 {
00428   return EventCompletenessImp(ceh, 0, false);
00429 }

Float_t TruthHelper::EventCompleteness ( CandEventHandle cevth,
CandSliceHandle csh 
)

Event completeness within the given slice.

Returns the completeness of event cevth defined over the strips in the slice csh. The value returned is:

(PE in reco event) / (PE in true event ending up in strips above PE cut)

ie, Only slice strips with charge greater than the minimum required for event reconstruction are used in the denominator.

The value of the PE cut is taken from the primary shower in the event. If there is no shower, the value used is zero, ie the denominator is formed from all strips

Definition at line 420 of file TruthHelper.cxx.

References EventCompletenessImp().

00421 {
00422   return EventCompletenessImp(ceh, &csh, false);
00423 }

Float_t TruthHelper::EventCompletenessAllStrips ( CandEventHandle cevth  ) 

Event completeness within the whole snarl, with no pulse height cut.

Returns the completeness of event cevth defined over the strips in the whole snarl. The value returned is:

(PE in reco event) / (PE in true event ending up in any strip)

Definition at line 438 of file TruthHelper.cxx.

References EventCompletenessImp().

00439 {
00440   return EventCompletenessImp(ceh, 0, true);
00441 }

Float_t TruthHelper::EventCompletenessAllStrips ( CandEventHandle cevth,
CandSliceHandle csh 
)

Event completeness within the given slice, with no pulse height cut.

Returns the completeness of event cevth defined over the strips in the slice csh. The value returned is:

(PE in reco event) / (PE in true event ending up in any strip)

Definition at line 431 of file TruthHelper.cxx.

References EventCompletenessImp().

00433 {
00434   return EventCompletenessImp(ceh, &csh, true);
00435 }

Float_t TruthHelper::EventCompletenessImp ( CandEventHandle ceh,
CandSliceHandle csh,
bool  useAllStrips 
) [private]

Event completeness implementation.

Returns the completeness of event ceh.

If csh is 0, the completeness over the whole snarl is returned, otherwise the completeness over the slice csh is returned.

If useAllStrips is true, the denominator in the completeness is formed from all strips, otherwise only strips above the PE cut are used in the denominator

Definition at line 443 of file TruthHelper.cxx.

References Truthifier::DigitIsOnlyCrosstalk(), CandRecord::FindCandHandle(), fMom, GetBestEventNeuMatch(), CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), DigiSignal::GetHit(), CandShowerHandle::GetMinStripPE(), GetNextNeuId(), DigiSignal::GetNumberOfHits(), CandEventHandle::GetPrimaryShower(), Truthifier::GetSignal(), Truthifier::Instance(), CalDigitType::kPE, and DigiScintHit::TrackId().

Referenced by EventCompleteness(), and EventCompletenessAllStrips().

00446 {
00447   Float_t truePE=0;
00448   Float_t evtPE=0;
00449   const Truthifier & truth = Truthifier::Instance(fMom);
00450   Int_t neuId= GetBestEventNeuMatch(ceh);
00451   Int_t nextneuId= GetNextNeuId(neuId);
00452 
00453   SimSnarlRecord *ssr = 
00454     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
00455   if (!ssr)return 0.0;
00456   //  const TClonesArray* ctca =
00457   //   dynamic_cast<const TClonesArray*>
00458   //   (ssr->FindComponent("TClonesArray","StdHep"));
00459   
00460   TIter evtstripitr(ceh.GetDaughterIterator());
00461 
00462   // (PAR) In the case where we're only using strips above the PE cut,
00463   // we need the minimum strip PE used for the shower reco to get the
00464   // event completeness, but adding it to CandEvent is too hard, so
00465   // just use the PE cut used for the shower, if there is one. If
00466   // there's not, use zero
00467   CandShowerHandle* cshwh=ceh.GetPrimaryShower();
00468   Double_t minStripPE= cshwh ? cshwh->GetMinStripPE() : 0.;
00469 
00470   // (PAR) TIter::TIter() is protected, so we can't create a blank
00471   // iterator that way. This works though
00472   TIter striplistitr((TIterator*)0);
00473 
00474   if(csh) {
00475     // (PAR) Only loop through strips in the slice
00476     striplistitr=csh->GetDaughterIterator();
00477   } else {
00478     // (PAR) Loop through all strips in the snarl
00479     CandRecord *crec = dynamic_cast<CandRecord *>
00480       (fMom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00481     
00482     CandStripListHandle *cstriplh = dynamic_cast<CandStripListHandle *>
00483       (crec->FindCandHandle("CandStripListHandle"));
00484     striplistitr=cstriplh->GetDaughterIterator();
00485   }
00486 
00487   while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(striplistitr())) {
00488     // (PAR)
00489     // Only use slice strips with charge greater than the minimum
00490     // required for showers, if requested. This means that the event completeness
00491     // is defined as:
00492     //
00493     // (PE in reco event) / (PE in true event ending up in strips above PE cut)
00494     //
00495     if ((!useAllStrips) && 
00496         cstriph->GetCharge(CalDigitType::kPE) < minStripPE) continue;
00497 
00498     TIter digitItr(cstriph->GetDaughterIterator());
00499     Bool_t found=false;
00500     while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
00501       const CandDigitHandle tcdh = *cdh;
00502       if(!truth.DigitIsOnlyCrosstalk(tcdh) && !found){
00503         const DigiSignal * signal = truth.GetSignal(tcdh);
00504         if(signal){
00505           for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
00506             const DigiScintHit * hit = signal->GetHit(i);
00507             if(hit){
00508               Int_t track = abs(hit->TrackId());
00509               //              TParticle* part = dynamic_cast<TParticle*>((*ctca)[track]);
00510               if(track> neuId && track<nextneuId){
00511                 //              if(part->GetStatusCode()==1) {
00512                   found=true;
00513                   //    }
00514               }
00515             }
00516           }         
00517         }
00518       }
00519     }
00520     if(found) {
00521       truePE+=cstriph->GetCharge();
00522       evtstripitr.Reset();
00523       Int_t plane=cstriph->GetPlane();
00524       Int_t strip=cstriph->GetStrip();
00525       while (CandStripHandle* cevtstriph = dynamic_cast<CandStripHandle*>(evtstripitr())) {
00526         if(cevtstriph->GetPlane()==plane && cevtstriph->GetStrip()==strip){
00527           evtPE+=cstriph->GetCharge();
00528           break;
00529         }
00530       }
00531     }
00532   }
00533   if(truePE>0) return (evtPE/truePE);
00534   return 0.;
00535 }

Float_t TruthHelper::EventPurity ( CandEventHandle ceh,
Int_t  neuId 
)

Definition at line 380 of file TruthHelper.cxx.

References fMom, CandHandle::GetDaughterIterator(), DigiSignal::GetHit(), GetNextNeuId(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), and DigiScintHit::TrackId().

00381 {
00382   const Truthifier & truth = Truthifier::Instance(fMom);
00383   Int_t nextneuId = GetNextNeuId(neuId);
00384   Float_t totalPE=0;
00385   Float_t hitPE=0;
00386    
00387   TIter stripitr(ceh.GetDaughterIterator());
00388   while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(stripitr())) {
00389     TIter digitItr(cstriph->GetDaughterIterator());
00390     while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
00391       Bool_t found=false;
00392       CandDigitHandle tcdh = *cdh;
00393       const DigiSignal * signal = truth.GetSignal(tcdh);
00394       if(signal){
00395         for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
00396           const DigiScintHit * hit = signal->GetHit(i);
00397           if(hit){
00398             Int_t track = abs(hit->TrackId());
00399             if(track>=neuId && track<=nextneuId){
00400               found=true;
00401             }
00402           }
00403         }
00404       } 
00405       if(found) {
00406         hitPE+=cdh->GetCharge();
00407         totalPE+= cdh->GetCharge();
00408       } else {
00409         totalPE+= cdh->GetCharge();
00410       }
00411     }
00412   }
00413 
00414   if(totalPE>0){
00415     return hitPE/totalPE; 
00416   }
00417   return 0.;
00418 }

int TruthHelper::GetBestEventNeuMatch ( CandEventHandle ceh  ) 

Definition at line 319 of file TruthHelper.cxx.

References RecDataRecord< T >::FindComponent(), fMom, CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), DigiSignal::GetHit(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), IsDocStatus(), IsNeutrino(), and DigiScintHit::TrackId().

Referenced by GfxMCVecList::Configure(), EventCompletenessImp(), and EVD::UpdateSummary().

00320 {
00321   const Truthifier & truth = Truthifier::Instance(fMom);
00322   Int_t BestNeu=-1;
00323   Int_t nNeutrinos=0;
00324   SimSnarlRecord *ssr = 
00325     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
00326   if (ssr) { 
00327     const TClonesArray* ctca =
00328       dynamic_cast<const TClonesArray*>
00329       (ssr->FindComponent("TClonesArray","StdHep"));
00330     Int_t siz = ctca->GetEntriesFast();
00331     TArrayI  neuIndBuf(siz+1);
00332     TArrayF  neuEBuf(siz);
00333     for (Int_t ind=0; ind < siz; ++ind) {
00334       TParticle* part = dynamic_cast<TParticle*>((*ctca)[ind]);
00335       if(IsNeutrino(part) && IsDocStatus(part)) {
00336         neuIndBuf[nNeutrinos]=ind;                       
00337         neuEBuf[nNeutrinos]=0;
00338         nNeutrinos++;
00339       }
00340     }
00341     neuIndBuf[nNeutrinos]=siz;
00342     
00343     for(Int_t ind=0; ind< nNeutrinos; ++ind) {
00344       TIter stripitr(ceh.GetDaughterIterator());
00345       while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(stripitr())) {
00346         TIter digitItr(cstriph->GetDaughterIterator());
00347         while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
00348           Bool_t found=false;
00349           CandDigitHandle tcdh = *cdh;
00350           const DigiSignal * signal = truth.GetSignal(tcdh);
00351           if(signal){
00352             for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
00353               const DigiScintHit * hit = signal->GetHit(i);
00354               if(hit){
00355                 Int_t track = abs(hit->TrackId());
00356                 if(track>=neuIndBuf[ind] && track <= neuIndBuf[ind+1]){
00357                   found=true;
00358                 }
00359               }
00360             }
00361           }     
00362           if(found) {
00363             neuEBuf[ind]+=cdh->GetCharge();
00364           }
00365         }
00366       }
00367     }
00368 
00369     Float_t PEMax=0;
00370     for (Int_t ind=0; ind < nNeutrinos; ++ind) {
00371       if(neuEBuf[ind]>PEMax){
00372         PEMax=neuEBuf[ind];
00373         BestNeu=neuIndBuf[ind];
00374       }
00375     }   
00376   }
00377   return BestNeu;
00378 }

Int_t TruthHelper::GetBestNeuMatch ( const CandStripHandle csh  ) 

Definition at line 246 of file TruthHelper.cxx.

References DigiScintHit::DE(), fMom, CandHandle::GetDaughterIterator(), DigiSignal::GetHit(), GetNeuKinIndex(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), and DigiScintHit::TrackId().

00247 {
00248   Int_t bestNeu=-1;
00249   Double_t maxDE=0; 
00250  const Truthifier & truth = Truthifier::Instance(fMom);
00251  TIter digitItr(csh.GetDaughterIterator());
00252   while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr()))
00253     {
00254       CandDigitHandle tcdh = *cdh;
00255       const DigiSignal * signal = truth.GetSignal(tcdh);
00256       if(signal){
00257         for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
00258           const DigiScintHit * hit = signal->GetHit(i);
00259           if(hit)
00260             {
00261               if(hit->DE()>maxDE){
00262                 Int_t track = abs(hit->TrackId());
00263                 bestNeu=GetNeuKinIndex(track);
00264                 maxDE=hit->DE();
00265               }
00266             }
00267         }
00268       }
00269     }
00270   return bestNeu;
00271 }

Int_t TruthHelper::GetBestNeuMatch ( const CandDigitHandle cdh  ) 

Definition at line 224 of file TruthHelper.cxx.

References DigiScintHit::DE(), fMom, DigiSignal::GetHit(), GetNeuKinIndex(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), and DigiScintHit::TrackId().

Referenced by GfxDigitList::ExecuteEvent(), and GfxStripList::ExecuteEvent().

00225 {
00226   Int_t bestNeu=-1;
00227   Double_t maxDE=0;
00228   const Truthifier & truth = Truthifier::Instance(fMom);
00229   const DigiSignal * signal = truth.GetSignal(cdh);
00230   if(signal){
00231     for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
00232       const DigiScintHit * hit = signal->GetHit(i);
00233       if(hit)
00234         {
00235           if(hit->DE()>maxDE){
00236             Int_t track = abs(hit->TrackId());
00237             bestNeu=GetNeuKinIndex(track);
00238             maxDE=hit->DE();
00239           }
00240         }
00241     }
00242   }
00243   return bestNeu;
00244 }

Int_t TruthHelper::GetBestShowerNeuMatch ( CandShowerHandle csh  ) 

Definition at line 1545 of file TruthHelper.cxx.

References RecDataRecord< T >::FindComponent(), fMom, CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), DigiSignal::GetHit(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), IsDocStatus(), IsNeutrino(), and DigiScintHit::TrackId().

Referenced by ShowerCompletenessImp(), and EVD::UpdateSummary().

01546 {
01547   const Truthifier & truth = Truthifier::Instance(fMom);
01548   Int_t BestNeu=-1;
01549   Int_t nNeutrinos=0;
01550   SimSnarlRecord *ssr = 
01551     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
01552   if (ssr){ 
01553     const TClonesArray* ctca =
01554       dynamic_cast<const TClonesArray*>
01555       (ssr->FindComponent("TClonesArray","StdHep"));
01556     Int_t siz = ctca->GetEntriesFast();
01557     TArrayI  neuIndBuf(siz+1);
01558     TArrayF  neuEBuf(siz);
01559     for (Int_t ind=0; ind < siz; ++ind) {
01560       TParticle* part = dynamic_cast<TParticle*>((*ctca)[ind]);
01561       if(IsNeutrino(part) && IsDocStatus(part)) { 
01562         neuIndBuf[nNeutrinos]=ind;
01563         neuEBuf[nNeutrinos]=0;
01564         nNeutrinos++;
01565       }
01566     }
01567     neuIndBuf[nNeutrinos]=siz;
01568     
01569     for (Int_t ind=0; ind < nNeutrinos; ++ind) {
01570       TIter stripitr(csh.GetDaughterIterator());
01571       while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(stripitr())) {
01572         TIter digitItr(cstriph->GetDaughterIterator());
01573         while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
01574           Bool_t found=false;
01575           CandDigitHandle tcdh = *cdh;
01576           const DigiSignal * signal = truth.GetSignal(tcdh);
01577           if(signal){
01578             for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
01579               const DigiScintHit * hit = signal->GetHit(i);
01580               if(hit){
01581                 Int_t track = abs(hit->TrackId());
01582                 if(track>=neuIndBuf[ind] && track <= neuIndBuf[ind+1]){
01583                   found=true;
01584                 }
01585               }
01586             }
01587           }     
01588           if(found) {
01589             neuEBuf[ind]+=cdh->GetCharge();
01590           }
01591         }
01592       }
01593     }
01594     Float_t PEMax=0;
01595     for (Int_t ind=0; ind < nNeutrinos; ++ind) {
01596       if(neuEBuf[ind]>PEMax){
01597         PEMax=neuEBuf[ind];
01598         BestNeu=neuIndBuf[ind];
01599       }
01600     }   
01601   }
01602   return BestNeu;
01603 }

Int_t TruthHelper::GetBestSliceNeuMatch ( CandSliceHandle csh  ) 

Definition at line 537 of file TruthHelper.cxx.

References RecDataRecord< T >::FindComponent(), fMom, CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), DigiSignal::GetHit(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), IsDocStatus(), IsNeutrino(), and DigiScintHit::TrackId().

Referenced by GfxMCVecList::Configure(), SliceCompleteness(), SliceCompleteness_MaxTimeGap(), SliceCompleteness_xtalk(), SlicePurity(), SlicePurity_MaxTimeGap(), SlicePurity_xtalk(), SliceTrueStrip(), SliceTrueStripxtalk(), and TrueNeuE().

00538 {
00539   const Truthifier & truth = Truthifier::Instance(fMom);
00540   Int_t BestNeu=-1;
00541   Int_t nNeutrinos=0;
00542   SimSnarlRecord *ssr = 
00543     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
00544   if (ssr) { 
00545     const TClonesArray* ctca =
00546       dynamic_cast<const TClonesArray*>
00547       (ssr->FindComponent("TClonesArray","StdHep"));
00548     Int_t siz = ctca->GetEntriesFast();
00549     TArrayI  neuIndBuf(siz+1);
00550     TArrayF  neuEBuf(siz);
00551     for (Int_t ind=0; ind < siz; ++ind) {
00552       TParticle* part = dynamic_cast<TParticle*>((*ctca)[ind]);
00553       if(IsNeutrino(part) && IsDocStatus(part)) {
00554         neuIndBuf[nNeutrinos]=ind;                       
00555         neuEBuf[nNeutrinos]=0;
00556         nNeutrinos++;
00557       }
00558     }
00559     neuIndBuf[nNeutrinos]=siz;
00560     
00561     for(Int_t ind=0; ind< nNeutrinos; ++ind) {
00562       TIter stripitr(csh.GetDaughterIterator());
00563       while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(stripitr())) {
00564         TIter digitItr(cstriph->GetDaughterIterator());
00565         while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
00566           Bool_t found=false;
00567           CandDigitHandle tcdh = *cdh;
00568           const DigiSignal * signal = truth.GetSignal(tcdh);
00569           if(signal){
00570             for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
00571               const DigiScintHit * hit = signal->GetHit(i);
00572               if(hit){
00573                 Int_t track = abs(hit->TrackId());
00574                 if(track>=neuIndBuf[ind] && track <= neuIndBuf[ind+1]){
00575                   found=true;
00576                 }
00577               }
00578             }
00579           }     
00580           if(found) {
00581             neuEBuf[ind]+=cdh->GetCharge();
00582           }
00583         }
00584       }
00585     }
00586 
00587     Float_t PEMax=0;
00588     for (Int_t ind=0; ind < nNeutrinos; ++ind) {
00589       if(neuEBuf[ind]>PEMax){
00590         PEMax=neuEBuf[ind];
00591         BestNeu=neuIndBuf[ind];
00592       }
00593     }   
00594   }
00595   return BestNeu;
00596 }

Int_t TruthHelper::GetBestTrackIdMatch ( CandTrackHandle cth  ) 

Definition at line 273 of file TruthHelper.cxx.

References RecDataRecord< T >::FindComponent(), fMom, CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), DigiSignal::GetHit(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), Msg::kWarning, MSG, and DigiScintHit::TrackId().

Referenced by GetTrackMaxE(), GetTrackMaxE2(), GetTrackMinE(), GetTrackMinE2(), TrackCompleteness(), and EVD::UpdateSummary().

00274 {
00275  const Truthifier & truth = Truthifier::Instance(fMom);
00276   Int_t bestTrack=-1;
00277   SimSnarlRecord *ssr = 
00278     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
00279   if (ssr){ 
00280     const TClonesArray* ctca =
00281       dynamic_cast<const TClonesArray*>
00282       (ssr->FindComponent("TClonesArray","StdHep"));
00283     Int_t siz = ctca->GetEntriesFast();
00284     TArrayI nTrackHits(siz);
00285     nTrackHits.Reset(0);
00286     TIter stripitr(cth.GetDaughterIterator());
00287     while (CandStripHandle* csh = dynamic_cast<CandStripHandle*>(stripitr())) {
00288       TIter digitItr(csh->GetDaughterIterator());
00289       while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
00290         CandDigitHandle tcdh = *cdh;
00291         const DigiSignal * signal = truth.GetSignal(tcdh);
00292         if(signal){
00293           for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
00294             const DigiScintHit * hit = signal->GetHit(i);
00295             if(hit){
00296               Int_t track = abs(hit->TrackId());
00297               if(track<siz){
00298                 nTrackHits[track]++;
00299               }
00300               else{
00301                 MSG("TruthHelper",Msg::kWarning) << "StdHep size or less than zero" << endl;
00302               }
00303               
00304             }
00305           }
00306         }
00307       }
00308     }
00309     Int_t nMax=0;
00310     for (Int_t ind=0; ind < siz; ++ind) {
00311       if(nTrackHits[ind]>nMax){
00312         nMax=nTrackHits[ind];
00313         bestTrack=ind;
00314       }
00315     }   
00316   }
00317   return bestTrack;
00318 }

Int_t TruthHelper::GetClosestNeuVtx ( CandRecoHandle crh  ) 

Definition at line 1834 of file TruthHelper.cxx.

References RecDataRecord< T >::FindComponent(), fMom, MomNavigator::GetFragment(), CandRecoHandle::GetVtxU(), CandRecoHandle::GetVtxV(), CandRecoHandle::GetVtxZ(), IsDocStatus(), and IsNeutrino().

01835 {
01836   Int_t bestNeu=-1;
01837   Float_t vtxU=crh.GetVtxU();
01838   Float_t vtxV=crh.GetVtxV();
01839   Float_t vtxX=0.707*(vtxU-vtxV);
01840   Float_t vtxY=0.707*(vtxU+vtxV);
01841   Float_t vtxZ=crh.GetVtxZ();
01842   Float_t closestDist=1e6;
01843   SimSnarlRecord *ssr = 
01844     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
01845   if (ssr){ 
01846     const TClonesArray* ctca =
01847       dynamic_cast<const TClonesArray*>
01848       (ssr->FindComponent("TClonesArray","StdHep"));
01849     Int_t siz = ctca->GetEntriesFast();
01850     for (Int_t ind=0; ind < siz; ++ind) {
01851       TParticle* part = dynamic_cast<TParticle*>((*ctca)[ind]);
01852       if(IsNeutrino(part) && IsDocStatus(part)){  //changed from 3 to 0.
01853         Float_t dist= sqrt((vtxX-part->Vx())*(vtxX-part->Vx())+
01854                            (vtxY-part->Vy())*(vtxY-part->Vy())+
01855                            (vtxZ-part->Vz())*(vtxZ-part->Vz()));
01856         if(dist<closestDist){
01857           closestDist=dist;
01858           bestNeu=ind;
01859         }
01860       }
01861     }
01862   }  
01863   return bestNeu;
01864 }

Int_t TruthHelper::GetNeuId ( Int_t  trackId  ) 

Definition at line 130 of file TruthHelper.cxx.

References RecDataRecord< T >::FindComponent(), fMom, MomNavigator::GetFragment(), IsDocStatus(), and IsNeutrino().

Referenced by GetTrackMaxE(), GetTrackMaxE2(), GetTrackMinE(), GetTrackMinE2(), and EVD::UpdateSummary().

00131 {
00132   Int_t neuId=-1;
00133   SimSnarlRecord *ssr = 
00134     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
00135   if (ssr){ 
00136     const TClonesArray* ctca =
00137       dynamic_cast<const TClonesArray*>
00138       (ssr->FindComponent("TClonesArray","StdHep"));
00139     for( Int_t ind=trackId; ind>-1; ind--){
00140       TParticle* part = dynamic_cast<TParticle*>((*ctca)[ind]);
00141       if(IsNeutrino(part) && IsDocStatus(part)){  //changed from 3 to 0
00142         neuId=ind;
00143         return neuId;
00144       }
00145     }
00146   }
00147   return -1;
00148 }

Int_t TruthHelper::GetNeuKinIndex ( Int_t  trackId  ) 

Definition at line 201 of file TruthHelper.cxx.

References RecDataRecord< T >::FindComponent(), fMom, MomNavigator::GetFragment(), IsDocStatus(), and IsNeutrino().

Referenced by GetBestNeuMatch().

00202 {
00203   Int_t neuKinIndex=-1;
00204   SimSnarlRecord *ssr = 
00205     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
00206   if (ssr){ 
00207     const TClonesArray* ctca =
00208       dynamic_cast<const TClonesArray*>
00209       (ssr->FindComponent("TClonesArray","StdHep"));
00210     Int_t siz = ctca->GetEntriesFast();
00211     if(trackId<siz && trackId>=0){
00212       for (Int_t ind=0; ind <= trackId; ++ind) {
00213         TParticle* part = dynamic_cast<TParticle*>((*ctca)[ind]);
00214         if(IsNeutrino(part) && IsDocStatus(part)){
00215           neuKinIndex++;
00216         } 
00217       }
00218     }
00219   }
00220   return neuKinIndex;
00221 }

Int_t TruthHelper::GetNextNeuId ( Int_t  trackId  ) 

Definition at line 150 of file TruthHelper.cxx.

References RecDataRecord< T >::FindComponent(), fMom, MomNavigator::GetFragment(), IsDocStatus(), and IsNeutrino().

Referenced by GfxMCVecList::Configure(), EventCompletenessImp(), EventPurity(), GetP4El1(), GetP4Mu1(), GetP4Mu2(), GetP4Shw(), GetTrackMaxE(), GetTrackMaxE2(), GetTrackMinE(), GetTrackMinE2(), ShowerCompletenessImp(), ShowerPurity(), SliceCompleteness(), SliceCompleteness_MaxTimeGap(), SliceCompleteness_xtalk(), SlicePurity(), SlicePurity_MaxTimeGap(), SlicePurity_xtalk(), SliceTrueStrip(), and SliceTrueStripxtalk().

00151 {
00152   Int_t neuId=-1;
00153   Int_t siz=-1;
00154   SimSnarlRecord *ssr = 
00155     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
00156   if (ssr){ 
00157     const TClonesArray* ctca =
00158       dynamic_cast<const TClonesArray*>
00159       (ssr->FindComponent("TClonesArray","StdHep"));
00160     siz = ctca->GetEntriesFast();
00161     for( Int_t ind=trackId+1; ind<siz; ind++){
00162       TParticle* part = dynamic_cast<TParticle*>((*ctca)[ind]);
00163       if(IsNeutrino(part) && IsDocStatus(part)) {
00164         neuId=ind;
00165         return neuId;
00166       }
00167     }
00168   }
00169   return siz;
00170 }

const Float_t * TruthHelper::GetP4El1 ( Int_t  neuId  ) 

Definition at line 1989 of file TruthHelper.cxx.

References RecDataRecord< T >::FindComponent(), fMom, MomNavigator::GetFragment(), GetNextNeuId(), IsElectron(), IsNeutrino(), and m_p4El1.

Referenced by EVD::UpdateSummary().

01989                                                 {
01990  
01991  for(Int_t i=0;i<4;i++) m_p4El1[i]=0; 
01992  if(neuId<0) return m_p4El1;
01993   Int_t nextneu = GetNextNeuId(neuId);
01994   SimSnarlRecord *ssr = 
01995     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
01996   if (ssr){ 
01997     const TClonesArray* ctca =
01998       dynamic_cast<const TClonesArray*>
01999       (ssr->FindComponent("TClonesArray","StdHep"));
02000     TParticle* neu = dynamic_cast<TParticle*>((*ctca)[neuId]);
02001     if(IsNeutrino(neu)){
02002       for (Int_t i=neuId;i<nextneu ; i++){
02003         TParticle* part = dynamic_cast<TParticle*>((*ctca)[i]);
02004         if(IsElectron(part)){
02005           Float_t p[4];
02006           p[0]=part->Px();
02007           p[1]=part->Py();
02008           p[2]=part->Pz();
02009           p[3]=part->Energy(); 
02010           if(p[3]>m_p4El1[3]){
02011             m_p4El1[0]=p[0];
02012             m_p4El1[1]=p[1];
02013             m_p4El1[2]=p[2];
02014             m_p4El1[3]=p[3];
02015           }       
02016         }
02017       }
02018     }
02019   }
02020   return m_p4El1;
02021 }

const Float_t * TruthHelper::GetP4Mu1 ( Int_t  neuId  ) 

Definition at line 1918 of file TruthHelper.cxx.

References RecDataRecord< T >::FindComponent(), fMom, MomNavigator::GetFragment(), GetNextNeuId(), IsMuon(), IsNeutrino(), and m_p4Mu1.

Referenced by GetP4Mu2(), and EVD::UpdateSummary().

01918                                                 {
01919 
01920  
01921   for(Int_t i=0;i<4;i++) m_p4Mu1[i]=0;
01922  if(neuId<0)return m_p4Mu1;
01923   Int_t nextneu = GetNextNeuId(neuId);
01924   SimSnarlRecord *ssr = 
01925     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
01926   if (ssr){ 
01927     const TClonesArray* ctca =
01928       dynamic_cast<const TClonesArray*>
01929       (ssr->FindComponent("TClonesArray","StdHep"));
01930     TParticle* neu = dynamic_cast<TParticle*>((*ctca)[neuId]);
01931     if(IsNeutrino(neu)){
01932       for (Int_t i=neuId;i<nextneu ; i++){
01933         TParticle* part = dynamic_cast<TParticle*>((*ctca)[i]);
01934         if(IsMuon(part)){
01935           Float_t p[4];
01936           p[0]=part->Px();
01937           p[1]=part->Py();
01938           p[2]=part->Pz();
01939           p[3]=part->Energy(); 
01940           if(p[3]>m_p4Mu1[3]){
01941             m_p4Mu1[0]=p[0];
01942             m_p4Mu1[1]=p[1];
01943             m_p4Mu1[2]=p[2];
01944             m_p4Mu1[3]=p[3];
01945           }       
01946         }
01947       }
01948     }
01949   }
01950   return m_p4Mu1;
01951 }

const Float_t * TruthHelper::GetP4Mu2 ( Int_t  neuId  ) 

Definition at line 1953 of file TruthHelper.cxx.

References RecDataRecord< T >::FindComponent(), fMom, MomNavigator::GetFragment(), GetNextNeuId(), GetP4Mu1(), IsMuon(), IsNeutrino(), and m_p4Mu2.

Referenced by EVD::UpdateSummary().

01953                                                 {
01954 
01955   const Float_t * mu1E = GetP4Mu1(neuId);  
01956   for(Int_t i=0;i<4;i++) m_p4Mu2[i]=0;
01957  if(neuId<0)return m_p4Mu2;
01958   Int_t nextneu = GetNextNeuId(neuId);
01959   SimSnarlRecord *ssr = 
01960     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
01961   if (ssr){ 
01962     const TClonesArray* ctca =
01963       dynamic_cast<const TClonesArray*>
01964       (ssr->FindComponent("TClonesArray","StdHep"));
01965     TParticle* neu = dynamic_cast<TParticle*>((*ctca)[neuId]);
01966     if(IsNeutrino(neu)){
01967       for (Int_t i=neuId;i<nextneu ; i++){
01968         TParticle* part = dynamic_cast<TParticle*>((*ctca)[i]);
01969         if(IsMuon(part) && part->Energy()!=mu1E[3]){
01970           Float_t p[4];
01971           p[0]=part->Px();
01972           p[1]=part->Py();
01973           p[2]=part->Pz();
01974           p[3]=part->Energy(); 
01975           if(p[3]>m_p4Mu2[3]){
01976             m_p4Mu2[0]=p[0];
01977             m_p4Mu2[1]=p[1];
01978             m_p4Mu2[2]=p[2];
01979             m_p4Mu2[3]=p[3];
01980           }       
01981         }
01982       }
01983     }
01984   }
01985   return m_p4Mu2;
01986 }

const Float_t * TruthHelper::GetP4Neu ( Int_t  neuId  ) 

Definition at line 1866 of file TruthHelper.cxx.

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

Referenced by EVD::UpdateSummary().

01866                                                 {
01867  
01868   for(Int_t i=0;i<4;i++) m_p4Neu[i]=0.;
01869  if(neuId<0)return m_p4Neu;
01870   SimSnarlRecord *ssr = 
01871     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
01872   if (ssr){ 
01873     const TClonesArray* ctca =
01874       dynamic_cast<const TClonesArray*>
01875       (ssr->FindComponent("TClonesArray","StdHep"));
01876     TParticle* part = dynamic_cast<TParticle*>((*ctca)[neuId]);
01877     if(IsNeutrino(part) ){
01878       m_p4Neu[0]=part->Px();
01879       m_p4Neu[1]=part->Py();
01880       m_p4Neu[2]=part->Pz();
01881       m_p4Neu[3]=part->Energy();
01882     }
01883     else{
01884       
01885       MSG("TruthHelper",Msg::kWarning) << "Non-neutrino stdhep entry interrigated to obtain Neu 4 vector" << endl;
01886     } 
01887   } 
01888   return m_p4Neu;
01889 }

const Float_t * TruthHelper::GetP4Shw ( Int_t  neuId  ) 

Definition at line 1891 of file TruthHelper.cxx.

References RecDataRecord< T >::FindComponent(), fMom, MomNavigator::GetFragment(), GetNextNeuId(), IsMuon(), IsNeutrino(), and m_p4Shw.

Referenced by EVD::UpdateSummary().

01891                                                 {
01892   for(Int_t i=0;i<4;i++) m_p4Shw[i]=0.;
01893   if(neuId<0)return m_p4Shw;
01894   Int_t nextneu = GetNextNeuId(neuId);
01895   SimSnarlRecord *ssr = 
01896     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
01897   if (ssr){ 
01898     const TClonesArray* ctca =
01899       dynamic_cast<const TClonesArray*>
01900       (ssr->FindComponent("TClonesArray","StdHep"));
01901     TParticle* neu = dynamic_cast<TParticle*>((*ctca)[neuId]);
01902     if(IsNeutrino(neu)){
01903       for (Int_t i=neuId;i<nextneu ; i++){
01904         TParticle* part = dynamic_cast<TParticle*>((*ctca)[i]);
01905         if( !IsNeutrino(part) && !IsMuon(part) && part->GetStatusCode()==1){
01906           m_p4Shw[0]+=part->Px();
01907           m_p4Shw[1]+=part->Py();
01908           m_p4Shw[2]+=part->Pz();
01909           m_p4Shw[3]+=part->Energy();
01910           if((part->GetPdgCode()/1000)%10 || part->GetPdgCode()>99999) m_p4Shw[3]-=part->GetMass();     
01911         }
01912       }
01913     }
01914   }
01915   return m_p4Shw;
01916 }

Int_t TruthHelper::GetStripNeuIndex ( CandStripHandle csh  ) 

Definition at line 172 of file TruthHelper.cxx.

References Truthifier::DigitIsOnlyCrosstalk(), fMom, CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), DigiSignal::GetHit(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), and DigiScintHit::TrackId().

00173 {
00174    //Tom Osiecki - osiecki@mail.hep.utexas.edu
00175   const Truthifier & truth = Truthifier::Instance(fMom);
00176   SimSnarlRecord *ssr = 
00177     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
00178   Int_t tracky = -1;
00179   Bool_t found = false;
00180   if (ssr){ 
00181     TIter digitItr(csh->GetDaughterIterator());
00182     while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())) {    
00183       CandDigitHandle tcdh = *cdh;
00184       if(!truth.DigitIsOnlyCrosstalk(tcdh) && !found){
00185         const DigiSignal * signal = truth.GetSignal(tcdh);
00186         if(signal){
00187           for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
00188             const DigiScintHit * hit = signal->GetHit(i);
00189             if(hit){
00190               tracky = abs(hit->TrackId());
00191               found=true;
00192             }
00193           }
00194         }
00195       }   
00196     }
00197   }
00198   return tracky;
00199 }

Float_t TruthHelper::GetTrackMaxE ( CandTrackHandle cth  ) 

Definition at line 1299 of file TruthHelper.cxx.

References fMom, GetBestTrackIdMatch(), CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), DigiSignal::GetHit(), GetNeuId(), GetNextNeuId(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), DigiScintHit::ParticleEnergy(), DigiScintHit::ParticleId(), and DigiScintHit::TrackId().

01300 {
01301   Float_t maxE=0;
01302   const Truthifier & truth = Truthifier::Instance(fMom);
01303   Int_t trackId=GetBestTrackIdMatch(cth);
01304   Int_t neuId=GetNeuId(trackId);
01305   Int_t nextneuId = GetNextNeuId(neuId);
01306 
01307   SimSnarlRecord *ssr = 
01308     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
01309   if (ssr){ 
01310 
01311 
01312     TIter stripitr(cth.GetDaughterIterator());
01313     while (CandStripHandle* csh = dynamic_cast<CandStripHandle*>(stripitr())) {
01314       TIter digitItr(csh->GetDaughterIterator());
01315       while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
01316         CandDigitHandle tcdh = *cdh;
01317         const DigiSignal * signal = truth.GetSignal(tcdh);
01318         if(signal){
01319           for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
01320             const DigiScintHit * hit = signal->GetHit(i);
01321             if(hit){
01322               Int_t track = abs(hit->TrackId());
01323               if(abs(hit->ParticleId())==13){
01324                 if(track>neuId && track<nextneuId){
01325                   if(hit->ParticleEnergy()>maxE)maxE=hit->ParticleEnergy();
01326                 }
01327               }
01328             }
01329           }
01330         }       
01331       }
01332     }
01333   }
01334   return maxE; 
01335 }

Float_t TruthHelper::GetTrackMaxE2 ( CandTrackHandle cth  ) 

Definition at line 1337 of file TruthHelper.cxx.

References RecDataRecord< T >::FindComponent(), fMom, GetBestTrackIdMatch(), MomNavigator::GetFragment(), GetNeuId(), GetNextNeuId(), DigiScintHit::ParticleEnergy(), DigiScintHit::ParticleId(), DigiScintHit::Plane(), and DigiScintHit::TrackId().

01338 {
01339   Float_t maxE=0;
01340   Int_t trackId=GetBestTrackIdMatch(cth);
01341   Int_t neuId=GetNeuId(trackId);
01342   Int_t nextneuId = GetNextNeuId(neuId);
01343   
01344   SimSnarlRecord *ssr = 
01345     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
01346   if (ssr){     
01347     // Get the scint hit array.
01348     const TObjArray * ScintHitArray = 
01349       dynamic_cast<const TObjArray*>(ssr->FindComponent(0,"DigiScintHits"));
01350     if(ScintHitArray==0)return maxE; 
01351     // Build the array of hits.
01352     TIter hitarrayIter(ScintHitArray);
01353     TObject* tobj;
01354     while( (tobj = hitarrayIter.Next()) ) {
01355       const DigiScintHit* hit = dynamic_cast<DigiScintHit*>(tobj);
01356       if(hit){
01357         Int_t track = abs(hit->TrackId());      
01358         // look only at muon hits not in veto shield.
01359         if(abs(hit->ParticleId())==13 && hit->Plane()<500){
01360           if(track>neuId && track<nextneuId){
01361             if(hit->ParticleEnergy()>maxE)maxE=hit->ParticleEnergy();
01362           }
01363         }
01364       }
01365     }
01366   }
01367   return maxE; 
01368 }

Float_t TruthHelper::GetTrackMinE ( CandTrackHandle cth  ) 

Definition at line 1406 of file TruthHelper.cxx.

References fMom, GetBestTrackIdMatch(), CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), DigiSignal::GetHit(), GetNeuId(), GetNextNeuId(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), DigiScintHit::ParticleEnergy(), DigiScintHit::ParticleId(), and DigiScintHit::TrackId().

01407 {
01408   Float_t minE=10000;
01409   const Truthifier & truth = Truthifier::Instance(fMom);
01410   Int_t trackId= GetBestTrackIdMatch(cth);
01411   Int_t neuId=GetNeuId(trackId);
01412   Int_t nextneuId = GetNextNeuId(neuId);
01413 
01414   SimSnarlRecord *ssr = 
01415     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
01416   if (ssr){ 
01417     
01418     TIter stripitr(cth.GetDaughterIterator());
01419     while (CandStripHandle* csh = dynamic_cast<CandStripHandle*>(stripitr())) {
01420       TIter digitItr(csh->GetDaughterIterator());
01421       while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
01422         CandDigitHandle tcdh = *cdh;
01423         const DigiSignal * signal = truth.GetSignal(tcdh);
01424         if(signal){
01425           for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
01426             const DigiScintHit * hit = signal->GetHit(i);
01427             if(hit){
01428               Int_t track = abs(hit->TrackId());
01429               if(abs(hit->ParticleId())==13){
01430                 if(track>neuId && track<nextneuId){
01431                   if(hit->ParticleEnergy()<minE)minE=hit->ParticleEnergy();
01432                 }
01433               }
01434             }
01435           }
01436         }       
01437       }
01438     }
01439   }
01440   return minE; 
01441 }

Float_t TruthHelper::GetTrackMinE2 ( CandTrackHandle cth  ) 

Definition at line 1370 of file TruthHelper.cxx.

References RecDataRecord< T >::FindComponent(), fMom, GetBestTrackIdMatch(), MomNavigator::GetFragment(), GetNeuId(), GetNextNeuId(), DigiScintHit::ParticleEnergy(), DigiScintHit::ParticleId(), DigiScintHit::Plane(), and DigiScintHit::TrackId().

01371 {
01372   Float_t minE=1000;
01373   Int_t trackId=GetBestTrackIdMatch(cth);
01374   Int_t neuId=GetNeuId(trackId);
01375   Int_t nextneuId = GetNextNeuId(neuId);
01376   
01377   SimSnarlRecord *ssr = 
01378     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
01379   if (ssr){ 
01380     
01381     // Get the scint hit array.
01382     const TObjArray * ScintHitArray = 
01383       dynamic_cast<const TObjArray*>(ssr->FindComponent(0,"DigiScintHits"));
01384     if(ScintHitArray==0)return minE; 
01385     // Build the array of hits.
01386     TIter hitarrayIter(ScintHitArray);
01387     TObject* tobj;
01388     while( (tobj = hitarrayIter.Next()) ) {
01389       const DigiScintHit* hit = dynamic_cast<DigiScintHit*>(tobj);
01390       if(hit){
01391         Int_t track = abs(hit->TrackId());
01392         
01393         // look only at muon hits not in veto shield.
01394         
01395         if(abs(hit->ParticleId())==13 && hit->Plane()<500){
01396           if(track>neuId && track<nextneuId){
01397             if(hit->ParticleEnergy()<minE)minE=hit->ParticleEnergy();
01398           }
01399         }
01400       }
01401     }
01402   }
01403   return minE; 
01404 }

Bool_t TruthHelper::IsDocStatus ( const TParticle *  part  )  [static]

Definition at line 118 of file TruthHelper.cxx.

Referenced by NtpMCModule::FillNtpMCTruth(), GetBestEventNeuMatch(), GetBestShowerNeuMatch(), GetBestSliceNeuMatch(), GetClosestNeuVtx(), GetNeuId(), GetNeuKinIndex(), GetNextNeuId(), NumNeu(), secondNEU(), and TruthSliceNum().

00119 {
00120   // Is the status code "Documentation" or "null"?
00121   // This should indicate that it was an initial particle
00122   // into the event generator.
00123   Int_t status = part->GetStatusCode();
00124   if( status == 3 || status == 0 ) return true;
00125   return false;
00126 }

Bool_t TruthHelper::IsElectron ( const TParticle *  part  )  [static]

Definition at line 92 of file TruthHelper.cxx.

Referenced by GetP4El1().

00093 {
00094   if(abs(part->GetPdgCode())==11)return true;
00095   return false;
00096 }

Bool_t TruthHelper::IsGamma ( const TParticle *  part  )  [static]

Definition at line 74 of file TruthHelper.cxx.

00075 {
00076   if(abs(part->GetPdgCode())==22)return true;
00077   return false;
00078 }

Bool_t TruthHelper::IsMuon ( const TParticle *  part  )  [static]

Definition at line 56 of file TruthHelper.cxx.

Referenced by MCAnalysis::Ana(), GetP4Mu1(), GetP4Mu2(), GetP4Shw(), IsPrimaryShowerPart(), and AlgRmMu::RunAlg().

00057 {
00058   if(abs(part->GetPdgCode())==13)return true;
00059   return false;
00060 }

Bool_t TruthHelper::IsNeutrino ( const TParticle *  part  )  [static]

Definition at line 48 of file TruthHelper.cxx.

Referenced by MCAnalysis::Ana(), NtpMCModule::FillNtpMCTruth(), GetBestEventNeuMatch(), GetBestShowerNeuMatch(), GetBestSliceNeuMatch(), GetClosestNeuVtx(), GetNeuId(), GetNeuKinIndex(), GetNextNeuId(), GetP4El1(), GetP4Mu1(), GetP4Mu2(), GetP4Neu(), GetP4Shw(), IsPrimaryShowerPart(), NumNeu(), AlgRmMu::RunAlg(), secondNEU(), StripPurity(), and TruthSliceNum().

00049 {
00050   if(abs(part->GetPdgCode())==12 ||
00051      abs(part->GetPdgCode())==14 ||
00052      abs(part->GetPdgCode())==16)return true;
00053   return false;
00054 }

Bool_t TruthHelper::IsNeutron ( const TParticle *  part  )  [static]

Definition at line 86 of file TruthHelper.cxx.

00087 {
00088   if(abs(part->GetPdgCode())==2112)return true;
00089   return false;
00090 }

Bool_t TruthHelper::IsP0 ( const TParticle *  part  )  [static]

Definition at line 68 of file TruthHelper.cxx.

00069 {
00070   if(abs(part->GetPdgCode())==111)return true;
00071   return false;
00072 }

Bool_t TruthHelper::IsPion ( const TParticle *  part  )  [static]

Definition at line 62 of file TruthHelper.cxx.

00063 {
00064   if(abs(part->GetPdgCode())==211)return true;
00065   return false;
00066 }

Bool_t TruthHelper::IsPrimaryShowerPart ( const TParticle *  part  ) 

Definition at line 98 of file TruthHelper.cxx.

References RecDataRecord< T >::FindComponent(), fMom, MomNavigator::GetFragment(), IsMuon(), and IsNeutrino().

Referenced by ShowerCompletenessImp().

00099 {
00100   if(IsNeutrino(part) || IsMuon(part)) return false;
00101   SimSnarlRecord *ssr = 
00102     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
00103   if (ssr){ 
00104     const TClonesArray* ctca =
00105       dynamic_cast<const TClonesArray*>
00106       (ssr->FindComponent("TClonesArray","StdHep"));
00107     Int_t status = part->GetStatusCode();
00108     const TParticle * chainpart = part;
00109     while (status == 205 || status == 212){
00110       chainpart =  dynamic_cast<const TParticle*>((*ctca)[chainpart->GetFirstMother()]);
00111       status = chainpart->GetStatusCode();
00112     }
00113     if(status !=1  || IsNeutrino(chainpart) || IsMuon(chainpart)) return false;
00114   }
00115   return true;
00116 }

Bool_t TruthHelper::IsProton ( const TParticle *  part  )  [static]

Definition at line 80 of file TruthHelper.cxx.

00081 {
00082   if(abs(part->GetPdgCode())==2212)return true;
00083   return false;
00084 }

Int_t TruthHelper::NumNeu ( CandSliceHandle csh  ) 

Definition at line 678 of file TruthHelper.cxx.

References RecDataRecord< T >::FindComponent(), fMom, CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), DigiSignal::GetHit(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), IsDocStatus(), IsNeutrino(), and DigiScintHit::TrackId().

00679 {
00680   //Tom Osiecki - osiecki@mail.hep.utexas.edu
00681   const Truthifier & truth = Truthifier::Instance(fMom);
00682   //Int_t BestNeu=-1;
00683   Int_t counter = 0;
00684   Int_t nNeutrinos=0;
00685   SimSnarlRecord *ssr = 
00686     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
00687   if (ssr){ 
00688     const TClonesArray* ctca =
00689       dynamic_cast<const TClonesArray*>
00690       (ssr->FindComponent("TClonesArray","StdHep"));
00691     Int_t siz = ctca->GetEntriesFast();
00692     TArrayI  neuIndBuf(siz+1);
00693     TArrayF  neuEBuf(siz);
00694     for (Int_t ind=0; ind < siz; ++ind) {
00695       TParticle* part = dynamic_cast<TParticle*>((*ctca)[ind]);
00696       if(IsNeutrino(part) && IsDocStatus(part)){  
00697         neuIndBuf[nNeutrinos]=ind;                       
00698         neuEBuf[nNeutrinos]=0;
00699         nNeutrinos++;
00700       }
00701     }
00702     neuIndBuf[nNeutrinos]=siz;
00703     
00704     for (Int_t ind=0; ind < nNeutrinos; ++ind) {
00705       TIter stripitr(csh.GetDaughterIterator());
00706       while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(stripitr())) {
00707         TIter digitItr(cstriph->GetDaughterIterator());
00708         while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
00709           Bool_t found=false; 
00710           CandDigitHandle tcdh = *cdh;
00711           const DigiSignal * signal = truth.GetSignal(tcdh);
00712           if(signal){
00713             for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
00714               const DigiScintHit * hit = signal->GetHit(i);
00715               if(hit){
00716                 Int_t track = abs(hit->TrackId()); 
00717                 if(track>=neuIndBuf[ind] && track <= neuIndBuf[ind+1]){
00718                   found=true;
00719                 }
00720               }
00721             }
00722           }     
00723           if(found) {
00724             neuEBuf[ind]+=cdh->GetCharge();
00725           }
00726         }
00727       }
00728     }
00729     counter = 0;
00730     for (Int_t ind=0; ind < nNeutrinos; ++ind) {
00731       if(neuEBuf[ind]>0){
00732         counter++;
00733       }
00734     }   
00735   }
00736   return counter;
00737 }

Float_t TruthHelper::secondNEU ( CandSliceHandle csh  ) 

Definition at line 599 of file TruthHelper.cxx.

References Truthifier::DigitIsOnlyCrosstalk(), RecDataRecord< T >::FindComponent(), fMom, CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), DigiSignal::GetHit(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), IsDocStatus(), IsNeutrino(), and DigiScintHit::TrackId().

00600 {
00601   //Tom Osiecki - osiecki@mail.hep.utexas.edu
00602   const Truthifier & truth = Truthifier::Instance(fMom);
00603   Int_t BestNeu=-1;
00604   Float_t PEMax2 = 0.0;
00605   Float_t TotPE = 0.0;
00606   Int_t nNeutrinos=0;
00607   SimSnarlRecord *ssr = 
00608     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
00609   if (ssr){ 
00610     const TClonesArray* ctca =
00611       dynamic_cast<const TClonesArray*>
00612       (ssr->FindComponent("TClonesArray","StdHep"));
00613     Int_t siz = ctca->GetEntriesFast();
00614     TArrayI  neuIndBuf(siz+1);
00615     TArrayF  neuEBuf(siz);
00616     for (Int_t ind=0; ind < siz; ++ind) {
00617       TParticle* part = dynamic_cast<TParticle*>((*ctca)[ind]);
00618       if(IsNeutrino(part) && IsDocStatus(part)){  
00619         neuIndBuf[nNeutrinos]=ind;                       
00620         neuEBuf[nNeutrinos]=0;
00621         nNeutrinos++;
00622       }
00623     }
00624     neuIndBuf[nNeutrinos]=siz;
00625     
00626     for (Int_t ind=0; ind < nNeutrinos; ++ind) {
00627       TIter stripitr(csh.GetDaughterIterator());
00628       while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(stripitr())) {
00629         TIter digitItr(cstriph->GetDaughterIterator());
00630         while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
00631           Bool_t found=false;
00632           CandDigitHandle tcdh = *cdh;
00633           if(!truth.DigitIsOnlyCrosstalk(tcdh) && !found) {
00634             const DigiSignal * signal = truth.GetSignal(tcdh);
00635             if(signal){
00636               for (UInt_t i=0;i<signal->GetNumberOfHits();i++) {
00637                 const DigiScintHit * hit = signal->GetHit(i);
00638                 if(hit){
00639                   Int_t track = abs(hit->TrackId());
00640                   if(track>=neuIndBuf[ind] && track <= neuIndBuf[ind+1]) {
00641                     found=true;
00642                   }
00643                 }
00644               }
00645             }
00646           }     
00647           if(found) {
00648             neuEBuf[ind]+=cdh->GetCharge();
00649           }
00650         }  
00651       }
00652     }
00653 
00654     Float_t PEMax=0;
00655     for (Int_t ind=0; ind < nNeutrinos; ++ind) {
00656       if(neuEBuf[ind]>PEMax){
00657         PEMax=neuEBuf[ind];
00658         BestNeu=neuIndBuf[ind];
00659       }
00660     }   
00661     PEMax2=0;
00662     for (Int_t ind=0; ind < nNeutrinos; ++ind) {
00663       if(neuEBuf[ind] > PEMax2 && neuEBuf[ind] < PEMax) {
00664         PEMax2 = neuEBuf[ind];
00665       }
00666     }
00667     for(Int_t ind=0; ind < nNeutrinos; ++ind) {
00668       TotPE += neuEBuf[ind];
00669     }
00670   }
00671   if(TotPE>0) {
00672     return (PEMax2/TotPE);
00673   } else {
00674     return 0;
00675   }
00676 }

Float_t TruthHelper::ShowerCompleteness ( CandShowerHandle cshwh  ) 

Shower completeness within the whole snarl.

Returns the completeness of shower cshwh defined over the strips in the whole snarl. The value returned is:

(PE in reco shower) / (PE in true shower ending up in strips above PE cut)

ie, Only slice strips with charge greater than the minimum required for shower reconstruction are used in the denominator

Definition at line 1651 of file TruthHelper.cxx.

References ShowerCompletenessImp().

01652 {
01653   return ShowerCompletenessImp(cshwh, 0, false);
01654 }

Float_t TruthHelper::ShowerCompleteness ( CandShowerHandle cshwh,
CandSliceHandle csh 
)

Shower completeness within the given slice.

Returns the completeness of shower cshwh defined over the strips in the slice csh. The value returned is:

(PE in reco shower) / (PE in true shower ending up in strips above PE cut)

ie, Only slice strips with charge greater than the minimum required for shower reconstruction are used in the denominator

Definition at line 1645 of file TruthHelper.cxx.

References ShowerCompletenessImp().

Referenced by EVD::UpdateSummary().

01646 {
01647   return ShowerCompletenessImp(cshwh, &csh, false);
01648 }

Float_t TruthHelper::ShowerCompletenessAllStrips ( CandShowerHandle cshwh  ) 

Shower completeness within the whole snarl, with no pulse height cut.

Returns the completeness of shower cshwh defined over the strips in the whole snarl. The value returned is:

(PE in reco shower) / (PE in true shower ending up in any strip)

Definition at line 1663 of file TruthHelper.cxx.

References ShowerCompletenessImp().

01664 {
01665   return ShowerCompletenessImp(cshwh, 0, true);
01666 }

Float_t TruthHelper::ShowerCompletenessAllStrips ( CandShowerHandle cshwh,
CandSliceHandle csh 
)

Shower completeness within the given slice, with no pulse height cut.

Returns the completeness of shower cshwh defined over the strips in the slice csh. The value returned is:

(PE in reco shower) / (PE in true shower ending up in any strip)

Definition at line 1656 of file TruthHelper.cxx.

References ShowerCompletenessImp().

01658 {
01659   return ShowerCompletenessImp(cshwh, &csh, true);
01660 }

Float_t TruthHelper::ShowerCompletenessImp ( CandShowerHandle cshwh,
CandSliceHandle csh,
bool  useAllStrips 
) [private]

Shower completeness implementation.

Returns the completeness of shower cshwh.

If csh is 0, the completeness over the whole snarl is returned, otherwise the completeness over the slice csh is returned.

If useAllStrips is true, the denominator in the completeness is formed from all strips, otherwise only strips above the PE cut are used in the denominator

Definition at line 1668 of file TruthHelper.cxx.

References Truthifier::DigitIsOnlyCrosstalk(), CandRecord::FindCandHandle(), RecDataRecord< T >::FindComponent(), fMom, GetBestShowerNeuMatch(), CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), DigiSignal::GetHit(), CandShowerHandle::GetMinStripPE(), GetNextNeuId(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), IsPrimaryShowerPart(), CalDigitType::kPE, and DigiScintHit::TrackId().

Referenced by ShowerCompleteness(), and ShowerCompletenessAllStrips().

01671 {
01672   Float_t truePE=0;
01673   Float_t shwPE=0;
01674   const Truthifier & truth = Truthifier::Instance(fMom);
01675   Int_t neuId= GetBestShowerNeuMatch(cshwh);
01676   Int_t nextneuId= GetNextNeuId(neuId);
01677 
01678   SimSnarlRecord *ssr = 
01679     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
01680   if (!ssr)return 0.0;
01681   const TClonesArray* ctca =
01682     dynamic_cast<const TClonesArray*>
01683     (ssr->FindComponent("TClonesArray","StdHep"));
01684   
01685   TIter shwstripitr(cshwh.GetDaughterIterator());
01686   
01687   // (PAR) TIter::TIter() is protected, so we can't create a blank
01688   // iterator that way. This works though
01689   TIter striplistitr((TIterator*)0);
01690 
01691   if(csh) {
01692     // (PAR) Only loop through strips in the slice
01693     striplistitr=csh->GetDaughterIterator();
01694   } else {
01695     // (PAR) Loop through all strips in the snarl
01696     CandRecord *crec = dynamic_cast<CandRecord *>
01697       (fMom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
01698     
01699     CandStripListHandle *cstriplh = dynamic_cast<CandStripListHandle *>
01700       (crec->FindCandHandle("CandStripListHandle"));
01701     striplistitr=cstriplh->GetDaughterIterator();
01702   }
01703 
01704   while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(striplistitr())) {
01705     // (PAR)
01706     // If requested, only use snarl strips with charge greater than the minimum
01707     // required for showers. This means that the shower completeness
01708     // is defined as:
01709     //
01710     // (PE in reco shower) / (PE in true shower ending up in strips above PE cut)
01711     //
01712     if ((!useAllStrips) && 
01713         cstriph->GetCharge(CalDigitType::kPE)<cshwh.GetMinStripPE()) continue;
01714     
01715     TIter digitItr(cstriph->GetDaughterIterator());
01716     Bool_t found=false;
01717     while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
01718       const CandDigitHandle tcdh = *cdh;
01719       if(!truth.DigitIsOnlyCrosstalk(tcdh) && !found){
01720         const DigiSignal * signal = truth.GetSignal(tcdh);
01721         if(signal){
01722           for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
01723             const DigiScintHit * hit = signal->GetHit(i);
01724             if(hit){
01725               Int_t track = abs(hit->TrackId());
01726               TParticle* part = dynamic_cast<TParticle*>((*ctca)[track]);
01727 
01728               if(track>neuId && track<nextneuId && IsPrimaryShowerPart(part)){
01729                 found=true;      
01730               }
01731             }
01732           }
01733         }
01734       }
01735     }
01736     if(found) {
01737       truePE+=cstriph->GetCharge();
01738       shwstripitr.Reset();
01739       Int_t plane=cstriph->GetPlane();
01740       Int_t strip=cstriph->GetStrip();
01741       while (CandStripHandle* cshwstriph = dynamic_cast<CandStripHandle*>(shwstripitr())) {
01742         if(cshwstriph->GetPlane()==plane && cshwstriph->GetStrip()==strip){
01743           shwPE+=cstriph->GetCharge();
01744           break;
01745         }         
01746       } 
01747     }
01748   }
01749   if(truePE>0) return shwPE/truePE;
01750   return 0.;
01751 
01752 }

Float_t TruthHelper::ShowerPurity ( CandShowerHandle csh,
Int_t  neuId 
)

Definition at line 1605 of file TruthHelper.cxx.

References fMom, CandHandle::GetDaughterIterator(), DigiSignal::GetHit(), GetNextNeuId(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), and DigiScintHit::TrackId().

Referenced by EVD::UpdateSummary().

01606 {
01607   const Truthifier & truth = Truthifier::Instance(fMom);
01608   Int_t nextneuId = GetNextNeuId(neuId);
01609   Float_t totalPE=0;
01610   Float_t hitPE=0;
01611    
01612   TIter stripitr(csh.GetDaughterIterator());
01613   while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(stripitr())) {
01614     TIter digitItr(cstriph->GetDaughterIterator());
01615     while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
01616       Bool_t found=false;
01617       CandDigitHandle tcdh = *cdh;
01618       const DigiSignal * signal = truth.GetSignal(tcdh);
01619       if(signal){
01620         for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
01621           const DigiScintHit * hit = signal->GetHit(i);
01622           if(hit){
01623             Int_t track = abs(hit->TrackId());
01624             if(track>=neuId && track<=nextneuId){
01625               found=true;
01626             }
01627           }
01628         }
01629       } 
01630       if(found) {
01631         hitPE+=cdh->GetCharge();
01632         totalPE+= cdh->GetCharge();
01633       } else {
01634         totalPE+= cdh->GetCharge();
01635       }
01636     }
01637   }
01638 
01639   if(totalPE>0){
01640     return hitPE/totalPE; 
01641   }
01642   return 0.;
01643 }

Float_t TruthHelper::SliceCompleteness ( CandSliceHandle csh  ) 

Definition at line 739 of file TruthHelper.cxx.

References Truthifier::DigitIsOnlyCrosstalk(), CandRecord::FindCandHandle(), fMom, GetBestSliceNeuMatch(), CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), DigiSignal::GetHit(), GetNextNeuId(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), and DigiScintHit::TrackId().

00740 {
00741   const Truthifier & truth = Truthifier::Instance(fMom);
00742   Int_t neuId=GetBestSliceNeuMatch(csh);
00743   Int_t nextneuId = GetNextNeuId(neuId);
00744   Float_t totalPE=0;
00745   Float_t slicePE=0;
00746   CandRecord *crec = dynamic_cast<CandRecord *>
00747     (fMom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00748   CandStripListHandle *cstriplh = dynamic_cast<CandStripListHandle *>
00749     (crec->FindCandHandle("CandStripListHandle"));
00750   TIter striplistitr(cstriplh->GetDaughterIterator());
00751   striplistitr.Reset();
00752   while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(striplistitr())) {
00753     TIter digitItr(cstriph->GetDaughterIterator());
00754     while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
00755       Bool_t found=false;
00756       const CandDigitHandle tcdh = *cdh;
00757       if(!truth.DigitIsOnlyCrosstalk(tcdh) && !found){
00758         const DigiSignal * signal = truth.GetSignal(tcdh);
00759         if(signal){
00760           for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
00761             const DigiScintHit * hit = signal->GetHit(i);
00762             if(hit){
00763               Int_t track = abs(hit->TrackId());
00764               if(track>=neuId && track<=nextneuId){
00765                 found=true;
00766               }
00767             }
00768           }
00769         }
00770       }
00771       if(found) {
00772         totalPE+= cdh->GetCharge();
00773       }
00774     }
00775   }
00776   TIter stripitr(csh.GetDaughterIterator());
00777   while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(stripitr())) {
00778     TIter digitItr(cstriph->GetDaughterIterator());
00779     while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
00780       Bool_t found=false;
00781       const CandDigitHandle tcdh = *cdh;
00782       if(!truth.DigitIsOnlyCrosstalk(tcdh) && !found){
00783         const DigiSignal * signal = truth.GetSignal(tcdh);
00784         if(signal){
00785           for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
00786             const DigiScintHit * hit = signal->GetHit(i);
00787             if(hit){
00788               Int_t track = abs(hit->TrackId());
00789               if(track>=neuId && track<=nextneuId){
00790                 found=true;
00791               }
00792             }
00793           }
00794         }
00795       }
00796       if(found) {
00797         slicePE+= cdh->GetCharge();
00798       }
00799     }
00800   }
00801 
00802   if(totalPE>0) return  (slicePE/totalPE);
00803   return 0.;
00804 }

Float_t TruthHelper::SliceCompleteness_MaxTimeGap ( CandSliceHandle csh,
Int_t  mincharge 
)

Definition at line 939 of file TruthHelper.cxx.

References Truthifier::DigitIsOnlyCrosstalk(), CandRecord::FindCandHandle(), fMom, GetBestSliceNeuMatch(), CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), DigiSignal::GetHit(), GetNextNeuId(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), and DigiScintHit::TrackId().

00940 {
00941   //Tom Osiecki - osiecki@mail.hep.utexas.edu
00942   const Truthifier & truth = Truthifier::Instance(fMom);
00943   Int_t neuId=GetBestSliceNeuMatch(csh);
00944   Int_t nextneuId = GetNextNeuId(neuId);
00945   Float_t totalPE=0;
00946   Float_t slicePE=0;
00947   CandRecord *crec = dynamic_cast<CandRecord *>
00948     (fMom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00949   CandStripListHandle *cstriplh = dynamic_cast<CandStripListHandle *>
00950     (crec->FindCandHandle("CandStripListHandle"));
00951   TIter striplistitr(cstriplh->GetDaughterIterator());
00952   striplistitr.Reset();
00953   while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(striplistitr())) {
00954     if(cstriph->GetPlane()<121 && cstriph->GetCharge()>=mincharge) {
00955       TIter digitItr(cstriph->GetDaughterIterator());
00956       while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
00957         Bool_t found=false;
00958         const CandDigitHandle tcdh = *cdh;
00959         if(!truth.DigitIsOnlyCrosstalk(tcdh) && !found){
00960           const DigiSignal * signal = truth.GetSignal(tcdh);
00961           if(signal){
00962             for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
00963               const DigiScintHit * hit = signal->GetHit(i);
00964               if(hit){
00965                 Int_t track = abs(hit->TrackId());
00966                 if(track>=neuId && track<=nextneuId){
00967                   found=true;
00968                 }
00969               }
00970             }
00971           }
00972         }
00973         if(found) {
00974           totalPE+= cdh->GetCharge();
00975         }
00976       }
00977     }
00978   }
00979   TIter stripitr(csh.GetDaughterIterator());
00980   while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(stripitr())) {
00981     if(cstriph->GetPlane()<121 && cstriph->GetCharge() >=mincharge) {
00982       TIter digitItr(cstriph->GetDaughterIterator());
00983       while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
00984         Bool_t found=false;
00985         const CandDigitHandle tcdh = *cdh;
00986         if(!truth.DigitIsOnlyCrosstalk(tcdh) && !found){
00987           const DigiSignal * signal = truth.GetSignal(tcdh);
00988           if(signal){
00989             for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
00990               const DigiScintHit * hit = signal->GetHit(i);
00991               if(hit){
00992                 Int_t track = abs(hit->TrackId());
00993                 if(track>=neuId && track<=nextneuId){
00994                   found=true;
00995                 }
00996               }
00997             }
00998           }
00999         }
01000         if(found) {
01001           slicePE+= cdh->GetCharge();
01002         }
01003       }
01004     }
01005   }
01006 
01007   if(totalPE>0) return  (slicePE/totalPE);
01008   return 0.;
01009 }

Float_t TruthHelper::SliceCompleteness_xtalk ( CandSliceHandle csh  ) 

Definition at line 1089 of file TruthHelper.cxx.

References CandRecord::FindCandHandle(), fMom, GetBestSliceNeuMatch(), CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), DigiSignal::GetHit(), GetNextNeuId(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), and DigiScintHit::TrackId().

01090 {
01091   //Tom Osiecki - osiecki@mail.hep.utexas.edu
01092   const Truthifier & truth = Truthifier::Instance(fMom);
01093   Int_t neuId=GetBestSliceNeuMatch(csh);
01094   Int_t nextneuId = GetNextNeuId(neuId);
01095   Float_t totalPE=0;
01096   Float_t slicePE=0;
01097   CandRecord *crec = dynamic_cast<CandRecord *>
01098     (fMom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
01099   CandStripListHandle *cstriplh = dynamic_cast<CandStripListHandle *>
01100     (crec->FindCandHandle("CandStripListHandle"));
01101   TIter striplistitr(cstriplh->GetDaughterIterator());
01102   striplistitr.Reset();
01103   while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(striplistitr())) {
01104     TIter digitItr(cstriph->GetDaughterIterator());
01105     while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
01106       Bool_t found=false;
01107       const CandDigitHandle tcdh = *cdh;
01108       if(!found){
01109         const DigiSignal * signal = truth.GetSignal(tcdh);
01110         if(signal){
01111           for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
01112             const DigiScintHit * hit = signal->GetHit(i);
01113             if(hit){
01114               Int_t track = abs(hit->TrackId());
01115               if(track>=neuId && track<=nextneuId) {
01116                 found=true;
01117               }
01118             }
01119           }
01120         }
01121       }
01122       if(found) {
01123         totalPE+= cdh->GetCharge();
01124       }
01125     }
01126   }
01127   TIter stripitr(csh.GetDaughterIterator());
01128   while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(stripitr())) {
01129     TIter digitItr(cstriph->GetDaughterIterator());
01130     while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
01131       Bool_t found=false;
01132       const CandDigitHandle tcdh = *cdh;
01133       if(!found){
01134         const DigiSignal * signal = truth.GetSignal(tcdh);
01135         if(signal){
01136           for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
01137             const DigiScintHit * hit = signal->GetHit(i);
01138             if(hit){
01139               Int_t track = abs(hit->TrackId());
01140               if(track>=neuId && track<=nextneuId) {
01141                 found=true;
01142               }
01143             }
01144           }
01145         }
01146       }
01147       if(found) {
01148         slicePE+= cdh->GetCharge();
01149       }
01150     }
01151   }
01152 
01153   if(totalPE>0) return (slicePE/totalPE);
01154   return 0.;
01155 }

Float_t TruthHelper::SlicePurity ( CandSliceHandle csh  ) 

Definition at line 850 of file TruthHelper.cxx.

References Truthifier::DigitIsOnlyCrosstalk(), fMom, GetBestSliceNeuMatch(), CandHandle::GetDaughterIterator(), DigiSignal::GetHit(), GetNextNeuId(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), and DigiScintHit::TrackId().

00851 {
00852   const Truthifier & truth = Truthifier::Instance(fMom);
00853   Int_t neuId = GetBestSliceNeuMatch(csh);
00854   Int_t nextneuId = GetNextNeuId(neuId);
00855   Float_t totalPE=0;
00856   Float_t hitPE=0;
00857   TIter stripitr(csh.GetDaughterIterator());
00858   while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(stripitr())) {
00859     TIter digitItr(cstriph->GetDaughterIterator());
00860     while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
00861       Bool_t found=false;
00862       CandDigitHandle tcdh = *cdh;
00863       if(!truth.DigitIsOnlyCrosstalk(tcdh) && !found) {
00864         const DigiSignal * signal = truth.GetSignal(tcdh);
00865         if(signal){
00866           for (UInt_t i=0;i<signal->GetNumberOfHits();i++) {
00867             const DigiScintHit * hit = signal->GetHit(i);
00868             if(hit) {
00869               Int_t track = abs(hit->TrackId());
00870               if(track>=neuId && track<=nextneuId){
00871                 found=true;
00872               }
00873             }
00874           }
00875         }       
00876       }
00877       if(found) {
00878         hitPE+=cdh->GetCharge();
00879         totalPE+= cdh->GetCharge();
00880       } else {
00881         if(!truth.DigitIsOnlyCrosstalk(tcdh))
00882           totalPE+= cdh->GetCharge();
00883       }
00884     }
00885   }
00886   if(totalPE>0){
00887     return (hitPE/totalPE); 
00888   }
00889   return 0;
00890 }

Float_t TruthHelper::SlicePurity_MaxTimeGap ( CandSliceHandle csh,
Int_t  mincharge 
)

Definition at line 892 of file TruthHelper.cxx.

References Truthifier::DigitIsOnlyCrosstalk(), fMom, GetBestSliceNeuMatch(), CandHandle::GetDaughterIterator(), DigiSignal::GetHit(), GetNextNeuId(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), and DigiScintHit::TrackId().

00893 {
00894   //Basically a way to measure the purity of a slice after the INITIAL step of slicing, 
00895   //before adding spectrometer hits and low ph hits.
00896   //Tom Osiecki - osiecki@mail.hep.utexas.edu
00897   const Truthifier & truth = Truthifier::Instance(fMom);
00898   Int_t neuId = GetBestSliceNeuMatch(csh);
00899   Int_t nextneuId = GetNextNeuId(neuId);
00900   Float_t totalPE=0;
00901   Float_t hitPE=0;
00902   TIter stripitr(csh.GetDaughterIterator());
00903   while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(stripitr())) {
00904     if(cstriph->GetPlane() < 121 && cstriph->GetCharge()>=mincharge) {
00905       TIter digitItr(cstriph->GetDaughterIterator());
00906       while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
00907         Bool_t found=false;
00908         CandDigitHandle tcdh = *cdh;
00909         if(!truth.DigitIsOnlyCrosstalk(tcdh) && !found){
00910           const DigiSignal * signal = truth.GetSignal(tcdh);
00911           if(signal){
00912             for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
00913               const DigiScintHit * hit = signal->GetHit(i);
00914               if(hit) {
00915                 Int_t track = abs(hit->TrackId());
00916                 if(track>=neuId && track<=nextneuId){
00917                   found=true;
00918                 }
00919               }
00920             }
00921           }     
00922         }
00923         if(found) {
00924           hitPE+=cdh->GetCharge();
00925           totalPE+= cdh->GetCharge();
00926         } else {
00927           if(!truth.DigitIsOnlyCrosstalk(tcdh))
00928             totalPE+= cdh->GetCharge();
00929         }
00930       }
00931     }
00932   }
00933   if(totalPE>0){
00934     return (hitPE/totalPE); 
00935   }
00936   return 0;
00937 }

Float_t TruthHelper::SlicePurity_xtalk ( CandSliceHandle csh  ) 

Definition at line 1157 of file TruthHelper.cxx.

References fMom, GetBestSliceNeuMatch(), CandHandle::GetDaughterIterator(), DigiSignal::GetHit(), GetNextNeuId(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), and DigiScintHit::TrackId().

01158 {
01159   //Tom Osiecki - osiecki@mail.hep.utexas.edu
01160   const Truthifier & truth = Truthifier::Instance(fMom);
01161   Int_t neuId = GetBestSliceNeuMatch(csh);
01162   Int_t nextneuId = GetNextNeuId(neuId);
01163   Float_t totalPE=0;
01164   Float_t hitPE=0;
01165   TIter stripitr(csh.GetDaughterIterator());
01166   while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(stripitr())) {
01167     TIter digitItr(cstriph->GetDaughterIterator());
01168     while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
01169       Bool_t found=false;
01170       CandDigitHandle tcdh = *cdh;
01171       if(!found){
01172         const DigiSignal * signal = truth.GetSignal(tcdh);
01173         if(signal){
01174           for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
01175             const DigiScintHit * hit = signal->GetHit(i);
01176             if(hit) {
01177               Int_t track = abs(hit->TrackId());
01178               if(track>=neuId && track<=nextneuId){
01179                 found=true;
01180               }
01181             }
01182           }
01183         }       
01184       }
01185       if(found) {
01186         hitPE+=cdh->GetCharge();
01187         totalPE+= cdh->GetCharge();
01188       } else {
01189         totalPE+= cdh->GetCharge();
01190       }
01191     }
01192   }
01193   if(totalPE>0){
01194     return (hitPE/totalPE); 
01195   }
01196   return 0;
01197 }

Int_t TruthHelper::SliceTrueStrip ( CandSliceHandle csh  ) 

Definition at line 806 of file TruthHelper.cxx.

References Truthifier::DigitIsOnlyCrosstalk(), CandRecord::FindCandHandle(), fMom, GetBestSliceNeuMatch(), CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), DigiSignal::GetHit(), GetNextNeuId(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), and DigiScintHit::TrackId().

00807 {
00808   //HUGE NOTE:  Since I'm trying to get the number of strips this function is probably correct to 1st order to 99%
00809   //The reason I say probably is because Strips can be 'polluted' by another neutrino so sometimes a strip that 'truely 
00810   //belongs to a slice' might have a strip that does belong, but it is polluted by another neutrino -> Neglible effect.
00811   //Tom Osiecki - osiecki@mail.hep.utexas.edu
00812   const Truthifier & truth = Truthifier::Instance(fMom);
00813   Int_t neuId = GetBestSliceNeuMatch(csh);
00814   Int_t nextneuId = GetNextNeuId(neuId);
00815   Int_t truenumber = 0;
00816   //First have to find true number of strips so we can make the array.
00817   CandRecord *crec = dynamic_cast<CandRecord *>
00818     (fMom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00819   CandStripListHandle *cstriplh = dynamic_cast<CandStripListHandle *>
00820     (crec->FindCandHandle("CandStripListHandle"));
00821   TIter stripitr(cstriplh->GetDaughterIterator());
00822   stripitr.Reset();
00823   while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(stripitr())) {
00824     TIter digitItr(cstriph->GetDaughterIterator());
00825     Bool_t found=false;
00826     while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())) {
00827       CandDigitHandle tcdh = *cdh;
00828       if(!truth.DigitIsOnlyCrosstalk(tcdh) && !found) { 
00829         const DigiSignal * signal = truth.GetSignal(tcdh);
00830         if(signal){
00831           for (UInt_t i=0;i<signal->GetNumberOfHits();i++) {
00832             const DigiScintHit * hit = signal->GetHit(i);
00833             if(hit){
00834               Int_t track = abs(hit->TrackId());
00835               if(track>=neuId && track<=nextneuId) {
00836                 found=true;
00837               }
00838             }
00839           }
00840         }       
00841       }
00842     }    
00843     if(found) {
00844       truenumber++;
00845     }
00846   }
00847   return truenumber;
00848 }

Int_t TruthHelper::SliceTrueStripxtalk ( CandSliceHandle csh  ) 

Definition at line 1222 of file TruthHelper.cxx.

References CandRecord::FindCandHandle(), fMom, GetBestSliceNeuMatch(), CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), DigiSignal::GetHit(), GetNextNeuId(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), and DigiScintHit::TrackId().

01223 {
01224   //Same as SliceTrueStrip except now including crosstalk
01225   //Tom Osiecki - osiecki@mail.hep.utexas.edu
01226   const Truthifier & truth = Truthifier::Instance(fMom);
01227   Int_t neuId = GetBestSliceNeuMatch(csh);
01228   Int_t nextneuId = GetNextNeuId(neuId);
01229   Int_t truenumber1 = 0;
01230   CandRecord *crec = dynamic_cast<CandRecord *>
01231     (fMom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
01232   CandStripListHandle *cstriplh = dynamic_cast<CandStripListHandle *>
01233     (crec->FindCandHandle("CandStripListHandle"));
01234   TIter stripitr(cstriplh->GetDaughterIterator());
01235   stripitr.Reset();
01236   while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(stripitr())) {
01237     Bool_t found=false;
01238     TIter digitItr(cstriph->GetDaughterIterator());
01239     while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())) {
01240       CandDigitHandle tcdh = *cdh;
01241       if(!found) {      
01242         const DigiSignal * signal = truth.GetSignal(tcdh);
01243         if(signal){
01244           for (UInt_t i=0;i<signal->GetNumberOfHits();i++) {
01245             const DigiScintHit * hit = signal->GetHit(i);
01246             if(hit){
01247               Int_t track = abs(hit->TrackId());
01248               if(track>=neuId && track<=nextneuId) {
01249                 found=true;
01250               }
01251             }
01252           }
01253         }       
01254       }
01255     }    
01256     if(found) {
01257       truenumber1++;
01258     }
01259   }
01260   return truenumber1;
01261 }

Float_t TruthHelper::StripPurity ( CandStripHandle csh  ) 

Definition at line 1775 of file TruthHelper.cxx.

References Truthifier::DigitIsOnlyCrosstalk(), RecDataRecord< T >::FindComponent(), fMom, CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), DigiSignal::GetHit(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), IsNeutrino(), and DigiScintHit::TrackId().

01776 {
01777   //Tom Osiecki - osiecki@mail.hep.utexas.edu
01778   const Truthifier & truth = Truthifier::Instance(fMom);
01779   Int_t nNeutrinos=0;
01780   Int_t totalnum = 0;
01781   SimSnarlRecord *ssr = 
01782     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
01783   if (ssr){ 
01784     const TClonesArray* ctca =
01785       dynamic_cast<const TClonesArray*>
01786       (ssr->FindComponent("TClonesArray","StdHep"));
01787     Int_t siz = ctca->GetEntriesFast();
01788     TArrayI  neuIndBuf(siz+1);
01789     TArrayF  neuEBuf(siz);
01790     for (Int_t ind=0; ind < siz; ++ind) {
01791       TParticle* part = dynamic_cast<TParticle*>((*ctca)[ind]);
01792       if(IsNeutrino(part) && part->GetStatusCode()==0){  
01793         neuIndBuf[nNeutrinos]=ind;
01794         neuEBuf[nNeutrinos]=0;
01795         nNeutrinos++;
01796       }
01797     }
01798     neuIndBuf[nNeutrinos]=siz;
01799     
01800     TIter digitItr(csh->GetDaughterIterator());
01801     while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){    
01802       Bool_t found=false;
01803       CandDigitHandle tcdh = *cdh;
01804       if(!truth.DigitIsOnlyCrosstalk(tcdh) && !found){
01805         const DigiSignal * signal = truth.GetSignal(tcdh);
01806         if(signal){
01807           for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
01808             const DigiScintHit * hit = signal->GetHit(i);
01809             if(hit) {
01810               Int_t track = abs(hit->TrackId());
01811               for(Int_t y=0; y<nNeutrinos; y++) {
01812                 if(track>=neuIndBuf[y] && track<=neuIndBuf[y+1]) {      
01813                   neuEBuf[y]++;
01814                 }
01815               }
01816             }
01817           }
01818         }       
01819       }
01820     }
01821     
01822     for(Int_t y=0; y<nNeutrinos; y++) {
01823       if(neuEBuf[y]>0) totalnum++;
01824     }
01825     
01826     if(totalnum>0) {
01827       return totalnum;
01828     }
01829   }
01830   return 0;
01831 }

Int_t TruthHelper::Stripxtalk ( CandStripHandle csh  ) 

Definition at line 1754 of file TruthHelper.cxx.

References Truthifier::DigitIsOnlyCrosstalk(), fMom, CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), and Truthifier::Instance().

01755 {
01756   //Tom Osiecki - osiecki@mail.hep.utexas.edu
01757   const Truthifier & truth = Truthifier::Instance(fMom);
01758   SimSnarlRecord *ssr = 
01759     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
01760   Int_t flag = 0;
01761   if (ssr){ 
01762     TIter digitItr(csh->GetDaughterIterator());
01763     while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())) {    
01764       CandDigitHandle tcdh = *cdh;
01765       if(truth.DigitIsOnlyCrosstalk(tcdh)) {
01766         flag = 1;
01767       } else {
01768         flag = 0;
01769       }
01770     }
01771   }
01772   return flag;
01773 }

Float_t TruthHelper::TrackCompleteness ( CandTrackHandle cth  ) 

Definition at line 1491 of file TruthHelper.cxx.

References Truthifier::DigitIsOnlyCrosstalk(), fMom, GetBestTrackIdMatch(), CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), DigiSignal::GetHit(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), and DigiScintHit::TrackId().

01492 {
01493   Float_t ntruehits=0;
01494   Float_t ntrkhits=0;
01495   const Truthifier & truth = Truthifier::Instance(fMom);
01496   Int_t trackId= GetBestTrackIdMatch(cth);
01497   
01498   TIter trkstripitr(cth.GetDaughterIterator());
01499   
01500   CandRecord *crec = dynamic_cast<CandRecord *>
01501     (fMom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
01502 //rwh  CandStripSRListHandle *cstriplh = dynamic_cast<CandStripSRListHandle *>
01503 //rwh    (crec->FindCandHandle("CandStripSRListHandle"));
01504   CandStripListHandle *cstriplh = dynamic_cast<CandStripListHandle *>
01505     (crec->FindCandHandle("CandStripListHandle"));
01506 
01507   TIter striplistitr(cstriplh->GetDaughterIterator());
01508   while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(striplistitr())) {
01509     TIter digitItr(cstriph->GetDaughterIterator());
01510     Bool_t found=false;
01511     while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
01512       const CandDigitHandle tcdh = *cdh;
01513       if(!truth.DigitIsOnlyCrosstalk(tcdh) && !found){
01514         const DigiSignal * signal = truth.GetSignal(tcdh);
01515         if(signal){
01516           for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
01517             const DigiScintHit * hit = signal->GetHit(i);
01518             if(hit){
01519               Int_t track = hit->TrackId();
01520               if(track==trackId){
01521                 found=true;
01522               }
01523             }
01524           }         
01525         }
01526       }
01527     }
01528     if(found) {
01529       ntruehits++;
01530       trkstripitr.Reset();
01531       Int_t plane=cstriph->GetPlane();
01532       Int_t strip=cstriph->GetStrip();
01533       while (CandStripHandle* ctrkstriph = dynamic_cast<CandStripHandle*>(trkstripitr())) {
01534         if(ctrkstriph->GetPlane()==plane && ctrkstriph->GetStrip()==strip){
01535           ntrkhits++;
01536           break;
01537         }
01538       }
01539     }
01540   }
01541   if(ntruehits>0) return ntrkhits/ntruehits;
01542   return 0.;
01543 }

Float_t TruthHelper::TrackCompleteness ( CandTrackHandle cth,
CandSliceHandle csh 
)

Definition at line 1444 of file TruthHelper.cxx.

References Truthifier::DigitIsOnlyCrosstalk(), fMom, GetBestTrackIdMatch(), CandHandle::GetDaughterIterator(), DigiSignal::GetHit(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), and DigiScintHit::TrackId().

Referenced by EVD::UpdateSummary().

01445 {
01446   Float_t ntruehits=0;
01447   Float_t ntrkhits=0;
01448   const Truthifier & truth = Truthifier::Instance(fMom);
01449   Int_t trackId=GetBestTrackIdMatch(cth);
01450   
01451   TIter trkstripitr(cth.GetDaughterIterator());
01452   
01453   TIter striplistitr(csh.GetDaughterIterator());
01454   while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(striplistitr())) {
01455     TIter digitItr(cstriph->GetDaughterIterator());
01456     Bool_t found=false;
01457     while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
01458       const CandDigitHandle tcdh = *cdh;
01459       if(!truth.DigitIsOnlyCrosstalk(tcdh) && !found){
01460         const DigiSignal * signal = truth.GetSignal(tcdh);
01461         if(signal){
01462           for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
01463             const DigiScintHit * hit = signal->GetHit(i);
01464             if(hit){
01465               Int_t track = hit->TrackId();
01466               if(track==trackId){
01467                 found=true;
01468               }
01469             }
01470           }         
01471         }
01472       }
01473     }
01474     if(found) {
01475       ntruehits++;
01476       trkstripitr.Reset();
01477       Int_t plane=cstriph->GetPlane();
01478       Int_t strip=cstriph->GetStrip();
01479       while (CandStripHandle* ctrkstriph = dynamic_cast<CandStripHandle*>(trkstripitr())) {
01480         if(ctrkstriph->GetPlane()==plane && ctrkstriph->GetStrip()==strip){
01481           ntrkhits++;
01482           break;
01483         }
01484       }
01485     }
01486   }
01487   if(ntruehits>0) return (ntrkhits/ntruehits);
01488   return 0.;
01489 }

Float_t TruthHelper::TrackPurity ( CandTrackHandle cth,
Int_t  trackId 
)

Definition at line 1264 of file TruthHelper.cxx.

References fMom, CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), DigiSignal::GetHit(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), total(), and DigiScintHit::TrackId().

Referenced by EVD::UpdateSummary().

01265 {
01266   const Truthifier & truth = Truthifier::Instance(fMom);
01267   Float_t total=0;
01268   Float_t hits=0;
01269   SimSnarlRecord *ssr = 
01270     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
01271   if (ssr){ 
01272     TIter stripitr(cth.GetDaughterIterator());
01273     while (CandStripHandle* csh = dynamic_cast<CandStripHandle*>(stripitr())) {
01274       TIter digitItr(csh->GetDaughterIterator());
01275       Bool_t found=false;
01276       while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
01277         CandDigitHandle tcdh = *cdh;
01278         const DigiSignal * signal = truth.GetSignal(tcdh);
01279         if(signal){
01280           for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
01281             const DigiScintHit * hit = signal->GetHit(i);
01282             if(hit){
01283               Int_t track = abs(hit->TrackId());
01284               if(track==trackId)found=true;
01285             }
01286           }
01287         }
01288       } 
01289       total++;
01290       if(found) hits++;
01291     }
01292   }
01293   if(total>0){
01294     return hits/total;
01295   }
01296   return 0.0; 
01297 }

Double_t TruthHelper::TrueNeuE ( CandSliceHandle csh  ) 

Definition at line 1199 of file TruthHelper.cxx.

References RecDataRecord< T >::FindComponent(), fMom, GetBestSliceNeuMatch(), MomNavigator::GetFragment(), Msg::kInfo, and MSG.

01200 {
01201   //Tom Osiecki - osiecki@mail.hep.utexas.edu
01202   //const Truthifier & truth = Truthifier::Instance(fMom);
01203   SimSnarlRecord *ssr = 
01204     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
01205   Int_t ind = GetBestSliceNeuMatch(csh);
01206   if (ssr && ind>=0){ 
01207     const TClonesArray* ctca =
01208       dynamic_cast<const TClonesArray*>
01209       (ssr->FindComponent("TClonesArray","StdHep"));
01210     TParticle* part = dynamic_cast<TParticle*>((*ctca)[ind]);
01211     if(part->Energy() > 0) {
01212       MSG("TruthHelper", Msg::kInfo) << "Neu " << ind << " E is: " << part->Energy() << endl;
01213       return part->Energy();
01214     } else {
01215       return 0.0;
01216     }
01217   } else {
01218     return 0.0;
01219   }
01220 }

Int_t TruthHelper::TruthSliceNum (  ) 

Definition at line 1011 of file TruthHelper.cxx.

References Truthifier::DigitIsOnlyCrosstalk(), CandRecord::FindCandHandle(), RecDataRecord< T >::FindComponent(), fMom, CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), DigiSignal::GetHit(), DigiSignal::GetNumberOfHits(), Truthifier::GetSignal(), Truthifier::Instance(), IsDocStatus(), IsNeutrino(), DigiScintHit::Plane(), and DigiScintHit::TrackId().

01011                                  {
01012   //This function is an 'attempt' to define what the true number of slices should be
01013   //Obviously this is general and in the end only comparisons of energy spectrums/global things etc,
01014   //will be the ultimate test of slicing : I rarely use this now
01015   //Tom Osiecki - osiecki@mail.hep.utexas.edu
01016   const Truthifier & truth = Truthifier::Instance(fMom);
01017   Int_t nNeutrinos=0;
01018   SimSnarlRecord *ssr = 
01019     dynamic_cast<SimSnarlRecord*>(fMom->GetFragment("SimSnarlRecord"));
01020   if (ssr){ 
01021     const TClonesArray* ctca =
01022       dynamic_cast<const TClonesArray*>
01023       (ssr->FindComponent("TClonesArray","StdHep"));
01024     Int_t siz = ctca->GetEntriesFast();
01025     TArrayI  neuIndBuf(siz+1);
01026     TArrayF  neuEBuf(siz);
01027     TArrayF  neuEBuf2(siz);
01028     for (Int_t ind=0; ind < siz; ++ind) {
01029       TParticle* part = dynamic_cast<TParticle*>((*ctca)[ind]);
01030       if(IsNeutrino(part) && IsDocStatus(part)){ 
01031         neuIndBuf[nNeutrinos]=ind;
01032         neuEBuf[nNeutrinos]=0;
01033         neuEBuf2[nNeutrinos]=0;
01034         nNeutrinos++;
01035       }
01036     }
01037     neuIndBuf[nNeutrinos]=siz;
01038     CandRecord *crec = dynamic_cast<CandRecord *>
01039       (fMom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
01040     CandStripListHandle *cstriplh = dynamic_cast<CandStripListHandle *>
01041       (crec->FindCandHandle("CandStripListHandle"));
01042     
01043     for(Int_t ind=0; ind < nNeutrinos; ++ind) {
01044       TIter striplistitr(cstriplh->GetDaughterIterator());
01045       while (CandStripHandle* cstriph = dynamic_cast<CandStripHandle*>(striplistitr())) {
01046         Bool_t found=false;
01047         TIter digitItr(cstriph->GetDaughterIterator());
01048         while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())){
01049           const CandDigitHandle tcdh = *cdh;
01050           if(!truth.DigitIsOnlyCrosstalk(tcdh) && !found){
01051             const DigiSignal * signal = truth.GetSignal(tcdh);
01052             if(signal){
01053               for (UInt_t i=0;i<signal->GetNumberOfHits();i++){
01054                 const DigiScintHit * hit = signal->GetHit(i);
01055                 if(hit && hit->Plane()<121) { //Events should NOT be taken if they interacted wholely in the spectro
01056                   Int_t track = abs(hit->TrackId());
01057                   if(track>=neuIndBuf[ind] && track <= neuIndBuf[ind+1]){
01058                     neuEBuf[ind]++;
01059                   }
01060                 }
01061               }
01062             }
01063           }
01064         }
01065         for(Int_t ind=0; ind < nNeutrinos; ++ind) {
01066           if(neuEBuf[ind]>0) {
01067             neuEBuf2[ind]++;
01068             neuEBuf[ind] = 0;
01069           } else {
01070             neuEBuf[ind] = 0;
01071           }
01072         }
01073       }
01074     }
01075     
01076     int counter = 0;
01077     for(int ind=0; ind < nNeutrinos; ++ind) {
01078       if(neuEBuf2[ind] >= 2) counter++;
01079     }
01080     
01081     if(counter > 0) {
01082       return counter;
01083     }
01084     return 0; 
01085   }
01086   return 0;
01087 }


Member Data Documentation

const MomNavigator* TruthHelper::fMom [private]
Float_t TruthHelper::m_p4El1[4] [private]

Definition at line 49 of file TruthHelper.h.

Referenced by GetP4El1().

Float_t TruthHelper::m_p4Mu1[4] [private]

Definition at line 47 of file TruthHelper.h.

Referenced by GetP4Mu1().

Float_t TruthHelper::m_p4Mu2[4] [private]

Definition at line 48 of file TruthHelper.h.

Referenced by GetP4Mu2().

Float_t TruthHelper::m_p4Neu[4] [private]

Definition at line 46 of file TruthHelper.h.

Referenced by GetP4Neu().

Float_t TruthHelper::m_p4Shw[4] [private]

Definition at line 50 of file TruthHelper.h.

Referenced by GetP4Shw().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1