From dcab1c7eb97c945f98bd1cc5bfef755cf03d850f Mon Sep 17 00:00:00 2001 From: kharlov Date: Sat, 10 May 2008 19:18:21 +0000 Subject: [PATCH] AliPHOSTrackSegmentMaker, AliPHOSPID, TClonesArray of EMC and CPV recpoints are created once per run in corresponding constructors, instead of creating them once per event. Memory leaks of AliPHOSEmcRecPoint, AliPHOSCpvRecPoints, AliPHOSRecParticles are fixed. --- PHOS/AliPHOSPID.cxx | 6 ++++-- PHOS/AliPHOSReconstructor.cxx | 35 ++++++++++++++++--------------- PHOS/AliPHOSReconstructor.h | 14 +++++++------ PHOS/AliPHOSTrackSegmentMaker.cxx | 14 +++++++------ 4 files changed, 38 insertions(+), 31 deletions(-) diff --git a/PHOS/AliPHOSPID.cxx b/PHOS/AliPHOSPID.cxx index 95aa0728807..aade7409548 100644 --- a/PHOS/AliPHOSPID.cxx +++ b/PHOS/AliPHOSPID.cxx @@ -65,6 +65,8 @@ AliPHOSPID::AliPHOSPID(AliPHOSGeometry *geom): fRecParticles(NULL) { // ctor + fEMCRecPoints = new TObjArray(100) ; + fCPVRecPoints = new TObjArray(100) ; fRecParticles = new TClonesArray("AliPHOSRecParticle",100) ; fRecParticles->SetName("RECPARTICLES"); @@ -112,8 +114,8 @@ void AliPHOSPID::SetInput(TTree *clustersTree, TClonesArray *trackSegments) AliError("can't get the branch with the PHOS EMC clusters !"); return; } - fEMCRecPoints = new TObjArray(100) ; emcbranch->SetAddress(&fEMCRecPoints); + fEMCRecPoints->Delete(); emcbranch->GetEntry(0); TBranch *cpvbranch = clustersTree->GetBranch("PHOSCpvRP"); @@ -121,7 +123,7 @@ void AliPHOSPID::SetInput(TTree *clustersTree, TClonesArray *trackSegments) AliError("can't get the branch with the PHOS CPV clusters !"); return; } - fCPVRecPoints = new TObjArray(100) ; cpvbranch->SetAddress(&fCPVRecPoints); + fCPVRecPoints->Delete(); cpvbranch->GetEntry(0); } diff --git a/PHOS/AliPHOSReconstructor.cxx b/PHOS/AliPHOSReconstructor.cxx index 813cf1d052f..ac05bbdb4eb 100644 --- a/PHOS/AliPHOSReconstructor.cxx +++ b/PHOS/AliPHOSReconstructor.cxx @@ -60,7 +60,7 @@ AliPHOSRecoParam* AliPHOSReconstructor::fgkRecoParamCpv =0; // CPV rec. paramet //____________________________________________________________________________ AliPHOSReconstructor::AliPHOSReconstructor() : - fGeom(NULL),fClusterizer(NULL) + fGeom(NULL),fClusterizer(NULL),fTSM(NULL),fPID(NULL) { // ctor @@ -75,7 +75,9 @@ AliPHOSReconstructor::AliPHOSReconstructor() : } fGeom = AliPHOSGeometry::GetInstance("IHEP",""); - fClusterizer = new AliPHOSClusterizerv1(fGeom); + fClusterizer = new AliPHOSClusterizerv1 (fGeom); + fTSM = new AliPHOSTrackSegmentMakerv1(fGeom); + fPID = new AliPHOSPIDv1 (fGeom); } //____________________________________________________________________________ @@ -84,6 +86,8 @@ AliPHOSReconstructor::AliPHOSReconstructor() : // dtor delete fGeom; delete fClusterizer; + delete fTSM; + delete fPID; } //____________________________________________________________________________ @@ -110,31 +114,29 @@ void AliPHOSReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree, // then it creates AliESDtracks out of them and // write tracks to the ESD - AliPHOSTrackSegmentMaker *tsm = new AliPHOSTrackSegmentMakerv1(fGeom); - AliPHOSPID *pid = new AliPHOSPIDv1 (fGeom); // do current event; the loop over events is done by AliReconstruction::Run() - tsm->SetESD(esd) ; - tsm->SetInput(clustersTree); + fTSM->SetESD(esd) ; + fTSM->SetInput(clustersTree); if ( Debug() ) - tsm->Clusters2TrackSegments("deb all") ; + fTSM->Clusters2TrackSegments("deb all") ; else - tsm->Clusters2TrackSegments("") ; + fTSM->Clusters2TrackSegments("") ; - pid->SetInput(clustersTree, tsm->GetTrackSegments()) ; - pid->SetESD(esd) ; + fPID->SetInput(clustersTree, fTSM->GetTrackSegments()) ; + fPID->SetESD(esd) ; if ( Debug() ) - pid->TrackSegments2RecParticles("deb all") ; + fPID->TrackSegments2RecParticles("deb all") ; else - pid->TrackSegments2RecParticles("") ; + fPID->TrackSegments2RecParticles("") ; // This function creates AliESDtracks from AliPHOSRecParticles // and // writes them to the ESD - TClonesArray *recParticles = pid->GetRecParticles(); - Int_t nOfRecParticles = recParticles->GetEntries(); + TClonesArray *recParticles = fPID->GetRecParticles(); + Int_t nOfRecParticles = recParticles->GetEntriesFast(); esd->SetNumberOfPHOSClusters(nOfRecParticles) ; esd->SetFirstPHOSCluster(esd->GetNumberOfCaloClusters()) ; @@ -254,7 +256,7 @@ void AliPHOSReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree, if (Debug()) rp->Print(); // Get track segment and EMC rec.point associated with this rec.particle - AliPHOSTrackSegment *ts = static_cast(tsm->GetTrackSegments() + AliPHOSTrackSegment *ts = static_cast(fTSM->GetTrackSegments() ->At(rp->GetPHOSTSIndex())); AliPHOSEmcRecPoint *emcRP = static_cast(emcRecPoints->At(ts->GetEmcIndex())); @@ -326,8 +328,7 @@ void AliPHOSReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree, delete digitsArray; emcRecPoints->Delete(); delete emcRecPoints; - delete tsm; - delete pid; + recParticles->Delete(); } //____________________________________________________________________________ diff --git a/PHOS/AliPHOSReconstructor.h b/PHOS/AliPHOSReconstructor.h index 3421bb084da..ad32c430f17 100644 --- a/PHOS/AliPHOSReconstructor.h +++ b/PHOS/AliPHOSReconstructor.h @@ -119,12 +119,14 @@ public: private: static Bool_t fgDebug ; //! verbosity controller - static AliPHOSRecoParam *fgkRecoParamEmc; // reconstruction parameters for EMC - static AliPHOSRecoParam *fgkRecoParamCpv; // reconstruction parameters for EMC - AliPHOSGeometry *fGeom; // pointer to the PHOS geometry - AliPHOSClusterizerv1 *fClusterizer; //! PHOS clusterizer - - ClassDef(AliPHOSReconstructor,5) // PHOS Reconstruction class + static AliPHOSRecoParam *fgkRecoParamEmc; // reconstruction parameters for EMC + static AliPHOSRecoParam *fgkRecoParamCpv; // reconstruction parameters for EMC + AliPHOSGeometry *fGeom; // pointer to the PHOS geometry + AliPHOSClusterizerv1 *fClusterizer; //! PHOS clusterizer + AliPHOSTrackSegmentMaker *fTSM; //! PHOS TrackSegmentMaker + AliPHOSPID *fPID; //! PHOS PID maker + + ClassDef(AliPHOSReconstructor,6) // PHOS Reconstruction class }; diff --git a/PHOS/AliPHOSTrackSegmentMaker.cxx b/PHOS/AliPHOSTrackSegmentMaker.cxx index fc3c480bfc3..3482f19e829 100644 --- a/PHOS/AliPHOSTrackSegmentMaker.cxx +++ b/PHOS/AliPHOSTrackSegmentMaker.cxx @@ -63,6 +63,8 @@ AliPHOSTrackSegmentMaker:: AliPHOSTrackSegmentMaker() : fCPVRecPoints(0) { // ctor + fEMCRecPoints = new TObjArray(100) ; + fCPVRecPoints = new TObjArray(100) ; } //____________________________________________________________________________ @@ -74,6 +76,8 @@ AliPHOSTrackSegmentMaker::AliPHOSTrackSegmentMaker(AliPHOSGeometry *geom): fCPVRecPoints(0) { // ctor + fEMCRecPoints = new TObjArray(100) ; + fCPVRecPoints = new TObjArray(100) ; } //____________________________________________________________________________ @@ -104,18 +108,16 @@ AliPHOSTrackSegmentMaker::~AliPHOSTrackSegmentMaker() //____________________________________________________________________________ void AliPHOSTrackSegmentMaker::SetInput(TTree *clustersTree) { - // Read the clusters tree and creates the - // arrays with the EMC and CPV - // clusters. - // and set the corresponding branch addresses + // Read the clusters tree and set addresses to the + // arrays with the EMC and CPV clusters TBranch *emcbranch = clustersTree->GetBranch("PHOSEmcRP"); if (!emcbranch) { AliError("can't get the branch with the PHOS EMC clusters !"); return; } - fEMCRecPoints = new TObjArray(100) ; emcbranch->SetAddress(&fEMCRecPoints); + fEMCRecPoints->Delete(); emcbranch->GetEntry(0); TBranch *cpvbranch = clustersTree->GetBranch("PHOSCpvRP"); @@ -123,7 +125,7 @@ void AliPHOSTrackSegmentMaker::SetInput(TTree *clustersTree) AliError("can't get the branch with the PHOS CPV clusters !"); return; } - fCPVRecPoints = new TObjArray(100) ; cpvbranch->SetAddress(&fCPVRecPoints); + fCPVRecPoints->Delete(); cpvbranch->GetEntry(0); } -- 2.43.0