Coverity fixes (Chiara, Diego, Ivana)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 4 Mar 2011 16:05:03 +0000 (16:05 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 4 Mar 2011 16:05:03 +0000 (16:05 +0000)
PWG3/muon/AliAnalysisTaskSingleMu.cxx
PWG3/muondep/AliCheckMuonDetEltResponse.cxx
PWG3/vertexingHF/AliCFTaskVertexingHF.cxx
PWG3/vertexingHF/AliCFVertexingHF.cxx
PWG3/vertexingHF/AliCFVertexingHF.h

index 67132ae..d43f442 100644 (file)
@@ -138,8 +138,11 @@ AliAnalysisTaskSingleMu::~AliAnalysisTaskSingleMu()
 
   delete fTriggerClasses;
   // For proof: do not delete output containers
-  if ( ! AliAnalysisManager::GetAnalysisManager()->IsProofMode() ) {
-    delete fCFManager->GetParticleContainer();  // The container is not deleted by framework
+  if ( ! AliAnalysisManager::GetAnalysisManager() || ! AliAnalysisManager::GetAnalysisManager()->IsProofMode() ) {
+    // In terminate mode fCFManager does not exist!
+    // So, check before deleting
+    if ( fCFManager )
+      delete fCFManager->GetParticleContainer();  // The container is not deleted by framework
     delete fCFManager;
     delete fHistoList;
     delete fHistoListMC;
@@ -208,7 +211,7 @@ void AliAnalysisTaskSingleMu::FinishTaskOutput()
       TH2* hStat = dynamic_cast<TH2*>(inputHandler->GetStatistics(statType.Data()));
       if ( hStat ) {
         histoName = Form("%s_SingleMuon", hStat->GetName());
-        TH2* cloneStat = dynamic_cast<TH2*>(hStat->Clone(histoName.Data()));
+        TH2* cloneStat = static_cast<TH2*>(hStat->Clone(histoName.Data()));
         cloneStat->SetDirectory(0);
         fHistoList->Add(cloneStat);
       }
index 247bfed..709b925 100644 (file)
@@ -78,11 +78,8 @@ AliCheckMuonDetEltResponse::AliCheckMuonDetEltResponse()
 
     fNbrUsableTracks = 0;
 
-    for (Int_t iCluster = 0; iCluster<fgkNCh; ++iCluster)
-      fNbrClustersCh[iCluster] = 0;
-
-    for (Int_t i=0; i<fgkNCh; ++i)
-      fTrackFilter[i] = 0;
+    memset(fNbrClustersCh,0, fgkNCh*sizeof(Int_t));
+    memset(fTrackFilter,  0, fgkNCh*sizeof(Int_t));
 }
 
 //_____________________________________________________________________________
index 9c172ae..60f6c05 100644 (file)
@@ -469,7 +469,12 @@ void AliCFTaskVertexingHF::UserExec(Option_t *)
        cfVtxHF->SetNVar(fNvar);
 
        if (fCentralitySelection)
-         if(fCuts->IsEventSelectedInCentrality(aodEvent)!=0) return;  
+         if(fCuts->IsEventSelectedInCentrality(aodEvent)!=0) {
+           delete[] containerInput;
+           delete[] containerInputMC;
+            delete [] trackCuts;
+            return;
+          }    
        
        Float_t centValue = fCuts->GetCentrality(aodEvent);
        cfVtxHF->SetCentralityValue(centValue);  
index ba1a2ef..784dd46 100644 (file)
@@ -13,6 +13,8 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
+// $Id$
+
 //-----------------------------------------------------------------------
 // Class for HF corrections as a function of many variables and step 
 // Author : C. Zampolli, CERN
@@ -143,6 +145,8 @@ AliCFVertexingHF& AliCFVertexingHF::operator=(const AliCFVertexingHF& c)
                fCentValue=c.fCentValue;
                if (fProngs > 0){
                        fLabelArray = new Int_t[fProngs];
+                        fPtAccCut = new Float_t[fProngs];
+                        fEtaAccCut = new Float_t[fProngs];
                        for(Int_t iP=0; iP<fProngs; iP++){
                                fLabelArray[iP]=c.fLabelArray[iP];
                                fPtAccCut[iP]=c.fPtAccCut[iP];
@@ -180,6 +184,8 @@ AliCFVertexingHF::AliCFVertexingHF(const AliCFVertexingHF &c) :
        //
        if (fProngs > 0){
                fLabelArray = new Int_t[fProngs];
+                fPtAccCut = new Float_t[fProngs];
+                fEtaAccCut = new Float_t[fProngs];
                if (c.fLabelArray) memcpy(fLabelArray,c.fLabelArray,fProngs*sizeof(Int_t));
                if (c.fPtAccCut) memcpy(fPtAccCut,c.fPtAccCut,fProngs*sizeof(Int_t));
                if (c.fEtaAccCut) memcpy(fEtaAccCut,c.fEtaAccCut,fProngs*sizeof(Int_t));
@@ -743,6 +749,12 @@ Bool_t AliCFVertexingHF::SetLabelArray()
                for(Int_t iDau=0; iDau<fProngs-1; iDau++){
                        Int_t iLabelDau = labelFirstDau+iDau;
                        AliAODMCParticle* part = dynamic_cast<AliAODMCParticle*>(fmcArray->At(iLabelDau));
+                        if ( ! part ) {
+                          AliError("Wrong particle type in fmcArray");
+                         delete [] fLabelArray; 
+                         fLabelArray = 0x0; 
+                          return bLabelArray;
+                        }  
                        Int_t pdgCode=TMath::Abs(part->GetPdgCode());
                        if(pdgCode==211 || pdgCode==321 || pdgCode==2212){
                                if (part) {
index 92eb095..844bd0b 100644 (file)
@@ -93,7 +93,7 @@ class AliCFVertexingHF : public TObject {
        Bool_t FillUnfoldingMatrix(Double_t fill[4]) const;
        
        void SetNProngs(Int_t nProngs){fProngs = nProngs;}
-       const Int_t GetNProngs() const {return fProngs;}
+       Int_t GetNProngs() const {return fProngs;}
        void SetDselection(UShort_t originDselection); 
        UShort_t GetDselection() {return fOriginDselection;}; 
        Int_t CheckReflexion(Char_t isSign);