1 /**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //-------------------------------------------------------------------------
19 // Class for Kinematic Events
20 // Author: Andreas Morsch, CERN
21 //-------------------------------------------------------------------------
27 #include <TParticle.h>
28 #include <TClonesArray.h>
33 #include "AliMCEvent.h"
34 #include "AliMCVertex.h"
36 #include "AliTrackReference.h"
37 #include "AliHeader.h"
38 #include "AliGenEventHeader.h"
39 #include "AliGenHijingEventHeader.h"
40 #include "AliGenCocktailEventHeader.h"
43 Int_t AliMCEvent::fgkBgLabelOffset(10000000);
46 AliMCEvent::AliMCEvent():
51 fHeader(new AliHeader()),
54 fTrackReferences(new TClonesArray("AliTrackReference", 1000)),
67 // Default constructor
70 AliMCEvent::AliMCEvent(const AliMCEvent& mcEvnt) :
72 fStack(mcEvnt.fStack),
73 fMCParticles(mcEvnt.fMCParticles),
74 fMCParticleMap(mcEvnt.fMCParticleMap),
75 fHeader(mcEvnt.fHeader),
76 fAODMCHeader(mcEvnt.fAODMCHeader),
77 fTRBuffer(mcEvnt.fTRBuffer),
78 fTrackReferences(mcEvnt.fTrackReferences),
79 fTreeTR(mcEvnt.fTreeTR),
80 fTmpTreeTR(mcEvnt.fTmpTreeTR),
81 fTmpFileTR(mcEvnt.fTmpFileTR),
82 fNprimaries(mcEvnt.fNprimaries),
83 fNparticles(mcEvnt.fNparticles),
88 fVertex(mcEvnt.fVertex),
95 AliMCEvent& AliMCEvent::operator=(const AliMCEvent& mcEvnt)
97 // assignment operator
99 AliVEvent::operator=(mcEvnt);
105 void AliMCEvent::ConnectTreeE (TTree* tree)
107 // Connect the event header tree
108 tree->SetBranchAddress("Header", &fHeader);
111 void AliMCEvent::ConnectTreeK (TTree* tree)
113 // Connect Kinematics tree
114 fStack = fHeader->Stack();
115 fStack->ConnectTree(tree);
120 UpdateEventInformation();
123 void AliMCEvent::ConnectHeaderAndStack(AliHeader* header)
125 // fill MC event information from stack and header
128 fStack = fHeader->Stack();
130 UpdateEventInformation();
133 void AliMCEvent::UpdateEventInformation()
135 // bookkeeping for next event
137 // Connect the kinematics tree to the stack
138 if (!fMCParticles) fMCParticles = new TClonesArray("AliMCParticle",1000);
140 // Initialize members
141 fNparticles = fStack->GetNtrack();
142 fNprimaries = fStack->GetNprimary();
144 Int_t iev = fHeader->GetEvent();
145 Int_t ievr = fHeader->GetEventNrInRun();
146 AliDebug(1, Form("AliMCEvent# %5d %5d: Number of particles: %5d (all) %5d (primaries)\n",
147 iev, ievr, fNparticles, fNprimaries));
149 // This is a cache for the TParticles converted to MCParticles on user request
150 if (fMCParticleMap) {
151 fMCParticleMap->Clear();
152 fMCParticles->Delete();
153 if (fNparticles>0) fMCParticleMap->Expand(fNparticles);
156 fMCParticleMap = new TObjArray(fNparticles);
159 void AliMCEvent::ConnectTreeTR (TTree* tree)
161 // Connect the track reference tree
164 if (fTreeTR->GetBranch("AliRun")) {
169 // This is an old format with one branch per detector not in synch with TreeK
170 ReorderAndExpandTreeTR();
173 fTreeTR->SetBranchAddress("TrackReferences", &fTRBuffer);
177 Int_t AliMCEvent::GetParticleAndTR(Int_t i, TParticle*& particle, TClonesArray*& trefs)
180 if (i < 0 || i >= fNparticles) {
181 AliWarning(Form("AliMCEventHandler::GetEntry: Index out of range"));
186 particle = fStack->Particle(i);
188 fTreeTR->GetEntry(fStack->TreeKEntry(i));
190 return trefs->GetEntries();
198 void AliMCEvent::Clean()
200 // Clean-up before new trees are connected
201 delete fStack; fStack = 0;
213 void AliMCEvent::FinishEvent()
215 // Clean-up after event
217 if (fStack) fStack->Reset(0);
218 fMCParticles->Delete();
221 fMCParticleMap->Clear();
225 // fTrackReferences->Delete();
226 fTrackReferences->Clear();
230 // fSubsidiaryEvents->Clear();
231 fSubsidiaryEvents = 0;
237 void AliMCEvent::DrawCheck(Int_t i, Int_t search)
240 // Simple event display for debugging
242 AliWarning("No Track Reference information available");
246 if (i > -1 && i < fNparticles) {
247 fTreeTR->GetEntry(fStack->TreeKEntry(i));
249 AliWarning("AliMCEvent::GetEntry: Index out of range");
252 Int_t nh = fTRBuffer->GetEntries();
256 while(nh <= search && i < fNparticles - 1) {
258 fTreeTR->GetEntry(fStack->TreeKEntry(i));
259 nh = fTRBuffer->GetEntries();
261 printf("Found Hits at %5d\n", i);
263 TParticle* particle = fStack->Particle(i);
265 TH2F* h = new TH2F("", "", 100, -500, 500, 100, -500, 500);
266 Float_t x0 = particle->Vx();
267 Float_t y0 = particle->Vy();
269 Float_t x1 = particle->Vx() + particle->Px() * 50.;
270 Float_t y1 = particle->Vy() + particle->Py() * 50.;
272 TArrow* a = new TArrow(x0, y0, x1, y1, 0.01);
278 for (Int_t ih = 0; ih < nh; ih++) {
279 AliTrackReference* ref = (AliTrackReference*) fTRBuffer->At(ih);
280 TMarker* m = new TMarker(ref->X(), ref->Y(), 20);
282 m->SetMarkerSize(0.4);
288 void AliMCEvent::ReorderAndExpandTreeTR()
291 // Reorder and expand the track reference tree in order to match the kinematics tree.
292 // Copy the information from different branches into one
296 fTmpFileTR = new TFile("TrackRefsTmp.root", "recreate");
297 fTmpTreeTR = new TTree("TreeTR", "TrackReferences");
298 if (!fTRBuffer) fTRBuffer = new TClonesArray("AliTrackReference", 100);
299 fTmpTreeTR->Branch("TrackReferences", "TClonesArray", &fTRBuffer, 64000, 0);
303 // Activate the used branches only. Otherwisw we get a bad memory leak.
305 fTreeTR->SetBranchStatus("*", 0);
306 fTreeTR->SetBranchStatus("AliRun.*", 1);
307 fTreeTR->SetBranchStatus("ITS.*", 1);
308 fTreeTR->SetBranchStatus("TPC.*", 1);
309 fTreeTR->SetBranchStatus("TRD.*", 1);
310 fTreeTR->SetBranchStatus("TOF.*", 1);
311 fTreeTR->SetBranchStatus("FRAME.*", 1);
312 fTreeTR->SetBranchStatus("MUON.*", 1);
316 // Connect the active branches
317 TClonesArray* trefs[7];
318 for (Int_t i = 0; i < 7; i++) trefs[i] = 0;
320 // make branch for central track references
321 if (fTreeTR->GetBranch("AliRun")) fTreeTR->SetBranchAddress("AliRun", &trefs[0]);
322 if (fTreeTR->GetBranch("ITS")) fTreeTR->SetBranchAddress("ITS", &trefs[1]);
323 if (fTreeTR->GetBranch("TPC")) fTreeTR->SetBranchAddress("TPC", &trefs[2]);
324 if (fTreeTR->GetBranch("TRD")) fTreeTR->SetBranchAddress("TRD", &trefs[3]);
325 if (fTreeTR->GetBranch("TOF")) fTreeTR->SetBranchAddress("TOF", &trefs[4]);
326 if (fTreeTR->GetBranch("FRAME")) fTreeTR->SetBranchAddress("FRAME", &trefs[5]);
327 if (fTreeTR->GetBranch("MUON")) fTreeTR->SetBranchAddress("MUON", &trefs[6]);
330 Int_t np = fStack->GetNprimary();
331 Int_t nt = fTreeTR->GetEntries();
334 // Loop over tracks and find the secondaries with the help of the kine tree
340 for (Int_t ip = np - 1; ip > -1; ip--) {
341 part = fStack->Particle(ip);
342 // printf("Particle %5d %5d %5d %5d %5d %5d \n",
343 // ip, part->GetPdgCode(), part->GetFirstMother(), part->GetFirstDaughter(),
344 // part->GetLastDaughter(), part->TestBit(kTransportBit));
346 // Determine range of secondaries produced by this primary during transport
347 Int_t dau1 = part->GetFirstDaughter();
348 if (dau1 < np) continue; // This particle has no secondaries produced during transport
351 Int_t inext = ip - 1;
354 part = fStack->Particle(inext);
355 dau2 = part->GetFirstDaughter();
356 if (dau2 == -1 || dau2 < np) {
362 dau2 = fStack->GetNtrack() - 1;
365 } // find upper bound
369 // printf("Check (1) %5d %5d %5d %5d %5d \n", ip, np, it, dau1, dau2);
371 // Loop over reference hits and find secondary label
372 // First the tricky part: find the entry in treeTR than contains the hits or
373 // make sure that no hits exist.
375 Bool_t hasHits = kFALSE;
376 Bool_t isOutside = kFALSE;
379 while (!hasHits && !isOutside && it < nt) {
380 fTreeTR->GetEntry(it++);
381 for (Int_t ib = 0; ib < 7; ib++) {
382 if (!trefs[ib]) continue;
383 Int_t nh = trefs[ib]->GetEntries();
384 for (Int_t ih = 0; ih < nh; ih++) {
385 AliTrackReference* tr = (AliTrackReference*) trefs[ib]->At(ih);
386 Int_t label = tr->Label();
387 if (label >= dau1 && label <= dau2) {
392 if (label > dau2 || label < ip) {
398 if (hasHits || isOutside) break;
403 // Write empty entries
404 for (Int_t id = dau1; (id <= dau2); id++) {
410 fTreeTR->GetEntry(itlast);
411 for (Int_t id = dau1; (id <= dau2) && (dau1 > -1); id++) {
412 for (Int_t ib = 0; ib < 7; ib++) {
413 if (!trefs[ib]) continue;
414 Int_t nh = trefs[ib]->GetEntries();
415 for (Int_t ih = 0; ih < nh; ih++) {
416 AliTrackReference* tr = (AliTrackReference*) trefs[ib]->At(ih);
417 Int_t label = tr->Label();
419 if (label == ip) continue;
420 if (label > dau2 || label < dau1)
421 printf("AliMCEventHandler::Track Reference Label out of range !: %5d %5d %5d %5d \n",
422 itlast, label, dau1, dau2);
425 tr->SetDetectorId(ib-1);
426 Int_t nref = fTRBuffer->GetEntriesFast();
427 TClonesArray &lref = *fTRBuffer;
428 new(lref[nref]) AliTrackReference(*tr);
440 // Now loop again and write the primaries
443 for (Int_t ip = 0; ip < np; ip++) {
445 while (labmax < ip && it > -1) {
446 fTreeTR->GetEntry(it--);
447 for (Int_t ib = 0; ib < 7; ib++) {
448 if (!trefs[ib]) continue;
449 Int_t nh = trefs[ib]->GetEntries();
451 // Loop over reference hits and find primary labels
452 for (Int_t ih = 0; ih < nh; ih++) {
453 AliTrackReference* tr = (AliTrackReference*) trefs[ib]->At(ih);
454 Int_t label = tr->Label();
455 if (label < np && label > labmax) {
460 tr->SetDetectorId(ib-1);
461 Int_t nref = fTRBuffer->GetEntriesFast();
462 TClonesArray &lref = *fTRBuffer;
463 new(lref[nref]) AliTrackReference(*tr);
477 delete fTreeTR; fTreeTR = 0;
479 for (Int_t ib = 0; ib < 7; ib++) {
487 if (ifills != fStack->GetNtrack())
488 printf("AliMCEvent:Number of entries in TreeTR (%5d) unequal to TreeK (%5d) \n",
489 ifills, fStack->GetNtrack());
492 fTreeTR = fTmpTreeTR;
495 AliVParticle* AliMCEvent::GetTrack(Int_t i) const
503 return ((AliVParticle*) (fMCParticles->At(i)));
508 // Check first if this explicitely accesses the subsidiary event
510 if (i >= BgLabelOffset()) {
511 if (fSubsidiaryEvents) {
512 AliMCEvent* bgEvent = (AliMCEvent*) (fSubsidiaryEvents->At(1));
513 return (bgEvent->GetTrack(i - BgLabelOffset()));
520 AliMCParticle *mcParticle = 0;
521 TParticle *particle = 0;
522 TClonesArray *trefs = 0;
524 TObjArray *rarray = 0;
528 // Out of range check
529 if (i < 0 || i >= fNparticles) {
530 AliWarning(Form("AliMCEvent::GetEntry: Index out of range"));
536 if (fSubsidiaryEvents) {
538 Int_t idx = FindIndexAndEvent(i, mc);
539 return (mc->GetTrack(idx));
543 // First check If the MC Particle has been already cached
544 if(!fMCParticleMap->At(i)) {
545 // Get particle from the stack
546 particle = fStack->Particle(i);
547 // Get track references from Tree TR
549 fTreeTR->GetEntry(fStack->TreeKEntry(i));
551 ntref = trefs->GetEntriesFast();
552 rarray = new TObjArray(ntref);
553 Int_t nen = fTrackReferences->GetEntriesFast();
554 for (Int_t j = 0; j < ntref; j++) {
555 // Save the track references in a TClonesArray
556 AliTrackReference* ref = dynamic_cast<AliTrackReference*>((*fTRBuffer)[j]);
557 // Save the pointer in a TRefArray
559 new ((*fTrackReferences)[nen]) AliTrackReference(*ref);
560 rarray->AddAt((*fTrackReferences)[nen], j);
563 } // loop over track references for entry i
564 } // if TreeTR available
565 Int_t nentries = fMCParticles->GetEntriesFast();
566 mcParticle = new ((*fMCParticles)[nentries]) AliMCParticle(particle, rarray, i);
567 fMCParticleMap->AddAt(mcParticle, i);
569 TParticle* part = mcParticle->Particle();
570 Int_t imo = part->GetFirstMother();
571 Int_t id1 = part->GetFirstDaughter();
572 Int_t id2 = part->GetLastDaughter();
573 if (fPrimaryOffset > 0 || fSecondaryOffset > 0) {
574 // Remapping of the mother and daughter indices
575 if (imo < fNprimaries) {
576 mcParticle->SetMother(imo + fPrimaryOffset);
578 mcParticle->SetMother(imo + fSecondaryOffset - fNprimaries);
581 if (id1 < fNprimaries) {
582 mcParticle->SetFirstDaughter(id1 + fPrimaryOffset);
583 mcParticle->SetLastDaughter (id2 + fPrimaryOffset);
585 mcParticle->SetFirstDaughter(id1 + fSecondaryOffset - fNprimaries);
586 mcParticle->SetLastDaughter (id2 + fSecondaryOffset - fNprimaries);
590 if (i > fNprimaries) {
591 mcParticle->SetLabel(i + fPrimaryOffset);
593 mcParticle->SetLabel(i + fSecondaryOffset - fNprimaries);
596 mcParticle->SetFirstDaughter(id1);
597 mcParticle->SetLastDaughter (id2);
598 mcParticle->SetMother (imo);
602 mcParticle = dynamic_cast<AliMCParticle*>(fMCParticleMap->At(i));
605 //Printf("mcParticleGetMother %d",mcParticle->GetMother());
609 AliGenEventHeader* AliMCEvent::GenEventHeader() const
613 return (fHeader->GenEventHeader());
617 TList * lh = fAODMCHeader->GetCocktailHeaders();
618 if (lh) {return ((AliGenEventHeader*) lh->At(0));}
625 void AliMCEvent::AddSubsidiaryEvent(AliMCEvent* event)
627 // Add a subsidiary event to the list; for example merged background event.
628 if (!fSubsidiaryEvents) {
629 TList* events = new TList();
630 events->Add(new AliMCEvent(*this));
631 fSubsidiaryEvents = events;
634 fSubsidiaryEvents->Add(event);
637 AliGenEventHeader *AliMCEvent::FindHeader(Int_t ipart) {
639 // Get Header belonging to this track;
640 // only works for primaries (i.e. particles coming from the Generator)
641 // Also sorts out the case of Cocktail event (get header of subevent in cocktail generetor header)
644 AliMCEvent *event = this;
646 if (fSubsidiaryEvents) {
647 // Get pointer to subevent if needed
648 ipart = FindIndexAndEvent(ipart,event);
651 AliGenEventHeader* header = event->GenEventHeader();
652 if (ipart >= header->NProduced()) {
653 AliWarning(Form("Not a primary -- returning 0 (idx %d, nPrimary %d)",ipart,header->NProduced()));
656 AliGenCocktailEventHeader *coHeader = dynamic_cast<AliGenCocktailEventHeader*>(header);
657 if (coHeader) { // Cocktail event
658 TList* headerList = coHeader->GetHeaders();
659 TIter headIt(headerList);
661 do { // Go trhough all headers and look for the correct one
662 header = (AliGenEventHeader*) headIt();
663 if (header) nproduced += header->NProduced();
664 } while (header && ipart >= nproduced);
670 Int_t AliMCEvent::FindIndexAndEvent(Int_t oldidx, AliMCEvent*& event) const
672 // Find the index and event in case of composed events like signal + background
673 TIter next(fSubsidiaryEvents);
675 if (oldidx < fNprimaries) {
676 while((event = (AliMCEvent*)next())) {
677 if (oldidx < (event->GetPrimaryOffset() + event->GetNumberOfPrimaries())) break;
680 return (oldidx - event->GetPrimaryOffset());
685 while((event = (AliMCEvent*)next())) {
686 if (oldidx < (event->GetSecondaryOffset() + (event->GetNumberOfTracks() - event->GetNumberOfPrimaries()))) break;
689 return (oldidx - event->GetSecondaryOffset() + event->GetNumberOfPrimaries());
696 Int_t AliMCEvent::BgLabelToIndex(Int_t label)
698 // Convert a background label to an absolute index
699 if (fSubsidiaryEvents) {
700 AliMCEvent* bgEvent = (AliMCEvent*) (fSubsidiaryEvents->At(1));
701 label -= BgLabelOffset();
702 if (label < bgEvent->GetNumberOfPrimaries()) {
703 label += bgEvent->GetPrimaryOffset();
705 label += (bgEvent->GetSecondaryOffset() - fNprimaries);
712 Bool_t AliMCEvent::IsPhysicalPrimary(Int_t i) const
715 // Delegate to subevent if necesarry
718 if (!fSubsidiaryEvents) {
719 return fStack->IsPhysicalPrimary(i);
722 Int_t idx = FindIndexAndEvent(i, evt);
723 return (evt->IsPhysicalPrimary(idx));
727 Bool_t AliMCEvent::IsSecondaryFromWeakDecay(Int_t i)
730 // Delegate to subevent if necesarry
731 if (!fSubsidiaryEvents) {
732 return fStack->IsSecondaryFromWeakDecay(i);
735 Int_t idx = FindIndexAndEvent(i, evt);
736 return (evt->IsSecondaryFromWeakDecay(idx));
740 Bool_t AliMCEvent::IsSecondaryFromMaterial(Int_t i)
743 // Delegate to subevent if necesarry
744 if (!fSubsidiaryEvents) {
745 return fStack->IsSecondaryFromMaterial(i);
748 Int_t idx = FindIndexAndEvent(i, evt);
749 return (evt->IsSecondaryFromMaterial(idx));
754 void AliMCEvent::InitEvent()
757 // Initialize the subsidiary event structure
758 if (fSubsidiaryEvents) {
759 TIter next(fSubsidiaryEvents);
764 while((evt = (AliMCEvent*)next())) {
765 fNprimaries += evt->GetNumberOfPrimaries();
766 fNparticles += evt->GetNumberOfTracks();
770 Int_t ioffs = fNprimaries;
773 while((evt = (AliMCEvent*)next())) {
774 evt->SetPrimaryOffset(ioffp);
775 evt->SetSecondaryOffset(ioffs);
776 ioffp += evt->GetNumberOfPrimaries();
777 ioffs += (evt->GetNumberOfTracks() - evt->GetNumberOfPrimaries());
782 void AliMCEvent::PreReadAll()
784 // Preread the MC information
787 for (i = fStack->GetNprimary(); i < fStack->GetNtrack(); i++)
792 for (i = 0; i < fStack->GetNprimary(); i++)
796 AssignGeneratorIndex();
799 const AliVVertex * AliMCEvent::GetPrimaryVertex() const
801 // Create a MCVertex object from the MCHeader information
803 GenEventHeader()->PrimaryVertex(v) ;
805 fVertex = new AliMCVertex(v[0], v[1], v[2]);
807 ((AliMCVertex*) fVertex)->SetPosition(v[0], v[1], v[2]);
812 Bool_t AliMCEvent::IsFromBGEvent(Int_t index)
814 // Checks if a particle is from the background events
815 // Works for HIJING inside Cocktail
817 AliGenCocktailEventHeader* coHeader =
818 dynamic_cast<AliGenCocktailEventHeader*> (GenEventHeader());
819 if (!coHeader) return (0);
820 TList* list = coHeader->GetHeaders();
821 AliGenHijingEventHeader* hijingH = dynamic_cast<AliGenHijingEventHeader*>(list->FindObject("Hijing"));
822 if (!hijingH) return (0);
823 fNBG = hijingH->NProduced();
826 return (index < fNBG);
830 TList* AliMCEvent::GetCocktailList()
832 //gives the CocktailHeaders when reading ESDs/AODs (corresponding to fExteral=kFALSE/kTRUE)
833 //the AODMC header (and the aodmc array) is passed as an instance to MCEvent by the AliAODInputHandler
834 if(fExternal==kFALSE) {
835 AliGenCocktailEventHeader* coHeader =dynamic_cast<AliGenCocktailEventHeader*> (GenEventHeader());
839 return (coHeader->GetHeaders());
845 return (fAODMCHeader->GetCocktailHeaders());
851 TString AliMCEvent::GetGenerator(Int_t index)
853 Int_t nsumpart=fNprimaries;
854 TList* lh = GetCocktailList();
855 if(!lh){ TString noheader="nococktailheader";
857 Int_t nh=lh->GetEntries();
858 for (Int_t i = nh-1; i >= 0; i--){
859 AliGenEventHeader* gh=(AliGenEventHeader*)lh->At(i);
860 TString genname=gh->GetName();
861 Int_t npart=gh->NProduced();
862 if (i == 0) npart = nsumpart;
863 if(index < nsumpart && index >= (nsumpart-npart)) return genname;
870 void AliMCEvent::AssignGeneratorIndex() {
872 // Assign the generator index to each particle
874 TList* list = GetCocktailList();
878 Int_t nh = list->GetEntries();
879 Int_t nsumpart = fNprimaries;
880 for(Int_t i = nh-1; i >= 0; i--){
881 AliGenEventHeader* gh = (AliGenEventHeader*)list->At(i);
882 Int_t npart = gh->NProduced();
884 if (npart != nsumpart) {
885 // printf("Header inconsistent ! %5d %5d \n", npart, nsumpart);
890 // Loop over primary particles for generator i
891 for (Int_t j = nsumpart-1; j >= nsumpart-npart; j--) {
892 AliVParticle* part = GetTrack(j);
893 part->SetGeneratorIndex(i);
894 Int_t dmin = part->GetFirstDaughter();
895 Int_t dmax = part->GetLastDaughter();
896 if (dmin == -1) continue;
897 AssignGeneratorIndex(i, dmin, dmax);
903 void AliMCEvent::AssignGeneratorIndex(Int_t index, Int_t dmin, Int_t dmax) {
904 for (Int_t k = dmin; k <= dmax; k++) {
905 AliVParticle* dpart = GetTrack(k);
906 dpart->SetGeneratorIndex(index);
907 Int_t d1 = dpart->GetFirstDaughter();
908 Int_t d2 = dpart->GetLastDaughter();
910 AssignGeneratorIndex(index, d1, d2);
915 Bool_t AliMCEvent::GetCocktailGenerator(Int_t index,TString &nameGen){
916 //method that gives the generator for a given particle with label index (or that of the corresponding primary)
917 AliVParticle* mcpart0 = (AliVParticle*) (GetTrack(index));
919 printf("AliMCEvent-BREAK: No valid AliMCParticle at label %i\n",index);
923 Int_t ig = mcpart0->GetGeneratorIndex();
925 nameGen = ((AliGenEventHeader*)GetCocktailList()->At(ig))->GetName();
929 nameGen=GetGenerator(index);
930 if(nameGen.Contains("nococktailheader") )return 0;
933 while(nameGen.IsWhitespace()){
936 AliVParticle* mcpart = (AliVParticle*) (GetTrack(lab));
939 printf("AliMCEvent-BREAK: No valid AliMCParticle at label %i\n",lab);
942 mother = mcpart->GetMother();
945 printf("AliMCEvent - BREAK: Reached primary particle without valid mother\n");
948 AliVParticle* mcmom = (AliVParticle*) (GetTrack(mother));
950 printf("AliMCEvent-BREAK: No valid AliMCParticle mother at label %i\n",mother);
955 nameGen=GetGenerator(mother);
961 void AliMCEvent::SetParticleArray(TClonesArray* mcParticles)
963 fMCParticles = mcParticles;
964 fNparticles = fMCParticles->GetEntries();
967 for (Int_t i = 0; i < mcParticles->GetEntries(); i++)
968 if (((AliVParticle*) mcParticles->At(i))->IsPrimary()) fNprimaries++;
969 AssignGeneratorIndex();