From: laphecet Date: Thu, 29 May 2008 16:08:00 +0000 (+0000) Subject: Minimizing the number of delete for TClonesArray, as per OCT request X-Git-Url: http://git.uio.no/git/?a=commitdiff_plain;h=9ec6a94847017334b64cf153973a7be8abff6935;p=u%2Fmrichter%2FAliRoot.git Minimizing the number of delete for TClonesArray, as per OCT request --- diff --git a/MUON/AliMUONDigitizerV3.cxx b/MUON/AliMUONDigitizerV3.cxx index f61e3294493..f2c93b63a1a 100644 --- a/MUON/AliMUONDigitizerV3.cxx +++ b/MUON/AliMUONDigitizerV3.cxx @@ -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 diff --git a/MUON/AliMUONDigitizerV3.h b/MUON/AliMUONDigitizerV3.h index ae5124ddf1a..bad43a58a7a 100644 --- a/MUON/AliMUONDigitizerV3.h +++ b/MUON/AliMUONDigitizerV3.h @@ -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 diff --git a/MUON/AliMUONPreClusterFinder.cxx b/MUON/AliMUONPreClusterFinder.cxx index dad97fa7aee..5919fc22252 100644 --- a/MUON/AliMUONPreClusterFinder.cxx +++ b/MUON/AliMUONPreClusterFinder.cxx @@ -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(); } diff --git a/MUON/AliMUONPreClusterFinder.h b/MUON/AliMUONPreClusterFinder.h index 6ff9f7f4914..06823bc465d 100644 --- a/MUON/AliMUONPreClusterFinder.h +++ b/MUON/AliMUONPreClusterFinder.h @@ -18,6 +18,9 @@ #ifndef ALI_MP_AREA_H # include "AliMpArea.h" #endif +#ifndef ROOT_TClonesArray +# include +#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 diff --git a/MUON/AliMUONReconstructor.cxx b/MUON/AliMUONReconstructor.cxx index a34ce6ae94b..8e84a4ea88b 100644 --- a/MUON/AliMUONReconstructor.cxx +++ b/MUON/AliMUONReconstructor.cxx @@ -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(); } //_____________________________________________________________________________ diff --git a/MUON/AliMUONReconstructor.h b/MUON/AliMUONReconstructor.h index cfd199de615..74c34d4c807 100644 --- a/MUON/AliMUONReconstructor.h +++ b/MUON/AliMUONReconstructor.h @@ -16,27 +16,21 @@ # 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