From 48f8adf3d97f67b488b48bbcb9e8884db9bd2e45 Mon Sep 17 00:00:00 2001 From: abercuci Date: Wed, 27 Aug 2008 15:41:50 +0000 Subject: [PATCH] fix "cw" option, small memory leak due to cluster array and optimizations for HLT --- TRD/AliTRDReconstructor.cxx | 9 +++++++++ TRD/AliTRDReconstructor.h | 2 +- TRD/AliTRDclusterizer.cxx | 10 +++++++--- TRD/AliTRDtrackerV1.cxx | 31 +++++++++++++++++++++++-------- 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/TRD/AliTRDReconstructor.cxx b/TRD/AliTRDReconstructor.cxx index 4076b24e28c..577b1583e04 100644 --- a/TRD/AliTRDReconstructor.cxx +++ b/TRD/AliTRDReconstructor.cxx @@ -72,6 +72,15 @@ AliTRDReconstructor::AliTRDReconstructor(const AliTRDReconstructor &r) memcpy(fTCParams, r.fTCParams, 8*sizeof(Double_t)); } +//_____________________________________________________________________________ +AliTRDReconstructor::~AliTRDReconstructor() +{ + if(fgClusters) { + fgClusters->Delete(); delete fgClusters; + } +} + + //_____________________________________________________________________________ void AliTRDReconstructor::Init(){ // diff --git a/TRD/AliTRDReconstructor.h b/TRD/AliTRDReconstructor.h index 86538ee31f9..acfbedf6bce 100644 --- a/TRD/AliTRDReconstructor.h +++ b/TRD/AliTRDReconstructor.h @@ -44,7 +44,7 @@ public: AliTRDReconstructor(); AliTRDReconstructor(const AliTRDReconstructor &r); - virtual ~AliTRDReconstructor() {;} + virtual ~AliTRDReconstructor(); AliTRDReconstructor& operator = (const AliTRDReconstructor&) { return *this;} virtual void Init(); diff --git a/TRD/AliTRDclusterizer.cxx b/TRD/AliTRDclusterizer.cxx index dcb73457c5a..fec8c6161bf 100644 --- a/TRD/AliTRDclusterizer.cxx +++ b/TRD/AliTRDclusterizer.cxx @@ -174,7 +174,7 @@ AliTRDclusterizer::~AliTRDclusterizer() // AliTRDclusterizer destructor // - if (fRecPoints && IsClustersOwner()){ + if (fRecPoints/* && IsClustersOwner()*/){ fRecPoints->Delete(); delete fRecPoints; } @@ -1361,8 +1361,8 @@ void AliTRDclusterizer::ResetRecPoints() if (fRecPoints) { fRecPoints->Delete(); + delete fRecPoints; } - } //_____________________________________________________________________________ @@ -1373,7 +1373,11 @@ TClonesArray *AliTRDclusterizer::RecPoints() // if (!fRecPoints) { - fRecPoints = new TClonesArray("AliTRDcluster", 400); + if(!(fRecPoints = AliTRDReconstructor::GetClusters())){ + fRecPoints = new TClonesArray("AliTRDcluster", 400); + } + //SetClustersOwner(kTRUE); + AliTRDReconstructor::SetClusters(0x0); } return fRecPoints; } diff --git a/TRD/AliTRDtrackerV1.cxx b/TRD/AliTRDtrackerV1.cxx index 0cbf7d67eef..5de08068449 100644 --- a/TRD/AliTRDtrackerV1.cxx +++ b/TRD/AliTRDtrackerV1.cxx @@ -121,7 +121,9 @@ AliTRDtrackerV1::~AliTRDtrackerV1() for(Int_t isl =0; islDelete(); delete fTracks;} if(fTracklets) {fTracklets->Delete(); delete fTracklets;} - if(fClusters) {fClusters->Delete(); delete fClusters;} + if(fClusters) { + fClusters->Delete(); delete fClusters; + } if(fGeom) delete fGeom; } @@ -1569,7 +1571,9 @@ Int_t AliTRDtrackerV1::LoadClusters(TTree *cTree) // Fills clusters into TRD tracking sectors // - if(!(fClusters = AliTRDReconstructor::GetClusters())){ + if(!fReconstructor->IsWritingClusters()){ + fClusters = AliTRDReconstructor::GetClusters(); + } else { if (ReadClusters(fClusters, cTree)) { AliError("Problem with reading the clusters !"); return 1; @@ -1577,7 +1581,7 @@ Int_t AliTRDtrackerV1::LoadClusters(TTree *cTree) } SetClustersOwner(); - if(!fClusters->GetEntriesFast()){ + if(!fClusters || !fClusters->GetEntriesFast()){ AliInfo("No TRD clusters"); return 1; } @@ -1653,6 +1657,15 @@ void AliTRDtrackerV1::UnloadClusters() if(fTracks) fTracks->Delete(); if(fTracklets) fTracklets->Delete(); if(fClusters && IsClustersOwner()) fClusters->Delete(); + if(fClusters){ + if(IsClustersOwner()) fClusters->Delete(); + + // save clusters array in the reconstructor for further use. + if(!fReconstructor->IsWritingClusters()){ + AliTRDReconstructor::SetClusters(fClusters); + SetClustersOwner(kFALSE); + } else AliTRDReconstructor::SetClusters(0x0); + } for (int i = 0; i < AliTRDgeometry::kNsector; i++) fTrSec[i].Clear(); @@ -2584,8 +2597,6 @@ AliTRDtrackV1* AliTRDtrackerV1::MakeTrack(AliTRDseedV1 *seeds, Double_t *params) // To be discussed with Marian !! // - AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance(); - if (!calibra) AliInfo("Could not get Calibra instance\n"); Double_t alpha = AliTRDgeometry::GetAlpha(); Double_t shift = AliTRDgeometry::GetAlpha()/2.0; @@ -2604,14 +2615,18 @@ AliTRDtrackV1* AliTRDtrackerV1::MakeTrack(AliTRDseedV1 *seeds, Double_t *params) if (nc < 30) return 0x0; AliTRDtrackV1 *ptrTrack = SetTrack(&track); - ptrTrack->CookLabel(.9); if(fReconstructor->IsHLT()) return ptrTrack; + + ptrTrack->CookLabel(.9); // computes PID for track ptrTrack->CookPID(); // update calibration references using this track - if(calibra->GetHisto2d()) calibra->UpdateHistogramsV1(ptrTrack); - + AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance(); + if (!calibra){ + AliInfo("Could not get Calibra instance\n"); + if(calibra->GetHisto2d()) calibra->UpdateHistogramsV1(ptrTrack); + } return ptrTrack; } -- 2.43.0