]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Fix coverity defects
authorprino <prino@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 7 Jun 2012 07:43:50 +0000 (07:43 +0000)
committerprino <prino@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 7 Jun 2012 07:43:50 +0000 (07:43 +0000)
PWGHF/correlationHF/AliAnalysisTaskDStarCorrelations.cxx
PWGHF/correlationHF/AliHFAssociatedTrackCuts.cxx

index 899557f32d66419ead863dd9e9312cc8591f093b..2324d433a31e468f256a179b7da98f05f5eb09d7 100644 (file)
@@ -179,23 +179,30 @@ void AliAnalysisTaskDStarCorrelations::UserExec(Option_t *){
        cout << " " << endl;
        cout << "=================================================================================" << endl;
        
-if(fselect==1) cout << "TASK::Correlation with hadrons "<< endl;
-if(fselect==2) cout << "TASK::Correlation with kaons "<< endl;
-if(fselect==3) cout << "TASK::Correlation with kzeros "<< endl;
+       if(fselect==1) cout << "TASK::Correlation with hadrons "<< endl;
+       if(fselect==2) cout << "TASK::Correlation with kaons "<< endl;
+       if(fselect==3) cout << "TASK::Correlation with kzeros "<< endl;
        
        if (!fInputEvent) {
                Error("UserExec","NO EVENT FOUND!");
                return;
        }
        
-        AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
+       AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
+       if(!aodEvent){
+         AliError("AOD event not found!");
+         return;
+       }
        Double_t pi = TMath::Pi();
        
        fEvents++; // event counter
        ((TH1D*)fOutput->FindObject("NofEvents"))->Fill(0);
-               
        fmcArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
-               
+       if(fmontecarlo && !fmcArray){
+         AliError("Array of MC particles not found");
+         return;
+       }
+       
        // initialize the pool for event mixing
        Int_t multiplicity = aodEvent->GetNTracks();
        AliAODVertex *vtx = aodEvent->GetPrimaryVertex();
@@ -442,7 +449,7 @@ if(fselect==3) cout << "TASK::Correlation with kzeros "<< endl;
                                        ((TH2I*)fOutput->FindObject("EventMixingCheck"))->Fill(multbinflag,zvtxflag); 
                                        cout << "filling" << endl;}
 
-                               TObjArray* mixedtracks = new TObjArray();
+                               TObjArray* mixedtracks = 0x0;
                                
                                for (Int_t jMix=0; jMix<pool->GetCurrentNEvents(); jMix++) {//loop over the events in the pool
                                        mixedtracks = pool->GetEvent(jMix);
index 683a90da6c8ff04c22e9d95675ea203e803072b5..7f19233a5e723a2e12f989710e51f1437ec21029 100644 (file)
@@ -27,6 +27,7 @@
 #include "AliESDtrackCuts.h"
 #include "AliESDtrack.h"
 #include "AliAODv0.h"
+#include "AliLog.h"
 #include "AliAODVertex.h"
 #include "AliAODMCParticle.h"
 #include "TString.h"
@@ -177,6 +178,7 @@ Bool_t AliHFAssociatedTrackCuts::CheckKaonCompatibility(AliAODTrack * track, Boo
                Int_t hadLabel = track->GetLabel();
                if(hadLabel < 0) return kFALSE;
                AliAODMCParticle* hadron = dynamic_cast<AliAODMCParticle*>(mcArray->At(hadLabel));
+               if(!hadron) return kFALSE;
                Int_t pdg = TMath::Abs(hadron->GetPdgCode()); 
                if (pdg == 321) isKaon = kTRUE;
        }
@@ -245,7 +247,7 @@ Int_t AliHFAssociatedTrackCuts::IsMCpartFromHF(Int_t label, TClonesArray*mcArray
   while(pdgCode!=2212){ // loops back to the collision to check the particle source
 
     mcParticle = dynamic_cast<AliAODMCParticle*>(mcArray->At(label));
-    if(!mcParticle) {cout << "NO MC PARTICLE" << endl; break;}
+    if(!mcParticle) {AliError("NO MC PARTICLE"); break;}
     pdgCode =  TMath::Abs(mcParticle->GetPdgCode());
 
     label = mcParticle->GetMother();