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);
1136 AliInfo(Form(
"MC Mother not available for label %d",label));
1140 Int_t momPDG = TMath::Abs(mother->GetPdgCode());
1141 if ( momPDG!=11 && momPDG!=22 )
continue;
1144 Int_t iParentClus = mother->GetFirstMother();
1145 if ( iParentClus < 0 )
continue;
1147 TParticle * parentClus = stack->Particle(iParentClus);
1148 if ( !parentClus )
continue;
1150 Int_t parentClusPDG = TMath::Abs(parentClus->GetPdgCode());
1151 Int_t parentClusStatus = parentClus->GetStatusCode();
1153 if( parentClusPDG != 22 && parentClusPDG != 11 && parentClusStatus != 0 )
continue;
1158 while ( (parentClusPDG == 22 || parentClusPDG == 11) && parentClusStatus != 1 )
1161 label = iParentClus;
1162 momPDG = parentClusPDG;
1164 iParentClus = parentClus->GetFirstMother();
1165 if(iParentClus < 0)
break;
1167 parentClus = stack->Particle(iParentClus);
1168 if(!parentClus)
break;
1170 parentClusPDG = TMath::Abs(parentClus->GetPdgCode());
1171 parentClusStatus = parentClus->GetStatusCode() ;
1174 if ( (momPDG == 22 || parentClusPDG ==22) && (label==pairLabel || iParentClus == pairLabel) )
1193 const TClonesArray* mcparticles, Int_t & tag)
1195 if(!arrayCluster || iMom < 0 || iParent < 0|| !mcparticles)
return;
1197 AliAODMCParticle * parent = (AliAODMCParticle*) mcparticles->At(iParent);
1201 if(parent->GetNDaughters()!=2)
1208 Int_t pairLabel = -1;
1209 if ( iMom != parent->GetDaughter(0) ) pairLabel = parent->GetDaughter(0);
1210 else if( iMom != parent->GetDaughter(1) ) pairLabel = parent->GetDaughter(1);
1221 for(Int_t iclus = 0; iclus < arrayCluster->GetEntriesFast(); iclus++)
1223 AliVCluster * cluster = (AliVCluster*) arrayCluster->At(iclus);
1225 for(UInt_t ilab = 0; ilab< cluster->GetNLabels(); ilab++)
1227 Int_t label = cluster->GetLabels()[ilab];
1231 if ( label==pairLabel )
1237 else if ( label== iParent || label== iMom )
1244 AliAODMCParticle * mother = (AliAODMCParticle*) mcparticles->At(label);
1248 AliInfo(Form(
"MC Mother not available for label %d",label));
1252 Int_t momPDG = TMath::Abs(mother->GetPdgCode());
1253 if ( momPDG!=11 && momPDG!=22 )
continue;
1256 Int_t iParentClus = mother->GetMother();
1257 if(iParentClus < 0)
continue;
1259 AliAODMCParticle * parentClus = (AliAODMCParticle*) mcparticles->At(iParentClus);
1260 if(!parentClus)
continue;
1262 Int_t parentClusPDG = TMath::Abs(parentClus->GetPdgCode());
1263 Int_t parentClusStatus = parentClus->GetStatus();
1265 if ( parentClusPDG != 22 && parentClusPDG != 11 && parentClusStatus != 0 )
1274 while ((parentClusPDG == 22 || parentClusPDG == 11) && parentClusStatus != 1)
1277 label = iParentClus;
1278 momPDG = parentClusPDG;
1280 iParentClus = parentClus->GetMother();
1281 if ( iParentClus < 0 )
break;
1283 parentClus = (AliAODMCParticle*) mcparticles->At(iParentClus);
1284 if ( !parentClus )
break;
1286 parentClusPDG = TMath::Abs(parentClus->GetPdgCode());
1287 parentClusStatus = parentClus->GetStatus() ;
1290 if ( (momPDG == 22 || parentClusPDG ==22) && (label==pairLabel || iParentClus == pairLabel) )
1314 AliStack * stack = reader->
GetStack();
1320 Int_t nTriggerJets = 0;
1321 Float_t tmpjet[]={0,0,0,0};
1325 if(stack->GetNtrack() < 8)
return fJetsList;
1326 TParticle * parton1 = stack->Particle(6);
1327 TParticle * parton2 = stack->Particle(7);
1329 AliDebug(2,Form(
"Parton 6 : %s, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f",
1330 parton1->GetName(),parton1->Pt(),parton1->Energy(),parton1->Phi()*TMath::RadToDeg(),parton1->Eta()));
1331 AliDebug(2,Form(
"Parton 7 : %s, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f",
1332 parton2->GetName(),parton2->Pt(),parton2->Energy(),parton2->Phi()*TMath::RadToDeg(),parton2->Eta()));
1375 TParticle * jet = 0x0;
1376 AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) geh;
1377 nTriggerJets = pygeh->NTriggerJets();
1378 AliDebug(2,Form(
"PythiaEventHeader: Njets: %d",nTriggerJets));
1380 for(Int_t i = 0; i< nTriggerJets; i++)
1382 pygeh->TriggerJet(i, tmpjet);
1383 jet =
new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
1385 Float_t phidiff1 = TMath::Abs(jet->Phi()-parton1->Phi());
1386 Float_t phidiff2 = TMath::Abs(jet->Phi()-parton2->Phi());
1387 if(phidiff1 > phidiff2) jet->SetFirstMother(7);
1388 else jet->SetFirstMother(6);
1390 AliDebug(1,Form(
"PYTHIA Jet %d: mother %d, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f",
1391 i, jet->GetFirstMother(),jet->Pt(),jet->Energy(),jet->Phi()*TMath::RadToDeg(),jet->Eta()));
1400 TParticle * tmp = parton1;
1401 if(parton1->GetPdgCode()!=22)
1404 if(tmp->GetFirstDaughter()==-1)
return fJetsList;
1405 tmp = stack->Particle(tmp->GetFirstDaughter());
1406 pdg = tmp->GetPdgCode();
1410 TParticle *jet1 =
new TParticle(*tmp);
1411 jet1->SetFirstMother(6);
1417 AliDebug(1,Form(
"HERWIG Jet 1: mother %d, status %d, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f",
1418 jet1->GetFirstMother(),jet1->GetStatusCode(),jet1->Pt(),jet1->Energy(),jet1->Phi()*TMath::RadToDeg(),jet1->Eta()));
1424 if(parton2->GetPdgCode()!=22)
1428 if(tmp->GetFirstDaughter()==-1)
return fJetsList;
1429 tmp = stack->Particle(tmp->GetFirstDaughter());
1430 pdg = tmp->GetPdgCode();
1434 TParticle *jet2 =
new TParticle(*tmp);
1435 jet2->SetFirstMother(7);
1438 AliDebug(2,Form(
"HERWIG Jet 2: mother %d, status %d, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f",
1439 jet2->GetFirstMother(),jet2->GetStatusCode(),jet2->Pt(),jet2->Energy(),jet2->Phi()*TMath::RadToDeg(),jet2->Eta()));
1462 Int_t &
pdg, Int_t & status,
1463 Bool_t & ok, Int_t & daughlabel, TVector3 & prodVertex)
1471 AliWarning(
"Stack is not available, check analysis settings in configuration file!!");
1477 Int_t nprimaries = reader->
GetStack()->GetNtrack();
1478 if(label >= 0 && label < nprimaries)
1480 TParticle * momP = reader->
GetStack()->Particle(label);
1481 daughlabel = momP->GetDaughter(idaugh);
1483 if(daughlabel < 0 || daughlabel >= nprimaries)
1489 TParticle * daughP = reader->
GetStack()->Particle(daughlabel);
1491 pdg = daughP->GetPdgCode();
1492 status = daughP->GetStatusCode();
1493 prodVertex.SetXYZ(daughP->Vx(),daughP->Vy(),daughP->Vz());
1506 AliWarning(
"AODMCParticles is not available, check analysis settings in configuration file!!");
1512 Int_t nprimaries = mcparticles->GetEntriesFast();
1513 if(label >= 0 && label < nprimaries)
1515 AliAODMCParticle * momP = (AliAODMCParticle *) mcparticles->At(label);
1516 daughlabel = momP->GetDaughter(idaugh);
1518 if(daughlabel < 0 || daughlabel >= nprimaries)
1524 AliAODMCParticle * daughP = (AliAODMCParticle *) mcparticles->At(daughlabel);
1525 fDaughMom.SetPxPyPzE(daughP->Px(),daughP->Py(),daughP->Pz(),daughP->E());
1526 pdg = daughP->GetPdgCode();
1527 status = daughP->GetStatus();
1528 prodVertex.SetXYZ(daughP->Xv(),daughP->Yv(),daughP->Zv());
1547 Int_t
pdg = -1; Int_t status = -1; Int_t momlabel = -1;
1549 return GetMother(label,reader,pdg,status, ok,momlabel);
1556 Int_t &
pdg, Int_t & status, Bool_t & ok)
1558 Int_t momlabel = -1;
1560 return GetMother(label,reader,pdg,status, ok,momlabel);
1567 Int_t &
pdg, Int_t & status, Bool_t & ok, Int_t & momlabel)
1575 AliWarning(
"Stack is not available, check analysis settings in configuration file, STOP!!");
1580 if(label >= 0 && label < reader->GetStack()->GetNtrack())
1582 TParticle * momP = reader->
GetStack()->Particle(label);
1584 pdg = momP->GetPdgCode();
1585 status = momP->GetStatusCode();
1586 momlabel = momP->GetFirstMother();
1599 AliWarning(
"AODMCParticles is not available, check analysis settings in configuration file!!");
1605 Int_t nprimaries = mcparticles->GetEntriesFast();
1606 if(label >= 0 && label < nprimaries)
1608 AliAODMCParticle * momP = (AliAODMCParticle *) mcparticles->At(label);
1609 fMotherMom.SetPxPyPzE(momP->Px(),momP->Py(),momP->Pz(),momP->E());
1610 pdg = momP->GetPdgCode();
1611 status = momP->GetStatus();
1612 momlabel = momP->GetMother();
1631 Bool_t & ok, Int_t & momlabel)
1639 AliWarning(
"Stack is not available, check analysis settings in configuration file!!");
1645 if(label >= 0 && label < reader->GetStack()->GetNtrack())
1647 TParticle * momP = reader->
GetStack()->Particle(label);
1649 if(momP->GetPdgCode()==
pdg)
1651 AliDebug(2,
"PDG of mother is already the one requested!");
1652 fGMotherMom.SetPxPyPzE(momP->Px(),momP->Py(),momP->Pz(),momP->Energy());
1657 Int_t grandmomLabel = momP->GetFirstMother();
1658 Int_t grandmomPDG = -1;
1659 TParticle * grandmomP = 0x0;
1660 while (grandmomLabel >=0 )
1662 grandmomP = reader->
GetStack()->Particle(grandmomLabel);
1663 grandmomPDG = grandmomP->GetPdgCode();
1664 if(grandmomPDG==pdg)
1666 momlabel = grandmomLabel;
1667 fGMotherMom.SetPxPyPzE(grandmomP->Px(),grandmomP->Py(),grandmomP->Pz(),grandmomP->Energy());
1671 grandmomLabel = grandmomP->GetFirstMother();
1675 if(grandmomPDG!=pdg) AliInfo(Form(
"Mother with PDG %d, NOT found! \n",pdg));
1683 AliWarning(
"AODMCParticles is not available, check analysis settings in configuration file!!");
1689 Int_t nprimaries = mcparticles->GetEntriesFast();
1690 if(label >= 0 && label < nprimaries)
1692 AliAODMCParticle * momP = (AliAODMCParticle *) mcparticles->At(label);
1694 if(momP->GetPdgCode()==
pdg)
1696 AliDebug(2,
"PDG of mother is already the one requested!");
1697 fGMotherMom.SetPxPyPzE(momP->Px(),momP->Py(),momP->Pz(),momP->E());
1702 Int_t grandmomLabel = momP->GetMother();
1703 Int_t grandmomPDG = -1;
1704 AliAODMCParticle * grandmomP = 0x0;
1705 while (grandmomLabel >=0 )
1707 grandmomP = (AliAODMCParticle *) mcparticles->At(grandmomLabel);
1708 grandmomPDG = grandmomP->GetPdgCode();
1709 if(grandmomPDG==pdg)
1712 momlabel = grandmomLabel;
1713 fGMotherMom.SetPxPyPzE(grandmomP->Px(),grandmomP->Py(),grandmomP->Pz(),grandmomP->E());
1717 grandmomLabel = grandmomP->GetMother();
1721 if(grandmomPDG!=pdg) AliInfo(Form(
"Mother with PDG %d, NOT found!",pdg));
1735 Int_t &
pdg, Int_t & status, Bool_t & ok,
1736 Int_t & grandMomLabel, Int_t & greatMomLabel)
1744 AliWarning(
"Stack is not available, check analysis settings in configuration file, STOP!!");
1750 if(label >= 0 && label < reader->GetStack()->GetNtrack())
1752 TParticle * momP = reader->
GetStack()->Particle(label);
1754 grandMomLabel = momP->GetFirstMother();
1756 TParticle * grandmomP = 0x0;
1758 if (grandMomLabel >=0 )
1760 grandmomP = reader->
GetStack()->Particle(grandMomLabel);
1761 pdg = grandmomP->GetPdgCode();
1762 status = grandmomP->GetStatusCode();
1764 fGMotherMom.SetPxPyPzE(grandmomP->Px(),grandmomP->Py(),grandmomP->Pz(),grandmomP->Energy());
1765 greatMomLabel = grandmomP->GetFirstMother();
1775 AliWarning(
"AODMCParticles is not available, check analysis settings in configuration file!!");
1781 Int_t nprimaries = mcparticles->GetEntriesFast();
1782 if(label >= 0 && label < nprimaries)
1784 AliAODMCParticle * momP = (AliAODMCParticle *) mcparticles->At(label);
1786 grandMomLabel = momP->GetMother();
1788 AliAODMCParticle * grandmomP = 0x0;
1790 if(grandMomLabel >=0 )
1792 grandmomP = (AliAODMCParticle *) mcparticles->At(grandMomLabel);
1793 pdg = grandmomP->GetPdgCode();
1794 status = grandmomP->GetStatus();
1796 fGMotherMom.SetPxPyPzE(grandmomP->Px(),grandmomP->Py(),grandmomP->Pz(),grandmomP->E());
1797 greatMomLabel = grandmomP->GetMother();
1812 Float_t & asym, Float_t & angle, Bool_t & ok)
1818 AliWarning(
"Stack is not available, check analysis settings in configuration file, STOP!!");
1822 if(label >= 0 && label < reader->GetStack()->GetNtrack())
1824 TParticle * momP = reader->
GetStack()->Particle(label);
1826 Int_t grandmomLabel = momP->GetFirstMother();
1827 Int_t grandmomPDG = -1;
1828 TParticle * grandmomP = 0x0;
1829 while (grandmomLabel >=0 )
1831 grandmomP = reader->
GetStack()->Particle(grandmomLabel);
1832 grandmomPDG = grandmomP->GetPdgCode();
1834 if(grandmomPDG==pdg)
break;
1836 grandmomLabel = grandmomP->GetFirstMother();
1840 if(grandmomPDG==pdg && grandmomP->GetNDaughters()==2)
1842 TParticle * d1 = reader->
GetStack()->Particle(grandmomP->GetDaughter(0));
1843 TParticle * d2 = reader->
GetStack()->Particle(grandmomP->GetDaughter(1));
1844 if(d1->GetPdgCode() == 22 && d1->GetPdgCode() == 22)
1846 asym = (d1->Energy()-d2->Energy())/grandmomP->Energy();
1855 AliInfo(Form(
"Mother with PDG %d, not found!",pdg));
1865 AliWarning(
"AODMCParticles is not available, check analysis settings in configuration file!!");
1871 Int_t nprimaries = mcparticles->GetEntriesFast();
1872 if(label >= 0 && label < nprimaries)
1874 AliAODMCParticle * momP = (AliAODMCParticle *) mcparticles->At(label);
1876 Int_t grandmomLabel = momP->GetMother();
1877 Int_t grandmomPDG = -1;
1878 AliAODMCParticle * grandmomP = 0x0;
1879 while (grandmomLabel >=0 )
1881 grandmomP = (AliAODMCParticle *) mcparticles->At(grandmomLabel);
1882 grandmomPDG = grandmomP->GetPdgCode();
1884 if(grandmomPDG==pdg)
break;
1886 grandmomLabel = grandmomP->GetMother();
1890 if(grandmomPDG==pdg && grandmomP->GetNDaughters()==2)
1892 AliAODMCParticle * d1 = (AliAODMCParticle *) mcparticles->At(grandmomP->GetDaughter(0));
1893 AliAODMCParticle * d2 = (AliAODMCParticle *) mcparticles->At(grandmomP->GetDaughter(1));
1894 if(d1->GetPdgCode() == 22 && d1->GetPdgCode() == 22)
1896 asym = (d1->E()-d2->E())/grandmomP->E();
1897 fDaughMom .SetPxPyPzE(d1->Px(),d1->Py(),d1->Pz(),d1->E());
1898 fDaughMom2.SetPxPyPzE(d2->Px(),d2->Py(),d2->Pz(),d2->E());
1905 AliInfo(Form(
"Mother with PDG %d, not found! \n",pdg));
1924 AliWarning(
"Stack is not available, check analysis settings in configuration file, STOP!!");
1929 if(label >= 0 && label < reader->GetStack()->GetNtrack())
1931 TParticle * momP = reader->
GetStack()->Particle(label);
1933 return momP->GetNDaughters();
1946 AliWarning(
"AODMCParticles is not available, check analysis settings in configuration file!!");
1952 Int_t nprimaries = mcparticles->GetEntriesFast();
1953 if(label >= 0 && label < nprimaries)
1955 AliAODMCParticle * momP = (AliAODMCParticle *) mcparticles->At(label);
1957 return momP->GetNDaughters();
1978 Int_t mctag, Int_t mesonLabel,
1981 Int_t ancPDG = 0, ancStatus = -1;
1982 TVector3 prodVertex;
1984 Int_t noverlaps = 0;
1987 for (UInt_t ilab = 1; ilab < nlabels; ilab++ )
1994 Bool_t overlap = kFALSE;
2006 else if( ancPDG!=22 && TMath::Abs(ancPDG)!=11 && ancPDG != 111 && ancPDG != 221 )
2012 if( !overlap ) continue ;
2021 Bool_t mOK = 0, gOK = 0;
2022 Int_t mpdg = -999999, gpdg = -1;
2023 Int_t mstatus = -1, gstatus = -1;
2024 Int_t gLabel = -1, ggLabel = -1;
2026 GetMother (label[ilab],reader,mpdg,mstatus,mOK);
2028 GetGrandMother(label[ilab],reader,gpdg,gstatus,gOK, gLabel,ggLabel);
2032 if( ( mpdg == 22 || TMath::Abs(mpdg==11) ) &&
2033 ( gpdg == 22 || TMath::Abs(gpdg==11) ) &&
2036 Int_t labeltmp = gLabel;
2037 while( ( gpdg == 22 || TMath::Abs(gpdg==11) ) && gLabel >=0 )
2044 overpdg[noverlaps-1] = mpdg;
2058 printf(
"***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
2060 printf(
"Debug level = %d\n",
fDebug);
2070 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)
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)
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
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