coverity fixes
authorslindal <slindal@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 24 Jan 2012 08:53:33 +0000 (08:53 +0000)
committerslindal <slindal@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 24 Jan 2012 08:53:33 +0000 (08:53 +0000)
PWGGA/GammaConv/AliAnalysisTaskGammaConversion.cxx
PWGGA/GammaConv/AliConversionCuts.cxx
PWGGA/GammaConv/AliConversionCuts.h

index aad815d..1952231 100644 (file)
@@ -406,7 +406,6 @@ void AliAnalysisTaskGammaConversion::UserExec(Option_t */*option*/)
        // Execute analysis for current event
 
        //      Load the esdpid from the esdhandler if exists (tender was applied) otherwise set the Bethe Bloch parameters
-       Int_t eventQuality=-1;
 
        AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
        AliESDInputHandler *esdHandler=0x0;
@@ -428,6 +427,7 @@ void AliAnalysisTaskGammaConversion::UserExec(Option_t */*option*/)
        if(fAODGamma) fAODGamma->Clear();
        
 
+       Int_t eventQuality=-1;
        if (fMCEvent ) {
                // To avoid crashes due to unzip errors. Sometimes the trees are not there.
 
@@ -1023,14 +1023,18 @@ void AliAnalysisTaskGammaConversion::ProcessMCData(){
                //      for (Int_t iTracks = 0; iTracks < fStack->GetNtrack(); iTracks++) {
                TParticle* particle = (TParticle *)fStack->Particle(iTracks);
 
+                if (!particle) {
+                   //print warning here
+                   continue;
+                }
 
 
-               if (!particle) {
-                       //print warning here
-                       continue;
-               }
-                               
-
+                if(fV0Reader->GetExcludeBackgroundEventForGammaCorrection()){
+                   Bool_t isFromBGEvent = kFALSE;
+                   isFromBGEvent = fV0Reader->IsParticleFromBGEvent(iTracks);
+                   if(isFromBGEvent) continue;
+                }
+                
 
                
                ///////////////////////Begin Chic Analysis/////////////////////////////
@@ -1227,7 +1231,7 @@ void AliAnalysisTaskGammaConversion::ProcessMCData(){
                                fHistograms->FillHistogram("MC_DecayAllGamma_Pt", particle->Pt()); // All
                                switch(fStack->Particle(particle->GetMother(0))->GetPdgCode()){
                                        case 111: // Pi0
-                                               fHistograms->FillHistogram("MC_DecayPi0Gamma_Pt", particle->Pt());
+                                               fHistograms->FillHistogram("MC_DecayPi0Gamma_Pt", particle->Pt());
                                                break;
                                        case 113: // Rho0
                                                fHistograms->FillHistogram("MC_DecayRho0Gamma_Pt", particle->Pt());
@@ -1251,8 +1255,8 @@ void AliAnalysisTaskGammaConversion::ProcessMCData(){
                        }
                        
                        fHistograms->FillHistogram("MC_allGamma_Energy", particle->Energy());
-                       fHistograms->FillHistogram("MC_allGamma_Pt", particle->Pt());
-                       fHistograms->FillHistogram("MC_allGamma_Eta", particle->Eta());
+                        fHistograms->FillHistogram("MC_allGamma_Pt", particle->Pt());
+                        fHistograms->FillHistogram("MC_allGamma_Eta", particle->Eta());
                        fHistograms->FillHistogram("MC_allGamma_Phi", tmpPhi);
                        fHistograms->FillHistogram("MC_allGamma_Rapid", rapidity);
                                        
@@ -1345,8 +1349,8 @@ void AliAnalysisTaskGammaConversion::ProcessMCData(){
                                fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructable);  // reconstructable gamma        
                        }
                        fHistograms->FillHistogram("MC_ConvGamma_Energy", particle->Energy());
-                       fHistograms->FillHistogram("MC_ConvGamma_Pt", particle->Pt());
-                       // Move down, in the if that mother exists
+                        fHistograms->FillHistogram("MC_ConvGamma_Pt", particle->Pt());
+                        // Move down, in the if that mother exists
                        //                      if(fStack->Particle(particle->GetMother(0))->GetPdgCode() == 221)
                        //                      fHistograms->FillHistogram("MC_ConvEtaGamma_Pt", particle->Pt());
                        fHistograms->FillHistogram("MC_ConvGamma_Eta", particle->Eta());
@@ -1800,7 +1804,6 @@ void AliAnalysisTaskGammaConversion::ProcessV0sNoCut(){
                }
 
 
-
                if( !((fV0Reader->GetNegativeESDTrack())->GetStatus() & AliESDtrack::kTPCrefit) || 
                                !((fV0Reader->GetPositiveESDTrack())->GetStatus() & AliESDtrack::kTPCrefit) ){
                        continue;
@@ -1872,7 +1875,7 @@ void AliAnalysisTaskGammaConversion::ProcessV0sNoCut(){
                        if(negativeMC->GetUniqueID() != 5 || positiveMC->GetUniqueID() !=5){ // id 5 is conversion
                                continue;
                        }
-                       
+               
                        if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){                               
                                fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt", fV0Reader->GetMotherCandidatePt());
                                 if(negativeMC->GetMother(0) <= fStack->GetNprimary()){
index 6b243f7..fef4497 100644 (file)
@@ -138,8 +138,8 @@ AliConversionCuts::AliConversionCuts(const char *name,const char *title) : AliAn
     fMinPhotonAsymmetry(0.),
     fIsHeavyIon(kFALSE),
     fMaxVertexZ(10),
-    fUseCentrality(kFALSE),
-    fUseCentralityBin(kFALSE),
+    fUseCentrality(0),
+    fUseCentralityBin(0),
     fUseCorrectedTPCClsInfo(kFALSE),
     fUseTOFpid(kFALSE),
     fAlphaMinCutMeson(0),
@@ -209,12 +209,13 @@ void AliConversionCuts::InitCutHistograms(){
     // IsPhotonSelected
 
     hCutIndex=new TH1F("IsPhotonSelected","IsPhotonSelected",10,-0.5,9.5);
-    hCutIndex->GetXaxis()->SetBinLabel(1,"in");
-    hCutIndex->GetXaxis()->SetBinLabel(2,"no tracks");
-    hCutIndex->GetXaxis()->SetBinLabel(3,"dEdx");
-    hCutIndex->GetXaxis()->SetBinLabel(4,"Track cuts");
-    hCutIndex->GetXaxis()->SetBinLabel(5,"PhotonCuts");
-    hCutIndex->GetXaxis()->SetBinLabel(6,"out");
+    hCutIndex->GetXaxis()->SetBinLabel(kPhotonIn+1,"in");
+    hCutIndex->GetXaxis()->SetBinLabel(kOnFly+1,"onfly");
+    hCutIndex->GetXaxis()->SetBinLabel(kNoTracks+1,"no tracks");
+    hCutIndex->GetXaxis()->SetBinLabel(kdEdxCuts+1,"dEdx");
+    hCutIndex->GetXaxis()->SetBinLabel(kTrackCuts+1,"Track cuts");
+    hCutIndex->GetXaxis()->SetBinLabel(kPhotonCuts+1,"PhotonCuts");
+    hCutIndex->GetXaxis()->SetBinLabel(kPhotonOut+1,"out");
     fHistograms->Add(hCutIndex);
 
     // Track Cuts
@@ -455,6 +456,10 @@ Bool_t AliConversionCuts::PhotonCuts(AliConversionPhotonBase *photon,AliVEvent *
     if(hPhotonCuts)hPhotonCuts->Fill(cutIndex);
     cutIndex++;
 
+    // Fill Histos before Cuts
+    if(hInvMassbefore)hInvMassbefore->Fill(photon->GetPhotonMass());
+    if(hArmenterosbefore)hArmenterosbefore->Fill(photon->GetArmenterosAlpha(),photon->GetArmenterosQt());
+
     // Gamma selection based on QT from Armenteros
     if(fDoQtGammaSelection == kTRUE){
        if(!ArmenterosQtCut(photon)){
@@ -516,6 +521,12 @@ Bool_t AliConversionCuts::PhotonCuts(AliConversionPhotonBase *photon,AliVEvent *
 
     cutIndex++; //9
     if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //9
+
+    // Histos after Cuts
+    if(hInvMassafter)hInvMassafter->Fill(photon->GetPhotonMass());
+    if(hArmenterosafter)hArmenterosafter->Fill(photon->GetArmenterosAlpha(),photon->GetArmenterosQt());
+
+
     return kTRUE;
 
 }
@@ -555,61 +566,43 @@ Bool_t AliConversionCuts::CorrectedTPCClusterCut(AliConversionPhotonBase *photon
     return kTRUE;
 }
 
-
 ///________________________________________________________________________
-Bool_t AliConversionCuts::PhotonIsSelected(AliConversionPhotonBase *photon, AliVEvent * event,Bool_t DoOnlyPhotonCuts) {
+Bool_t AliConversionCuts::PhotonIsSelected(AliConversionPhotonBase *photon, AliVEvent * event)
+{
     //Selection of Reconstructed Photons
 
-   Int_t cutIndex=0;
-   if(hCutIndex)hCutIndex->Fill(cutIndex);
-   cutIndex++;
-
-   // Fill Histos before Cuts
-  if(hInvMassbefore)hInvMassbefore->Fill(photon->GetPhotonMass());
-  if(hArmenterosbefore)hArmenterosbefore->Fill(photon->GetArmenterosAlpha(),photon->GetArmenterosQt());
-
-  //Track cuts, if
-  if(!DoOnlyPhotonCuts){
-      // Get Tracks
-      AliVTrack * negTrack = GetTrack(event, photon->GetTrackLabelNegative());
-      AliVTrack * posTrack = GetTrack(event, photon->GetTrackLabelPositive());
-
-      if(!negTrack || !posTrack) {
-         if(hCutIndex)hCutIndex->Fill(cutIndex);
-         return kFALSE;
-      }
-      cutIndex++; //1
+    FillPhotonCutIndex(kPhotonIn);
 
-      // dEdx Cuts
-      if(!dEdxCuts(negTrack) || !dEdxCuts(posTrack)) {
-         if(hCutIndex)hCutIndex->Fill(cutIndex);
-         return kFALSE;
-      }
-      cutIndex++;
+    // Get Tracks
+    AliVTrack * negTrack = GetTrack(event, photon->GetTrackLabelNegative());
+    AliVTrack * posTrack = GetTrack(event, photon->GetTrackLabelPositive());
 
-      // Track Cuts
-      if(!TracksAreSelected(negTrack, posTrack)){
-         if(hCutIndex)hCutIndex->Fill(cutIndex);//4
-         return kFALSE;
-      }
-      cutIndex++;
-  }
-  else{cutIndex+=3;}
+    if(!negTrack || !posTrack) {
+       FillPhotonCutIndex(kNoTracks);
+       return kFALSE;
+    }
 
-  // Photon Cuts
-  if(!PhotonCuts(photon,event)){
-      if(hCutIndex)hCutIndex->Fill(cutIndex);
-      return kFALSE;
-  }
-  cutIndex++;
+    // dEdx Cuts
+    if(!dEdxCuts(negTrack) || !dEdxCuts(posTrack)) {
+       FillPhotonCutIndex(kdEdxCuts);
+       return kFALSE;
+    }
 
+    // Track Cuts
+    if(!TracksAreSelected(negTrack, posTrack)){
+       FillPhotonCutIndex(kTrackCuts);
+       return kFALSE;
+    }
 
-  // Photon passed cuts
-  if(hCutIndex)hCutIndex->Fill(cutIndex);
-  if(hInvMassafter)hInvMassafter->Fill(photon->GetPhotonMass());
-  if(hArmenterosafter)hArmenterosafter->Fill(photon->GetArmenterosAlpha(),photon->GetArmenterosQt());
+    // Photon Cuts
+    if(!PhotonCuts(photon,event)){
+       FillPhotonCutIndex(kPhotonCuts);
+       return kFALSE;
+    }
 
-  return kTRUE;
+    // Photon passed cuts
+    FillPhotonCutIndex(kPhotonOut);
+    return kTRUE;
 }
 
 ///________________________________________________________________________
@@ -645,7 +638,7 @@ Bool_t AliConversionCuts::MesonIsSelected(AliAODConversionMother *pi0,Bool_t IsS
     cutIndex++;
 
     // Opening Angle Cut
-    fOpeningAngle=2*TMath::ATan(0.134/pi0->P());// physical minimum opening angle
+    //fOpeningAngle=2*TMath::ATan(0.134/pi0->P());// physical minimum opening angle
     if(pi0->GetOpeningAngle()<fOpeningAngle){
        if(hist)hist->Fill(cutIndex);
        return kFALSE;
@@ -1166,12 +1159,6 @@ Bool_t AliConversionCuts::SetCut(cutIds cutID, const Int_t value) {
 
   cout << "Updating cut  " << fgkCutNames[cutID] << " (" << cutID << ") to " << value << endl;
 
-  if(cutID >= kNCuts) {
-       cout << "Error:: Cut id "<<  cutID << " outside range of kNCuts " << kNCuts << endl;
-       return kFALSE;
-  }
-
-
 
   switch (cutID) {
   case kgoodId:
@@ -1399,6 +1386,7 @@ Bool_t AliConversionCuts::SetCut(cutIds cutID, const Int_t value) {
        return kFALSE;
   }
 
+  cout << "Error:: Cut id " << cutID << " not recognized "<< endl;
   return kFALSE;
 
 
@@ -1407,6 +1395,7 @@ Bool_t AliConversionCuts::SetCut(cutIds cutID, const Int_t value) {
 
 
 
+
   // case kv0FinderType:
   //   fCuts[kv0FinderType] = value;
   //   if(!SetV0Finder(fCuts[kv0FinderType]))return kFALSE;
@@ -2297,19 +2286,24 @@ Bool_t AliConversionCuts::SetTRDElectronCut(Int_t TRDElectronCut)
     switch(TRDElectronCut){
     case 0:
        fDoTRDPID=kFALSE;
+       break;
     case 1:
        fDoTRDPID=kTRUE;
        fPIDTRDEfficiency=0.1;
+       break;
     case 8:
        fDoTRDPID=kTRUE;
        fPIDTRDEfficiency=0.8;
+       break;
     case 9:
        fDoTRDPID=kTRUE;
        fPIDTRDEfficiency=0.9;
+       break;
     default:
         cout<<"Warning: TRDElectronCut not defined "<<TRDElectronCut<<endl;
        return kFALSE;
     }
+
     return kTRUE;
 }
 ///________________________________________________________________________
index 9c71826..b84d6ae 100644 (file)
@@ -13,6 +13,7 @@
 #include "AliAODTrack.h"
 #include "AliStack.h"
 #include "AliAnalysisCuts.h"
+#include "TH1F.h"
 
 class AliESDEvent;
 class AliAODEvent;
@@ -76,6 +77,17 @@ class AliConversionCuts : public AliAnalysisCuts {
        kNCuts
   };
 
+  enum photonCuts {
+      kPhotonIn=0,
+      kOnFly,
+      kNoTracks,
+      kTrackCuts,
+      kdEdxCuts,
+      kPhotonCuts,
+      kPhotonOut
+  };
+
+
   Bool_t SetCutIds(TString cutString); 
   Int_t fCuts[kNCuts];
   Bool_t SetCut(cutIds cutID, Int_t cut);
@@ -100,7 +112,7 @@ class AliConversionCuts : public AliAnalysisCuts {
 
   // Cut Selection
   Bool_t EventIsSelected(AliVEvent *fInputEvent);
-  Bool_t PhotonIsSelected(AliConversionPhotonBase * photon, AliVEvent  * event,Bool_t DoOnlyPhotonCuts=kFALSE);
+  Bool_t PhotonIsSelected(AliConversionPhotonBase * photon, AliVEvent  * event);
   Bool_t PhotonIsSelectedMC(TParticle *particle,AliStack *fMCStack);
   Bool_t TracksAreSelected(AliVTrack * negTrack, AliVTrack * posTrack);
   Bool_t MesonIsSelected(AliAODConversionMother *pi0,Bool_t IsSignal=kTRUE);
@@ -118,6 +130,7 @@ class AliConversionCuts : public AliAnalysisCuts {
   void InitCutHistograms();
   void SetFillCutHistograms(){if(!fHistograms){InitCutHistograms();};}
   TList *GetCutHistograms(){return fHistograms;}
+  void FillPhotonCutIndex(Int_t photoncut){if(hCutIndex)hCutIndex->Fill(photoncut);}
 
   AliVTrack * GetTrack(AliVEvent * event, Int_t label) const;
 
@@ -245,8 +258,8 @@ class AliConversionCuts : public AliAnalysisCuts {
   Double_t fMinPhotonAsymmetry;  // Asymmetry Cut
   Bool_t fIsHeavyIon;               // flag for heavy ion
   Double_t fMaxVertexZ;    // max z offset of vertex
-  Bool_t fUseCentrality;  // centrality selection
-  Bool_t fUseCentralityBin; // centrality selection with individual bins
+  Int_t fUseCentrality;  // centrality selection
+  Int_t fUseCentralityBin; // centrality selection with individual bins
   Bool_t fUseCorrectedTPCClsInfo; // flag to use corrected tpc cl info
   Bool_t fUseTOFpid; // flag to use tof pid
   Double_t fAlphaMinCutMeson; // min value for meson alpha cut