- if(fDebug > 0) printf("AliMCAnalysisUtils::CheckOriginInStack() - Checking ancestors of electrons");
-
- //check first for B and C ancestry, then other possibilities.
- //An electron from a photon parent could have other particles in
- //its history and we would want to know that, right?
-
- if(mStatus == 1) { //electron from event generator
- if (pPdg == 23) { decayChk = kTRUE; SetTagBit(tag,kMCZDecay); } //parent is Z-boson
- else if (pPdg == 24) { decayChk = kTRUE; SetTagBit(tag,kMCWDecay); } //parent is W-boson
- else if (pPdg == 111) { decayChk = kTRUE; SetTagBit(tag,kMCPi0Decay); } //Pi0 Dalitz decay
- else if (pPdg == 221) { decayChk = kTRUE; SetTagBit(tag,kMCEtaDecay); } //Eta Dalitz decay
- else if((499 < pPdg && pPdg < 600)||(4999 < pPdg && pPdg < 6000)) {decayChk = kTRUE; SetTagBit(tag,kMCEFromB); }
- else if((399 < pPdg && pPdg < 500)||(3999 < pPdg && pPdg < 5000)) {decayChk = kTRUE; SetTagBit(tag,kMCEFromC); }
- //check the electron's ancestors for B/C contribution
- Bool_t bAncestor = kFALSE;
- Bool_t cAncestor = kFALSE;
- TParticle * ancestors = stack->Particle(label); //start from electron
- Int_t iAncestors = ancestors->GetFirstMother(); //get its mother index
- if(iAncestors < 0) return tag; //no ancestor, shouldn't happen
- ancestors = stack->Particle(iAncestors); //get electron mother
- Int_t aPdg = TMath::Abs(ancestors->GetPdgCode()); //get electron mother pdg
- if(fDebug > 0) printf("AliMCAnalysisUtils::CheckOrigin: Scaning the decay chain for bottom/charm generated electron");
- while(1){//check electron's mother's pdg and its mother(s) pdgs
- if((499 < aPdg && aPdg < 600)||(4999 < aPdg && aPdg < 6000)) bAncestor = kTRUE;
- if((399 < aPdg && aPdg < 500)||(3999 < aPdg && aPdg < 5000)) cAncestor = kTRUE;
- if(bAncestor && cAncestor) break;
- iAncestors = ancestors->GetFirstMother();
- if(iAncestors < 0) break;
- ancestors = stack->Particle(iAncestors);
- aPdg = TMath::Abs(ancestors->GetPdgCode());
- }//searching for ancestors
- if(bAncestor && cAncestor) { SetTagBit(tag,kMCEFromCFromB); }//Decay chain has both B and C
- else if(bAncestor && !cAncestor) { SetTagBit(tag,kMCEFromB);}//Decay chain has only B
- else if(!bAncestor && cAncestor) { SetTagBit(tag,kMCEFromC);}//Decay chain has only C
- //if it is not from any of the above, where is it from?
- if(!decayChk) {
- if(fDebug > 0) printf("STACK Status 1 Electron from other origin: %s (pPdg = %d) %s (mpdg = %d)\n",parent->GetName(),pPdg,mom->GetName(),mPdg);
-
- SetTagBit(tag,kMCOtherDecay);
- }
- }
- else if (mStatus == 0) { //electron from GEANT
- if (pPdg == 23) { decayChk = kTRUE; SetTagBit(tag,kMCZDecay); } //parent is Z-boson
- else if (pPdg == 24) { decayChk = kTRUE; SetTagBit(tag,kMCWDecay); } //parent is W-boson
- else if (pPdg == 111) { decayChk = kTRUE; SetTagBit(tag,kMCPi0Decay); } //Pi0 Dalitz decay
- else if (pPdg == 221) { decayChk = kTRUE; SetTagBit(tag,kMCEtaDecay); } //Eta Dalitz decay
- else if((499 < pPdg && pPdg < 600)||(4999 < pPdg && pPdg < 6000)) {decayChk = kTRUE; SetTagBit(tag,kMCEFromB); }
- else if((399 < pPdg && pPdg < 500)||(3999 < pPdg && pPdg < 5000)) {decayChk = kTRUE; SetTagBit(tag,kMCEFromC); }
-
- //check the electron's ancestors for B/C contribution
- //Rewind ancestry and check for electron with status == 1
- //if we find one, we'll assume that this object is from an
- //electron but that it may have gone through some showering in
- //material before the detector
-
- //Not a double-counting problem because we are only accessing
- //these histories for MC labels connected to a reco object.
- //If you wanted to use this to sort through the kine stack
- //directly, might it be a problem?
- Bool_t eleFromEvGen = kFALSE;
- Bool_t bAncestor = kFALSE;
- Bool_t cAncestor = kFALSE;
-
- TParticle * ancestors = stack->Particle(label); //start from electron
- Int_t iAncestors = ancestors->GetFirstMother(); //get its mother index
- if(iAncestors < 0) return tag; //no ancestor, shouldn't happen
- ancestors = stack->Particle(iAncestors); //get electron mother
- Int_t aStatus = ancestors->GetStatusCode(); //get electron mother's status
- Int_t aPdg = TMath::Abs(ancestors->GetPdgCode()); //get electron mother pdg
- if(fDebug > 0) printf("AliMCAnalysisUtils::CheckOrigin: Scanning the decay chain for bottom/charm generated electron");
- while(1){//check electron's mother's pdg and its mother(s) pdgs
- if(aStatus == 1 && aPdg == 11) eleFromEvGen = kTRUE;
- if(eleFromEvGen && aPdg == 23) { SetTagBit(tag,kMCZDecay);}
- if(eleFromEvGen && aPdg == 24) { SetTagBit(tag,kMCWDecay);}
- if(eleFromEvGen && ((499 < aPdg && aPdg < 600)||(4999 < aPdg && aPdg < 6000))) bAncestor = kTRUE;
- if(eleFromEvGen && ((399 < aPdg && aPdg < 500)||(3999 < aPdg && aPdg < 5000))) cAncestor = kTRUE;
- if(bAncestor && cAncestor) break;
- iAncestors = ancestors->GetFirstMother();
- if(iAncestors <= 5) break;
- ancestors = stack->Particle(iAncestors);
- aPdg = TMath::Abs(ancestors->GetPdgCode());
- }//searching for ancestors
- if(bAncestor && cAncestor) { SetTagBit(tag,kMCEFromCFromB);}//Decay chain has both B and C
- else if(bAncestor && !cAncestor) { SetTagBit(tag,kMCEFromB);}//Decay chain has only B
- else if(!bAncestor && cAncestor) { SetTagBit(tag,kMCEFromC);}//Decay chain has only C
- //if it is not from any of the above, where is it from?
- if(pPdg > 10000) SetTagBit(tag,kMCUnknown);
- if(!decayChk) {
- if(fDebug > 0) printf("Stack Status 0 Electron from other origin: %s (pPdg = %d) %s (mPdg = %d)\n",parent->GetName(),pPdg,mom->GetName(),mPdg);
- SetTagBit(tag,kMCOtherDecay);
- }
- } //GEANT check
+ if(fDebug > 0) printf("AliMCAnalysisUtils::CheckOriginInStack() - Checking ancestors of electrons\n");
+ if (pPdg == 111) { SetTagBit(tag,kMCPi0Decay); } //Pi0 Dalitz decay
+ else if (pPdg == 221) { SetTagBit(tag,kMCEtaDecay); } //Eta Dalitz decay
+ else if((499 < pPdg && pPdg < 600)||(4999 < pPdg && pPdg < 6000)) { SetTagBit(tag,kMCEFromB); } //b-->e decay
+ else if((399 < pPdg && pPdg < 500)||(3999 < pPdg && pPdg < 5000)) { //check charm decay
+ if(parent){
+ Int_t iGrandma = parent->GetFirstMother();
+ if(iGrandma >= 0) {
+ TParticle* gma = (TParticle*)stack->Particle(iGrandma); //get mother of charm
+ Int_t gPdg = TMath::Abs(gma->GetPdgCode());
+ if((499 < gPdg && gPdg < 600)||(4999 < gPdg && gPdg < 6000)) SetTagBit(tag,kMCEFromCFromB); //b-->c-->e
+ else SetTagBit(tag,kMCEFromC); //c-->e
+ } else SetTagBit(tag,kMCEFromC); //c-->e
+ }//parent
+ } else {
+ //if it is not from any of the above, where is it from?
+ if(pPdg > 10000) SetTagBit(tag,kMCUnknown);
+ else SetTagBit(tag,kMCOtherDecay);
+ if(fDebug > 0 && parent) printf("AliMCAnalysisUtils::CheckOriginInStack() - Status %d Electron from other origin: %s (pPdg = %d) %s (mpdg = %d)\n",mStatus,parent->GetName(),pPdg,mom->GetName(),mPdg);
+ }