]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Various code optimization:
authorkharlov <kharlov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 3 May 2008 17:36:38 +0000 (17:36 +0000)
committerkharlov <kharlov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 3 May 2008 17:36:38 +0000 (17:36 +0000)
Creation of TClonesArray and AliPHOSClusterizerv1 once per run instead of once per event.

PHOS/AliPHOSClusterizer.cxx
PHOS/AliPHOSClusterizerv1.cxx
PHOS/AliPHOSLoader.cxx
PHOS/AliPHOSLoader.h
PHOS/AliPHOSQADataMakerSim.cxx
PHOS/AliPHOSQADataMakerSim.h
PHOS/AliPHOSReconstructor.cxx
PHOS/AliPHOSReconstructor.h

index 3b5af58d27cc1f5760f09191f143acfe4d36291f..4e3bf42a1e73d918ae3cca3700c6eb6956d97ebc 100644 (file)
@@ -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);
 }
index c3fcae525579f0714f80fa8e74420b541c20f76e..9db0db353d45bc9a0f0f0053f41575f728b8f519 100644 (file)
@@ -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<TClonesArray*>( fDigitsArr->Clone() ) ;
  
   // Clusterization starts  
index 5c0502a324ee3ae3c09f7fc2988f02520c693ad5..bd88259f52f6323e8ebb30ef860498dd1565af66 100644 (file)
@@ -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<TClonesArray*>(*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;
 }
 //____________________________________________________________________________ 
index d086278768c5fbba3086eb6eaa1bdc1e4d26e9fb..c6ea78badfa6d12f46e05521e6c7b45fdd417bfd 100644 (file)
@@ -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 
 
 };
 
index 80e8270b057469918a9d6d2f76bdc99d5ccaebdf..ef32ecc059c4c0cb43871d284179a26e2a775a07 100644 (file)
 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<AliPHOSHit *>(next())) ) {
-      GetHitsData(0)->Fill( hit->GetEnergy()) ;
-    }
+  //make QA data from Hits
+  
+  TIter next(fHits) ; 
+  AliPHOSHit * hit ; 
+  while ( (hit = dynamic_cast<AliPHOSHit *>(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<AliPHOSHit *> (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) ;
+  }
 }
 
 //____________________________________________________________________________
index c3ce485f27d2cca78ac66617a6a107cbd5166148..1b025a1cb1708369eb6effdd6127d59a1217570d 100644 (file)
@@ -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 
 
 };
 
index 778365aa291cf858e3f49a44e5db05339a2e50b4..ff3366efd1befbce867a269cba176179613ccfd3 100644 (file)
@@ -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();
 }
 
 //____________________________________________________________________________
index c259a0ca6b665f745c7382e468f706d8db6210a7..3421bb084da80ccf6530631a5c60b45cdfc990ac 100644 (file)
@@ -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
 
 };