K0s code update (Matt Steinpreis)
authordgangadh <dgangadh@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 28 Nov 2013 10:35:33 +0000 (10:35 +0000)
committerdgangadh <dgangadh@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 28 Nov 2013 10:35:33 +0000 (10:35 +0000)
PWGCF/FEMTOSCOPY/K0Analysis/AliFemtoK0Analysis.cxx
PWGCF/FEMTOSCOPY/K0Analysis/AliFemtoK0Analysis.h
PWGCF/FEMTOSCOPY/K0Analysis/AliFemtoK0EventCollection.cxx

index f377649..bb2d799 100644 (file)
@@ -46,6 +46,8 @@
 //             - 1-mass, 2-v0dca, 3-dddca, 4-combination (used to be v0dca)\r
 //     - added passable argument for two-track minimum separation (10/16/13)\r
 //     - added boolean to turn off field-sign dependence for train (10/30/13)\r
+//     - changed destructors to minimize lost memory (11/27/13)\r
+//     - added Case3D to switch off all 3D objects (11/27/13)\r
 ////////////////////////////////////////////////////////////////////////////////\r
 \r
 \r
@@ -94,6 +96,7 @@ AliAnalysisTaskSE(),
   fFieldPos(kTRUE),\r
   fOnlineCase(kTRUE),\r
   fMeritCase(kTRUE),\r
+  fCase3D(kFALSE),\r
   fMinDecayLength(0.0),\r
   fMeritCutChoice(0),\r
   fMinSep(0.0),\r
@@ -108,12 +111,13 @@ AliAnalysisTaskSE(),
 {\r
 }\r
 //________________________________________________________________________\r
-AliFemtoK0Analysis::AliFemtoK0Analysis(const char *name, bool SignDep, bool FieldPositive, bool OnlineCase, bool MeritCase, float MinDL, int MeritCutChoice, float MinSep) \r
+AliFemtoK0Analysis::AliFemtoK0Analysis(const char *name, bool SignDep, bool FieldPositive, bool OnlineCase, bool MeritCase, bool Case3D, float MinDL, int MeritCutChoice, float MinSep) \r
 : AliAnalysisTaskSE(name),\r
   fSignDep(SignDep),\r
   fFieldPos(FieldPositive),\r
   fOnlineCase(OnlineCase),\r
   fMeritCase(MeritCase),\r
+  fCase3D(Case3D),\r
   fMinDecayLength(MinDL),\r
   fMeritCutChoice(MeritCutChoice),\r
   fMinSep(MinSep),\r
