]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Coverity fixes
authorshahoian <shahoian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 14 Dec 2012 11:00:23 +0000 (11:00 +0000)
committershahoian <shahoian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 14 Dec 2012 11:00:23 +0000 (11:00 +0000)
ITS/UPGRADE/AliITSUClusterPix.cxx
ITS/UPGRADE/AliITSURecoLayer.cxx
ITS/UPGRADE/AliITSUReconstructor.cxx
ITS/UPGRADE/AliITSUSDigit.cxx
ITS/UPGRADE/AliITSUSeed.cxx
ITS/UPGRADE/AliITSUSeed.h
ITS/UPGRADE/AliITSUSensMap.cxx
ITS/UPGRADE/AliITSUTrackerGlo.cxx
ITS/UPGRADE/AliITSUTrackerGlo.h

index 1447107a00ab860f9ca12caca18270b83f24fd8b..5c30d664be5f7830ce744596b1a4755e8c27ff37 100644 (file)
@@ -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<const AliITSUClusterPix*>(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<const AliITSUClusterPix*>(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
index 6ff89e12b33ca7ffa7b6fa85e180f3b2eef4f69a..02c6919dbd3ded211f40eac42bf217edeb8d8fca 100644 (file)
@@ -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<const AliITSURecoLayer*>(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<const AliITSURecoLayer*>(obj);
+  const AliITSURecoLayer* lr = (const AliITSURecoLayer*)obj;
   double dr = GetR() - lr->GetR();
   if (Abs(dr)<1e-6) return 0;
   return dr>0 ? 1:-1;
index edbb731462b4790bea72be1cc5f76b5ab9bd8282..04ca9db58e26d1da5b1e9348c58417e9d40accd8 100644 (file)
@@ -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;ilr<fGeom->GetNLayers();ilr++) {
+    lrBranch[ilr] = 0;
     if (clustersTree) { // do we write clusters tree?
       int tp = fGeom->GetLayerDetTypeID(ilr)/AliITSUGeomTGeo::kMaxSegmPerDetType;
       if (tp==AliITSUGeomTGeo::kDetTypePix) {
index b7054b27caee04eb3d9fb51f1b03749fda93dc64..8fa6257a4ffc2db92f90dc1452745971cc6ecb1a 100644 (file)
@@ -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;
+  }
 }
 
 //______________________________________________________________________
index 7c424057c11f37c6ccdfcd7f92d0ed4b92d0f051..b98be8d84b1939763e5fb24db6f0bed1cdf3c2dd 100644 (file)
@@ -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())<kTol;
 }
+
+//______________________________________________________________________________
+Bool_t AliITSUSeed::PropagateToX(Double_t xk, Double_t b) 
+{
+  // Propagate this track to the plane X=xk (cm) in the field "b" (kG)
+  Double_t dx=xk-fX;
+  if (TMath::Abs(dx)<=kAlmost0)  return kTRUE;
+
+  Double_t crv=GetC(b);
+  if (TMath::Abs(b) < kAlmost0Field) crv=0.;
+  Double_t x2r = crv*dx;
+  Double_t f1=fP[2], f2=f1 + x2r;
+  if (TMath::Abs(f1) >= 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)<kAlmost0)  return kFALSE;
+  if (TMath::Abs(r2)<kAlmost0)  return kFALSE;
+
+  fX=xk;
+  double dy2dx = (f1+f2)/(r1+r2);
+  fP0 += dx*dy2dx;
+  if (TMath::Abs(x2r)<0.05) {
+    fP1 += dx*(r2 + f2*dy2dx)*fP3;  // Many thanks to P.Hristov !
+    fP2 += x2r;
+  }
+  else { 
+    // for small dx/R the linear apporximation of the arc by the segment is OK,
+    // but at large dx/R the error is very large and leads to incorrect Z propagation
+    // angle traversed delta = 2*asin(dist_start_end / R / 2), hence the arc is: R*deltaPhi
+    // The dist_start_end is obtained from sqrt(dx^2+dy^2) = x/(r1+r2)*sqrt(2+f1*f2+r1*r2)
+    // Similarly, the rotation angle in linear in dx only for dx<<R
+    double chord = dx*TMath::Sqrt(1+dy2dx*dy2dx);   // distance from old position to new one
+    double rot = 2*TMath::ASin(0.5*chord*crv); // angular difference seen from the circle center
+    fP1 += rot/crv*fP3;
+    fP2  = TMath::Sin(rot + TMath::ASin(fP2));
+  }
+
+  //f = F - 1
+  double r1i = 1./r1;
+  double r2i = 1./r2;
+  double tg1 = f1*r1i;
+  double tg2 = f2*r2i;
+  double v0 = 1. + dy2dx*tg2;
+  double v1 = (r1i+r2i)*(dy2dx*(tg1+tg2)+2);
+  double v2 = (r1i+r2i)*v0;
+  //
+  double f24 = dx*crv/fP4;
+  double f02 = dx*v1;
+  double f04 = dx*v2*f24;
+  double f12 = dx*fP3*    (f2*v1+dy2dx-tg2);
+  double f13 = dx*r2*v0;
+  double f14 = dx*f24*fP3*(f2*v2+dy2dx-tg2);
+  //
+  //b = C*ft
+  Double_t b00=f02*fC20 + f04*fC40, b01=f12*fC20 + f14*fC40 + f13*fC30;
+  Double_t b02=f24*fC40;
+  Double_t b10=f02*fC21 + f04*fC41, b11=f12*fC21 + f14*fC41 + f13*fC31;
+  Double_t b12=f24*fC41;
+  Double_t b20=f02*fC22 + f04*fC42, b21=f12*fC22 + f14*fC42 + f13*fC32;
+  Double_t b22=f24*fC42;
+  Double_t b40=f02*fC42 + f04*fC44, b41=f12*fC42 + f14*fC44 + f13*fC43;
+  Double_t b42=f24*fC44;
+  Double_t b30=f02*fC32 + f04*fC43, b31=f12*fC32 + f14*fC43 + f13*fC33;
+  Double_t b32=f24*fC43;
+  
+  //a = f*b = f*C*ft
+  Double_t a00=f02*b20+f04*b40,a01=f02*b21+f04*b41,a02=f02*b22+f04*b42;
+  Double_t a11=f12*b21+f14*b41+f13*b31,a12=f12*b22+f14*b42+f13*b32;
+  Double_t a22=f24*b42;
+
+  //F*C*Ft = C + (b + bt + a)
+  fC00 += b00 + b00 + a00;
+  fC10 += b10 + b01 + a01; 
+  fC20 += b20 + b02 + a02;
+  fC30 += b30;
+  fC40 += b40;
+  fC11 += b11 + b11 + a11;
+  fC21 += b21 + b12 + a12;
+  fC31 += b31; 
+  fC41 += b41;
+  fC22 += b22 + b22 + a22;
+  fC32 += b32;
+  fC42 += b42;
+  //
+  // update stored transformation matrix   F = Fnew*Fold
+  fFMatrix[kF04] += f04 + f24*fFMatrix[kF02];
+  fFMatrix[kF14] += f14 + f24*fFMatrix[kF12];
+  fFMatrix[kF02] += f02;
+  fFMatrix[kF12] += f12;
+  fFMatrix[kF13] += f13;
+  fFMatrix[kF24] += f24;
+  //
+  CheckCovariance();
+
+  return kTRUE;
+}
index 8ebafd6a9d2ead3b9ce0d14be91a672357aee543..7d8b9608104fcb4af2c995159190261853db7470 100644 (file)
@@ -10,6 +10,8 @@ class AliITSUSeed: public AliExternalTrackParam
 {
  public:
   enum {kKilled=BIT(14)};
+  enum {kF02,kF04,kF12,kF13,kF14,kF24, kF44,kNFElem}; // non-trivial elems of propagation matrix
+  enum {kB00,kB01,kB02,kB03,kB04,kB10,kB11,kB12,kB13,kB14, kNBElem}; // non-trivial elems of B matrix (I - K*H)
   //
   AliITSUSeed();
   AliITSUSeed(const AliITSUSeed& src);
@@ -42,7 +44,18 @@ class AliITSUSeed: public AliExternalTrackParam
   virtual Bool_t  IsEqual(const TObject* obj)      const;
   virtual Int_t          Compare(const TObject* obj)      const;
   //
+  // test
+  void            ResetFMatrix();
+  void            ApplyELoss2FMatrix(Double_t frac, Bool_t beforeProp);
+  Bool_t          ApplyMaterialCorrection(Double_t xOverX0, Double_t xTimesRho, Double_t mass, Bool_t beforeProp);
+  Bool_t          PropagateToX(Double_t xk, Double_t b);
+  //
  protected:
+  //
+  Double_t              fFMatrix[kNFElem];  // matxif of propagation from prev layer (non-trivial elements)
+  Double_t              fResid[2];          // residuals vector
+  Double_t              fCombErrI[3];       // inverse combined error matrix
+  Double_t              fBMatix[kNBElem];   // I - K*H matix non-trivial elements
   UShort_t              fHitsPattern;       // bit pattern of hits
   UInt_t                fClID;              // packed cluster info (see AliITSUAux::PackCluster)
   Float_t               fChi2Glo;           // current chi2 global
@@ -60,5 +73,39 @@ inline void AliITSUSeed::SetLrClusterID(Int_t lr, Int_t cl)
   if (cl>=0) fHitsPattern |= 0x1<<lr;
 }
 
