]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG4/totEt/AliAnalysisHadEtReconstructed.cxx
Another pass at fixing coverity issues
[u/mrichter/AliRoot.git] / PWG4 / totEt / AliAnalysisHadEtReconstructed.cxx
index 5a3b975dfb17493d9c657ddbe72d30d0ecc06375..38b67f47fc192c12ddac9b29e573b7d31604ac92 100644 (file)
@@ -26,6 +26,7 @@
 #include "TString.h"
 #include "AliAnalysisEtCommon.h"
 #include "AliAnalysisHadEt.h"
+#include "AliLog.h"
 
 using namespace std;
 
@@ -89,8 +90,16 @@ AliAnalysisHadEtReconstructed::~AliAnalysisHadEtReconstructed()
 Int_t AliAnalysisHadEtReconstructed::AnalyseEvent(AliVEvent* ev)
 { // analyse ESD event
     ResetEventValues();
+  if(!ev){
+    AliFatal("ERROR: Event does not exist");   
+    return 0;
+  }
 
     AliESDEvent *realEvent = dynamic_cast<AliESDEvent*>(ev);
+    if(!realEvent){  
+      AliFatal("ERROR: ESD Event does not exist");
+      return 0;
+    }
     //for PID
     AliESDpid *pID = new AliESDpid();
     pID->MakePID(realEvent);
@@ -145,10 +154,14 @@ Int_t AliAnalysisHadEtReconstructed::AnalyseEvent(AliVEvent* ev)
              nSigmaKaon = TMath::Abs(pID->NumberOfSigmasITS(track,AliPID::kKaon));
              nSigmaElectron = TMath::Abs(pID->NumberOfSigmasITS(track,AliPID::kElectron));
            }
-           bool isPion = (nSigmaPion<3.0 && nSigmaProton>2.0 && nSigmaKaon>2.0);
-           bool isElectron = (nSigmaElectron<2.0 && nSigmaPion>4.0 && nSigmaProton>3.0 && nSigmaKaon>3.0);
-           bool isKaon = (nSigmaPion>3.0 && nSigmaProton>2.0 && nSigmaKaon<2.0);
-           bool isProton = (nSigmaPion>3.0 && nSigmaProton<2.0 && nSigmaKaon>2.0);
+//         bool isPion = (nSigmaPion<3.0 && nSigmaProton>2.0 && nSigmaKaon>2.0);
+//         bool isElectron = (nSigmaElectron<2.0 && nSigmaPion>4.0 && nSigmaProton>3.0 && nSigmaKaon>3.0);
+//         bool isKaon = (nSigmaPion>3.0 && nSigmaProton>2.0 && nSigmaKaon<2.0);
+//         bool isProton = (nSigmaPion>3.0 && nSigmaProton<2.0 && nSigmaKaon>2.0);
+         bool isPion = (nSigmaPion<3.0 && nSigmaProton>2.0 && nSigmaKaon>2.0);
+         bool isElectron = (nSigmaElectron<2.0 && nSigmaPion>4.0 && nSigmaProton>3.0 && nSigmaKaon>3.0);
+         bool isKaon = (nSigmaPion>3.0 && nSigmaProton>3.0 && nSigmaKaon<3.0 && track->Pt()<0.45);
+         bool isProton = (nSigmaPion>3.0 && nSigmaProton<3.0 && nSigmaKaon>3.0 && track->Pt()<0.9);
 
            bool unidentified = (!isProton && !isKaon && !isElectron && !isPion);
            Float_t dEdx = track->GetTPCsignal();
