add mc header and tclonesarray pointer to the task for final deletion in the d'tor...
authorkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 21 Feb 2011 20:57:18 +0000 (20:57 +0000)
committerkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 21 Feb 2011 20:57:18 +0000 (20:57 +0000)
ANALYSIS/AliAnalysisTaskMCParticleFilter.cxx
ANALYSIS/AliAnalysisTaskMCParticleFilter.h

index f6ada4c..354b3a0 100644 (file)
@@ -55,8 +55,10 @@ ClassImp(AliAnalysisTaskMCParticleFilter)
 
 //____________________________________________________________________
 AliAnalysisTaskMCParticleFilter::AliAnalysisTaskMCParticleFilter():
-AliAnalysisTaskSE(),
+  AliAnalysisTaskSE(),
   fTrackFilterMother(0x0),
+  fAODMcHeader(0x0),
+  fAODMcParticles(0x0),
   fHistList(0x0)
 {
   // Default constructor
@@ -116,6 +118,8 @@ Bool_t AliAnalysisTaskMCParticleFilter::Notify()
 AliAnalysisTaskMCParticleFilter::AliAnalysisTaskMCParticleFilter(const char* name):
     AliAnalysisTaskSE(name),
     fTrackFilterMother(0x0),
+    fAODMcHeader(0x0),
+    fAODMcParticles(0x0),
     fHistList(0x0)
 {
   // Default constructor
@@ -134,7 +138,14 @@ AliAnalysisTaskMCParticleFilter::AliAnalysisTaskMCParticleFilter(const AliAnalys
 //____________________________________________________________________
 AliAnalysisTaskMCParticleFilter::~AliAnalysisTaskMCParticleFilter()
 {
-  //  if( fTrackFilterMother ) delete fTrackFilterMother;
+
+  if(fAODMcHeader){
+    delete fAODMcHeader;
+  }
+  if(fAODMcParticles){
+    fAODMcParticles->Delete();
+    delete fAODMcParticles;
+  }
 }
 
 /*
@@ -168,16 +179,14 @@ void AliAnalysisTaskMCParticleFilter::UserCreateOutputObjects()
 
 
     // mcparticles
-    TClonesArray *tca = new TClonesArray("AliAODMCParticle", 0);
-    tca->SetName(AliAODMCParticle::StdBranchName());
-    AddAODBranch("TClonesArray",&tca);
+    fAODMcParticles = new TClonesArray("AliAODMCParticle", 0);
+    fAODMcParticles->SetName(AliAODMCParticle::StdBranchName());
+    AddAODBranch("TClonesArray",&fAODMcParticles);
 
     // MC header...
-    AliAODMCHeader *mcHeader = new AliAODMCHeader();
-    mcHeader->SetName(AliAODMCHeader::StdBranchName());
-    AddAODBranch("AliAODMCHeader",&mcHeader);    
-
-    
+    fAODMcHeader = new AliAODMCHeader();
+    fAODMcHeader->SetName(AliAODMCHeader::StdBranchName());
+    AddAODBranch("AliAODMCHeader",&fAODMcHeader);    
 
     AliMCEventHandler *mcH = (AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler()); 
     AliAODHandler *aodH = dynamic_cast<AliAODHandler*> ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
@@ -253,7 +262,6 @@ void AliAnalysisTaskMCParticleFilter::UserExec(Option_t */*option*/)
   Int_t nprim = mcE->GetNumberOfPrimaries();
   // TODO ADD MC VERTEX
 
-  AliAODMCHeader *aodMCHo = (AliAODMCHeader *) aod->FindListObject("mcHeader");
   // Get the proper MC Collision Geometry
   AliGenEventHeader* mcEH = mcE->GenEventHeader();
 
@@ -300,7 +308,7 @@ void AliAnalysisTaskMCParticleFilter::UserExec(Option_t */*option*/)
 
 
   if (colG) {
-    aodMCHo->SetReactionPlaneAngle(colG->ReactionPlaneAngle());
+    fAODMcHeader->SetReactionPlaneAngle(colG->ReactionPlaneAngle());
     AliInfo(Form("Found Collision Geometry. Got Reaction Plane %lf\n", colG->ReactionPlaneAngle()));
   }
 
index 31f5b3c..46cf1f9 100644 (file)
@@ -14,6 +14,8 @@
 class AliAnalysisFilter;
 class TString;
 class TList;
+class AliAODMCHeader;
+class TClonesArray;
 
 class AliAnalysisTaskMCParticleFilter : public AliAnalysisTaskSE
 {
@@ -40,9 +42,11 @@ class AliAnalysisTaskMCParticleFilter : public AliAnalysisTaskSE
 
 
     AliAnalysisFilter*  fTrackFilterMother;   //  Track Filter
+    AliAODMCHeader *fAODMcHeader;                 // ! MC Header
+    TClonesArray *fAODMcParticles;            // ! tclones array of MC Particles
     TList *fHistList;                         // list to store e histograms, only as exchange
 
-    ClassDef( AliAnalysisTaskMCParticleFilter, 2 ); // Analysis task for Kinematic filtering
+    ClassDef( AliAnalysisTaskMCParticleFilter, 3 ); // Analysis task for Kinematic filtering
 };
  
 #endif