]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Minimizing the number of delete for TClonesArray, as per OCT request
authorlaphecet <laphecet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 29 May 2008 16:08:00 +0000 (16:08 +0000)
committerlaphecet <laphecet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 29 May 2008 16:08:00 +0000 (16:08 +0000)
MUON/AliMUONDigitizerV3.cxx
MUON/AliMUONDigitizerV3.h
MUON/AliMUONPreClusterFinder.cxx
MUON/AliMUONPreClusterFinder.h
MUON/AliMUONReconstructor.cxx
MUON/AliMUONReconstructor.h

index f61e3294493869bb60a0ad2e27162361be10cf95..f2c93b63a1a0020fab64fdb3df15ff0fa77e4b86 100644 (file)
@@ -104,7 +104,8 @@ fGenerateNoisyDigits(generateNoisyDigits),
 fLogger(new AliMUONLogger(1000)),
 fTriggerStore(new AliMUONTriggerStoreV1),
 fDigitStore(0x0),
-fOutputDigitStore(0x0)
+fOutputDigitStore(0x0),
+fInputDigitStore(0x0)
 {
   /// Ctor.
 
@@ -125,7 +126,8 @@ AliMUONDigitizerV3::~AliMUONDigitizerV3()
   delete fTriggerStore;
   delete fDigitStore;
   delete fOutputDigitStore;
-   
+  delete fInputDigitStore;
+  
   AliInfo("Summary of messages");
   fLogger->Print();
   
@@ -327,6 +329,43 @@ AliMUONDigitizerV3::DecalibrateTrackerDigit(const AliMUONVCalibParam& pedestals,
   return adc;
 }
 
+//_____________________________________________________________________________
+void
+AliMUONDigitizerV3::CreateInputDigitStore()
+{
+  /// Create an input digit store, and check that all input files
+  /// actually contains the same type of AliMUONVDigitStore
+  
+  fInputDigitStore = 0x0;
+  
+  for ( Int_t iFile = 0; iFile < fManager->GetNinputs(); ++iFile )
+  {    
+    AliLoader* inputLoader = GetLoader(fManager->GetInputFolderName(iFile));
+    
+    inputLoader->LoadSDigits("READ");
+    
+    TTree* iTreeS = inputLoader->TreeS();
+    if (!iTreeS)
+    {
+      AliFatal(Form("Could not get access to input file #%d",iFile));
+    }
+    
+    AliMUONVDigitStore* inputStore = AliMUONVDigitStore::Create(*iTreeS);
+    
+    if (!fInputDigitStore)
+    {
+      fInputDigitStore = inputStore;
+    }
+    else
+    {
+      if ( inputStore->IsA() != fInputDigitStore->IsA() )
+      {
+        AliFatal("Got different types of AliMUONVDigitStore here. Please implement me.");
+      }
+    }
+  }
+}
+
 //_____________________________________________________________________________
 void
 AliMUONDigitizerV3::Exec(Option_t*)
@@ -380,17 +419,20 @@ AliMUONDigitizerV3::Exec(Option_t*)
     {
       AliFatal(Form("Could not get access to input file #%d",iFile));
     }
-    
-    AliMUONVDigitStore* inputStore = AliMUONVDigitStore::Create(*iTreeS);
-    inputStore->Connect(*iTreeS);
+
+    if (!fInputDigitStore)
+    {
+      CreateInputDigitStore();
+    }
+    fInputDigitStore->Connect(*iTreeS);
     
     iTreeS->GetEvent(0);
     
-    MergeWithSDigits(fDigitStore,*inputStore,fManager->GetMask(iFile));
+    MergeWithSDigits(fDigitStore,*fInputDigitStore,fManager->GetMask(iFile));
 
     inputLoader->UnloadSDigits();
     
-    delete inputStore;
+    fInputDigitStore->Clear();
   }
   
   // At this point, we do have digit arrays (one per chamber) which contains 
index ae5124ddf1af0dba5c4fcebac9f8af04546bc763..bad43a58a7ae74cfb75581bb03162e81a80d443b 100644 (file)
@@ -46,7 +46,7 @@ public:
                                        Bool_t addNoise=kFALSE,
                                        Bool_t noiseOnly=kFALSE);
   
-         /// Set calibration data
+  /// Set calibration data
   void SetCalibrationData(AliMUONCalibrationData* calibrationData) 
                           {fCalibrationData = calibrationData;}
   
@@ -75,6 +75,8 @@ private:
   
   static TF1* NoiseFunction();
   
