Removing TClonesArray deletions (C.Cheshkov)
authorfca <fca@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 20 Jan 2012 14:14:33 +0000 (14:14 +0000)
committerfca <fca@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 20 Jan 2012 14:14:33 +0000 (14:14 +0000)
RAW/AliRawEquipmentV2.cxx
RAW/AliRawEquipmentV2.h
RAW/AliRawEventV2.cxx
RAW/AliRawEventV2.h
RAW/alirawdump_main.cxx

index 8bd2aed..46c1ba2 100644 (file)
@@ -88,6 +88,17 @@ void AliRawEquipmentV2::Reset()
 }
 
 //______________________________________________________________________________
+void AliRawEquipmentV2::Clear(Option_t*)
+{
+   // Clear the equipment in case it needs to be re-used (avoiding costly
+   // new/delete cycle). Called by AliRawEventV2 Clear method inside the event loop.
+
+   fEqpHdr.Reset();
+   fRawDataRef = NULL;
+   fRawData = NULL;
+}
+
+//______________________________________________________________________________
 AliRawEquipmentV2::~AliRawEquipmentV2()
 {
    // Clean up event object. Delete also, possible, private raw data.
index 9c7b79e..351ec5e 100644 (file)
@@ -49,6 +49,7 @@ public:
    virtual AliRawEquipmentHeader *GetEquipmentHeader();
    virtual AliRawData            *GetRawData();
    void                           Reset();
+   virtual void                          Clear(Option_t* = "");
    AliRawData                    *NextRawData(AliRawDataArrayV2 *array);
 
    virtual void                   CloneRawData(const AliRawData *rawData);
index 5f4d542..a2e0c55 100644 (file)
@@ -215,3 +215,22 @@ AliRawEventV2::~AliRawEventV2()
       fEvtHdrs->Delete();
    delete fEvtHdrs;
 }
+
+//______________________________________________________________________________
+void AliRawEventV2::Clear(Option_t*)
+{
+   // Clear the event in case it needs to be re-used (avoiding costly
+   // new/delete cycle). Can be used inside the event loop.
+
+  fEquipments.Clear("C");
+
+  if (fEvtHdrs) {
+    for (int i = 0; i < fEvtHdrs->GetEntriesFast(); i++) {
+      AliRawEventHeaderBase *hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(i);
+      hdr->Reset();
+    }
+    fEvtHdrs->Clear();
+  }
+  fIndex = 0;
+}
+
index 070dd5f..f6ab8d2 100644 (file)
@@ -60,6 +60,7 @@ public:
    AliRawEventV2                 *NextSubEvent();
    virtual AliRawVEvent          *GetSubEvent(Int_t index);
    void                           Reset();
+   virtual void                          Clear(Option_t* = "");
 
 private:
    TClonesArray           fEquipments;  // AliRawEquipmentV2's
index 464d079..67768b5 100644 (file)
@@ -237,13 +237,16 @@ int main(int argc, char **argv)
   cout << "*******************************************" << endl;
 
   for(Int_t iEvent=0; iEvent < nEvents; iEvent++) {
-    rawEvent=NULL;
+    //    rawEvent=NULL;
     rawTree->GetEntry(iEvent);
     cout << "  *********** Event " << iEvent << " *******" << endl;
     DumpEvent(argv[0],rawEvent);
-    delete rawEvent;
+    //    delete rawEvent;
+    rawEvent->Clear();
   }
 
+  delete rawEvent;
+
   cout << "*******************************************" << endl;
   cout << "EOF" << endl;
   cout << "*******************************************" << endl;