From 0c978ad5f69462dfb3e77bd2602760410cecbab8 Mon Sep 17 00:00:00 2001 From: gconesab Date: Thu, 17 Jun 2010 14:26:30 +0000 Subject: [PATCH] -mavoid creation-deletion of TClonesArray per event --- EMCAL/AliEMCALLoader.cxx | 56 ++++++++++++++++++++++++++-------------- EMCAL/AliEMCALLoader.h | 5 ++-- 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/EMCAL/AliEMCALLoader.cxx b/EMCAL/AliEMCALLoader.cxx index 4ebcd6a5796..5f12d827bd2 100644 --- a/EMCAL/AliEMCALLoader.cxx +++ b/EMCAL/AliEMCALLoader.cxx @@ -61,38 +61,56 @@ AliEMCALSimParam* AliEMCALLoader::fgSimParam = 0; //simulation parameters //____________________________________________________________________________ AliEMCALLoader::AliEMCALLoader() - : fDebug(0) +: fDebug(0), fTempArr(0x0) { //Default constructor for EMCAL Loader Class - + fTempArr = new TClonesArray("AliEMCALHit",0); + } //____________________________________________________________________________ AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfoldername) - : AliLoader(detname,eventfoldername), fDebug(0) + : AliLoader(detname,eventfoldername), fDebug(0), fTempArr(0x0) { //Specific constructor for EMCAL Loader class + fTempArr = new TClonesArray("AliEMCALHit",0); + } //____________________________________________________________________________ AliEMCALLoader::AliEMCALLoader(const Char_t *name, TFolder *topfolder) - : AliLoader(name,topfolder), fDebug(0) + : AliLoader(name,topfolder), fDebug(0), fTempArr(0x0) { //Specific constructor for EMCAL Loader class + fTempArr = new TClonesArray("AliEMCALHit",0); + } //____________________________________________________________________________ AliEMCALLoader::~AliEMCALLoader() { // Disconnect trees and remove arrays - if (TreeH()) - TreeH()->SetBranchAddress(fDetectorName,0); - if (TreeD()) - TreeD()->SetBranchAddress(fDetectorName,0); - if (TreeS()) - TreeS()->SetBranchAddress(fDetectorName,0); - if (TreeR()) - TreeR()->SetBranchAddress(fgkECARecPointsBranchName,0); +// if (TreeH()) +// TreeH()->SetBranchAddress(fDetectorName,0); +// if (TreeD()) +// TreeD()->SetBranchAddress(fDetectorName,0); +// if (TreeS()) +// TreeS()->SetBranchAddress(fDetectorName,0); +// if (TreeR()) +// TreeR()->SetBranchAddress(fgkECARecPointsBranchName,0); + + Clean(fgkECAHitsBranchName); + Clean(fgkECASDigitsBranchName); + Clean(fgkECADigitsBranchName); + Clean(fgkECARecPointsBranchName); + + AliLoader::CleanFolders(); + + if (fTempArr) { + fTempArr->Delete(); + delete fTempArr; + } + } //____________________________________________________________________________ @@ -173,24 +191,22 @@ Int_t AliEMCALLoader::GetEvent() if (treeH) { Int_t nEnt = treeH->GetEntries(); // TreeH has array of hits for every primary Int_t index = 0; - TClonesArray *tempArr = 0x0; TBranch * branchH = treeH->GetBranch(fDetectorName); - branchH->SetAddress(&tempArr); + branchH->SetAddress(&fTempArr); TClonesArray* hits = const_cast(this)->Hits(); if (hits) hits->Clear(); for (Int_t iEnt = 0; iEnt < nEnt; iEnt++) { branchH->GetEntry(iEnt); - Int_t nHit = tempArr->GetEntriesFast(); + Int_t nHit = fTempArr->GetEntriesFast(); for (Int_t iHit = 0; iHit < nHit; iHit++) { - new ((*hits)[index]) AliEMCALHit(*((AliEMCALHit*)tempArr->At(iHit))); + new ((*hits)[index]) AliEMCALHit(*((AliEMCALHit*)fTempArr->At(iHit))); index++; } } branchH->ResetAddress(); - if (tempArr) { - tempArr->Delete(); - delete tempArr; - } + if (fTempArr) { + fTempArr->Clear(); + } } // *** SDigits *** diff --git a/EMCAL/AliEMCALLoader.h b/EMCAL/AliEMCALLoader.h index 9f0ae431027..fe351e34d7a 100644 --- a/EMCAL/AliEMCALLoader.h +++ b/EMCAL/AliEMCALLoader.h @@ -114,12 +114,13 @@ class AliEMCALLoader : public AliLoader { static const TString fgkECARecPointsBranchName; //! Name of branch with ECA Reconstructed Points Int_t fDebug ; // Debug level - + TClonesArray *fTempArr; //! Temporary array for hits + static AliEMCALCalibData * fgCalibData; // calibration data // static AliCaloCalibPedestal * fgCaloPed; // dead map static AliEMCALSimParam * fgSimParam; // sim param - ClassDef(AliEMCALLoader,5) // Algorithm class that provides methods to retrieve objects from a list knowing the index + ClassDef(AliEMCALLoader,6) // Algorithm class that provides methods to retrieve objects from a list knowing the index }; -- 2.31.1