From e0dc3f7df7a5d1f0605d8373255d7c76d828c7fa Mon Sep 17 00:00:00 2001 From: gconesab Date: Tue, 10 Aug 2010 16:37:58 +0000 Subject: [PATCH] Define Clear for AliEMCALDigits to delete the owned arrays when the TClonesArray Clear is called. change the call to the TClonesArray::Clear to Clear("C") to call the clear of the digits. --- EMCAL/AliEMCALDigit.cxx | 77 +++++++++++++++++++------------- EMCAL/AliEMCALDigit.h | 4 +- EMCAL/AliEMCALDigitizer.cxx | 4 +- EMCAL/AliEMCALLoader.cxx | 4 +- EMCAL/AliEMCALQADataMakerRec.cxx | 2 +- EMCAL/AliEMCALQADataMakerSim.cxx | 4 +- EMCAL/AliEMCALRawDigit.cxx | 12 ++++- EMCAL/AliEMCALRawDigit.h | 2 +- EMCAL/AliEMCALRawUtils.cxx | 2 +- EMCAL/AliEMCALSDigitizer.cxx | 6 +-- 10 files changed, 69 insertions(+), 48 deletions(-) diff --git a/EMCAL/AliEMCALDigit.cxx b/EMCAL/AliEMCALDigit.cxx index 2037198d444..b23fd68a45f 100644 --- a/EMCAL/AliEMCALDigit.cxx +++ b/EMCAL/AliEMCALDigit.cxx @@ -149,17 +149,17 @@ AliEMCALDigit::AliEMCALDigit(const AliEMCALDigit & digit) : AliDigitNew(digit), fAmpFloat(digit.fAmpFloat), fNSamples(digit.fNSamples), - fSamples(0x0), + fSamples(), fNSamplesHG(digit.fNSamplesHG), - fSamplesHG(0x0), + fSamplesHG(), fNprimary(digit.fNprimary), fNMaxPrimary(digit.fNMaxPrimary), - fPrimary(0x0), - fDEPrimary(0x0), + fPrimary(), + fDEPrimary(), fNiparent(digit.fNiparent), fNMaxiparent(digit.fNMaxiparent), - fIparent(0x0), - fDEParent(0x0), + fIparent(), + fDEParent(), fMaxIter(digit.fMaxIter), fTime(digit.fTime), fTimeR(digit.fTimeR), @@ -168,26 +168,31 @@ AliEMCALDigit::AliEMCALDigit(const AliEMCALDigit & digit) fDigitType(digit.fDigitType) { // copy ctor - // data memebrs of the base class (AliNewDigit) fAmp = digit.fAmp ; fId = digit.fId; fIndexInList = digit.fIndexInList ; // data members - if(fNSamples){ + if (fSamples ) delete [] fSamples ; fSamples = NULL ; + if (fSamplesHG ) delete [] fSamplesHG ; fSamplesHG = NULL ; + if (fPrimary ) delete [] fPrimary ; fPrimary = NULL ; + if (fDEPrimary) delete [] fDEPrimary ; fDEPrimary = NULL ; + if (fIparent ) delete [] fIparent ; fIparent = NULL ; + if (fDEParent) delete [] fDEParent ; fDEParent = NULL ; + + if (fNSamples){ fSamples = new Int_t[fNSamples]; for (Int_t i=0; i < digit.fNSamples; i++) fSamples[i] = digit.fSamples[i]; } - else fNSamples = 0; - - if(fNSamplesHG){ + + if (fNSamplesHG){ fSamplesHG = new Int_t[fNSamplesHG]; for (Int_t i=0; i < digit.fNSamplesHG; i++) fSamplesHG[i] = digit.fSamplesHG[i]; } - else fNSamplesHG = 0; - - if(fNMaxPrimary){ + + + if (fNMaxPrimary){ fPrimary = new Int_t [fNMaxPrimary] ; fDEPrimary = new Float_t[fNMaxPrimary] ; for ( Int_t i = 0; i < fNMaxPrimary ; i++) { @@ -195,35 +200,43 @@ AliEMCALDigit::AliEMCALDigit(const AliEMCALDigit & digit) fDEPrimary[i] = digit.fDEPrimary[i] ; } } - else{ - fPrimary = 0 ; - fDEPrimary = 0 ; - - } - if(fNMaxiparent){ + + if (fNMaxiparent){ fIparent = new Int_t [fNMaxiparent] ; fDEParent = new Float_t[fNMaxiparent] ; for (Int_t j = 0; j< fNMaxiparent ; j++) { fIparent[j] = digit.fIparent[j] ; fDEParent[j] = digit.fDEParent[j] ; } - } - else { - fIparent = 0 ; - fDEParent = 0 ; - } + } + } //____________________________________________________________________________ AliEMCALDigit::~AliEMCALDigit() { - // Delete array of primiries if any - delete [] fPrimary ; - delete [] fDEPrimary ; - delete [] fIparent ; - delete [] fDEParent ; - delete [] fSamples; - delete [] fSamplesHG; + // Delete array of primaries if any + + if (fSamples ) delete [] fSamples ; fSamples = NULL ; + if (fSamplesHG ) delete [] fSamplesHG ; fSamplesHG = NULL ; + if (fPrimary ) delete [] fPrimary ; fPrimary = NULL ; + if (fDEPrimary) delete [] fDEPrimary ; fDEPrimary = NULL ; + if (fIparent ) delete [] fIparent ; fIparent = NULL ; + if (fDEParent) delete [] fDEParent ; fDEParent = NULL ; + +} + + +//____________________________________________________________________________ +void AliEMCALDigit::Clear(const Option_t*) +{ + // Delete array of primaries if any + if (fSamples ) delete [] fSamples ; fSamples = NULL ; + if (fSamplesHG ) delete [] fSamplesHG ; fSamplesHG = NULL ; + if (fPrimary ) delete [] fPrimary ; fPrimary = NULL ; + if (fDEPrimary) delete [] fDEPrimary ; fDEPrimary = NULL ; + if (fIparent ) delete [] fIparent ; fIparent = NULL ; + if (fDEParent) delete [] fDEParent ; fDEParent = NULL ; } diff --git a/EMCAL/AliEMCALDigit.h b/EMCAL/AliEMCALDigit.h index 37a52e31fd2..c5771b75662 100644 --- a/EMCAL/AliEMCALDigit.h +++ b/EMCAL/AliEMCALDigit.h @@ -39,9 +39,9 @@ class AliEMCALDigit : public AliDigitNew { AliEMCALDigit operator+(const AliEMCALDigit &rValue) ; AliEMCALDigit operator*(Float_t factor) ; const AliEMCALDigit& operator = (const AliEMCALDigit &) {return *this;} - enum digitType{kUnknown=-1, kHG=0, kLG=1, kLGnoHG=2, kTrigger=3}; - + + void Clear(const Option_t*) ; Int_t Compare(const TObject * obj) const ; Float_t GetAmplitude() const { if(!fAmp)return fAmpFloat ; else return fAmp ;}//Keep backward compatibility. Float_t GetEta() const ; diff --git a/EMCAL/AliEMCALDigitizer.cxx b/EMCAL/AliEMCALDigitizer.cxx index 57201d7c304..6e1685240af 100644 --- a/EMCAL/AliEMCALDigitizer.cxx +++ b/EMCAL/AliEMCALDigitizer.cxx @@ -611,8 +611,8 @@ void AliEMCALDigitizer::Exec(Option_t *option) Unload(); - digitsTRG->Clear(); - digitsTMP->Clear(); + digitsTRG->Clear("C"); + digitsTMP->Clear("C"); //------------------------------------- if(strstr(option,"deb")) diff --git a/EMCAL/AliEMCALLoader.cxx b/EMCAL/AliEMCALLoader.cxx index ff96490a3fc..9c32e91d32a 100644 --- a/EMCAL/AliEMCALLoader.cxx +++ b/EMCAL/AliEMCALLoader.cxx @@ -187,7 +187,7 @@ Int_t AliEMCALLoader::GetEvent() // Reset SDigits array and branch branchS->ResetAddress(); TClonesArray* sdigits = const_cast(this)->SDigits(); - if (sdigits) sdigits->Clear(); + if (sdigits) sdigits->Clear("C"); branchS->SetAddress(&sdigits); branchS->GetEntry(0); @@ -204,7 +204,7 @@ Int_t AliEMCALLoader::GetEvent() // Reset Digits array and branch branchD->ResetAddress(); TClonesArray* digits = const_cast(this)->Digits(); - if (digits) digits->Clear(); + if (digits) digits->Clear("C"); branchD->SetAddress(&digits); branchD->GetEntry(0); diff --git a/EMCAL/AliEMCALQADataMakerRec.cxx b/EMCAL/AliEMCALQADataMakerRec.cxx index ff795839da1..351a2071023 100644 --- a/EMCAL/AliEMCALQADataMakerRec.cxx +++ b/EMCAL/AliEMCALQADataMakerRec.cxx @@ -830,7 +830,7 @@ void AliEMCALQADataMakerRec::MakeDigits(TTree * digitTree) { // makes data from Digit Tree if (fDigitsArray) - fDigitsArray->Clear() ; + fDigitsArray->Clear("C") ; else fDigitsArray = new TClonesArray("AliEMCALDigit", 1000) ; diff --git a/EMCAL/AliEMCALQADataMakerSim.cxx b/EMCAL/AliEMCALQADataMakerSim.cxx index 318bd2b3469..b9e120f7ab3 100644 --- a/EMCAL/AliEMCALQADataMakerSim.cxx +++ b/EMCAL/AliEMCALQADataMakerSim.cxx @@ -176,7 +176,7 @@ void AliEMCALQADataMakerSim::MakeDigits(TTree * digitTree) { // makes data from Digit Tree if (fDigitsArray) - fDigitsArray->Clear() ; + fDigitsArray->Clear("C") ; else fDigitsArray = new TClonesArray("AliEMCALDigit", 1000) ; @@ -215,7 +215,7 @@ void AliEMCALQADataMakerSim::MakeSDigits(TTree * sdigitTree) { // makes data from SDigit Tree if (fSDigitsArray) - fSDigitsArray->Clear() ; + fSDigitsArray->Clear("C") ; else fSDigitsArray = new TClonesArray("AliEMCALDigit", 1000) ; diff --git a/EMCAL/AliEMCALRawDigit.cxx b/EMCAL/AliEMCALRawDigit.cxx index a7a8910a489..970408c6d7f 100644 --- a/EMCAL/AliEMCALRawDigit.cxx +++ b/EMCAL/AliEMCALRawDigit.cxx @@ -64,10 +64,18 @@ fSamples(0x0) //____________________________________________________________________________ AliEMCALRawDigit::~AliEMCALRawDigit() { - // Delete array of time samples - delete [] fSamples; + // Delete array of time samples + delete [] fSamples; } +//____________________________________________________________________________ +void AliEMCALRawDigit::Clear(Option_t *) +{ + // Delete array of time samples + delete [] fSamples; +} + + //____________________________________________________________________________ Bool_t AliEMCALRawDigit::GetTimeSample(const Int_t iSample, Int_t& timeBin, Int_t& amp) const { diff --git a/EMCAL/AliEMCALRawDigit.h b/EMCAL/AliEMCALRawDigit.h index 04c50c1f512..c69b7df8b23 100644 --- a/EMCAL/AliEMCALRawDigit.h +++ b/EMCAL/AliEMCALRawDigit.h @@ -25,7 +25,7 @@ public: AliEMCALRawDigit(const AliEMCALRawDigit& digit); virtual ~AliEMCALRawDigit(); - + void Clear(Option_t *); Bool_t operator==(const AliEMCALRawDigit &rValue) const; const AliEMCALRawDigit& operator = (const AliEMCALRawDigit&) {return *this;} diff --git a/EMCAL/AliEMCALRawUtils.cxx b/EMCAL/AliEMCALRawUtils.cxx index 77d2ee7dbb9..dad0953c2a2 100644 --- a/EMCAL/AliEMCALRawUtils.cxx +++ b/EMCAL/AliEMCALRawUtils.cxx @@ -324,7 +324,7 @@ void AliEMCALRawUtils::Raw2Digits(AliRawReader* reader,TClonesArray *digitsArr, { // convert raw data of the current event to digits - digitsArr->Clear(); + digitsArr->Clear("C"); if (!digitsArr) { Error("Raw2Digits", "no digits found !"); diff --git a/EMCAL/AliEMCALSDigitizer.cxx b/EMCAL/AliEMCALSDigitizer.cxx index 9c6ee153513..86fedf03ed4 100644 --- a/EMCAL/AliEMCALSDigitizer.cxx +++ b/EMCAL/AliEMCALSDigitizer.cxx @@ -272,9 +272,9 @@ void AliEMCALSDigitizer::Exec(Option_t *option) emcalLoader->MakeSDigitsContainer(); treeS = emcalLoader->TreeS(); } - //TClonesArray * hits = emcalLoader->Hits() ; + TClonesArray * sdigits = emcalLoader->SDigits() ; - sdigits->Clear(); + sdigits->Clear("C"); Int_t nSdigits = 0 ; Int_t iHit, iTrack, iSDigit; @@ -487,7 +487,7 @@ void AliEMCALSDigitizer::PrintSDigits(Option_t * option) printf("%s",tempo); } } - delete tempo ; + delete [] tempo ; printf("\n** Sum %2.3f : %10.3f GeV/c **\n ", isum, Calibrate(isum)); } else printf("\n"); } -- 2.39.3