27 #include <TParticle.h> 28 #include <TClonesArray.h> 56 fTrackReferences(new TClonesArray(
"AliTrackReference", 1000)),
118 tree->SetBranchAddress(
"Header", &
fHeader);
156 AliDebug(1, Form(
"AliMCEvent# %5d %5d: Number of particles: %5d (all) %5d (primaries)\n",
175 if (
fTreeTR->GetBranch(
"AliRun")) {
204 AliWarning(Form(
"AliMCEventHandler::GetEntry: Index out of range"));
220 return trefs->GetEntries();
274 AliWarning(
"No Track Reference information available");
281 AliWarning(
"AliMCEvent::GetEntry: Index out of range");
293 printf(
"Found Hits at %5d\n", i);
296 if (!particle)
return;
297 TH2F* h =
new TH2F(
"",
"", 100, -500, 500, 100, -500, 500);
298 Float_t x0 = particle->Vx();
299 Float_t y0 = particle->Vy();
301 Float_t x1 = particle->Vx() + particle->Px() * 50.;
302 Float_t y1 = particle->Vy() + particle->Py() * 50.;
304 TArrow* a =
new TArrow(x0, y0, x1, y1, 0.01);
310 for (Int_t ih = 0; ih < nh; ih++) {
312 TMarker* m =
new TMarker(ref->
X(), ref->
Y(), 20);
314 m->SetMarkerSize(0.4);
328 fTmpFileTR =
new TFile(
"TrackRefsTmp.root",
"recreate");
329 fTmpTreeTR =
new TTree(
"TreeTR",
"TrackReferences");
337 fTreeTR->SetBranchStatus(
"*", 0);
338 fTreeTR->SetBranchStatus(
"AliRun.*", 1);
339 fTreeTR->SetBranchStatus(
"ITS.*", 1);
340 fTreeTR->SetBranchStatus(
"TPC.*", 1);
341 fTreeTR->SetBranchStatus(
"TRD.*", 1);
342 fTreeTR->SetBranchStatus(
"TOF.*", 1);
343 fTreeTR->SetBranchStatus(
"FRAME.*", 1);
344 fTreeTR->SetBranchStatus(
"MUON.*", 1);
349 TClonesArray* trefs[7];
350 for (Int_t i = 0; i < 7; i++) trefs[i] = 0;
353 if (
fTreeTR->GetBranch(
"AliRun"))
fTreeTR->SetBranchAddress(
"AliRun", &trefs[0]);
354 if (
fTreeTR->GetBranch(
"ITS"))
fTreeTR->SetBranchAddress(
"ITS", &trefs[1]);
355 if (
fTreeTR->GetBranch(
"TPC"))
fTreeTR->SetBranchAddress(
"TPC", &trefs[2]);
356 if (
fTreeTR->GetBranch(
"TRD"))
fTreeTR->SetBranchAddress(
"TRD", &trefs[3]);
357 if (
fTreeTR->GetBranch(
"TOF"))
fTreeTR->SetBranchAddress(
"TOF", &trefs[4]);
358 if (
fTreeTR->GetBranch(
"FRAME"))
fTreeTR->SetBranchAddress(
"FRAME", &trefs[5]);
359 if (
fTreeTR->GetBranch(
"MUON"))
fTreeTR->SetBranchAddress(
"MUON", &trefs[6]);
372 for (Int_t ip = np - 1; ip > -1; ip--) {
379 Int_t dau1 = part->GetFirstDaughter();
380 if (dau1 < np)
continue;
383 Int_t inext = ip - 1;
387 dau2 = part->GetFirstDaughter();
388 if (dau2 == -1 || dau2 < np) {
407 Bool_t hasHits = kFALSE;
408 Bool_t isOutside = kFALSE;
411 while (!hasHits && !isOutside && it < nt) {
413 for (Int_t ib = 0; ib < 7; ib++) {
414 if (!trefs[ib])
continue;
415 Int_t nh = trefs[ib]->GetEntries();
416 for (Int_t ih = 0; ih < nh; ih++) {
418 Int_t label = tr->
Label();
419 if (label >= dau1 && label <= dau2) {
424 if (label > dau2 || label < ip) {
430 if (hasHits || isOutside)
break;
436 for (Int_t
id = dau1; (
id <= dau2);
id++) {
443 for (Int_t
id = dau1; (id <= dau2) && (dau1 > -1);
id++) {
444 for (Int_t ib = 0; ib < 7; ib++) {
445 if (!trefs[ib])
continue;
446 Int_t nh = trefs[ib]->GetEntries();
447 for (Int_t ih = 0; ih < nh; ih++) {
449 Int_t label = tr->
Label();
451 if (label == ip)
continue;
452 if (label > dau2 || label < dau1)
453 printf(
"AliMCEventHandler::Track Reference Label out of range !: %5d %5d %5d %5d \n",
454 itlast, label, dau1, dau2);
458 Int_t nref =
fTRBuffer->GetEntriesFast();
475 for (Int_t ip = 0; ip < np; ip++) {
477 while (labmax < ip && it > -1) {
479 for (Int_t ib = 0; ib < 7; ib++) {
480 if (!trefs[ib])
continue;
481 Int_t nh = trefs[ib]->GetEntries();
484 for (Int_t ih = 0; ih < nh; ih++) {
486 Int_t label = tr->
Label();
487 if (label < np && label > labmax) {
493 Int_t nref =
fTRBuffer->GetEntriesFast();
511 for (Int_t ib = 0; ib < 7; ib++) {
520 printf(
"AliMCEvent:Number of entries in TreeTR (%5d) unequal to TreeK (%5d) \n",
564 TParticle *particle = 0;
565 TClonesArray *trefs = 0;
572 AliWarning(Form(
"AliMCEvent::GetEntry: Index out of range"));
593 ntref = trefs->GetEntriesFast();
596 for (Int_t j = 0; j < ntref; j++) {
608 mcParticle =
new ((*fMCParticles)[nentries])
AliMCParticle(particle, rarray, i);
611 TParticle* part = mcParticle->
Particle();
612 Int_t imo = part->GetFirstMother();
613 Int_t id1 = part->GetFirstDaughter();
614 Int_t id2 = part->GetLastDaughter();
688 TList* events =
new TList();
689 events->SetOwner(kFALSE);
696 event->SetTopEvent(
this);
715 AliWarning(Form(
"Not a primary -- returning 0 (idx %d, nPrimary %d)",ipart,header->
NProduced()));
721 TIter headIt(headerList);
725 if (header) nproduced += header->
NProduced();
726 }
while (header && ipart >= nproduced);
746 if (oldidx < (event->
GetPrimaryOffset() +
event->GetNumberOfPrimaries()))
break;
755 if (oldidx < (event->
GetSecondaryOffset() + (
event->GetNumberOfTracks() -
event->GetNumberOfPrimaries())))
break;
902 if (!coHeader)
return (0);
905 if (!hijingH)
return (0);
909 return (index <
fNBG);
937 TString retv =
"suppressed";
942 if(!lh){ TString noheader=
"nococktailheader";
944 Int_t nh=lh->GetEntries();
945 for (Int_t i = nh-1; i >= 0; i--){
947 TString genname=gh->GetName();
949 if (i == 0) npart = nsumpart;
950 if(index < nsumpart && index >= (nsumpart-npart))
return genname;
969 Int_t nh = list->GetEntries();
971 for(Int_t i = nh-1; i >= 0; i--){
975 if (npart != nsumpart) {
982 for (Int_t j = nsumpart-1; j >= nsumpart-npart; j--) {
985 AliWarning(Form(
"AliMCEvent::AssignGeneratorIndex: 0-pointer to particle j %8d npart %8d nsumpart %8d Nprimaries %8d\n",
992 if (dmin == -1)
continue;
1000 for (Int_t k = dmin; k <= dmax; k++) {
1015 printf(
"AliMCEvent-BREAK: No valid AliMCParticle at label %i\n",index);
1026 if(nameGen.Contains(
"nococktailheader") )
return 0;
1029 while(nameGen.IsWhitespace()){
1035 printf(
"AliMCEvent-BREAK: No valid AliMCParticle at label %i\n",lab);
1041 printf(
"AliMCEvent - BREAK: Reached primary particle without valid mother\n");
1046 printf(
"AliMCEvent-BREAK: No valid AliMCParticle mother at label %i\n",mother);
1064 static Int_t binaryfirst(TClonesArray* a, Int_t low, Int_t high)
1066 Int_t mid = low + (high - low)/2;
1067 if (low > a->GetEntries()-1)
return (a->GetEntries()-1);
1069 if (mid > 1 && !((
AliVParticle*) a->At(mid-1))->IsPrimary()) {
1070 return binaryfirst(a, low, mid-1);
1075 return binaryfirst(a, mid+1, high);
1079 fNprimaries = Local::binaryfirst(mcParticles, 0, mcParticles->GetEntries()-1);
1092 return mcpart ? mcpart->
Particle() : 0;
1114 int current, parent;
1119 parent=
Particle(current)->GetFirstMother();
1120 if(parent<0)
return current;
virtual const AliVVertex * GetPrimaryVertex() const
virtual Int_t GetLastDaughter() const
virtual void AddSubsidiaryEvent(AliMCEvent *event)
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
virtual Bool_t IsPhysicalPrimary(Int_t i) const
virtual Int_t GetNumberOfPrimaries() const
void SetMother(Int_t idx)
AliGenEventHeader * GenEventHeader() const
static TParticle * GetDummyParticle()
virtual void FinishEvent()
const AliMCEvent * fTopEvent
virtual void DrawCheck(Int_t i, Int_t search)
virtual Bool_t IsSecondaryFromMaterial(Int_t index)
virtual void SetSecondaryOffset(Int_t ioff)
Bool_t IsSecondaryFromWeakDecay(Int_t index, Bool_t useInEmbedding=kFALSE)
virtual void ConnectTreeK(TTree *tree)
virtual void ConnectTreeTR(TTree *tree)
TList * fSubsidiaryEvents
virtual Bool_t IsFromBGEvent(Int_t index)
AliMCEvent & operator=(const AliMCEvent &mcEvnt)
virtual void ConnectHeaderAndStack(AliHeader *header)
TClonesArray * fMCParticles
virtual Int_t BgLabelToIndex(Int_t label)
virtual void ConnectTreeE(TTree *tree)
virtual AliVEvent::EDataLayoutType GetDataLayoutType() const
TList * GetCocktailList()
#define AliWarning(message)
virtual Int_t GetParticleAndTR(Int_t i, TParticle *&particle, TClonesArray *&trefs)
Int_t GetNprimary() const
virtual Int_t FindIndexAndEvent(Int_t oldidx, AliMCEvent *&event) const
void SetFirstDaughter(Int_t idx)
virtual Float_t Y() const
Bool_t IsPhysicalPrimary(Int_t i, Bool_t useInEmbedding=kFALSE)
Int_t GetPrimary(Int_t id)
virtual Int_t GetNtrack() const
virtual void AssignGeneratorIndex()
static Int_t fgkBgLabelOffset
Top MCEvent (if not embedded, then itself)
AliVHeader * fAODMCHeader
Int_t TreeKEntry(Int_t id, Bool_t useInEmbedding=kFALSE) const
void ConnectTree(TTree *tree)
virtual AliVParticle * GetTrack(Int_t i) const
virtual Int_t GetMother() const
static Int_t BgLabelOffset()
static AliMCParticle * GetDummyTrack()
TParticle * ParticleFromStack(Int_t i) const
virtual void SetParticleArray(TClonesArray *mcParticles)
virtual Int_t GetFirstDaughter() const
Bool_t GetCocktailGenerator(Int_t index, TString &nameGen)
TString GetGenerator(Int_t index)
AliVEvent & operator=(const AliVEvent &vEvnt)
virtual void SetDetectorId(Int_t id)
virtual Int_t Label() const
virtual AliGenEventHeader * FindHeader(Int_t ipart)
Bool_t IsSecondaryFromMaterial(Int_t index, Bool_t useInEmbedding=kFALSE)
virtual Int_t GetNumberOfTracks() const
virtual Int_t GetSecondaryOffset() const
TParticle * Particle(Int_t id, Bool_t useInEmbedding=kFALSE)
#define AliDebug(logLevel, message)
virtual TParticle * Particle() const
virtual void PreReadAll()
virtual Int_t GetPrimaryOffset() const
TClonesArray * fTrackReferences
TParticle * Particle(int i) const
virtual void SetGeneratorIndex(Short_t)
void SetLabel(Int_t label)
void SetLastDaughter(Int_t idx)
Int_t Raw2MergedLabel(int lbRaw) const
virtual void ReorderAndExpandTreeTR()
virtual Float_t X() const
TObjArray * fMCParticleMap
void SetMCEmbeddingFlag(Bool_t v=kTRUE)
Bool_t IsFromSubsidiaryEvent(int id) const
void SetStack(AliStack *st)
virtual Bool_t IsSecondaryFromWeakDecay(Int_t index)
virtual void SetPrimaryOffset(Int_t ioff)
void UpdateEventInformation()