Fixing memory leak when running with a centrality train
authorpchrist <pchrist@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 24 Oct 2011 10:13:35 +0000 (10:13 +0000)
committerpchrist <pchrist@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 24 Oct 2011 10:13:35 +0000 (10:13 +0000)
PWG2/EBYE/AliAnalysisTaskBF.cxx
PWG2/EBYE/AliBalance.cxx
PWG2/EBYE/AliBalance.h
PWG2/EBYE/macros/AddTaskBalanceMCCentralityTrain.C
PWG2/EBYE/macros/configBalanceFunctionAnalysis.C

index 717aa30..3703b61 100755 (executable)
@@ -655,6 +655,8 @@ void AliAnalysisTaskBF::UserExec(Option_t *) {
       Printf("ERROR: mcEvent not available");\r
       return;\r
     }\r
+    fHistEventStats->Fill(1); //total events\r
+    fHistEventStats->Fill(2); //offline trigger\r
 \r
     Double_t gReactionPlane = 0., gImpactParameter = 0.;\r
     if(fUseCentrality) {\r
index 720151b..2a52742 100644 (file)
@@ -44,7 +44,8 @@ AliBalance::AliBalance() :
   TObject(), 
   bShuffle(kFALSE),
   fAnalysisLevel("ESD"),
-  fAnalyzedEvents(0) {
+  fAnalyzedEvents(0) ,
+  fCentralityId(0) {
   // Default constructor
  
   for(Int_t i = 0; i < ANALYSIS_TYPES; i++){
@@ -89,8 +90,10 @@ AliBalance::AliBalance() :
 
 //____________________________________________________________________//
 AliBalance::AliBalance(const AliBalance& balance):
-  TObject(balance), bShuffle(balance.bShuffle), fAnalysisLevel(balance.fAnalysisLevel),
-  fAnalyzedEvents(balance.fAnalyzedEvents) {
+  TObject(balance), bShuffle(balance.bShuffle), 
+  fAnalysisLevel(balance.fAnalysisLevel),
+  fAnalyzedEvents(balance.fAnalyzedEvents), 
+  fCentralityId(balance.fCentralityId) {
   //copy constructor
   for(Int_t i = 0; i < ANALYSIS_TYPES; i++){
     fNn[i] = balance.fNn[i];
@@ -138,25 +141,6 @@ AliBalance::~AliBalance() {
   }
 }
 
-
-//____________________________________________________________________//
-/*void AliBalance::SetNumberOfBins(Int_t ibin, Int_t ibins) {
-  // Sets the number of bins for the analyzed interval
-  // Set the same Information for all analyses
-  if(ibin == -1){             
-    for(Int_t i = 0; i < ANALYSIS_TYPES; i++){
-      fNumberOfBins[i] = ibins;
-    }
-  }
-  // Set the Information for one analysis
-  else if(ibin > -1 && ibin < ANALYSIS_TYPES){
-    fNumberOfBins[ibin] = ibins;
-  }
-  else{
-    AliError("Wrong ANALYSIS number!");
-  }
-  }*/
-
 //____________________________________________________________________//
 void AliBalance::SetInterval(Int_t iAnalysisType,
                             Double_t p1Start, Double_t p1Stop,
@@ -186,29 +170,42 @@ void AliBalance::SetInterval(Int_t iAnalysisType,
   else {
     AliError("Wrong ANALYSIS number!");
   }
-
-  //InitHistograms();
 }
 
 //____________________________________________________________________//
 void AliBalance::InitHistograms() {
-  //
+  //Initialize the histograms
   TString histName;
   for(Int_t iAnalysisType = 0; iAnalysisType < ANALYSIS_TYPES; iAnalysisType++) {
-    histName = "fHistP"; histName += gBFAnalysisType[iAnalysisType]; if(bShuffle) histName.Append("_shuffle");
+    histName = "fHistP"; histName += gBFAnalysisType[iAnalysisType]; 
+    if(bShuffle) histName.Append("_shuffle");
+    if(fCentralityId) histName += fCentralityId.Data();
     fHistP[iAnalysisType] = new TH1D(histName.Data(),"",100,fP1Start[iAnalysisType],fP1Stop[iAnalysisType]);
-    histName = "fHistN"; histName += gBFAnalysisType[iAnalysisType]; if(bShuffle) histName.Append("_shuffle");
+
+    histName = "fHistN"; histName += gBFAnalysisType[iAnalysisType]; 
+    if(bShuffle) histName.Append("_shuffle");
+    if(fCentralityId) histName += fCentralityId.Data();
     fHistN[iAnalysisType] = new TH1D(histName.Data(),"",100,fP1Start[iAnalysisType],fP1Stop[iAnalysisType]);
   
-    histName = "fHistPN"; histName += gBFAnalysisType[iAnalysisType]; if(bShuffle) histName.Append("_shuffle");
+    histName = "fHistPN"; histName += gBFAnalysisType[iAnalysisType]; 
+    if(bShuffle) histName.Append("_shuffle");
+    if(fCentralityId) histName += fCentralityId.Data();
     fHistPN[iAnalysisType] = new TH1D(histName.Data(),"",fNumberOfBins[iAnalysisType],fP2Start[iAnalysisType],fP2Stop[iAnalysisType]);
-    histName = "fHistNP"; histName += gBFAnalysisType[iAnalysisType]; if(bShuffle) histName.Append("_shuffle");
+    
+    histName = "fHistNP"; histName += gBFAnalysisType[iAnalysisType]; 
+    if(bShuffle) histName.Append("_shuffle");
+    if(fCentralityId) histName += fCentralityId.Data();
     fHistNP[iAnalysisType] = new TH1D(histName.Data(),"",fNumberOfBins[iAnalysisType],fP2Start[iAnalysisType],fP2Stop[iAnalysisType]);
-    histName = "fHistPP"; histName += gBFAnalysisType[iAnalysisType]; if(bShuffle) histName.Append("_shuffle");
+    
+    histName = "fHistPP"; histName += gBFAnalysisType[iAnalysisType]; 
+    if(bShuffle) histName.Append("_shuffle");
+    if(fCentralityId) histName += fCentralityId.Data();
     fHistPP[iAnalysisType] = new TH1D(histName.Data(),"",fNumberOfBins[iAnalysisType],fP2Start[iAnalysisType],fP2Stop[iAnalysisType]);
-    histName = "fHistNN"; histName += gBFAnalysisType[iAnalysisType]; if(bShuffle) histName.Append("_shuffle");
+    
+    histName = "fHistNN"; histName += gBFAnalysisType[iAnalysisType]; 
+    if(bShuffle) histName.Append("_shuffle");
+    if(fCentralityId) histName += fCentralityId.Data();
     fHistNN[iAnalysisType] = new TH1D(histName.Data(),"",fNumberOfBins[iAnalysisType],fP2Start[iAnalysisType],fP2Stop[iAnalysisType]);
-
   }
 }
 
index 2eaf808..ce7445e 100644 (file)
@@ -39,8 +39,10 @@ class AliBalance : public TObject {
   AliBalance();
   AliBalance(const AliBalance& balance);
   ~AliBalance();
+
+  void SetCentralityIdentifier(const char* centralityId) {
+    fCentralityId = centralityId;}
   
-  //void SetNumberOfBins(Int_t ibin, Int_t ibins);
   void SetAnalysisLevel(const char* analysisLevel) {
     fAnalysisLevel = analysisLevel;}
   void SetShuffle(Bool_t shuffle) {bShuffle = shuffle;}
@@ -107,12 +109,13 @@ class AliBalance : public TObject {
   void PrintResults(Int_t iAnalysisType, TH1D *gHist);
 
  private:
-
   Bool_t bShuffle; //shuffled balance function object
   TString fAnalysisLevel; //ESD, AOD or MC
   Int_t fAnalyzedEvents; //number of events that have been analyzed
 
-  Int_t fNumberOfBins[ANALYSIS_TYPES]; //number of bins of the analyzed interval
+  TString fCentralityId;//Centrality identifier to be used for the histo naming
+
+  Int_t fNumberOfBins[ANALYSIS_TYPES];//number of bins of the analyzed interval
   Double_t fP1Start[ANALYSIS_TYPES];
   Double_t fP1Stop[ANALYSIS_TYPES];
   Double_t fP2Start[ANALYSIS_TYPES];
index efc5b6b..bf60d1c 100644 (file)
@@ -1,6 +1,6 @@
 // now in options\r
 //=============================================//\r
-const char* centralityEstimator = "V0M";\r
+//const char* centralityEstimator = "V0M";\r
 //const char* centralityEstimator = "CL1";\r
 //const char* centralityEstimator = "TRK";\r
 //=============================================//\r
@@ -52,16 +52,16 @@ AliAnalysisTaskBF *AddTaskBalanceMCCentralityTrain(Double_t centrMin=0.,
   AliBalance *bfs = 0;  // shuffled Balance function object\r
 \r
   if (analysisType=="ESD"){\r
-    bf  = GetBalanceFunctionObject("ESD");\r
-    if(gRunShuffling) bfs = GetBalanceFunctionObject("ESD",kTRUE);\r
+    bf  = GetBalanceFunctionObject("ESD",centralityName.Data());\r
+    if(gRunShuffling) bfs = GetBalanceFunctionObject("ESD",centralityName.Data(),kTRUE);\r
   }\r
   else if (analysisType=="AOD"){\r
-    bf  = GetBalanceFunctionObject("AOD");\r
-    if(gRunShuffling) bfs = GetBalanceFunctionObject("AOD",kTRUE);\r
+    bf  = GetBalanceFunctionObject("AOD",centralityName.Data());\r
+    if(gRunShuffling) bfs = GetBalanceFunctionObject("AOD",centralityName.Data(),kTRUE);\r
   }\r
   else if (analysisType=="MC"){\r
-    bf  = GetBalanceFunctionObject("MC");\r
-    if(gRunShuffling) bfs = GetBalanceFunctionObject("MC",kTRUE);\r
+    bf  = GetBalanceFunctionObject("MC",centralityName.Data());\r
+    if(gRunShuffling) bfs = GetBalanceFunctionObject("MC",centralityName.Data(),kTRUE);\r
   }\r
   else{\r
     ::Error("AddTaskBF", "analysis type NOT known.");\r
index 14b5199..c51e2d6 100644 (file)
@@ -1,10 +1,12 @@
 //__________________________________________________//\r
 AliBalance *GetBalanceFunctionObject(const char* analysisLevel = "ESD", \r
+                                    const char* centralityName = 0x0,\r
                                     Bool_t bShuffle = kFALSE) {\r
   //Function to setup the AliBalance object and return it\r
   AliBalance *gBalance = new AliBalance();\r
   gBalance->SetAnalysisLevel(analysisLevel);\r
   gBalance->SetShuffle(bShuffle);\r
+  if(centralityName) gBalance->SetCentralityIdentifier(centralityName);\r
 \r
   //Set all analyses separately\r
   //Rapidity\r