From 472f0066038174b70bb65a83219ecf68fa20a2eb Mon Sep 17 00:00:00 2001 From: marian Date: Thu, 24 Mar 2011 11:34:23 +0000 Subject: [PATCH] coverity changes AliESDcosmic.cxx - pointer check AliTPCcalibTime.cxx - proper pointer check AliTPCcalibTracksGain.cxx - removing obsolete functions and data members AliTPCtrackerSector.cxx - array initialization in cosntructor AliTPCclustererKr.cxx - check the pointer at the beginning of function AliTPCkalmanAlign.cxx - coverity warning AliXRDPROOFtoolkit.cxx - snprintf instead of sprintf --- TPC/AliESDcosmic.cxx | 1 + TPC/AliTPCcalibTime.cxx | 10 ++++---- TPC/AliTPCcalibTracksGain.cxx | 43 +---------------------------------- TPC/AliTPCcalibTracksGain.h | 4 ---- TPC/AliTPCclustererKr.cxx | 5 ++-- TPC/AliTPCkalmanAlign.cxx | 1 + TPC/AliTPCtrackerSector.cxx | 6 +++-- TPC/AliXRDPROOFtoolkit.cxx | 12 +++++----- 8 files changed, 21 insertions(+), 61 deletions(-) diff --git a/TPC/AliESDcosmic.cxx b/TPC/AliESDcosmic.cxx index 5e46c0af2a7..19b475418a5 100644 --- a/TPC/AliESDcosmic.cxx +++ b/TPC/AliESDcosmic.cxx @@ -150,6 +150,7 @@ void AliESDcosmic::DumpToTree(){ // TTreeSRedirector * cstream = fDebugStreamer; if (!cstream) return; + if (!fESD) return; Int_t ntracks0 =fESD->GetNumberOfTracks(); Int_t ntracks = (fTracksAcorde) ? fTracksAcorde->GetEntries():0; Float_t mag = fESD->GetMagneticField(); diff --git a/TPC/AliTPCcalibTime.cxx b/TPC/AliTPCcalibTime.cxx index 49c340338e7..0a18897dbaa 100644 --- a/TPC/AliTPCcalibTime.cxx +++ b/TPC/AliTPCcalibTime.cxx @@ -347,10 +347,10 @@ AliTPCcalibTime::~AliTPCcalibTime(){ fResHistoTPCvertex[i]=0; } - if (fTPCVertex) { + if (fTPCVertex[0]) { for (Int_t i=0;i<12;i++) delete fTPCVertex[i]; } - if (fTPCVertexCorrelation) { + if (fTPCVertexCorrelation[0]) { for (Int_t i=0;i<5;i++) delete fTPCVertexCorrelation[i]; } @@ -1030,7 +1030,7 @@ THnSparse* AliTPCcalibTime::GetHistoDrift(const char* name) const THnSparse* newHist=new THnSparseF(newName,"HistVdrift;time;p/T ratio;Vdrift;run",4,fBinsVdrift,fXminVdrift,fXmaxVdrift); THnSparse* addHist=NULL; while((addHist=(THnSparseF*)iterator->Next())){ - if(!addHist) continue; + // if(!addHist) continue; TString histName=addHist->GetName(); if(!histName.Contains(newName)) continue; addHist->Print(); @@ -1129,7 +1129,7 @@ Long64_t AliTPCcalibTime::Merge(TCollection *const li) { } } - if (fTPCVertex && cal->fTPCVertex) + if (fTPCVertex[0] && cal->fTPCVertex[0]) for (Int_t imeas=0; imeas<12; imeas++){ if (fTPCVertex[imeas] && cal->fTPCVertex[imeas]) fTPCVertex[imeas]->Add(cal->fTPCVertex[imeas]); } @@ -1178,7 +1178,7 @@ Long64_t AliTPCcalibTime::Merge(TCollection *const li) { iterator->Reset(); THnSparse* addHist=NULL; if ((fMemoryMode>1)) while((addHist=(THnSparseF*)iterator->Next())){ - if(!addHist) continue; + // if(!addHist) continue; addHist->Print(); THnSparse* localHist=(THnSparseF*)fArrayDz->FindObject(addHist->GetName()); if(!localHist){ diff --git a/TPC/AliTPCcalibTracksGain.cxx b/TPC/AliTPCcalibTracksGain.cxx index e453180a77a..4d4de07bd75 100644 --- a/TPC/AliTPCcalibTracksGain.cxx +++ b/TPC/AliTPCcalibTracksGain.cxx @@ -407,12 +407,6 @@ AliTPCcalibTracksGain::AliTPCcalibTracksGain(const char* name, const char* title // fTotalTracks = 0; fAcceptedTracks = 0; - // this will be gone for the a new ROOT version > v5-17-05 - for (UInt_t i = 0; i < 36; i++) { - fNShortClusters[i] = 0; - fNMediumClusters[i] = 0; - fNLongClusters[i] = 0; - } } AliTPCcalibTracksGain::~AliTPCcalibTracksGain() { @@ -580,12 +574,6 @@ void AliTPCcalibTracksGain::Add(AliTPCcalibTracksGain* cal) { if (cal->fDFitter1T->GetNpoints()>0) fDFitter1T->Add(cal->fDFitter1T); if (cal->fDFitter2T->GetNpoints()>0) fDFitter2T->Add(cal->fDFitter2T); // - // this will be gone for the a new ROOT version > v5-17-05 - for (UInt_t iSegment = 0; iSegment < 36; iSegment++) { - fNShortClusters[iSegment] += cal->fNShortClusters[iSegment]; - fNMediumClusters[iSegment] += cal->fNMediumClusters[iSegment]; - fNLongClusters[iSegment] += cal->fNLongClusters[iSegment]; - } // just for debugging, remove me fTotalTracks += cal->fTotalTracks; @@ -694,13 +682,6 @@ void AliTPCcalibTracksGain::AddCluster(AliTPCclusterMI* cluster, Float_t /*momen fitter=fSingleSectorFitter->GetFitter(0, padType); fitter->AddPoint(xx, q); - // this will be gone for the a new ROOT version > v5-17-05 - if (padType == kShortPads) - fNShortClusters[segment]++; - if (padType == kMediumPads) - fNMediumClusters[segment]++; - if (padType == kLongPads) - fNLongClusters[segment]++; } void AliTPCcalibTracksGain::Evaluate(Bool_t robust, Double_t frac) { @@ -902,31 +883,9 @@ void AliTPCcalibTracksGain::GetErrors(UInt_t segment, UInt_t padType, UInt_t fit // GetFitter(segment, padType, fitType)->GetErrors(fitError); - fitError *= TMath::Sqrt(GetRedChi2(segment, padType, fitType)); + //fitError *= TMath::Sqrt(GetRedChi2(segment, padType, fitType)); } -Double_t AliTPCcalibTracksGain::GetRedChi2(UInt_t segment, UInt_t padType, UInt_t fitType) { - // - // Returns the reduced chi^2 value for the specified segment, padType and fitType. - // padType is one of kShortPads, kMediumPads, kLongPads. fitType is one of kSimpleFitter, kSqrtFitter, kLogFitter. - // Note: The fitter has to be evaluated first! - // - - // this will be gone for the a new ROOT version > v5-17-05 - Int_t lNClusters = 0; - switch (padType) { - case kShortPads: - lNClusters = fNShortClusters[segment]; - break; - case kMediumPads: - lNClusters = fNMediumClusters[segment]; - break; - case kLongPads: - lNClusters = fNLongClusters[segment]; - break; - } - return GetFitter(segment, padType, fitType)->GetChisquare()/(lNClusters - 8); -} void AliTPCcalibTracksGain::GetCovarianceMatrix(UInt_t segment, UInt_t padType, UInt_t fitType, TMatrixD& covMatrix) { // diff --git a/TPC/AliTPCcalibTracksGain.h b/TPC/AliTPCcalibTracksGain.h index 767e04714bd..545ad0da62b 100644 --- a/TPC/AliTPCcalibTracksGain.h +++ b/TPC/AliTPCcalibTracksGain.h @@ -90,7 +90,6 @@ public: void Evaluate(Bool_t robust = kFALSE, Double_t frac = -1.); Bool_t GetParameters(UInt_t segment, UInt_t padType, UInt_t fitType, TVectorD &fitParam); void GetErrors(UInt_t segment, UInt_t padType, UInt_t fitType, TVectorD &fitError); - Double_t GetRedChi2(UInt_t segment, UInt_t padType, UInt_t fitType); void GetCovarianceMatrix(UInt_t segment, UInt_t padType, UInt_t fitType, TMatrixD& covMatrix); // // @@ -143,9 +142,6 @@ public: // UInt_t fTotalTracks; // just for debugging UInt_t fAcceptedTracks; // just for debugging - UInt_t fNShortClusters[36]; // number of clusters registered on short pads - UInt_t fNMediumClusters[36]; // number of clusters registered on medium pads - UInt_t fNLongClusters[36]; // number of clusters registered on long pads // // // diff --git a/TPC/AliTPCclustererKr.cxx b/TPC/AliTPCclustererKr.cxx index 0576374467b..03c16a048e6 100644 --- a/TPC/AliTPCclustererKr.cxx +++ b/TPC/AliTPCclustererKr.cxx @@ -443,8 +443,9 @@ Int_t AliTPCclustererKr::FinderIO(AliRawReader* rawReader) // Krypton cluster finder for the TPC raw data // this method is unsing AliAltroRawStreamV3 // fParam must be defined before - - if(rawReader)fRawData=kTRUE; //set flag to data + if (!rawReader) return 1; + // + fRawData=kTRUE; //set flag to data if (!fOutput) { Error("Digits2Clusters", "output tree not initialised"); diff --git a/TPC/AliTPCkalmanAlign.cxx b/TPC/AliTPCkalmanAlign.cxx index e6049f05b6b..3123033f595 100644 --- a/TPC/AliTPCkalmanAlign.cxx +++ b/TPC/AliTPCkalmanAlign.cxx @@ -919,6 +919,7 @@ void AliTPCkalmanAlign::FitCE(){ TCut cutSector=Form("(sector%%36)==%d",isec); strFitLX = TStatToolkit::FitPlane(chain,"deltaT-CEG.fElements-CELX.fElements", fstringL.Data(),cutSector+cutAll+"abs(deltaT-CEG.fElements-CELX.fElements)<0.4", chi2,npoints,vecL[isec],covar,-1,0, 10000000, kFALSE); printf("sec=%d\tchi2=%f\n",isec,TMath::Sqrt(chi2/npoints)); + delete strFitLX; // TString fitL=Form("((sector%%36)==%d)++((sector%%36)==%d)*(sector<36)++((sector%%36)==%d)*(lx-133)/100.++((sector%%36)==%d)*(sector<36)*(lx-133)/100.++((sector%%36)==%d)*(ly)/100.++((sector%%36)==%d)*(sector<36)*(ly)/100.",isec,isec,isec,isec,isec,isec); if (isec<18) padFitTmpCE=AliTPCCalPad::CreateCalPadFit(fitL.Data(),vecL[isec],dummy); diff --git a/TPC/AliTPCtrackerSector.cxx b/TPC/AliTPCtrackerSector.cxx index 551a9d54570..d0671fac14a 100644 --- a/TPC/AliTPCtrackerSector.cxx +++ b/TPC/AliTPCtrackerSector.cxx @@ -55,7 +55,9 @@ AliTPCtrackerRow::AliTPCtrackerRow(): fClusters2(0), fN2(0), fN(0), - fX(0.) + fClusters(), + fIndex(), + fX(0.) { // // default constructor @@ -194,7 +196,7 @@ void AliTPCtrackerRow::SetFastCluster(Int_t i, Short_t cl){ // // Set cluster info for fast navigation // - if (i>510|| i<0){ + if (i>=510|| i<0){ }else{ fFastCluster[i]=cl; } diff --git a/TPC/AliXRDPROOFtoolkit.cxx b/TPC/AliXRDPROOFtoolkit.cxx index d2c1daf8dc9..752da17cca1 100644 --- a/TPC/AliXRDPROOFtoolkit.cxx +++ b/TPC/AliXRDPROOFtoolkit.cxx @@ -359,16 +359,16 @@ Bool_t AliXRDPROOFtoolkit::FilterList(const char*inputList, const char*fileList for (Int_t i=0; iGetEntries(); i+=2){ char fname[1000]; if (!isZip){ - sprintf(fname, "%s/%s",dirname,array->At(i)->GetName()); + snprintf(fname,1000, "%s/%s",dirname,array->At(i)->GetName()); if (((TObjString*)array->At(i))->String().Contains("*")){ - sprintf(fname, "%s", currentFile.Data()); + snprintf(fname,1000, "%s", currentFile.Data()); } } if (isZip) { const char * fileName = gSystem->BaseName(currentFile.Data()); TString fstring=fileName; fstring[fstring.First("#")]=0; - sprintf(fname, "%s/%s#%s",dirname,fstring.Data(),array->At(i)->GetName()); + snprintf(fname,1000, "%s/%s#%s",dirname,fstring.Data(),array->At(i)->GetName()); printf(fname, "To check %s%s#%s\n",dirname,fstring.Data(),array->At(i)->GetName()); } @@ -444,7 +444,7 @@ Bool_t AliXRDPROOFtoolkit::FilterListZip(const char*inputList, const char*fileL for (Int_t i=0; iGetEntries(); i+=2){ char fname[1000]; //if (isZip) sprintf(fname, - sprintf(fname, "%s/%s#%s",dirname,fstring.Data(),array->At(i)->GetName()); + snprintf(fname,1000, "%s/%s#%s",dirname,fstring.Data(),array->At(i)->GetName()); printf(fname, "To check %s%s#%s\n",dirname,fstring.Data(),array->At(i)->GetName()); //cout <<"\n arguments: "<< array->At(i+1)->GetName()<<" "<At(i+1)->GetName(), checkLevel,0); @@ -488,8 +488,8 @@ Bool_t AliXRDPROOFtoolkit::XRDCopyDir(const char * idir, const char * files, co char outfile[1000]; Bool_t succes=kTRUE; for (Int_t ifile =0; ifileAt(ifile)->GetName()); - sprintf(outfile,"%s/%s", odir, array->At(ifile)->GetName()); + snprintf(infile,1000,"%s/%s", idir, array->At(ifile)->GetName()); + snprintf(outfile,1000,"%s/%s", odir, array->At(ifile)->GetName()); printf("%s - %s\n",infile, outfile); Bool_t result = TFile::Cp(infile,outfile); succes &= result; -- 2.43.0