]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
fixes for possible issues reported by coverity
authordsilverm <dsilverm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 27 Aug 2013 18:26:35 +0000 (18:26 +0000)
committerdsilverm <dsilverm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 27 Aug 2013 18:26:35 +0000 (18:26 +0000)
PWGLF/totEt/AliAnalysisEmEtMonteCarlo.cxx
PWGLF/totEt/AliAnalysisEtSelectorPhos.cxx
PWGLF/totEt/AliAnalysisHadEtMonteCarlo.cxx
PWGLF/totEt/AliAnalysisHadEtReconstructed.cxx
PWGLF/totEt/AliAnalysisTaskHadEt.cxx
PWGLF/totEt/AliAnalysisTaskTotEt.cxx

index 495c855057e19a4f7ca74fb525becbb02a9df28a..fcbd1ab4e56d0d56424d4684039fd800e4e5a567 100644 (file)
@@ -1711,8 +1711,9 @@ Int_t AliAnalysisEmEtMonteCarlo::AnalyseEvent(AliVEvent* ev)
                     // few checks
                     if ((stack->IsPhysicalPrimary(iPart)) || (!fGeoUt->IsInEMCAL(part->Vx(),part->Vy(),part->Vz())))
                     {//Marcelo - ...isn't this redundant?
-                        if (pdgMom)
-                            fHistElectronFirstMother->Fill(pdgMom->PdgCode());
+                     if (pdgMom) {
+                       fHistElectronFirstMother->Fill(pdgMom->PdgCode());
+                     }
                         fHistElectronFirstMotherXY->Fill(part->Vx(),part->Vy());                                       
                         fHistElectronNDaughters->Fill(nPartDaughters);
                                                
@@ -1734,7 +1735,9 @@ Int_t AliAnalysisEmEtMonteCarlo::AnalyseEvent(AliVEvent* ev)
                         //if (IsInAcceptance(part,pdg,extParam)) 
                         if (IsInAcceptance(aliPart)) 
                         {//Marcelo - should all three of the lines below be in the if statement?
-                            if (pdgMom) fHistElectronFirstMotherAcc->Fill(pdgMom->PdgCode());
+                         if (pdgMom) { 
+                           fHistElectronFirstMotherAcc->Fill(pdgMom->PdgCode());
+                         }
                             fHistElectronFirstMotherXYAcc->Fill(part->Vx(),part->Vy());                                        
                             fHistElectronNDaughtersAcc->Fill(nPartDaughters);
                                                        
@@ -1940,8 +1943,9 @@ Int_t AliAnalysisEmEtMonteCarlo::AnalyseEvent(AliVEvent* ev)
                     // few checks
                     if ((stack->IsPhysicalPrimary(iPart)) || (!fGeoUt->IsInEMCAL(part->Vx(),part->Vy(),part->Vz())))
                     {
-                        if (pdgMom)
-                            fHistGammaFirstMother->Fill(pdgMom->PdgCode());
+                     if (pdgMom) {
+                       fHistGammaFirstMother->Fill(pdgMom->PdgCode());
+                     }
                         fHistGammaFirstMotherXY->Fill(part->Vx(),part->Vy());                                  
                         fHistGammaNDaughters->Fill(nPartDaughters);
                                                
@@ -1975,8 +1979,9 @@ Int_t AliAnalysisEmEtMonteCarlo::AnalyseEvent(AliVEvent* ev)
                         //if (IsInAcceptance(part,pdg)) 
                         if (IsInAcceptance(aliPart)) 
                         {
-                            if (pdgMom)//Marcelo - again, should this be all three?
-                                fHistGammaFirstMotherAcc->Fill(pdgMom->PdgCode());
+                         if (pdgMom) {//Marcelo - again, should this be all three?
+                           fHistGammaFirstMotherAcc->Fill(pdgMom->PdgCode());
+                         }
                             fHistGammaFirstMotherXYAcc->Fill(part->Vx(),part->Vy());                                   
                             fHistGammaNDaughtersAcc->Fill(nPartDaughters);
                                                        
@@ -2092,7 +2097,7 @@ Int_t AliAnalysisEmEtMonteCarlo::AnalyseEvent(AliVEvent* ev)
                         }                                                      
                                                
                         // few checks
-                        if(pdgMom) fHistNPPElectronFirstMother->Fill(pdgMom->PdgCode());
+                        if(pdgMom) { fHistNPPElectronFirstMother->Fill(pdgMom->PdgCode()); }
                         fHistNPPElectronFirstMotherXY->Fill(part->Vx(),part->Vy());                                    
                         fHistNPPElectronNDaughters->Fill(nPartDaughters);
                                                
@@ -2114,7 +2119,7 @@ Int_t AliAnalysisEmEtMonteCarlo::AnalyseEvent(AliVEvent* ev)
                         //if (IsInAcceptance(part,pdg,extParam)) 
                         if (IsInAcceptance(aliPart)) 
                         {
-                            if(pdgMom) fHistNPPElectronFirstMotherAcc->Fill(pdgMom->PdgCode());
+                         if(pdgMom) { fHistNPPElectronFirstMotherAcc->Fill(pdgMom->PdgCode()); }
                             fHistNPPElectronFirstMotherXYAcc->Fill(part->Vx(),part->Vy());                                     
                             fHistNPPElectronNDaughtersAcc->Fill(nPartDaughters);
                             
@@ -2168,8 +2173,9 @@ Int_t AliAnalysisEmEtMonteCarlo::AnalyseEvent(AliVEvent* ev)
                         }                                                                                      
                                                
                         // few checks
-                        if (pdgMom)
-                            fHistNPPGammaFirstMother->Fill(pdgMom->PdgCode());
+                        if (pdgMom) {
+                         fHistNPPGammaFirstMother->Fill(pdgMom->PdgCode());
+                       }
                         fHistNPPGammaFirstMotherXY->Fill(part->Vx(),part->Vy());                                       
                         fHistNPPGammaNDaughters->Fill(nPartDaughters);
                                                
@@ -2191,7 +2197,9 @@ Int_t AliAnalysisEmEtMonteCarlo::AnalyseEvent(AliVEvent* ev)
                         //if (IsInAcceptance(part,pdg)) 
                         if (IsInAcceptance(aliPart)) 
                         {
-                            fHistNPPGammaFirstMotherAcc->Fill(pdgMom->PdgCode());
+                         if (pdgMom) { 
+                           fHistNPPGammaFirstMotherAcc->Fill(pdgMom->PdgCode());
+                         }
                             fHistNPPGammaFirstMotherXYAcc->Fill(part->Vx(),part->Vy());                                        
                             fHistNPPGammaNDaughtersAcc->Fill(nPartDaughters);
                             
@@ -2592,8 +2600,9 @@ Int_t AliAnalysisEmEtMonteCarlo::AnalyseEvent(AliVEvent* ev,AliVEvent* ev2)
                 }
                                
                 // few checks
-                if (pdgMom)
-                    fHistGammaFirstMotherRec->Fill(pdgMom->PdgCode());
+                if (pdgMom) {
+                 fHistGammaFirstMotherRec->Fill(pdgMom->PdgCode());
+               }
                 fHistGammaFirstMotherXYRec->Fill(part->Vx(),part->Vy());                                       
                 fHistGammaNDaughtersRec->Fill(nPartDaughters);
                                
@@ -2658,8 +2667,9 @@ Int_t AliAnalysisEmEtMonteCarlo::AnalyseEvent(AliVEvent* ev,AliVEvent* ev2)
                 }
                                
                 // few checks
-                if (pdgMom)
-                    fHistElectronFirstMotherRec->Fill(pdgMom->PdgCode());
+                if (pdgMom) {
+                 fHistElectronFirstMotherRec->Fill(pdgMom->PdgCode());
+               }
                 fHistElectronFirstMotherXYRec->Fill(part->Vx(),part->Vy());                                    
                 fHistElectronNDaughtersRec->Fill(nPartDaughters);
                                
@@ -2911,7 +2921,7 @@ Int_t AliAnalysisEmEtMonteCarlo::AnalyseEvent(AliVEvent* ev,AliVEvent* ev2)
                     fNPPElectronRectotET += et;
                                        
                     // few checks
-                    if(pdgMom) fHistNPPElectronFirstMotherRec->Fill(pdgMom->PdgCode());
+                    if(pdgMom) { fHistNPPElectronFirstMotherRec->Fill(pdgMom->PdgCode()); }
                     fHistNPPElectronFirstMotherXYRec->Fill(part->Vx(),part->Vy());                                     
                     fHistNPPElectronNDaughtersRec->Fill(nPartDaughters);
                                        
@@ -2953,8 +2963,9 @@ Int_t AliAnalysisEmEtMonteCarlo::AnalyseEvent(AliVEvent* ev,AliVEvent* ev2)
                     }
                                        
                     // few checks
-                    if (pdgMom)
-                        fHistNPPGammaFirstMotherRec->Fill(pdgMom->PdgCode());
+                    if (pdgMom) {
+                     fHistNPPGammaFirstMotherRec->Fill(pdgMom->PdgCode());
+                   }
                     fHistNPPGammaFirstMotherXYRec->Fill(part->Vx(),part->Vy());                                        
                     fHistNPPGammaNDaughtersRec->Fill(nPartDaughters);
                                        
index 2595c0be22c1ff6cc5b76bbb499f46167fee01fe..aefe6cfb8cc732b1b696c4f018b8b1565b7e9338 100644 (file)
@@ -342,28 +342,32 @@ Bool_t AliAnalysisEtSelectorPhos::CutGeometricalAcceptance(const AliESDCaloClust
 UInt_t AliAnalysisEtSelectorPhos::GetLabel(const AliESDCaloCluster *cluster, AliStack *stack){
   //Finds primary and estimates if it unique one?
   Int_t n=cluster->GetNLabels() ;
-  Double_t*  Ekin=  new  Double_t[n] ;
-  for(Int_t i=0;  i<n;  i++){
-    TParticle*  p=  stack->Particle(cluster->GetLabelAt(i)) ;
-    Ekin[i]=p->P() ;  // estimate of kinetic energy
-    if(p->GetPdgCode()==-2212  ||  p->GetPdgCode()==-2112){
-      Ekin[i]+=1.8  ;  //due to annihilation
-    }
-  }
   Int_t iMax=0;
-  Double_t eMax=0.;//eSubMax=0. ;
-  for(Int_t i=0;  i<n;  i++){
-    if(Ekin[i]>eMax){
-      //      eSubMax=eMax;
-      eMax=Ekin[i];
-      iMax=i;
+
+  if (n > 0) {
+    Double_t*  Ekin=  new  Double_t[n] ;
+    for(Int_t i=0;  i<n;  i++){
+      TParticle*  p=  stack->Particle(cluster->GetLabelAt(i)) ;
+      Ekin[i]=p->P() ;  // estimate of kinetic energy
+      if(p->GetPdgCode()==-2212  ||  p->GetPdgCode()==-2112){
+       Ekin[i]+=1.8  ;  //due to annihilation
+      }
+    }
+    Double_t eMax=0.;//eSubMax=0. ;
+    for(Int_t i=0;  i<n;  i++){
+      if(Ekin[i]>eMax){
+       //      eSubMax=eMax;
+       eMax=Ekin[i];
+       iMax=i;
+      }
     }
-  }
 //   if(eSubMax>0.8*eMax)//not obvious primary
 //     sure=kFALSE;
 //   else
 //     sure=kTRUE;
-  delete  Ekin;
-  return  cluster->GetLabelAt(iMax) ;
+    delete  Ekin;
+
+  } // n>0
+  return  cluster->GetLabelAt(iMax) ; // DS: should this line be inside n>0 check, and return another value if n<=0 ? 
 
 }
index 0a7686cb9975e92a3657c96abac9f89f499536c2..acb389e3dd54274ef08f15830a60f42808376382 100644 (file)
@@ -1764,9 +1764,16 @@ void AliAnalysisHadEtMonteCarlo::CreateHistograms(){
   //for simulated Et only (no reconstruction)
 
   AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
+  if (!man) {
+    AliFatal("Analysis manager needed");
+    return;
+  }
   AliInputEventHandler *inputHandler=dynamic_cast<AliInputEventHandler*>(man->GetInputEventHandler());
-  if (!inputHandler) AliFatal("Input handler needed");
-  
+  if (!inputHandler) {
+    AliFatal("Input handler needed");
+    return;
+  }
+
   //pid response object
   fPIDResponse=inputHandler->GetPIDResponse();
   if (!fPIDResponse) AliError("PIDResponse object was not created");
index 2c2499987aa1d70337786dd1e0cd29f6b0f15066..22753397de39f1ab849a1c53cd10888c9e44c4cc 100644 (file)
@@ -605,9 +605,16 @@ void AliAnalysisHadEtReconstructed::ResetEventValues(){//resetting event by even
 void AliAnalysisHadEtReconstructed::CreateHistograms(){//Creating histograms and adding them to the output TList
 
   AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
+  if (!man) {
+    AliFatal("Analysis manager needed");
+    return;
+  }
   AliInputEventHandler *inputHandler=dynamic_cast<AliInputEventHandler*>(man->GetInputEventHandler());
-  if (!inputHandler) AliFatal("Input handler needed");
-  
+  if (!inputHandler) {
+    AliFatal("Input handler needed");
+    return;
+  }
+
   //pid response object
   fPIDResponse=inputHandler->GetPIDResponse();
   if (!fPIDResponse) AliError("PIDResponse object was not created");
index 3420b0a1b61e94d630b8523e02d3636f6e0df42f..4f5f1f146392893c82e52971ef9f4cf4be19019f 100644 (file)
@@ -52,8 +52,16 @@ ClassImp(AliAnalysisTaskHadEt)
     // Constructor
   //input hander
   AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
+  if (!man) {
+    AliFatal("Analysis manager needed");
+    return;
+  }
+
   AliInputEventHandler *inputHandler=dynamic_cast<AliInputEventHandler*>(man->GetInputEventHandler());
-  if (!inputHandler) AliFatal("Input handler needed");
+  if (!inputHandler) {
+    AliFatal("Input handler needed");
+    return;
+  }
 
   //pid response object
   fPIDResponse=inputHandler->GetPIDResponse();
@@ -104,8 +112,16 @@ void AliAnalysisTaskHadEt::UserCreateOutputObjects()
 
   //input hander
   AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
+  if (!man) {
+    AliFatal("Analysis manager needed");
+    return;
+  }
+
   AliInputEventHandler *inputHandler=dynamic_cast<AliInputEventHandler*>(man->GetInputEventHandler());
-  if (!inputHandler) AliFatal("Input handler needed");
+  if (!inputHandler) {
+    AliFatal("Input handler needed");
+    return;
+  }
 
   //pid response object
   fPIDResponse=inputHandler->GetPIDResponse();
index 5b69b58fa658fd09528feeaaab5d76b67749e988..32f41d076e4a2d3e09d3611c16b54048b9865df9 100644 (file)
@@ -124,8 +124,16 @@ void AliAnalysisTaskTotEt::UserCreateOutputObjects()
 {
   //input hander
   AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
+  if (!man) {
+    AliFatal("Analysis manager needed");
+    return;
+  }
+
   AliInputEventHandler *inputHandler=dynamic_cast<AliInputEventHandler*>(man->GetInputEventHandler());
-  if (!inputHandler) AliFatal("Input handler needed");
+  if (!inputHandler) {
+    AliFatal("Input handler needed");
+    return;
+  }
 
   //pid response object
   fPIDResponse=inputHandler->GetPIDResponse();