]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliESDEvent.cxx
Fixes for some mem-leaks: most changes where pretty basic (i.e. adding deletes).
[u/mrichter/AliRoot.git] / STEER / AliESDEvent.cxx
index 8e37ef2239f13d60e086b8978a841c717933aafb..0460f61e38d31f179f94ed0e77d909ee02f55611 100644 (file)
@@ -80,6 +80,7 @@ ClassImp(AliESDEvent)
                                                       "AliRawDataErrorLogs"};
 //______________________________________________________________________________
 AliESDEvent::AliESDEvent():
+  AliVEvent(),
   fESDObjects(new TList()),
   fESDRun(0),
   fHeader(0),
@@ -111,7 +112,7 @@ AliESDEvent::AliESDEvent():
 }
 //______________________________________________________________________________
 AliESDEvent::AliESDEvent(const AliESDEvent& esd):
-  TObject(esd),
+  AliVEvent(esd),
   fESDObjects(new TList()),
   fESDRun(new AliESDRun(*esd.fESDRun)),
   fHeader(new AliESDHeader(*esd.fHeader)),
@@ -173,7 +174,7 @@ AliESDEvent & AliESDEvent::operator=(const AliESDEvent& source) {
   // Assignment operator
 
   if(&source == this) return *this;
-  TObject::operator=(source);
+  AliVEvent::operator=(source);
 
   fESDRun = new AliESDRun(*source.fESDRun);
   fHeader = new AliESDHeader(*source.fHeader);
@@ -277,24 +278,29 @@ void AliESDEvent::ResetStdContent()
   if(fESDTZERO) fESDTZERO->Reset(); 
   // CKB no clear/reset implemented
   if(fSPDVertex){
+    fSPDVertex->~AliESDVertex();
     new (fSPDVertex) AliESDVertex();
     fSPDVertex->SetName(fESDListName[kSPDVertex]);
   }
   if(fPrimaryVertex){
+    fPrimaryVertex->~AliESDVertex();
     new (fPrimaryVertex) AliESDVertex();
     fPrimaryVertex->SetName(fESDListName[kPrimaryVertex]);
   }
-  if(fSPDMult)new (fSPDMult) AliMultiplicity();
+  if(fSPDMult){
+    fSPDMult->~AliMultiplicity();
+    new (fSPDMult) AliMultiplicity();
+  }
   if(fPHOSTrigger)fPHOSTrigger->Reset(); 
   if(fEMCALTrigger)fEMCALTrigger->Reset(); 
-  if(fTracks)fTracks->Clear();
+  if(fTracks)fTracks->Delete();
   if(fMuonTracks)fMuonTracks->Clear();
   if(fPmdTracks)fPmdTracks->Clear();
   if(fTrdTracks)fTrdTracks->Clear();
   if(fV0s)fV0s->Clear();
   if(fCascades)fCascades->Clear();
   if(fKinks)fKinks->Clear();
-  if(fCaloClusters)fCaloClusters->Clear();
+  if(fCaloClusters)fCaloClusters->Delete();
   if(fErrorLogs) fErrorLogs->Clear();
 
   // don't reset fconnected fConnected ;
@@ -352,6 +358,8 @@ void AliESDEvent::Print(Option_t *) const
   printf("                 emcal     %d\n", GetNumberOfEMCALClusters());
   printf("                 FMD       %s\n", (fESDFMD ? "yes" : "no"));
   printf("                 VZERO     %s\n", (fESDVZERO ? "yes" : "no"));
+
+  return;
 }
 
 void AliESDEvent::SetESDfriend(const AliESDfriend *ev) {
@@ -372,6 +380,26 @@ void AliESDEvent::SetESDfriend(const AliESDfriend *ev) {
   }
 }
 
+Bool_t  AliESDEvent::RemoveTrack(Int_t /*i*/) {
+  // ---------------------------------------------------------
+  // Remove track
+  // ---------------------------------------------------------
+
+  // Check if this track comes from a reconstructed decay
+  // if (yes) return kFALSE
+
+  // Remap the indices of the daughters of recosntructed decays
+
+  // Remove the track
+  // delete fTracks->RemoveAt(i);
+
+  // Compress the array with tracks
+  // fTracks->Compress();
+
+  return kTRUE;
+}
+
+
 Int_t  AliESDEvent::AddTrack(const AliESDtrack *t) {
     // Add track
     TClonesArray &ftr = *fTracks;
@@ -430,22 +458,21 @@ Int_t AliESDEvent::AddCaloCluster(const AliESDCaloCluster *c) {
 void  AliESDEvent::SetVertex(const AliESDVertex *vertex) {
   // use already allocated space
   if(fSPDVertex){
-    new(fSPDVertex)  AliESDVertex(*vertex);
+    *fSPDVertex = *vertex;
     fSPDVertex->SetName(fESDListName[kSPDVertex]);
   }
 }
 
 void  AliESDEvent::SetPrimaryVertex(const AliESDVertex *vertex) {
-  // use already allocated space
   if(fPrimaryVertex){
-    new(fPrimaryVertex)  AliESDVertex(*vertex);
+    *fPrimaryVertex = *vertex;
     fPrimaryVertex->SetName(fESDListName[kPrimaryVertex]);
   }
 }
 
 void AliESDEvent::SetMultiplicity(const AliMultiplicity *mul) {
   if(fSPDMult){
-    new (&fSPDMult) AliMultiplicity(*mul);
+    *fSPDMult = *mul;
   }
 }
 
@@ -453,7 +480,7 @@ void AliESDEvent::SetMultiplicity(const AliMultiplicity *mul) {
 void AliESDEvent::SetFMDData(AliESDFMD * obj) { 
   // use already allocated space
   if(fESDFMD){
-    new(fESDFMD) AliESDFMD(*obj); 
+    *fESDFMD = *obj;
   }
 }
 
@@ -568,9 +595,6 @@ void AliESDEvent::CreateStdContent()
   SetStdNames();
   // read back pointers
   GetStdContent();
-
-
-
 }
 
 TObject* AliESDEvent::FindListObject(const char *name){
@@ -579,8 +603,10 @@ TObject* AliESDEvent::FindListObject(const char *name){
 } 
 
 void AliESDEvent::ReadFromTree(TTree *tree){
-  
+
+  // load the TTree
+  tree->LoadTree(0);
+
   // if we find the "ESD" branch on the tree we do have the old structure
   if(tree->GetBranch("ESD")){
       char ** address = (char **)(tree->GetBranch("ESD")->GetAddress());
@@ -725,7 +751,7 @@ void AliESDEvent::CopyFromOldESD()
     //  leave amps out
 
     // VZERO
-    SetVZEROData(fESDOld->GetVZEROData());
+    if (fESDOld->GetVZEROData()) SetVZEROData(fESDOld->GetVZEROData());
 
     SetVertex(fESDOld->GetVertex());