]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Memory leak fixes in the AOD and MC loops (M. Putis)
authormfloris <mfloris@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 25 Jan 2011 16:01:59 +0000 (16:01 +0000)
committermfloris <mfloris@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 25 Jan 2011 16:01:59 +0000 (16:01 +0000)
PWG2/SPECTRA/LambdaK0PbPb/AliAnalysisTaskPerformanceStrange.cxx

index adabc7c28ce9fbda44de9f6dd26b4c100ebbe50d..27f89c54914bd71be85a97bb77201047a6273e5f 100644 (file)
@@ -2359,24 +2359,54 @@ void AliAnalysisTaskPerformanceStrange::UserExec(Option_t *)
        TParticle  *lMCESDPartPos  = stack->Particle(lLabelTrackPos);
        if(!lMCESDPartPos) { 
          Printf("no MC particle for positive and/or negative daughter\n");
-         continue;
+         
+        if (negPiKF) delete negPiKF; negPiKF=NULL;
+       if (posPiKF) delete posPiKF; posPiKF=NULL;
+       if (posPKF)  delete posPKF;  posPKF=NULL;
+       if (negAPKF) delete negAPKF; negAPKF=NULL;  
+       continue;
+    
        }
        TParticle  *lMCESDPartNeg  = stack->Particle(lLabelTrackNeg);
-       if (!lMCESDPartNeg) continue;
+       if (!lMCESDPartNeg) {
+        if (negPiKF) delete negPiKF; negPiKF=NULL;
+       if (posPiKF) delete posPiKF; posPiKF=NULL;
+       if (posPKF)  delete posPKF;  posPKF=NULL;
+       if (negAPKF) delete negAPKF; negAPKF=NULL;  
+       continue;
+    }
        lPDGCodePosDaughter = lMCESDPartPos->GetPdgCode();
        lPDGCodeNegDaughter = lMCESDPartNeg->GetPdgCode();
        lIndexPosMother = lMCESDPartPos->GetFirstMother();
        lIndexNegMother = lMCESDPartNeg->GetFirstMother();
        
-       if (lIndexPosMother == -1) continue;
+       if (lIndexPosMother == -1) {
+        if (negPiKF) delete negPiKF; negPiKF=NULL;
+       if (posPiKF) delete posPiKF; posPiKF=NULL;
+       if (posPKF)  delete posPKF;  posPKF=NULL;
+       if (negAPKF) delete negAPKF; negAPKF=NULL;  
+       continue;
+    }
        TParticle  *lMCESDMother    = stack->Particle(lIndexPosMother);
-       if (!lMCESDMother) continue;
+       if (!lMCESDMother) {
+        if (negPiKF) delete negPiKF; negPiKF=NULL;
+       if (posPiKF) delete posPiKF; posPiKF=NULL;
+       if (posPKF)  delete posPKF;  posPKF=NULL;
+       if (negAPKF) delete negAPKF; negAPKF=NULL;  
+       continue;
+    }
        lPdgcodeMother         = lMCESDMother->GetPdgCode();
        lIndexMotherOfMother   = lMCESDMother->GetFirstMother();
        if (lIndexMotherOfMother ==-1) lPdgcodeMotherOfMother = 0;
        else {
          TParticle  *lMCESDMotherOfMother    = stack->Particle(lIndexMotherOfMother);
-         if (!lMCESDMotherOfMother) continue;
+         if (!lMCESDMotherOfMother) {
+        if (negPiKF) delete negPiKF; negPiKF=NULL;
+       if (posPiKF) delete posPiKF; posPiKF=NULL;
+       if (posPKF)  delete posPKF;  posPKF=NULL;
+       if (negAPKF) delete negAPKF; negAPKF=NULL;  
+       continue;
+    }
          lPdgcodeMotherOfMother = lMCESDMotherOfMother->GetPdgCode();
        }
        
@@ -2503,11 +2533,23 @@ void AliAnalysisTaskPerformanceStrange::UserExec(Option_t *)
       // Monte-Carlo particle associated to reconstructed particles:  
       if (fAnalysisMC) {
        AliAODMCParticle *lMCAODPartPos = (AliAODMCParticle*)mcArray->At(lLabelTrackPos);
-       if (!lMCAODPartPos) continue;
+       if (!lMCAODPartPos) {
+        if (negPiKF) delete negPiKF; negPiKF=NULL;
+       if (posPiKF) delete posPiKF; posPiKF=NULL;
+       if (posPKF)  delete posPKF;  posPKF=NULL;
+       if (negAPKF) delete negAPKF; negAPKF=NULL;  
+       continue;
+    }
        AliAODMCParticle *lMCAODPartNeg = (AliAODMCParticle*)mcArray->At(lLabelTrackNeg);
-       if(!lMCAODPartNeg) { 
+       if(!lMCAODPartNeg)  
         // Printf("strange analysis::UserExec:no MC particle for negative daughter\n");
-         continue;
+         {
+        if (negPiKF) delete negPiKF; negPiKF=NULL;
+       if (posPiKF) delete posPiKF; posPiKF=NULL;
+       if (posPKF)  delete posPKF;  posPKF=NULL;
+       if (negAPKF) delete negAPKF; negAPKF=NULL;  
+       continue;
+    
        }
        lPDGCodePosDaughter = lMCAODPartPos->GetPdgCode();
        lPDGCodeNegDaughter = lMCAODPartNeg->GetPdgCode();