#include <Truthifier.h>
Public Member Functions | |
| Truthifier (const MomNavigator *mom, Bool_t supressErrors=false) | |
| void | Reset (const MomNavigator *mom, Bool_t supressErrors=false) |
| Bool_t | IsValid () const |
| std::vector< Int_t > | GetListOfNeutrinoIndecies () const |
| Int_t | GetStdHepSize () const |
| const TParticle * | GetStdHepParticle (Int_t index) const |
| Int_t | GetScintHitListSize () const |
| const DigiScintHit * | GetScintHit (Int_t index) const |
| const REROOT_NeuKin * | GetNeuKin (Int_t i) const |
| const REROOT_NeuKin * | GetNeuKinOfParticle (Int_t index) const |
| const RawDigit * | GetRawDigit (const CandDigitHandle &cdh) const |
| const std::vector< const DigiSignal * > & | GetSignalVector (const DigiScintHit *hit) const |
| const RawDigit * | GetRawDigit (const DigiSignal *signal) const |
| const std::vector< const RawDigit * > & | GetRawDigitVector (const DigiScintHit *hit) const |
| template<class T> | |
| std::vector< const T * > | GetCandidatesFromParticle (int ParticleId, const CandHandle *list) const |
| template<class T> | |
| std::vector< const T * > | GetCandidatesFromTrack (int TrackId, const CandHandle *list) const |
| Int_t | GetNeutrinoOfTrack (Int_t trackId) const |
| const DigiSignal * | GetSignal (const CandDigitHandle &cdh) const |
| Digit->Signal. | |
| const DigiSignal * | GetSignal (const RawDigit *digit) const |
| DigiSignal::DigiPmtTruth_t | GetSignalTruthFlags (const CandDigitHandle &cdh) const |
| DigiSignal::DigiPmtTruth_t | GetSignalTruthFlags (const RawDigit *digit) const |
| Bool_t | DigitIsOnlyCrosstalk (const CandDigitHandle &cdh) const |
| Bool_t | DigitIsOnlyCrosstalk (const RawDigit *digit) const |
| Bool_t | DigitIsOnlyCrosstalk (const CandDigitHandle *cdh) const |
| Float_t | IsSignalFromParticle (Int_t particleID, const DigiSignal *signal) const |
| Float_t | IsSignalFromTrack (Int_t trackID, const DigiSignal *signal) const |
| Float_t | IsSignalFromNeutrino (Int_t neturinoID, const DigiSignal *signal, Double_t max_t=1e19) const |
| const DigiScintHit * | GetBiggestHit (const CandDigitHandle &cdh) const |
| const DigiScintHit * | GetBiggestHit (const RawDigit *digit) const |
| Float_t | IsDigitFromParticle (Int_t particleID, const CandDigitHandle &cdh) const |
| Float_t | IsDigitFromParticle (Int_t particleID, const RawDigit *digit) const |
| Float_t | IsDigitFromTrack (Int_t trackID, const CandDigitHandle &cdh) const |
| Float_t | IsDigitFromTrack (Int_t trackID, const RawDigit *digit) const |
| Float_t | IsDigitFromNeutrino (Int_t neutrinoID, const CandDigitHandle &cdh, Double_t max_t=1e19) const |
| Float_t | IsDigitFromNeutrino (Int_t neutrinoID, const RawDigit *digit, Double_t max_t=1e19) const |
| PlexStripEndId | BestSEIdOfDigit (const CandDigitHandle *cdh) const |
| Candidate -> info. | |
| void | GetAllScintHits (const RawDigit *digit, std::set< const DigiScintHit * > &outSet) const |
| These functions get a list (set) of hits, not overcounting. | |
| void | GetAllScintHits (const CandDigitHandle &cdh, std::set< const DigiScintHit * > &outSet) const |
| void | GetAllScintHits (const CandHandle *candidate, std::set< const DigiScintHit * > &outSet) const |
| Float_t | GetTotalEnergy (const RawDigit *digit, Int_t particleID=0) const |
| Float_t | GetTotalEnergy (const CandDigitHandle &cdh, Int_t particleID=0) const |
| Float_t | GetTotalEnergy (const CandHandle *candidate, Int_t particleID=0) const |
| Float_t | IsCandidateFromParticle (Int_t particleID, const CandHandle *candidate) const |
| Float_t | IsCandidateFromTrack (Int_t trackID, const CandHandle *candidate) const |
| Float_t | IsCandidateGenuine (const CandHandle *candidate) const |
| Use this to see if your CandStrip is all noise or crosstalk:. | |
| virtual void | Print (const Option_t *="") const |
| Prints out the whole blessed mess. | |
Static Public Member Functions | |
| const Truthifier & | Instance (const MomNavigator *mom, Bool_t supressErrors=false) |
Private Types | |
| typedef std::vector< Int_t > | NeutrinoList_t |
| typedef std::vector< Int_t > | TrackIndexToNeutrinoIndex_t |
| typedef std::map< Int_t, std::vector< Int_t > > | NeutrinoIndexToTrackIndex_t |
| typedef std::map< Int_t, std::vector< const DigiScintHit * > > | TrackToHit_t |
| typedef std::map< const DigiScintHit *, std::vector< const DigiSignal * > > | HitToSignal_t |
| typedef std::map< const DigiSignal *, const RawDigit * > | SignalToDigit_t |
| typedef std::map< UInt_t, const DigiSignal * > | SignalMap_t |
Private Member Functions | |
| void | CandDigitsFrom (std::vector< const CandDigitHandle * > &output, const CandHandle *list) const |
| ClassDef (Truthifier, 0) | |
Private Attributes | |
| const MomNavigator * | fMom |
| Bool_t | fValid |
| const RawDigitDataBlock * | fRddb |
| const TClonesArray * | fStdHep |
| const TClonesArray * | fNeuKins |
| const TObjArray * | fScintHitArray |
| NeutrinoList_t | fNeutrinoList |
| TrackIndexToNeutrinoIndex_t | fTrackIndexToNeutrinoIndex |
| NeutrinoIndexToTrackIndex_t | fNeutrinoIndexToTrackIndex |
| TrackToHit_t | fTrackToHit |
| HitToSignal_t | fHitToSignal |
| SignalToDigit_t | fSignalToDigit |
| SignalMap_t | fSignals |
Created on:
Definition at line 62 of file Truthifier.h.
|
|
Definition at line 208 of file Truthifier.h. |
|
|
Definition at line 200 of file Truthifier.h. |
|
|
Definition at line 193 of file Truthifier.h. |
|
|
Definition at line 216 of file Truthifier.h. |
|
|
Definition at line 212 of file Truthifier.h. |
|
|
Definition at line 197 of file Truthifier.h. |
|
|
Definition at line 204 of file Truthifier.h. |
|
||||||||||||
|
Definition at line 75 of file Truthifier.h. References Reset(). 00075 { Reset(mom,supressErrors); };
|
|
|
Candidate -> info. Returns the SEID alternative for the strip end that has the most PEs on it. Definition at line 724 of file Truthifier.cxx. References PlexSEIdAltL::GetEnd(), DigiSignal::GetHit(), DigiSignal::GetHitWeight(), DigiSignal::GetNumberOfHits(), CandDigitHandle::GetPlexSEIdAltL(), GetSignal(), PlexStripEndId::IsValid(), MSG, PlexStripEndId::SetEnd(), and DigiScintHit::StripEndId(). Referenced by DmxDeMuxModule::Ana(). 00725 {
00730 // Get list of the stripends.
00731 std::map<PlexStripEndId,float> ends;
00732 std::map<PlexStripEndId,float>::iterator endit;
00733
00734 if(!cdh) {
00735 MSG("DataUtil",Msg::kError) << "BestSEIdOfDigit was handed null CandDigitHandle*" << endl;
00736 return PlexStripEndId();
00737 }
00738
00739 const DigiSignal* signal = GetSignal(*cdh);
00740 if(signal) {
00741 for(UInt_t i=0; i<signal->GetNumberOfHits(); i++) {
00742 PlexStripEndId seid = signal->GetHit(i)->StripEndId();
00743 float weight = signal->GetHitWeight(i);
00744 ends[seid] += weight;
00745 }
00746 } else return PlexStripEndId();
00747
00748 // Find the best one.
00749 PlexStripEndId best;
00750 float bestpe = 0;
00751 for(endit = ends.begin(); endit!= ends.end(); endit++) {
00752 if(endit->second > bestpe) {
00753 bestpe = endit->second;
00754 best = endit->first;
00755 }
00756 }
00757
00758 if(best.IsValid()) best.SetEnd(cdh->GetPlexSEIdAltL().GetEnd());
00759
00760 return best;
00761 }
|
|
||||||||||||
|
Definition at line 982 of file Truthifier.cxx. References CandHandle::GetDaughterIterator(). Referenced by GetAllScintHits(), IsCandidateFromParticle(), IsCandidateFromTrack(), and IsCandidateGenuine(). 00984 {
00985 if(!list) return;
00986
00987 const CandDigitHandle* cdh =
00988 dynamic_cast<const CandDigitHandle*>(list);
00989
00990 if(cdh){
00991 output.push_back(cdh);
00992 return;
00993 }
00994
00995 TIter it = list->GetDaughterIterator();
00996 TObject* obj;
00997 while( (obj=it.Next()) ) {
00998 const CandHandle* newHandle = dynamic_cast<const CandHandle*>(obj);
00999 if(newHandle)
01000 CandDigitsFrom(output,newHandle);
01001 };
01002 }
|
|
||||||||||||
|
|
|
|
Definition at line 137 of file Truthifier.h. References DigitIsOnlyCrosstalk(). 00137 {
00138 if(cdh) return DigitIsOnlyCrosstalk(*cdh); return false;};
|
|
|
Example how to use the truth flags. Returns true if the Digit is has some crosstalk but has no genuine light. Definition at line 538 of file Truthifier.cxx. References digit(), and GetSignalTruthFlags(). 00539 {
00545 DigiSignal::DigiPmtTruth_t flags = GetSignalTruthFlags(digit);
00546 if( ( (flags & DigiSignal::kCrosstalk) || (flags & DigiSignal::kCrosstalkOptical) )
00547 && ( ! (flags & DigiSignal::kGenuine) ) ) {
00548 return true;
00549 }
00550 return false;
00551
00552 }
|
|
|
||||||||||||
|
Definition at line 793 of file Truthifier.cxx. References CandDigitsFrom(), and GetAllScintHits(). 00795 {
00796 if(!candidate) return;
00797 std::vector<const CandDigitHandle*> digits;
00798 CandDigitsFrom(digits,candidate);
00799
00800 for(UInt_t i=0;i<digits.size();i++)
00801 GetAllScintHits(*(digits[i]),outSet);
00802 }
|
|
||||||||||||
|
Definition at line 779 of file Truthifier.cxx. References DigiSignal::GetHit(), DigiSignal::GetNumberOfHits(), and GetSignal(). 00781 {
00782 const DigiSignal* signal = GetSignal(cdh);
00783 if(!signal) return;
00784 UInt_t n = signal->GetNumberOfHits();
00785 for(UInt_t i=0; i<n; i++) {
00786 const DigiScintHit* hit = signal->GetHit(i);
00787 outSet.insert(hit);
00788 }
00789 }
|
|
||||||||||||
|
These functions get a list (set) of hits, not overcounting.
Definition at line 765 of file Truthifier.cxx. References digit(), DigiSignal::GetHit(), DigiSignal::GetNumberOfHits(), and GetSignal(). Referenced by GetAllScintHits(), and GetTotalEnergy(). 00767 {
00768 const DigiSignal* signal = GetSignal(digit);
00769 if(!signal) return;
00770 UInt_t n = signal->GetNumberOfHits();
00771 for(UInt_t i=0; i<n; i++) {
00772 const DigiScintHit* hit = signal->GetHit(i);
00773 outSet.insert(hit);
00774 }
00775 }
|
|
|
Returns pointer to the hit that contributed the most light to this digit. Definition at line 640 of file Truthifier.cxx. References digit(), DigiSignal::GetBiggestHit(), and GetSignal(). 00641 {
00646 const DigiSignal* signal = GetSignal(digit);
00647 if(!signal) return 0;
00648 return signal->GetBiggestHit();
00649 }
|
|
|
Returns pointer for the hit that contributed the most light to this digit. Definition at line 628 of file Truthifier.cxx. References DigiSignal::GetBiggestHit(), and GetSignal(). Referenced by MCAnalysis::Ana(), and AlgRmMu::RunAlg(). 00629 {
00634 const DigiSignal* signal = GetSignal(cdh);
00635 if(!signal) return 0;
00636 return signal->GetBiggestHit();
00637 }
|
|
||||||||||||||||
|
Track->Hit->Signal->Digit->Candidate Use like this: myTruthifier->GetCandidatesFromParticle<CandStripHandle>(13,CandStripListHandlePtr) Definition at line 384 of file Truthifier.cxx. References CandHandle::GetDaughterIterator(), and IsCandidateFromParticle(). 00386 {
00391 std::vector<const T*> output;
00392
00393 // Loop throuth the list.
00394 TIter it = list->GetDaughterIterator();
00395 TObject* obj;
00396 while( (obj=it.Next()) ) {
00397 const T* thing = dynamic_cast<const T*>(obj);
00398 if(thing) {
00399 const CandHandle* handle = dynamic_cast<const CandHandle*>(thing);
00400 if(handle)
00401 if(IsCandidateFromParticle(ParticleId,handle)) output.push_back(thing);
00402 }
00403 };
00404
00405 return output;
00406 }
|
|
||||||||||||||||
|
Reads the given CandxxxxListHandle and returns a vector of CandxxxxHandles that are from the TrackId. Definition at line 410 of file Truthifier.cxx. References CandHandle::GetDaughterIterator(), and IsCandidateFromTrack(). 00412 {
00417 std::vector<const T*> output;
00418
00419 // Loop throuth the list.
00420 TIter it = list->GetDaughterIterator();
00421 TObject* obj;
00422 while( (obj=it.Next()) ) {
00423 const T* thing = dynamic_cast<const T*>(obj);
00424 if(thing) {
00425 const CandHandle* handle = dynamic_cast<const CandHandle*>(thing);
00426 if(handle)
00427 if(IsCandidateFromTrack(TrackId,handle)) output.push_back(thing);
00428 }
00429 };
00430
00431 return output;
00432 }
|
|
|
Definition at line 256 of file Truthifier.cxx. Referenced by ChopModule::Ana(), and AlgChopListPerfectMC::RunAlg(). 00257 {
00258 return fNeutrinoList;
00259 }
|
|
|
Definition at line 278 of file Truthifier.cxx. Referenced by ChopModule::Ana(), and GetNeuKinOfParticle(). 00279 {
00280 if(fNeuKins) {
00281 return dynamic_cast<const REROOT_NeuKin*>((*fNeuKins)[i]);
00282 }
00283 return 0;
00284 }
|
|
|
Definition at line 286 of file Truthifier.cxx. References fNeutrinoList, and GetNeuKin(). 00287 {
00288 // Find matching neutrino
00289 for(Int_t i=fNeutrinoList.size()-1;i>=0;i--) {
00290 if(fNeutrinoList[i] <= index) {
00291 return GetNeuKin(i);
00292 }
00293 }
00294 return 0;
00295 }
|
|
|
Backward tracking: Digit->...->Particle Definition at line 328 of file Truthifier.cxx. References abs(), and fTrackIndexToNeutrinoIndex. Referenced by ChopModule::Ana(). 00329 {
00330 return fTrackIndexToNeutrinoIndex[abs(track)];
00331 }
|
|
|
Retrieves a pointer to a raw digit caused by a given DigiSignal. Definition at line 350 of file Truthifier.cxx. References fSignalToDigit. 00351 {
00355 SignalToDigit_t::const_iterator it = fSignalToDigit.find(signal);
00356 if(it!=fSignalToDigit.end()) return it->second;
00357 return 0;
00358 }
|
|
|
Definition at line 313 of file Truthifier.cxx. References RawDigitDataBlock::At(), digit(), fRddb, and CandDigitHandle::GetRawDigitIndex(). Referenced by ChopEvaluation::Evaluate(), and GetRawDigitVector(). 00314 {
00315 int digitIndex = cdh.GetRawDigitIndex();
00316 const RawDigit* digit = 0;
00317 if(fRddb) digit = fRddb->At(digitIndex);
00318 return digit;
00319 }
|
|
|
Creates a vector of RawDigit pointers associated with a given particle Hit. Note: copy the output after retrieving; returned variable is a simple static variable. Definition at line 362 of file Truthifier.cxx. References GetRawDigit(), and GetSignalVector(). 00363 {
00371 static std::vector<const RawDigit*> output;
00372 output.clear();
00373 const std::vector<const DigiSignal*>& signalList
00374 = GetSignalVector(hit);
00375 for(UInt_t i=0;i<signalList.size();i++) {
00376 output.push_back(GetRawDigit(signalList[i]));
00377 }
00378 return output;
00379 }
|
|
|
Definition at line 305 of file Truthifier.cxx. References GetScintHitListSize(). Referenced by ChopModule::Ana(). 00306 {
00307 if(index >= GetScintHitListSize()) return 0;
00308 return dynamic_cast<const DigiScintHit*>( (*fScintHitArray)[index] );
00309 }
|
|
|
Definition at line 297 of file Truthifier.cxx. References fScintHitArray. Referenced by ChopModule::Ana(), and GetScintHit(). 00298 {
00299 if(fScintHitArray) {
00300 return fScintHitArray->GetEntriesFast();
00301 }
00302 return 0;
00303 }
|
|
|
GetSignal Retrives pointer to the DigiSignal associated with this RawDigit. Definition at line 463 of file Truthifier.cxx. References digit(), fSignals, and RawDigiDigitMixIn::GetDigiSignalIndex(). 00464 {
00469
00470 if(digit==0) return NULL;
00471
00472 const RawDigiDigitMixIn* ddigit = dynamic_cast<const RawDigiDigitMixIn*>(digit);
00473 if(ddigit==0) return NULL;
00474
00475 UInt_t id = ddigit->GetDigiSignalIndex();
00476
00477 SignalMap_t::const_iterator it = fSignals.find(id);
00478 if(it!=fSignals.end()) return it->second;
00479
00480 return NULL;
00481 }
|
|
|
|
Gets the truth flags for the digit. Definition at line 511 of file Truthifier.cxx. References digit(), GetSignal(), and DigiSignal::GetTruth(). 00512 {
00516 const DigiSignal* signal = GetSignal(digit);
00517 if(signal==0) return DigiSignal::kUnknown;
00518 return signal->GetTruth();
00519 }
|
|
|
Gets the truth flags for the digit. Definition at line 499 of file Truthifier.cxx. References GetSignal(), and DigiSignal::GetTruth(). Referenced by DigitIsOnlyCrosstalk(), NtpTHModule::FillNtpTHStrip(), and IsCandidateGenuine(). 00500 {
00504 const DigiSignal* signal = GetSignal(cdh);
00505 if(signal==0) return DigiSignal::kUnknown;
00506 return signal->GetTruth();
00507 }
|
|
|
Forward tracking: Particle->...->Digit Definition at line 336 of file Truthifier.cxx. References fHitToSignal. Referenced by GetRawDigitVector(). 00337 {
00341 HitToSignal_t::const_iterator it = fHitToSignal.find(hit);
00342 if(it!=fHitToSignal.end()) return it->second;
00343
00344 static std::vector<const DigiSignal*> nullResult;
00345 return nullResult;
00346 }
|
|
|
Definition at line 261 of file Truthifier.cxx. Referenced by ChopModule::Ana(). 00262 {
00263 if(fStdHep) {
00264 TParticle* part = dynamic_cast<TParticle*>((*fStdHep)[index]);
00265 return part;
00266 }
00267 return 0;
00268 }
|
|
|
Definition at line 270 of file Truthifier.cxx. References fStdHep. 00271 {
00272 if(fStdHep) {
00273 return fStdHep->GetEntries();
00274 }
00275 return 0;
00276 }
|
|
||||||||||||
|
Definition at line 850 of file Truthifier.cxx. References abs(), DigiScintHit::DE(), GetAllScintHits(), DigiScintHit::ParticleId(), and total(). 00851 {
00852 // Get the total energy of all scinthits that lent energy to this digit.
00853 // If particleID is non-zero, only add energy from that particle type
00854 // (-ve or +ve of that type)
00855
00856 std::set<const DigiScintHit*> hits;
00857 std::set<const DigiScintHit*>::iterator it;
00858 Float_t total = 0;
00859 GetAllScintHits(candidate,hits);
00860 for(it = hits.begin(); it!= hits.end(); it++) {
00861 const DigiScintHit* hit = *it;
00862 if(hit)
00863 if((particleID==0) || (abs(hit->ParticleId()) == particleID))
00864 total += hit->DE();
00865 }
00866
00867 return total;
00868 }
|
|
||||||||||||
|
Definition at line 828 of file Truthifier.cxx. References abs(), DigiScintHit::DE(), GetAllScintHits(), DigiScintHit::ParticleId(), and total(). 00829 {
00830 // Get the total energy of all scinthits that lent energy to this digit.
00831 // If particleID is non-zero, only add energy from that particle type
00832 // (-ve or +ve of that type)
00833
00834 std::set<const DigiScintHit*> hits;
00835 std::set<const DigiScintHit*>::iterator it;
00836 Float_t total = 0;
00837 GetAllScintHits(cdh,hits);
00838 for(it = hits.begin(); it!= hits.end(); it++) {
00839 const DigiScintHit* hit = *it;
00840 if(hit)
00841 if((particleID==0) || (abs(hit->ParticleId()) == particleID))
00842 total += hit->DE();
00843 }
00844
00845 return total;
00846 }
|
|
||||||||||||
|
Note that using these functions you may OVERCOUNT energy! e.g. two digits from the same strip will give the same energy but asking for a CandStrip's energy will NOT overcount. Definition at line 806 of file Truthifier.cxx. References abs(), DigiScintHit::DE(), digit(), GetAllScintHits(), DigiScintHit::ParticleId(), and total(). 00807 {
00808 // Get the total energy of all scinthits that lent energy to this digit.
00809 // If particleID is non-zero, only add energy from that particle type
00810 // (-ve or +ve of that type)
00811
00812 std::set<const DigiScintHit*> hits;
00813 std::set<const DigiScintHit*>::iterator it;
00814 Float_t total = 0;
00815 GetAllScintHits(digit,hits);
00816 for(it = hits.begin(); it!= hits.end(); it++) {
00817 const DigiScintHit* hit = *it;
00818 if(hit)
00819 if((particleID==0) || (abs(hit->ParticleId()) == particleID))
00820 total += hit->DE();
00821 }
00822
00823 return total;
00824 }
|
|
||||||||||||
|
Important note: If there's anything you want from this object please let me know and I'll put it in. --Nathaniel Definition at line 29 of file Truthifier.cxx. References RecDataRecord< T >::AdoptTemporary(), RecDataRecord< T >::FindTemporary(), IsValid(), and Reset(). Referenced by DmxDeMuxModule::Ana(), CustomLightInjector::Ana(), ChopModule::Ana(), TruthHelper::EventCompletenessImp(), TruthHelper::EventPurity(), NtpMCModule::FillNtpMCTruth(), TruthHelper::GetBestEventNeuMatch(), TruthHelper::GetBestNeuMatch(), TruthHelper::GetBestShowerNeuMatch(), TruthHelper::GetBestSliceNeuMatch(), TruthHelper::GetBestTrackIdMatch(), TruthHelper::GetStripNeuIndex(), TruthHelper::GetTrackMaxE(), TruthHelper::GetTrackMinE(), CDTruthifier::GetTruthHitInfo(), TruthHelper::NumNeu(), NtpTHModule::Reco(), AlgChopListPerfectMC::RunAlg(), TruthHelper::secondNEU(), TruthHelper::ShowerCompletenessImp(), TruthHelper::ShowerPurity(), TruthHelper::SliceCompleteness(), TruthHelper::SliceCompleteness_MaxTimeGap(), TruthHelper::SliceCompleteness_xtalk(), TruthHelper::SlicePurity(), TruthHelper::SlicePurity_MaxTimeGap(), TruthHelper::SlicePurity_xtalk(), TruthHelper::SliceTrueStrip(), TruthHelper::SliceTrueStripxtalk(), TruthHelper::StripPurity(), TruthHelper::Stripxtalk(), TruthHelper::TrackCompleteness(), TruthHelper::TrackPurity(), and TruthHelper::TruthSliceNum(). 00030 {
00035
00036 // Deal with the case of a null mom.
00037 static Truthifier nullTruth(0);
00038 if(mom==0) return nullTruth;
00039
00040 // Look for the simSnarl in Mom.
00041 SimSnarlRecord* simsnarl = 0;
00042 TObject* tobj;
00043 TIter fragiter = mom->FragmentIter();
00044 while( ( tobj = fragiter.Next() ) ) {
00045 simsnarl = dynamic_cast<SimSnarlRecord*>(tobj);
00046 if(simsnarl) break;
00047 }
00048
00049 if(simsnarl==0) return nullTruth; // No good.
00050
00051 // look for the Truthifier in the simSnarl.
00052 const TObject* o;
00053 o = simsnarl->FindTemporary("Truthifier","Truthifier");
00054 if(o) {
00055 // Found one.
00056 Truthifier* ct = const_cast<Truthifier*>(dynamic_cast<const Truthifier*>(o));
00057 if(ct){
00058 if(ct->IsValid()) return *ct;
00059 else {
00060 ct->Reset(mom,supressErrors);
00061 return *ct;
00062 // it's not valid. Tell the record to drop it.
00063 // whooops, this is illegal.
00064 //simsnarl->RemoveTemporary(o);
00065 }
00066 }
00067 }
00068
00069 // Ok, now there's no truthifier.
00070 // Make one.
00071 Truthifier* t = new Truthifier(mom, supressErrors);
00072
00073 // Save it.
00074 simsnarl->AdoptTemporary(t);
00075
00076 // return it.
00077 return *t;
00078 }
|
|
||||||||||||
|
Returns the fractional digits that are due to a certain particle ID Definition at line 874 of file Truthifier.cxx. References CandDigitsFrom(), IsDigitFromParticle(), and total(). Referenced by GetCandidatesFromParticle(). 00875 {
00879 if(!candidate) return 0;
00880 std::vector<const CandDigitHandle*> digits;
00881 CandDigitsFrom(digits,candidate);
00882
00883 // Test each digit. to see if it satisfies.
00884 Float_t total = 0;
00885 for(UInt_t i=0;i<digits.size();i++)
00886 total += IsDigitFromParticle(particleID,*digits[i]);
00887
00888 return total;
00889 }
|
|
||||||||||||
|
Returns the fractional digits that are due to a certain track ID Definition at line 893 of file Truthifier.cxx. References CandDigitsFrom(), IsDigitFromTrack(), and total(). Referenced by GetCandidatesFromTrack(). 00894 {
00898 if(!candidate) return 0;
00899 std::vector<const CandDigitHandle*> digits;
00900 CandDigitsFrom(digits,candidate);
00901
00902 // Test each digit. to see if it satisfies.
00903 Float_t total = 0;
00904 for(UInt_t i=0;i<digits.size();i++)
00905 total += IsDigitFromTrack(trackID,*digits[i]);
00906
00907 return total;
00908 }
|
|
|
Use this to see if your CandStrip is all noise or crosstalk:. Returns the fractional digits that are due to a certain track ID Definition at line 912 of file Truthifier.cxx. References CandDigitsFrom(), GetSignalTruthFlags(), and total(). 00913 {
00917 if(!candidate) return 0;
00918 std::vector<const CandDigitHandle*> digits;
00919 CandDigitsFrom(digits,candidate);
00920
00921 // Test each digit. to see if it satisfies.
00922 Float_t total = 0;
00923 for(UInt_t i=0;i<digits.size();i++) {
00924 DigiSignal::DigiPmtTruth_t flags = GetSignalTruthFlags(*digits[i]);
00925 if(flags & DigiSignal::kGenuine) {
00926 total++;
00927 }
00928 }
00929
00930 return total/(float)(digits.size());
00931 }
|
|
||||||||||||||||
|
Returns the fraction of the signal that is due to a certain track ID. Definition at line 689 of file Truthifier.cxx. References digit(), GetSignal(), and IsSignalFromNeutrino(). 00690 {
00695 return IsSignalFromNeutrino(neutrinoID,GetSignal(digit),max_t);
00696 }
|
|
||||||||||||||||
|
Returns the fraction of the signal that is due to a certain track ID. Definition at line 712 of file Truthifier.cxx. References GetSignal(), and IsSignalFromNeutrino(). Referenced by ChopModule::Ana(), ChopEvaluation::Evaluate(), and AlgChopListPerfectMC::RunAlg(). 00713 {
00718 return IsSignalFromNeutrino(neutrinoID,GetSignal(cdh),max_t);
00719 }
|
|
||||||||||||
|
Returns the fraction of the signal that is due to a certain particle ID. Definition at line 655 of file Truthifier.cxx. References digit(), GetSignal(), and IsSignalFromParticle(). 00656 {
00661 return IsSignalFromParticle(particleID,GetSignal(digit));
00662 }
|
|
||||||||||||
|
Returns the fraction of the signal that is due to a certain particle ID. Definition at line 666 of file Truthifier.cxx. References GetSignal(), and IsSignalFromParticle(). Referenced by FitTrackCamAnalysisModule::EfficiencySection(), IsCandidateFromParticle(), and FitTrackCamAnalysisModule::TruthSliceSection(). 00667 {
00672 return IsSignalFromParticle(particleID,GetSignal(cdh));
00673 }
|
|
||||||||||||
|
Returns the fraction of the signal that is due to a certain track ID. Definition at line 678 of file Truthifier.cxx. References digit(), GetSignal(), and IsSignalFromTrack(). 00679 {
00684 return IsSignalFromTrack(trackID,GetSignal(digit));
00685 }
|
|
||||||||||||
|
Returns the fraction of the signal that is due to a certain track ID. Definition at line 700 of file Truthifier.cxx. References GetSignal(), and IsSignalFromTrack(). Referenced by IsCandidateFromTrack(). 00701 {
00706 return IsSignalFromTrack(trackID,GetSignal(cdh));
00707 }
|
|
||||||||||||||||
|
Returns the fraction of the signal that is due to a certain neutrino Definition at line 601 of file Truthifier.cxx. References abs(), fTrackIndexToNeutrinoIndex, DigiSignal::GetHit(), DigiSignal::GetHitWeight(), DigiSignal::GetNumberOfHits(), DigiScintHit::T1(), total(), and DigiScintHit::TrackId(). Referenced by IsDigitFromNeutrino(). 00602 {
00606 if(! signal) return 0;
00607 Float_t total = 0;
00608 Float_t totalMatch = 0;
00609 UInt_t n = signal->GetNumberOfHits();
00610 for(UInt_t i=0; i<n; i++) {
00611 const DigiScintHit* hit = signal->GetHit(i);
00612 Float_t weight = signal->GetHitWeight(i);
00613 total += weight;
00614 int trackId = abs(hit->TrackId());
00615
00616 if(fTrackIndexToNeutrinoIndex[trackId]==neutrinoID) {
00617 if(hit->T1()<=max_t)
00618 totalMatch += weight;
00619 }
00620 }
00621 if(total<=0) return 0; // Guard against FPEs
00622 return totalMatch/total;
00623 }
|
|
||||||||||||
|
Returns the fraction of the signal that is due to a certain particle ID. Definition at line 557 of file Truthifier.cxx. References DigiSignal::GetHit(), DigiSignal::GetHitWeight(), DigiSignal::GetNumberOfHits(), DigiScintHit::ParticleId(), and total(). Referenced by IsDigitFromParticle(). 00558 {
00563 if(! signal) return 0;
00564 Float_t total = 0;
00565 Float_t totalMatch = 0;
00566 UInt_t n = signal->GetNumberOfHits();
00567 for(UInt_t i=0; i<n; i++) {
00568 const DigiScintHit* hit = signal->GetHit(i);
00569 Float_t weight = signal->GetHitWeight(i);
00570 if(hit->ParticleId() == particleID) totalMatch += weight;
00571 total += weight;
00572 }
00573 if(total<=0) return 0; // Guard against FPEs
00574 return totalMatch/total;
00575 }
|
|
||||||||||||
|
Returns the fraction of the signal that is due to a certain particle track. Definition at line 579 of file Truthifier.cxx. References DigiSignal::GetHit(), DigiSignal::GetHitWeight(), DigiSignal::GetNumberOfHits(), total(), and DigiScintHit::TrackId(). Referenced by IsDigitFromTrack(). 00580 {
00585 if(! signal) return 0;
00586 Float_t total = 0;
00587 Float_t totalMatch = 0;
00588 UInt_t n = signal->GetNumberOfHits();
00589 for(UInt_t i=0; i<n; i++) {
00590 const DigiScintHit* hit = signal->GetHit(i);
00591 Float_t weight = signal->GetHitWeight(i);
00592 if(hit->TrackId() == trackID) totalMatch += weight;
00593 total += weight;
00594 }
00595 if(total<=0) return 0; // Guard against FPEs
00596 return totalMatch/total;
00597 }
|
|
|
Definition at line 78 of file Truthifier.h. Referenced by MCAnalysis::Ana(), Instance(), and AlgRmMu::RunAlg(). 00078 { return fValid; };
|
|
|
Prints out the whole blessed mess. Prints out a complete map of the event, from tracks to hits. Useful for debugging, but too difficult for real work. Definition at line 934 of file Truthifier.cxx. References UtilMCFlag::AsString(), DigiScintHit::AsString(), digit(), fHitToSignal, fSignalToDigit, fTrackToHit, DigiSignal::GetCharge(), and DigiSignal::GetTruth(). 00935 {
00941
00942 // Go through all tracks.
00943 TrackToHit_t::const_iterator hitItr = fTrackToHit.begin();
00944 for( ; hitItr!=fTrackToHit.end(); hitItr++) {
00945 std::cout << "+--- TRACK " << hitItr->first << " ---------\n";
00946
00947 // For each scint hit
00948 for(UInt_t ihit=0; ihit<hitItr->second.size(); ihit++) {
00949 const DigiScintHit* hit = (hitItr->second)[ihit];
00950 std::cout << "|+-- DigiScintHit: " << hit->AsString() << std::endl;
00951
00952 // For each signal
00953 HitToSignal_t::const_iterator htsItr = fHitToSignal.find(hit);
00954 if(htsItr != fHitToSignal.end()) {
00955 for(UInt_t isig = 0; isig<htsItr->second.size(); isig++) {
00956
00957 const DigiSignal* signal = (htsItr->second)[isig];
00958 SignalToDigit_t::const_iterator stdItr = fSignalToDigit.find(signal);
00959 if(stdItr != fSignalToDigit.end()) {
00960 const RawDigit* digit = stdItr->second;
00961 std::cout << " |-- RawDigit: " << *digit << std::endl;
00962 std::cout << " | DigiSignal: "
00963 << signal->GetCharge() / Munits::fC
00964 << " fC"
00965 << " Truth: " << AsString(signal->GetTruth()) << std::endl;
00966 }
00967 }
00968
00969 }
00970
00971 }
00972 }
00973 }
|
|
||||||||||||
|
Reset(mom) Builds or rebuilds the association maps to do all the other cool things this class does. Definition at line 81 of file Truthifier.cxx. References abs(), fHitToSignal, RecDataRecord< T >::FindComponent(), fMom, fNeuKins, fNeutrinoIndexToTrackIndex, fNeutrinoList, MomNavigator::FragmentIter(), fRddb, fScintHitArray, fSignals, fSignalToDigit, fStdHep, fTrackIndexToNeutrinoIndex, fTrackToHit, fValid, RawDigitDataBlock::GetDatumIter(), DigiSignal::GetHit(), DigiSignal::GetId(), DigiSignal::GetNumberOfHits(), RawRecord::GetRawBlockIter(), RawRecord::GetRawHeader(), GetSignal(), MAXMSG, MSG, and DigiScintHit::TrackId(). Referenced by TruthHelper::GetBestTrackIdMatch(), Instance(), TruthHelper::SliceCompleteness(), TruthHelper::SliceCompleteness_MaxTimeGap(), TruthHelper::SliceCompleteness_xtalk(), TruthHelper::SliceTrueStrip(), TruthHelper::SliceTrueStripxtalk(), and Truthifier(). 00082 {
00088
00089 fMom = mom;
00090 fRddb = 0;
00091 fStdHep = 0;
00092 fNeutrinoList.clear();
00093 fTrackIndexToNeutrinoIndex.clear();
00094 fNeutrinoIndexToTrackIndex.clear();
00095 fTrackToHit.clear();
00096 fHitToSignal.clear();
00097 fSignalToDigit.clear();
00098 fSignals.clear();
00099 fValid=false;
00100
00101 if(fMom ==0 ) return;
00102
00103 // Find the simsnarl.
00104 SimSnarlRecord* simsnarl = 0;
00105 TObject* tobj;
00106 TIter fragiter = mom->FragmentIter();
00107
00108 // Get the simsnarl.
00109 while( ( tobj = fragiter.Next() ) ) {
00110 simsnarl = dynamic_cast<SimSnarlRecord*>(tobj);
00111 if(simsnarl) break;
00112 }
00113 if(simsnarl==0) { MSG("DataUtil",Msg::kWarning) << "Can't find simsnarl.\n"; return; };
00114
00115 // Get the scint hit array.
00116 fScintHitArray =
00117 dynamic_cast<const TObjArray*>(simsnarl->FindComponent(0,"DigiScintHits"));
00118 if(fScintHitArray==0) {
00119
00120 if(!supressErrors) MSG("DataUtil",Msg::kWarning) << "Can't find scint hit array.\n";
00121
00122 } else {
00123
00124 // Build the array of hits.
00125 TIter hitarrayIter(fScintHitArray);
00126 while( (tobj = hitarrayIter.Next()) ) {
00127 const DigiScintHit* scinthit = dynamic_cast<DigiScintHit*>(tobj);
00128 if(scinthit)
00129 fTrackToHit[scinthit->TrackId()].push_back(scinthit);
00130 }
00131
00132 }
00133
00134 // Get the signal array.
00135 const TObjArray* signalArray =
00136 dynamic_cast<const TObjArray*>(simsnarl->FindComponent(0,"DigiSignal"));
00137 if(signalArray==0) {
00138
00139 if(!supressErrors) MSG("DataUtil",Msg::kWarning) << "Can't find signal array.\n";
00140
00141 } else {
00142
00143 // Build the array of signals.
00144 TIter signalIter(signalArray);
00145 while( (tobj = signalIter.Next()) ) {
00146 const DigiSignal* signal = dynamic_cast<DigiSignal*>(tobj);
00147 if(signal) {
00148 fSignals[signal->GetId()] = signal;
00149 for(UInt_t i=0;i<signal->GetNumberOfHits();i++) {
00150 const DigiScintHit* hit = signal->GetHit(i);
00151 if(hit)
00152 fHitToSignal[hit].push_back(signal);
00153 }
00154 }
00155 }
00156 if(!supressErrors) MSG("DataUtil",Msg::kDebug) << "Got " << fSignals.size() << " signals." << std::endl;
00157
00158 }
00159
00160 // Get the StdHep list.
00161 fStdHep = dynamic_cast<const TClonesArray*>(simsnarl->FindComponent("TClonesArray","StdHep"));
00162 if(fStdHep ==0) {
00163 if(!supressErrors) MSG("DataUtil",Msg::kWarning) << "Can't find StdHep list.\n";
00164 } else {
00165 // Look through initial pariticle list. Associate track ID with originating neutrinos
00166 Int_t siz = fStdHep->GetEntriesFast();
00167 fTrackIndexToNeutrinoIndex.resize(siz);
00168 fNeutrinoList.clear();
00169 Int_t neu = 0;
00170 for(Int_t ind=0; ind<siz; ind++) {
00171 TParticle* part = dynamic_cast<TParticle*>((*fStdHep)[ind]);
00172
00173 // Is this a lepton?
00174 if(abs(part->GetPdgCode())>=12 &&
00175 abs(part->GetPdgCode())<=16
00176 ) {
00177 // Is the status code "Documentation" or "null"?
00178 // This should indicate that it was an initial particle
00179 // into the event generator.
00180 Int_t status = part->GetStatusCode();
00181 if( status == 3 || status == 0 ) {
00182 // We got a neutrino event!
00183 neu=ind;
00184 fNeutrinoList.push_back(ind);
00185 }
00186 }
00187 fTrackIndexToNeutrinoIndex[ind]=neu;
00188 fNeutrinoIndexToTrackIndex[neu].push_back(ind);
00189 }
00190 }
00191
00192 // Get the NeuKin list.
00193 fNeuKins = dynamic_cast<const TClonesArray*>(simsnarl->FindComponent("TClonesArray","NeuKinList"));
00194
00195 // Find the RDDB.
00196 const RawHeader* rawhead =0;
00197 fRddb =0;
00198 fragiter.Reset();
00199 while( ( tobj = fragiter.Next() ) ) {
00200 RawRecord* rawRec = dynamic_cast<RawRecord*>(tobj);
00201 if(rawRec) {
00202 rawhead = rawRec->GetRawHeader();
00203 TIter itr = rawRec->GetRawBlockIter();
00204 RawDataBlock* rawBlk;
00205 while ( ( rawBlk = dynamic_cast<RawDataBlock*>(itr.Next()) ) ) {
00206 fRddb = dynamic_cast<RawDigitDataBlock*>(rawBlk);
00207 if(fRddb) {
00208 // Got one!
00209 TIter diter = fRddb->GetDatumIter();
00210 RawDigit* rawDigit;
00211 diter.Reset();
00212 while( ( rawDigit = (RawDigit*) diter.Next() ) ) {
00213 // Relate this digit to the signal
00214 const DigiSignal* signal = GetSignal(rawDigit);
00215 if(signal) {
00216 fSignalToDigit[signal] = rawDigit;
00217 }
00218 }
00219 }
00220 }
00221 }
00222 } // Ugly ugly ugly
00223
00224 // See if we're good enough.
00225 fValid = true;
00226
00227
00228 if(fRddb==0) {
00229 //if(!supressErrors) MSG("DataUtil",Msg::kError) << "Couldn't find RDDB. Truthifier is invalid. \n";
00230 fValid = false;
00231 }
00232 if(fTrackToHit.size()==0) {
00233 //if(!supressErrors) MSG("DataUtil",Msg::kError) << "No hits found. Truthifier is invalid. \n";
00234 fValid = false;
00235 }
00236 if(fHitToSignal.size()==0) {
00237 //if(!supressErrors) MSG("DataUtil",Msg::kError) << "No map hit->signal. Truthifier is invalid. \n";
00238 fValid = false;
00239 }
00240 if(fSignalToDigit.size()==0) {
00241 //if(!supressErrors) MSG("DataUtil",Msg::kError) << "No map signal->digit found. Truthifier is invalid. \n";
00242 fValid = false;
00243 }
00244 if(fSignals.size()==0) {
00245 //if(!supressErrors) MSG("DataUtil",Msg::kError) << "No signals found. Truthifier is invalid. \n";
00246 fValid = false;
00247 }
00248 if ((!fValid)&&(!supressErrors)) {
00249 MAXMSG("DataUtil",Msg::kWarning,5)
00250 << "Truthifier built but is invalid. Not MC or null snarl." << endl;
00251 }
00252 }
|
|
|
Definition at line 209 of file Truthifier.h. Referenced by GetSignalVector(), Print(), and Reset(). |
|
|
Definition at line 184 of file Truthifier.h. Referenced by Reset(). |
|
|
Definition at line 189 of file Truthifier.h. Referenced by Reset(). |
|
|
Definition at line 201 of file Truthifier.h. Referenced by Reset(). |
|
|
Definition at line 194 of file Truthifier.h. Referenced by GetNeuKinOfParticle(), and Reset(). |
|
|
Definition at line 187 of file Truthifier.h. Referenced by GetRawDigit(), GetSignal(), and Reset(). |
|
|
Definition at line 190 of file Truthifier.h. Referenced by GetScintHitListSize(), and Reset(). |
|
|
Definition at line 217 of file Truthifier.h. Referenced by GetSignal(), and Reset(). |
|
|
Definition at line 213 of file Truthifier.h. Referenced by GetRawDigit(), Print(), and Reset(). |
|
|
Definition at line 188 of file Truthifier.h. Referenced by GetStdHepSize(), and Reset(). |
|
|
Definition at line 198 of file Truthifier.h. Referenced by GetNeutrinoOfTrack(), IsSignalFromNeutrino(), and Reset(). |
|
|
Definition at line 205 of file Truthifier.h. |
|
|
Definition at line 185 of file Truthifier.h. Referenced by Reset(). |
1.3.9.1