Coverity Fix CID 22307:
authormiweber <m.weber@cern.ch>
Mon, 3 Nov 2014 14:36:31 +0000 (15:36 +0100)
committermiweber <m.weber@cern.ch>
Mon, 3 Nov 2014 14:56:50 +0000 (15:56 +0100)
- check for AOD header before header->GetCentralityP()

PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskEffContBF.cxx

index 9ea3f58..1e4ed64 100644 (file)
@@ -386,11 +386,16 @@ void AliAnalysisTaskEffContBF::UserExec(Option_t *) {
   fHistEventStats->Fill(1); //all events
   
   //Centrality stuff
-  AliAODHeader *header = dynamic_cast<AliAODHeader*>(fAOD->GetHeader());
   Double_t nCentrality = 0;
-  
   if(fUseCentrality) {
-    AliCentrality *centrality = header->GetCentralityP();
+    
+    AliAODHeader *headerAOD = dynamic_cast<AliAODHeader*>(fAOD->GetHeader());
+    if (!headerAOD){
+      AliFatal("AOD header found");
+      return;
+    }
+
+    AliCentrality *centrality = headerAOD->GetCentralityP();
     nCentrality =centrality->GetCentralityPercentile(fCentralityEstimator.Data());