Fixing big memory leaks from empty destructors and fixing some smaller memory leaks
authorcnattras <cnattras@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 19 Dec 2010 22:39:18 +0000 (22:39 +0000)
committercnattras <cnattras@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 19 Dec 2010 22:39:18 +0000 (22:39 +0000)
PWG4/totEt/AliAnalysisEtCommon.cxx
PWG4/totEt/AliAnalysisEtSelectionHandler.cxx
PWG4/totEt/AliAnalysisHadEtMonteCarlo.cxx
PWG4/totEt/AliAnalysisHadEtReconstructed.cxx
PWG4/totEt/AliAnalysisTaskHadEt.cxx
PWG4/totEt/AliAnalysisTaskTransverseEnergy.cxx
PWG4/totEt/macros/CreateAlienHandlerHadEtSim.C
PWG4/totEt/macros/runHadEt.C

index 1d3c1b8..62a73b3 100644 (file)
@@ -121,6 +121,12 @@ void AliAnalysisEtCommon::Init()
   //parameter 0 = dNdy
   //parameter 1 = temp
   //parameter 2 = power
+  if(fK0PythiaD6T) delete fK0PythiaD6T;
+  if(fLambdaPythiaD6T) delete fLambdaPythiaD6T;
+  if(fAntiLambdaPythiaD6T) delete fAntiLambdaPythiaD6T;
+  if(fK0Data) delete fK0Data;
+  if(fLambdaData) delete fLambdaData;
+  if(fAntiLambdaData) delete fAntiLambdaData;
   fK0PythiaD6T = new TF1("K0PythiaD6T",function, &AliAnalysisLevyPt::Evaluate,0,50,3,"AliAnalysisLevyPt","Evaluate");
   fLambdaPythiaD6T = new TF1("LambdaPythiaD6T",function, &AliAnalysisLevyPt::Evaluate,0,50,3,"AliAnalysisLevyPt","Evaluate");
   fAntiLambdaPythiaD6T = new TF1("LambdaPythiaD6T",function, &AliAnalysisLevyPt::Evaluate,0,50,3,"AliAnalysisLevyPt","Evaluate");
@@ -172,6 +178,7 @@ void AliAnalysisEtCommon::Init()
     fAntiLambdaData->SetParameter(1,0.290);
     fAntiLambdaData->SetParameter(2,9.28);
   }
+  if(fLambdaEnhancement) delete fLambdaEnhancement;
   fLambdaEnhancement = new TF1("fLambdaEnhancement","([0]*pow(x,[1])*exp(-pow(x/[2],[3])))/([4]*exp(-pow([5]/x,[6]))+[7]*x)",0,50);
    fLambdaEnhancement->SetParameter(0,0.5630487);
    fLambdaEnhancement->SetParameter(1,1.388818);
@@ -181,6 +188,7 @@ void AliAnalysisEtCommon::Init()
    fLambdaEnhancement->SetParameter(5,2);
    fLambdaEnhancement->SetParameter(6,0.4747893);
    fLambdaEnhancement->SetParameter(7,-0.2250856);
+   if(fProtonEnhancement) delete fProtonEnhancement;
    fProtonEnhancement = new TF1("fProtonEnhancement","[0]*pow(x,[1])*exp(-pow(x/[2],[3]))/([4]+[5]*x)",0,50);
    fProtonEnhancement->SetParameter(0,0.5630487*1.6);
    fProtonEnhancement->SetParameter(1,1.388818);
index 2f09dfd..3fe8220 100644 (file)
@@ -34,8 +34,8 @@ fSelections(0)
 }
 
 AliAnalysisEtSelectionHandler::~AliAnalysisEtSelectionHandler()
