]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Bugfix, fixed memory leaks.
authorkaamodt <kaamodt@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 12 Oct 2009 10:32:13 +0000 (10:32 +0000)
committerkaamodt <kaamodt@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 12 Oct 2009 10:32:13 +0000 (10:32 +0000)
Added functionality to run CF through commandline

PWG4/GammaConv/AliAnalysisTaskGammaConversion.cxx
PWG4/GammaConv/AliAnalysisTaskGammaConversion.h
PWG4/GammaConv/AliV0Reader.cxx
PWG4/GammaConv/AliV0Reader.h
PWG4/macros/ConfigGammaConversion.C

index 6d98107f7252b98f7dd5721070064df5ed428026..4200c79503cca6ad572085f194ff18edeea1c685 100644 (file)
@@ -104,6 +104,7 @@ AliAnalysisTaskSE(),
   fLeadingChargedIndex(-1),
   fLowPtMapping(1.),
   fHighPtMapping(3.),
+  fDoCF(kFALSE),
   fAODBranch(NULL),
   fAODBranchName("GammaConv")//,
   //  fAODObjects(NULL)
@@ -173,6 +174,7 @@ AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion(const char* name)
   fLeadingChargedIndex(-1),
   fLowPtMapping(1.),
   fHighPtMapping(3.),
+  fDoCF(kFALSE),
   fAODBranch(NULL),
   fAODBranchName("GammaConv")//,
   // fAODObjects(NULL)
@@ -253,7 +255,8 @@ void AliAnalysisTaskGammaConversion::Exec(Option_t */*option*/)
   ConnectInputData("");
        
   //Each event needs an empty branch
-  fAODBranch->Clear();
+  //  fAODBranch->Clear();
+  fAODBranch->Delete();
        
   if(fKFReconstructedGammasTClone == NULL){
     fKFReconstructedGammasTClone = new TClonesArray("AliKFParticle",0);
@@ -278,12 +281,18 @@ void AliAnalysisTaskGammaConversion::Exec(Option_t */*option*/)
   }
        
   //clear TClones
-  fKFReconstructedGammasTClone->Clear();
-  fCurrentEventPosElectronTClone->Clear();
-  fCurrentEventNegElectronTClone->Clear();
-  fKFReconstructedGammasCutTClone->Clear();
-  fPreviousEventTLVNegElectronTClone->Clear();
-  fPreviousEventTLVPosElectronTClone->Clear();
+  fKFReconstructedGammasTClone->Delete();
+  fCurrentEventPosElectronTClone->Delete();
+  fCurrentEventNegElectronTClone->Delete();
+  fKFReconstructedGammasCutTClone->Delete();
+  fPreviousEventTLVNegElectronTClone->Delete();
+  fPreviousEventTLVPosElectronTClone->Delete();
+  //fKFReconstructedGammasTClone->Clear();
+  //fCurrentEventPosElectronTClone->Clear();
+  //fCurrentEventNegElectronTClone->Clear();
+  //fKFReconstructedGammasCutTClone->Clear();
+  //fPreviousEventTLVNegElectronTClone->Clear();
+  //fPreviousEventTLVPosElectronTClone->Clear();
        
   //clear vectors
   //  fKFReconstructedGammas.clear();
@@ -293,7 +302,8 @@ void AliAnalysisTaskGammaConversion::Exec(Option_t */*option*/)
   //  fCurrentEventNegElectron.clear();        
   //  fKFReconstructedGammasCut.clear(); 
        
-  fChargedParticles->Clear();  
+  fChargedParticles->Delete(); 
+  //fChargedParticles->Clear();        
   fChargedParticlesId.clear(); 
        
   //Clear the data in the v0Reader
