]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ANALYSIS/AliAnalysisTaskMCParticleFilter.cxx
Added posibility to add V0 tender, by default this is off
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisTaskMCParticleFilter.cxx
index 9e52b181a640d2b6cd6b5f4f376b7b6abe343a54..aba20f8cdfe927e2c9ead2862f561c3e6fa84cd0 100644 (file)
@@ -99,7 +99,7 @@ Bool_t AliAnalysisTaskMCParticleFilter::Notify()
     }
     TTree *xtree = (TTree*)fxsec->Get("Xsection");
     if(!xtree){
-      Printf("%s:%d tree not found in the pyxsec.root",(char*)__FILE__,__LINE__);
+      AliWarning(Form("%s:%d tree not found in the pyxsec.root",(char*)__FILE__,__LINE__));
       return kTRUE;
     }
     xtree->SetBranchAddress("xsection",&xsection);
@@ -119,7 +119,7 @@ AliAnalysisTaskMCParticleFilter::AliAnalysisTaskMCParticleFilter(const char* nam
     fHistList(0x0)
 {
   // Default constructor
-  DefineOutput(1,TList::Class());  
+  DefineOutput(1, TList::Class());  
 }
 
 /*
@@ -180,7 +180,7 @@ void AliAnalysisTaskMCParticleFilter::UserCreateOutputObjects()
     AliMCEventHandler *mcH = (AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler()); 
     AliAODHandler *aodH = dynamic_cast<AliAODHandler*> ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
     if(!aodH){
-      Printf("%s:&d Could not get AODHandler",(char*)__FILE__,__LINE__);
+      AliWarning("Could not get AODHandler");
       return;
     }
     aodH->SetMCEventHandler(mcH);
@@ -224,6 +224,13 @@ void AliAnalysisTaskMCParticleFilter::UserExec(Option_t */*option*/)
     AliWarning("No MC handler Found");
     return;
   }
+  
+  AliAODHandler *aodH = dynamic_cast<AliAODHandler*> ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
+  if(!aodH){
+    AliWarning("Could not get AODHandler");
+    return;
+  }
+
 
 
   // fetch the output 
@@ -248,20 +255,20 @@ void AliAnalysisTaskMCParticleFilter::UserExec(Option_t */*option*/)
   // Get the proper MC Collision Geometry
   AliGenEventHeader* mcEH = mcE->GenEventHeader();
 
-  AliGenPythiaEventHeader *pyH = dynamic_cast<AliGenPythiaEventHeader*>(mcEH);
-  AliGenHijingEventHeader *hiH = 0;
-  AliCollisionGeometry *colG = 0;
+  AliGenPythiaEventHeader *pyH  = dynamic_cast<AliGenPythiaEventHeader*>(mcEH);
+  AliGenHijingEventHeader *hiH  = 0;
+  AliCollisionGeometry    *colG = 0;
   AliGenDPMjetEventHeader *dpmH = 0;
   // it can be only one save some casts
   // assuming PYTHIA and HIJING are the most likely ones...
   if(!pyH){
-    hiH = dynamic_cast<AliGenHijingEventHeader*>(mcEH);
-    if(!hiH){
-      colG = dynamic_cast<AliCollisionGeometry *>(mcEH);
-      if(!colG)dpmH = dynamic_cast<AliGenDPMjetEventHeader*>(mcEH);
-    }
+      hiH = dynamic_cast<AliGenHijingEventHeader*>(mcEH);
+      if(!hiH){
+         dpmH = dynamic_cast<AliGenDPMjetEventHeader*>(mcEH);
+      }
   }
-
+  
+  if (hiH || dpmH) colG = dynamic_cast<AliCollisionGeometry*>(mcEH);
 
   // fetch the trials on a event by event basis, not from pyxsec.root otherwise 
   // we will get a problem when running on proof since Notify may be called 
@@ -292,7 +299,7 @@ void AliAnalysisTaskMCParticleFilter::UserExec(Option_t */*option*/)
 
   if (colG) {
     aodMCHo->SetReactionPlaneAngle(colG->ReactionPlaneAngle());
-    printf("Found Collision Geometry. Got Reaction Plane %lf\n", colG->ReactionPlaneAngle());
+    AliInfo(Form("Found Collision Geometry. Got Reaction Plane %lf\n", colG->ReactionPlaneAngle()));
   }
 
 
@@ -383,6 +390,7 @@ void AliAnalysisTaskMCParticleFilter::UserExec(Option_t */*option*/)
 
   AliInfo(Form("Taken daughters %d/%d of %d charm",iTaken,iAll,iCharm));
 
+  aodH->StoreMCParticles();
   PostData(1,fHistList);
 
   return;
@@ -394,18 +402,12 @@ void AliAnalysisTaskMCParticleFilter::Terminate(Option_t */*option*/){
   //
 
 
-  TTree *tree = (TTree*)GetOutputData(0);
   fHistList = (TList*)GetOutputData(1);
   if(!fHistList){
     Printf("%s:%d Output list not found",(char*)__FILE__,__LINE__);
     return;
   }
 
-  if(!tree){
-    Printf("%s:%d Output tree not found",(char*)__FILE__,__LINE__);
-    return;
-  }
-
   TProfile *hXsec = ((TProfile*)(fHistList->FindObject("h1Xsec")));
   TH1F* hTrials  = ((TH1F*)(fHistList->FindObject("h1Trials")));
   if(!hXsec)return;
@@ -414,16 +416,6 @@ void AliAnalysisTaskMCParticleFilter::Terminate(Option_t */*option*/){
   Float_t xsec = hXsec->GetBinContent(1);
   Float_t trials = hTrials->Integral();
   AliInfo(Form("Average -section %.4E and total number of trials %E",xsec,trials));
-  
-  // This only works if the tree is not a special output
-  // in this case it is already written
-  /*
-  TParameter<float> *x = new TParameter<float>("xsection",xsec);
-  tree->GetUserInfo()->Add(x);
-  TParameter<float> *t = new TParameter<float>("trials",trials);
-  tree->GetUserInfo()->Add(t);
-  */
-  
 
 }