+  void CreateInputDigitStore();
+
 private:
   Bool_t fIsInitialized; ///< are we initialized ?
   AliMUONCalibrationData* fCalibrationData; //!< pointer to access calib parameters
@@ -87,8 +89,9 @@ private:
   AliMUONVTriggerStore* fTriggerStore; //!< trigger objects
   AliMUONVDigitStore* fDigitStore; //!< temporary digits
   AliMUONVDigitStore* fOutputDigitStore; //!< digits we'll output to disk
-
-  ClassDef(AliMUONDigitizerV3,7) // MUON Digitizer V3-5
+  AliMUONVDigitStore* fInputDigitStore; //!< input digit store
+  
+  ClassDef(AliMUONDigitizerV3,8) // MUON Digitizer V3-8
 };
 
 #endif
index dad97fa7aeeea6589731b396c78b1fb92a274da5..5919fc22252aff86048da74577e45574ced024ba 100644 (file)
@@ -47,7 +47,7 @@ ClassImp(AliMUONPreClusterFinder)
 //_____________________________________________________________________________
 AliMUONPreClusterFinder::AliMUONPreClusterFinder()
 : AliMUONVClusterFinder(),
-  fClusters(0x0),
+  fClusters("AliMUONCluster"),
   fPads(0x0),
   fDetElemId(0),
   fArea(),
@@ -60,7 +60,6 @@ AliMUONPreClusterFinder::AliMUONPreClusterFinder()
 AliMUONPreClusterFinder::~AliMUONPreClusterFinder()
 {
   /// dtor : note we're owner of the clusters, but not of the pads
-  delete fClusters;
 }
 
 //_____________________________________________________________________________
@@ -87,10 +86,9 @@ AliMUONPreClusterFinder::Prepare(Int_t detElemId,
                                  const AliMpArea& area)
 {
   /// Prepare for clustering, by giving access to segmentations and digit lists
-  
-  delete fClusters;
-  fClusters = new TClonesArray("AliMUONCluster");
 
+  fClusters.Clear("C");
+  
   fPads = pads;
   fDetElemId = detElemId;
   fArea = area;
@@ -197,8 +195,8 @@ AliMUONPreClusterFinder::NextCluster()
 //  AliCodeTimerAuto("pre-clustering")
   
   // Start a new cluster
-  Int_t id = fClusters->GetLast()+1;
-  AliMUONCluster* cluster = new ((*fClusters)[id]) AliMUONCluster;
+  Int_t id = fClusters.GetLast()+1;
+  AliMUONCluster* cluster = new (fClusters[id]) AliMUONCluster;
   cluster->SetUniqueID(id);
   
   AliMUONPad* pad = GetNextPad(0);
@@ -240,8 +238,8 @@ AliMUONPreClusterFinder::NextCluster()
   if ( ShouldAbort() ) 
   {
     AliError("Aborting clustering of that DE because we've got too many pads");
-    fClusters->Remove(cluster);
-    fClusters->Compress();
+    fClusters.Remove(cluster);
+    fClusters.Compress();
     return 0x0;
   }
   
@@ -254,8 +252,8 @@ AliMUONPreClusterFinder::NextCluster()
     }
     // else only 1 pad (not suspicious, but kind of useless, probably noise)
     // so we remove it from our list
-    fClusters->Remove(cluster);
-    fClusters->Compress();
+    fClusters.Remove(cluster);
+    fClusters.Compress();
     // then proceed further
     return NextCluster();
   }
index 6ff9f7f4914f656901a9c6e0ac73e2d55b2f78a4..06823bc465dab76a766c7cc82a8a424d6d79d185 100644 (file)
@@ -18,6 +18,9 @@
 #ifndef ALI_MP_AREA_H
 #  include "AliMpArea.h"
 #endif
+#ifndef ROOT_TClonesArray
+#  include <TClonesArray.h>
+#endif
 
 class TStopwatch;
 class AliMUONPad;
@@ -52,13 +55,13 @@ private:
   virtual Bool_t ShouldAbort() const { return fShouldAbort; }
   
 private:
-  TClonesArray* fClusters; //!< the clusters we've found (owner)
+  TClonesArray fClusters; //!< the clusters we've found (owner)
   TClonesArray** fPads; //!< the pads corresponding to the digits (not owner)
   Int_t fDetElemId; //!< which DE we're considering
   AliMpArea fArea; //!< area into which to consider pads to *start* a cluster
   Bool_t fShouldAbort; //!< to indicate clustering should stop right now
   