@@ -360,9 +370,11 @@ void AliAnalysisTaskGammaConversion::ProcessMCData(){
        
        
   // for CF
-  if(!fGCMCEvent) cout << "NO MC INFO FOUND" << endl;
-  fCFManager->SetEventInfo(fGCMCEvent);
-  Double_t containerInput[3]; 
+  Double_t containerInput[3];
+  if(fDoCF){
+    if(!fGCMCEvent) cout << "NO MC INFO FOUND" << endl;
+    fCFManager->SetEventInfo(fGCMCEvent);
+  } 
   // end for CF
        
        
@@ -482,17 +494,18 @@ void AliAnalysisTaskGammaConversion::ProcessMCData(){
       fHistograms->FillHistogram("MC_allGamma_Rapid", rapidity);
                        
       // for CF
-      containerInput[0] = particle->Pt();
-      containerInput[1] = particle->Eta();
-      if(particle->GetMother(0) >=0){
-       containerInput[2] = fStack->Particle(particle->GetMother(0))->GetMass();
-      }
-      else{
-       containerInput[2]=-1;
-      }
+      if(fDoCF){
+       containerInput[0] = particle->Pt();
+       containerInput[1] = particle->Eta();
+       if(particle->GetMother(0) >=0){
+         containerInput[2] = fStack->Particle(particle->GetMother(0))->GetMass();
+       }
+       else{
+         containerInput[2]=-1;
+       }
       
-      fCFManager->GetParticleContainer()->Fill(containerInput,kStepGenerated);                                 // generated gamma
-                       
+       fCFManager->GetParticleContainer()->Fill(containerInput,kStepGenerated);                                        // generated gamma
+      }                
       if(particle->GetMother(0) < 0){   // direct gamma
        fHistograms->FillHistogram("MC_allDirectGamma_Energy",particle->Energy());
        fHistograms->FillHistogram("MC_allDirectGamma_Pt", particle->Pt());
@@ -555,8 +568,9 @@ void AliAnalysisTaskGammaConversion::ProcessMCData(){
                
                        
       // for CF
-      fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructable);   // reconstructable gamma        
-                       
+      if(fDoCF){
+       fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructable);  // reconstructable gamma        
+      }
       fHistograms->FillHistogram("MC_ConvGamma_Energy", particle->Energy());
       fHistograms->FillHistogram("MC_ConvGamma_Pt", particle->Pt());
       fHistograms->FillHistogram("MC_ConvGamma_Eta", particle->Eta());
@@ -1294,8 +1308,11 @@ void AliAnalysisTaskGammaConversion::ProcessGammasForNeutralMesonAnalysis(){
            rapidity = 0.5*(TMath::Log((twoGammaCandidate->GetE() +twoGammaCandidate->GetPz()) / (twoGammaCandidate->GetE()-twoGammaCandidate->GetPz())));
          }
                                        
-         if(openingAngleTwoGammaCandidate < fMinOpeningAngleGhostCut) continue;   // minimum opening angle to avoid using ghosttracks
-                                       
+         if(openingAngleTwoGammaCandidate < fMinOpeningAngleGhostCut){
+           delete twoGammaCandidate;
+           continue;   // minimum opening angle to avoid using ghosttracks
+         }
+                       
          fHistograms->FillHistogram("ESD_Mother_GammaDaughter_OpeningAngle", openingAngleTwoGammaCandidate);
          fHistograms->FillHistogram("ESD_Mother_Energy", twoGammaCandidate->GetE());
          fHistograms->FillHistogram("ESD_Mother_Pt", momentumVectorTwoGammaCandidate.Pt());
@@ -1353,8 +1370,10 @@ void AliAnalysisTaskGammaConversion::CalculateBackground(){
                                        
                                        
                                        
-         if(openingAngleBG < fMinOpeningAngleGhostCut ) continue;   // minimum opening angle to avoid using ghosttracks
-                                       
+         if(openingAngleBG < fMinOpeningAngleGhostCut ){
+           delete backgroundCandidate;   
+           continue;   // minimum opening angle to avoid using ghosttracks
+         }                     
                                        
          fHistograms->FillHistogram("ESD_Background_GammaDaughter_OpeningAngle", openingAngleBG);
          fHistograms->FillHistogram("ESD_Background_Energy", backgroundCandidate->GetE());
@@ -1584,7 +1603,10 @@ void AliAnalysisTaskGammaConversion::Terminate(Option_t */*option*/)
 void AliAnalysisTaskGammaConversion::UserCreateOutputObjects()
 {
   //AOD
-  fAODBranch = new TClonesArray("AliGammaConversionAODObject", 0);
+  if(fAODBranch==NULL){
+    fAODBranch = new TClonesArray("AliGammaConversionAODObject", 0);
+  }
+  fAODBranch->Delete();
   fAODBranch->SetName(fAODBranchName); 
   AddAODBranch("TClonesArray", &fAODBranch);
        
@@ -2012,8 +2034,21 @@ void AliAnalysisTaskGammaConversion::ProcessGammaElectronsForChicAnalysis(){
         
         
   */
-       
-       
+
+
+  vESDeNegTemp->Delete();
+  vESDePosTemp->Delete();
+  vESDxNegTemp->Delete();
+  vESDxPosTemp->Delete();
+  vESDeNegNoJPsi->Delete();
+  vESDePosNoJPsi->Delete();
+
+  delete vESDeNegTemp;
+  delete vESDePosTemp;
+  delete vESDxNegTemp;
+  delete vESDxPosTemp;
+  delete vESDeNegNoJPsi;
+  delete vESDePosNoJPsi;       
 }
 
 /*
index 93df3824cb20a8cbee326ff84e0ad7035d23b858..6832f905482e9007e285eda550838f81b39a64f2 100644 (file)
@@ -117,7 +117,8 @@ class AliAnalysisTaskGammaConversion : public AliAnalysisTaskSE
   TClonesArray GetTLorentzVector(TClonesArray* esdTrack);      
   void ProcessGammaElectronsForChicAnalysis();
   ///////////////////////////////////////////////////////////////
-               
+
+  void SetDoCF(Bool_t flag){fDoCF = flag;}
                
  private:
   AliAnalysisTaskGammaConversion(const AliAnalysisTaskGammaConversion&); // Not implemented
@@ -212,16 +213,16 @@ class AliAnalysisTaskGammaConversion : public AliAnalysisTaskSE
   Double_t fMinPtGamChargedCorr; //! transient
   Double_t fMinPtJetCone; //! transient
   Int_t    fLeadingChargedIndex; //! transient
-  Double_t fLowPtMapping;
-  Double_t fHighPtMapping;
-
+  Double_t fLowPtMapping; //! transient
+  Double_t fHighPtMapping; //! transient
+  Bool_t fDoCF; //! transient
                
   TClonesArray* fAODBranch ;        //! selected particles branch
   TString fAODBranchName; // New AOD branch name
                
   //  TClonesArray *fAODObjects;
                
-  ClassDef(AliAnalysisTaskGammaConversion, 4); // Analysis task for gamma conversions
+  ClassDef(AliAnalysisTaskGammaConversion, 5); // Analysis task for gamma conversions
 };
 
 #endif //ALIANALYSISTASKGAMMA_H
index 6a99950091581129273ed1f7f06ee5b012c7590f..7aba652e0ba0884344f5c28a8b733efd99e2939a 100644 (file)
@@ -99,6 +99,7 @@ AliV0Reader::AliV0Reader() :
   fNSigmaMass(0.),
   fUseImprovedVertex(kFALSE),
   fUseOwnXYZCalculation(kFALSE),
+  fDoCF(kFALSE),
   fCurrentEventGoodV0s(),
   fPreviousEventGoodV0s()
 {
@@ -161,6 +162,7 @@ AliV0Reader::AliV0Reader(const AliV0Reader & original) :
   fNSigmaMass(original.fNSigmaMass),
   fUseImprovedVertex(original.fUseImprovedVertex),
   fUseOwnXYZCalculation(original.fUseOwnXYZCalculation),
+  fDoCF(original.fDoCF),
   fCurrentEventGoodV0s(original.fCurrentEventGoodV0s),
   fPreviousEventGoodV0s(original.fPreviousEventGoodV0s)
 {
@@ -210,11 +212,13 @@ void AliV0Reader::Initialize(){
        
   // for CF
   //Get pointer to the mc event
-  fMCEvent = fMCTruth->MCEvent();
-  if(fMCEvent == NULL){
-    //print warning here
-  }    
-       
+  if(fDoCF){
+    fMCEvent = fMCTruth->MCEvent();
+    if(fMCEvent == NULL){
+      //print warning here
+      fDoCF = kFALSE;
+    }  
+  }
        
   AliKFParticle::SetField(fESDEvent->GetMagneticField());
        
@@ -247,10 +251,11 @@ Bool_t AliV0Reader::NextV0(){
     }
 
     Double_t containerInput[3];
-    containerInput[0] = GetMotherCandidatePt();
-    containerInput[1] = GetMotherCandidateEta();
-    containerInput[2] = GetMotherCandidateMass();
-               
+    if(fDoCF){
+      containerInput[0] = GetMotherCandidatePt();
+      containerInput[1] = GetMotherCandidateEta();
+      containerInput[2] = GetMotherCandidateMass();
+    }
 
     //checks if on the fly mode is set
     if ( !fCurrentV0->GetOnFlyStatus() ){
@@ -260,8 +265,10 @@ Bool_t AliV0Reader::NextV0(){
       fCurrentV0IndexNumber++;
       continue;
     }
-    fCFManager->GetParticleContainer()->Fill(containerInput,kStepGetOnFly);            // for CF       
-               
+    if(fDoCF){
+      fCFManager->GetParticleContainer()->Fill(containerInput,kStepGetOnFly);          // for CF       
+    }
+
     //checks if we have a prim vertex
     if(fESDEvent->GetPrimaryVertex()->GetNContributors()<=0) { 
       if(fHistograms != NULL){
@@ -270,8 +277,9 @@ Bool_t AliV0Reader::NextV0(){
       fCurrentV0IndexNumber++;
       continue;
     }
-    fCFManager->GetParticleContainer()->Fill(containerInput,kStepNContributors);               // for CF       
-               
+    if(fDoCF){
+      fCFManager->GetParticleContainer()->Fill(containerInput,kStepNContributors);             // for CF       
+    }
                
     //Check the pid probability
     if(CheckPIDProbability(fPIDProbabilityCutNegativeParticle,fPIDProbabilityCutPositiveParticle)==kFALSE){
@@ -281,8 +289,9 @@ Bool_t AliV0Reader::NextV0(){
       fCurrentV0IndexNumber++;
       continue;
     }
-    fCFManager->GetParticleContainer()->Fill(containerInput,kStepTPCPID);                      // for CF
-               
+    if(fDoCF){
+      fCFManager->GetParticleContainer()->Fill(containerInput,kStepTPCPID);                    // for CF
+    }
                
                
     if(fUseOwnXYZCalculation == kFALSE){
@@ -304,9 +313,10 @@ Bool_t AliV0Reader::NextV0(){
       }
       fCurrentV0IndexNumber++;
       continue;
-    }          
-    fCFManager->GetParticleContainer()->Fill(containerInput,kStepR);                   // for CF
-               
+    }  
+    if(fDoCF){
+      fCFManager->GetParticleContainer()->Fill(containerInput,kStepR);                 // for CF
+    }
                
                
     if((TMath::Abs(fCurrentZValue)*fLineCutZRSlope)-fLineCutZValue > GetXYRadius() ){ // cuts out regions where we do not reconstruct
@@ -315,9 +325,10 @@ Bool_t AliV0Reader::NextV0(){
       }
       fCurrentV0IndexNumber++;
       continue;
-    }          
-    fCFManager->GetParticleContainer()->Fill(containerInput,kStepLine);                        // for CF
-               
+    }
+    if(fDoCF){
+      fCFManager->GetParticleContainer()->Fill(containerInput,kStepLine);                      // for CF
+    }
                
     if(TMath::Abs(fCurrentZValue) > fMaxZ ){ // cuts out regions where we do not reconstruct
       if(fHistograms != NULL){
@@ -325,9 +336,10 @@ Bool_t AliV0Reader::NextV0(){
       }
       fCurrentV0IndexNumber++;
       continue;
-    }          
-    fCFManager->GetParticleContainer()->Fill(containerInput,kStepZ);           // for CF       
-               
+    }
+    if(fDoCF){
+      fCFManager->GetParticleContainer()->Fill(containerInput,kStepZ);         // for CF       
+    }
                
     /* Moved further up so corr framework can work
        if(UpdateV0Information() == kFALSE){
@@ -345,8 +357,9 @@ Bool_t AliV0Reader::NextV0(){
        fCurrentV0IndexNumber++;
        continue;
       }
-      fCFManager->GetParticleContainer()->Fill(containerInput,kStepNDF);               // for CF       
-                       
+      if(fDoCF){
+       fCFManager->GetParticleContainer()->Fill(containerInput,kStepNDF);              // for CF       
+      }
                        
       Double_t chi2V0 = fCurrentMotherKFCandidate->GetChi2()/fCurrentMotherKFCandidate->GetNDF();
       if(chi2V0 > fChi2CutConversion || chi2V0 <=0){
@@ -356,8 +369,9 @@ Bool_t AliV0Reader::NextV0(){
        fCurrentV0IndexNumber++;
        continue;
       }
-      fCFManager->GetParticleContainer()->Fill(containerInput,kStepChi2);                      // for CF
-                       
+      if(fDoCF){
+       fCFManager->GetParticleContainer()->Fill(containerInput,kStepChi2);                     // for CF
+      }
                        
       if(TMath::Abs(fMotherCandidateLorentzVector->Eta())> fEtaCut){
        if(fHistograms != NULL){
@@ -366,8 +380,9 @@ Bool_t AliV0Reader::NextV0(){
        fCurrentV0IndexNumber++;
        continue;
       }
-      fCFManager->GetParticleContainer()->Fill(containerInput,kStepEta);                       // for CF
-                       
+      if(fDoCF){
+       fCFManager->GetParticleContainer()->Fill(containerInput,kStepEta);                      // for CF
+      }
                        
       if(fMotherCandidateLorentzVector->Pt()<fPtCut){
        if(fHistograms != NULL){
@@ -376,8 +391,9 @@ Bool_t AliV0Reader::NextV0(){
        fCurrentV0IndexNumber++;
        continue;
       }
-      fCFManager->GetParticleContainer()->Fill(containerInput,kStepPt);                        // for CF
-                       
+      if(fDoCF){
+       fCFManager->GetParticleContainer()->Fill(containerInput,kStepPt);                       // for CF
+      }
                        
     }
     else if(fUseESDTrack){
@@ -569,14 +585,15 @@ Bool_t AliV0Reader::UpdateV0Information(){
 
   // for CF
   Double_t containerInput[3];
-  containerInput[0] = GetMotherCandidatePt();
-  containerInput[1] = GetMotherCandidateEta();
-  containerInput[2] = GetMotherCandidateMass();
-
-  fCFManager->GetParticleContainer()->Fill(containerInput,kStepLikeSign);              // for CF       
-  fCFManager->GetParticleContainer()->Fill(containerInput,kStepTPCRefit);              // for CF       
-  fCFManager->GetParticleContainer()->Fill(containerInput,kStepKinks);         // for CF       
-
+  if(fDoCF){
+    containerInput[0] = GetMotherCandidatePt();
+    containerInput[1] = GetMotherCandidateEta();
+    containerInput[2] = GetMotherCandidateMass();
+    
+    fCFManager->GetParticleContainer()->Fill(containerInput,kStepLikeSign);            // for CF       
+    fCFManager->GetParticleContainer()->Fill(containerInput,kStepTPCRefit);            // for CF       
+    fCFManager->GetParticleContainer()->Fill(containerInput,kStepKinks);               // for CF       
+  }
   return iResult;
 }
 
index 17460cd97105407a6e8a5458fdc368eb498603de..eaa6109d7ae15e86276428401c70a9b868dacf15 100644 (file)
@@ -581,6 +581,9 @@ class AliV0Reader : public TObject {
   Bool_t GetConvPosXY(AliESDtrack* ptrack,AliESDtrack* ntrack, Double_t b, Double_t convpos[2]);
        
   Double_t GetConvPosZ(AliESDtrack* ptrack,AliESDtrack* ntrack, Double_t b);
+
+  void SetDoCF(Bool_t flag){fDoCF = flag;}
+
        
  private:
   AliStack * fMCStack;           // pointer to MonteCarlo particle stack 
@@ -657,11 +660,13 @@ class AliV0Reader : public TObject {
   Bool_t fUseImprovedVertex; //flag
 
   Bool_t fUseOwnXYZCalculation; //flag that determines if we use our own calculation of xyz (markus)
+
+  Bool_t fDoCF;
        
   vector<AliKFParticle> fCurrentEventGoodV0s; //vector of good v0s
   vector<AliKFParticle> fPreviousEventGoodV0s; // vector of good v0s from prevous events
        
-  ClassDef(AliV0Reader,4)
+  ClassDef(AliV0Reader,5)
 };
 #endif
 
index 5cba718ff7bbd2607313e34679c07ab69d0c4ecd..c3fe9915ed2f743fea2302c513a1a75209e2852a 100644 (file)
@@ -11,6 +11,7 @@ Int_t kGCnumberOfFilesToAnalyze=0;
 Bool_t kGCrunNeutralMeson = kTRUE;
 Bool_t kGCrunJet          = kFALSE;
 Bool_t kGCrunChic         = kFALSE;
+Bool_t kGCrunCF           = kFALSE;
 
 /** ---------------------------------- define cuts here ------------------------------------*/
 
@@ -743,6 +744,11 @@ Bool_t scanArguments(TString arguments){
        cout<<"Running Chi_c analysis"<<endl;
        kGCrunChic = kTRUE;
       }
+      else if (argument.CompareTo("-run-cf") == 0){
+       cout<<"Running CF"<<endl;
+       kGCrunCF = kTRUE;
+      }
+
       else if (argument.CompareTo("-jet-off") == 0){
        cout<<"Skipping jet analysis"<<endl;
        kGCrunJet = kFALSE;
@@ -1099,9 +1105,11 @@ AliAnalysisTaskGammaConversion* ConfigGammaConversion(TString arguments,AliAnaly
   gammaconversion->SetDoNeutralMeson(kGCrunNeutralMeson);
   gammaconversion->SetDoJet(kGCrunJet);
   gammaconversion->SetDoChic(kGCrunChic);
+
   // for CF
   gammaconversion->SetCFManager(man);
-       
+  gammaconversion->SetDoCF(kGCrunCF);
+  v0Reader->SetDoCF(kGCrunCF);
        
   // Add task to the manager 
   mgr->AddTask(gammaconversion);