]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFtrack.cxx
bugfix: corrected calculation of slice and partition from track point Id
[u/mrichter/AliRoot.git] / TOF / AliTOFtrack.cxx
index 47309c9b431696153b2a1ac202226ed15c1d99e9..17880f5c69996fc0509a616b514fd7cb7fabdb15 100644 (file)
@@ -28,7 +28,6 @@
 #include "AliESDtrack.h" 
 #include "AliTracker.h" 
 
-#include "AliTOFGeometryV4.h"
 #include "AliTOFGeometry.h"
 #include "AliTOFtrack.h" 
 
@@ -38,8 +37,7 @@ ClassImp(AliTOFtrack)
 AliTOFtrack::AliTOFtrack() : 
   AliKalmanTrack(),
   fSeedInd(-1),
-  fSeedLab(-1),
-  fTOFgeometry(0)
+  fSeedLab(-1)
 {
   //
   // Default constructor.
@@ -50,8 +48,7 @@ AliTOFtrack::AliTOFtrack() :
 AliTOFtrack::AliTOFtrack(const AliTOFtrack& t) : 
   AliKalmanTrack(t),
   fSeedInd(t.fSeedInd),
-  fSeedLab(t.fSeedLab),
-  fTOFgeometry(new AliTOFGeometryV4()) 
+  fSeedLab(t.fSeedLab) 
 {
   //
   // Copy constructor.
@@ -62,8 +59,7 @@ AliTOFtrack::AliTOFtrack(const AliTOFtrack& t) :
 AliTOFtrack::AliTOFtrack(const AliESDtrack& t) :
   AliKalmanTrack(), 
   fSeedInd(-1),
-  fSeedLab(-1),
-  fTOFgeometry(new AliTOFGeometryV4()) 
+  fSeedLab(-1) 
 {
   //
   // Constructor from AliESDtrack
@@ -82,35 +78,69 @@ AliTOFtrack::AliTOFtrack(const AliESDtrack& t) :
 }              
 
 //____________________________________________________________________________
-AliTOFtrack& AliTOFtrack::operator=(const AliTOFtrack &source)
+AliTOFtrack& AliTOFtrack::operator=(const AliTOFtrack &/*source*/)
 {
   // ass. op.
 
-  this->fTOFgeometry=source.fTOFgeometry;
   return *this;
 
 }
 
 //_____________________________________________________________________________
-Bool_t AliTOFtrack::PropagateTo(Double_t xk,Double_t x0,Double_t rho)
-{
+Bool_t AliTOFtrack::PropagateTo(Double_t xk,Double_t /*x0*/,Double_t /*rho*/)
+ {
+  //
   // Propagates a track of particle with mass=pm to a reference plane 
   // defined by x=xk through media of density=rho and radiationLength=x0
+  //
 
   if (xk == GetX()) return kTRUE;
   
-  Double_t oldX=GetX(), oldY=GetY(), oldZ=GetZ();
+  Double_t oldX=GetX();//, oldY=GetY(), oldZ=GetZ();
+  Double_t start[3], end[3], mparam[7];
 
-  Double_t bz=GetBz();
-  if (!AliExternalTrackParam::PropagateTo(xk,bz)) return kFALSE;
+  /* get start position */
+  GetXYZ(start);
 
+  /* propagate the track */
+  Double_t b[3];GetBxByBz(b);
+  if (!AliExternalTrackParam::PropagateToBxByBz(xk,b)) return kFALSE;
+  // OLD used code
+  //Double_t bz=GetBz();
+  //if (!AliExternalTrackParam::PropagateTo(xk,bz)) return kFALSE;
+
+  /* get end position */
+  GetXYZ(end);
+
+  /* add time step to integral */
+#if 0 /*** OLD ***/
   Double_t d = TMath::Sqrt((GetX()-oldX)*(GetX()-oldX) + 
                            (GetY()-oldY)*(GetY()-oldY) + 
                            (GetZ()-oldZ)*(GetZ()-oldZ));
   if (IsStartedTimeIntegral() && GetX()>oldX) AddTimeStep(d);
+#endif
+  Double_t d = TMath::Sqrt((end[0]-start[0])*(end[0]-start[0]) + 
+                           (end[1]-start[1])*(end[1]-start[1]) + 
+                           (end[2]-start[2])*(end[2]-start[2]));
+  if (IsStartedTimeIntegral() && GetX()>oldX) AddTimeStep(d);
+
+  /* get material budget from tracker */
+  AliTracker::MeanMaterialBudget(start, end, mparam);
+  Double_t xTimesRho = mparam[4]*mparam[0];
+  if (oldX < xk) { // CZ
+    xTimesRho = -xTimesRho; // it should be negative in case of outward
+                            // propagation (--> energy decreases)
+  } // CZ
+  Double_t xOverX0   = mparam[1];
 
+  /* correct for mean material */
+  if (!AliExternalTrackParam::CorrectForMeanMaterial(xOverX0,xTimesRho,GetMass())) return kFALSE;
+
+
+#if 0 /*** OLD ***/
   if (!AliExternalTrackParam::CorrectForMaterial(d*rho/x0,x0,GetMass())) 
      return kFALSE;
+#endif
 
   /*
   //Energy losses************************
@@ -128,15 +158,82 @@ Bool_t AliTOFtrack::PropagateTo(Double_t xk,Double_t x0,Double_t rho)
 }     
 
 //_____________________________________________________________________________
-Bool_t AliTOFtrack::PropagateToInnerTOF(Bool_t holes)
+Bool_t AliTOFtrack::PropagateToInnerTOF()
 {
   // Propagates a track of particle with mass=pm to a reference plane 
   // defined by x=xk through media of density=rho and radiationLength=x0
 
+  //const Double_t kAlphac  = TMath::Pi()/9.0; // 20 degree
+  const Double_t kAlphac  = AliTOFGeometry::GetAlpha(); // 20 degree
+  const Double_t kTalphac = TMath::Tan(kAlphac*0.5);
+
+  //const Double_t kStepSize = 0.1; // [cm] Step size
+  const Double_t kStepSize = 0.5; // [cm] Step size
+
+  Double_t x = GetX();
+  //Double_t bz = GetBz();
+
+  //Double_t xyz0[3];
+  //Double_t xyz1[3];
+  //Double_t y;
+  //Double_t z;
+
+  Int_t nsteps = (Int_t)((AliTOFGeometry::Rmin()-x)/kStepSize);
+  for (Int_t istep=0; istep<nsteps; istep++){
+
+    // Critical alpha  - cross sector indication
 
-  Double_t ymax=fTOFgeometry->RinTOF()*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
+    Double_t dir = (GetX() > AliTOFGeometry::Rmin()) ? -1.0 : 1.0;
+
+    x = GetX()+dir*kStepSize;
+    if ( x<GetX() && GetX()<AliTOFGeometry::Rmin()) {
+      AliDebug(1,Form("Track doesn't reach rho=%f",AliTOFGeometry::Rmin()));
+      return kFALSE;
+    }
+
+    //GetXYZ(xyz0);
+    //bz = GetBz();
+    //GetXYZAt(x,bz,xyz1);
+    //AliExternalTrackParam::GetYAt(x,bz,y);
+    //AliExternalTrackParam::GetZAt(x,bz,z);
+    PropagateTo(x,0.,0.); /* passing 0.,0. as arguments since now
+                             this method queries TGeo for material budget
+                          */
+    
+    if (GetY() >  GetX()*kTalphac)
+      Rotate(kAlphac);
+    else if (GetY() < -GetX()*kTalphac)
+      Rotate(-kAlphac);
+
+  }
+
+  //Bool_t check = PropagateTo(AliTOFGeometry::RinTOF());
+  Bool_t check = PropagateTo(AliTOFGeometry::RinTOF(),0.,0.); /* passing 0.,0. as arguments since now
+                                                                this method queries TGeo for material budget
+                                                             */
+
+  if (!check) return kFALSE;
+
+  if (GetY() >  GetX()*kTalphac)
+    Rotate(kAlphac);
+  else if (GetY() < -GetX()*kTalphac)
+    Rotate(-kAlphac);
+
+  return kTRUE;
+  
+}     
+
+//_____________________________________________________________________________
+Bool_t AliTOFtrack::PropagateToInnerTOFold()
+{
+  // Propagates a track of particle with mass=pm to a reference plane 
+  // defined by x=xk through media of density=rho and radiationLength=x0
+
+
+  Double_t ymax=AliTOFGeometry::RinTOF()*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
   Bool_t skip = kFALSE;
-  Double_t y=GetYat(fTOFgeometry->RinTOF(),skip);
+  Double_t y=GetYat(AliTOFGeometry::RinTOF(),skip);
   if (skip) {
     return kFALSE;
   }
@@ -150,23 +247,61 @@ Bool_t AliTOFtrack::PropagateToInnerTOF(Bool_t holes)
     }
   }
   
-  
   Double_t x = GetX();
-  Int_t nsteps=Int_t((370.-x)/0.5); // 0.5 cm Steps
+  Int_t nsteps=Int_t((AliTOFGeometry::Rmin()-x)/0.5); // 0.5 cm Steps
   for (Int_t istep=0;istep<nsteps;istep++){
     Float_t xp = x+istep*0.5; 
-    Double_t param[2];  
-    GetPropagationParameters(holes,param);  
-    PropagateTo(xp,param[0],param[1]);
+    //    GetPropagationParameters(param);  
+    PropagateTo(xp,0.,0.); /* passing 0.,0. as arguments since now
+                             this method queries TGeo for material budget
+                          */
     
   }
   
-  if(!PropagateTo(fTOFgeometry->RinTOF()))return 0;
+  if(!PropagateTo(AliTOFGeometry::RinTOF()))return 0;
   
   return kTRUE;
   
 }     
 
