coverity fixes
authormverweij <marta.verweij@cern.ch>
Wed, 14 Jan 2015 12:47:21 +0000 (13:47 +0100)
committermverweij <marta.verweij@cern.ch>
Wed, 14 Jan 2015 12:47:33 +0000 (13:47 +0100)
ANALYSIS/ANALYSISalice/AliESDtrackCuts.cxx
PWGJE/EMCALJetTasks/AliEmcalJetByJetCorrection.cxx
PWGJE/EMCALJetTasks/AliEmcalPicoTrackInGridMaker.cxx
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskJetShapeConst.cxx
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskJetShapeDeriv.cxx
PWGJE/PWGJE/AliAnaChargedJetResponseMaker.cxx

index cf88fc8..5719c44 100644 (file)
@@ -1174,7 +1174,7 @@ Bool_t AliESDtrackCuts::AcceptTrack(const AliESDtrack* esdTrack)
   Float_t y   = -100.;
   if((momentum != TMath::Abs(p[2]))&&(momentum != 0))
     eta = 0.5*TMath::Log((momentum + p[2])/(momentum - p[2]));
-  if((energy != TMath::Abs(p[2]))&&(momentum != 0))
+  if((energy != TMath::Abs(p[2]))&&(energy != 0))
     y = 0.5*TMath::Log((energy + p[2])/(energy - p[2]));
     
   if (extCov[14] < 0) 
index d381e60..2179ac1 100644 (file)
@@ -162,7 +162,7 @@ void AliEmcalJetByJetCorrection::Init() {
 
     fh3JetPtDRTrackPt->GetXaxis()->SetRange(binMin,binMax);
     TH2D *h2 = dynamic_cast<TH2D*>(fh3JetPtDRTrackPt->Project3D("zy"));
-    h2->SetName(Form("hPtR_%.0f_%.0f",fh3JetPtDRTrackPt->GetXaxis()->GetBinLowEdge(binMin),fh3JetPtDRTrackPt->GetXaxis()->GetBinUpEdge(binMax)));
+    if(h2) h2->SetName(Form("hPtR_%.0f_%.0f",fh3JetPtDRTrackPt->GetXaxis()->GetBinLowEdge(binMin),fh3JetPtDRTrackPt->GetXaxis()->GetBinUpEdge(binMax)));
     fCollTemplates.Add(h2);
     counter++;
   }
