From adca66d269c395ce066efceac97ad641b3d5cc29 Mon Sep 17 00:00:00 2001 From: dainese Date: Tue, 26 Jul 2011 11:25:58 +0000 Subject: [PATCH] Coverity --- PWG1/ITS/AliMeanVertexPreprocessorOffline.cxx | 242 +++++++++--------- 1 file changed, 122 insertions(+), 120 deletions(-) diff --git a/PWG1/ITS/AliMeanVertexPreprocessorOffline.cxx b/PWG1/ITS/AliMeanVertexPreprocessorOffline.cxx index f266e39bd70..cfc2e04a957 100644 --- a/PWG1/ITS/AliMeanVertexPreprocessorOffline.cxx +++ b/PWG1/ITS/AliMeanVertexPreprocessorOffline.cxx @@ -112,33 +112,38 @@ void AliMeanVertexPreprocessorOffline::ProcessOutput(const char *filename, const if (useTRKvtx){ - - Float_t nEntriesX = histTRKvtxX->GetEffectiveEntries(); + + Float_t nEntriesX = histTRKvtxX->GetEffectiveEntries(); Float_t nEntriesY = histTRKvtxY->GetEffectiveEntries(); Float_t nEntriesZ = histTRKvtxZ->GetEffectiveEntries(); if (nEntriesX < 50. || nEntriesY<50. || nEntriesZ<50.) { - AliWarning(Form("TRK vertex histograms have too few entries for fitting")); - - if (useITSSAvtx){ - if (nEntriesX < 50. || nEntriesY<50. || nEntriesZ<50.) { - AliWarning(Form("ITSSA vertex histograms have too few entries for fitting")); - - if (useSPDvtx){ - - nEntriesX = histSPDvtxX->GetEffectiveEntries(); - nEntriesY = histSPDvtxY->GetEffectiveEntries(); - nEntriesZ = histSPDvtxZ->GetEffectiveEntries(); + AliError(Form("TRK vertex histograms have too few entries for fitting")); + return; + } + } + if (useITSSAvtx){ + + Float_t nEntriesX = histTRKvtxX->GetEffectiveEntries(); + Float_t nEntriesY = histTRKvtxY->GetEffectiveEntries(); + Float_t nEntriesZ = histTRKvtxZ->GetEffectiveEntries(); + + if (nEntriesX < 50. || nEntriesY<50. || nEntriesZ<50.) { + AliError(Form("ITSSA vertex histograms have too few entries for fitting")); + return; + } + } + if (useSPDvtx){ + + Float_t nEntriesX = histSPDvtxX->GetEffectiveEntries(); + Float_t nEntriesY = histSPDvtxY->GetEffectiveEntries(); + Float_t nEntriesZ = histSPDvtxZ->GetEffectiveEntries(); - if (nEntriesX < 50. || nEntriesY<50. || nEntriesZ<50.) { - AliError(Form("Also SPD vertex histograms have too few entries for fitting, return")); - return; - } - } - } - } - } - } + if (nEntriesX < 50. || nEntriesY<50. || nEntriesZ<50.) { + AliError(Form("Also SPD vertex histograms have too few entries for fitting, return")); + return; + } + } Double_t xMeanVtx=0., yMeanVtx=0., zMeanVtx=0.; @@ -243,27 +248,28 @@ void AliMeanVertexPreprocessorOffline::ProcessOutput(const char *filename, const if (useTRKvtx || useITSSAvtx){ AliCDBManager *manCheck = AliCDBManager::Instance(); manCheck->SetDefaultStorage("raw://"); - manCheck->SetRun(runNb); + manCheck->SetRun(runNb); AliCDBEntry *entr = manCheck->Get("GRP/Calib/MeanVertexSPD"); - AliESDVertex *vtxOnline = (AliESDVertex*)entr->GetObject(); + if(entr) { + AliESDVertex *vtxOnline = (AliESDVertex*)entr->GetObject(); - Double_t posOnline[3], sigmaOnline[3]; - posOnline[0] = vtxOnline->GetX(); - posOnline[1] = vtxOnline->GetY(); - posOnline[2] = vtxOnline->GetZ(); + Double_t posOnline[3], sigmaOnline[3]; + posOnline[0] = vtxOnline->GetX(); + posOnline[1] = vtxOnline->GetY(); + posOnline[2] = vtxOnline->GetZ(); - sigmaOnline[0] = vtxOnline->GetXRes(); - sigmaOnline[1] = vtxOnline->GetYRes(); - sigmaOnline[2] = vtxOnline->GetZRes(); + sigmaOnline[0] = vtxOnline->GetXRes(); + sigmaOnline[1] = vtxOnline->GetYRes(); + sigmaOnline[2] = vtxOnline->GetZRes(); - //vtxOnline->GetSigmaXYZ(sigmaOnline); + //vtxOnline->GetSigmaXYZ(sigmaOnline); - if ((TMath::Abs(posOnline[0]-xMeanVtx) > 0.1) || (TMath::Abs(posOnline[1]-yMeanVtx) > 0.1) || (TMath::Abs(posOnline[2]-zMeanVtx) > 1.)){ - AliWarning(Form("vertex offline far from the online one")); - return; + if ((TMath::Abs(posOnline[0]-xMeanVtx) > 0.1) || (TMath::Abs(posOnline[1]-yMeanVtx) > 0.1) || (TMath::Abs(posOnline[2]-zMeanVtx) > 1.)){ + AliWarning(Form("vertex offline far from the online one")); + return; + } } - } Float_t meanMult = 40.; @@ -272,7 +278,6 @@ void AliMeanVertexPreprocessorOffline::ProcessOutput(const char *filename, const Double_t xSigmaMult, ySigmaMult, corrXZ, corrYZ, lumiRegSquaredX, lumiRegSquaredY; Double_t covarXZ=0., covarYZ=0.; - Bool_t histosLumiReg = kTRUE; TF1 *sigmaFitX, *sigmaFitY, *corrFit; @@ -281,95 +286,92 @@ void AliMeanVertexPreprocessorOffline::ProcessOutput(const char *filename, const TH2F *histTRKVertexXZ=0; TH2F *histTRKVertexYZ=0; - if ((!histTRKdefMultX) || (!histTRKdefMultY)){ - AliWarning(Form("histos for lumi reg calculation not found, default value setted")); - xSigmaMult=0.0120; - ySigmaMult=0.0120; - histosLumiReg=kFALSE; - - } - if (histosLumiReg){ - if (useTRKvtx){ - - histTRKdefMultX = (TH1F*)list->FindObject("hTRKVertexXdefMult"); - histTRKdefMultY = (TH1F*)list->FindObject("hTRKVertexYdefMult"); - histTRKVertexXZ = (TH2F*)list->FindObject("hTRKVertexXZ"); - histTRKVertexYZ = (TH2F*)list->FindObject("hTRKVertexYZ"); + if (useTRKvtx){ + + histTRKdefMultX = (TH1F*)list->FindObject("hTRKVertexXdefMult"); + histTRKdefMultY = (TH1F*)list->FindObject("hTRKVertexYdefMult"); + histTRKVertexXZ = (TH2F*)list->FindObject("hTRKVertexXZ"); + histTRKVertexYZ = (TH2F*)list->FindObject("hTRKVertexYZ"); - } + } - if (useITSSAvtx){ - - histTRKdefMultX = (TH1F*)list->FindObject("hITSSAVertexXdefMult"); - histTRKdefMultY = (TH1F*)list->FindObject("hITSSAVertexYdefMult"); - histTRKVertexXZ = (TH2F*)list->FindObject("hITSSAVertexXZ"); - histTRKVertexYZ = (TH2F*)list->FindObject("hITSSAVertexYZ"); - } + if (useITSSAvtx){ + + histTRKdefMultX = (TH1F*)list->FindObject("hITSSAVertexXdefMult"); + histTRKdefMultY = (TH1F*)list->FindObject("hITSSAVertexYdefMult"); + histTRKVertexXZ = (TH2F*)list->FindObject("hITSSAVertexXZ"); + histTRKVertexYZ = (TH2F*)list->FindObject("hITSSAVertexYZ"); + } + if ((!histTRKdefMultX) || (!histTRKdefMultY)){ + AliWarning(Form("histos for lumi reg calculation not found, default value setted")); + xSigmaMult=0.0120; + ySigmaMult=0.0120; + } else { - histTRKdefMultX -> Fit("gaus", "M", "", -1., 1.); - sigmaFitX = histTRKdefMultX -> GetFunction("gaus"); - xSigmaMult = sigmaFitX->GetParameter(2); - - - lumiRegSquaredX = (xSigmaMult*xSigmaMult - ((resolVtx*resolVtx)/TMath::Power(meanMult, p2))); - if (lumiRegSquaredX < 0) { - AliWarning(Form("Problems with luminosiy region determination, update of the postion only")); - xSigmaMult = 0.; - xSigmaVtx = 0.0120; - } - - if (lumiRegSquaredX > 0 && lumiRegSquaredX < 0.0005){ - xSigmaVtx = TMath::Sqrt(lumiRegSquaredX); - xSigmaVtx = xSigmaVtx*1.2; - } - - - histTRKdefMultY -> Fit("gaus", "M"); - sigmaFitY = histTRKdefMultY -> GetFunction("gaus"); - ySigmaMult = sigmaFitY->GetParameter(2); - - lumiRegSquaredY= (ySigmaMult*ySigmaMult - ((resolVtx*resolVtx)/TMath::Power(meanMult, p2))); - if (lumiRegSquaredY < 0) { - AliWarning(Form("Problems with luminosiy region determination, update of the postion only")); - ySigmaMult = 0.; - ySigmaVtx = 0.0120; - } - - if (lumiRegSquaredY > 0 && lumiRegSquaredY < 0.0005){ - ySigmaVtx = TMath::Sqrt(lumiRegSquaredY); - ySigmaVtx = ySigmaVtx*1.2; - } - - TProfile *htrkXZ = histTRKVertexXZ ->ProfileY(); - htrkXZ -> Fit("pol1", "M", "", -10., 10.); - corrFit = htrkXZ->GetFunction("pol1"); - corrXZ = corrFit->GetParameter(1); - - if (TMath::Abs(corrXZ) > 0.01) { - AliWarning(Form("Problems in the correlation fitting, not update the covariance matrix")); - corrXZ =0.; - } - else{ - covarXZ = corrXZ * zSigmaVtx*zSigmaVtx; - - } - - TProfile *htrkYZ = histTRKVertexYZ ->ProfileY(); - htrkYZ -> Fit("pol1", "M", "", -10., 10.); - corrFit = htrkYZ->GetFunction("pol1"); - corrYZ = corrFit->GetParameter(1); - - if (TMath::Abs(corrYZ) > 0.01) { - AliWarning(Form("Problems in the correlation fitting, not update the covariance matrix")); - corrYZ =0.; - } - else{ - covarYZ = corrYZ*zSigmaVtx*zSigmaVtx; - } - + histTRKdefMultX -> Fit("gaus", "M", "", -1., 1.); + sigmaFitX = histTRKdefMultX -> GetFunction("gaus"); + xSigmaMult = sigmaFitX->GetParameter(2); + + + lumiRegSquaredX = (xSigmaMult*xSigmaMult - ((resolVtx*resolVtx)/TMath::Power(meanMult, p2))); + if (lumiRegSquaredX < 0) { + AliWarning(Form("Problems with luminosiy region determination, update of the postion only")); + xSigmaMult = 0.; + xSigmaVtx = 0.0120; + } + + if (lumiRegSquaredX > 0 && lumiRegSquaredX < 0.0005){ + xSigmaVtx = TMath::Sqrt(lumiRegSquaredX); + xSigmaVtx = xSigmaVtx*1.2; + } + + + histTRKdefMultY -> Fit("gaus", "M"); + sigmaFitY = histTRKdefMultY -> GetFunction("gaus"); + ySigmaMult = sigmaFitY->GetParameter(2); + + lumiRegSquaredY= (ySigmaMult*ySigmaMult - ((resolVtx*resolVtx)/TMath::Power(meanMult, p2))); + if (lumiRegSquaredY < 0) { + AliWarning(Form("Problems with luminosiy region determination, update of the postion only")); + ySigmaMult = 0.; + ySigmaVtx = 0.0120; + } + + if (lumiRegSquaredY > 0 && lumiRegSquaredY < 0.0005){ + ySigmaVtx = TMath::Sqrt(lumiRegSquaredY); + ySigmaVtx = ySigmaVtx*1.2; + } + + TProfile *htrkXZ = histTRKVertexXZ ->ProfileY(); + htrkXZ -> Fit("pol1", "M", "", -10., 10.); + corrFit = htrkXZ->GetFunction("pol1"); + corrXZ = corrFit->GetParameter(1); + + if (TMath::Abs(corrXZ) > 0.01) { + AliWarning(Form("Problems in the correlation fitting, not update the covariance matrix")); + corrXZ =0.; + } + else{ + covarXZ = corrXZ * zSigmaVtx*zSigmaVtx; + + } + + TProfile *htrkYZ = histTRKVertexYZ ->ProfileY(); + htrkYZ -> Fit("pol1", "M", "", -10., 10.); + corrFit = htrkYZ->GetFunction("pol1"); + corrYZ = corrFit->GetParameter(1); + + if (TMath::Abs(corrYZ) > 0.01) { + AliWarning(Form("Problems in the correlation fitting, not update the covariance matrix")); + corrYZ =0.; + } + else{ + covarYZ = corrYZ*zSigmaVtx*zSigmaVtx; + } + } Double_t position[3], covMatrix[6]; -- 2.39.3