]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
fixes for memory leaks and a bug in loading clusters
authoramastros <amastros@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 14 Jan 2011 11:50:23 +0000 (11:50 +0000)
committeramastros <amastros@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 14 Jan 2011 11:50:23 +0000 (11:50 +0000)
ITS/UPGRADE/AliITSUpgradeClusterFinder.cxx
ITS/UPGRADE/AliITStrackerUpgrade.cxx

index 90f505e8149969c2304e1f223aaae118f50fb9a9..ba6135911ed819ffc3e836faa275e4ac3a0e0777 100644 (file)
@@ -791,16 +791,15 @@ void AliITSUpgradeClusterFinder::DigitsToRecPoints(const TObjArray *digList) {
   //
   // the clusterization is performed here
   //
-  AliITSsegmentationUpgrade *segmentation2 = 0x0;
+  AliITSsegmentationUpgrade *segmentation = new AliITSsegmentationUpgrade(); 
   AliITSRecPoint  recpnt;
-  if(!segmentation2) segmentation2 = new AliITSsegmentationUpgrade();
   Int_t nClusters =0;
   TClonesArray &lrecp = *fRecPoints;
 
   for(Int_t ilayer=0; ilayer < 6 ;ilayer ++){
     TClonesArray *pArrDig= (TClonesArray*)digList->At(ilayer);
     StartEvent();
-    AliInfo(Form("layer %i with digit entries %i",ilayer,pArrDig->GetEntries()));
+    AliDebug(1,Form("layer %i : # digits %i",ilayer,pArrDig->GetEntries()));
     for(Int_t ientr =0; ientr < pArrDig->GetEntries() ; ientr++){
       AliITSDigitUpgrade *dig = (AliITSDigitUpgrade*)pArrDig->At(ientr);
       Int_t colz=dig->GetzPixelNumber();
@@ -826,9 +825,9 @@ void AliITSUpgradeClusterFinder::DigitsToRecPoints(const TObjArray *digList) {
 
       xPixC2 = GetClusterMeanRow(ilayer, nClu);
       zPixC2 = GetClusterMeanCol(ilayer, nClu);
-      xzl2[0] = xPixC2*(segmentation2->GetCellSizeX(ilayer))+0.5*(segmentation2-> GetCellSizeX(ilayer));
-      xzl2[1] = zPixC2*(segmentation2->GetCellSizeZ(ilayer))+0.5*(segmentation2->GetCellSizeZ(ilayer))-(segmentation2->GetHalfLength(ilayer));
-      check2 = segmentation2->DetToGlobal(ilayer,xzl2[0], xzl2[1],xcheck2,ycheck2,zcheck2);
+      xzl2[0] = xPixC2*(segmentation->GetCellSizeX(ilayer))+0.5*(segmentation-> GetCellSizeX(ilayer));
+      xzl2[1] = zPixC2*(segmentation->GetCellSizeZ(ilayer))+0.5*(segmentation->GetCellSizeZ(ilayer))-(segmentation->GetHalfLength(ilayer));
+      check2 = segmentation->DetToGlobal(ilayer,xzl2[0], xzl2[1],xcheck2,ycheck2,zcheck2);
       recpnt.SetType(GetClusterType(ilayer,nClu ));
       // recpnt.SetLocalCoord(xzl2[0],xzl2[1]); //temporary solution (no LocalToTrack Matrix)
       //from global to tracking system coordinate
@@ -860,7 +859,7 @@ void AliITSUpgradeClusterFinder::DigitsToRecPoints(const TObjArray *digList) {
       recpnt.SetZ(zclu1);
 
       Double_t xsize, zsize;
-      segmentation2->GetSegmentation(ilayer,xsize, zsize);
+      segmentation->GetSegmentation(ilayer,xsize, zsize);
       recpnt.SetSigmaY2(xsize/TMath::Sqrt(12)*xsize/TMath::Sqrt(12));
       recpnt.SetSigmaZ2(zsize/TMath::Sqrt(12)*zsize/TMath::Sqrt(12));
       new(lrecp[nClusters++]) AliITSRecPoint(recpnt);
@@ -868,5 +867,6 @@ void AliITSUpgradeClusterFinder::DigitsToRecPoints(const TObjArray *digList) {
       AliInfo(Form("recpoint : Nelectrons %f (entry %i)",recpnt.GetQ(),fRecPoints->GetEntries()));
     }//cluster list entries
   }//ilayer
+  if(segmentation) delete segmentation;
 }
 
index 31b8b91c86b994d6bad22d774943c1c6ba367cff..636057153e4f8532055f21c08a972542dbf0950e 100644 (file)
@@ -224,9 +224,9 @@ void AliITStrackerUpgrade::Init(){
   fCluLayer = 0;
   fCluCoord = 0;
   fMinNPoints = 3;
-  AliITSsegmentationUpgrade *segmentation2 = 0x0;
-  if(!segmentation2)
-    segmentation2 = new AliITSsegmentationUpgrade();
+  //AliITSsegmentationUpgrade *segmentation2 = 0x0;
+  //if(!segmentation2)
+  //  segmentation2 = new AliITSsegmentationUpgrade();
   for(Int_t layer=0; layer<6; layer++){
     Double_t p=0.;
     Double_t zC= 0.;
@@ -237,23 +237,28 @@ void AliITStrackerUpgrade::Init(){
 }
 //_______________________________________________________________________
 Int_t AliITStrackerUpgrade::LoadClusters(TTree *clusTree){ 
+//
+// Load clusters for tracking
+// 
+
   TClonesArray statITSCluster("AliITSRecPoint");
-  for(Int_t layer=0; layer<6; layer++){
-    TClonesArray *ITSCluster = &statITSCluster;
+  TClonesArray *ITSCluster = &statITSCluster;
+
     TBranch* itsClusterBranch=clusTree->GetBranch("ITSRecPoints");
     if (!itsClusterBranch){
       AliError("can't get the branch with the ITS clusters ! \n");
       return 1;
     }
     itsClusterBranch->SetAddress(&ITSCluster);
-    if (!clusTree->GetEvent(layer))    continue;
+    clusTree->GetEvent(0);
     Int_t nCluster = ITSCluster->GetEntriesFast();
     for(Int_t i=0; i<nCluster; i++){
       AliITSRecPoint *recp = (AliITSRecPoint*)ITSCluster->UncheckedAt(i);
-
-      fLayers[layer]->InsertCluster(new AliITSRecPoint(*recp));
+      fLayers[recp->GetLayer()]->InsertCluster(new AliITSRecPoint(*recp));
     }//loop clusters
-  }//loop layer
+
+
+
    
   SetClusterTree(clusTree);
   return 0;
@@ -357,6 +362,7 @@ Int_t AliITStrackerUpgrade::FindTracks(AliESDEvent* event,Bool_t useAllClusters)
     TClonesArray &clulay = *fCluLayer[ilay];
     TClonesArray &clucoo = *fCluCoord[ilay];
     if (!ForceSkippingOfLayer(ilay)){
+    AliDebug(2,Form("number of clusters in layer %i : %i",ilay,fLayers[ilay]->GetNumberOfClusters()));
       for(Int_t cli=0;cli<fLayers[ilay]->GetNumberOfClusters();cli++){
         AliITSRecPoint* cls = (AliITSRecPoint*)fLayers[ilay]->GetCluster(cli);
         if(cls->TestBit(kSAflag)==kTRUE) continue;
@@ -615,9 +621,7 @@ AliITStrackV2* AliITStrackerUpgrade::FitTrack(AliITStrackSA* tr,Double_t *primar
               Double_t yclu1 = p1->GetY();
               Double_t zclu1 = p1->GetZ();
              layer=p1->GetLayer();
-             AliITSsegmentationUpgrade *segmentation = 0x0;
-             if(!segmentation)
-                segmentation = new AliITSsegmentationUpgrade();
+             AliITSsegmentationUpgrade *segmentation = new AliITSsegmentationUpgrade();
              radius=segmentation->GetRadius(layer);
              Double_t cv=0.,tgl2=0.,phi2=0.;
              Int_t cln1=mrk1;
@@ -772,11 +776,13 @@ void AliITStrackerUpgrade::StoreTrack(AliITStrackV2 *t,AliESDEvent *event, Bool_
 Int_t AliITStrackerUpgrade::SearchClusters(Int_t layer,Double_t phiwindow,Double_t lambdawindow, AliITStrackSA* trs,Double_t /*zvertex*/,Int_t pflag){
   //function used to to find the clusters associated to the track
 
-  AliITSsegmentationUpgrade *segmentation = 0x0;
-  if(!segmentation)
-    segmentation = new AliITSsegmentationUpgrade();
+   AliITSsegmentationUpgrade *segmentation = new AliITSsegmentationUpgrade();
 
-  if(ForceSkippingOfLayer(layer)) return 0;
+  AliDebug(2,"Starting...");
+  if(ForceSkippingOfLayer(layer)) {
+  AliDebug(2,Form("Forcing skipping of layer %i. Exiting",layer));
+  return 0;
+  }
 
   Int_t nc=0;
   Double_t r=segmentation->GetRadius(layer);
@@ -792,6 +798,7 @@ Int_t AliITStrackerUpgrade::SearchClusters(Int_t layer,Double_t phiwindow,Double
 
  
   Int_t ncl = fCluLayer[layer]->GetEntries();
+  AliDebug(2,Form(" Number of clusters %i in layer %i.",ncl,layer));
   for (Int_t index=0; index<ncl; index++) {
     AliITSRecPoint *c = (AliITSRecPoint*)fCluLayer[layer]->At(index);
     if (!c) continue;
@@ -826,6 +833,7 @@ Int_t AliITStrackerUpgrade::SearchClusters(Int_t layer,Double_t phiwindow,Double
     fPointc[0]=arr->GetX();
     fPointc[1]=arr->GetY();
   }
+  delete segmentation;
   return nc;
 }
 
@@ -1105,9 +1113,7 @@ void AliITStrackerUpgrade::GetCoorAngles(AliITSRecPoint* cl,Double_t &phi,Double
   Double_t xz[2];
   xz[0]= cl->GetDetLocalX(); 
   xz[1]= cl->GetDetLocalZ() ; 
-  AliITSsegmentationUpgrade *segmentation2 = 0x0;
-  if(!segmentation2)
-    segmentation2 = new AliITSsegmentationUpgrade();
+  AliITSsegmentationUpgrade *segmentation2 = new AliITSsegmentationUpgrade();
   Bool_t check2;
   Int_t ilayer;
   ilayer = cl->GetLayer();
@@ -1116,6 +1122,7 @@ void AliITStrackerUpgrade::GetCoorAngles(AliITSRecPoint* cl,Double_t &phi,Double
   if(x!=0 && y!=0)  
     phi=TMath::ATan2(y-vertex[1],x-vertex[0]);
   lambda=TMath::ATan2(z-vertex[2],TMath::Sqrt((x-vertex[0])*(x-vertex[0])+(y-vertex[1])*(y-vertex[1])));
+  if(segmentation2) delete segmentation2;
 }
 
 //________________________________________________________________________
@@ -1173,9 +1180,7 @@ Bool_t AliITStrackerUpgrade::RefitAtBase(Double_t xx,AliITStrackMI *track,
   for (k=0; k<AliITSgeomTGeo::GetNLayers(); k++) {
     index[k]=clusters[k];
   }
-  AliITSsegmentationUpgrade *segmentation = 0x0;
-  if(!segmentation)
-    segmentation = new AliITSsegmentationUpgrade();
+  AliITSsegmentationUpgrade *segmentation = new AliITSsegmentationUpgrade();
 
   ULong_t trStatus=0;
   if(track->GetESDtrack()) trStatus=track->GetStatus();
@@ -1219,6 +1224,7 @@ Bool_t AliITStrackerUpgrade::RefitAtBase(Double_t xx,AliITStrackMI *track,
     Double_t oldGlobXYZ[3];
 
     if (!track->GetXYZ(oldGlobXYZ)) {
+      if(segmentation) delete segmentation;
       return kFALSE;
     }
     // continue if we are already beyond this layer
@@ -1231,6 +1237,7 @@ Bool_t AliITStrackerUpgrade::RefitAtBase(Double_t xx,AliITStrackMI *track,
     }
     Double_t phi,z;
     if (!track->GetPhiZat(r,phi,z)){
+      if(segmentation) delete segmentation;
       return kFALSE;
     }
     // only for ITS-SA tracks refit
@@ -1244,7 +1251,7 @@ Bool_t AliITStrackerUpgrade::RefitAtBase(Double_t xx,AliITStrackMI *track,
     Double_t alpha= (ladder*18.+9.)*TMath::Pi()/180.;
     
     if (!track->Propagate(alpha,r)) {
+      if(segmentation) delete segmentation;
       return kFALSE;
     }
 
@@ -1263,13 +1270,15 @@ Bool_t AliITStrackerUpgrade::RefitAtBase(Double_t xx,AliITStrackMI *track,
          clAcc=cl;                                                              
          maxchi2=chi2;                                                          
        } else {                                                                 
-         return kFALSE;                                                         
+           if(segmentation) delete segmentation;
+          return kFALSE;                                                         
        }                                                                        
       }                                                                          
     }              
 
     if (clAcc) {
       if (!UpdateMI(track,clAcc,maxchi2,idx)){
+        if(segmentation) delete segmentation;
        return kFALSE;
       }
       track->SetSampledEdx(clAcc->GetQ(),ilayer-2);
@@ -1280,14 +1289,17 @@ Bool_t AliITStrackerUpgrade::RefitAtBase(Double_t xx,AliITStrackMI *track,
     // cross material
     // add time if going outward
     if(!CorrectForLayerMaterial(track,ilayer,oldGlobXYZ,dir)){
+      if(segmentation) delete segmentation;
       return kFALSE;
     }
     track->SetCheckInvariant(kFALSE);
   } // end loop on layers
 
   if (!track->PropagateTo(xx,0.,0.)){
+    if(segmentation) delete segmentation;
     return kFALSE;
-  }
+  } 
+  if(segmentation) delete segmentation;
   return kTRUE;
 }