@@ -353,11 +366,19 @@ void AliAnalysisHadEtReconstructed::AddEt(Float_t rawEt, Float_t rawEtNoPID, Flo
 }
 
 Bool_t AliAnalysisHadEtReconstructed::IsInPHOS(AliESDtrack *track){//This function will need to be elaborated on later to include PHOS dead channels
+  if(!track){
+    cout<<"Error: Track does not exist!!"<<endl;
+    return kFALSE;
+  }
   return   TMath::Abs(track->Eta()) < fCuts->GetGeometryPhosEtaAccCut()//in eta acceptance
     && track->Phi()*180.0/TMath::Pi() > fCuts->GetGeometryPhosPhiAccMinCut()//greater than the minimum phi
     && track->Phi()*180.0/TMath::Pi() < fCuts->GetGeometryPhosPhiAccMaxCut();//less than the maximum phi
 }
 Bool_t AliAnalysisHadEtReconstructed::IsInEMCAL(AliESDtrack *track){//This function will need to be elaborated on later to include EMCAL dead channels
+  if(!track){
+    cout<<"Error: Track does not exist!!"<<endl;
+    return kFALSE;
+  }
   return   TMath::Abs(track->Eta()) < fCuts->GetGeometryEmcalEtaAccCut()//in eta acceptance
     && track->Phi()*180.0/TMath::Pi() > fCuts->GetGeometryEmcalPhiAccMinCut()//greater than the minimum phi
     && track->Phi()*180.0/TMath::Pi() < fCuts->GetGeometryEmcalPhiAccMaxCut();//less than the maximum phi
@@ -367,7 +388,16 @@ Bool_t AliAnalysisHadEtReconstructed::CheckGoodVertex(AliVParticle* track)
 
     Float_t bxy = 999.;
     Float_t bz = 999.;
-    dynamic_cast<AliESDtrack*>(track)->GetImpactParametersTPC(bxy,bz);
+    if(!track){
+      AliError("ERROR: no track");
+      return kFALSE;
+    }
+    AliESDtrack *esdTrack = dynamic_cast<AliESDtrack*>(track);
+    if(!esdTrack){
+      AliError("ERROR: no track");
+      return kFALSE;
+    }
+    esdTrack->GetImpactParametersTPC(bxy,bz);
 
     bool status = (TMath::Abs(track->Xv()) < fCuts->GetReconstructedVertexXCut()) && 
       (TMath::Abs(track->Yv()) < fCuts->GetReconstructedVertexYCut()) && 
@@ -456,7 +486,7 @@ void AliAnalysisHadEtReconstructed::ResetEventValues(){//resetting event by even
 }
 void AliAnalysisHadEtReconstructed::CreateHistograms(){//Creating histograms and adding them to the output TList
 
-  TString *strTPC = new TString("TPC");
+  //TString *strTPC = new TString("TPC");
   TString *strITS = new TString("ITS");
   TString *strTPCITS = new TString("TPCITS");
   for(Int_t i=0;i<2;i++){
@@ -473,11 +503,12 @@ void AliAnalysisHadEtReconstructed::CreateHistograms(){//Creating histograms and
       maxPtdEdx = 5;
       maxdEdx = 500.0;
       break;
-    case 2:
-      cutName = strTPC;
-      maxPtdEdx = 5;
-      maxdEdx = 500.0;
-      break;
+      //not deleting this completely since we might want to add it back in later
+//     case 2:
+//       cutName = strTPC;
+//       maxPtdEdx = 5;
+//       maxdEdx = 500.0;
+//       break;
     default:
       cerr<<"Error:  cannot make histograms!"<<endl;
       return;
@@ -577,9 +608,9 @@ void AliAnalysisHadEtReconstructed::CreateHistograms(){//Creating histograms and
          default:
            acceptance = sFull;
          }
-         sprintf(histoname,"Reco%s%sAcceptance%s%s",et->Data(),acceptance->Data(),detector->Data(),partid->Data());
-         sprintf(histotitle,"Reconstructed %s with %s acceptance for p_{T}>%s GeV/c%s",etstring->Data(),acceptance->Data(),ptstring->Data(),partidstring->Data());
-         sprintf(xtitle,"Reconstructed %s",etstring->Data());
+         snprintf(histoname,200,"Reco%s%sAcceptance%s%s",et->Data(),acceptance->Data(),detector->Data(),partid->Data());
+         snprintf(histotitle,200,"Reconstructed %s with %s acceptance for p_{T}>%s GeV/c%s",etstring->Data(),acceptance->Data(),ptstring->Data(),partidstring->Data());
+         snprintf(xtitle,50,"Reconstructed %s",etstring->Data());
          CreateHisto1D(histoname,histotitle,xtitle,ytitle->Data(),nbinsEt*2,minEt,maxEt);
        }
       }