]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Bool_t AliMCEvent::GetCocktailGenerator(Int_t index,TClonesArray *arrayMC,TString...
authormorsch <andreas.morsch@cern.ch>
Mon, 5 May 2014 10:12:01 +0000 (12:12 +0200)
committermorsch <andreas.morsch@cern.ch>
Mon, 5 May 2014 10:12:01 +0000 (12:12 +0200)
if(kFALSE) no cocktail header was found
if(kTRUE) it returns the name of the generator for particle with label index (or for it's mother)

Leticia Cunqueiro

STEER/STEERBase/AliMCEvent.cxx
STEER/STEERBase/AliMCEvent.h

index a93e63e568ecd89c3c9864f1816d0976491551dd..c3988769c3eeb81c7263fd533eefd973c30d0e5a 100644 (file)
@@ -806,4 +806,54 @@ Bool_t AliMCEvent::IsFromBGEvent(Int_t index)
 }
 
 
+
+
+
+   TString AliMCEvent::GetGenerator(Int_t index){
+   Int_t nsumpart=0;
+   AliGenCocktailEventHeader* coHeader = 
+   dynamic_cast<AliGenCocktailEventHeader*> (GenEventHeader());
+   if(!coHeader) {TString noheader="nococktailheader";
+   return noheader;}
+   TList *lh=coHeader->GetHeaders();
+   Int_t nh=lh->GetEntries();
+   for(Int_t i=0;i<nh;i++){
+    AliGenEventHeader* gh=(AliGenEventHeader*)lh->At(i);
+    TString genname=gh->GetName();
+    Int_t npart=gh->NProduced();
+    if(index>=nsumpart && index<(nsumpart+npart)) return genname;
+    nsumpart+=npart;
+    }
+    TString empty="";
+    return empty;
+}
+
+Bool_t  AliMCEvent::GetCocktailGenerator(Int_t index,TClonesArray *arrayMC, TString &nameGen){
+  //method that gives the generator for a given particle with label index (or that of the corresponding primary)
+   nameGen=GetGenerator(index);
+   if(nameGen.Contains("nococktailheader") )return 0;
+
+   while(nameGen.IsWhitespace()){
+    AliMCParticle *mcpart= (AliMCParticle*)arrayMC->At(index);
+    if(!mcpart){
+      printf("AliMCEvent-BREAK: No valid AliAODMCParticle at label %i\n",index);
+      break;
+    }
+    Int_t mother = mcpart->GetMother();
+    if(mother<0){
+      printf("AliMCEvent - BREAK: Reached primary particle without valid mother\n");
+      break;
+    }
+    index=mother;
+    nameGen=GetGenerator(mother);
+   }
+   
+   return 1;
+}
+
+
+
+
 ClassImp(AliMCEvent)
index 1bff083236cafce8955a5b6ba5e9f11b83a1619f..4f3ae76fc3fecb8de2409205720862efc392afcf 100644 (file)
@@ -129,6 +129,8 @@ public:
     virtual Int_t     BgLabelToIndex(Int_t label);
     static  Int_t     BgLabelOffset() {return fgkBgLabelOffset;}
     virtual Bool_t    IsFromBGEvent(Int_t index);
+        TString  GetGenerator(Int_t index); 
+  Bool_t GetCocktailGenerator(Int_t index,TClonesArray *arrayMC,TString &nameGen);
     virtual Bool_t    IsSecondaryFromWeakDecay(Int_t index);
     virtual Bool_t    IsSecondaryFromMaterial(Int_t index);
     // External particle array