]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITStrackV2.cxx
Return the most probable momentum if the magnetic field is too weak and the momentum...
[u/mrichter/AliRoot.git] / ITS / AliITStrackV2.cxx
index 64d4b66c2943b6d6092a1116b9a66763d508ddfa..60834d30969a9ff5fecc2df77163e79ee2bfa672 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-//-------------------------------------------------------------------------
+///////////////////////////////////////////////////////////////////////////
 //                Implementation of the ITS track class
 //
 //          Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
 //     dEdx analysis by: Boris Batyunya, JINR, Boris.Batiounia@cern.ch
-//-------------------------------------------------------------------------
+///////////////////////////////////////////////////////////////////////////
 #include <TMath.h>
 
 #include "AliCluster.h"
 #include "AliESDtrack.h"
 #include "AliITStrackV2.h"
+#include "AliStrLine.h"
 
 ClassImp(AliITStrackV2)
 
@@ -56,7 +57,7 @@ AliITStrackV2::AliITStrackV2():AliKalmanTrack(),
   fC44(0),
   fESDtrack(0)
 {
-    for(Int_t i=0; i<kMaxLayer; i++) fIndex[i]=0;
+    for(Int_t i=0; i<2*kMaxLayer; i++) fIndex[i]=-1;
     for(Int_t i=0; i<4; i++) fdEdxSample[i]=0;
 }
 
@@ -81,13 +82,13 @@ AliKalmanTrack() {
 
   //Conversion of the track parameters
   Double_t x,p[5]; 
-  if (c) t.GetConstrainedExternalParameters(x,p);
+  if (c) t.GetConstrainedExternalParameters(fAlpha,x,p);
   else t.GetExternalParameters(x,p);
-  fX=x;    x=GetConvConst();
+  fX=x;   
   fP0=p[0]; 
-  fP1=p[1]; 
+  fP1=p[1];   SaveLocalConvConst(); 
   fP2=p[2];
-  fP3=p[3];
+  fP3=p[3];   x=GetLocalConvConst();
   fP4=p[4]/x; 
 
   //Conversion of the covariance matrix
@@ -107,15 +108,13 @@ AliKalmanTrack() {
   }
   fESDtrack=&t;
 
-  if (!Invariant()) throw "AliITStrackV2: conversion failed !\n";
+  //  if (!Invariant()) throw "AliITStrackV2: conversion failed !\n";
+  for(Int_t i=0; i<4; i++) fdEdxSample[i]=0;
 }
 
 void AliITStrackV2::UpdateESDtrack(ULong_t flags) const {
   fESDtrack->UpdateTrackParams(this,flags);
 }