+//_________________________________________________________________________
+inline void AliITSUSeed::ResetFMatrix()
+{
+  // reset transport matrix
+  fFMatrix[kF02] = fFMatrix[kF04] = fFMatrix[kF12] = fFMatrix[kF13] = fFMatrix[kF14] = fFMatrix[kF24] = 0;
+  fFMatrix[kF44] = 1.0;  // this element accumulates eloss 
+}
+
+//_________________________________________________________________________
+inline Bool_t AliITSUSeed::ApplyMaterialCorrection(Double_t xOverX0, Double_t xTimesRho, Double_t mass, Bool_t beforeProp)
+{
+  // apply material correction and modify transport matrix
+  double pold = Get1P();
+  if (!CorrectForMeanMaterial(xOverX0,xTimesRho,mass)) return kFALSE;
+  ApplyELoss2FMatrix( Get1P()/pold, beforeProp);
+  return kTRUE;
+}
+
+
+//_________________________________________________________________________
+inline void AliITSUSeed::ApplyELoss2FMatrix(Double_t frac, Bool_t beforeProp)
+{
+  // Accounts for the energy loss in the transport matrix
+  // equivalent to multiplying Fmatix by E=diag{1,1,1,1,P4new/P4old}, where P4 is the 1/pt param.
+  // If beforeProp is true, then it is assumed that the eloss was applied before the transport,
+  // i.e. F' = F * E, otherwise, after transport, F' = E * F
+  fFMatrix[kF44] *= frac;
+  if (beforeProp) {
+    fFMatrix[kF04] *= frac;
+    fFMatrix[kF14] *= frac;
+    fFMatrix[kF24] *= frac;
+  }
+}
+
 
 #endif
index b142786f8169e4a3591469844703c6222dace1b9..2756ffaa279751b3cd86f222d4fce83ae9579e36 100644 (file)
@@ -75,10 +75,12 @@ AliITSUSensMap::AliITSUSensMap(const AliITSUSensMap &source)
 {
   if (source.fBTree) {
     fBTree = new TBtree();
-    for (int i=fItems->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);
+      }
     }
   }
 }
index 7dd56d1b5a22d193c91e2f835674fc8949756722..ed7ae4d083aa424e44f88d381bbf921625c93528 100644 (file)
@@ -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         = (xpos<xToGo) ? 1:-1;
+  Double_t xyz0[3],xyz1[3],param[7];
+  //
+  if (matCorr) seed->GetXYZ(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;
+}
index c10ea0118648841a5ed5e0b901b142276678c785..45995a10fb95c4dd22a222ff94e0d22117388154 100644 (file)
@@ -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&);