From 44785f3e323b52cf3992aa28d80217e25f7ae08b Mon Sep 17 00:00:00 2001 From: shahoian Date: Fri, 14 Dec 2012 11:00:23 +0000 Subject: [PATCH] Coverity fixes --- ITS/UPGRADE/AliITSUClusterPix.cxx | 4 +- ITS/UPGRADE/AliITSURecoLayer.cxx | 4 +- ITS/UPGRADE/AliITSUReconstructor.cxx | 4 +- ITS/UPGRADE/AliITSUSDigit.cxx | 5 ++ ITS/UPGRADE/AliITSUSeed.cxx | 109 +++++++++++++++++++++++++++ ITS/UPGRADE/AliITSUSeed.h | 47 ++++++++++++ ITS/UPGRADE/AliITSUSensMap.cxx | 10 ++- ITS/UPGRADE/AliITSUTrackerGlo.cxx | 34 ++++++++- ITS/UPGRADE/AliITSUTrackerGlo.h | 3 + 9 files changed, 209 insertions(+), 11 deletions(-) diff --git a/ITS/UPGRADE/AliITSUClusterPix.cxx b/ITS/UPGRADE/AliITSUClusterPix.cxx index 1447107a00a..5c30d664be5 100644 --- a/ITS/UPGRADE/AliITSUClusterPix.cxx +++ b/ITS/UPGRADE/AliITSUClusterPix.cxx @@ -251,7 +251,7 @@ void AliITSUClusterPix::GetTrackingXYZ(Float_t xyz[3]) const Int_t AliITSUClusterPix::Compare(const TObject* obj) const { // compare clusters accodring to specific mode - const AliITSUClusterPix* px = dynamic_cast(obj); + const AliITSUClusterPix* px = (const AliITSUClusterPix*)obj; float xyz[3],xyz1[3]; if (fgMode & kSortIdLocXZ) { // sorting in local frame if (GetVolumeId()==px->GetVolumeId()) { @@ -285,7 +285,7 @@ Int_t AliITSUClusterPix::Compare(const TObject* obj) const Bool_t AliITSUClusterPix::IsEqual(const TObject* obj) const { // compare clusters accodring to specific mode - const AliITSUClusterPix* px = dynamic_cast(obj); + const AliITSUClusterPix* px = (const AliITSUClusterPix*)obj; const Float_t kTol = 1e-5; float xyz[3],xyz1[3]; if (fgMode & kSortIdLocXZ) { // sorting in local frame diff --git a/ITS/UPGRADE/AliITSURecoLayer.cxx b/ITS/UPGRADE/AliITSURecoLayer.cxx index 6ff89e12b33..02c6919dbd3 100644 --- a/ITS/UPGRADE/AliITSURecoLayer.cxx +++ b/ITS/UPGRADE/AliITSURecoLayer.cxx @@ -298,7 +298,7 @@ void AliITSURecoLayer::ProcessClusters(Int_t mode) Bool_t AliITSURecoLayer::IsEqual(const TObject* obj) const { // check if layers are equal in R - const AliITSURecoLayer* lr = dynamic_cast(obj); + const AliITSURecoLayer* lr = (const AliITSURecoLayer*)obj; return Abs(lr->GetR()-GetR())<1e-6 ? kTRUE : kFALSE; } @@ -306,7 +306,7 @@ Bool_t AliITSURecoLayer::IsEqual(const TObject* obj) const Int_t AliITSURecoLayer::Compare(const TObject* obj) const { // compare two layers - const AliITSURecoLayer* lr = dynamic_cast(obj); + const AliITSURecoLayer* lr = (const AliITSURecoLayer*)obj; double dr = GetR() - lr->GetR(); if (Abs(dr)<1e-6) return 0; return dr>0 ? 1:-1; diff --git a/ITS/UPGRADE/AliITSUReconstructor.cxx b/ITS/UPGRADE/AliITSUReconstructor.cxx index edbb731462b..04ca9db58e2 100644 --- a/ITS/UPGRADE/AliITSUReconstructor.cxx +++ b/ITS/UPGRADE/AliITSUReconstructor.cxx @@ -65,8 +65,9 @@ AliITSUReconstructor::~AliITSUReconstructor() delete clFinder; } // - delete[] fClusters; + delete fClusters[i]; } + delete[] fClusters; // delete fGeom; } @@ -120,6 +121,7 @@ void AliITSUReconstructor::Reconstruct(TTree *digitsTree, TTree *clustersTree) c TBranch *lrBranch[fGeom->GetNLayers()]; // for (int ilr=0;ilrGetNLayers();ilr++) { + lrBranch[ilr] = 0; if (clustersTree) { // do we write clusters tree? int tp = fGeom->GetLayerDetTypeID(ilr)/AliITSUGeomTGeo::kMaxSegmPerDetType; if (tp==AliITSUGeomTGeo::kDetTypePix) { diff --git a/ITS/UPGRADE/AliITSUSDigit.cxx b/ITS/UPGRADE/AliITSUSDigit.cxx index b7054b27cae..8fa6257a4ff 100644 --- a/ITS/UPGRADE/AliITSUSDigit.cxx +++ b/ITS/UPGRADE/AliITSUSDigit.cxx @@ -32,6 +32,11 @@ AliITSUSDigit::AliITSUSDigit() ,fSignalAfterElect(0.0) { // Default constructor + for (int i=kBuffSize;i--;) { + fTrack[i] = -2; + fHits[i] = -1; + fSignal[i] = 0; + } } //______________________________________________________________________ diff --git a/ITS/UPGRADE/AliITSUSeed.cxx b/ITS/UPGRADE/AliITSUSeed.cxx index 7c424057c11..b98be8d84b1 100644 --- a/ITS/UPGRADE/AliITSUSeed.cxx +++ b/ITS/UPGRADE/AliITSUSeed.cxx @@ -14,6 +14,7 @@ AliITSUSeed::AliITSUSeed() ,fParent(0) { // def c-tor + ResetFMatrix(); } //_________________________________________________________________________ @@ -32,6 +33,7 @@ AliITSUSeed::AliITSUSeed(const AliITSUSeed& src) ,fParent(src.fParent) { // def c-tor + for (int i=kNFElem;i--;) fFMatrix[i] = src.fFMatrix[i]; } //_________________________________________________________________________ @@ -44,6 +46,7 @@ AliITSUSeed &AliITSUSeed::operator=(const AliITSUSeed& src) fChi2Glo = src.fChi2Glo; fChi2Cl = src.fChi2Cl; fParent = src.fParent; + for (int i=kNFElem;i--;) fFMatrix[i] = src.fFMatrix[i]; AliExternalTrackParam::operator=(src); return *this; } @@ -94,3 +97,109 @@ Bool_t AliITSUSeed::IsEqual(const TObject* obj) const if (IsKilled() != sd->IsKilled()) return kFALSE; return Abs(GetChi2Glo() - sd->GetChi2Glo())= kAlmost1) return kFALSE; + if (TMath::Abs(f2) >= kAlmost1) return kFALSE; + if (TMath::Abs(fP[4])< kAlmost0) return kFALSE; + + Double_t &fP0=fP[0], &fP1=fP[1], &fP2=fP[2], &fP3=fP[3], &fP4=fP[4]; + Double_t + &fC00=fC[0], + &fC10=fC[1], &fC11=fC[2], + &fC20=fC[3], &fC21=fC[4], &fC22=fC[5], + &fC30=fC[6], &fC31=fC[7], &fC32=fC[8], &fC33=fC[9], + &fC40=fC[10], &fC41=fC[11], &fC42=fC[12], &fC43=fC[13], &fC44=fC[14]; + + Double_t r1=TMath::Sqrt((1.-f1)*(1.+f1)), r2=TMath::Sqrt((1.-f2)*(1.+f2)); + if (TMath::Abs(r1)=0) fHitsPattern |= 0x1<GetEntriesFast();i--;) { - TObject* obj = fItems->At(i); - if (obj && ! IsDisabled(obj)) continue; - RegisterItem(obj); + if (fItems) { + for (int i=fItems->GetEntriesFast();i--;) { + TObject* obj = fItems->At(i); + if (obj && ! IsDisabled(obj)) continue; + RegisterItem(obj); + } } } } diff --git a/ITS/UPGRADE/AliITSUTrackerGlo.cxx b/ITS/UPGRADE/AliITSUTrackerGlo.cxx index 7dd56d1b5a2..ed7ae4d083a 100644 --- a/ITS/UPGRADE/AliITSUTrackerGlo.cxx +++ b/ITS/UPGRADE/AliITSUTrackerGlo.cxx @@ -309,7 +309,7 @@ Bool_t AliITSUTrackerGlo::TransportToLayer(AliITSUSeed* seed, Int_t lFrom, Int_t if (doLayer) { if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE; // go via layer to its boundary, applying material correction. - if (!PropagateTrackTo(seed,xToGo,fCurrMass, lrFr->GetMaxStep(), kFALSE, -1, 0, kTRUE)) return kFALSE; + if (!PropagateSeed(seed,xToGo,fCurrMass, lrFr->GetMaxStep())) return kFALSE; } } AliITSURecoLayer* lrTo = fITS->GetLayer( (lFrom+=dir) ); @@ -318,7 +318,7 @@ Bool_t AliITSUTrackerGlo::TransportToLayer(AliITSUSeed* seed, Int_t lFrom, Int_t // go the entrance of the layer, assuming no materials in between double xToGo = dir>0 ? lrTo->GetRMin() : lrTo->GetRMax(); if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE; - if (!seed->PropagateTo(xToGo, GetBz())) return kFALSE; // RS: do we need BxByBz? + if (!PropagateSeed(seed,xToGo,fCurrMass,100, kFALSE )) return kFALSE; lrFr = lrTo; } return kTRUE; @@ -460,3 +460,33 @@ Bool_t AliITSUTrackerGlo::NeedToKill(AliITSUSeed *seed, Int_t flag) } return kTRUE; } + +//______________________________________________________________________________ +Bool_t AliITSUTrackerGlo::PropagateSeed(AliITSUSeed *seed, Double_t xToGo, Double_t mass, Double_t maxStep, Bool_t matCorr) +{ + // propagate seed to given x applying material correction if requested + const Double_t kEpsilon = 1e-5; + Double_t xpos = seed->GetX(); + Int_t dir = (xposGetXYZ(xyz1); //starting global position + while ( (xToGo-xpos)*dir > kEpsilon){ + Double_t step = dir*TMath::Min(TMath::Abs(xToGo-xpos), maxStep); + Double_t x = xpos+step; + Double_t bz=GetBz(); // getting the local Bz + if (!seed->PropagateToX(x,bz)) return kFALSE; + if (matCorr) { + xyz0[0]=xyz1[0]; // global pos at the beginning of step + xyz0[1]=xyz1[1]; + xyz0[2]=xyz1[2]; + seed->GetXYZ(xyz1); // // global pos at the end of step + MeanMaterialBudget(xyz0,xyz1,param); + Double_t xrho=param[0]*param[4], xx0=param[1]; + if (dir>0) xrho = -xrho; // outward should be negative + if (!seed->ApplyMaterialCorrection(xx0,xrho,mass,kFALSE)) return kFALSE; + } + xpos = seed->GetX(); + } + return kTRUE; +} diff --git a/ITS/UPGRADE/AliITSUTrackerGlo.h b/ITS/UPGRADE/AliITSUTrackerGlo.h index c10ea011864..45995a10fb9 100644 --- a/ITS/UPGRADE/AliITSUTrackerGlo.h +++ b/ITS/UPGRADE/AliITSUTrackerGlo.h @@ -56,6 +56,8 @@ class AliITSUTrackerGlo : public AliTracker { Int_t GetNSeeds(Int_t lr) const {return fSeedsLr[lr].GetEntriesFast();} //RS TOCHECK AliITSUSeed* GetSeed(Int_t lr, Int_t sID) const {return (AliITSUSeed*)fSeedsLr[lr].UncheckedAt(sID);} //RS TOCHECK Bool_t TransportToLayer(AliITSUSeed* seed, Int_t lFrom, Int_t lTo); + Bool_t PropagateSeed(AliITSUSeed *seed, Double_t xToGo, Double_t mass, Double_t maxStep=1.0, Bool_t matCorr=kTRUE); + // Bool_t NeedToKill(AliITSUSeed* seed, Int_t flag); Bool_t GetRoadWidth(AliITSUSeed* seed, int ilrA); Int_t CheckCluster(AliITSUSeed* seed, Int_t lr, Int_t clID); @@ -65,6 +67,7 @@ class AliITSUTrackerGlo : public AliTracker { void DeleteLastSeedFromPool() {fSeedsPool.RemoveLast();} void ResetSeedTree(); // RS TOCHECK // + private: AliITSUTrackerGlo(const AliITSUTrackerGlo&); -- 2.43.0