+//_________________________________________________________________________
+Double_t AliTOFtrack::GetPredictedChi2(const AliCluster3D *c) const {
+  //
+  // Estimate the chi2 of the space point "c" with its cov. matrix elements
+  //
+
+  Double_t p[3]={c->GetX(), c->GetY(), c->GetZ()};
+  Double_t covyz[3]={c->GetSigmaY2(), c->GetSigmaYZ(), c->GetSigmaZ2()};
+  Double_t covxyz[3]={c->GetSigmaX2(), c->GetSigmaXY(), c->GetSigmaXZ()};
+  return AliExternalTrackParam::GetPredictedChi2(p, covyz, covxyz);
+}
+//_________________________________________________________________________
+Bool_t AliTOFtrack::PropagateTo(const AliCluster3D *c) {
+  //
+  // Propagates a track to the plane containing cluster 'c'
+  //
+  Double_t oldX=GetX(), oldY=GetY(), oldZ=GetZ();
+  Double_t p[3]={c->GetX(), c->GetY(), c->GetZ()};
+  Double_t covyz[3]={c->GetSigmaY2(), c->GetSigmaYZ(), c->GetSigmaZ2()};
+  Double_t covxyz[3]={c->GetSigmaX2(), c->GetSigmaXY(), c->GetSigmaXZ()};
+  Double_t bz=GetBz();
+  if (!AliExternalTrackParam::PropagateTo(p, covyz, covxyz, bz)) return kFALSE;
+  if (IsStartedTimeIntegral()) {
+    Double_t d = TMath::Sqrt((GetX()-oldX)*(GetX()-oldX) +
+                            (GetY()-oldY)*(GetY()-oldY) +
+                            (GetZ()-oldZ)*(GetZ()-oldZ));
+    if (GetX()<oldX) d=-d;
+    AddTimeStep(d);
+
+  }
+
+  if (GetY() >  GetX()*TMath::Tan(0.5*AliTOFGeometry::GetAlpha()))
+    Rotate(AliTOFGeometry::GetAlpha());
+  else if (GetY() < -GetX()*TMath::Tan(0.5*AliTOFGeometry::GetAlpha()))
+    Rotate(-AliTOFGeometry::GetAlpha());
+
+  return kTRUE;
+}
 //_________________________________________________________________________
 Double_t AliTOFtrack::GetYat(Double_t xk, Bool_t & skip) const {     
 //-----------------------------------------------------------------
@@ -191,27 +326,20 @@ Int_t AliTOFtrack::Compare(const TObject *o) const {
   return 0;
 }
 
-Double_t AliTOFtrack::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);
-}
 
 //_____________________________________________________________________________
