From 8d8258f61fb4d0b79d3e41f81c0ba74a6c6f4796 Mon Sep 17 00:00:00 2001 From: kharlov Date: Sat, 3 May 2008 17:36:38 +0000 Subject: [PATCH] Various code optimization: Creation of TClonesArray and AliPHOSClusterizerv1 once per run instead of once per event. --- PHOS/AliPHOSClusterizer.cxx | 22 ++++++++--- PHOS/AliPHOSClusterizerv1.cxx | 5 ++- PHOS/AliPHOSLoader.cxx | 63 ++++++++++++++----------------- PHOS/AliPHOSLoader.h | 10 ++--- PHOS/AliPHOSQADataMakerSim.cxx | 68 ++++++++++++++++------------------ PHOS/AliPHOSQADataMakerSim.h | 7 +++- PHOS/AliPHOSReconstructor.cxx | 18 +++++---- PHOS/AliPHOSReconstructor.h | 4 +- 8 files changed, 100 insertions(+), 97 deletions(-) diff --git a/PHOS/AliPHOSClusterizer.cxx b/PHOS/AliPHOSClusterizer.cxx index 3b5af58d27c..4e3bf42a1e7 100644 --- a/PHOS/AliPHOSClusterizer.cxx +++ b/PHOS/AliPHOSClusterizer.cxx @@ -39,6 +39,11 @@ AliPHOSClusterizer::AliPHOSClusterizer(): fCPVRecPoints(0) { // ctor + fDigitsArr = new TClonesArray("AliPHOSDigit",100); + fEMCRecPoints = new TObjArray(100) ; + fEMCRecPoints ->SetName("EMCRECPOINTS") ; + fCPVRecPoints = new TObjArray(100) ; + fCPVRecPoints ->SetName("CPVRECPOINTS") ; } //____________________________________________________________________________ @@ -50,7 +55,11 @@ AliPHOSClusterizer::AliPHOSClusterizer(AliPHOSGeometry *geom): fCPVRecPoints(0) { // ctor - + fDigitsArr = new TClonesArray("AliPHOSDigit",100); + fEMCRecPoints = new TObjArray(100) ; + fEMCRecPoints ->SetName("EMCRECPOINTS") ; + fCPVRecPoints = new TObjArray(100) ; + fCPVRecPoints ->SetName("CPVRECPOINTS") ; } //____________________________________________________________________________ @@ -81,7 +90,7 @@ void AliPHOSClusterizer::SetInput(TTree * digitsTree) AliError("can't get the branch with the PHOS digits !"); return; } - fDigitsArr = new TClonesArray("AliPHOSDigit",100); + fDigitsArr->Clear(); branch->SetAddress(&fDigitsArr); branch->GetEntry(0); } @@ -94,15 +103,16 @@ void AliPHOSClusterizer::SetOutput(TTree * clustersTree) // and set the corresponding branch addresses fTreeR = clustersTree; +// fEMCRecPoints->Clear(); +// fCPVRecPoints->Clear(); + fEMCRecPoints->Delete(); + fCPVRecPoints->Delete(); + AliDebug(9, "Making array for EMC clusters"); - fEMCRecPoints = new TObjArray(100) ; - fEMCRecPoints->SetName("EMCRECPOINTS") ; Int_t split = 0; Int_t bufsize = 32000; fTreeR->Branch("PHOSEmcRP", "TObjArray", &fEMCRecPoints, bufsize, split); AliDebug(9, "Making array for CPV clusters"); - fCPVRecPoints = new TObjArray(100) ; - fCPVRecPoints->SetName("CPVRECPOINTS") ; fTreeR->Branch("PHOSCpvRP", "TObjArray", &fCPVRecPoints, bufsize, split); } diff --git a/PHOS/AliPHOSClusterizerv1.cxx b/PHOS/AliPHOSClusterizerv1.cxx index c3fcae52557..9db0db353d4 100644 --- a/PHOS/AliPHOSClusterizerv1.cxx +++ b/PHOS/AliPHOSClusterizerv1.cxx @@ -261,7 +261,7 @@ void AliPHOSClusterizerv1::Digits2Clusters(Option_t *option) gBenchmark->Stop("PHOSClusterizer"); AliInfo(Form("took %f seconds for Clusterizing\n", gBenchmark->GetCpuTime("PHOSClusterizer"))); - } + } } //____________________________________________________________________________ @@ -532,6 +532,9 @@ void AliPHOSClusterizerv1::MakeClusters() // Steering method to construct the clusters stored in a list of Reconstructed Points // A cluster is defined as a list of neighbour digits + fNumberOfCpvClusters = 0 ; + fNumberOfEmcClusters = 0 ; + TClonesArray * digitsC = static_cast( fDigitsArr->Clone() ) ; // Clusterization starts diff --git a/PHOS/AliPHOSLoader.cxx b/PHOS/AliPHOSLoader.cxx index 5c0502a324e..bd88259f52f 100644 --- a/PHOS/AliPHOSLoader.cxx +++ b/PHOS/AliPHOSLoader.cxx @@ -90,29 +90,31 @@ const TString AliPHOSLoader::fgkCpvRecPointsBranchName("PHOSCpvRP");//Name for b const TString AliPHOSLoader::fgkTrackSegmentsBranchName("PHOSTS");//Name for branch with TrackSegments const TString AliPHOSLoader::fgkRecParticlesBranchName("PHOSRP");//Name for branch with Reconstructed Particles //____________________________________________________________________________ -AliPHOSLoader::AliPHOSLoader() : fBranchTitle(), fcdb(0), fDebug(0) +AliPHOSLoader::AliPHOSLoader() : fBranchTitle(), fcdb(0), fDebug(0), fTmpHits(0x0) { //def ctor + fTmpHits = new TClonesArray("AliPHOSHit",1000); } //____________________________________________________________________________ AliPHOSLoader::AliPHOSLoader(const Char_t *detname,const Char_t *eventfoldername) : AliLoader(detname, eventfoldername), - fBranchTitle(), fcdb(0), fDebug(0) + fBranchTitle(), fcdb(0), fDebug(0), fTmpHits(0x0) { //ctor } //____________________________________________________________________________ AliPHOSLoader::AliPHOSLoader(const Char_t *detname,TFolder *topfolder): - AliLoader(detname,topfolder), - fBranchTitle(), fcdb(0), fDebug(0) + AliLoader(detname,topfolder), + fBranchTitle(), fcdb(0), fDebug(0), fTmpHits(0x0) { //ctor + fTmpHits = new TClonesArray("AliPHOSHit",1000); } //____________________________________________________________________________ AliPHOSLoader::AliPHOSLoader(const AliPHOSLoader & obj): AliLoader(obj),fBranchTitle(obj.GetBranchTitle()),fcdb(obj.CalibrationDB()), - fDebug(obj.GetDebug()) + fDebug(obj.GetDebug()),fTmpHits(obj.fTmpHits) { // Copy constructor } @@ -402,58 +404,47 @@ Int_t AliPHOSLoader::ReadHits() // Reads data from TreeH and stores it in TClonesArray that sits in DetectorDataFolder // TObject** hitref = HitsRef(); - if(hitref == 0x0) - { - MakeHitsArray(); - hitref = HitsRef(); - } + if(hitref == 0x0) { + MakeHitsArray(); + hitref = HitsRef(); + } TClonesArray* hits = dynamic_cast(*hitref); TTree* treeh = TreeH(); - if(treeh == 0) - { + if(treeh == 0) { AliError("Cannot read TreeH from folder"); return 1; } TBranch * hitsbranch = treeh->GetBranch(fDetectorName); - if (hitsbranch == 0) - { + if (hitsbranch == 0) { AliError("Cannot find branch PHOS"); return 1; } AliDebug(1, "Reading Hits"); - if (hitsbranch->GetEntries() > 1) - { - TClonesArray * tempo = new TClonesArray("AliPHOSHit",1000); + if (hitsbranch->GetEntries() > 1) { - hitsbranch->SetAddress(&tempo); + hitsbranch->SetAddress(&fTmpHits); Int_t index = 0 ; - Int_t i = 0 ; - for (i = 0 ; i < hitsbranch->GetEntries(); i++) - { + for (Int_t i = 0 ; i < hitsbranch->GetEntries(); i++) { hitsbranch->GetEntry(i) ; - Int_t j = 0 ; - for ( j = 0 ; j < tempo->GetEntries() ; j++) - { - AliPHOSHit* hit = (AliPHOSHit*)tempo->At(j); - new((*hits)[index]) AliPHOSHit( *hit ) ; - index++ ; - } - } - tempo->Delete(); - delete tempo; - } - else - { + for (Int_t j = 0 ; j < fTmpHits->GetEntriesFast() ; j++) { + AliPHOSHit* hit = (AliPHOSHit*)fTmpHits->At(j); + new((*hits)[index]) AliPHOSHit( *hit ) ; + index++ ; + } + } + fTmpHits->Clear(); + } + else { hitsbranch->SetAddress(hitref); hitsbranch->GetEntry(0) ; - } - + } + return 0; } //____________________________________________________________________________ diff --git a/PHOS/AliPHOSLoader.h b/PHOS/AliPHOSLoader.h index d086278768c..c6ea78badfa 100644 --- a/PHOS/AliPHOSLoader.h +++ b/PHOS/AliPHOSLoader.h @@ -26,7 +26,7 @@ // another set of RecPoints. // // The objects are retrived from folders. -//*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH) +//-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH) // @@ -39,7 +39,6 @@ class TTask ; // --- Standard library --- // --- AliRoot header files --- - #include "AliRun.h" #include "AliLoader.h" #include "AliRunLoader.h" @@ -57,10 +56,6 @@ class AliPHOSCalibrationDB ; class AliPHOSSDigitizer ; class AliPHOSDigitizer ; - - -// - class AliPHOSLoader : public AliLoader { public: @@ -202,6 +197,7 @@ private: Int_t ReadRecParticles(); Int_t fDebug ; // Debug level + TClonesArray *fTmpHits; //! Temporary array of hits per track static const TString fgkHitsName;//Name for TClonesArray with hits from one event static const TString fgkSDigitsName;//Name for TClonesArray @@ -217,7 +213,7 @@ private: static const TString fgkRecParticlesBranchName;//Name for branch - ClassDef(AliPHOSLoader,3) // Algorithm class that provides methods to retrieve objects from a list knowing the index + ClassDef(AliPHOSLoader,4) // Algorithm class that provides methods to retrieve objects from a list knowing the index }; diff --git a/PHOS/AliPHOSQADataMakerSim.cxx b/PHOS/AliPHOSQADataMakerSim.cxx index 80e8270b057..ef32ecc059c 100644 --- a/PHOS/AliPHOSQADataMakerSim.cxx +++ b/PHOS/AliPHOSQADataMakerSim.cxx @@ -43,19 +43,23 @@ ClassImp(AliPHOSQADataMakerSim) //____________________________________________________________________________ - AliPHOSQADataMakerSim::AliPHOSQADataMakerSim() : - AliQADataMakerSim(AliQA::GetDetName(AliQA::kPHOS), "PHOS Quality Assurance Data Maker") +AliPHOSQADataMakerSim::AliPHOSQADataMakerSim() : + AliQADataMakerSim(AliQA::GetDetName(AliQA::kPHOS), "PHOS Quality Assurance Data Maker"), + fHits(0x0) { // ctor + fHits = new TClonesArray("AliPHOSHit", 1000); } //____________________________________________________________________________ AliPHOSQADataMakerSim::AliPHOSQADataMakerSim(const AliPHOSQADataMakerSim& qadm) : - AliQADataMakerSim() + AliQADataMakerSim(), + fHits(0x0) { //copy ctor SetName((const char*)qadm.GetName()) ; SetTitle((const char*)qadm.GetTitle()); + fHits = new TClonesArray("AliPHOSHit", 1000); } //__________________________________________________________________ @@ -82,7 +86,7 @@ void AliPHOSQADataMakerSim::InitHits() TH1F * h0 = new TH1F("hPhosHits", "Hits energy distribution in PHOS", 100, 0., 100.) ; h0->Sumw2() ; Add2HitsList(h0, 0) ; - TH1I * h1 = new TH1I("hPhosHitsMul", "Hits multiplicity distribution in PHOS", 500, 0., 10000) ; + TH1I * h1 = new TH1I("hPhosHitsMul", "Hits multiplicity distribution in PHOS", 500, 0., 10000) ; h1->Sumw2() ; Add2HitsList(h1, 1) ; } @@ -112,44 +116,36 @@ void AliPHOSQADataMakerSim::InitSDigits() } //____________________________________________________________________________ -void AliPHOSQADataMakerSim::MakeHits(TClonesArray * hits) +void AliPHOSQADataMakerSim::MakeHits() { - //make QA data from Hits - - GetHitsData(1)->Fill(hits->GetEntriesFast()) ; - TIter next(hits) ; - AliPHOSHit * hit ; - while ( (hit = dynamic_cast(next())) ) { - GetHitsData(0)->Fill( hit->GetEnergy()) ; - } + //make QA data from Hits + + TIter next(fHits) ; + AliPHOSHit * hit ; + while ( (hit = dynamic_cast(next())) ) { + GetHitsData(0)->Fill( hit->GetEnergy()) ; + } } //____________________________________________________________________________ void AliPHOSQADataMakerSim::MakeHits(TTree * hitTree) { - // make QA data from Hit Tree - - TClonesArray * hits = new TClonesArray("AliPHOSHit", 1000); - - TBranch * branch = hitTree->GetBranch("PHOS") ; - if ( ! branch ) { - AliWarning("PHOS branch in Hit Tree not found") ; - } else { - TClonesArray * tmp = new TClonesArray("AliPHOSHit", 1000) ; - branch->SetAddress(&tmp) ; - Int_t index = 0 ; - for (Int_t ientry = 0 ; ientry < branch->GetEntries() ; ientry++) { - branch->GetEntry(ientry) ; - for (Int_t ihit = 0 ; ihit < tmp->GetEntries() ; ihit++) { - AliPHOSHit * hit = dynamic_cast (tmp->At(ihit)) ; - new((*hits)[index]) AliPHOSHit(*hit) ; - index++ ; - } - } - tmp->Delete() ; - delete tmp ; - MakeHits(hits) ; - } + // make QA data from Hit Tree + + TBranch * branch = hitTree->GetBranch("PHOS") ; + if ( ! branch ) { + AliWarning("PHOS branch in Hit Tree not found") ; + } else { + Int_t nHits = 0; + branch->SetAddress(&fHits) ; + for (Int_t ientry = 0 ; ientry < branch->GetEntries() ; ientry++) { + branch->GetEntry(ientry) ; + nHits += fHits->GetEntriesFast(); + MakeHits() ; + fHits->Clear(); + } + GetHitsData(1)->Fill(nHits) ; + } } //____________________________________________________________________________ diff --git a/PHOS/AliPHOSQADataMakerSim.h b/PHOS/AliPHOSQADataMakerSim.h index c3ce485f27d..1b025a1cb17 100644 --- a/PHOS/AliPHOSQADataMakerSim.h +++ b/PHOS/AliPHOSQADataMakerSim.h @@ -36,7 +36,7 @@ private: virtual void InitHits() ; virtual void InitDigits() ; virtual void InitSDigits() ; - virtual void MakeHits(TClonesArray * hits) ; + void MakeHits() ; virtual void MakeHits(TTree * hitTree) ; virtual void MakeDigits(TClonesArray * digits) ; virtual void MakeDigits(TTree * digitTree) ; @@ -44,7 +44,10 @@ private: virtual void MakeSDigits(TTree * sigitTree) ; virtual void StartOfDetectorCycle() ; - ClassDef(AliPHOSQADataMakerSim,1) // description +private: + TClonesArray * fHits; //!Array of PHOS hits + + ClassDef(AliPHOSQADataMakerSim,2) // description }; diff --git a/PHOS/AliPHOSReconstructor.cxx b/PHOS/AliPHOSReconstructor.cxx index 778365aa291..ff3366efd1b 100644 --- a/PHOS/AliPHOSReconstructor.cxx +++ b/PHOS/AliPHOSReconstructor.cxx @@ -22,7 +22,7 @@ // derived from STEER/AliReconstructor. // // --- ROOT system --- - +#include "TObjectTable.h" // --- Standard library --- // --- AliRoot header files --- @@ -60,7 +60,7 @@ AliPHOSRecoParam* AliPHOSReconstructor::fgkRecoParamCpv =0; // CPV rec. paramet //____________________________________________________________________________ AliPHOSReconstructor::AliPHOSReconstructor() : - fGeom(NULL) + fGeom(NULL),fClusterizer(NULL) { // ctor @@ -74,7 +74,8 @@ AliPHOSReconstructor::AliPHOSReconstructor() : fgkRecoParamCpv = AliPHOSRecoParamCpv::GetCpvDefaultParameters(); } - fGeom = AliPHOSGeometry::GetInstance("IHEP",""); + fGeom = AliPHOSGeometry::GetInstance("IHEP",""); + fClusterizer = new AliPHOSClusterizerv1(fGeom); } //____________________________________________________________________________ @@ -82,6 +83,7 @@ AliPHOSReconstructor::AliPHOSReconstructor() : { // dtor delete fGeom; + delete fClusterizer; } //____________________________________________________________________________ @@ -92,13 +94,13 @@ void AliPHOSReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) c // segment maker needs access to the AliESDEvent object to retrieve the tracks reconstructed by // the global tracking. - AliPHOSClusterizerv1 clu(fGeom); - clu.SetInput(digitsTree); - clu.SetOutput(clustersTree); + fClusterizer->SetInput(digitsTree); + fClusterizer->SetOutput(clustersTree); if ( Debug() ) - clu.Digits2Clusters("deb all") ; + fClusterizer->Digits2Clusters("deb all") ; else - clu.Digits2Clusters("") ; + fClusterizer->Digits2Clusters("") ; + gObjectTable->Print(); } //____________________________________________________________________________ diff --git a/PHOS/AliPHOSReconstructor.h b/PHOS/AliPHOSReconstructor.h index c259a0ca6b6..3421bb084da 100644 --- a/PHOS/AliPHOSReconstructor.h +++ b/PHOS/AliPHOSReconstructor.h @@ -51,6 +51,7 @@ #include "AliPHOSRecoParamCpv.h" class AliPHOSDigitizer ; class AliPHOSClusterizer ; +class AliPHOSClusterizerv1 ; class AliPHOSTrackSegmentMaker ; class AliPHOSPID ; class AliPHOSSDigitizer ; @@ -121,8 +122,9 @@ private: 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,4) // PHOS Reconstruction class + ClassDef(AliPHOSReconstructor,5) // PHOS Reconstruction class }; -- 2.43.0