index 2389cfb..66d1db9 100644 (file)
@@ -522,6 +522,7 @@ Bool_t AliEmcalPicoTrackInGridMaker::CreateGridPatches(const Int_t dim, const In
   if(!InitPatches(dim,level)) return kFALSE;
 
   Int_t pt = GetPatchType(dim,level);
+  if(pt<0) return kFALSE;
   Int_t nm = (Int_t)(dim/2.);    //size of trigger patch in number of mini patches
   Int_t stepm = (Int_t)(dim/2.); //step size through grid in mini patches
   if(level==1 && fL1Slide)  stepm = GetSlidingStepSizeMiniPatches(dim,level);
index 4f6e42d..7dd63ed 100644 (file)
@@ -383,7 +383,7 @@ Bool_t AliAnalysisTaskJetShapeConst::FillHistograms()
       
       if(fCreateTree) {      
        fJet1Vec->SetPxPyPzE(jet1->Px(),jet1->Py(),jet1->Pz(),jet1->E());
-       if(jetS && jetS->Pt()>0.) fJetSubVec->SetPtEtaPhiM(jetS->Pt(),jetS->Eta(),jetS->Phi(),jetS->M());
+       if(jetS->Pt()>0.) fJetSubVec->SetPtEtaPhiM(jetS->Pt(),jetS->Eta(),jetS->Phi(),jetS->M());
        else fJetSubVec->SetPtEtaPhiM(0.,0.,0.,0.);
        fArea = (Float_t)jet1->Area();
        fAreaPhi = (Float_t)jet1->AreaPhi();
index 6ccdecc..41fab4e 100644 (file)
@@ -402,86 +402,85 @@ Bool_t AliAnalysisTaskJetShapeDeriv::FillHistograms()
   AliEmcalJet *jetL = NULL;
   if(jetContNoEmb) jetL = jetContNoEmb->GetLeadingJet("rho");
 
-  if(jetCont) {
-    jetCont->ResetCurrentID();
-    while((jet1 = jetCont->GetNextAcceptJet())) {
-      jet2 = NULL;
-
-      Double_t mjet1 = jet1->GetSecondOrderSubtracted();
-      Double_t ptjet1 = jet1->Pt()-jetCont->GetRhoVal()*jet1->Area();
-      Double_t var = mjet1;
-      if(fJetMassVarType==kRatMPt) {
-       if(ptjet1>0. || ptjet1<0.) var = mjet1/ptjet1;
-       else var = -999.;
-      }
+  jetCont->ResetCurrentID();
+  while((jet1 = jetCont->GetNextAcceptJet())) {
+    jet2 = NULL;
+
+    Double_t mjet1 = jet1->GetSecondOrderSubtracted();
+    Double_t ptjet1 = jet1->Pt()-jetCont->GetRhoVal()*jet1->Area();
+    Double_t var = mjet1;
+    if(fJetMassVarType==kRatMPt) {
+      if(ptjet1>0. || ptjet1<0.) var = mjet1/ptjet1;
+      else var = -999.;
+    }
 
-      //Fill histograms for all AA jets
-      fh2MSubPtRawAll[fCentBin]->Fill(var,ptjet1);
-      fh2PtRawSubFacV1[fCentBin]->Fill(jet1->Pt(),-1.*(fRho+fRhoM)*jet1->GetFirstDerivative());
-      fh2PtCorrSubFacV1[fCentBin]->Fill(jet1->Pt()-fRho*jet1->Area(),-1.*(fRho+fRhoM)*jet1->GetFirstDerivative());
-      fh2NConstSubFacV1[fCentBin]->Fill(jet1->GetNumberOfTracks(),-1.*(fRho+fRhoM)*jet1->GetFirstDerivative());
-      fh2PtRawSubFacV2[fCentBin]->Fill(jet1->Pt(),0.5*(fRho+fRhoM)*(fRho+fRhoM)*jet1->GetSecondDerivative());
-      fh2PtCorrSubFacV2[fCentBin]->Fill(jet1->Pt()-fRho*jet1->Area(),0.5*(fRho+fRhoM)*(fRho+fRhoM)*jet1->GetSecondDerivative());
-      fh2NConstSubFacV2[fCentBin]->Fill(jet1->GetNumberOfTracks(),0.5*(fRho+fRhoM)*(fRho+fRhoM)*jet1->GetSecondDerivative());
-
-      Double_t fraction = 0.;
-      fMatch = 0;
-      fJet2Vec->SetPtEtaPhiM(0.,0.,0.,0.);
-      if(fSingleTrackEmb) {
-       AliVParticle *vp = GetEmbeddedConstituent(jet1);
-       if(vp) {
-         fJet2Vec->SetPxPyPzE(vp->Px(),vp->Py(),vp->Pz(),vp->E());
-         fMatch = 1;
-       }
-      } else {
-       jet2 = jet1->ClosestJet();
-       fraction = jetCont->GetFractionSharedPt(jet1);
-       fMatch = 1;
-       if(fMinFractionShared>0.) {
-         if(fraction>fMinFractionShared) {
-           fJet2Vec->SetPxPyPzE(jet2->Px(),jet2->Py(),jet2->Pz(),jet2->E());
-           fMatch = 1;
-         } else
-           fMatch = 0;
-       }
+    //Fill histograms for all AA jets
+    fh2MSubPtRawAll[fCentBin]->Fill(var,ptjet1);
+    fh2PtRawSubFacV1[fCentBin]->Fill(jet1->Pt(),-1.*(fRho+fRhoM)*jet1->GetFirstDerivative());
+    fh2PtCorrSubFacV1[fCentBin]->Fill(jet1->Pt()-fRho*jet1->Area(),-1.*(fRho+fRhoM)*jet1->GetFirstDerivative());
+    fh2NConstSubFacV1[fCentBin]->Fill(jet1->GetNumberOfTracks(),-1.*(fRho+fRhoM)*jet1->GetFirstDerivative());
+    fh2PtRawSubFacV2[fCentBin]->Fill(jet1->Pt(),0.5*(fRho+fRhoM)*(fRho+fRhoM)*jet1->GetSecondDerivative());
+    fh2PtCorrSubFacV2[fCentBin]->Fill(jet1->Pt()-fRho*jet1->Area(),0.5*(fRho+fRhoM)*(fRho+fRhoM)*jet1->GetSecondDerivative());
+    fh2NConstSubFacV2[fCentBin]->Fill(jet1->GetNumberOfTracks(),0.5*(fRho+fRhoM)*(fRho+fRhoM)*jet1->GetSecondDerivative());
+
+    Double_t fraction = 0.;
+    fMatch = 0;
+    fJet2Vec->SetPtEtaPhiM(0.,0.,0.,0.);
+    if(fSingleTrackEmb) {
+      AliVParticle *vp = GetEmbeddedConstituent(jet1);
+      if(vp) {
+        fJet2Vec->SetPxPyPzE(vp->Px(),vp->Py(),vp->Pz(),vp->E());
+        fMatch = 1;
       }
-
-      //      if(fMatch==1 && jet2->GetTagStatus()>0) jet2T = jet2->GetTaggedJet();
-
-      //Fill histograms for matched jets
-      fh2MSubMatch[fCentBin]->Fill(var,fMatch);
-      if(fMatch==1) {
-       Double_t drToLJ = -1.;
-       if(jetL) drToLJ = jet1->DeltaR(jetL);
-       fh3MSubPtRawDRMatch[fCentBin]->Fill(var,ptjet1,drToLJ);
-       if(jet2) {
-         Double_t var2 = jet2->M();
-         if(fJetMassVarType==kRatMPt) {
-           if(jet2->Pt()>0. || jet2->Pt()<0.) var2 = jet2->M()/jet2->Pt();
-         }
-         fh3MSubPtTrueDR[fCentBin]->Fill(var,jet2->Pt(),drToLJ);
-         fh3MTruePtTrueDR[fCentBin]->Fill(var2,jet2->Pt(),drToLJ);
-         fh3PtTrueDeltaMDR[fCentBin]->Fill(jet2->Pt(),var-var2,drToLJ);
-         if(jet2->M()>0.) fh3PtTrueDeltaMRelDR[fCentBin]->Fill(jet2->Pt(),(var-var2)/var2,drToLJ);
-         Double_t varsp[5] = {var,var2,ptjet1,jet2->Pt(),drToLJ};
-         fhnMassResponse[fCentBin]->Fill(varsp);
-       }
+    } else {
+      jet2 = jet1->ClosestJet();
+      fraction = jetCont->GetFractionSharedPt(jet1);
+      fMatch = 1;
+      if(fMinFractionShared>0.) {
+        if(fraction>fMinFractionShared) {
+          fJet2Vec->SetPxPyPzE(jet2->Px(),jet2->Py(),jet2->Pz(),jet2->E());
+          fMatch = 1;
+        } else
+          fMatch = 0;
       }
+    }
 
-      if(fCreateTree) {      
-       fJet1Vec->SetPxPyPzE(jet1->Px(),jet1->Py(),jet1->Pz(),jet1->E());
-       fArea = (Float_t)jet1->Area();
-       fAreaPhi = (Float_t)jet1->AreaPhi();
-       fAreaEta = (Float_t)jet1->AreaEta();
-       fNConst = (Int_t)jet1->GetNumberOfTracks();
-       fM1st   = (Float_t)jet1->GetFirstOrderSubtracted();
-       fM2nd   = (Float_t)jet1->GetSecondOrderSubtracted();
-       fDeriv1st = (Float_t)jet1->GetFirstDerivative();
-       fDeriv2nd = (Float_t)jet1->GetSecondDerivative();
-       fTreeJetBkg->Fill();
+    //      if(fMatch==1 && jet2->GetTagStatus()>0) jet2T = jet2->GetTaggedJet();
+
+    //Fill histograms for matched jets
+    fh2MSubMatch[fCentBin]->Fill(var,fMatch);
+    if(fMatch==1) {
+      Double_t drToLJ = -1.;
+      if(jetL) drToLJ = jet1->DeltaR(jetL);
+      fh3MSubPtRawDRMatch[fCentBin]->Fill(var,ptjet1,drToLJ);
+      if(jet2) {
+        Double_t var2 = jet2->M();
+        if(fJetMassVarType==kRatMPt) {
+          if(jet2->Pt()>0. || jet2->Pt()<0.) var2 = jet2->M()/jet2->Pt();
+        }
+        fh3MSubPtTrueDR[fCentBin]->Fill(var,jet2->Pt(),drToLJ);
+        fh3MTruePtTrueDR[fCentBin]->Fill(var2,jet2->Pt(),drToLJ);
+        fh3PtTrueDeltaMDR[fCentBin]->Fill(jet2->Pt(),var-var2,drToLJ);
+        if(jet2->M()>0.) fh3PtTrueDeltaMRelDR[fCentBin]->Fill(jet2->Pt(),(var-var2)/var2,drToLJ);
+        Double_t varsp[5] = {var,var2,ptjet1,jet2->Pt(),drToLJ};
+        fhnMassResponse[fCentBin]->Fill(varsp);
       }
     }
+
+    if(fCreateTree) {      
+      fJet1Vec->SetPxPyPzE(jet1->Px(),jet1->Py(),jet1->Pz(),jet1->E());
+      fArea = (Float_t)jet1->Area();
+      fAreaPhi = (Float_t)jet1->AreaPhi();
+      fAreaEta = (Float_t)jet1->AreaEta();
+      fNConst = (Int_t)jet1->GetNumberOfTracks();
+      fM1st   = (Float_t)jet1->GetFirstOrderSubtracted();
+      fM2nd   = (Float_t)jet1->GetSecondOrderSubtracted();
+      fDeriv1st = (Float_t)jet1->GetFirstDerivative();
+      fDeriv2nd = (Float_t)jet1->GetSecondDerivative();
+      fTreeJetBkg->Fill();
+    }
   }
+
   return kTRUE;
 }
 
index 2882c99..372b643 100644 (file)
@@ -1148,8 +1148,8 @@ TH1D* AliAnaChargedJetResponseMaker::MultiplyResponseGenerated(TH1 *hGen, TH2 *h
   Double_t yieldMC = 0.;
   Double_t yieldMCerror = 0.;
   Double_t sumYield = 0.;
-  const Int_t nbinsRec = hRec->GetNbinsX();
-  Double_t sumError2[nbinsRec+1];
+  const Int_t nbinsRec = hRec->GetNbinsX()+1;
+  Double_t sumError2[nbinsRec];
   for(int irec=0; irec<=hRec->GetNbinsX(); irec++)
     sumError2[irec]=0.;
   Double_t eff = 0.;
@@ -1197,7 +1197,7 @@ TH1D* AliAnaChargedJetResponseMaker::MultiplyResponseGenerated(TH1 *hGen, TH2 *h
     cout << "igen: " << igen << "\tpTMC: " << hGen->GetXaxis()->GetBinCenter(igen) << "\teff:" << eff << "\tsumYield: " << sumYield << endl;
   }
   
-  for(int i=0; i<=nbinsRec; i++) {
+  for(int i=0; i<nbinsRec; i++) {
     if(sumError2[i]>0.)
       hRec->SetBinError(i+1,TMath::Sqrt(sumError2[i]));
   }