19 #include "TParticle.h"
20 #include "TDatabasePDG.h"
27 #include "AliGenPythiaEventHeader.h"
28 #include "AliAODMCParticle.h"
43 fMCGenerator(kPythia),
44 fMCGeneratorString(
"PYTHIA"),
45 fDaughMom(), fDaughMom2(),
46 fMotherMom(), fGMotherMom()
68 TLorentzVector & momentum, TVector3 & prodVertex)
77 if(label1[0]==label2[0])
89 Int_t label=label1[0];
90 if(label < 0)
return -1;
92 while(label > -1 && counter1 < 99)
95 AliAODMCParticle * mom = (AliAODMCParticle *) mcparticles->At(label);
98 label = mom->GetMother() ;
99 label1[counter1]=label;
106 if(label < 0)
return -1;
108 while(label > -1 && counter2 < 99)
111 AliAODMCParticle * mom = (AliAODMCParticle *) mcparticles->At(label);
114 label = mom->GetMother() ;
115 label2[counter2]=label;
122 AliStack * stack = reader->
GetStack();
124 Int_t label=label1[0];
125 while(label > -1 && counter1 < 99)
128 TParticle * mom = stack->Particle(label);
131 label = mom->GetFirstMother() ;
132 label1[counter1]=label;
140 while(label > -1 && counter2 < 99)
143 TParticle * mom = stack->Particle(label);
146 label = mom->GetFirstMother() ;
147 label2[counter2]=label;
158 Int_t commonparents = 0;
161 for (
Int_t c1 = 0; c1 < counter1; c1++)
163 for (
Int_t c2 = 0; c2 < counter2; c2++)
165 if(label1[c1]==label2[c2] && label1[c1]>-1)
167 ancLabel = label1[c1];
172 AliAODMCParticle * mom = (AliAODMCParticle *) reader->
GetAODMCParticles()->At(label1[c1]);
176 ancPDG = mom->GetPdgCode();
177 ancStatus = mom->GetStatus();
178 momentum.SetPxPyPzE(mom->Px(),mom->Py(),mom->Pz(),mom->E());
179 prodVertex.SetXYZ(mom->Xv(),mom->Yv(),mom->Zv());
184 TParticle * mom = (reader->
GetStack())->Particle(label1[c1]);
188 ancPDG = mom->GetPdgCode();
189 ancStatus = mom->GetStatusCode();
190 mom->Momentum(momentum);
191 prodVertex.SetXYZ(mom->Vx(),mom->Vy(),mom->Vz());
206 momentum.SetXYZT(0,0,0,0);
207 prodVertex.SetXYZ(-10,-10,-10);
225 AliWarning(
"No MC labels available, please check!!!");
258 AliWarning(
"No MC labels available, please check!!!");
266 Int_t labels[]={label};
289 AliStack* stack,
const TObjArray* arrayCluster)
293 AliDebug(1,
"Stack is not available, check analysis settings in configuration file, STOP!!");
298 Int_t label=labels[0];
300 if(label >= 0 && label < stack->GetNtrack())
303 TParticle * mom = stack->Particle(label);
305 Int_t mPdgSign = mom->GetPdgCode();
306 Int_t mPdg = TMath::Abs(mPdgSign);
307 Int_t mStatus = mom->GetStatusCode() ;
308 Int_t iParent = mom->GetFirstMother() ;
313 TParticle * parent = NULL;
318 parent = stack->Particle(iParent);
322 pPdg = TMath::Abs(parent->GetPdgCode());
323 pStatus = parent->GetStatusCode();
326 else AliDebug(1,Form(
"Parent with label %d",iParent));
328 AliDebug(2,
"Cluster most contributing mother and its parent:");
329 AliDebug(2,Form(
"\t Mother label %d, pdg %d, status %d",iMom, mPdg, mStatus));
330 AliDebug(2,Form(
"\t Parent label %d, pdg %d, status %d",iParent, pPdg, pStatus));
333 if((mPdg == 22 || mPdg == 11) && (pPdg == 22 || pPdg == 11) && mStatus == 0)
338 while ((pPdg == 22 || pPdg == 11) && mStatus != 1)
341 iMom = mom->GetFirstMother();
345 AliInfo(Form(
"pdg = %d, mother = %d, skip",pPdg,iMom));
349 mom = stack->Particle(iMom);
350 mPdgSign = mom->GetPdgCode();
351 mPdg = TMath::Abs(mPdgSign);
352 mStatus = mom->GetStatusCode() ;
353 iParent = mom->GetFirstMother() ;
360 parent = stack->Particle(iParent);
363 pPdg = TMath::Abs(parent->GetPdgCode());
364 pStatus = parent->GetStatusCode();
374 AliDebug(2,
"Converted photon/electron:");
375 AliDebug(2,Form(
"\t Mother label %d, pdg %d, status %d",iMom, mPdg, mStatus));
376 AliDebug(2,Form(
"\t Parent label %d, pdg %d, status %d",iParent, pPdg, pStatus));
379 else if((mPdg == 22 || mPdg == 11) && mStatus == 0)
382 if(pPdg == 2112 || pPdg == 211 || pPdg == 321 ||
383 pPdg == 2212 || pPdg == 130 || pPdg == 13 )
386 iMom = mom->GetFirstMother();
390 AliInfo(Form(
"pdg = %d, mother = %d, skip",pPdg,iMom));
394 mom = stack->Particle(iMom);
395 mPdgSign = mom->GetPdgCode();
396 mPdg = TMath::Abs(mPdgSign);
398 AliDebug(2,
"Converted hadron:");
399 AliDebug(2,Form(
"\t Mother label %d, pdg %d, status %d",iMom, mPdg, mStatus));
430 AliDebug(2,
"First mother is directly pi0, not decayed by generator");
439 AliDebug(2,
"First mother is directly eta, not decayed by generator");
452 AliDebug(2,
"PYTHIA pi0 decay photon, parent pi0 with status 11");
461 else if (pPdg == 221)
465 AliDebug(2,
"PYTHIA eta decay photon, parent pi0 with status 11");
472 else if(mStatus == 1)
476 if(iParent < 8 && iParent > 5)
481 else if(iParent <= 5)
496 if(parent->GetFirstMother()<=5)
break;
497 iParent = parent->GetFirstMother();
498 parent=stack->Particle(iParent);
499 pStatus= parent->GetStatusCode();
500 pPdg = TMath::Abs(parent->GetPdgCode());
504 if(iParent < 8 && iParent > 5)
520 if(pPdg == 11 && parent)
522 Int_t iGrandma = parent->GetFirstMother();
525 TParticle* gma = (TParticle*)stack->Particle(iGrandma);
526 Int_t gPdg = TMath::Abs(gma->GetPdgCode());
535 AliDebug(1,
"Checking ancestors of electrons");
539 else if((499 < pPdg && pPdg < 600)||(4999 < pPdg && pPdg < 6000)) {
SetTagBit(tag,
kMCEFromB); }
540 else if((399 < pPdg && pPdg < 500)||(3999 < pPdg && pPdg < 5000))
544 Int_t iGrandma = parent->GetFirstMother();
547 TParticle* gma = (TParticle*)stack->Particle(iGrandma);
548 Int_t gPdg = TMath::Abs(gma->GetPdgCode());
568 AliDebug(2,Form(
"\t Setting kMCUnknown for cluster from %s (pdg = %d, Parent pdg = %d)",
569 mom->GetName(),mPdg,pPdg));
577 AliWarning(Form(
"*** bad label or no stack ***: label %d ", label));
579 if(label >= stack->GetNtrack())
580 AliWarning(Form(
"*** large label ***: label %d, n tracks %d", label, stack->GetNtrack()));
600 const TClonesArray *mcparticles,
const TObjArray* arrayCluster)
604 AliDebug(1,
"AODMCParticles is not available, check analysis settings in configuration file!!");
609 Int_t label=labels[0];
610 Int_t nprimaries = mcparticles->GetEntriesFast();
612 if(label >= 0 && label < nprimaries)
615 AliAODMCParticle * mom = (AliAODMCParticle *) mcparticles->At(label);
617 Int_t mPdgSign = mom->GetPdgCode();
618 Int_t mPdg = TMath::Abs(mPdgSign);
619 Int_t iParent = mom->GetMother() ;
624 AliAODMCParticle * parent = NULL ;
628 parent = (AliAODMCParticle *) mcparticles->At(iParent);
629 pPdg = TMath::Abs(parent->GetPdgCode());
631 else AliDebug(1,Form(
"Parent with label %d",iParent));
633 AliDebug(2,
"Cluster most contributing mother and its parent:");
634 AliDebug(2,Form(
"\t Mother label %d, pdg %d, Primary? %d, Physical Primary? %d",iMom, mPdg, mom->IsPrimary(), mom->IsPhysicalPrimary()));
635 AliDebug(2,Form(
"\t Parent label %d, pdg %d, Primary? %d, Physical Primary? %d",iParent, pPdg, parent?parent->IsPrimary():-1, parent?parent->IsPhysicalPrimary():-1));
638 if((mPdg == 22 || mPdg == 11) && (pPdg == 22 || pPdg == 11) && !mom->IsPrimary())
643 while ((pPdg == 22 || pPdg == 11) && !mom->IsPhysicalPrimary())
646 iMom = mom->GetMother();
650 AliInfo(Form(
"pdg = %d, mother = %d, skip",pPdg,iMom));
654 mom = (AliAODMCParticle *) mcparticles->At(iMom);
655 mPdgSign = mom->GetPdgCode();
656 mPdg = TMath::Abs(mPdgSign);
657 iParent = mom->GetMother() ;
661 if(iParent >= 0 && parent)
663 parent = (AliAODMCParticle *) mcparticles->At(iParent);
664 pPdg = TMath::Abs(parent->GetPdgCode());
671 AliDebug(2,
"AliMCAnalysisUtils::CheckOriginInAOD() - Converted photon/electron:");
672 AliDebug(2,Form(
"\t Mother label %d, pdg %d, Primary? %d, Physical Primary? %d",iMom, mPdg, mom->IsPrimary(), mom->IsPhysicalPrimary()));
673 AliDebug(2,Form(
"\t Parent label %d, pdg %d, Primary? %d, Physical Primary? %d",iParent, pPdg, parent?parent->IsPrimary():-1, parent?parent->IsPhysicalPrimary():-1));
676 else if((mPdg == 22 || mPdg == 11) && !mom->IsPrimary())
679 if(pPdg == 2112 || pPdg == 211 || pPdg == 321 ||
680 pPdg == 2212 || pPdg == 130 || pPdg == 13 )
683 iMom = mom->GetMother();
687 AliInfo(Form(
"pdg = %d, mother = %d, skip",pPdg,iMom));
691 mom = (AliAODMCParticle *) mcparticles->At(iMom);
692 mPdgSign = mom->GetPdgCode();
693 mPdg = TMath::Abs(mPdgSign);
695 AliDebug(2,
"AliMCAnalysisUtils::CheckOriginInAOD() - Converted hadron:");
696 AliDebug(2,Form(
"\t Mother label %d, pdg %d, Primary? %d, Physical Primary? %d",iMom, mPdg, mom->IsPrimary(), mom->IsPhysicalPrimary()));
729 AliDebug(2,
"First mother is directly pi0, not decayed by generator");
737 AliDebug(2,
"First mother is directly eta, not decayed by generator");
750 AliDebug(2,
"Generator pi0 decay photon");
761 else if (pPdg == 221)
765 AliDebug(2,
"Generator eta decay photon");
774 if(iParent < 8 && iParent > 5 )
792 if(pPdg == 11 && parent)
794 Int_t iGrandma = parent->GetMother();
797 AliAODMCParticle* gma = (AliAODMCParticle*)mcparticles->At(iGrandma);
798 Int_t gPdg = TMath::Abs(gma->GetPdgCode());
807 AliDebug(1,
"Checking ancestors of electrons");
811 else if((499 < pPdg && pPdg < 600)||(4999 < pPdg && pPdg < 6000)) {
SetTagBit(tag,
kMCEFromB);}
812 else if((399 < pPdg && pPdg < 500)||(3999 < pPdg && pPdg < 5000))
816 Int_t iGrandma = parent->GetMother();
819 AliAODMCParticle* gma = (AliAODMCParticle*)mcparticles->At(iGrandma);
820 Int_t gPdg = TMath::Abs(gma->GetPdgCode());
828 TParticlePDG* foo = TDatabasePDG::Instance()->GetParticle(pPdg);
829 TParticlePDG* foo1 = TDatabasePDG::Instance()->GetParticle(mPdg);
831 AliDebug(1,Form(
"Electron from other origin: %s (pPdg = %d) %s (mPdg = %d)",foo->GetName(), pPdg,foo1->GetName(),mPdg));
840 AliDebug(1,Form(
"\t Setting kMCUnknown for cluster with pdg = %d, Parent pdg = %d",mPdg,pPdg));
848 AliWarning(Form(
"*** bad label or no mcparticles ***: label %d", label));
850 if(label >= mcparticles->GetEntriesFast())
851 AliWarning(Form(
"*** large label ***: label %d, n tracks %d", label, mcparticles->GetEntriesFast()));
865 Int_t mesonIndex, AliStack *stack,
868 if(labels[0] < 0 || labels[0] > stack->GetNtrack() || nlabels <= 1)
870 AliDebug(2,Form(
"Exit : label[0] %d, n primaries %d, nlabels %d",labels[0],stack->GetNtrack(), nlabels));
874 TParticle *
meson = stack->Particle(mesonIndex);
875 Int_t mesonPdg = meson->GetPdgCode();
876 if(mesonPdg!=111 && mesonPdg!=221)
878 AliWarning(Form(
"Wrong pi0/eta PDG : %d",mesonPdg));
882 AliDebug(2,Form(
"%s, label %d",meson->GetName(), mesonIndex));
885 if(meson->GetNDaughters() != 2)
887 AliDebug(2,Form(
"Not overalapped. Number of daughters is %d, not 2",meson->GetNDaughters()));
892 Int_t iPhoton0 = meson->GetDaughter(0);
893 Int_t iPhoton1 = meson->GetDaughter(1);
894 TParticle *photon0 = stack->Particle(iPhoton0);
895 TParticle *photon1 = stack->Particle(iPhoton1);
898 if(photon0->GetPdgCode() != 22 || photon1->GetPdgCode()!=22)
900 AliDebug(2,Form(
"Not overalapped. PDG: daughter 1 = %d, of daughter 2 = %d",photon0->GetPdgCode(),photon1->GetPdgCode()));
904 AliDebug(2,Form(
"Daughter labels : photon0 = %d, photon1 = %d",iPhoton0,iPhoton1));
907 Bool_t okPhoton0 = kFALSE;
908 Bool_t okPhoton1 = kFALSE;
910 AliDebug(3,
"Labels loop:");
912 Bool_t conversion = kFALSE;
914 for(
Int_t i = 0; i < nlabels; i++)
916 AliDebug(3,Form(
"\t at begin:label %d/%d: %d, ok? photon1 %d, photon2 %d", i+1, nlabels, labels[i], okPhoton0, okPhoton1));
919 if(okPhoton0 && okPhoton1)
break;
921 Int_t index = labels[i];
922 if (iPhoton0 == index)
927 else if (iPhoton1 == index)
935 if(index >= stack->GetNtrack())
937 AliWarning(Form(
"Particle index %d larger than size of list %d!!",index,stack->GetNtrack()));
941 TParticle * daught = stack->Particle(index);
942 Int_t tmpindex = daught->GetFirstMother();
944 AliDebug(3,Form(
"\t Conversion? : mother %d",tmpindex));
949 AliDebug(3,Form(
"\t \t parent index %d",tmpindex));
950 daught = stack->Particle(tmpindex);
951 if (iPhoton0 == tmpindex)
957 else if (iPhoton1 == tmpindex)
964 tmpindex = daught->GetFirstMother();
974 if(okPhoton0 && okPhoton1)
976 AliDebug(2,Form(
"%s OVERLAPPED DECAY", meson->GetName()));
990 const TClonesArray *mcparticles,
Int_t & tag )
992 if(labels[0] < 0 || labels[0] > mcparticles->GetEntriesFast() || nlabels <= 1)
994 AliDebug(2,Form(
"Exit : label[0] %d, n primaries %d, nlabels %d",labels[0],mcparticles->GetEntriesFast(), nlabels));
998 AliAODMCParticle *
meson = (AliAODMCParticle *) mcparticles->At(mesonIndex);
999 Int_t mesonPdg = meson->GetPdgCode();
1000 if(mesonPdg != 111 && mesonPdg != 221)
1002 AliWarning(Form(
"Wrong pi0/eta PDG : %d",mesonPdg));
1006 AliDebug(2,Form(
"pdg %d, label %d, ndaughters %d", mesonPdg, mesonIndex, meson->GetNDaughters()));
1009 if(meson->GetNDaughters() != 2)
1011 AliDebug(2,Form(
"Not overalapped. Number of daughters is %d, not 2",meson->GetNDaughters()));
1015 Int_t iPhoton0 = meson->GetDaughter(0);
1016 Int_t iPhoton1 = meson->GetDaughter(1);
1022 AliAODMCParticle *photon0 = (AliAODMCParticle *) mcparticles->At(iPhoton0);
1023 AliAODMCParticle *photon1 = (AliAODMCParticle *) mcparticles->At(iPhoton1);
1026 if(photon0->GetPdgCode() != 22 && photon1->GetPdgCode()!=22)
1028 AliWarning(Form(
"Not overlapped. PDG: daughter 1 = %d, of daughter 2 = %d",photon0->GetPdgCode(),photon1->GetPdgCode()));
1032 AliDebug(2,Form(
"Daughter labels : photon0 = %d, photon1 = %d",iPhoton0,iPhoton1));
1035 Bool_t okPhoton0 = kFALSE;
1036 Bool_t okPhoton1 = kFALSE;
1038 AliDebug(3,
"Labels loop:");
1040 Bool_t conversion = kFALSE;
1042 for(
Int_t i = 0; i < nlabels; i++)
1044 AliDebug(3, Form(
"\t label %d/%d: %d, ok? %d, %d", i, nlabels, labels[i], okPhoton0, okPhoton1));
1046 if(labels[i]<0)
continue;
1049 if(okPhoton0 && okPhoton1)
break;
1051 Int_t index = labels[i];
1052 if (iPhoton0 == index)
1057 else if (iPhoton1 == index)
1065 if(index >= mcparticles->GetEntriesFast())
1067 AliWarning(Form(
"Particle index %d larger than size of list %d!!",index,mcparticles->GetEntriesFast()));
1071 AliAODMCParticle * daught = (AliAODMCParticle*) mcparticles->At(index);
1072 Int_t tmpindex = daught->GetMother();
1073 AliDebug(3,Form(
"Conversion? : mother %d",tmpindex));
1078 AliDebug(3,Form(
"\t parent index %d",tmpindex));
1079 daught = (AliAODMCParticle*) mcparticles->At(tmpindex);
1081 if (iPhoton0 == tmpindex)
1087 else if (iPhoton1 == tmpindex)
1094 tmpindex = daught->GetMother();
1103 if(okPhoton0 && okPhoton1)
1105 AliDebug(2,Form(
"%s OVERLAPPED DECAY",(TDatabasePDG::Instance()->GetParticle(mesonPdg))->GetName()));
1109 AliDebug(2,
"Second decay photon produced a conversion");
1122 AliStack * stack,
Int_t & tag)
1124 if(!arrayCluster || iMom < 0 || iParent < 0|| !stack)
return;
1126 TParticle * parent= stack->Particle(iParent);
1128 if(parent->GetNDaughters()!=2)
1134 Int_t pairLabel = -1;
1135 if ( iMom != parent->GetDaughter(0) ) pairLabel = parent->GetDaughter(0);
1136 else if( iMom != parent->GetDaughter(1) ) pairLabel = parent->GetDaughter(1);
1144 for(
Int_t iclus = 0; iclus < arrayCluster->GetEntriesFast(); iclus++)
1146 AliVCluster * cluster = (AliVCluster*) arrayCluster->At(iclus);
1147 for(
UInt_t ilab = 0; ilab< cluster->GetNLabels(); ilab++)
1149 Int_t label = cluster->GetLabels()[ilab];
1150 if ( label==pairLabel )
1155 else if ( label== iParent || label== iMom )
1161 TParticle * mother = stack->Particle(label);
1165 AliInfo(Form(
"MC Mother not available for label %d",label));
1169 Int_t momPDG = TMath::Abs(mother->GetPdgCode());
1170 if ( momPDG!=11 && momPDG!=22 )
continue;
1173 Int_t iParentClus = mother->GetFirstMother();
1174 if ( iParentClus < 0 )
continue;
1176 TParticle * parentClus = stack->Particle(iParentClus);
1177 if ( !parentClus )
continue;
1179 Int_t parentClusPDG = TMath::Abs(parentClus->GetPdgCode());
1180 Int_t parentClusStatus = parentClus->GetStatusCode();
1182 if( parentClusPDG != 22 && parentClusPDG != 11 && parentClusStatus != 0 )
continue;
1187 while ( (parentClusPDG == 22 || parentClusPDG == 11) && parentClusStatus != 1 )
1190 label = iParentClus;
1191 momPDG = parentClusPDG;
1193 iParentClus = parentClus->GetFirstMother();
1194 if(iParentClus < 0)
break;
1196 parentClus = stack->Particle(iParentClus);
1197 if(!parentClus)
break;
1199 parentClusPDG = TMath::Abs(parentClus->GetPdgCode());
1200 parentClusStatus = parentClus->GetStatusCode() ;
1203 if ( (momPDG == 22 || parentClusPDG ==22) && (label==pairLabel || iParentClus == pairLabel) )
1222 const TClonesArray* mcparticles,
Int_t & tag)
1224 if(!arrayCluster || iMom < 0 || iParent < 0|| !mcparticles)
return;
1226 AliAODMCParticle * parent = (AliAODMCParticle*) mcparticles->At(iParent);
1230 if(parent->GetNDaughters()!=2)
1237 Int_t pairLabel = -1;
1238 if ( iMom != parent->GetDaughter(0) ) pairLabel = parent->GetDaughter(0);
1239 else if( iMom != parent->GetDaughter(1) ) pairLabel = parent->GetDaughter(1);
1250 for(
Int_t iclus = 0; iclus < arrayCluster->GetEntriesFast(); iclus++)
1252 AliVCluster * cluster = (AliVCluster*) arrayCluster->At(iclus);
1254 for(
UInt_t ilab = 0; ilab< cluster->GetNLabels(); ilab++)
1256 Int_t label = cluster->GetLabels()[ilab];
1260 if ( label==pairLabel )
1266 else if ( label== iParent || label== iMom )
1273 AliAODMCParticle * mother = (AliAODMCParticle*) mcparticles->At(label);
1277 AliInfo(Form(
"MC Mother not available for label %d",label));
1281 Int_t momPDG = TMath::Abs(mother->GetPdgCode());
1282 if ( momPDG!=11 && momPDG!=22 )
continue;
1285 Int_t iParentClus = mother->GetMother();
1286 if(iParentClus < 0)
continue;
1288 AliAODMCParticle * parentClus = (AliAODMCParticle*) mcparticles->At(iParentClus);
1289 if(!parentClus)
continue;
1291 Int_t parentClusPDG = TMath::Abs(parentClus->GetPdgCode());
1292 Int_t parentClusStatus = parentClus->GetStatus();
1294 if ( parentClusPDG != 22 && parentClusPDG != 11 && parentClusStatus != 0 )
1303 while ((parentClusPDG == 22 || parentClusPDG == 11) && parentClusStatus != 1)
1306 label = iParentClus;
1307 momPDG = parentClusPDG;
1309 iParentClus = parentClus->GetMother();
1310 if ( iParentClus < 0 )
break;
1312 parentClus = (AliAODMCParticle*) mcparticles->At(iParentClus);
1313 if ( !parentClus )
break;
1315 parentClusPDG = TMath::Abs(parentClus->GetPdgCode());
1316 parentClusStatus = parentClus->GetStatus() ;
1319 if ( (momPDG == 22 || parentClusPDG ==22) && (label==pairLabel || iParentClus == pairLabel) )
1343 AliStack * stack = reader->
GetStack();
1349 Int_t nTriggerJets = 0;
1354 if(stack->GetNtrack() < 8)
return fJetsList;
1355 TParticle * parton1 = stack->Particle(6);
1356 TParticle * parton2 = stack->Particle(7);
1358 AliDebug(2,Form(
"Parton 6 : %s, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f",
1359 parton1->GetName(),parton1->Pt(),parton1->Energy(),parton1->Phi()*TMath::RadToDeg(),parton1->Eta()));
1360 AliDebug(2,Form(
"Parton 7 : %s, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f",
1361 parton2->GetName(),parton2->Pt(),parton2->Energy(),parton2->Phi()*TMath::RadToDeg(),parton2->Eta()));
1404 TParticle * jet = 0x0;
1405 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) geh;
1406 nTriggerJets = pygeh->NTriggerJets();
1407 AliDebug(2,Form(
"PythiaEventHeader: Njets: %d",nTriggerJets));
1409 for(
Int_t i = 0; i< nTriggerJets; i++)
1411 pygeh->TriggerJet(i, tmpjet);
1412 jet =
new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
1414 Float_t phidiff1 = TMath::Abs(jet->Phi()-parton1->Phi());
1415 Float_t phidiff2 = TMath::Abs(jet->Phi()-parton2->Phi());
1416 if(phidiff1 > phidiff2) jet->SetFirstMother(7);
1417 else jet->SetFirstMother(6);
1419 AliDebug(1,Form(
"PYTHIA Jet %d: mother %d, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f",
1420 i, jet->GetFirstMother(),jet->Pt(),jet->Energy(),jet->Phi()*TMath::RadToDeg(),jet->Eta()));
1429 TParticle * tmp = parton1;
1430 if(parton1->GetPdgCode()!=22)
1433 if(tmp->GetFirstDaughter()==-1)
return fJetsList;
1434 tmp = stack->Particle(tmp->GetFirstDaughter());
1435 pdg = tmp->GetPdgCode();
1439 TParticle *jet1 =
new TParticle(*tmp);
1440 jet1->SetFirstMother(6);
1446 AliDebug(1,Form(
"HERWIG Jet 1: mother %d, status %d, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f",
1447 jet1->GetFirstMother(),jet1->GetStatusCode(),jet1->Pt(),jet1->Energy(),jet1->Phi()*TMath::RadToDeg(),jet1->Eta()));
1453 if(parton2->GetPdgCode()!=22)
1457 if(tmp->GetFirstDaughter()==-1)
return fJetsList;
1458 tmp = stack->Particle(tmp->GetFirstDaughter());
1459 pdg = tmp->GetPdgCode();
1463 TParticle *jet2 =
new TParticle(*tmp);
1464 jet2->SetFirstMother(7);
1467 AliDebug(2,Form(
"HERWIG Jet 2: mother %d, status %d, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f",
1468 jet2->GetFirstMother(),jet2->GetStatusCode(),jet2->Pt(),jet2->Energy(),jet2->Phi()*TMath::RadToDeg(),jet2->Eta()));
1492 Bool_t & ok,
Int_t & daughlabel, TVector3 & prodVertex)
1500 AliWarning(
"Stack is not available, check analysis settings in configuration file!!");
1507 if(label >= 0 && label < nprimaries)
1509 TParticle * momP = reader->
GetStack()->Particle(label);
1510 daughlabel = momP->GetDaughter(idaugh);
1512 if(daughlabel < 0 || daughlabel >= nprimaries)
1518 TParticle * daughP = reader->
GetStack()->Particle(daughlabel);
1520 pdg = daughP->GetPdgCode();
1521 status = daughP->GetStatusCode();
1522 prodVertex.SetXYZ(daughP->Vx(),daughP->Vy(),daughP->Vz());
1535 AliWarning(
"AODMCParticles is not available, check analysis settings in configuration file!!");
1541 Int_t nprimaries = mcparticles->GetEntriesFast();
1542 if(label >= 0 && label < nprimaries)
1544 AliAODMCParticle * momP = (AliAODMCParticle *) mcparticles->At(label);
1545 daughlabel = momP->GetDaughter(idaugh);
1547 if(daughlabel < 0 || daughlabel >= nprimaries)
1553 AliAODMCParticle * daughP = (AliAODMCParticle *) mcparticles->At(daughlabel);
1554 fDaughMom.SetPxPyPzE(daughP->Px(),daughP->Py(),daughP->Pz(),daughP->E());
1555 pdg = daughP->GetPdgCode();
1556 status = daughP->GetStatus();
1557 prodVertex.SetXYZ(daughP->Xv(),daughP->Yv(),daughP->Zv());
1578 return GetMother(label,reader,pdg,status, ok,momlabel);
1587 Int_t momlabel = -1;
1589 return GetMother(label,reader,pdg,status, ok,momlabel);
1604 AliWarning(
"Stack is not available, check analysis settings in configuration file, STOP!!");
1609 if(label >= 0 && label < reader->
GetStack()->GetNtrack())
1611 TParticle * momP = reader->
GetStack()->Particle(label);
1613 pdg = momP->GetPdgCode();
1614 status = momP->GetStatusCode();
1615 momlabel = momP->GetFirstMother();
1628 AliWarning(
"AODMCParticles is not available, check analysis settings in configuration file!!");
1634 Int_t nprimaries = mcparticles->GetEntriesFast();
1635 if(label >= 0 && label < nprimaries)
1637 AliAODMCParticle * momP = (AliAODMCParticle *) mcparticles->At(label);
1638 fMotherMom.SetPxPyPzE(momP->Px(),momP->Py(),momP->Pz(),momP->E());
1639 pdg = momP->GetPdgCode();
1640 status = momP->GetStatus();
1641 momlabel = momP->GetMother();
1668 AliWarning(
"Stack is not available, check analysis settings in configuration file!!");
1674 if(label >= 0 && label < reader->
GetStack()->GetNtrack())
1676 TParticle * momP = reader->
GetStack()->Particle(label);
1678 if(momP->GetPdgCode()==
pdg)
1680 AliDebug(2,
"PDG of mother is already the one requested!");
1681 fGMotherMom.SetPxPyPzE(momP->Px(),momP->Py(),momP->Pz(),momP->Energy());
1686 Int_t grandmomLabel = momP->GetFirstMother();
1687 Int_t grandmomPDG = -1;
1688 TParticle * grandmomP = 0x0;
1689 while (grandmomLabel >=0 )
1691 grandmomP = reader->
GetStack()->Particle(grandmomLabel);
1692 grandmomPDG = grandmomP->GetPdgCode();
1693 if(grandmomPDG==pdg)
1695 momlabel = grandmomLabel;
1696 fGMotherMom.SetPxPyPzE(grandmomP->Px(),grandmomP->Py(),grandmomP->Pz(),grandmomP->Energy());
1700 grandmomLabel = grandmomP->GetFirstMother();
1704 if(grandmomPDG!=pdg) AliInfo(Form(
"Mother with PDG %d, NOT found! \n",pdg));
1712 AliWarning(
"AODMCParticles is not available, check analysis settings in configuration file!!");
1718 Int_t nprimaries = mcparticles->GetEntriesFast();
1719 if(label >= 0 && label < nprimaries)
1721 AliAODMCParticle * momP = (AliAODMCParticle *) mcparticles->At(label);
1723 if(momP->GetPdgCode()==
pdg)
1725 AliDebug(2,
"PDG of mother is already the one requested!");
1726 fGMotherMom.SetPxPyPzE(momP->Px(),momP->Py(),momP->Pz(),momP->E());
1731 Int_t grandmomLabel = momP->GetMother();
1732 Int_t grandmomPDG = -1;
1733 AliAODMCParticle * grandmomP = 0x0;
1734 while (grandmomLabel >=0 )
1736 grandmomP = (AliAODMCParticle *) mcparticles->At(grandmomLabel);
1737 grandmomPDG = grandmomP->GetPdgCode();
1738 if(grandmomPDG==pdg)
1741 momlabel = grandmomLabel;
1742 fGMotherMom.SetPxPyPzE(grandmomP->Px(),grandmomP->Py(),grandmomP->Pz(),grandmomP->E());
1746 grandmomLabel = grandmomP->GetMother();
1750 if(grandmomPDG!=pdg) AliInfo(Form(
"Mother with PDG %d, NOT found!",pdg));
1765 Int_t & grandMomLabel,
Int_t & greatMomLabel)
1773 AliWarning(
"Stack is not available, check analysis settings in configuration file, STOP!!");
1779 if(label >= 0 && label < reader->
GetStack()->GetNtrack())
1781 TParticle * momP = reader->
GetStack()->Particle(label);
1783 grandMomLabel = momP->GetFirstMother();
1785 TParticle * grandmomP = 0x0;
1787 if (grandMomLabel >=0 )
1789 grandmomP = reader->
GetStack()->Particle(grandMomLabel);
1790 pdg = grandmomP->GetPdgCode();
1791 status = grandmomP->GetStatusCode();
1793 fGMotherMom.SetPxPyPzE(grandmomP->Px(),grandmomP->Py(),grandmomP->Pz(),grandmomP->Energy());
1794 greatMomLabel = grandmomP->GetFirstMother();
1804 AliWarning(
"AODMCParticles is not available, check analysis settings in configuration file!!");
1810 Int_t nprimaries = mcparticles->GetEntriesFast();
1811 if(label >= 0 && label < nprimaries)
1813 AliAODMCParticle * momP = (AliAODMCParticle *) mcparticles->At(label);
1815 grandMomLabel = momP->GetMother();
1817 AliAODMCParticle * grandmomP = 0x0;
1819 if(grandMomLabel >=0 )
1821 grandmomP = (AliAODMCParticle *) mcparticles->At(grandMomLabel);
1822 pdg = grandmomP->GetPdgCode();
1823 status = grandmomP->GetStatus();
1825 fGMotherMom.SetPxPyPzE(grandmomP->Px(),grandmomP->Py(),grandmomP->Pz(),grandmomP->E());
1826 greatMomLabel = grandmomP->GetMother();
1847 AliWarning(
"Stack is not available, check analysis settings in configuration file, STOP!!");
1851 if(label >= 0 && label < reader->
GetStack()->GetNtrack())
1853 TParticle * momP = reader->
GetStack()->Particle(label);
1855 Int_t grandmomLabel = momP->GetFirstMother();
1856 Int_t grandmomPDG = -1;
1857 TParticle * grandmomP = 0x0;
1858 while (grandmomLabel >=0 )
1860 grandmomP = reader->
GetStack()->Particle(grandmomLabel);
1861 grandmomPDG = grandmomP->GetPdgCode();
1863 if(grandmomPDG==pdg)
break;
1865 grandmomLabel = grandmomP->GetFirstMother();
1869 if(grandmomPDG==pdg && grandmomP->GetNDaughters()==2)
1871 TParticle * d1 = reader->
GetStack()->Particle(grandmomP->GetDaughter(0));
1872 TParticle * d2 = reader->
GetStack()->Particle(grandmomP->GetDaughter(1));
1873 if(d1->GetPdgCode() == 22 && d1->GetPdgCode() == 22)
1875 asym = (d1->Energy()-d2->Energy())/grandmomP->Energy();
1884 AliInfo(Form(
"Mother with PDG %d, not found!",pdg));
1894 AliWarning(
"AODMCParticles is not available, check analysis settings in configuration file!!");
1900 Int_t nprimaries = mcparticles->GetEntriesFast();
1901 if(label >= 0 && label < nprimaries)
1903 AliAODMCParticle * momP = (AliAODMCParticle *) mcparticles->At(label);
1905 Int_t grandmomLabel = momP->GetMother();
1906 Int_t grandmomPDG = -1;
1907 AliAODMCParticle * grandmomP = 0x0;
1908 while (grandmomLabel >=0 )
1910 grandmomP = (AliAODMCParticle *) mcparticles->At(grandmomLabel);
1911 grandmomPDG = grandmomP->GetPdgCode();
1913 if(grandmomPDG==pdg)
break;
1915 grandmomLabel = grandmomP->GetMother();
1919 if(grandmomPDG==pdg && grandmomP->GetNDaughters()==2)
1921 AliAODMCParticle * d1 = (AliAODMCParticle *) mcparticles->At(grandmomP->GetDaughter(0));
1922 AliAODMCParticle * d2 = (AliAODMCParticle *) mcparticles->At(grandmomP->GetDaughter(1));
1923 if(d1->GetPdgCode() == 22 && d1->GetPdgCode() == 22)
1925 asym = (d1->E()-d2->E())/grandmomP->E();
1926 fDaughMom .SetPxPyPzE(d1->Px(),d1->Py(),d1->Pz(),d1->E());
1927 fDaughMom2.SetPxPyPzE(d2->Px(),d2->Py(),d2->Pz(),d2->E());
1934 AliInfo(Form(
"Mother with PDG %d, not found! \n",pdg));
1953 AliWarning(
"Stack is not available, check analysis settings in configuration file, STOP!!");
1958 if(label >= 0 && label < reader->
GetStack()->GetNtrack())
1960 TParticle * momP = reader->
GetStack()->Particle(label);
1962 return momP->GetNDaughters();
1975 AliWarning(
"AODMCParticles is not available, check analysis settings in configuration file!!");
1981 Int_t nprimaries = mcparticles->GetEntriesFast();
1982 if(label >= 0 && label < nprimaries)
1984 AliAODMCParticle * momP = (AliAODMCParticle *) mcparticles->At(label);
1986 return momP->GetNDaughters();
2011 Int_t ancPDG = 0, ancStatus = -1;
2012 TVector3 prodVertex;
2014 Int_t noverlaps = 0;
2017 for (
UInt_t ilab = 1; ilab < nlabels; ilab++ )
2031 else if ( ( ancPDG==111 || ancPDG==221 ) &&
2033 ( (mesonLabel != ancLabel) && mesonLabel >=0 ) )
2038 else if( ancPDG!=22 && TMath::Abs(ancPDG)!=11 && ancPDG != 111 && ancPDG != 221 )
2044 if( !overlap ) continue ;
2054 Int_t mpdg = -999999, gpdg = -1;
2055 Int_t mstatus = -1, gstatus = -1;
2056 Int_t gLabel = -1, ggLabel = -1;
2058 GetMother (label[ilab],reader,mpdg,mstatus,mOK);
2060 GetGrandMother(label[ilab],reader,gpdg,gstatus,gOK, gLabel,ggLabel);
2064 if( ( mpdg == 22 || TMath::Abs(mpdg==11) ) &&
2065 ( gpdg == 22 || TMath::Abs(gpdg==11) ) &&
2068 Int_t labeltmp = gLabel;
2069 while( ( gpdg == 22 || TMath::Abs(gpdg==11) ) && gLabel >=0 )
2076 overpdg [noverlaps-1] = mpdg;
2077 overlabel[noverlaps-1] = label[ilab];
2091 printf(
"***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
2093 printf(
"Debug level = %d\n",
fDebug);
2103 printf(
"AliMCAnalysisUtils::PrintMCTag() - tag %d \n photon %d, conv %d, prompt %d, frag %d, isr %d, \n pi0 decay %d, eta decay %d, other decay %d pi0 %d, eta %d \n electron %d, muon %d,pion %d, proton %d, neutron %d, \n kaon %d, a-proton %d, a-neutron %d, unk %d, bad %d\n",
TLorentzVector GetMotherWithPDG(Int_t label, Int_t pdg, const AliCaloTrackReader *reader, Bool_t &ok, Int_t &momLabel)
void SetMCGenerator(Int_t mcgen)
Set the generator type.
void CheckLostDecayPair(const TObjArray *arrayCluster, Int_t iMom, Int_t iParent, AliStack *stack, Int_t &tag)
Check on ESDs if the current decay photon has the second photon companion lost.
Int_t fCurrentEvent
Current Event number.
TLorentzVector fMotherMom
! particle momentum
Bool_t ReadAODMCParticles() const
void PrintMCTag(Int_t tag) const
Print the assigned origins to this particle.
virtual TObjArray * GetEMCALClusters() const
virtual AliGenEventHeader * GetGenEventHeader() const
const TString calorimeter
virtual ~AliMCAnalysisUtils()
Destructor.
void SetTagBit(Int_t &tag, UInt_t set) const
TLorentzVector fGMotherMom
! particle momentum
TLorentzVector GetMother(Int_t label, const AliCaloTrackReader *reader, Bool_t &ok)
TLorentzVector fDaughMom2
! particle momentum
void GetMCDecayAsymmetryAngleForPDG(Int_t label, Int_t pdg, const AliCaloTrackReader *reader, Float_t &asy, Float_t &angle, Bool_t &ok)
In case of an eta or pi0 decay into 2 photons, get the asymmetry in the energy of the photons...
virtual Int_t GetEventNumber() const
virtual TClonesArray * GetAODMCParticles() const
void Print(const Option_t *opt) const
Print some relevant parameters set for the analysis.
Int_t CheckOriginInStack(const Int_t *labels, Int_t nlabels, AliStack *stack, const TObjArray *arrayCluster)
Int_t GetNDaughters(Int_t label, const AliCaloTrackReader *reader, Bool_t &ok)
TLorentzVector GetGrandMother(Int_t label, const AliCaloTrackReader *reader, Int_t &pdg, Int_t &status, Bool_t &ok, Int_t &grandMomLabel, Int_t &greatMomLabel)
Int_t CheckOrigin(Int_t label, const AliCaloTrackReader *reader, Int_t calorimeter)
Base class for event, clusters and tracks filtering and preparation for the analysis.
Int_t fMCGenerator
MC generator used to generate data in simulation.
Int_t CheckOriginInAOD(const Int_t *labels, Int_t nlabels, const TClonesArray *mcparticles, const TObjArray *arrayCluster)
virtual TObjArray * GetPHOSClusters() const
TLorentzVector fDaughMom
! particle momentum
TList * fJetsList
List of jets.
TLorentzVector GetDaughter(Int_t daughter, Int_t label, const AliCaloTrackReader *reader, Int_t &pdg, Int_t &status, Bool_t &ok, Int_t &daugLabel, TVector3 &prodVertex)
Int_t GetNOverlaps(const Int_t *label, UInt_t nlabels, Int_t mctag, Int_t mesonLabel, AliCaloTrackReader *reader, Int_t *overpdg, Int_t *overlabel)
virtual AliStack * GetStack() const
TString fMCGeneratorString
MC generator used to generate data in simulation.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
THStack * GetStack(TCollection *c, const char *name, Bool_t verb=true)
void CheckOverlapped2GammaDecay(const Int_t *labels, Int_t nlabels, Int_t mesonIndex, AliStack *stack, Int_t &tag)
AliMCAnalysisUtils()
Constructor.
Class with analysis utils for simulations.
Int_t CheckCommonAncestor(Int_t index1, Int_t index2, const AliCaloTrackReader *reader, Int_t &ancPDG, Int_t &ancStatus, TLorentzVector &momentum, TVector3 &prodVertex)
TList * GetJets(const AliCaloTrackReader *reader)
Bool_t CheckTagBit(Int_t tag, UInt_t test) const