Correction of memory leaks.
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 21 Feb 2011 19:54:46 +0000 (19:54 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 21 Feb 2011 19:54:46 +0000 (19:54 +0000)
Ch. Klein-Boesing

ANALYSIS/AliAnalysisTaskESDfilter.cxx
ANALYSIS/AliAnalysisTaskESDfilter.h
STEER/AliAODHeader.cxx
STEER/AliAODHeader.h

index 4459d19..e6528ed 100644 (file)
@@ -139,7 +139,9 @@ fTimeZeroType(AliESDpid::kTOF_T0)
 {\r
   // Constructor\r
 }\r
-\r
+AliAnalysisTaskESDfilter::~AliAnalysisTaskESDfilter(){\r
+  if(fIsPidOwner)delete fESDpid;\r
+}\r
 //______________________________________________________________________________\r
 void AliAnalysisTaskESDfilter::UserCreateOutputObjects()\r
 {\r
@@ -258,7 +260,7 @@ AliAODHeader* AliAnalysisTaskESDfilter::ConvertHeader(const AliESDEvent& esd)
     \r
     header->SetEventNumberESDFile(esd.GetHeader()->GetEventNumberInFile());\r
     if(const_cast<AliESDEvent&>(esd).GetCentrality()){\r
-      header->SetCentrality(new AliCentrality(*(const_cast<AliESDEvent&>(esd).GetCentrality())));\r
+      header->SetCentrality(const_cast<AliESDEvent&>(esd).GetCentrality());\r
     }\r
     else{\r
       header->SetCentrality(0);\r
@@ -1549,8 +1551,10 @@ void AliAnalysisTaskESDfilter::ConvertESDtoAOD()
   //setting best TOF PID\r
   fESDpid = dynamic_cast<AliESDInputHandler*>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler())->GetESDpid();\r
 \r
-  if ( fIsPidOwner) delete fESDpid;\r
-  \r
+  if ( fIsPidOwner){\r
+    delete fESDpid;\r
+    fESDpid = 0;\r
+  }\r
   if(!fESDpid)\r
   { //in case of no Tender attached \r
     fESDpid = new AliESDpid;\r
index 7fb060a..f625af9 100644 (file)
@@ -26,7 +26,7 @@ class AliAnalysisTaskESDfilter : public AliAnalysisTaskSE
  public:
     AliAnalysisTaskESDfilter();
     AliAnalysisTaskESDfilter(const char* name);
-    virtual ~AliAnalysisTaskESDfilter() {;}
+    virtual ~AliAnalysisTaskESDfilter();
     // Implementation of interface methods
     virtual void   UserCreateOutputObjects();
     virtual void   Init();
index 722a5a1..bc4f2e8 100644 (file)
@@ -368,7 +368,11 @@ void AliAODHeader::RemoveQTheta()
 void AliAODHeader::Clear(Option_t* /*opt*/)
 {
   RemoveQTheta();
-  if (fCentralityP) delete fCentralityP;
+  if (fCentralityP){
+    delete fCentralityP;
+    fCentralityP = 0;
+    fCentrality = -999;
+  }
   return;
 }
 
index f657086..b9c877f 100644 (file)
@@ -105,8 +105,16 @@ class AliAODHeader : public AliVHeader {
   void SetMagneticField(Double_t magFld)       { fMagneticField = magFld; }
   void SetMuonMagFieldScale(Double_t magFldScl){ fMuonMagFieldScale = magFldScl; }
   
-  void SetCentrality(AliCentrality* cent)      { fCentralityP = cent; 
-    if (cent) fCentrality = cent->GetCentralityPercentile("V0M");}
+  void SetCentrality(AliCentrality* cent)      { 
+    if(cent){
+      if(fCentralityP)*fCentralityP = *cent;
+      else fCentralityP = new AliCentrality(*cent);
+      fCentrality = cent->GetCentralityPercentile("V0M");
+    }
+    else{
+      fCentrality = -999;
+    }
+  }
   void SetZDCN1Energy(Double_t n1Energy)       { fZDCN1Energy = n1Energy; }
   void SetZDCP1Energy(Double_t p1Energy)       { fZDCP1Energy = p1Energy; }
   void SetZDCN2Energy(Double_t n2Energy)       { fZDCN2Energy = n2Energy; }