]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Improved memory leaks in AliTOFtracker* classes: additional solution for bug #66136
authordecaro <decaro@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 23 Apr 2010 17:38:40 +0000 (17:38 +0000)
committerdecaro <decaro@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 23 Apr 2010 17:38:40 +0000 (17:38 +0000)
TOF/AliTOFtracker.cxx
TOF/AliTOFtracker.h
TOF/AliTOFtrackerMI.cxx
TOF/AliTOFtrackerMI.h
TOF/AliTOFtrackerV1.cxx
TOF/AliTOFtrackerV1.h

index 60f29321ac857508b08930ae0d4ac25ac7669a59..0356c7e33c25f93a52554e0f182e3084ef897142 100644 (file)
@@ -56,6 +56,7 @@
 extern TGeoManager *gGeoManager;
 extern TROOT *gROOT;
 
+
 ClassImp(AliTOFtracker)
 
 //_____________________________________________________________________________
@@ -70,7 +71,8 @@ AliTOFtracker::AliTOFtracker():
   fnunmatch(0),
   fnmatch(0),
   fTracks(new TClonesArray("AliTOFtrack")),
-  fSeeds(new TObjArray(15000)),
+  fSeeds(new TObjArray(100)),
+  fTOFtrackPoints(new TObjArray(10)),
   fHDigClusMap(0x0),
   fHDigNClus(0x0),
   fHDigClusTime(0x0),
@@ -130,6 +132,11 @@ AliTOFtracker::~AliTOFtracker() {
     delete fSeeds;
     fSeeds=0x0;
   }
+  if (fTOFtrackPoints){
+    fTOFtrackPoints->Delete();
+    delete fTOFtrackPoints;
+    fTOFtrackPoints=0x0;
+  }
 
 }
 //_____________________________________________________________________________
