]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITStrackV2.cxx
- AliITSInitGeometry.cxx (updated): fgkOldSSDcone changed from kTRUE to
[u/mrichter/AliRoot.git] / ITS / AliITStrackV2.cxx
index ec1fb078b40b47a1d224519c5550f8d9012c1356..6edcfebfd48180d7c2939e142fc065c66ea94531 100644 (file)
@@ -13,6 +13,8 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
+/* $Id$ */
+
 ///////////////////////////////////////////////////////////////////////////
 //                Implementation of the ITS track class
 //
 #include "AliESDtrack.h"
 #include "AliITStrackV2.h"
 
+const Int_t AliITStrackV2::fgkWARN = 5;
+
 ClassImp(AliITStrackV2)
 
-const Int_t kWARN=5;
 
 //____________________________________________________________________________
 AliITStrackV2::AliITStrackV2() : AliKalmanTrack(),
   fdEdx(0),
   fESDtrack(0)
 {
-    for(Int_t i=0; i<2*kMaxLayer; i++) fIndex[i]=-1;
-    for(Int_t i=0; i<4; i++) fdEdxSample[i]=0;
+  for(Int_t i=0; i<2*AliITSgeomTGeo::kNLayers; i++) {fIndex[i]=-1; fModule[i]=-1;}
+  for(Int_t i=0; i<4; i++) fdEdxSample[i]=0;
 }
 
 
@@ -74,6 +77,11 @@ AliITStrackV2::AliITStrackV2(AliESDtrack& t,Bool_t c) throw (const Char_t *) :
 
 void AliITStrackV2::UpdateESDtrack(ULong_t flags) const {
   fESDtrack->UpdateTrackParams(this,flags);
+  // copy the module indices
+  for(Int_t i=0;i<12;i++) {
+    //   printf("     %d\n",GetModuleIndex(i));
+    fESDtrack->SetITSModuleIndex(i,GetModuleIndex(i));
+  }
 }
 
 //____________________________________________________________________________
@@ -87,7 +95,10 @@ AliITStrackV2::AliITStrackV2(const AliITStrackV2& t) :
   //------------------------------------------------------------------
   Int_t i;
   for (i=0; i<4; i++) fdEdxSample[i]=t.fdEdxSample[i];
-  for (i=0; i<2*kMaxLayer; i++) fIndex[i]=t.fIndex[i];
+  for (i=0; i<2*AliITSgeomTGeo::GetNLayers(); i++) {
+    fIndex[i]=t.fIndex[i];
+    fModule[i]=t.fModule[i];
+  }
 }
 
 //_____________________________________________________________________________
@@ -96,8 +107,8 @@ Int_t AliITStrackV2::Compare(const TObject *o) const {
   // This function compares tracks according to the their curvature
   //-----------------------------------------------------------------
   AliITStrackV2 *t=(AliITStrackV2*)o;
-  //Double_t co=TMath::Abs(t->Get1Pt());
-  //Double_t c =TMath::Abs(Get1Pt());
+  //Double_t co=OneOverPt();
+  //Double_t c =OneOverPt();
   Double_t co=t->GetSigmaY2()*t->GetSigmaZ2();
   Double_t c =GetSigmaY2()*GetSigmaZ2();
   if (c>co) return 1;
@@ -113,19 +124,22 @@ AliITStrackV2::PropagateToVertex(const AliESDVertex *v,Double_t d,Double_t x0)
   //This function propagates a track to the minimal distance from the origin
   //------------------------------------------------------------------  
   Double_t bz=GetBz();
-  if (PropagateToDCA(v,bz,kVeryBig))
-   if (AliExternalTrackParam::CorrectForMaterial(d,x0,GetMass())) return kTRUE;
+  if (PropagateToDCA(v,bz,kVeryBig)) {
+    Double_t xOverX0,xTimesRho; 
+    xOverX0 = d; xTimesRho = d*x0;
+    if (CorrectForMeanMaterial(xOverX0,xTimesRho,kTRUE)) return kTRUE;
+  }
   return kFALSE;
 }
 
 //____________________________________________________________________________
 Bool_t AliITStrackV2::
