Int_t pStatus =-1;
if(iParent >= 0){
parent = stack->Particle(iParent);
- pPdg = TMath::Abs(parent->GetPdgCode());
- pStatus = parent->GetStatusCode();
+ if(parent){
+ pPdg = TMath::Abs(parent->GetPdgCode());
+ pStatus = parent->GetStatusCode();
+ }
}
else if(fDebug > 0 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - Parent with label %d\n",iParent);
//GrandParent
if(iParent >= 0){
parent = stack->Particle(iParent);
- pPdg = TMath::Abs(parent->GetPdgCode());
- pStatus = parent->GetStatusCode();
+ if(parent){
+ pPdg = TMath::Abs(parent->GetPdgCode());
+ pStatus = parent->GetStatusCode();
+ }
}
else {// in case of gun/box simulations
pPdg = 0;
else SetTagBit(tag,kMCOtherDecay);
}//Decay
else {
- if(fDebug > 1 ) printf("AliMCAnalysisUtils::CheckOrigingInStack() - what is it in PYTHIA? Wrong generator setting? Mother mPdg %d, status %d \n Parent iParent %d, pPdg %d %s, status %d\n",
+ if(fDebug > 1 && parent) printf("AliMCAnalysisUtils::CheckOrigingInStack() - what is it in PYTHIA? Wrong generator setting? Mother mPdg %d, status %d \n Parent iParent %d, pPdg %d %s, status %d\n",
mPdg, mStatus,iParent, pPdg, parent->GetName(),pStatus);
if(pPdg == 111) {
SetTagBit(tag,kMCPi0Decay);
else if(fMCGenerator == "HERWIG"){
if(pStatus < 197){//Not decay
while(1){
- if(parent->GetFirstMother()<=5) break;
- iParent = parent->GetFirstMother();
- parent=stack->Particle(iParent);
- pStatus= parent->GetStatusCode();
- pPdg = TMath::Abs(parent->GetPdgCode());
+ if(parent){
+ if(parent->GetFirstMother()<=5) break;
+ iParent = parent->GetFirstMother();
+ parent=stack->Particle(iParent);
+ pStatus= parent->GetStatusCode();
+ pPdg = TMath::Abs(parent->GetPdgCode());
+ } else break;
}//Look for the parton
if(iParent < 8 && iParent > 5) {
//Electron check. Where did that electron come from?
else if(mPdg == 11){ //electron
- if(pPdg == 11){
+ if(pPdg == 11 && parent){
Int_t iGrandma = parent->GetFirstMother();
if(iGrandma >= 0) {
TParticle* gma = (TParticle*)stack->Particle(iGrandma); //get mother
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
+ else if((399 < pPdg && pPdg < 500)||(3999 < pPdg && pPdg < 5000) && parent) { //check charm decay
Int_t iGrandma = parent->GetFirstMother();
if(iGrandma >= 0) {
TParticle* gma = (TParticle*)stack->Particle(iGrandma); //get mother of charm
//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) printf("AliMCAnalysisUtils::CheckOriginInStack() - Status %d Electron from other origin: %s (pPdg = %d) %s (mpdg = %d)\n",mStatus,parent->GetName(),pPdg,mom->GetName(),mPdg);
+ 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);
}
}//electron check
//Cluster was made by something else
if(fDebug > 0 && label < 8 ) printf("AliMCAnalysisUtils::CheckOriginInAOD() - Mother is parton %d\n",iParent);
//GrandParent
- AliAODMCParticle * parent = new AliAODMCParticle ;
+ AliAODMCParticle * parent = NULL ;
Int_t pPdg = -1;
- if(iParent >= 0){
+ if(iParent >= 0 && parent){
parent = (AliAODMCParticle *) mcparticles->At(iParent);
pPdg = TMath::Abs(parent->GetPdgCode());
}
if(fDebug > 2 ) {
printf("AliMCAnalysisUtils::CheckOriginInAOD() - Cluster most contributing mother and its parent: \n");
printf("\t Mother label %d, pdg %d, Primary? %d, Physical Primary? %d\n",iMom, mPdg, mom->IsPrimary(), mom->IsPhysicalPrimary());
- printf("\t Parent label %d, pdg %d, Primary? %d, Physical Primary? %d\n",iParent, pPdg, parent->IsPrimary(), parent->IsPhysicalPrimary());
+ if(parent)
+ printf("\t Parent label %d, pdg %d, Primary? %d, Physical Primary? %d\n",iParent, pPdg, parent->IsPrimary(), parent->IsPhysicalPrimary());
}
//Check if mother is converted, if not, get the first non converted mother
if(fDebug > 0 && label < 8 ) printf("AliMCAnalysisUtils::CheckOriginInAOD() - Mother is parton %d\n",iParent);
//GrandParent
- if(iParent >= 0){
+ if(iParent >= 0 && parent){
parent = (AliAODMCParticle *) mcparticles->At(iParent);
pPdg = TMath::Abs(parent->GetPdgCode());
}
if(fDebug > 2 ) {
printf("AliMCAnalysisUtils::CheckOriginInAOD() - Converted photon/electron : \n");
printf("\t Mother label %d, pdg %d, Primary? %d, Physical Primary? %d\n",iMom, mPdg, mom->IsPrimary(), mom->IsPhysicalPrimary());
- printf("\t Parent label %d, pdg %d, Primary? %d, Physical Primary? %d\n",iParent, pPdg, parent->IsPrimary(), parent->IsPhysicalPrimary());
+ if(parent)
+ printf("\t Parent label %d, pdg %d, Primary? %d, Physical Primary? %d\n",iParent, pPdg, parent->IsPrimary(), parent->IsPhysicalPrimary());
}
}//mother and parent are electron or photon and have status 0 and parent is photon or electron
else if(iParent <= 5) {
SetTagBit(tag, kMCISR); //Initial state radiation
}
- else if(parent->IsPrimary() && !parent->IsPhysicalPrimary()){//Decay
+ else if(parent && parent->IsPrimary() && !parent->IsPhysicalPrimary()){//Decay
if(pPdg == 111){
SetTagBit(tag,kMCPi0Decay);
if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInAOD() - Generator pi0 decay photon \n");
else SetTagBit(tag,kMCOtherDecay);
}//Decay
else {
- printf("AliMCAnalysisUtils::ChecOrigingInAOD() - what is it? Mother mPdg %d, is primary? %d, is physical %d \n Parent iParent %d, pPdg %d, is primary? %d, is physical? %d\n",
+ if(parent)printf("AliMCAnalysisUtils::ChecOrigingInAOD() - what is it? Mother mPdg %d, is primary? %d, is physical %d \n Parent iParent %d, pPdg %d, is primary? %d, is physical? %d\n",
mPdg, mom->IsPrimary(), mom->IsPhysicalPrimary(),iParent, pPdg,parent->IsPrimary(), parent->IsPhysicalPrimary());
SetTagBit(tag,kMCOtherDecay);//Check
}
//Electron check. Where did that electron come from?
else if(mPdg == 11){ //electron
- if(pPdg == 11){
+ if(pPdg == 11 && parent){
Int_t iGrandma = parent->GetMother();
if(iGrandma >= 0) {
AliAODMCParticle* gma = (AliAODMCParticle*)mcparticles->At(iGrandma);
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-hadron decay
- else if((399 < pPdg && pPdg < 500)||(3999 < pPdg && pPdg < 5000)) { //c-hadron decay check
+ else if((399 < pPdg && pPdg < 500)||(3999 < pPdg && pPdg < 5000) && parent) { //c-hadron decay check
Int_t iGrandma = parent->GetMother();
if(iGrandma >= 0) {
AliAODMCParticle* gma = (AliAODMCParticle*)mcparticles->At(iGrandma); //charm's mother