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()
67 Int_t & ancPDG, Int_t & ancStatus,
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!!!");
229 TObjArray* arrayCluster = 0;
258 AliWarning(
"No MC labels available, please check!!!");
262 TObjArray* arrayCluster = 0;
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();
342 mom = stack->Particle(iMom);
343 mPdgSign = mom->GetPdgCode();
344 mPdg = TMath::Abs(mPdgSign);
345 mStatus = mom->GetStatusCode() ;
346 iParent = mom->GetFirstMother() ;
353 parent = stack->Particle(iParent);
356 pPdg = TMath::Abs(parent->GetPdgCode());
357 pStatus = parent->GetStatusCode();
367 AliDebug(2,
"Converted photon/electron:");
368 AliDebug(2,Form(
"\t Mother label %d, pdg %d, status %d",iMom, mPdg, mStatus));
369 AliDebug(2,Form(
"\t Parent label %d, pdg %d, status %d",iParent, pPdg, pStatus));
372 else if((mPdg == 22 || mPdg == 11) && mStatus == 0)
375 if(pPdg == 2112 || pPdg == 211 || pPdg == 321 ||
376 pPdg == 2212 || pPdg == 130 || pPdg == 13 )
379 iMom = mom->GetFirstMother();
380 mom = stack->Particle(iMom);
381 mPdgSign = mom->GetPdgCode();
382 mPdg = TMath::Abs(mPdgSign);
384 AliDebug(2,
"Converted hadron:");
385 AliDebug(2,Form(
"\t Mother label %d, pdg %d, status %d",iMom, mPdg, mStatus));
416 AliDebug(2,
"First mother is directly pi0, not decayed by generator");
425 AliDebug(2,
"First mother is directly eta, not decayed by generator");
438 AliDebug(2,
"PYTHIA pi0 decay photon, parent pi0 with status 11");
447 else if (pPdg == 221)
451 AliDebug(2,
"PYTHIA eta decay photon, parent pi0 with status 11");
458 else if(mStatus == 1)
462 if(iParent < 8 && iParent > 5)
467 else if(iParent <= 5)
482 if(parent->GetFirstMother()<=5)
break;
483 iParent = parent->GetFirstMother();
484 parent=stack->Particle(iParent);
485 pStatus= parent->GetStatusCode();
486 pPdg = TMath::Abs(parent->GetPdgCode());
490 if(iParent < 8 && iParent > 5)
506 if(pPdg == 11 && parent)
508 Int_t iGrandma = parent->GetFirstMother();
511 TParticle* gma = (TParticle*)stack->Particle(iGrandma);
512 Int_t gPdg = TMath::Abs(gma->GetPdgCode());
521 AliDebug(1,
"Checking ancestors of electrons");
525 else if((499 < pPdg && pPdg < 600)||(4999 < pPdg && pPdg < 6000)) {
SetTagBit(tag,
kMCEFromB); }
526 else if((399 < pPdg && pPdg < 500)||(3999 < pPdg && pPdg < 5000))
530 Int_t iGrandma = parent->GetFirstMother();
533 TParticle* gma = (TParticle*)stack->Particle(iGrandma);
534 Int_t gPdg = TMath::Abs(gma->GetPdgCode());
554 AliDebug(2,Form(
"\t Setting kMCUnknown for cluster from %s (pdg = %d, Parent pdg = %d)",
555 mom->GetName(),mPdg,pPdg));
563 AliWarning(Form(
"*** bad label or no stack ***: label %d ", label));
565 if(label >= stack->GetNtrack())
566 AliWarning(Form(
"*** large label ***: label %d, n tracks %d", label, stack->GetNtrack()));
586 const TClonesArray *mcparticles,
const TObjArray* arrayCluster)
590 AliDebug(1,
"AODMCParticles is not available, check analysis settings in configuration file!!");
595 Int_t label=labels[0];
597 Int_t nprimaries = mcparticles->GetEntriesFast();
598 if(label >= 0 && label < nprimaries)
601 AliAODMCParticle * mom = (AliAODMCParticle *) mcparticles->At(label);
603 Int_t mPdgSign = mom->GetPdgCode();
604 Int_t mPdg = TMath::Abs(mPdgSign);
605 Int_t iParent = mom->GetMother() ;
610 AliAODMCParticle * parent = NULL ;
614 parent = (AliAODMCParticle *) mcparticles->At(iParent);
615 pPdg = TMath::Abs(parent->GetPdgCode());
617 else AliDebug(1,Form(
"Parent with label %d",iParent));
619 AliDebug(2,
"Cluster most contributing mother and its parent:");
620 AliDebug(2,Form(
"\t Mother label %d, pdg %d, Primary? %d, Physical Primary? %d",iMom, mPdg, mom->IsPrimary(), mom->IsPhysicalPrimary()));
621 AliDebug(2,Form(
"\t Parent label %d, pdg %d, Primary? %d, Physical Primary? %d",iParent, pPdg, parent?parent->IsPrimary():-1, parent?parent->IsPhysicalPrimary():-1));
624 if((mPdg == 22 || mPdg == 11) && (pPdg == 22 || pPdg == 11) && !mom->IsPrimary())
629 while ((pPdg == 22 || pPdg == 11) && !mom->IsPhysicalPrimary())
632 iMom = mom->GetMother();
633 mom = (AliAODMCParticle *) mcparticles->At(iMom);
634 mPdgSign = mom->GetPdgCode();
635 mPdg = TMath::Abs(mPdgSign);
636 iParent = mom->GetMother() ;
640 if(iParent >= 0 && parent)
642 parent = (AliAODMCParticle *) mcparticles->At(iParent);
643 pPdg = TMath::Abs(parent->GetPdgCode());
650 AliDebug(2,
"AliMCAnalysisUtils::CheckOriginInAOD() - Converted photon/electron:");
651 AliDebug(2,Form(
"\t Mother label %d, pdg %d, Primary? %d, Physical Primary? %d",iMom, mPdg, mom->IsPrimary(), mom->IsPhysicalPrimary()));
652 AliDebug(2,Form(
"\t Parent label %d, pdg %d, Primary? %d, Physical Primary? %d",iParent, pPdg, parent?parent->IsPrimary():-1, parent?parent->IsPhysicalPrimary():-1));
655 else if((mPdg == 22 || mPdg == 11) && !mom->IsPrimary())
658 if(pPdg == 2112 || pPdg == 211 || pPdg == 321 ||
659 pPdg == 2212 || pPdg == 130 || pPdg == 13 )
662 iMom = mom->GetMother();
663 mom = (AliAODMCParticle *) mcparticles->At(iMom);
664 mPdgSign = mom->GetPdgCode();
665 mPdg = TMath::Abs(mPdgSign);
667 AliDebug(2,
"AliMCAnalysisUtils::CheckOriginInAOD() - Converted hadron:");
668 AliDebug(2,Form(
"\t Mother label %d, pdg %d, Primary? %d, Physical Primary? %d",iMom, mPdg, mom->IsPrimary(), mom->IsPhysicalPrimary()));
701 AliDebug(2,
"First mother is directly pi0, not decayed by generator");
709 AliDebug(2,
"First mother is directly eta, not decayed by generator");
722 AliDebug(2,
"Generator pi0 decay photon");
733 else if (pPdg == 221)
737 AliDebug(2,
"Generator eta decay photon");
746 if(iParent < 8 && iParent > 5 )
764 if(pPdg == 11 && parent)
766 Int_t iGrandma = parent->GetMother();
769 AliAODMCParticle* gma = (AliAODMCParticle*)mcparticles->At(iGrandma);
770 Int_t gPdg = TMath::Abs(gma->GetPdgCode());
779 AliDebug(1,
"Checking ancestors of electrons");
783 else if((499 < pPdg && pPdg < 600)||(4999 < pPdg && pPdg < 6000)) {
SetTagBit(tag,
kMCEFromB);}
784 else if((399 < pPdg && pPdg < 500)||(3999 < pPdg && pPdg < 5000))
788 Int_t iGrandma = parent->GetMother();
791 AliAODMCParticle* gma = (AliAODMCParticle*)mcparticles->At(iGrandma);
792 Int_t gPdg = TMath::Abs(gma->GetPdgCode());
800 TParticlePDG* foo = TDatabasePDG::Instance()->GetParticle(pPdg);
801 TParticlePDG* foo1 = TDatabasePDG::Instance()->GetParticle(mPdg);
803 AliDebug(1,Form(
"Electron from other origin: %s (pPdg = %d) %s (mPdg = %d)",foo->GetName(), pPdg,foo1->GetName(),mPdg));
812 AliDebug(1,Form(
"\t Setting kMCUnknown for cluster with pdg = %d, Parent pdg = %d",mPdg,pPdg));
819 AliWarning(Form(
"*** bad label or no mcparticles ***: label %d", label));
821 if(label >= mcparticles->GetEntriesFast())
822 AliWarning(Form(
"*** large label ***: label %d, n tracks %d", label, mcparticles->GetEntriesFast()));
836 Int_t mesonIndex, AliStack *stack,
839 if(labels[0] < 0 || labels[0] > stack->GetNtrack() || nlabels <= 1)
841 AliDebug(2,Form(
"Exit : label[0] %d, n primaries %d, nlabels %d",labels[0],stack->GetNtrack(), nlabels));
845 TParticle *
meson = stack->Particle(mesonIndex);
846 Int_t mesonPdg = meson->GetPdgCode();
847 if(mesonPdg!=111 && mesonPdg!=221)
849 AliWarning(Form(
"Wrong pi0/eta PDG : %d",mesonPdg));
853 AliDebug(2,Form(
"%s, label %d",meson->GetName(), mesonIndex));
856 if(meson->GetNDaughters() != 2)
858 AliDebug(2,Form(
"Not overalapped. Number of daughters is %d, not 2",meson->GetNDaughters()));
863 Int_t iPhoton0 = meson->GetDaughter(0);
864 Int_t iPhoton1 = meson->GetDaughter(1);
865 TParticle *photon0 = stack->Particle(iPhoton0);
866 TParticle *photon1 = stack->Particle(iPhoton1);
869 if(photon0->GetPdgCode() != 22 || photon1->GetPdgCode()!=22)
871 AliDebug(2,Form(
"Not overalapped. PDG: daughter 1 = %d, of daughter 2 = %d",photon0->GetPdgCode(),photon1->GetPdgCode()));
875 AliDebug(2,Form(
"Daughter labels : photon0 = %d, photon1 = %d",iPhoton0,iPhoton1));
878 Bool_t okPhoton0 = kFALSE;
879 Bool_t okPhoton1 = kFALSE;
881 AliDebug(3,
"Labels loop:");
883 Bool_t conversion = kFALSE;
885 for(Int_t i = 0; i < nlabels; i++)
887 AliDebug(3,Form(
"\t at begin:label %d/%d: %d, ok? photon1 %d, photon2 %d", i+1, nlabels, labels[i], okPhoton0, okPhoton1));
890 if(okPhoton0 && okPhoton1)
break;
892 Int_t index = labels[i];
893 if (iPhoton0 == index)
898 else if (iPhoton1 == index)
906 if(index >= stack->GetNtrack())
908 AliWarning(Form(
"Particle index %d larger than size of list %d!!",index,stack->GetNtrack()));
912 TParticle * daught = stack->Particle(index);
913 Int_t tmpindex = daught->GetFirstMother();
915 AliDebug(3,Form(
"\t Conversion? : mother %d",tmpindex));
920 AliDebug(3,Form(
"\t \t parent index %d",tmpindex));
921 daught = stack->Particle(tmpindex);
922 if (iPhoton0 == tmpindex)
928 else if (iPhoton1 == tmpindex)
935 tmpindex = daught->GetFirstMother();
945 if(okPhoton0 && okPhoton1)
947 AliDebug(2,Form(
"%s OVERLAPPED DECAY", meson->GetName()));
961 const TClonesArray *mcparticles, Int_t & tag )
963 if(labels[0] < 0 || labels[0] > mcparticles->GetEntriesFast() || nlabels <= 1)
965 AliDebug(2,Form(
"Exit : label[0] %d, n primaries %d, nlabels %d",labels[0],mcparticles->GetEntriesFast(), nlabels));
969 AliAODMCParticle *
meson = (AliAODMCParticle *) mcparticles->At(mesonIndex);
970 Int_t mesonPdg = meson->GetPdgCode();
971 if(mesonPdg != 111 && mesonPdg != 221)
973 AliWarning(Form(
"Wrong pi0/eta PDG : %d",mesonPdg));
977 AliDebug(2,Form(
"pdg %d, label %d, ndaughters %d", mesonPdg, mesonIndex, meson->GetNDaughters()));
980 if(meson->GetNDaughters() != 2)
982 AliDebug(2,Form(
"Not overalapped. Number of daughters is %d, not 2",meson->GetNDaughters()));
986 Int_t iPhoton0 = meson->GetDaughter(0);
987 Int_t iPhoton1 = meson->GetDaughter(1);
993 AliAODMCParticle *photon0 = (AliAODMCParticle *) mcparticles->At(iPhoton0);
994 AliAODMCParticle *photon1 = (AliAODMCParticle *) mcparticles->At(iPhoton1);
997 if(photon0->GetPdgCode() != 22 && photon1->GetPdgCode()!=22)
999 AliWarning(Form(
"Not overlapped. PDG: daughter 1 = %d, of daughter 2 = %d",photon0->GetPdgCode(),photon1->GetPdgCode()));
1003 AliDebug(2,Form(
"Daughter labels : photon0 = %d, photon1 = %d",iPhoton0,iPhoton1));
1006 Bool_t okPhoton0 = kFALSE;
1007 Bool_t okPhoton1 = kFALSE;
1009 AliDebug(3,
"Labels loop:");
1011 Bool_t conversion = kFALSE;
1013 for(Int_t i = 0; i < nlabels; i++)
1015 AliDebug(3, Form(
"\t label %d/%d: %d, ok? %d, %d", i, nlabels, labels[i], okPhoton0, okPhoton1));
1017 if(labels[i]<0)
continue;
1020 if(okPhoton0 && okPhoton1)
break;
1022 Int_t index = labels[i];
1023 if (iPhoton0 == index)
1028 else if (iPhoton1 == index)
1036 if(index >= mcparticles->GetEntriesFast())
1038 AliWarning(Form(
"Particle index %d larger than size of list %d!!",index,mcparticles->GetEntriesFast()));
1042 AliAODMCParticle * daught = (AliAODMCParticle*) mcparticles->At(index);
1043 Int_t tmpindex = daught->GetMother();
1044 AliDebug(3,Form(
"Conversion? : mother %d",tmpindex));
1049 AliDebug(3,Form(
"\t parent index %d",tmpindex));
1050 daught = (AliAODMCParticle*) mcparticles->At(tmpindex);
1052 if (iPhoton0 == tmpindex)
1058 else if (iPhoton1 == tmpindex)
1065 tmpindex = daught->GetMother();
1074 if(okPhoton0 && okPhoton1)
1076 AliDebug(2,Form(
"%s OVERLAPPED DECAY",(TDatabasePDG::Instance()->GetParticle(mesonPdg))->GetName()));
1080 AliDebug(2,
"Second decay photon produced a conversion");
1093 AliStack * stack, Int_t & tag)
1095 if(!arrayCluster || iMom < 0 || iParent < 0|| !stack)
return;
1097 TParticle * parent= stack->Particle(iParent);
1099 if(parent->GetNDaughters()!=2)
1105 Int_t pairLabel = -1;
1106 if ( iMom != parent->GetDaughter(0) ) pairLabel = parent->GetDaughter(0);
1107 else if( iMom != parent->GetDaughter(1) ) pairLabel = parent->GetDaughter(1);
1115 for(Int_t iclus = 0; iclus < arrayCluster->GetEntriesFast(); iclus++)
1117 AliVCluster * cluster = (AliVCluster*) arrayCluster->At(iclus);
1118 for(UInt_t ilab = 0; ilab< cluster->GetNLabels(); ilab++)
1120 Int_t label = cluster->GetLabels()[ilab];
1121 if(label==pairLabel)
1126 else if(label== iParent || label== iMom)
1132 TParticle * mother = stack->Particle(label);
1133 Int_t momPDG = TMath::Abs(mother->GetPdgCode());
1134 if(momPDG!=11 && momPDG!=22)
continue;
1137 Int_t iParentClus = mother->GetFirstMother();
1138 if(iParentClus < 0)
continue;
1140 TParticle * parentClus = stack->Particle(iParentClus);
1141 if(!parentClus)
continue;
1143 Int_t parentClusPDG = TMath::Abs(parentClus->GetPdgCode());
1144 Int_t parentClusStatus = parentClus->GetStatusCode();
1146 if( parentClusPDG != 22 && parentClusPDG != 11 && parentClusStatus != 0)
continue;
1151 while ((parentClusPDG == 22 || parentClusPDG == 11) && parentClusStatus != 1)
1154 label = iParentClus;
1155 momPDG = parentClusPDG;
1157 iParentClus = parentClus->GetFirstMother();
1158 if(iParentClus < 0)
break;
1160 parentClus = stack->Particle(iParentClus);
1161 if(!parentClus)
break;
1163 parentClusPDG = TMath::Abs(parentClus->GetPdgCode());
1164 parentClusStatus = parentClus->GetStatusCode() ;
1167 if((momPDG == 22 || parentClusPDG ==22) && (label==pairLabel || iParentClus == pairLabel))
1186 const TClonesArray* mcparticles, Int_t & tag)
1188 if(!arrayCluster || iMom < 0 || iParent < 0|| !mcparticles)
return;
1190 AliAODMCParticle * parent = (AliAODMCParticle*) mcparticles->At(iParent);
1194 if(parent->GetNDaughters()!=2)
1201 Int_t pairLabel = -1;
1202 if ( iMom != parent->GetDaughter(0) ) pairLabel = parent->GetDaughter(0);
1203 else if( iMom != parent->GetDaughter(1) ) pairLabel = parent->GetDaughter(1);
1214 for(Int_t iclus = 0; iclus < arrayCluster->GetEntriesFast(); iclus++)
1216 AliVCluster * cluster = (AliVCluster*) arrayCluster->At(iclus);
1218 for(UInt_t ilab = 0; ilab< cluster->GetNLabels(); ilab++)
1220 Int_t label = cluster->GetLabels()[ilab];
1224 if(label==pairLabel)
1230 else if(label== iParent || label== iMom)
1237 AliAODMCParticle * mother = (AliAODMCParticle*) mcparticles->At(label);
1238 Int_t momPDG = TMath::Abs(mother->GetPdgCode());
1239 if(momPDG!=11 && momPDG!=22)
1246 Int_t iParentClus = mother->GetMother();
1247 if(iParentClus < 0)
continue;
1249 AliAODMCParticle * parentClus = (AliAODMCParticle*) mcparticles->At(iParentClus);
1250 if(!parentClus)
continue;
1252 Int_t parentClusPDG = TMath::Abs(parentClus->GetPdgCode());
1253 Int_t parentClusStatus = parentClus->GetStatus();
1255 if( parentClusPDG != 22 && parentClusPDG != 11 && parentClusStatus != 0)
1264 while ((parentClusPDG == 22 || parentClusPDG == 11) && parentClusStatus != 1)
1267 label = iParentClus;
1268 momPDG = parentClusPDG;
1270 iParentClus = parentClus->GetMother();
1271 if(iParentClus < 0)
break;
1273 parentClus = (AliAODMCParticle*) mcparticles->At(iParentClus);
1274 if(!parentClus)
break;
1276 parentClusPDG = TMath::Abs(parentClus->GetPdgCode());
1277 parentClusStatus = parentClus->GetStatus() ;
1280 if((momPDG == 22 || parentClusPDG ==22) && (label==pairLabel || iParentClus == pairLabel))
1304 AliStack * stack = reader->
GetStack();
1310 Int_t nTriggerJets = 0;
1311 Float_t tmpjet[]={0,0,0,0};
1315 if(stack->GetNtrack() < 8)
return fJetsList;
1316 TParticle * parton1 = stack->Particle(6);
1317 TParticle * parton2 = stack->Particle(7);
1319 AliDebug(2,Form(
"Parton 6 : %s, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f",
1320 parton1->GetName(),parton1->Pt(),parton1->Energy(),parton1->Phi()*TMath::RadToDeg(),parton1->Eta()));
1321 AliDebug(2,Form(
"Parton 7 : %s, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f",
1322 parton2->GetName(),parton2->Pt(),parton2->Energy(),parton2->Phi()*TMath::RadToDeg(),parton2->Eta()));
1365 TParticle * jet = 0x0;
1366 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) geh;
1367 nTriggerJets = pygeh->NTriggerJets();
1368 AliDebug(2,Form(
"PythiaEventHeader: Njets: %d",nTriggerJets));
1370 for(Int_t i = 0; i< nTriggerJets; i++)
1372 pygeh->TriggerJet(i, tmpjet);
1373 jet =
new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
1375 Float_t phidiff1 = TMath::Abs(jet->Phi()-parton1->Phi());
1376 Float_t phidiff2 = TMath::Abs(jet->Phi()-parton2->Phi());
1377 if(phidiff1 > phidiff2) jet->SetFirstMother(7);
1378 else jet->SetFirstMother(6);
1380 AliDebug(1,Form(
"PYTHIA Jet %d: mother %d, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f",
1381 i, jet->GetFirstMother(),jet->Pt(),jet->Energy(),jet->Phi()*TMath::RadToDeg(),jet->Eta()));
1390 TParticle * tmp = parton1;
1391 if(parton1->GetPdgCode()!=22)
1394 if(tmp->GetFirstDaughter()==-1)
return fJetsList;
1395 tmp = stack->Particle(tmp->GetFirstDaughter());
1396 pdg = tmp->GetPdgCode();
1400 TParticle *jet1 =
new TParticle(*tmp);
1401 jet1->SetFirstMother(6);
1407 AliDebug(1,Form(
"HERWIG Jet 1: mother %d, status %d, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f",
1408 jet1->GetFirstMother(),jet1->GetStatusCode(),jet1->Pt(),jet1->Energy(),jet1->Phi()*TMath::RadToDeg(),jet1->Eta()));
1414 if(parton2->GetPdgCode()!=22)
1418 if(tmp->GetFirstDaughter()==-1)
return fJetsList;
1419 tmp = stack->Particle(tmp->GetFirstDaughter());
1420 pdg = tmp->GetPdgCode();
1424 TParticle *jet2 =
new TParticle(*tmp);
1425 jet2->SetFirstMother(7);
1428 AliDebug(2,Form(
"HERWIG Jet 2: mother %d, status %d, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f",
1429 jet2->GetFirstMother(),jet2->GetStatusCode(),jet2->Pt(),jet2->Energy(),jet2->Phi()*TMath::RadToDeg(),jet2->Eta()));
1452 Int_t &
pdg, Int_t & status,
1453 Bool_t & ok, Int_t & daughlabel, TVector3 & prodVertex)
1461 AliWarning(
"Stack is not available, check analysis settings in configuration file!!");
1467 Int_t nprimaries = reader->
GetStack()->GetNtrack();
1468 if(label >= 0 && label < nprimaries)
1470 TParticle * momP = reader->
GetStack()->Particle(label);
1471 daughlabel = momP->GetDaughter(idaugh);
1473 if(daughlabel < 0 || daughlabel >= nprimaries)
1479 TParticle * daughP = reader->
GetStack()->Particle(daughlabel);
1481 pdg = daughP->GetPdgCode();
1482 status = daughP->GetStatusCode();
1483 prodVertex.SetXYZ(daughP->Vx(),daughP->Vy(),daughP->Vz());
1496 AliWarning(
"AODMCParticles is not available, check analysis settings in configuration file!!");
1502 Int_t nprimaries = mcparticles->GetEntriesFast();
1503 if(label >= 0 && label < nprimaries)
1505 AliAODMCParticle * momP = (AliAODMCParticle *) mcparticles->At(label);
1506 daughlabel = momP->GetDaughter(idaugh);
1508 if(daughlabel < 0 || daughlabel >= nprimaries)
1514 AliAODMCParticle * daughP = (AliAODMCParticle *) mcparticles->At(daughlabel);
1515 fDaughMom.SetPxPyPzE(daughP->Px(),daughP->Py(),daughP->Pz(),daughP->E());
1516 pdg = daughP->GetPdgCode();
1517 status = daughP->GetStatus();
1518 prodVertex.SetXYZ(daughP->Xv(),daughP->Yv(),daughP->Zv());
1537 Int_t
pdg = -1; Int_t status = -1; Int_t momlabel = -1;
1539 return GetMother(label,reader,pdg,status, ok,momlabel);
1546 Int_t &
pdg, Int_t & status, Bool_t & ok)
1548 Int_t momlabel = -1;
1550 return GetMother(label,reader,pdg,status, ok,momlabel);
1557 Int_t &
pdg, Int_t & status, Bool_t & ok, Int_t & momlabel)
1565 AliWarning(
"Stack is not available, check analysis settings in configuration file, STOP!!");
1570 if(label >= 0 && label < reader->GetStack()->GetNtrack())
1572 TParticle * momP = reader->
GetStack()->Particle(label);
1574 pdg = momP->GetPdgCode();
1575 status = momP->GetStatusCode();
1576 momlabel = momP->GetFirstMother();
1589 AliWarning(
"AODMCParticles is not available, check analysis settings in configuration file!!");
1595 Int_t nprimaries = mcparticles->GetEntriesFast();
1596 if(label >= 0 && label < nprimaries)
1598 AliAODMCParticle * momP = (AliAODMCParticle *) mcparticles->At(label);
1599 fMotherMom.SetPxPyPzE(momP->Px(),momP->Py(),momP->Pz(),momP->E());
1600 pdg = momP->GetPdgCode();
1601 status = momP->GetStatus();
1602 momlabel = momP->GetMother();
1621 Bool_t & ok, Int_t & momlabel)
1629 AliWarning(
"Stack is not available, check analysis settings in configuration file!!");
1635 if(label >= 0 && label < reader->GetStack()->GetNtrack())
1637 TParticle * momP = reader->
GetStack()->Particle(label);
1639 if(momP->GetPdgCode()==
pdg)
1641 AliDebug(2,
"PDG of mother is already the one requested!");
1642 fGMotherMom.SetPxPyPzE(momP->Px(),momP->Py(),momP->Pz(),momP->Energy());
1647 Int_t grandmomLabel = momP->GetFirstMother();
1648 Int_t grandmomPDG = -1;
1649 TParticle * grandmomP = 0x0;
1650 while (grandmomLabel >=0 )
1652 grandmomP = reader->
GetStack()->Particle(grandmomLabel);
1653 grandmomPDG = grandmomP->GetPdgCode();
1654 if(grandmomPDG==pdg)
1656 momlabel = grandmomLabel;
1657 fGMotherMom.SetPxPyPzE(grandmomP->Px(),grandmomP->Py(),grandmomP->Pz(),grandmomP->Energy());
1661 grandmomLabel = grandmomP->GetFirstMother();
1665 if(grandmomPDG!=pdg) AliInfo(Form(
"Mother with PDG %d, NOT found! \n",pdg));
1673 AliWarning(
"AODMCParticles is not available, check analysis settings in configuration file!!");
1679 Int_t nprimaries = mcparticles->GetEntriesFast();
1680 if(label >= 0 && label < nprimaries)
1682 AliAODMCParticle * momP = (AliAODMCParticle *) mcparticles->At(label);
1684 if(momP->GetPdgCode()==
pdg)
1686 AliDebug(2,
"PDG of mother is already the one requested!");
1687 fGMotherMom.SetPxPyPzE(momP->Px(),momP->Py(),momP->Pz(),momP->E());
1692 Int_t grandmomLabel = momP->GetMother();
1693 Int_t grandmomPDG = -1;
1694 AliAODMCParticle * grandmomP = 0x0;
1695 while (grandmomLabel >=0 )
1697 grandmomP = (AliAODMCParticle *) mcparticles->At(grandmomLabel);
1698 grandmomPDG = grandmomP->GetPdgCode();
1699 if(grandmomPDG==pdg)
1702 momlabel = grandmomLabel;
1703 fGMotherMom.SetPxPyPzE(grandmomP->Px(),grandmomP->Py(),grandmomP->Pz(),grandmomP->E());
1707 grandmomLabel = grandmomP->GetMother();
1711 if(grandmomPDG!=pdg) AliInfo(Form(
"Mother with PDG %d, NOT found!",pdg));
1725 Int_t &
pdg, Int_t & status, Bool_t & ok,
1726 Int_t & grandMomLabel, Int_t & greatMomLabel)
1734 AliWarning(
"Stack is not available, check analysis settings in configuration file, STOP!!");
1740 if(label >= 0 && label < reader->GetStack()->GetNtrack())
1742 TParticle * momP = reader->
GetStack()->Particle(label);
1744 grandMomLabel = momP->GetFirstMother();
1746 TParticle * grandmomP = 0x0;
1748 if (grandMomLabel >=0 )
1750 grandmomP = reader->
GetStack()->Particle(grandMomLabel);
1751 pdg = grandmomP->GetPdgCode();
1752 status = grandmomP->GetStatusCode();
1754 fGMotherMom.SetPxPyPzE(grandmomP->Px(),grandmomP->Py(),grandmomP->Pz(),grandmomP->Energy());
1755 greatMomLabel = grandmomP->GetFirstMother();
1765 AliWarning(
"AODMCParticles is not available, check analysis settings in configuration file!!");
1771 Int_t nprimaries = mcparticles->GetEntriesFast();
1772 if(label >= 0 && label < nprimaries)
1774 AliAODMCParticle * momP = (AliAODMCParticle *) mcparticles->At(label);
1776 grandMomLabel = momP->GetMother();
1778 AliAODMCParticle * grandmomP = 0x0;
1780 if(grandMomLabel >=0 )
1782 grandmomP = (AliAODMCParticle *) mcparticles->At(grandMomLabel);
1783 pdg = grandmomP->GetPdgCode();
1784 status = grandmomP->GetStatus();
1786 fGMotherMom.SetPxPyPzE(grandmomP->Px(),grandmomP->Py(),grandmomP->Pz(),grandmomP->E());
1787 greatMomLabel = grandmomP->GetMother();
1802 Float_t & asym, Float_t & angle, Bool_t & ok)
1808 AliWarning(
"Stack is not available, check analysis settings in configuration file, STOP!!");
1812 if(label >= 0 && label < reader->GetStack()->GetNtrack())
1814 TParticle * momP = reader->
GetStack()->Particle(label);
1816 Int_t grandmomLabel = momP->GetFirstMother();
1817 Int_t grandmomPDG = -1;
1818 TParticle * grandmomP = 0x0;
1819 while (grandmomLabel >=0 )
1821 grandmomP = reader->
GetStack()->Particle(grandmomLabel);
1822 grandmomPDG = grandmomP->GetPdgCode();
1824 if(grandmomPDG==pdg)
break;
1826 grandmomLabel = grandmomP->GetFirstMother();
1830 if(grandmomPDG==pdg && grandmomP->GetNDaughters()==2)
1832 TParticle * d1 = reader->
GetStack()->Particle(grandmomP->GetDaughter(0));
1833 TParticle * d2 = reader->
GetStack()->Particle(grandmomP->GetDaughter(1));
1834 if(d1->GetPdgCode() == 22 && d1->GetPdgCode() == 22)
1836 asym = (d1->Energy()-d2->Energy())/grandmomP->Energy();
1845 AliInfo(Form(
"Mother with PDG %d, not found!",pdg));
1855 AliWarning(
"AODMCParticles is not available, check analysis settings in configuration file!!");
1861 Int_t nprimaries = mcparticles->GetEntriesFast();
1862 if(label >= 0 && label < nprimaries)
1864 AliAODMCParticle * momP = (AliAODMCParticle *) mcparticles->At(label);
1866 Int_t grandmomLabel = momP->GetMother();
1867 Int_t grandmomPDG = -1;
1868 AliAODMCParticle * grandmomP = 0x0;
1869 while (grandmomLabel >=0 )
1871 grandmomP = (AliAODMCParticle *) mcparticles->At(grandmomLabel);
1872 grandmomPDG = grandmomP->GetPdgCode();
1874 if(grandmomPDG==pdg)
break;
1876 grandmomLabel = grandmomP->GetMother();
1880 if(grandmomPDG==pdg && grandmomP->GetNDaughters()==2)
1882 AliAODMCParticle * d1 = (AliAODMCParticle *) mcparticles->At(grandmomP->GetDaughter(0));
1883 AliAODMCParticle * d2 = (AliAODMCParticle *) mcparticles->At(grandmomP->GetDaughter(1));
1884 if(d1->GetPdgCode() == 22 && d1->GetPdgCode() == 22)
1886 asym = (d1->E()-d2->E())/grandmomP->E();
1887 fDaughMom .SetPxPyPzE(d1->Px(),d1->Py(),d1->Pz(),d1->E());
1888 fDaughMom2.SetPxPyPzE(d2->Px(),d2->Py(),d2->Pz(),d2->E());
1895 AliInfo(Form(
"Mother with PDG %d, not found! \n",pdg));
1914 AliWarning(
"Stack is not available, check analysis settings in configuration file, STOP!!");
1919 if(label >= 0 && label < reader->GetStack()->GetNtrack())
1921 TParticle * momP = reader->
GetStack()->Particle(label);
1923 return momP->GetNDaughters();
1936 AliWarning(
"AODMCParticles is not available, check analysis settings in configuration file!!");
1942 Int_t nprimaries = mcparticles->GetEntriesFast();
1943 if(label >= 0 && label < nprimaries)
1945 AliAODMCParticle * momP = (AliAODMCParticle *) mcparticles->At(label);
1947 return momP->GetNDaughters();
1968 Int_t mctag, Int_t mesonLabel,
1971 Int_t ancPDG = 0, ancStatus = -1;
1972 TVector3 prodVertex;
1974 Int_t noverlaps = 0;
1977 for (UInt_t ilab = 1; ilab < nlabels; ilab++ )
1984 Bool_t overlap = kFALSE;
1996 else if( ancPDG!=22 && TMath::Abs(ancPDG)!=11 && ancPDG != 111 && ancPDG != 221 )
2002 if( !overlap ) continue ;
2011 Bool_t mOK = 0, gOK = 0;
2012 Int_t mpdg = -999999, gpdg = -1;
2013 Int_t mstatus = -1, gstatus = -1;
2014 Int_t gLabel = -1, ggLabel = -1;
2016 GetMother (label[ilab],reader,mpdg,mstatus,mOK);
2018 GetGrandMother(label[ilab],reader,gpdg,gstatus,gOK, gLabel,ggLabel);
2022 if( ( mpdg == 22 || TMath::Abs(mpdg==11) ) &&
2023 ( gpdg == 22 || TMath::Abs(gpdg==11) ) &&
2026 Int_t labeltmp = gLabel;
2027 while( ( gpdg == 22 || TMath::Abs(gpdg==11) ) && gLabel >=0 )
2034 overpdg[noverlaps-1] = mpdg;
2048 printf(
"***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
2050 printf(
"Debug level = %d\n",
fDebug);
2060 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)
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
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)
virtual AliStack * GetStack() const
TString fMCGeneratorString
MC generator used to generate data in simulation.
Int_t GetNOverlaps(const Int_t *label, UInt_t nlabels, Int_t mctag, Int_t mesonLabel, AliCaloTrackReader *reader, Int_t *overpdg)
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