-void AliITStrackV2::SetConstrainedESDtrack(Double_t chi2) const {
-  fESDtrack->SetConstrainedTrackParams(this,chi2);
-}
 
 //____________________________________________________________________________
 AliITStrackV2::AliITStrackV2(const AliITStrackV2& t) : AliKalmanTrack(t) {
@@ -134,11 +133,10 @@ AliITStrackV2::AliITStrackV2(const AliITStrackV2& t) : AliKalmanTrack(t) {
   fC30=t.fC30;  fC31=t.fC31;  fC32=t.fC32;  fC33=t.fC33;
   fC40=t.fC40;  fC41=t.fC41;  fC42=t.fC42;  fC43=t.fC43;  fC44=t.fC44;
 
-  Int_t n=GetNumberOfClusters();
-  for (Int_t i=0; i<n; i++) {
-    fIndex[i]=t.fIndex[i];
-    if (i<4) fdEdxSample[i]=t.fdEdxSample[i];
-  }
+  Int_t i;
+  for (i=0; i<2*kMaxLayer; i++) fIndex[i]=t.fIndex[i];
+  for (i=0; i<4; i++) fdEdxSample[i]=t.fdEdxSample[i];
+
   fESDtrack=t.fESDtrack;
 }
 
@@ -163,7 +161,7 @@ void AliITStrackV2::GetExternalCovariance(Double_t cc[15]) const {
   // This function returns an external representation of the covriance matrix.
   //   (See comments in AliTPCtrack.h about external track representation)
   //-------------------------------------------------------------------------
-  Double_t a=GetConvConst();
+  Double_t a=GetLocalConvConst();
 
   cc[0 ]=fC00;
   cc[1 ]=fC10;   cc[2 ]=fC11;
@@ -212,6 +210,24 @@ GetGlobalXYZat(Double_t xk, Double_t &x, Double_t &y, Double_t &z) const {
   return 1;
 }
 
+//_____________________________________________________________________________
+void AliITStrackV2::ApproximateHelixWithLine(Double_t xk, AliStrLine *line)
+{
+  //------------------------------------------------------------
+  // Approximate the track (helix) with a straight line tangent to the
+  // helix in the point defined by r (F. Prino, prino@to.infn.it)
+  //------------------------------------------------------------
+  Double_t mom[3];
+  Double_t azim = TMath::ASin(fP2)+fAlpha;
+  Double_t theta = TMath::Pi()/2. - TMath::ATan(fP3);
+  mom[0] = TMath::Sin(theta)*TMath::Cos(azim);
+  mom[1] = TMath::Sin(theta)*TMath::Sin(azim);
+  mom[2] = TMath::Cos(theta);
+  Double_t pos[3];
+  GetGlobalXYZat(xk,pos[0],pos[1],pos[2]);
+  line->SetP0(pos);
+  line->SetCd(mom);
+}
 //_____________________________________________________________________________
 Double_t AliITStrackV2::GetPredictedChi2(const AliCluster *c) const 
 {
@@ -276,12 +292,15 @@ Int_t AliITStrackV2::PropagateTo(Double_t xk, Double_t d, Double_t x0) {
   //------------------------------------------------------------------
   Double_t x1=fX, x2=xk, dx=x2-x1;
   Double_t f1=fP2, f2=f1 + fP4*dx;
-  if (TMath::Abs(f2) >= 0.9999) {
-    Int_t n=GetNumberOfClusters();
-    if (n>kWARN) 
-       Warning("PropagateTo","Propagation failed !\n",n);
+  if (TMath::Abs(f2) >= 0.98) {
+    // MI change  - don't propagate highly inclined tracks
+    //              covariance matrix distorted
+    //Int_t n=GetNumberOfClusters();
+    //if (n>kWARN) 
+    //   Warning("PropagateTo","Propagation failed !\n",n);
     return 0;
   }
+  Double_t lcc=GetLocalConvConst();  
 
   // old position [SR, GSI, 17.02.2003]
   Double_t oldX = fX, oldY = fP0, oldZ = fP1;
@@ -334,6 +353,10 @@ Int_t AliITStrackV2::PropagateTo(Double_t xk, Double_t d, Double_t x0) {
 
   fX=x2;
 
+  //Change of the magnetic field *************
+  SaveLocalConvConst();
+  fP4*=lcc/GetLocalConvConst();
+
   if (!CorrectForMaterial(d,x0)) return 0;
 
   // Integrated Time [SR, GSI, 17.02.2003]
@@ -502,19 +525,28 @@ Int_t AliITStrackV2::Propagate(Double_t alp,Double_t xk) {
   {
   Double_t dx=xk-fX;
   Double_t f1=fP2, f2=f1 + fP4*dx;
-  if (TMath::Abs(f2) >= 0.9999) {
-    Int_t n=GetNumberOfClusters();
-    if (n>kWARN) 
-       Warning("Propagate","Propagation failed (%d) !\n",n);
+  if (TMath::Abs(f2) >= 0.98) {
+    // don't propagate highly inclined tracks MI
     return 0;
   }
+  //    Int_t n=GetNumberOfClusters();
+  //  if (n>kWARN) 
+  //     Warning("Propagate","Propagation failed (%d) !\n",n);
+  //  return 0;
+  //}
+  Double_t lcc=GetLocalConvConst();  
+
   Double_t r1=TMath::Sqrt(1.- f1*f1), r2=TMath::Sqrt(1.- f2*f2);
-  
+
   fX=xk;
   fP0 += dx*(f1+f2)/(r1+r2);
   fP1 += dx*(f1+f2)/(f1*r2 + f2*r1)*fP3;
   fP2 += dx*fP4;
 
+  //Change of the magnetic field *************
+  SaveLocalConvConst();
+  fP4*=lcc/GetLocalConvConst();
+
   //f = F - 1
   
   Double_t f02=    dx/(r1*r1*r1);
@@ -701,3 +733,40 @@ void AliITStrackV2::CookdEdx(Double_t low, Double_t up) {
 
   SetdEdx(dedx);
 }
+
+Double_t AliITStrackV2::
+PropagateToDCA(AliKalmanTrack *p, Double_t d, Double_t x0) {
+  //--------------------------------------------------------------
+  // Propagates this track and the argument track to the position of the
+  // distance of closest approach. 
+  // Returns the (weighed !) distance of closest approach.
+  //--------------------------------------------------------------
+  Double_t xthis, xp, dca;
+  {
+  //Temporary solution
+  Double_t b=1./GetLocalConvConst()/kB2C;
+  AliExternalTrackParam dummy1(*this), dummy2(*p); 
+  dca=dummy1.GetDCA(&dummy2,b,xthis,xp);
+  }
+  if (!PropagateTo(xthis,d,x0)) {
+    //AliWarning(" propagation failed !");
+    return 1e+33;
+  }  
+
+  if (!p->PropagateTo(xp,d,x0)) {
+    //AliWarning(" propagation failed !";
+    return 1e+33;
+  }  
+
+  return dca;
+} 
+
+Double_t AliITStrackV2::Get1Pt() const {
+  //--------------------------------------------------------------
+  // Returns the inverse Pt (1/GeV/c)
+  // (or 1/"most probable pt", if the field is too weak)
+  //--------------------------------------------------------------
+  if (TMath::Abs(GetLocalConvConst()) > kVeryBigConvConst)
+      return 1./kMostProbableMomentum/TMath::Sqrt(1.+ GetTgl()*GetTgl());
+  return (TMath::Sign(1e-9,fP4) + fP4)*GetLocalConvConst();
+}