-  ClassDef(AliMUONPreClusterFinder,3) // A basic pre-cluster finder
+  ClassDef(AliMUONPreClusterFinder,4) // A basic pre-cluster finder
 };
 
 #endif
index a34ce6ae94bbc8fc11e5aef239a03f21d72a7106..8e84a4ea88b6aa81e15577b25b41693dce898881 100644 (file)
@@ -142,7 +142,8 @@ fCalibrationData(0x0),
 fDigitCalibrator(0x0),
 fClusterServer(0x0),
 fTriggerStore(0x0),
-fTrackStore(0x0)
+fTrackStore(0x0),
+fClusterStore(0x0)
 {
   /// normal ctor
 
@@ -169,6 +170,7 @@ AliMUONReconstructor::~AliMUONReconstructor()
   delete fClusterServer;
   delete fTriggerStore;
   delete fTrackStore;
+  delete fClusterStore;
 }
 
 //_____________________________________________________________________________
@@ -531,11 +533,12 @@ AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
     }
   }
 
-  AliMUONVClusterStore* clusterStore(0x0);
-  
   if ( !alone )
   {
-    clusterStore = new AliMUONClusterStoreV2;
+    if (!fClusterStore)
+    {
+      fClusterStore = new AliMUONClusterStoreV2;
+    }
     
     CreateClusterServer();
     
@@ -552,17 +555,17 @@ AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
       {
         if ( i >= 6 && AliMUONReconstructor::GetRecoParam()->BypassSt45() ) continue;
         
-        fClusterServer->Clusterize(i,*clusterStore,area);
+        fClusterServer->Clusterize(i,*fClusterStore,area);
       }
     }
     
-    Bool_t cok = clusterStore->Connect(clustersTree,alone);
+    Bool_t cok = fClusterStore->Connect(clustersTree,alone);
     
     if (!cok) AliError("Could not connect clusterStore to clusterTree");
     
-    AliDebug(1,Form("Number of clusters found = %d",clusterStore->GetSize()));
+    AliDebug(1,Form("Number of clusters found = %d",fClusterStore->GetSize()));
     
-    StdoutToAliDebug(1,clusterStore->Print());
+    StdoutToAliDebug(1,fClusterStore->Print());
   }
          
   if (ok) // at least one type of branches created successfully
@@ -570,7 +573,7 @@ AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
     clustersTree.Fill();
   }
   
-  delete clusterStore;
+  fClusterStore->Clear();
 }
 
 //_____________________________________________________________________________
index cfd199de61544cf1d0003baf0f02f148ae619e81..74c34d4c8077ca3d5fb3909161cc638293b83afc 100644 (file)
 #  include "AliReconstructor.h"
 #endif
 
+class AliMUONCalibrationData;
+class AliMUONDigitCalibrator;
 class AliMUONDigitMaker;
-class AliMUONVDigitStore;
-class AliMUONVTriggerStore;
-
 class AliMUONGeometryTransformer;
-
-class AliMUONTriggerCircuit;
-class TClonesArray;
-class AliMUONVTriggerStore;
-
-class AliMUONDigitCalibrator;
-class AliMUONCalibrationData;
-
-class AliMUONTracker;
-class AliMUONVTrackStore;
-
 class AliMUONRecoParam;
-
+class AliMUONTracker;
+class AliMUONTriggerCircuit;
 class AliMUONVClusterFinder;
-
 class AliMUONVClusterServer;
+class AliMUONVClusterStore;
+class AliMUONVDigitStore;
+class AliMUONVTrackStore;
+class AliMUONVTriggerStore;
+class AliMUONVTriggerStore;
+class TClonesArray;
 
 class AliMUONReconstructor : public AliReconstructor
 {
@@ -89,10 +83,11 @@ private:
   mutable AliMUONVClusterServer* fClusterServer; //!<  Clusterizer
   mutable AliMUONVTriggerStore* fTriggerStore; //!< Trigger container
   mutable AliMUONVTrackStore* fTrackStore; //!< Track container
+  mutable AliMUONVClusterStore* fClusterStore; //!< cluster store (when not in combined tracking mode)
   
   static AliMUONRecoParam* fgRecoParam; //!< parameters used to tune the MUON reconstruction
-  
-  ClassDef(AliMUONReconstructor,6) // Implementation of AliReconstructor
+    
+  ClassDef(AliMUONReconstructor,7) // Implementation of AliReconstructor
 };
 
 #endif