Coverity fixes (FORWARD NULL and DEADCODE)
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 27 Jan 2011 07:52:14 +0000 (07:52 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 27 Jan 2011 07:52:14 +0000 (07:52 +0000)
ANALYSIS/AliAnalysisTaskAODCentralityMaker.cxx
ANALYSIS/AliAnalysisTaskME.cxx
ANALYSIS/AliAnalysisTaskSE.cxx
ANALYSIS/AliCentralitySelectionTask.cxx
ANALYSIS/AliFileMerger.cxx
ANALYSIS/AliTagAnalysis.cxx
ANALYSIS/AliXMLCollection.cxx

index 46ba358..cee25d4 100644 (file)
@@ -45,6 +45,7 @@
 #include "AliGenEventHeader.h"
 #include "AliGenHijingEventHeader.h"
 #include "AliAnalysisTaskAODCentralityMaker.h"
+#include "AliLog.h"
 
 ClassImp(AliAnalysisTaskAODCentralityMaker)
 
@@ -122,7 +123,11 @@ void AliAnalysisTaskAODCentralityMaker::UserExec(Option_t */*option*/)
 {
   AliVEvent*   event = InputEvent();
   AliESDEvent* esd   = dynamic_cast<AliESDEvent*>(event);
-
+  if (!esd) {
+      AliError("No ESD Event");
+      return;
+  }
+  
   Float_t beamEnergy = esd->GetBeamEnergy();
   Int_t   nTracks    = event->GetNumberOfTracks();     
   Int_t   nPmdTracks = esd->GetNumberOfPmdTracks();     
index 1b37176..ea16666 100644 (file)
@@ -155,12 +155,13 @@ void AliAnalysisTaskME::Exec(Option_t* option)
 //
 // Was event selected ? If no event selection mechanism, the event SHOULD be selected (AG)
     UInt_t isSelected = AliVEvent::kAny;
-    if( fInputHandler && fInputHandler->GetEventSelection()) {
+    if(fInputHandler && fInputHandler->GetEventSelection()) {
       // Get the actual offline trigger mask for the event and AND it with the
       // requested mask. If no mask requested select by default the event.
       if (fOfflineTriggerMask)
        isSelected = fOfflineTriggerMask & fInputHandler->IsEventSelected();
     }
+    
     if (!isSelected) { 
        if (fDebug > 1) AliInfo("Event rejected \n");
        fInputHandler->EventSkipped();
@@ -168,7 +169,7 @@ void AliAnalysisTaskME::Exec(Option_t* option)
     }
 // Call the user analysis    
     
-    if (fInputHandler->IsBufferReady()) {
+    if (fInputHandler && fInputHandler->IsBufferReady()) {
        if ((fFreshBufferOnly && fInputHandler->IsFreshBuffer()) || !fFreshBufferOnly)
        {
            if (outputHandler) outputHandler->SetFillAOD(kTRUE);
index 18be81f..abbe975 100644 (file)
@@ -345,56 +345,57 @@ void AliAnalysisTaskSE::Exec(Option_t* option)
     if (handler && aodH) {
        fMCEvent = aodH->MCEvent();
        Bool_t merging = aodH->GetMergeEvents();
-       
-       if (!(handler->IsStandard()) && !(handler->AODIsReplicated())) {
+       AliAODEvent* aod = dynamic_cast<AliAODEvent*>(InputEvent());
+
+       if (aod && !(handler->IsStandard()) && !(handler->AODIsReplicated())) {
            if ((handler->NeedsHeaderReplication()) && (fgAODHeader))
            {
              // copy the contents by assigment
-             *fgAODHeader =  *(dynamic_cast<AliAODHeader*>(InputEvent()->GetHeader()));
+             *fgAODHeader =  *(aod->GetHeader());
            }
            if ((handler->NeedsTracksBranchReplication() || merging) && (fgAODTracks))
            {
-               TClonesArray* tracks = (dynamic_cast<AliAODEvent*>(InputEvent()))->GetTracks();
+               TClonesArray* tracks = aod->GetTracks();
                new (fgAODTracks) TClonesArray(*tracks);
            }
            if ((handler->NeedsVerticesBranchReplication() || merging) && (fgAODVertices))
            {
-               TClonesArray* vertices = (dynamic_cast<AliAODEvent*>(InputEvent()))->GetVertices();
+               TClonesArray* vertices = aod->GetVertices();
                new (fgAODVertices) TClonesArray(*vertices);
            }
            if ((handler->NeedsV0sBranchReplication()) && (fgAODV0s))
            {
-               TClonesArray* v0s = (dynamic_cast<AliAODEvent*>(InputEvent()))->GetV0s();
+               TClonesArray* v0s = aod->GetV0s();
                new (fgAODV0s) TClonesArray(*v0s);
            }
            if ((handler->NeedsTrackletsBranchReplication()) && (fgAODTracklets))
            {
-             *fgAODTracklets = *(dynamic_cast<AliAODEvent*>(InputEvent()))->GetTracklets();
+             *fgAODTracklets = *aod->GetTracklets();
            }
            if ((handler->NeedsPMDClustersBranchReplication()) && (fgAODPMDClusters))
            {
-               TClonesArray* pmdClusters = (dynamic_cast<AliAODEvent*>(InputEvent()))->GetPmdClusters();
+               TClonesArray* pmdClusters = aod->GetPmdClusters();
                new (fgAODPMDClusters) TClonesArray(*pmdClusters);
            }
            if ((handler->NeedsJetsBranchReplication() || merging) && (fgAODJets))
            {
-               TClonesArray* jets = (dynamic_cast<AliAODEvent*>(InputEvent()))->GetJets();
+               TClonesArray* jets = aod->GetJets();
                new (fgAODJets) TClonesArray(*jets);
            }
            if ((handler->NeedsFMDClustersBranchReplication()) && (fgAODFMDClusters))
            {
-               TClonesArray* fmdClusters = (dynamic_cast<AliAODEvent*>(InputEvent()))->GetFmdClusters();
+               TClonesArray* fmdClusters = aod->GetFmdClusters();
                new (fgAODFMDClusters) TClonesArray(*fmdClusters);
            }
            if ((handler->NeedsCaloClustersBranchReplication() || merging) && (fgAODCaloClusters))
            {
-               TClonesArray* caloClusters = (dynamic_cast<AliAODEvent*>(InputEvent()))->GetCaloClusters();
+               TClonesArray* caloClusters = aod->GetCaloClusters();
                new (fgAODCaloClusters) TClonesArray(*caloClusters);
            }
 
            if ((handler->NeedsMCParticlesBranchReplication() || merging) && (fgAODMCParticles))
            {
-               TClonesArray* mcParticles = (TClonesArray*) ((dynamic_cast<AliAODEvent*>(InputEvent()))->FindListObject("mcparticles"));
+               TClonesArray* mcParticles = (TClonesArray*) (aod->FindListObject("mcparticles"));
                new (fgAODMCParticles) TClonesArray(*mcParticles);
            }
            
index b372377..d3ab613 100644 (file)
@@ -350,7 +350,11 @@ void AliCentralitySelectionTask::UserExec(Option_t */*option*/)
 \r
     AliVEvent* event = InputEvent();\r
     AliESDEvent* esd = dynamic_cast<AliESDEvent*>(event);\r
-  \r
+    if (!esd) {\r
+       AliError("No ESD Event");\r
+       return;\r
+    }\r
+    \r
     if (fRunNo<=0) {\r
       if (SetupRun(esd)<0)\r
          AliFatal("Centrality File not available for this run");\r
@@ -460,17 +464,18 @@ void AliCentralitySelectionTask::UserExec(Option_t */*option*/)
   //  else     printf("  Centrality by V0 vs TKL not available!!!\n\n");\r
   if(fHtempZEMvsZDC) fCentZEMvsZDC = fHtempZEMvsZDC->GetBinContent(fHtempZEMvsZDC->FindBin((zem1Energy+zem2Energy)/1000.));\r
   //  else     printf("  Centrality by ZEM vs ZDC not available!!!\n\n");\r
-\r
-  esdCent->SetCentralityV0M(fCentV0M);\r
-  esdCent->SetCentralityFMD(fCentFMD);\r
-  esdCent->SetCentralityTRK(fCentTRK);\r
-  esdCent->SetCentralityTKL(fCentTKL);\r
-  esdCent->SetCentralityCL0(fCentCL0);\r
-  esdCent->SetCentralityCL1(fCentCL1);\r
-  esdCent->SetCentralityV0MvsFMD(fCentV0MvsFMD);\r
-  esdCent->SetCentralityTKLvsV0M(fCentTKLvsV0M);\r
-  esdCent->SetCentralityZEMvsZDC(fCentZEMvsZDC);\r
-\r
+  if (esdCent) {\r
+      esdCent->SetCentralityV0M(fCentV0M);\r
+      esdCent->SetCentralityFMD(fCentFMD);\r
+      esdCent->SetCentralityTRK(fCentTRK);\r
+      esdCent->SetCentralityTKL(fCentTKL);\r
+      esdCent->SetCentralityCL0(fCentCL0);\r
+      esdCent->SetCentralityCL1(fCentCL1);\r
+      esdCent->SetCentralityV0MvsFMD(fCentV0MvsFMD);\r
+      esdCent->SetCentralityTKLvsV0M(fCentTKLvsV0M);\r
+      esdCent->SetCentralityZEMvsZDC(fCentZEMvsZDC);\r
+  }\r
+  \r
   fHOutCentV0M->Fill(fCentV0M);\r
   fHOutCentFMD->Fill(fCentFMD);\r
   fHOutCentTRK->Fill(fCentTRK);\r
index 03a00d7..1373894 100644 (file)
@@ -121,13 +121,10 @@ void AliFileMerger::IterAlien(const char* outputDir, const char* outputFileName,
 
     if(currentFile) delete currentFile;
   }
-  Bool_t separate = kFALSE;
-  if (separate) {
-    StoreSeparateResults(mergeArray,outputFileName);
-  }
-  else {
+
+  // StoreSeparateResults(mergeArray,outputFileName);
     StoreResults(mergeArray,outputFileName);
-  }
+
   delete mergeArray;
   delete res;
 
index ff00c86..5f09ced 100644 (file)
@@ -118,7 +118,7 @@ void AliTagAnalysis::ChainLocalTags(const char *dirname) {
   const char * name = 0x0;
   // Add all files matching *pattern* to the chain
   while((name = gSystem->GetDirEntry(dirp))) {
-    if (strstr(name,tagPattern)) { 
+    if (tagPattern && strstr(name,tagPattern)) { 
       fTagFilename = fTagDirName;
       fTagFilename += "/";
       fTagFilename += name;
@@ -596,7 +596,7 @@ TChain *AliTagAnalysis::GetInputChain(const char* system, const char *wn) {
   collection->Reset();
   while (collection->Next()) {
     AliInfo(Form("Adding: %s",collection->GetTURL("")));
-    fAnalysisChain->Add(collection->GetTURL(""));
+    if (fAnalysisChain) fAnalysisChain->Add(collection->GetTURL(""));
     TEntryList *list = (TEntryList *)collection->GetEventList("");
     for(Int_t i = 0; i < list->GetN(); i++) fEventList->Enter(iAccepted+list->GetEntry(i));
 
@@ -604,7 +604,7 @@ TChain *AliTagAnalysis::GetInputChain(const char* system, const char *wn) {
     else if(fsystem == "PbPb") iAccepted += 1;
   }
 
-  fAnalysisChain->SetEventList(fEventList);
+  if (fAnalysisChain) fAnalysisChain->SetEventList(fEventList);
   
   AliInfo(Form("Number of selected events: %d",fEventList->GetN()));
 
index 9b1d457..90f434a 100644 (file)
@@ -425,7 +425,6 @@ void AliXMLCollection::ParseXML() {
     AliError(Form("cannot find the <event> tag in %s",fXmlFile.Data()));
     return;
   }
-  if (!xevent) return;
   
   do {
     if (xml.GetAttr(xevent, "name")) {