From 9517d886fca30a9ee019b29ecd22380bfd69b82e Mon Sep 17 00:00:00 2001 From: jklay Date: Wed, 30 Apr 2008 21:51:00 +0000 Subject: [PATCH] code updates suggested by Federico to improve memory management --- EMCAL/AliEMCALDigitizer.cxx | 46 +++++++++++++++++++++------------ EMCAL/AliEMCALLoader.cxx | 12 +++------ EMCAL/AliEMCALReconstructor.cxx | 18 ++++++++----- EMCAL/AliEMCALReconstructor.h | 4 ++- 4 files changed, 47 insertions(+), 33 deletions(-) diff --git a/EMCAL/AliEMCALDigitizer.cxx b/EMCAL/AliEMCALDigitizer.cxx index ff290568d56..767fdd5cad3 100644 --- a/EMCAL/AliEMCALDigitizer.cxx +++ b/EMCAL/AliEMCALDigitizer.cxx @@ -254,7 +254,7 @@ void AliEMCALDigitizer::Digitize(Int_t event) rl->GetEvent(readEvent); TClonesArray * digits = emcalLoader->Digits() ; - digits->Delete() ; + digits->Delete() ; //JLK why is this created then deleted? // Load Geometry AliEMCALGeometry *geom = 0; @@ -324,7 +324,7 @@ void AliEMCALDigitizer::Digitize(Int_t event) AliEMCALDigit * digit ; AliEMCALDigit * curSDigit ; - TClonesArray * ticks = new TClonesArray("AliEMCALTick",1000) ; + // TClonesArray * ticks = new TClonesArray("AliEMCALTick",1000) ; //Put Noise contribution for(absID = 0; absID < nEMC; absID++){ // Nov 30, 2006 by PAI; was from 1 to nEMC @@ -336,14 +336,22 @@ void AliEMCALDigitizer::Digitize(Int_t event) if(absID==nextSig){ //Add SDigits from all inputs - ticks->Clear() ; - Int_t contrib = 0 ; - Float_t a = digit->GetAmp() ; - Float_t b = TMath::Abs( a /fTimeSignalLength) ; + // ticks->Clear() ; + //Int_t contrib = 0 ; + + //Follow PHOS and comment out this timing model til a better one + //can be developed - JLK 28-Apr-2008 + + //Float_t a = digit->GetAmp() ; + //Float_t b = TMath::Abs( a /fTimeSignalLength) ; //Mark the beginning of the signal - new((*ticks)[contrib++]) AliEMCALTick(digit->GetTime(),0, b); + //new((*ticks)[contrib++]) AliEMCALTick(digit->GetTime(),0, b); //Mark the end of the signal - new((*ticks)[contrib++]) AliEMCALTick(digit->GetTime()+fTimeSignalLength, -a, -b); + //new((*ticks)[contrib++]) AliEMCALTick(digit->GetTime()+fTimeSignalLength, -a, -b); + + // Calculate time as time of the largest digit + Float_t time = digit->GetTime() ; + Float_t eTime= digit->GetAmp() ; // loop over input for(i = 0; i< fInput ; i++){ //loop over (possible) merge sources @@ -360,11 +368,16 @@ void AliEMCALDigitizer::Digitize(Int_t event) else primaryoffset = i ; curSDigit->ShiftPrimary(primaryoffset) ; - - a = curSDigit->GetAmp() ; - b = a /fTimeSignalLength ; - new((*ticks)[contrib++]) AliEMCALTick(curSDigit->GetTime(),0, b); - new((*ticks)[contrib++]) AliEMCALTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b); + + //Remove old timing model - JLK 28-April-2008 + //a = curSDigit->GetAmp() ; + //b = a /fTimeSignalLength ; + //new((*ticks)[contrib++]) AliEMCALTick(curSDigit->GetTime(),0, b); + //new((*ticks)[contrib++]) AliEMCALTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b); + if(curSDigit->GetAmp()>eTime) { + eTime = curSDigit->GetAmp(); + time = curSDigit->GetTime(); + } *digit = *digit + *curSDigit ; //add energies @@ -380,7 +393,8 @@ void AliEMCALDigitizer::Digitize(Int_t event) amp *= static_cast(gRandom->Poisson(fMeanPhotonElectron)) / static_cast(fMeanPhotonElectron) ; //calculate and set time - Float_t time = FrontEdgeTime(ticks) ; + //New timing model needed - JLK 28-April-2008 + //Float_t time = FrontEdgeTime(ticks) ; digit->SetTime(time) ; //Find next signal module @@ -401,8 +415,8 @@ void AliEMCALDigitizer::Digitize(Int_t event) absID, amp, nextSig)); } // for(absID = 1; absID <= nEMC; absID++) - ticks->Delete() ; - delete ticks ; + //ticks->Delete() ; + //delete ticks ; delete sdigArray ; //We should not delete its contents diff --git a/EMCAL/AliEMCALLoader.cxx b/EMCAL/AliEMCALLoader.cxx index 5219e943e58..663f6b95dad 100644 --- a/EMCAL/AliEMCALLoader.cxx +++ b/EMCAL/AliEMCALLoader.cxx @@ -256,9 +256,7 @@ Int_t AliEMCALLoader::GetEvent() TBranch * branchS = treeS->GetBranch(fDetectorName); branchS->ResetAddress(); if (fSDigits) { - fSDigits->Delete(); - delete fSDigits; - fSDigits = 0x0; + fSDigits->Clear(); } branchS->SetAddress(&fSDigits); treeS->GetEvent(0); @@ -270,9 +268,7 @@ Int_t AliEMCALLoader::GetEvent() TBranch * branchD = treeD->GetBranch(fDetectorName); branchD->ResetAddress(); if (fDigits) { - fDigits->Delete(); - delete fDigits; - fDigits = 0x0; + fDigits->Clear(); } branchD->SetAddress(&fDigits); treeD->GetEvent(0); @@ -284,9 +280,7 @@ Int_t AliEMCALLoader::GetEvent() TBranch * branchR = treeR->GetBranch(fgkECARecPointsBranchName); branchR->ResetAddress(); if (fRecPoints) { - fRecPoints->Delete(); - delete fRecPoints; - fRecPoints = 0x0; + fRecPoints->Clear(); } branchR->SetAddress(&fRecPoints); treeR->GetEvent(0); diff --git a/EMCAL/AliEMCALReconstructor.cxx b/EMCAL/AliEMCALReconstructor.cxx index a5a2d6d6fef..7708f9a432b 100644 --- a/EMCAL/AliEMCALReconstructor.cxx +++ b/EMCAL/AliEMCALReconstructor.cxx @@ -61,8 +61,8 @@ ClassImp(AliEMCALReconstructor) AliEMCALRecParam* AliEMCALReconstructor::fgkRecParam = 0; // EMCAL rec. parameters AliEMCALRawUtils* AliEMCALReconstructor::fgRawUtils = 0; // EMCAL raw utilities class +AliEMCALClusterizer* AliEMCALReconstructor::fgClusterizer = 0; // EMCAL clusterizer class TClonesArray* AliEMCALReconstructor::fgDigitsArr = 0; // shoud read just once at event - //____________________________________________________________________________ AliEMCALReconstructor::AliEMCALReconstructor() : fDebug(kFALSE), fList(0), fGeom(0) @@ -71,6 +71,7 @@ AliEMCALReconstructor::AliEMCALReconstructor() InitRecParam(); fgRawUtils = new AliEMCALRawUtils; + fgClusterizer = new AliEMCALClusterizerv1; //To make sure we match with the geometry in a simulation file, //let's try to get it first. If not, take the default geometry @@ -144,15 +145,18 @@ void AliEMCALReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) if(fgDigitsArr && fgDigitsArr->GetEntries()) { - AliEMCALClusterizerv1 clu; - clu.SetInput(digitsTree); - clu.SetOutput(clustersTree); + fgClusterizer->SetInput(digitsTree); + fgClusterizer->SetOutput(clustersTree); + if(Debug()) - clu.Digits2Clusters("deb all") ; + fgClusterizer->Digits2Clusters("deb all") ; else - clu.Digits2Clusters("") ; + fgClusterizer->Digits2Clusters(""); + + fgClusterizer->Clear(); } + } //____________________________________________________________________________ @@ -196,7 +200,6 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree, // Works on the current event // printf(" ## AliEMCALReconstructor::FillESD() is started ### \n "); //return; - const double timeScale = 1.e+11; // transition constant from sec to 0.01 ns //###################################################### //#########Calculate trigger and set trigger info########### @@ -426,6 +429,7 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree, // printf(" ## AliEMCALReconstructor::FillESD() is ended : ncl %i -> %i ### \n ",nClusters, nClustersNew); } +//__________________________________________________________________________ void AliEMCALReconstructor::ReadDigitsArrayFromTree(TTree *digitsTree) const { // See AliEMCALClusterizer::SetInput(TTree *digitsTree); diff --git a/EMCAL/AliEMCALReconstructor.h b/EMCAL/AliEMCALReconstructor.h index a0bcb470b21..da9d138929b 100644 --- a/EMCAL/AliEMCALReconstructor.h +++ b/EMCAL/AliEMCALReconstructor.h @@ -77,15 +77,17 @@ public: private: Bool_t fDebug; //! verbosity controller + TList *fList; //! List of hists (only for trigger now) AliEMCALGeometry *fGeom; // pointer to the EMCAL geometry + static AliEMCALClusterizer* fgClusterizer; // clusterizer static AliEMCALRecParam* fgkRecParam; // reconstruction parameters for EMCAL static AliEMCALRawUtils* fgRawUtils; // raw utilities class - // only need one per reco static TClonesArray* fgDigitsArr; // Array with EMCAL digits - ClassDef(AliEMCALReconstructor,3) // Reconstruction algorithm class (Base Class) + ClassDef(AliEMCALReconstructor,5) // Reconstruction algorithm class (Base Class) }; -- 2.43.0