#ifndef HDEANAMYUTILS_H #define HDEANAMYUTILS_H #include "hgeantkine.h" #include "hcategory.h" #include "hparticlecandsim.h" #include using std::vector; class HDEAnaMyUtils { public: static Bool_t isMcSignalElectron( HGeantKine* kine) { if (kine == NULL) return kFALSE; return (kine->getID() == 2 || kine->getID() == 3) && kine->isPrimary() && kine->getGeneratorInfo() > 0; //kine->getGeneratorInfo() == -3 for delta electrons } static Bool_t isMcGammaElectron( HGeantKine* kine, HCategory* kineCat) { if (kine == NULL) return kFALSE; if (kine->getID() == 2 || kine->getID() == 3){ Int_t parentInd = kine->getParentTrack() - 1; if (parentInd < 0) return kFALSE; HGeantKine* kineParent = static_cast(kineCat->getObject(parentInd)); if (kineParent != NULL && kineParent->getID() == 1) { return kTRUE; } return kFALSE; } return kFALSE; } static Bool_t isMcPi0Electron( HGeantKine* kine, HCategory* kineCat) { if (kine == NULL) return kFALSE; if (kine->getID() == 2 || kine->getID() == 3){ Int_t parentInd = kine->getParentTrack() - 1; if (parentInd < 0) return kFALSE; HGeantKine* kineParent = static_cast(kineCat->getObject(parentInd)); if (kineParent != NULL && kineParent->getID() == 7) { return kTRUE; } return kFALSE; } return kFALSE; } static Bool_t isMcPi0( HGeantKine* kine) { if(kine == NULL) return kFALSE; if(kine->getID() == 7) return kTRUE; return kFALSE; } static Bool_t isMcPi0Primary( HGeantKine* kine) { return (isMcPi0(kine) && kine->isPrimary()); } static Bool_t isMcSignalElectron( HParticleCandSim* cand, HCategory* kineCat) { if (cand == NULL) return kFALSE; Int_t trackInd = cand->getGeantTrack() - 1; if (trackInd < 0) return kFALSE; HGeantKine* kine = static_cast(kineCat->getObject(trackInd)); if (kine == NULL) return kFALSE; return (kine->getID() == 2 || kine->getID() == 3) && kine->isPrimary() && kine->getGeneratorInfo() > 0; } static Bool_t isMcGammaElectron( HParticleCandSim* cand, HCategory* kineCat) { if (cand == NULL) return kFALSE; return ((cand->getGeantPID() == 2 || cand->getGeantPID() == 3) && cand->getGeantParentPID() == 1); /* Int_t trackInd = cand->getGeantTrack() - 1; if (trackInd < 0) return kFALSE; HGeantKine* kine = static_cast(kineCat->getObject(trackInd)); if (kine == NULL) return kFALSE; if (kine->getID() == 2 || kine->getID() == 3){ Int_t parentInd = kine->getParentTrack() - 1; if (parentInd < 0) return kFALSE; HGeantKine* kineParent = static_cast(kineCat->getObject(parentInd)); if (kineParent != NULL && kineParent->getID() == 1) { return kTRUE; } return kFALSE; } return kFALSE; */ } static Bool_t isMcPi0Electron( HParticleCandSim* cand, HCategory* kineCat) { if (cand == NULL) return kFALSE; return ((cand->getGeantPID() == 2 || cand->getGeantPID() == 3) && cand->getGeantParentPID() == 7); } static Bool_t isMcPion( HParticleCandSim* cand) { if (cand == NULL) return kFALSE; return ( cand->getGeantPID() == 9 || cand->getGeantPID() == 8); } static Bool_t isMcProton( HParticleCandSim* cand) { if (cand == NULL) return kFALSE; return ( cand->getGeantPID() == 14 || cand->getGeantPID() == 15); } static Bool_t isMcSignalPair( HParticleCandSim* cand1, HParticleCandSim* cand2, HCategory* kineCat) { if (isSameCharge(cand1, cand2)) return false; return (isMcSignalElectron(cand1, kineCat) && isMcSignalElectron(cand2, kineCat)); } static Bool_t isMcGammaPair( HParticleCandSim* cand1, HParticleCandSim* cand2, HCategory* kineCat) { if (isSameCharge(cand1, cand2)) return false; return (isMcGammaElectron(cand1, kineCat) && isMcGammaElectron(cand2, kineCat) && cand1->getGeantParentTrackNum() == cand2->getGeantParentTrackNum()); } static Bool_t isMcPi0Pair( HParticleCandSim* cand1, HParticleCandSim* cand2, HCategory* kineCat) { if (isSameCharge(cand1, cand2)) return false; return (isMcPi0Electron(cand1, kineCat) && isMcPi0Electron(cand2, kineCat) && cand1->getGeantParentTrackNum() == cand2->getGeantParentTrackNum()); } static Int_t getNofSharedCandidatesForRing( Int_t richInd, HCategory* candCat) { if (richInd < 0) return 0; Int_t nofCands = candCat->getEntries(); Int_t counter = 0; for( Int_t iC = 0; iC < nofCands; iC++){ HParticleCandSim* cand = static_cast(candCat->getObject(iC)); Bool_t isLepton = cand->isFlagBit(kIsLepton); if (isLepton && cand != NULL && cand->getRichInd() == richInd) counter++; } return counter; } static Bool_t isSameCharge(HParticleCandSim* cand1, HParticleCandSim* cand2) { return ( (cand1->getCharge() > 0) == (cand2->getCharge() > 0) ); } static vector getLegendLabelsWithMean(const vector& labels, const vector& hists ) { assert(hists.size() != 0 && labels.size() == hists.size()); vector newLabels; for (UInt_t i = 0; i < labels.size(); i++) { newLabels.push_back(labels[i] + " (" + HDEAna::NumberToString(hists[i]->GetMean()) + ")"); } return newLabels; } static vector getLegendLabelsWithMeanRms(const vector& labels, const vector& hists ) { assert(hists.size() != 0 && labels.size() == hists.size()); vector newLabels; for (UInt_t i = 0; i < labels.size(); i++) { newLabels.push_back(labels[i] + " (" + HDEAna::NumberToString(hists[i]->GetMean()) + "/" + HDEAna::NumberToString(hists[i]->GetRMS()) + ")"); } return newLabels; } }; #endif