]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
further mem leak fix
authormploskon <mploskon@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 20 Jun 2011 14:09:19 +0000 (14:09 +0000)
committermploskon <mploskon@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 20 Jun 2011 14:09:19 +0000 (14:09 +0000)
EMCAL/AliEMCALRecoUtils.cxx
EMCAL/AliEMCALReconstructor.cxx

index 014137fb1c92ef4f92157c67a237269a1f3458fe..a2a432ea98e2ef371eb89e560c2508de9ca4f185 100644 (file)
@@ -1113,7 +1113,7 @@ void AliEMCALRecoUtils::FindMatches(AliVEvent *event,TObjArray * clusterArr,  Al
   for (Int_t i=0; i<21;i++) cv[i]=0;
   for(Int_t itr=0; itr<event->GetNumberOfTracks(); itr++)
   {
-    AliExternalTrackParam *trackParam=0;
+    AliExternalTrackParam *trackParam = 0;
 
     //If the input event is ESD, the starting point for extrapolation is TPCOut, if available, or TPCInner 
     if(esdevent)
@@ -1125,12 +1125,12 @@ void AliEMCALRecoUtils::FindMatches(AliVEvent *event,TObjArray * clusterArr,  Al
        if(friendTrack && friendTrack->GetTPCOut())
          {
            //Use TPC Out as starting point if it is available
-           trackParam= new AliExternalTrackParam(*friendTrack->GetTPCOut());
+           trackParam=  const_cast<AliExternalTrackParam*>(friendTrack->GetTPCOut());
          }
        else
          {
            //Otherwise use TPC inner
-           trackParam = new AliExternalTrackParam(*esdTrack->GetInnerParam());
+           trackParam =  const_cast<AliExternalTrackParam*>(esdTrack->GetInnerParam());
          }
       }
     
@@ -1163,11 +1163,11 @@ void AliEMCALRecoUtils::FindMatches(AliVEvent *event,TObjArray * clusterArr,  Al
     if(!clusterArr){// get clusters from event
       for(Int_t icl=0; icl<event->GetNumberOfCaloClusters(); icl++)
        {
-         AliExternalTrackParam *trkPamTmp = new AliExternalTrackParam(*trackParam);//Retrieve the starting point every time before the extrapolation
          AliVCluster *cluster = (AliVCluster*) event->GetCaloCluster(icl);
-         if(geom && !IsGoodCluster(cluster,geom,(AliVCaloCells*)event->GetEMCALCells())) continue;     
+         if(geom && !IsGoodCluster(cluster,geom,(AliVCaloCells*)event->GetEMCALCells())) continue;
+         AliExternalTrackParam trkPamTmp(*trackParam);//Retrieve the starting point every time before the extrapolation        
          Float_t tmpEta=-999, tmpPhi=-999;
-         if(!ExtrapolateTrackToCluster(trkPamTmp, cluster, tmpEta, tmpPhi)) continue;
+         if(!ExtrapolateTrackToCluster(&trkPamTmp, cluster, tmpEta, tmpPhi)) continue;
          if(fCutEtaPhiSum)
            {
              Float_t tmpR=TMath::Sqrt(tmpEta*tmpEta + tmpPhi*tmpPhi);
@@ -1193,18 +1193,18 @@ void AliEMCALRecoUtils::FindMatches(AliVEvent *event,TObjArray * clusterArr,  Al
              printf("Error: please specify your cut criteria\n");
              printf("To cut on sqrt(dEta^2+dPhi^2), use: SwitchOnCutEtaPhiSum()\n");
              printf("To cut on dEta and dPhi separately, use: SwitchOnCutEtaPhiSeparate()\n");
+             if(aodevent && trackParam) delete trackParam;
              return;
            }
-         delete trkPamTmp;
        }//cluster loop
     } else { // external cluster array, not from ESD event
       for(Int_t icl=0; icl<clusterArr->GetEntriesFast(); icl++)
        {
-         AliExternalTrackParam *trkPamTmp = new AliExternalTrackParam(*trackParam);//Retrieve the starting point every time before the extrapolation
          AliVCluster *cluster = (AliVCluster*) clusterArr->At(icl);
          if(!cluster->IsEMCAL()) continue;
+         AliExternalTrackParam trkPamTmp (*trackParam);//Retrieve the starting point every time before the extrapolation
          Float_t tmpEta=-999, tmpPhi=-999;
-         if(!ExtrapolateTrackToCluster(trkPamTmp, cluster, tmpEta, tmpPhi)) continue;
+         if(!ExtrapolateTrackToCluster(&trkPamTmp, cluster, tmpEta, tmpPhi)) continue;
          if(fCutEtaPhiSum)
            {
              Float_t tmpR=TMath::Sqrt(tmpEta*tmpEta + tmpPhi*tmpPhi);
@@ -1230,9 +1230,9 @@ void AliEMCALRecoUtils::FindMatches(AliVEvent *event,TObjArray * clusterArr,  Al
              printf("Error: please specify your cut criteria\n");
              printf("To cut on sqrt(dEta^2+dPhi^2), use: SwitchOnCutEtaPhiSum()\n");
              printf("To cut on dEta and dPhi separately, use: SwitchOnCutEtaPhiSeparate()\n");
+             if(aodevent && trackParam) delete trackParam;
              return;
            }
-         delete trkPamTmp;
       }//cluster loop
     }// external list of clusters
 
@@ -1244,7 +1244,7 @@ void AliEMCALRecoUtils::FindMatches(AliVEvent *event,TObjArray * clusterArr,  Al
       fResidualPhi          ->AddAt(dPhiMax,matched);
       matched++;
     }
-    delete trackParam;
+    if(aodevent && trackParam) delete trackParam;
   }//track loop
   
   AliDebug(2,Form("Number of matched pairs = %d !\n",matched));
@@ -1276,11 +1276,11 @@ Int_t AliEMCALRecoUtils::FindMatchedCluster(AliESDtrack *track, AliVEvent *event
   if(!trackParam) return index;          
   for(Int_t icl=0; icl<event->GetNumberOfCaloClusters(); icl++)
     {
-      AliExternalTrackParam *trkPamTmp = new AliExternalTrackParam(*trackParam);//Retrieve the starting point every time before the extrapolation
       AliVCluster *cluster = (AliVCluster*) event->GetCaloCluster(icl);
-      if(geom && !IsGoodCluster(cluster,geom,(AliVCaloCells*)event->GetEMCALCells())) continue;                        
+      if(geom && !IsGoodCluster(cluster,geom,(AliVCaloCells*)event->GetEMCALCells())) continue;        
+      AliExternalTrackParam trkPamTmp (*trackParam);//Retrieve the starting point every time before the extrapolation
       Float_t tmpEta=-999, tmpPhi=-999;
-      if(!ExtrapolateTrackToCluster(trkPamTmp, cluster, tmpEta, tmpPhi)) continue;
+      if(!ExtrapolateTrackToCluster(&trkPamTmp, cluster, tmpEta, tmpPhi)) continue;
       if(fCutEtaPhiSum)
        {
          Float_t tmpR=TMath::Sqrt(tmpEta*tmpEta + tmpPhi*tmpPhi);
@@ -1308,7 +1308,6 @@ Int_t AliEMCALRecoUtils::FindMatchedCluster(AliESDtrack *track, AliVEvent *event
          printf("To cut on dEta and dPhi separately, use: SwitchOnCutEtaPhiSeparate()\n");
          return -1;
        }
-      delete trkPamTmp;
     }//cluster loop
   return index;
 }
index b24cc801ce8b8e3e827f11764cbf4b1ed63f4b58..af5ae92542e50540417d49288e6b43f3f7965c18 100644 (file)
@@ -679,7 +679,7 @@ Bool_t AliEMCALReconstructor::CalculateResidual(AliESDtrack *track, AliESDCaloCl
 
   // If the esdFriend is available, use the TPCOuter point as the starting point of extrapolation
   // Otherwise use the TPCInner point
-  AliExternalTrackParam *trkParam;
+  AliExternalTrackParam *trkParam = 0;
   const AliESDfriendTrack*  friendTrack = track->GetFriendTrack();
   if(friendTrack && friendTrack->GetTPCOut())
     trkParam = const_cast<AliExternalTrackParam*>(friendTrack->GetTPCOut());
@@ -691,20 +691,19 @@ Bool_t AliEMCALReconstructor::CalculateResidual(AliESDtrack *track, AliESDCaloCl
   Double_t trkPos[3];
   Float_t  clsPos[3];
 
-  AliExternalTrackParam *trkParamTmp = new AliExternalTrackParam(*trkParam);
+  AliExternalTrackParam trkParamTmp (*trkParam);
   cluster->GetPosition(clsPos);
   TVector3 vec(clsPos[0],clsPos[1],clsPos[2]);
   Double_t alpha =  ((int)(vec.Phi()*TMath::RadToDeg()/20)+0.5)*20*TMath::DegToRad();
   //Rotate to proper local coordinate
   vec.RotateZ(-alpha); 
-  trkParamTmp->Rotate(alpha); 
+  trkParamTmp.Rotate(alpha); 
   //extrapolation is done here
-  if(!AliTrackerBase::PropagateTrackToBxByBz(trkParamTmp, vec.X(), track->GetMass(), GetRecParam()->GetExtrapolateStep(), kFALSE, 0.8, -1)) 
+  if(!AliTrackerBase::PropagateTrackToBxByBz(&trkParamTmp, vec.X(), track->GetMass(), GetRecParam()->GetExtrapolateStep(), kFALSE, 0.8, -1)) 
     return kFALSE; 
 
   //Calculate the residuals
-  trkParamTmp->GetXYZ(trkPos);     
-  delete trkParamTmp;
+  trkParamTmp.GetXYZ(trkPos); 
    
   TVector3 clsPosVec(clsPos[0],clsPos[1],clsPos[2]);
   TVector3 trkPosVec(trkPos[0],trkPos[1],trkPos[2]);