@@ -131,6 +135,7 @@ AliFemtoK0Analysis::AliFemtoK0Analysis(const char *name, bool SignDep, bool Fiel
   fFieldPos    = FieldPositive;\r
   fOnlineCase  = OnlineCase;\r
   fMeritCase   = MeritCase;\r
+  fCase3D              = Case3D;\r
   fMinDecayLength = MinDL;\r
   fMeritCutChoice = MeritCutChoice;\r
   fMinSep              = MinSep;\r
@@ -147,6 +152,7 @@ AliFemtoK0Analysis::AliFemtoK0Analysis(const AliFemtoK0Analysis &obj)
   fFieldPos(obj.fFieldPos),\r
   fOnlineCase(obj.fOnlineCase),\r
   fMeritCase(obj.fMeritCase),\r
+  fCase3D(obj.fCase3D),\r
   fMinDecayLength(obj.fMinDecayLength),\r
   fMeritCutChoice(obj.fMeritCutChoice),\r
   fMinSep(obj.fMinSep),\r
@@ -170,6 +176,7 @@ AliFemtoK0Analysis &AliFemtoK0Analysis::operator=(const AliFemtoK0Analysis &obj)
  fFieldPos     = obj.fFieldPos;\r
  fOnlineCase   = obj.fOnlineCase;\r
  fMeritCase    = obj.fMeritCase;\r
+ fCase3D               = obj.fCase3D;\r
  fMinDecayLength= obj.fMinDecayLength;\r
  fMeritCutChoice= obj.fMeritCutChoice;\r
  fMinSep               = obj.fMinSep;\r
@@ -188,13 +195,22 @@ AliFemtoK0Analysis &AliFemtoK0Analysis::operator=(const AliFemtoK0Analysis &obj)
 AliFemtoK0Analysis::~AliFemtoK0Analysis()\r
 {\r
   // Destructor\r
-  if(fEC) delete fEC;\r
-  if(fEvt) delete fEvt;\r
-  if(fRandomNumber) delete fRandomNumber;\r
-  if(fName) delete fName;\r
-  if(fAOD) delete fAOD;\r
-  if(fOutputList) delete fOutputList;\r
-  if(fPidAOD) delete fPidAOD;\r
+  for(unsigned short i=0; i<kZVertexBins; i++)\r
+  {\r
+    for(unsigned short j=0; j<kCentBins; j++)\r
+    {\r
+      fEC[i][j]->~AliFemtoK0EventCollection();\r
+      fEC[i][j] = NULL;\r
+    }\r
+    delete[] fEC[i]; fEC[i] = NULL;\r
+  }\r
+  delete[] fEC; fEC = NULL;\r
+\r
+  if(fEC){ delete fEC; fEC = NULL;}\r
+  if(fRandomNumber){ delete fRandomNumber; fRandomNumber = NULL;}\r
+  if(fAOD){ delete fAOD; fAOD = NULL;}\r
+  if(fOutputList){ delete fOutputList; fOutputList = NULL;}\r
+  if(fPidAOD){ delete fPidAOD; fPidAOD = NULL;}\r
 }\r
 //________________________________________________________________________\r
 void AliFemtoK0Analysis::MyInit()\r
@@ -348,65 +364,43 @@ void AliFemtoK0Analysis::UserCreateOutputObjects()
   //fOutputList->Add(fHistCRCRSignal);\r
   //fOutputList->Add(fHistCRCRBkg);\r
   \r
-\r
-  //3D out-side-long\r
-  /*TH3F* fHistOSLCentLowKt = new TH3F("fHistOSLCentLowKt","",100,-.5,.5,100,-.5,.5,100,-.5,.5);\r
-  fOutputList->Add(fHistOSLCentLowKt);\r
-  TH3F* fHistOSLCentLowKtBkg = new TH3F("fHistOSLCentLowKtBkg","",100,-.5,.5,100,-.5,.5,100,-.5,.5);\r
-  fOutputList->Add(fHistOSLCentLowKtBkg);\r
-\r
-  TH3F* fHistOSLCentHighKt = new TH3F("fHistOSLCentHighKt","",100,-.5,.5,100,-.5,.5,100,-.5,.5);\r
-  fOutputList->Add(fHistOSLCentHighKt);\r
-  TH3F* fHistOSLCentHighKtBkg = new TH3F("fHistOSLCentHighKtBkg","",100,-.5,.5,100,-.5,.5,100,-.5,.5);\r
-  fOutputList->Add(fHistOSLCentHighKtBkg);\r
-\r
-  TH3F* fHistOSLSemiCentLowKt = new TH3F("fHistOSLSemiCentLowKt","",100,-.5,.5,100,-.5,.5,100,-.5,.5);\r
-  fOutputList->Add(fHistOSLSemiCentLowKt);\r
-  TH3F* fHistOSLSemiCentLowKtBkg = new TH3F("fHistOSLSemiCentLowKtBkg","",100,-.5,.5,100,-.5,.5,100,-.5,.5);\r
-  fOutputList->Add(fHistOSLSemiCentLowKtBkg);\r
-\r
-  TH3F* fHistOSLSemiCentHighKt = new TH3F("fHistOSLSemiCentHighKt","",100,-.5,.5,100,-.5,.5,100,-.5,.5);\r
-  fOutputList->Add(fHistOSLSemiCentHighKt);\r
-  TH3F* fHistOSLSemiCentHighKtBkg = new TH3F("fHistOSLSemiCentHighKtBkg","",100,-.5,.5,100,-.5,.5,100,-.5,.5);\r
-  fOutputList->Add(fHistOSLSemiCentHighKtBkg);*/\r
-\r
   //3D out-side-long\r
   TH3F *fHist3DOSLSignal[10][4];\r
   TH3F *fHist3DOSLBkg[10][4];\r
   \r
-  for(int i3D=0;i3D<10;i3D++){\r
-   for(int j3D=0;j3D<4;j3D++){\r
-    TString *histname = new TString("fHist3DOSL");\r
-    *histname += i3D;\r
-    *histname += j3D;\r
-    histname->Append("Signal");\r
-    fHist3DOSLSignal[i3D][j3D] = new TH3F(histname->Data(),"",100,-.5,.5,100,-.5,.5,100,-.5,.5);\r
-    fOutputList->Add(fHist3DOSLSignal[i3D][j3D]);\r
-    histname->Replace(12,6,"Bkg");\r
-    fHist3DOSLBkg[i3D][j3D] = new TH3F(histname->Data(),"",100,-.5,.5,100,-.5,.5,100,-.5,.5);\r
-    fOutputList->Add(fHist3DOSLBkg[i3D][j3D]);\r
+  if(fCase3D){\r
+   for(int i3D=0;i3D<10;i3D++){\r
+    for(int j3D=0;j3D<4;j3D++){\r
+     TString *histname = new TString("fHist3DOSL");\r
+     *histname += i3D;\r
+     *histname += j3D;\r
+     histname->Append("Signal");\r
+     fHist3DOSLSignal[i3D][j3D] = new TH3F(histname->Data(),"",100,-.5,.5,100,-.5,.5,100,-.5,.5);\r
+     fOutputList->Add(fHist3DOSLSignal[i3D][j3D]);\r
+     histname->Replace(12,6,"Bkg");\r
+     fHist3DOSLBkg[i3D][j3D] = new TH3F(histname->Data(),"",100,-.5,.5,100,-.5,.5,100,-.5,.5);\r
+     fOutputList->Add(fHist3DOSLBkg[i3D][j3D]);\r
+    }\r
    }\r
   }\r
-    \r
-\r
 \r
   //3D Spherical Harmonics\r
-  TH3F* fHistSHCentLowKt = new TH3F("fHistSHCentLowKt","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
-  TH3F* fHistSHCentHighKt = new TH3F("fHistSHCentHighKt","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
-  TH3F* fHistSHSemiCentLowKt = new TH3F("fHistSHSemiCentLowKt","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
-  TH3F* fHistSHSemiCentHighKt = new TH3F("fHistSHSemiCentHighKt","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
-  TH3F* fHistSHCentLowKtBkg = new TH3F("fHistSHCentLowKtBkg","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
-  TH3F* fHistSHCentHighKtBkg = new TH3F("fHistSHCentHighKtBkg","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
-  TH3F* fHistSHSemiCentLowKtBkg = new TH3F("fHistSHSemiCentLowKtBkg","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
-  TH3F* fHistSHSemiCentHighKtBkg = new TH3F("fHistSHSemiCentHighKtBkg","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
-  fOutputList->Add(fHistSHCentLowKt);\r
-  fOutputList->Add(fHistSHCentHighKt);\r
-  fOutputList->Add(fHistSHSemiCentLowKt);\r
-  fOutputList->Add(fHistSHSemiCentHighKt);\r
-  fOutputList->Add(fHistSHCentLowKtBkg);\r
-  fOutputList->Add(fHistSHCentHighKtBkg);\r
-  fOutputList->Add(fHistSHSemiCentLowKtBkg);\r
-  fOutputList->Add(fHistSHSemiCentHighKtBkg);\r
+  //TH3F* fHistSHCentLowKt = new TH3F("fHistSHCentLowKt","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
+  //TH3F* fHistSHCentHighKt = new TH3F("fHistSHCentHighKt","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
+  //TH3F* fHistSHSemiCentLowKt = new TH3F("fHistSHSemiCentLowKt","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
+  //TH3F* fHistSHSemiCentHighKt = new TH3F("fHistSHSemiCentHighKt","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
+  //TH3F* fHistSHCentLowKtBkg = new TH3F("fHistSHCentLowKtBkg","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
+  //TH3F* fHistSHCentHighKtBkg = new TH3F("fHistSHCentHighKtBkg","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
+  //TH3F* fHistSHSemiCentLowKtBkg = new TH3F("fHistSHSemiCentLowKtBkg","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
+  //TH3F* fHistSHSemiCentHighKtBkg = new TH3F("fHistSHSemiCentHighKtBkg","",50,0,.5,ncthetabins,-1,1,nphibins,0,2*PI);\r
+  //fOutputList->Add(fHistSHCentLowKt);\r
+  //fOutputList->Add(fHistSHCentHighKt);\r
+  //fOutputList->Add(fHistSHSemiCentLowKt);\r
+  //fOutputList->Add(fHistSHSemiCentHighKt);\r
+  //fOutputList->Add(fHistSHCentLowKtBkg);\r
+  //fOutputList->Add(fHistSHCentHighKtBkg);\r
+  //fOutputList->Add(fHistSHSemiCentLowKtBkg);\r
+  //fOutputList->Add(fHistSHSemiCentHighKtBkg);\r
 \r
   //side-side\r
   //TH3F* fHistLeftLeftSignal = new TH3F("fHistLeftLeftSignal","", kCentBins, .5, kCentBins+.5, 300, 0., 3., 100, 0., 1);\r
@@ -802,7 +796,7 @@ void AliFemtoK0Analysis::Exec(Option_t *)
   (fEvt)->fNumV0s = unskippedCount;\r
   //Printf("Number of v0s: %d", v0Count);\r
   //Printf("Number of K0s: %d", k0Count);\r
-  tempK0->~AliFemtoK0Particle();\r
+  delete [] tempK0; tempK0 = NULL;\r
 \r
   ((TH1F*)fOutputList->FindObject("fHistMultK0"))->Fill(unskippedCount);       // changed 3/25, used to be "k0Count"\r
 \r
@@ -1083,11 +1077,12 @@ void AliFemtoK0Analysis::Exec(Option_t *)
            //else ((TH3F*)fOutputList->FindObject("fHistCRCRSignal"))->Fill(centBin+1, pairKt, qinv);\r
 \r
            //3D\r
-           if(pairKt > 0.2 && pairKt < 1.5 && centBin > 5){\r
-                   histname3D->Append("Signal");\r
-                       ((TH3F*)fOutputList->FindObject(histname3D->Data()))->Fill(qOutPRF,qSide,qLong);\r
-                  }\r
-             \r
+           if(fCase3D){\r
+            if(pairKt > 0.2 && pairKt < 1.5 && centBin > 5){\r
+                    histname3D->Append("Signal");\r
+                        ((TH3F*)fOutputList->FindObject(histname3D->Data()))->Fill(qOutPRF,qSide,qLong);\r
+                   }\r
+           }  \r
            /*if(pairKt < 1.0){\r
             if(centBin > 13){\r
              ((TH3F*)fOutputList->FindObject("fHistOSLCentLowKt"))->Fill(qOutPRF,qSide,qLong);\r
@@ -1132,10 +1127,12 @@ void AliFemtoK0Analysis::Exec(Option_t *)
            //else ((TH3F*)fOutputList->FindObject("fHistCRCRBkg"))->Fill(centBin+1, pairKt, qinv);\r
 \r
            //3D\r
-           if(pairKt > 0.2 && pairKt < 1.5 && centBin > 5){\r
-                   histname3D->Replace(12,6,"Bkg");\r
-                       ((TH3F*)fOutputList->FindObject(histname3D->Data()))->Fill(qOutPRF,qSide,qLong);\r
-                  }\r
+           if(fCase3D){\r
+            if(pairKt > 0.2 && pairKt < 1.5 && centBin > 5){\r
+                    histname3D->Replace(12,6,"Bkg");\r
+                        ((TH3F*)fOutputList->FindObject(histname3D->Data()))->Fill(qOutPRF,qSide,qLong);\r
+                   }\r
+           }\r
            /*if(pairKt < 1.0){\r
             if(centBin > 13){\r
              ((TH3F*)fOutputList->FindObject("fHistOSLCentLowKtBkg"))->Fill(qOutPRF,qSide,qLong);\r
index 1e127fb..5745194 100644 (file)
@@ -30,7 +30,7 @@ class AliESDpid;
 class AliFemtoK0Analysis : public AliAnalysisTaskSE {
  public:
   AliFemtoK0Analysis();
-  AliFemtoK0Analysis(const char *name, bool SignDep = kFALSE, bool FieldPositive = kTRUE, bool OnlineCase = kTRUE, bool MeritCase = kTRUE, float MinDL = 0.0, int MeritCutChoice = 2, float MinSep = 5.0);
+  AliFemtoK0Analysis(const char *name, bool SignDep = kFALSE, bool FieldPositive = kTRUE, bool OnlineCase = kTRUE, bool MeritCase = kTRUE, bool Case3D = kFALSE, float MinDL = 0.0, int MeritCutChoice = 2, float MinSep = 5.0);
   virtual ~AliFemtoK0Analysis();
   AliFemtoK0Analysis(const AliFemtoK0Analysis&);
   AliFemtoK0Analysis& operator=(const AliFemtoK0Analysis&);
@@ -60,6 +60,7 @@ class AliFemtoK0Analysis : public AliAnalysisTaskSE {
   bool fFieldPos;
   bool fOnlineCase;
   bool fMeritCase;
+  bool fCase3D;
   float fMinDecayLength;
   int fMeritCutChoice;
   float fMinSep;
index bd48718..c3db0a1 100644 (file)
@@ -152,9 +152,11 @@ AliFemtoK0Event &AliFemtoK0Event::operator=(const AliFemtoK0Event &obj)
 AliFemtoK0Event::~AliFemtoK0Event()
 {
  //Destructor
- if(fK0Particle) delete fK0Particle;
+ if(fK0Particle){
+  delete fK0Particle;
+  fK0Particle = NULL;
+ }
 }
-
 //_____________________________________________________________________________
 AliFemtoK0EventCollection::AliFemtoK0EventCollection() : 
  fBufferSize(0),
@@ -211,10 +213,11 @@ AliFemtoK0EventCollection::~AliFemtoK0EventCollection()
  for(int i =0; i < fBufferSize; i++){
   if((fEvt + i)->fK0Particle != NULL){
    delete [] (fEvt + i)->fK0Particle;
+   (fEvt + i)->fK0Particle = NULL;
   }
  }
  
- delete [] fEvt;
+ delete [] fEvt; fEvt = NULL;
 }
 //_____________________________________________________________________________
 void AliFemtoK0EventCollection::FIFOShift(){ //Shift elements in FIFO by one and clear last element in FIFO