]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITStrackV2.cxx
An upgrade of the generated validation script from A.Maire
[u/mrichter/AliRoot.git] / ITS / AliITStrackV2.cxx
index 469832ba137ca59d97940c74f8dd2079e3b1aac1..2de59d64cbe2c1deb8134c9c09ba4b3476bfeea5 100644 (file)
@@ -13,6 +13,8 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
+/* $Id$ */
+
 ///////////////////////////////////////////////////////////////////////////
 //                Implementation of the ITS track class
 //
 #include <TMath.h>
 
 #include "AliCluster.h"
-#include "AliTracker.h"
 #include "AliESDtrack.h"
+#include "AliESDVertex.h"
+#include "AliITSReconstructor.h"
 #include "AliITStrackV2.h"
+#include "AliTracker.h"
 
 const Int_t AliITStrackV2::fgkWARN = 5;
 
@@ -36,8 +40,8 @@ AliITStrackV2::AliITStrackV2() : AliKalmanTrack(),
   fdEdx(0),
   fESDtrack(0)
 {
-    for(Int_t i=0; i<2*AliITSgeomTGeo::kNLayers; 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;
 }
 
 
@@ -73,8 +77,23 @@ AliITStrackV2::AliITStrackV2(AliESDtrack& t,Bool_t c) throw (const Char_t *) :
   for(Int_t i=0; i<4; i++) fdEdxSample[i]=0;
 }
 
+//____________________________________________________________________________
+void AliITStrackV2::ResetClusters() {
+  //------------------------------------------------------------------
+  // Reset the array of attached clusters.
+  //------------------------------------------------------------------
+  for (Int_t i=0; i<2*AliITSgeomTGeo::kNLayers; i++) fIndex[i]=-1;
+  SetChi2(0.); 
+  SetNumberOfClusters(0);
+} 
+
 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));
+  }
 }
 
 //____________________________________________________________________________
@@ -88,7 +107,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*AliITSgeomTGeo::GetNLayers(); i++) fIndex[i]=t.fIndex[i];
+  for (i=0; i<2*AliITSgeomTGeo::GetNLayers(); i++) {
+    fIndex[i]=t.fIndex[i];
+    fModule[i]=t.fModule[i];
+  }
 }
 
 //_____________________________________________________________________________
@@ -129,7 +151,7 @@ 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(xloc, AliTracker::GetBz(), r);
+  Bool_t rc=GetXYZAt(xloc, GetBz(), r);
   x=r[0]; y=r[1]; z=r[2]; 
   return rc;
 }
@@ -168,7 +190,7 @@ Bool_t AliITStrackV2::PropagateTo(Double_t xk, Double_t d, Double_t x0) {
 }
 
 //____________________________________________________________________________