-GetGlobalXYZat(Double_t xk, Double_t &x, Double_t &y, Double_t &z) const {
+GetGlobalXYZat(Double_t xloc, Double_t &x, Double_t &y, Double_t &z) const {
   //------------------------------------------------------------------
   //This function returns a track position in the global system
   //------------------------------------------------------------------
   Double_t r[3];
-  Bool_t rc=GetXYZAt(xk, AliTracker::GetBz(), r);
+  Bool_t rc=GetXYZAt(xloc, AliTracker::GetBz(), r);
   x=r[0]; y=r[1]; z=r[2]; 
   return rc;
 }
@@ -145,13 +159,16 @@ Bool_t AliITStrackV2::PropagateTo(Double_t xk, Double_t d, Double_t x0) {
   //------------------------------------------------------------------
   //This function propagates a track
   //------------------------------------------------------------------
+
   Double_t oldX=GetX(), oldY=GetY(), oldZ=GetZ();
   
   Double_t bz=GetBz();
   if (!AliExternalTrackParam::PropagateTo(xk,bz)) return kFALSE;
- if (!AliExternalTrackParam::CorrectForMaterial(d,x0,GetMass())) return kFALSE;
+  Double_t xOverX0,xTimesRho; 
+  xOverX0 = d; xTimesRho = d*x0;
+  if (!CorrectForMeanMaterial(xOverX0,xTimesRho,kTRUE)) return kFALSE;
 
-  Double_t x=GetX(), y=GetZ(), z=GetZ();
+  Double_t x=GetX(), y=GetY(), z=GetZ();
   if (IsStartedTimeIntegral() && x>oldX) {
     Double_t l2 = (x-oldX)*(x-oldX) + (y-oldY)*(y-oldY) + (z-oldZ)*(z-oldZ);
     AddTimeStep(TMath::Sqrt(l2));
@@ -160,6 +177,46 @@ Bool_t AliITStrackV2::PropagateTo(Double_t xk, Double_t d, Double_t x0) {
   return kTRUE;
 }
 
+//____________________________________________________________________________
+Bool_t AliITStrackV2::PropagateToTGeo(Double_t xToGo, Int_t nstep, Double_t &xOverX0, Double_t &xTimesRho) {
+  //-------------------------------------------------------------------
+  //  Propagates the track to a reference plane x=xToGo in n steps.
+  //  These n steps are only used to take into account the curvature.
+  //  The material is calculated with TGeo. (L.Gaudichet)
+  //-------------------------------------------------------------------
+  
+  Double_t startx = GetX(), starty = GetY(), startz = GetZ();
+  Double_t sign = (startx<xToGo) ? -1.:1.;
+  Double_t step = (xToGo-startx)/TMath::Abs(nstep);
+
+  Double_t start[3], end[3], mparam[7], bz = GetBz();
+  Double_t x = startx;
+  
+  for (Int_t i=0; i<nstep; i++) {
+    
+    GetXYZ(start);   //starting global position
+    x += step;
+    if (!GetXYZAt(x, bz, end)) return kFALSE;
+    if (!AliExternalTrackParam::PropagateTo(x, bz)) return kFALSE;
+    AliTracker::MeanMaterialBudget(start, end, mparam);
+    if (mparam[1]<900000) {
+      xTimesRho = sign*mparam[4]*mparam[0];
+      xOverX0   = mparam[1];
+      if (!AliExternalTrackParam::CorrectForMeanMaterial(xOverX0,
+                                     xTimesRho,GetMass())) return kFALSE;
+    }
+  }
+
+  if (IsStartedTimeIntegral() && GetX()>startx) {
+    Double_t l2 = ( (GetX()-startx)*(GetX()-startx) +
+                   (GetY()-starty)*(GetY()-starty) +
+                   (GetZ()-startz)*(GetZ()-startz) );
+    AddTimeStep(TMath::Sqrt(l2));
+  }
+
+  return kTRUE;
+}
+
 //____________________________________________________________________________
 Bool_t AliITStrackV2::Update(const AliCluster* c, Double_t chi2, Int_t index) 
 {
@@ -178,6 +235,8 @@ Bool_t AliITStrackV2::Update(const AliCluster* c, Double_t chi2, Int_t index)
 
   if (chi2<0) return kTRUE;
 
+  AliTracker::FillResiduals(this,p,cov,c->GetVolumeId());
+
   Int_t n=GetNumberOfClusters();
   fIndex[n]=index;
   SetNumberOfClusters(n+1);
@@ -194,32 +253,32 @@ Bool_t AliITStrackV2::Invariant() const {
 
   Double_t sP2=GetParameter()[2];
   if (TMath::Abs(sP2) >= kAlmost1){
-     if (n>kWARN) Warning("Invariant","fP2=%f\n",sP2);
+     if (n>fgkWARN) Warning("Invariant","fP2=%f\n",sP2);
      return kFALSE;
   }
   Double_t sC00=GetCovariance()[0];
   if (sC00<=0 || sC00>9.) {
-     if (n>kWARN) Warning("Invariant","fC00=%f\n",sC00); 
+     if (n>fgkWARN) Warning("Invariant","fC00=%f\n",sC00); 
      return kFALSE;
   }
   Double_t sC11=GetCovariance()[2];
   if (sC11<=0 || sC11>9.) {
-     if (n>kWARN) Warning("Invariant","fC11=%f\n",sC11); 
+     if (n>fgkWARN) Warning("Invariant","fC11=%f\n",sC11); 
      return kFALSE;
   }
   Double_t sC22=GetCovariance()[5];
   if (sC22<=0 || sC22>1.) {
-     if (n>kWARN) Warning("Invariant","fC22=%f\n",sC22); 
+     if (n>fgkWARN) Warning("Invariant","fC22=%f\n",sC22); 
      return kFALSE;
   }
   Double_t sC33=GetCovariance()[9];
   if (sC33<=0 || sC33>1.) {
-     if (n>kWARN) Warning("Invariant","fC33=%f\n",sC33); 
+     if (n>fgkWARN) Warning("Invariant","fC33=%f\n",sC33); 
      return kFALSE;
   }
   Double_t sC44=GetCovariance()[14];
   if (sC44<=0 /*|| sC44>6e-5*/) {
-     if (n>kWARN) Warning("Invariant","fC44=%f\n",sC44);
+     if (n>fgkWARN) Warning("Invariant","fC44=%f\n",sC44);
      return kFALSE;
   }
 
@@ -242,6 +301,42 @@ Bool_t AliITStrackV2::Propagate(Double_t alp,Double_t xk) {
   return kTRUE;
 }
 
+Bool_t AliITStrackV2::MeanBudgetToPrimVertex(Double_t xyz[3], Double_t step, Double_t &d) const {
+
+  //-------------------------------------------------------------------
+  //  Get the mean material budget between the actual point and the
+  //  primary vertex. (L.Gaudichet)
+  //-------------------------------------------------------------------
+
+  Double_t cs=TMath::Cos(GetAlpha()), sn=TMath::Sin(GetAlpha());
+  Double_t vertexX = xyz[0]*cs + xyz[1]*sn;
+
+  Int_t nstep = Int_t((GetX()-vertexX)/step);
+  if (nstep<1) nstep = 1;
+  step = (GetX()-vertexX)/nstep;
+
+  //  Double_t mparam[7], densMean=0, radLength=0, length=0;
+  Double_t mparam[7];
+  Double_t p1[3], p2[3], x = GetX(), bz = GetBz();
+  GetXYZ(p1);
+
+  d=0.;
+
+  for (Int_t i=0; i<nstep; i++) {
+    x  += step;
+    if (!GetXYZAt(x, bz, p2)) return kFALSE;
+    AliTracker::MeanMaterialBudget(p1, p2, mparam);
+    if (mparam[1]>900000) return kFALSE;
+    d  += mparam[1];
+
+    p1[0] = p2[0];
+    p1[1] = p2[1];
+    p1[2] = p2[2];
+  }
+
+  return kTRUE;
+}
+
 Bool_t AliITStrackV2::Improve(Double_t x0,Double_t xyz[3],Double_t ers[3]) {
   //------------------------------------------------------------------
   //This function improves angular track parameters
@@ -253,7 +348,7 @@ Bool_t AliITStrackV2::Improve(Double_t x0,Double_t xyz[3],Double_t ers[3]) {
 
   Double_t dy = Par(0) - yv, dz = Par(1) - zv;
   Double_t r2=GetX()*GetX() + dy*dy;
-  Double_t p2=(1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt());
+  Double_t p2=(1.+ GetTgl()*GetTgl())/(GetSigned1Pt()*GetSigned1Pt());
   Double_t beta2=p2/(p2 + GetMass()*GetMass());
   x0*=TMath::Sqrt((1.+ GetTgl()*GetTgl())/(1.- GetSnp()*GetSnp()));
   Double_t theta2=14.1*14.1/(beta2*p2*1e6)*x0;
@@ -268,7 +363,7 @@ Bool_t AliITStrackV2::Improve(Double_t x0,Double_t xyz[3],Double_t ers[3]) {
     sigma2p += Cov(0)/r2*(1.- dy*dy/r2)*(1.- dy*dy/r2);
     sigma2p += ers[1]*ers[1]/r2;
     sigma2p += 0.25*Cov(14)*cnv*cnv*GetX()*GetX();
-    Double_t eps2p=sigma2p/(Cov(2) + sigma2p);
+    Double_t eps2p=sigma2p/(Cov(5) + sigma2p);
     Par(0) += Cov(3)/(Cov(5) + sigma2p)*(parp - GetSnp());
     Par(2)  = eps2p*GetSnp() + (1 - eps2p)*parp;
     Cov(5) *= eps2p;
@@ -284,7 +379,7 @@ Bool_t AliITStrackV2::Improve(Double_t x0,Double_t xyz[3],Double_t ers[3]) {
     Par(4) += Cov(13)/(Cov(9) + sigma2l)*(parl - Par(3));
     Par(3)  = eps2l*Par(3) + (1-eps2l)*parl;
     Cov(9) *= eps2l; 
-    Cov(13)*= (eps2l/cnv/cnv)
+    Cov(13)*= eps2l
     Cov(7) *= eps2l; 
   }
   if (!Invariant()) return kFALSE;
@@ -337,3 +432,43 @@ Double_t AliITStrackV2::GetBz() const {
   return AliTracker::GetBz(r);
 }
 
+//____________________________________________________________________________
+Bool_t AliITStrackV2::
+GetPhiZat(Double_t r, Double_t &phi, Double_t &z) const {
+  //------------------------------------------------------------------
+  // This function returns the global cylindrical (phi,z) of the track 
+  // position estimated at the radius r. 
+  // The track curvature is neglected.
+  //------------------------------------------------------------------
+  Double_t d=GetD(0.,0.);
+  if (TMath::Abs(d) > r) return kFALSE; 
+
+  Double_t rcurr=TMath::Sqrt(GetX()*GetX() + GetY()*GetY());
+  if (TMath::Abs(d) > rcurr) return kFALSE; 
+  Double_t phicurr=GetAlpha()+TMath::ASin(GetSnp());
+
+  phi=phicurr+TMath::ASin(d/r)-TMath::ASin(d/rcurr);
+  z=GetZ()+GetTgl()*(TMath::Sqrt((r-d)*(r+d))-TMath::Sqrt((rcurr-d)*(rcurr+d)));
+  return kTRUE;
+}
+//____________________________________________________________________________
+Bool_t AliITStrackV2::
+GetLocalXat(Double_t r,Double_t &xloc) const {
+  //------------------------------------------------------------------
+  // This function returns the local x of the track 
+  // position estimated at the radius r. 
+  // The track curvature is neglected.
+  //------------------------------------------------------------------
+  Double_t d=GetD(0.,0.);
+  if (TMath::Abs(d) > r) return kFALSE; 
+
+  Double_t rcurr=TMath::Sqrt(GetX()*GetX() + GetY()*GetY());
+  Double_t phicurr=GetAlpha()+TMath::ASin(GetSnp());
+  Double_t phi=phicurr+TMath::ASin(d/r)-TMath::ASin(d/rcurr);
+
+  xloc=r*(TMath::Cos(phi)*TMath::Cos(GetAlpha())
+         +TMath::Sin(phi)*TMath::Sin(GetAlpha())); 
+
+  return kTRUE;
+}
+