-{
-  // Destructor
+{  // Destructor
+  delete fSelections;
 }
 
 AliAnalysisEtSelectionHandler::AliAnalysisEtSelectionHandler(const AliAnalysisEtSelectionHandler& other): TObject(other)
index afb6dc4..f7d031c 100644 (file)
@@ -68,7 +68,7 @@ Int_t AliAnalysisHadEtMonteCarlo::AnalyseEvent(AliVEvent* ev,AliVEvent* ev2)
   AliStack *stack = mcEvent->Stack();
 
   //for PID
-  AliESDpid *pID = new AliESDpid();
+  AliESDpid *pID = new AliESDpid();//This is identified as a memory leak in valgrind but I delete this object so I think it may be a problem with AliESDpid.
 
   //=============================================
 
@@ -81,8 +81,8 @@ Int_t AliAnalysisHadEtMonteCarlo::AnalyseEvent(AliVEvent* ev,AliVEvent* ev2)
   Int_t lastcutset = 1;
   if(fRequireITSHits) lastcutset = 2;
   for(Int_t cutset=0;cutset<=lastcutset;cutset++){
-    TString *cutName;
-    TObjArray* list;
+    TString *cutName = NULL;
+    TObjArray* list = NULL;
     switch(cutset){
     case 0:
       cutName = strTPC;
@@ -447,7 +447,7 @@ Int_t AliAnalysisHadEtMonteCarlo::AnalyseEvent(AliVEvent* ev)
     for (Int_t iPart = 0; iPart < nPrim; iPart++)
     {
 
-        TParticle *part = stack->Particle(iPart);
+      TParticle *part = stack->Particle(iPart);//This line is identified as a loss of memory by valgrind, however, the pointer still belongs to the stack, so it's the stack's problem
 
         if (!part)
          {
@@ -1089,7 +1089,7 @@ void AliAnalysisHadEtMonteCarlo::CreateHistograms(){
   Int_t lastcutset = 1;
   if(fRequireITSHits) lastcutset = 2;
   for(Int_t i=0;i<=lastcutset;i++){
-    TString *cutName;
+    TString *cutName = NULL;
     Float_t maxPtdEdx = 10;
     Float_t mindEdx = 35;
     Float_t maxdEdx = 150.0;
@@ -1231,20 +1231,20 @@ void AliAnalysisHadEtMonteCarlo::CreateHistograms(){
   float etDiff = 1.5;
 
   for(int tpc = 0;tpc<lastcutset;tpc++){
-    TString *detector;
-    TString *ptstring;
+    TString *detector = NULL;
+    TString *ptstring = NULL;
     if(tpc==1) {detector = sTPC; ptstring = sTPCpt;}
     else{detector = sITS; ptstring = sITSpt;}
     for(int hadet = 0;hadet<2;hadet++){
-      TString *et;
-      TString *etstring;
+      TString *et = NULL;
+      TString *etstring = NULL;
       if(hadet==1) {et = sHadEt; etstring = sHadEtString;}
       else{et = sTotEt; etstring = sTotEtString;}
       for(int type = 0;type<3;type++){
        if(type==0 && !fInvestigateFull) continue;
        if(type==1 && !fInvestigateEMCal) continue;
        if(type==2 && !fInvestigatePHOS) continue;
-       TString *acceptance;
+       TString *acceptance = NULL;
        switch(type){
        case 0:
          acceptance = sFull;
@@ -1262,8 +1262,8 @@ void AliAnalysisHadEtMonteCarlo::CreateHistograms(){
          acceptance = sFull;
        }
        for(int pid = 0;pid<2;pid++){
-         TString *partid;
-         TString *partidstring;
+         TString *partid = NULL;
+         TString *partidstring = NULL;
          if(pid==1){partid = sPID; partidstring = sPID;}
          else{partid = sNoPID; partidstring = sNoPIDString;}
          sprintf(histoname,"Sim%sMinusReco%s%sAcceptance%s%s",et->Data(),et->Data(),acceptance->Data(),detector->Data(),partid->Data());
index 492c6f7..27056f1 100644 (file)
@@ -93,8 +93,8 @@ Int_t AliAnalysisHadEtReconstructed::AnalyseEvent(AliVEvent* ev)
     TString *strTPCITS = new TString("TPCITS");
     for(Int_t cutset=0;cutset<2;cutset++){
       bool isTPC = false;
-      TString *cutName;
-      TObjArray* list;
+      TString *cutName = NULL;
+      TObjArray* list = NULL;
       switch(cutset){
       case 0:
        cutName = strTPCITS;
@@ -241,6 +241,7 @@ Int_t AliAnalysisHadEtReconstructed::AnalyseEvent(AliVEvent* ev)
            AddEt(et,etNoID,etpartialcorrected,etpartialcorrectedNoID,track->Pt(),isTPC,inPHOS,inEMCAL);
          }
        }
+      delete list;
     }
     if(GetCorrectedHadEtFullAcceptanceTPC()>0.0)FillHisto1D("RecoHadEtFullAcceptanceTPC",GetCorrectedHadEtFullAcceptanceTPC(),1.0);
     if(GetCorrectedTotEtFullAcceptanceTPC()>0.0)FillHisto1D("RecoTotEtFullAcceptanceTPC",GetCorrectedTotEtFullAcceptanceTPC(),1.0);
@@ -422,7 +423,7 @@ void AliAnalysisHadEtReconstructed::CreateHistograms(){//Creating histograms and
   TString *strITS = new TString("ITS");
   TString *strTPCITS = new TString("TPCITS");
   for(Int_t i=0;i<2;i++){
-    TString *cutName;
+    TString *cutName = NULL;
     Float_t maxPtdEdx = 10;
     Float_t mindEdx = 35;
     Float_t maxdEdx = 150.0;
@@ -512,12 +513,12 @@ void AliAnalysisHadEtReconstructed::CreateHistograms(){//Creating histograms and
     for(int hadet = 0;hadet<3;hadet++){
       for(int type = 0;type<3;type++){
        for(int pid = 0;pid<2;pid++){
-         TString *detector;
-         TString *partid;
+         TString *detector = NULL;
+         TString *partid = NULL;
          TString *et = sHadEt;
-         TString *acceptance;
-         TString *ptstring;
-         TString *partidstring;
+         TString *acceptance = NULL;
+         TString *ptstring = NULL;
+         TString *partidstring = NULL;
          TString *etstring = sHadEtString;
          if(tpc==1) {detector = sTPC; ptstring = sTPCpt;}
          else{detector = sITS; ptstring = sITSpt;}
index a478af5..8cd1b97 100644 (file)
@@ -42,6 +42,9 @@ AliAnalysisTaskHadEt::AliAnalysisTaskHadEt(const char *name, Bool_t isMc) :
   fMCConfigFile = "ConfigHadEtMonteCarlo.C";
   fRecoConfigFile = "ConfigHadEtReconstructed.C";
   
+  if(fMCAnalysis) delete fMCAnalysis;
+  if(fRecAnalysis) delete fRecAnalysis;
+
   if (fMCConfigFile.Length()) {
     cout<<"Rereading AliAnalysisHadEtMonteCarlo configuration file..."<<endl;
     gROOT->LoadMacro(fMCConfigFile);
@@ -84,6 +87,9 @@ void AliAnalysisTaskHadEt::UserCreateOutputObjects()
   }
 
   Bool_t selectPrimaries=kTRUE;
+  if(fEsdtrackCutsITSTPC) delete fEsdtrackCutsITSTPC;
+  if(fEsdtrackCutsITS) delete fEsdtrackCutsITS;
+  if(fEsdtrackCutsTPC) delete fEsdtrackCutsTPC;
   if(fRecAnalysis->DataSet()==2009){
     cout<<"Setting track cuts for the 2009 p+p collisions at 900 GeV"<<endl;
     fEsdtrackCutsITSTPC = AliESDtrackCuts::GetStandardITSTPCTrackCuts2009(selectPrimaries);
index 3685311..ac6a8f5 100644 (file)
@@ -15,6 +15,7 @@
 //_________________________________________________________________________//
 #include "AliESDtrackCuts.h"
 #include "AliLog.h"
+#include "TH2F.h"
 #include <iostream>
 
 ClassImp(AliAnalysisTaskTransverseEnergy)
@@ -41,8 +42,13 @@ AliAnalysisTaskTransverseEnergy::AliAnalysisTaskTransverseEnergy(const char* nam
 }
 
 AliAnalysisTaskTransverseEnergy::~AliAnalysisTaskTransverseEnergy()
-{
-    // destructor
+{    // destructor
+  delete fHistEtRecvsEtMC;
+  delete fEsdtrackCutsITSTPC;
+  delete fEsdtrackCutsTPC;
+  delete fEsdtrackCutsITS;
+  delete fOutputList;
+  delete fSelectionHandler;
 }
 
 Int_t AliAnalysisTaskTransverseEnergy::CheckPhysicsSelection(Int_t runNumber)
index 2493485..c7210e8 100644 (file)
@@ -8,32 +8,48 @@
 
 // Overwrite all generated files, datasets and output results from a previous session
    plugin->SetOverwriteMode();
-// Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
-   //plugin->SetRunMode("full");  // VERY IMPORTANT - DECRIBED BELOW
+// Set the run modSoon a picture of Kim Jong-un (sitting far left) flashed around the world, the first known image of him since his school dayse (can be "full", "test", "offline", "submit" or "terminate")
    plugin->SetRunMode("full");  // VERY IMPORTANT - DECRIBED BELOW
-// Set versions of used packages 
+   //plugin->SetRunMode("test");  // VERY IMPORTANT - DECRIBED BELOW
+   //plugin->SetCheckCopy(kFALSE);
+// Set versions of used packages
    plugin->SetAPIVersion("V1.1x");
-   plugin->SetROOTVersion("v5-27-05");
-   plugin->SetAliROOTVersion("v4-20-08-AN");
+   plugin->SetROOTVersion("v5-27-06b");
+   plugin->SetAliROOTVersion("v4-21-10-AN");
 // Declare input data to be processed.
 
 // Method 1: Create automatically XML collections using alien 'find' command.
 // Define production directory LFN
-//   plugin->SetGridDataDir("/alice/sim/LHC10a18");
+//   plugin->SetGridDataDir("/alice/data/2010/LHC10d");
 // Set data search pattern
 //   plugin->SetDataPattern("*ESDs.root");  // simulated, tags not used
-//   plugin->SetDataPattern("*ESDs/pass4/*ESDs.root"); // real data check reco pass and data base directory
+//   plugin->SetDataPattern("*ESDs/pass2/*ESDs.root"); // real data check reco pass and data base directory
 //   plugin->SetRunPrefix("000");   // real data
 //   plugin->SetDataPattern("*tag.root");  // Use ESD tags (same applies for AOD's)
 // ...then add run numbers to be considered
 //   plugin->AddRunNumber(125020);    // simulated
-//   plugin->AddRunNumber(104065);  // real data
+//   plugin->AddRunNumber(126403);  // real data
+//   plugin->AddRunNumber(126404);  // real data
+//   plugin->AddRunNumber(126405);  // real data
+
+   plugin->SetGridDataDir("/alice/sim/LHC10d4");
+   plugin->SetDataPattern("*ESDs.root");
+   plugin->AddRunNumber(120741);//smallest of the above
+//    plugin->AddRunNumber(120750);
+//    plugin->AddRunNumber(120758);
+//    plugin->AddRunNumber(120820);
+//    plugin->AddRunNumber(120821);
+//    plugin->AddRunNumber(120822);
+//    plugin->AddRunNumber(120823);
+//    plugin->AddRunNumber(120824);
+//    plugin->AddRunNumber(120825);
+//    plugin->AddRunNumber(120829);
 
 // Method 2: Declare existing data files (raw collections, xml collections, root file)
 // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())
 // XML collections added via this method can be combined with the first method if
 // the content is compatible (using or not tags)
-   plugin->AddDataFile("tag.xml");
+//   plugin->AddDataFile("tag.xml");
 //   plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");
 
 // Define alien work directory where all files will be copied. Relative to alien $HOME.
    plugin->SetAnalysisSource("AliAnalysisEtCuts.cxx AliAnalysisHadEtCorrections.cxx AliAnalysisEtCommon.cxx AliAnalysisHadEt.cxx AliAnalysisHadEtMonteCarlo.cxx AliAnalysisHadEtReconstructed.cxx AliAnalysisEtSelectionContainer.cxx AliAnalysisEtSelectionHandler.cxx AliAnalysisTaskTransverseEnergy.cxx AliAnalysisTaskHadEt.cxx");
 // Declare all libraries (other than the default ones for the framework. These will be
 // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
-   plugin->SetAdditionalLibs("AliAnalysisEtCuts.h AliAnalysisEtCuts.cxx AliAnalysisHadEtCorrections.h AliAnalysisHadEtCorrections.cxx  AliAnalysisEtSelectionContainer.cxx AliAnalysisEtSelectionHandler.cxx AliAnalysisTaskTransverseEnergy.cxx AliAnalysisEtCommon.h AliAnalysisEtCommon.cxx AliAnalysisHadEt.cxx AliAnalysisHadEtMonteCarlo.cxx AliAnalysisHadEtReconstructed.cxx AliAnalysisTaskHadEt.cxx AliAnalysisHadEt.h AliAnalysisHadEtMonteCarlo.h AliAnalysisHadEtReconstructed.h AliAnalysisTaskHadEt.h  AliAnalysisEtSelectionContainer.h AliAnalysisEtSelectionHandler.h AliAnalysisTaskTransverseEnergy.h corrections.root ConfigHadEtAnalysis.C ConfigHadEtMonteCarlo.C ConfigHadEtReconstructed.C physicsSelections.root");
+   plugin->SetAdditionalLibs("AliAnalysisEtCuts.h AliAnalysisEtCuts.cxx AliAnalysisHadEtCorrections.h AliAnalysisHadEtCorrections.cxx AliAnalysisEtCommon.h AliAnalysisEtCommon.cxx AliAnalysisHadEt.cxx AliAnalysisHadEtMonteCarlo.cxx AliAnalysisHadEtReconstructed.cxx  AliAnalysisEtSelectionContainer.cxx AliAnalysisEtSelectionHandler.cxx AliAnalysisTaskTransverseEnergy.cxx AliAnalysisTaskHadEt.cxx AliAnalysisHadEt.h AliAnalysisHadEtMonteCarlo.h AliAnalysisHadEtReconstructed.h  AliAnalysisEtSelectionContainer.h AliAnalysisEtSelectionHandler.h AliAnalysisTaskTransverseEnergy.h AliAnalysisTaskHadEt.h physicsSelections.root corrections.root ConfigHadEtAnalysis.C ConfigHadEtMonteCarlo.C ConfigHadEtReconstructed.C");
 // No need for output file names. Procedure is automatic. <-- not true
    plugin->SetDefaultOutputs(kFALSE);
-   plugin->SetOutputFiles("Et.ESD.new.sim.root");
+   plugin->SetOutputFiles("Et.ESD.new.sim.root event_stat.root");
 // No need define the files to be archived. Note that this is handled automatically by the plugin.
 //   plugin->SetOutputArchive("log_archive.zip:stdout,stderr");
 // Set a name for the generated analysis macro (default MyAnalysis.C) Make this unique !
index b80026e..ef9a29c 100644 (file)
@@ -66,10 +66,15 @@ void runHadEt(bool submit = false, bool data = false, bool PbPb = false) {
     handler->SetReadTR(kFALSE);
     mgr->SetMCtruthEventHandler(handler);
   }
+  AliPhysicsSelectionTask *physSelTask = new AliPhysicsSelectionTask("PhysSelTask");
+  mgr->AddTask(physSelTask);
   AliAnalysisTaskHadEt *task2 = new AliAnalysisTaskHadEt("TaskHadEt");
   mgr->AddTask(task2);
   AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
   AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("out2", TList::Class(), AliAnalysisManager::kOutputContainer,"Et.ESD.new.sim.root");
+  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("out1", TList::Class(), AliAnalysisManager::kOutputContainer,"Et.ESD.new.sim.root");
+  mgr->ConnectInput(physSelTask,0,cinput1);
+  mgr->ConnectOutput(physSelTask,1,coutput1);
   mgr->ConnectInput(task2,0,cinput1);
   mgr->ConnectOutput(task2,1,coutput2);