-Bool_t AliITStrackV2::PropagateToTGeo(Double_t xToGo, Int_t nstep, Double_t &xOverX0, Double_t &xTimesRho) {
+Bool_t AliITStrackV2::PropagateToTGeo(Double_t xToGo, Int_t nstep, Double_t &xOverX0, Double_t &xTimesRho, Bool_t addTime) {
   //-------------------------------------------------------------------
   //  Propagates the track to a reference plane x=xToGo in n steps.
   //  These n steps are only used to take into account the curvature.
@@ -197,7 +219,7 @@ Bool_t AliITStrackV2::PropagateToTGeo(Double_t xToGo, Int_t nstep, Double_t &xOv
     }
   }
 
-  if (IsStartedTimeIntegral() && GetX()>startx) {
+  if (addTime && IsStartedTimeIntegral() && GetX()>startx) {
     Double_t l2 = ( (GetX()-startx)*(GetX()-startx) +
                    (GetY()-starty)*(GetY()-starty) +
                    (GetZ()-startz)*(GetZ()-startz) );
@@ -218,14 +240,21 @@ Bool_t AliITStrackV2::Update(const AliCluster* c, Double_t chi2, Int_t index)
 
   if (!AliExternalTrackParam::Update(p,cov)) return kFALSE;
 
+  Int_t n=GetNumberOfClusters();
   if (!Invariant()) {
-     AliWarning("Wrong invariant !");
+     if (n>fgkWARN) AliWarning("Wrong invariant !");
      return kFALSE;
   }
 
   if (chi2<0) return kTRUE;
 
-  Int_t n=GetNumberOfClusters();
+  // fill residuals for ITS+TPC tracks 
+  if (fESDtrack) {
+    if (fESDtrack->GetStatus()&AliESDtrack::kTPCin) {
+      AliTracker::FillResiduals(this,p,cov,c->GetVolumeId());
+    }
+  }
+
   fIndex[n]=index;
   SetNumberOfClusters(n+1);
   SetChi2(GetChi2()+chi2);
@@ -239,18 +268,31 @@ Bool_t AliITStrackV2::Invariant() const {
   //------------------------------------------------------------------
   Int_t n=GetNumberOfClusters();
 
+  // take into account the misalignment error
+  Float_t maxMisalErrY2=0,maxMisalErrZ2=0;
+  for (Int_t lay=0; lay<AliITSgeomTGeo::kNLayers; lay++) {
+    maxMisalErrY2 = TMath::Max(maxMisalErrY2,AliITSReconstructor::GetRecoParam()->GetClusterMisalErrorY(lay));
+    maxMisalErrZ2 = TMath::Max(maxMisalErrZ2,AliITSReconstructor::GetRecoParam()->GetClusterMisalErrorZ(lay));
+  }
+  maxMisalErrY2 *= maxMisalErrY2;
+  maxMisalErrZ2 *= maxMisalErrZ2;
+  // this is because when we reset before refitting, we multiply the
+  // matrix by 10
+  maxMisalErrY2 *= 10.; 
+  maxMisalErrZ2 *= 10.;
+
   Double_t sP2=GetParameter()[2];
   if (TMath::Abs(sP2) >= kAlmost1){
      if (n>fgkWARN) Warning("Invariant","fP2=%f\n",sP2);
      return kFALSE;
   }
   Double_t sC00=GetCovariance()[0];
-  if (sC00<=0 || sC00>9.) {
+  if (sC00<=0 || sC00>(9.+maxMisalErrY2)) {
      if (n>fgkWARN) Warning("Invariant","fC00=%f\n",sC00); 
      return kFALSE;
   }
   Double_t sC11=GetCovariance()[2];
-  if (sC11<=0 || sC11>9.) {
+  if (sC11<=0 || sC11>(9.+maxMisalErrZ2)) {
      if (n>fgkWARN) Warning("Invariant","fC11=%f\n",sC11); 
      return kFALSE;
   }
@@ -282,8 +324,9 @@ Bool_t AliITStrackV2::Propagate(Double_t alp,Double_t xk) {
   if (!AliExternalTrackParam::Propagate(alp,xk,bz)) return kFALSE;
 
   if (!Invariant()) {
-     AliWarning("Wrong invariant !");
-     return kFALSE;
+    Int_t n=GetNumberOfClusters();
+    if (n>fgkWARN) AliWarning("Wrong invariant !");
+    return kFALSE;
   }
 
   return kTRUE;
@@ -411,15 +454,6 @@ void AliITStrackV2::CookdEdx(Double_t low, Double_t up) {
   SetdEdx(dedx);
 }
 
-Double_t AliITStrackV2::GetBz() const {
-  //
-  // returns Bz component of the magnetic field (kG)
-  //
-  if (AliTracker::UniformField()) return AliTracker::GetBz();
-  Double_t r[3]; GetXYZ(r); 
-  return AliTracker::GetBz(r);
-}
-
 //____________________________________________________________________________
 Bool_t AliITStrackV2::
 GetPhiZat(Double_t r, Double_t &phi, Double_t &z) const {
@@ -436,8 +470,7 @@ GetPhiZat(Double_t r, Double_t &phi, Double_t &z) const {
   Double_t phicurr=GetAlpha()+TMath::ASin(GetSnp());
 
   phi=phicurr+TMath::ASin(d/r)-TMath::ASin(d/rcurr);
-  z=GetZ()+GetTgl()*(TMath::Sqrt(r*r-d*d) - TMath::Sqrt(rcurr*rcurr-d*d));
-
+  z=GetZ()+GetTgl()*(TMath::Sqrt((r-d)*(r+d))-TMath::Sqrt((rcurr-d)*(rcurr+d)));
   return kTRUE;
 }
 //____________________________________________________________________________
@@ -460,4 +493,3 @@ GetLocalXat(Double_t r,Double_t &xloc) const {
 
   return kTRUE;
 }
-