-void AliTOFtrack::GetPropagationParameters(Bool_t holes, Double_t *param) {
+void AliTOFtrack::GetPropagationParameters(Double_t *param) {
 
  //Get average medium density, x0 while propagating the track
 
   //For TRD holes description
-
+  /*
   Double_t thetamin = (90.-31.1) * TMath::Pi()/180.;
   Double_t thetamax = (90.+31.1) * TMath::Pi()/180.;
 
   Double_t zmin = -55.;
   Double_t zmax =  55.;
+  */
 
   // Detector inner/outer radii
   Double_t rTPC    = 261.53;
@@ -228,10 +356,11 @@ void AliTOFtrack::GetPropagationParameters(Bool_t holes, Double_t *param) {
   Double_t x0TRD = 171.7;
   Double_t rhoTRD =0.33;
 
-  Int_t isec = GetSector();
+  //  Int_t isec = GetSector();
   Double_t r[3]; GetXYZ(r);
-  Float_t thetatr = TMath::ATan2(TMath::Sqrt(r[0]*r[0]+r[1]*r[1]),r[2]);
+  //  Float_t thetatr = TMath::ATan2(TMath::Sqrt(r[0]*r[0]+r[1]*r[1]),r[2]);
 
+  /*
   if(holes){
     if (isec == 0 || isec == 1 || isec == 2 ) {
       if( thetatr>=thetamin && thetatr<=thetamax){ 
@@ -246,7 +375,7 @@ void AliTOFtrack::GetPropagationParameters(Bool_t holes, Double_t *param) {
       }
     }
   }
-
+  */
   if(GetX() <= rTPC)
     {param[0]=x0TPC;param[1]=rhoTPC;}
   else if(GetX() > rTPC &&  GetX() < rTPCTRD)