@@ -174,8 +181,6 @@ Int_t AliTOFtracker::PropagateBack(AliESDEvent * const event) {
 
 
   //Load ESD tracks into a local Array of ESD Seeds
-  if (!fSeeds)
-    fSeeds = new TObjArray(fNseeds);
   for (Int_t i=0; i<fNseeds; i++)
     fSeeds->AddLast(event->GetTrack(i));
 
@@ -311,7 +316,7 @@ Int_t AliTOFtracker::PropagateBack(AliESDEvent * const event) {
   // Now done in AliESDpid
   // fPid->MakePID(event,timeZero);
 
-  fSeeds->Clear(); delete fSeeds; fSeeds=0;
+  fSeeds->Clear();
   fTracks->Delete();
   return 0;
   
@@ -421,35 +426,21 @@ void AliTOFtracker::MatchTracks( Bool_t mLastStep){
   Int_t * clind = new Int_t[fN];
   
   // Some init
-  const Int_t kNfoundMax = 10000; // related to nSteps value
-  Int_t         index[kNfoundMax];
-  Float_t        dist[kNfoundMax];
-  Float_t       distZ[kNfoundMax];
-  Float_t       distY[kNfoundMax]; // delta(rhoXphi) // AdC
-  Float_t       cxpos[kNfoundMax];
-  Float_t       crecL[kNfoundMax];
   const Int_t kNclusterMax = 1000; // related to fN value
-  TGeoHMatrix   global[kNclusterMax];
-     
+  TGeoHMatrix global[kNclusterMax];
+
   //The matching loop
   for (Int_t iseed=0; iseed<fNseedsTOF; iseed++) {
 
-    for (Int_t ii=0; ii<kNfoundMax; ii++) {
-      index[ii] = -1;
-      dist[ii] = 9999.;
-      distZ[ii] = 9999.;
-      distY[ii] = 9999.;
-      cxpos[ii] = 9999.;
-      crecL[ii] = 0.;
-    }
+    fTOFtrackPoints->Clear();
+
     for (Int_t ii=0; ii<kNclusterMax; ii++)
       global[ii] = 0x0;
-
     AliTOFtrack *track =(AliTOFtrack*)fTracks->UncheckedAt(iseed);
     AliESDtrack *t =(AliESDtrack*)fSeeds->At(track->GetSeedIndex());
     //if ( t->GetTOFsignal()>0. ) continue;
     if ( (t->GetStatus()&AliESDtrack::kTOFout)!=0 ) continue;
-    AliTOFtrack *trackTOFin =new AliTOFtrack(*track);
+    AliTOFtrack *trackTOFin = new AliTOFtrack(*track);
 
     // Determine a window around the track
     Double_t x,par[5]; 
@@ -476,15 +467,12 @@ void AliTOFtracker::MatchTracks( Bool_t mLastStep){
     Double_t z=par[1];   
 
     //upper limit on window's size.
-
-    if(dz> dzMax) dz=dzMax;
-    if(dphi*sensRadius> dyMax) dphi=dyMax/sensRadius;
+    if (dz> dzMax) dz=dzMax;
+    if (dphi*sensRadius> dyMax) dphi=dyMax/sensRadius;
 
 
-    Int_t nc=0;
-
     // find the clusters in the window of the track
-
+    Int_t nc=0;
     for (Int_t k=FindClusterIndex(z-dz); k<fN; k++) {
 
       if (nc>=kNclusterMax) {
@@ -495,7 +483,6 @@ void AliTOFtracker::MatchTracks( Bool_t mLastStep){
       AliTOFcluster *c=fClusters[k];
       if (c->GetZ() > z+dz) break;
       if (c->IsUsed()) continue;
-
       if (!c->GetStatus()) {
        AliDebug(1,"Cluster in channel declared bad!");
        continue; // skip bad channels as declared in OCDB
@@ -569,11 +556,6 @@ void AliTOFtracker::MatchTracks( Bool_t mLastStep){
     Bool_t isInside = kFALSE;
     for (Int_t istep=0; istep<nStepsDone; istep++) {
 
-      if (nfound>=kNfoundMax) {
-       AliWarning("No more track positions can be stored! Please, increase the corresponding vectors size.");
-       break;
-      }
-
       Float_t ctrackPos[3];    
       ctrackPos[0] = trackPos[0][istep];
       ctrackPos[1] = trackPos[1][istep];
@@ -597,30 +579,12 @@ void AliTOFtracker::MatchTracks( Bool_t mLastStep){
        }
        if (accept) {
 
-         dist[nfound] = TMath::Sqrt(dist3d[0]*dist3d[0] +
-                                    dist3d[1]*dist3d[1] +
-                                    dist3d[2]*dist3d[2]);
-         AliDebug(2,Form(" dist3dLoc[0] = %f, dist3dLoc[1] = %f, dist3dLoc[2] = %f ",
-                         dist3d[0],dist3d[1],dist3d[2]));
-         distZ[nfound] = dist3d[2]; // Z distance in the RF of the
-                                    // hit pad closest to the
-                                    // reconstructed track
-         distY[nfound] = dist3d[0]; // X distance in the RF of the
-                                    // hit pad closest to the
-                                    // reconstructed track
-                                    // It corresponds to Y coordinate
-                                    // in tracking RF
-
-
-         AliDebug(2,Form("   dist3dLoc[0] = %f --- distY[%d] = %f",
-                         dist3d[0],nfound,distY[nfound]));
-         AliDebug(2,Form("   dist3dLoc[2] = %f --- distZ[%d] = %f",
-                         dist3d[2],nfound,distZ[nfound]));
-
-
-         crecL[nfound] = trackPos[3][istep];
-         index[nfound] = clind[i]; // store cluster id             
-         cxpos[nfound] = AliTOFGeometry::RinTOF()+istep*0.1; //store prop.radius
+         fTOFtrackPoints->AddLast(new AliTOFtrackPoint(clind[i],
+                                                       TMath::Sqrt(dist3d[0]*dist3d[0] + dist3d[1]*dist3d[1] + dist3d[2]*dist3d[2]),
+                                                       dist3d[2], dist3d[0],
+                                                       AliTOFGeometry::RinTOF()+istep*0.1,trackPos[3][istep]));
+
+         AliDebug(2,Form(" dist3dLoc[0] = %f, dist3dLoc[1] = %f, dist3dLoc[2] = %f ",dist3d[0],dist3d[1],dist3d[2]));
          nfound++;
          if(accept &&!mLastStep)break;
        }//end if accept
@@ -649,30 +613,28 @@ void AliTOFtracker::MatchTracks( Bool_t mLastStep){
     Float_t  mindistZ=0.;
     Float_t  mindistY=0.;
     for (Int_t iclus= 0; iclus<nfound;iclus++){
-      if (dist[iclus]< mindist){
-       mindist = dist[iclus];
-       mindistZ = distZ[iclus]; // Z distance in the RF of the hit
-                                // pad closest to the reconstructed
-                                // track
-       mindistY = distY[iclus]; // Y distance in the RF of the hit
-                                // pad closest to the reconstructed
-                                // track
-       xpos = cxpos[iclus];
-        idclus =index[iclus]; 
-        recL=crecL[iclus]+corrLen*0.5;
+      AliTOFtrackPoint *matchableTOFcluster = (AliTOFtrackPoint*)fTOFtrackPoints->At(iclus);
+      if (matchableTOFcluster->Distance()<mindist) {
+       mindist = matchableTOFcluster->Distance();
+       mindistZ = matchableTOFcluster->DistanceZ();  // Z distance in the
+                                                     // RF of the hit pad
+                                                     // closest to the
+                                                     // reconstructed
+                                                     // track
+       mindistY = matchableTOFcluster->DistanceY(); // Y distance in the
+                                                    // RF of the hit pad
+                                                    // closest to the
+                                                    // reconstructed
+                                                    // track
+       xpos = matchableTOFcluster->PropRadius();
+        idclus = matchableTOFcluster->Index();
+        recL = matchableTOFcluster->Length() + corrLen*0.5;
       }
-    }
+    } // loop on found TOF track points
 
 
     AliTOFcluster *c=fClusters[idclus];
-    /*
-    Float_t tiltangle = AliTOFGeometry::GetAngles(c->GetDetInd(1),c->GetDetInd(2))*TMath::DegToRad();
-    Float_t localCheck=-mindistZ;
-    localCheck/=TMath::Cos(tiltangle); // Z (tracking/ALICE RF) component of
-                                      // the distance between the
-                                      // reconstructed track and the
-                                      // TOF closest cluster
-    */
+
     AliDebug(2, Form("%7d     %7d     %10d     %10d  %10d  %10d      %7d",
                     iseed,
                     fnmatch-1,
@@ -684,14 +646,14 @@ void AliTOFtracker::MatchTracks( Bool_t mLastStep){
 
     // Track length correction for matching Step 2 
 
-    if(mLastStep){
-      Float_t rc=TMath::Sqrt(c->GetR()*c->GetR() + c->GetZ()*c->GetZ());
-      Float_t rt=TMath::Sqrt(trackPos[0][70]*trackPos[0][70]
-                            +trackPos[1][70]*trackPos[1][70]
-                            +trackPos[2][70]*trackPos[2][70]);
-      Float_t dlt=rc-rt;      
+    if (mLastStep) {
+      Float_t rc = TMath::Sqrt(c->GetR()*c->GetR() + c->GetZ()*c->GetZ());
+      Float_t rt = TMath::Sqrt(trackPos[0][70]*trackPos[0][70]
+                              +trackPos[1][70]*trackPos[1][70]
+                              +trackPos[2][70]*trackPos[2][70]);
+      Float_t dlt=rc-rt;
       recL=trackPos[3][70]+dlt;
-    }    
+    }
 
     if (
        (c->GetLabel(0)==TMath::Abs(trackTOFin->GetLabel()))
@@ -798,6 +760,7 @@ void AliTOFtracker::MatchTracks( Bool_t mLastStep){
     }
     delete trackTOFout;
   }
+
   for (Int_t ii=0; ii<4; ii++) delete [] trackPos[ii];
   delete [] clind;
  
index 70aaf545d8ad4183e22d0286d0f416497864d991..95f234bc34f948774434b37b998c3e19dfbc5a8f 100644 (file)
@@ -20,6 +20,9 @@
 
 #include "AliTracker.h"
 
+#include "TObject.h"
+
+
 class TClonesArray;
 class TObjArray;
 
@@ -33,11 +36,56 @@ class AliTOFcluster;
 class AliTOFRecoParam;
 class AliTOFGeometry;
 
-class AliTOFtracker : public AliTracker {
+class AliTOFtrackPoint : public TObject {
+
+ public:
+
+  AliTOFtrackPoint() :
+    fIndex(0),fDistance(0),fDistanceZ(0),
+    fDistanceY(0),fPropRadius(0),fLength(0) { };
+  AliTOFtrackPoint(Int_t index,Float_t dist,Float_t distZ,
+                  Float_t distY,Float_t radius,Float_t length) :
+    TObject(),
+    fIndex(index),fDistance(dist),fDistanceZ(distZ),
+    fDistanceY(distY),fPropRadius(radius),fLength(length) { };
+  AliTOFtrackPoint(const AliTOFtrackPoint & source) :
+    TObject(source),
+    fIndex(source.fIndex),
+    fDistance(source.fDistance),
+    fDistanceZ(source.fDistanceZ),
+    fDistanceY(source.fDistanceY),
+    fPropRadius(source.fPropRadius),
+    fLength(source.fLength) { };
+  AliTOFtrackPoint & operator=(const AliTOFtrackPoint & source)
+    { if (this == &source) return *this;
+      TObject::operator=(source);
+      fDistance=source.fDistance;fDistanceZ=source.fDistanceZ;fDistanceY=source.fDistanceY;
+      fPropRadius=source.fPropRadius;fLength=source.fLength;
+      return *this; };
+
+  Int_t Index()       const {return fIndex;} // cluster index
+  Float_t Distance()  const {return fDistance;} // distance
+  Float_t DistanceZ() const {return fDistanceZ;} // distance, Z component
+  Float_t DistanceY() const {return fDistanceY;} // distance, Y  component
+  Float_t PropRadius() const {return fPropRadius;} // propagation radius at TOF
+  Float_t Length() const {return fLength;} // reconstructed track length at TOF
+
+ private:
+
+  Int_t fIndex; // cluster index 
+  Float_t fDistance; // track-cluster distance
+  Float_t fDistanceZ; //  Z component of track-cluster distance
+  Float_t fDistanceY; //  Y component of track-cluster distance
+  Float_t fPropRadius; // track propagation radius
+  Float_t fLength; // receonstructed track length
+
+  //ClassDef(AliTOFtrackPoint, 1) // TOF matchable cluster
+
+}; 
 
-enum {kMaxCluster=77777}; //maximal number of the TOF clusters
+class AliTOFtracker : public AliTracker {
 
-public:
+ public:
 
  AliTOFtracker(); 
 
@@ -58,6 +106,8 @@ public:
 
 private:
 
+ enum {kMaxCluster=77777}; //maximal number of the TOF clusters
+
  AliTOFtracker(const AliTOFtracker &t); //Copy Ctor 
  AliTOFtracker& operator=(const AliTOFtracker &source); // ass. op.
 
@@ -80,7 +130,9 @@ private:
  
  TClonesArray* fTracks; //! pointer to the TClonesArray with TOF tracks
  TObjArray* fSeeds;  //! pointer to the TObjArray with ESD tracks
- //Digits/Reco QA histos
+                     //Digits/Reco QA histos
+ TObjArray* fTOFtrackPoints; //! pointer to TObjArray of matchable TOF
+                            //track points
 
  TH2F * fHDigClusMap; //Digits QA, Cluster Map 
  TH1F * fHDigNClus;   //Digits QA, # of clusters on TOF/event
@@ -102,7 +154,7 @@ private:
  Float_t fExpTimeKa; // exp time, Kaons
  Float_t fExpTimePr; // exp time, Protons
 
- ClassDef(AliTOFtracker, 5) // TOF tracker 
+ ClassDef(AliTOFtracker, 6) // TOF tracker 
 };
 
 #endif
index dd94ebefcab51ec01e288539a7b89c3bf1b3ee49..a2b56493ebc977e56e06701bd87856bb1ef45fdb 100644 (file)
@@ -65,7 +65,7 @@ AliTOFtrackerMI::AliTOFtrackerMI():
   fDy(0), 
   fDz(0), 
   fTracks(new TClonesArray("AliTOFtrack")),
-  fSeeds(new TObjArray(15000)),
+  fSeeds(new TObjArray(100)),
   fDebugStreamer(0x0)
  { 
   //AliTOFtrackerMI main Ctor
@@ -139,8 +139,6 @@ Int_t AliTOFtrackerMI::PropagateBack(AliESDEvent * const event) {
   fNseeds = ntrk;
 
   //Load ESD tracks into a local Array of ESD Seeds
-  if (!fSeeds)
-    fSeeds = new TObjArray(fNseeds);
   for (Int_t i=0; i<fNseeds; i++)
     fSeeds->AddLast(event->GetTrack(i));
 
@@ -209,7 +207,7 @@ Int_t AliTOFtrackerMI::PropagateBack(AliESDEvent * const event) {
 
   //Make TOF PID
 
-  fSeeds->Clear(); delete fSeeds; fSeeds=0;
+  fSeeds->Clear();
   fTracks->Delete();
   return 0;
   
@@ -284,8 +282,6 @@ void AliTOFtrackerMI::MatchTracksMI(Bool_t mLastStep){
   
   Int_t nSteps=(Int_t)(fTOFHeigth/0.1);
 
-  //AliTOFcalib *calib = new AliTOFcalib(); // AdC
-
   //PH Arrays (moved outside of the loop)
   Float_t * trackPos[4];
   for (Int_t ii=0; ii<4; ii++) trackPos[ii] = new Float_t[nSteps];
index e20d5341bdfc785bfcd1961057b191cfc4deee9d..617dd3b696e0bf6a1e5b82f3d85fdf277163c750 100644 (file)
@@ -30,8 +30,6 @@ class AliTOFtrack;
 
 class AliTOFtrackerMI : public AliTracker {
 
-enum {kMaxCluster=77777}; //maximal number of the TOF clusters
-
 public:
 
  AliTOFtrackerMI(); 
@@ -52,6 +50,8 @@ public:
 
 private:
 
+ enum {kMaxCluster=77777}; //maximal number of the TOF clusters
+
  AliTOFtrackerMI(const AliTOFtrackerMI &t); //Copy Ctor 
  AliTOFtrackerMI& operator=(const AliTOFtrackerMI &source); // ass. op.
 
index 14e5433b5d4a0a97c08ff326248439b8a6355248..953484a0c198f336c9b99a69ca1cebc64db1daf1 100644 (file)
@@ -67,7 +67,7 @@ AliTOFtrackerV1::AliTOFtrackerV1():
   fnunmatch(0),
   fnmatch(0),
   fTracks(new TClonesArray("AliTOFtrack")),
-  fSeeds(new TObjArray(15000)),
+  fSeeds(new TObjArray(100)),
   fHDigClusMap(0x0),
   fHDigNClus(0x0),
   fHDigClusTime(0x0),
@@ -158,10 +158,7 @@ Int_t AliTOFtrackerV1::PropagateBack(AliESDEvent * const event) {
   Int_t ntrk=event->GetNumberOfTracks();
   fNseeds = ntrk;
 
-
   //Load ESD tracks into a local Array of ESD Seeds
-  if (!fSeeds)
-    fSeeds = new TObjArray(fNseeds);
   for (Int_t i=0; i<fNseeds; i++)
     fSeeds->AddLast(event->GetTrack(i));
 
@@ -291,7 +288,7 @@ Int_t AliTOFtrackerV1::PropagateBack(AliESDEvent * const event) {
     }
   }
 
-  fSeeds->Clear(); delete fSeeds; fSeeds=0;
+  fSeeds->Clear();
   fTracks->Delete();
   return 0;
   
@@ -390,7 +387,7 @@ void AliTOFtrackerV1::MatchTracks( ){
     AliESDtrack *t =(AliESDtrack*)fSeeds->At(track->GetSeedIndex());
     //if ( t->GetTOFsignal()>0. ) continue;
     if ( (t->GetStatus()&AliESDtrack::kTOFout)!=0 ) continue;
-    AliTOFtrack *trackTOFin =new AliTOFtrack(*track);
+    AliTOFtrack *trackTOFin = new AliTOFtrack(*track);
      
     // Determine a window around the track
     Double_t x,par[5]; trackTOFin->GetExternalParameters(x,par);
@@ -403,16 +400,16 @@ void AliTOFtrackerV1::MatchTracks( ){
     }
 
     Double_t z    = par[1];   
-    Double_t dz   =  scaleFact*3.*TMath::Sqrt(TMath::Abs(cov[2])+dZ*dZ/12.);
-    Double_t dphi =  scaleFact*3.*TMath::Sqrt(TMath::Abs(cov[0])+dY*dY/12.)/sensRadius; 
+    Double_t dz   = scaleFact*3.*TMath::Sqrt(TMath::Abs(cov[2])+dZ*dZ/12.);
+    Double_t dphi = scaleFact*3.*TMath::Sqrt(TMath::Abs(cov[0])+dY*dY/12.)/sensRadius; 
 
     Double_t phi=TMath::ATan2(par[0],x) + trackTOFin->GetAlpha();
     if (phi<-TMath::Pi())phi+=2*TMath::Pi();
     if (phi>=TMath::Pi())phi-=2*TMath::Pi();
 
     //upper limit on window's size.
-    if(dz> dzMax) dz=dzMax;
-    if(dphi*sensRadius> dyMax) dphi=dyMax/sensRadius;
+    if (dz> dzMax) dz=dzMax;
+    if (dphi*sensRadius> dyMax) dphi=dyMax/sensRadius;
 
     // find the clusters inside the selected window 
     Int_t nc=0;
@@ -425,9 +422,9 @@ void AliTOFtrackerV1::MatchTracks( ){
        AliWarning("No more matchable clusters can be stored! Please, increase the corresponding vectors size.");
        break; /* R+ fix (buffer overflow protection) */
       }
-      if(c->GetZ() > z+dz) break;
-      if(c->IsUsed()) continue;      
-      if(!c->GetStatus()) {
+      if (c->GetZ() > z+dz) break;
+      if (c->IsUsed()) continue;      
+      if (!c->GetStatus()) {
        AliDebug(1,"Cluster in channel declared bad!");
        continue; // skip bad channels as declared in OCDB  
       }
index 78439c365803b9ab6cdc559f62831ef96d817aca..c48f1569b448fa73aae24fe48843b71081cfe893 100644 (file)
@@ -8,7 +8,7 @@
 
 //----------------------------------------------------------------------//
 //                                                                      //
-// AliTOFtrackerV1 Class                                                  //
+// AliTOFtrackerV1 Class                                                //
 // Task: Perform association of the ESD tracks to TOF Clusters          //
 // and Update ESD track with associated TOF Cluster parameters          //
 //                                                                      //
@@ -34,8 +34,6 @@ class AliESDpid;
 
 class AliTOFtrackerV1 : public AliTracker {
 
-enum {kMaxCluster=77777}; //maximal number of the TOF clusters
-
 public:
 
  AliTOFtrackerV1(); 
@@ -57,6 +55,8 @@ public:
 
 private:
 
+ enum {kMaxCluster=77777}; //maximal number of the TOF clusters
+
  AliTOFtrackerV1(const AliTOFtrackerV1 &t); //Copy Ctor 
  AliTOFtrackerV1& operator=(const AliTOFtrackerV1 &source); // ass. op.