]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCtrack.cxx
Vertexing with tracks included (Andrea)
[u/mrichter/AliRoot.git] / TPC / AliTPCtrack.cxx
index 63340efff0c86d89ccd93faa22e75b4fa7308a04..d6733b39e26e7f795ec30237d19028935e322937 100644 (file)
 
 #include "AliTPCtrack.h"
 #include "AliCluster.h"
-#include "AliBarrelTrack.h"
 #include "AliESDtrack.h"
+#include "AliTPCReconstructor.h"
 
 ClassImp(AliTPCtrack)
 
 //_________________________________________________________________________
-AliTPCtrack::AliTPCtrack(): AliKalmanTrack() 
+AliTPCtrack::AliTPCtrack(): 
+  AliKalmanTrack(),
+  fX(0),
+  fAlpha(0),
+  fdEdx(0),
+  fP0(0),
+  fP1(0),
+  fP2(0),
+  fP3(0),
+  fP4(0),
+  fC00(1e10),
+  fC10(0),
+  fC11(1e10),
+  fC20(0),
+  fC21(0),
+  fC22(1e10),
+  fC30(0),
+  fC31(0),
+  fC32(0),
+  fC33(1e10),
+  fC40(0),
+  fC41(0),
+  fC42(0),
+  fC43(0),
+  fC44(0),
+  fNumber(0),
+  fSdEdx(1e10),
+  fNFoundable(0),
+  fBConstrain(kFALSE),
+  fLastPoint(-1),
+  fFirstPoint(-1),
+  fRemoval(0),
+  fTrackType(0),
+  fLab2(-1),
+  fNShared(0),
+  fReference()
 {
-  fX = fP0 = fP1 = fP2 = fP3 = fP3 = fP4 = 0.0;
-  fAlpha = fdEdx = 0.0;
-  fNWrong = fNRotation = fNumber = 0;  // [SR, 01.04.2003]
+  //-------------------------------------------------
+  // default constructor
+  //-------------------------------------------------
+  for (Int_t i=0; i<kMaxRow;i++) fIndex[i]=-2;
+  for (Int_t i=0; i<4;i++) fPoints[i]=0.;
+  for (Int_t i=0; i<12;i++) fKinkPoint[i]=0.;
+  for (Int_t i=0; i<3;i++) fKinkIndexes[i]=0;
+  for (Int_t i=0; i<3;i++) fV0Indexes[i]=0;
 }
 
 //_________________________________________________________________________
+
+
+
 AliTPCtrack::AliTPCtrack(UInt_t index, const Double_t xx[5],
-const Double_t cc[15], Double_t xref, Double_t alpha) : AliKalmanTrack() {
+const Double_t cc[15], Double_t xref, Double_t alpha) :
+  AliKalmanTrack(),
+  fX(xref),
+  fdEdx(0),
+  fP0(xx[0]),
+  fP1(xx[1]),
+  fP2(xx[2]),
+  fP3(xx[3]),
+  fP4(xx[4]),
+  fC00(cc[0]),
+  fC10(cc[1]),
+  fC11(cc[2]),
+  fC20(cc[3]),
+  fC21(cc[4]),
+  fC22(cc[5]),
+  fC30(cc[6]),
+  fC31(cc[7]),
+  fC32(cc[8]),
+  fC33(cc[9]),
+  fC40(cc[10]),
+  fC41(cc[11]),
+  fC42(cc[12]),
+  fC43(cc[13]),
+  fC44(cc[14]),
+  fNumber(1),
+  fSdEdx(1e10),
+  fNFoundable(0),
+  fBConstrain(kFALSE),
+  fLastPoint(0),
+  fFirstPoint(0),
+  fRemoval(0),
+  fTrackType(0),
+  fLab2(0),
+  fNShared(0),
+  fReference()
+{
   //-----------------------------------------------------------------
   // This is the main track constructor.
   //-----------------------------------------------------------------
-  fX=xref;
   fAlpha=alpha;
   if (fAlpha<-TMath::Pi()) fAlpha += 2*TMath::Pi();
   if (fAlpha>=TMath::Pi()) fAlpha -= 2*TMath::Pi();
-  fdEdx=0.;
-
-  fP0=xx[0]; fP1=xx[1]; fP2=xx[2]; fP3=xx[3]; fP4=xx[4];
 
-  fC00=cc[0];
-  fC10=cc[1];  fC11=cc[2];
-  fC20=cc[3];  fC21=cc[4];  fC22=cc[5];
-  fC30=cc[6];  fC31=cc[7];  fC32=cc[8];  fC33=cc[9];
-  fC40=cc[10]; fC41=cc[11]; fC42=cc[12]; fC43=cc[13]; fC44=cc[14];
+  SaveLocalConvConst();
 
-  fIndex[0]=index;
   SetNumberOfClusters(1);
-  //
-  //MI
-  fSdEdx      = 0;
-  fNFoundable = 0;
-  fBConstrain = 0;
-  fLastPoint  = 0;
-  fFirstPoint = 0;
-  fRemoval    = 0;
-  fTrackType  = 0;
-  fLab2       = 0;
-}
-
-//_____________________________________________________________________________
-AliTPCtrack::AliTPCtrack(const AliKalmanTrack& t,Double_t alpha) :
-AliKalmanTrack(t) {
-  //-----------------------------------------------------------------
-  // Conversion AliKalmanTrack -> AliTPCtrack.
-  //-----------------------------------------------------------------
-  SetChi2(0.);
-  SetNumberOfClusters(0);
-
-  fdEdx  = 0.;
-  fAlpha = alpha;
-  if      (fAlpha < -TMath::Pi()) fAlpha += 2*TMath::Pi();
-  else if (fAlpha >= TMath::Pi()) fAlpha -= 2*TMath::Pi();
-
-  //Conversion of the track parameters
-  Double_t x,p[5]; t.GetExternalParameters(x,p);
-  fX=x;    x=GetConvConst();
-  fP0=p[0]; 
-  fP1=p[1]; 
-  fP3=p[3];
-  fP4=p[4]/x; 
-  fP2=fP4*fX - p[2];
-
-  //Conversion of the covariance matrix
-  Double_t c[15]; t.GetExternalCovariance(c);
-  c[10]/=x; c[11]/=x; c[12]/=x; c[13]/=x; c[14]/=x*x;
-
-  Double_t c22=fX*fX*c[14] - 2*fX*c[12] + c[5];
-  Double_t c32=fX*c[13] - c[8];
-  Double_t c20=fX*c[10] - c[3], c21=fX*c[11] - c[4], c42=fX*c[14] - c[12];
   
-  fC00=c[0 ];
-  fC10=c[1 ];   fC11=c[2 ];
-  fC20=c20;     fC21=c21;     fC22=c22;
-  fC30=c[6 ];   fC31=c[7 ];   fC32=c32;   fC33=c[9 ];
-  fC40=c[10];   fC41=c[11];   fC42=c42;   fC43=c[13]; fC44=c[14];
-  //
-  //MI
-  fSdEdx      = 0;
-  fNFoundable = 0;
-  fBConstrain = 0;
-  fLastPoint  = 0;
-  fFirstPoint = 0;
-  fRemoval    = 0;
-  fTrackType  = 0;
-  fLab2       = 0;
+  fIndex[0]=index;
+  for (Int_t i=1; i<kMaxRow;i++) fIndex[i]=-2;
+  for (Int_t i=0; i<4;i++) fPoints[i]=0.;
+  for (Int_t i=0; i<12;i++) fKinkPoint[i]=0.;
+  for (Int_t i=0; i<3;i++) fKinkIndexes[i]=0;
+  for (Int_t i=0; i<3;i++) fV0Indexes[i]=0;
 }
 
 //_____________________________________________________________________________
-AliTPCtrack::AliTPCtrack(const AliESDtrack& t) : AliKalmanTrack() {
+AliTPCtrack::AliTPCtrack(const AliESDtrack& t) :
+  AliKalmanTrack(),
+  fSdEdx(1e10),
+  fNFoundable(0),
+  fBConstrain(kFALSE),
+  fLastPoint(0),
+  fFirstPoint(0),
+  fRemoval(0),
+  fTrackType(0),
+  fLab2(0),
+  fNShared(0),
+  fReference()
+{
   //-----------------------------------------------------------------
   // Conversion AliESDtrack -> AliTPCtrack.
   //-----------------------------------------------------------------
   SetNumberOfClusters(t.GetTPCclusters(fIndex));
   SetLabel(t.GetLabel());
   SetMass(t.GetMass());
+  for (Int_t i=0; i<4;i++) fPoints[i]=0.;
+  for (Int_t i=0; i<12;i++) fKinkPoint[i]=0.;
+  for (Int_t i=0; i<3;i++) fKinkIndexes[i]=0;
+  for (Int_t i=0; i<3;i++) fV0Indexes[i]=0;
 
   fdEdx  = t.GetTPCsignal();
   fAlpha = t.GetAlpha();
@@ -136,15 +170,16 @@ AliTPCtrack::AliTPCtrack(const AliESDtrack& t) : AliKalmanTrack() {
 
   //Conversion of the track parameters
   Double_t x,p[5]; t.GetExternalParameters(x,p);
-  fX=x;    x=GetConvConst();
+  Double_t c[15]; t.GetExternalCovariance(c);
+
+  fX=x;    
   fP0=p[0];
-  fP1=p[1];
-  fP3=p[3];
+  fP1=p[1];    SaveLocalConvConst();
+  fP3=p[3];    x=GetLocalConvConst();
   fP4=p[4]/x;
   fP2=fP4*fX - p[2];
 
   //Conversion of the covariance matrix
-  Double_t c[15]; t.GetExternalCovariance(c);
   c[10]/=x; c[11]/=x; c[12]/=x; c[13]/=x; c[14]/=x*x;
 
   Double_t c22=fX*fX*c[14] - 2*fX*c[12] + c[5];
@@ -161,82 +196,57 @@ AliTPCtrack::AliTPCtrack(const AliESDtrack& t) : AliKalmanTrack() {
   StartTimeIntegral();
   Double_t times[10]; t.GetIntegratedTimes(times); SetIntegratedTimes(times);
   SetIntegratedLength(t.GetIntegratedLength());
-  //
-  //MI
-  fSdEdx      = 0;
-  fNFoundable = 0;
-  fBConstrain = 0;
-  fLastPoint  = 0;
-  fFirstPoint = 0;
-  fRemoval    = 0;
-  fTrackType  = 0;
-  fLab2       = 0;
 }
 
 //_____________________________________________________________________________
-AliTPCtrack::AliTPCtrack(const AliTPCtrack& t) : AliKalmanTrack(t) {
+AliTPCtrack::AliTPCtrack(const AliTPCtrack& t) :
+  AliKalmanTrack(t),
+  fX(t.fX),
+  fAlpha(t.fAlpha),
+  fdEdx(t.fdEdx),
+  fP0(t.fP0),
+  fP1(t.fP1),
+  fP2(t.fP2),
+  fP3(t.fP3),
+  fP4(t.fP4),
+  fC00(t.fC00),
+  fC10(t.fC10),
+  fC11(t.fC11),
+  fC20(t.fC20),
+  fC21(t.fC21),
+  fC22(t.fC22),
+  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),
+  fNumber(t.fNumber),
+  fSdEdx(t.fSdEdx),
+  fNFoundable(t.fNFoundable),
+  fBConstrain(t.fBConstrain),
+  fLastPoint(t.fLastPoint),
+  fFirstPoint(t.fFirstPoint),
+  fRemoval(t.fRemoval),
+  fTrackType(t.fTrackType),
+  fLab2(t.fLab2),
+  fNShared(t.fNShared),
+  fReference(t.fReference)
+
+{
   //-----------------------------------------------------------------
   // This is a track copy constructor.
   //-----------------------------------------------------------------
-  fX=t.fX;
-  fAlpha=t.fAlpha;
-  fdEdx=t.fdEdx;
-
-  fP0=t.fP0; fP1=t.fP1; fP2=t.fP2; fP3=t.fP3; fP4=t.fP4;
-
-  fC00=t.fC00;
-  fC10=t.fC10;  fC11=t.fC11;
-  fC20=t.fC20;  fC21=t.fC21;  fC22=t.fC22;
-  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<kMaxRow; i++) fIndex[i]=t.fIndex[i];
-  //
-  //MI 
-  fSdEdx      = t.fSdEdx;
-  fNFoundable = t.fNFoundable;
-  fBConstrain = t.fBConstrain;
-  fLastPoint  = t.fLastPoint;
-  fFirstPoint = t.fFirstPoint;
-  fRemoval    = t.fRemoval ;
-  fTrackType  = t.fTrackType;
-  fLab2       = t.fLab2;
-
+  for (Int_t i=0; i<4;i++) fPoints[i]=t.fPoints[i];
+  for (Int_t i=0; i<12;i++) fKinkPoint[i]=t.fKinkPoint[i];
+  for (Int_t i=0; i<3;i++) fKinkIndexes[i]=t.fKinkIndexes[i];
+  for (Int_t i=0; i<3;i++) fV0Indexes[i]=t.fV0Indexes[i];
 }
-//_____________________________________________________________________________
-
-void  AliTPCtrack::GetBarrelTrack(AliBarrelTrack *track) {
-  //
-  // Create a Barrel Track out of this track
-  // Current track is propagated to the reference plane
-  // by the tracker
-  //
-  // [SR, 01.04.2003]
-  
-  if (!track) return;
-  Double_t xr, vec[5], cov[15];
-
-  track->SetLabel(GetLabel());
-  track->SetX(fX, fAlpha);
-  track->SetNClusters(GetNumberOfClusters(), GetChi2());
-  Double_t times[10];
-  GetIntegratedTimes(times);
-  track->SetTime(times, GetIntegratedLength());
 
-  track->SetMass(GetMass());
-  track->SetdEdX(GetdEdx());
-
-  track->SetNWrongClusters(fNWrong);
-  track->SetNRotate(fNRotation);
-
-  GetExternalParameters(xr, vec);
-  track->SetStateVector(vec);
-  
-  GetExternalCovariance(cov);
-  track->SetCovarianceMatrix(cov);
-
-}
 //_____________________________________________________________________________
 Int_t AliTPCtrack::Compare(const TObject *o) const {
   //-----------------------------------------------------------------
@@ -254,11 +264,11 @@ Int_t AliTPCtrack::Compare(const TObject *o) const {
 
 //_____________________________________________________________________________
 void AliTPCtrack::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();
 
   Double_t c22=fX*fX*fC44-2*fX*fC42+fC22;
   Double_t c32=fX*fC43-fC32;
@@ -298,8 +308,15 @@ Double_t AliTPCtrack::GetYat(Double_t xk) const {
 //-----------------------------------------------------------------
 // This function calculates the Y-coordinate of a track at the plane x=xk.
 //-----------------------------------------------------------------
+  if (TMath::Abs(fP4*fX - fP2)>AliTPCReconstructor::GetMaxSnpTrack()) return 0.; //patch 01 jan 06
     Double_t c1=fP4*fX - fP2, r1=TMath::Sqrt(1.- c1*c1);
-    Double_t c2=fP4*xk - fP2, r2=TMath::Sqrt(1.- c2*c2);
+    Double_t c2=fP4*xk - fP2;
+    if (c2*c2>AliTPCReconstructor::GetMaxSnpTrack()) {
+      //       Int_t n=GetNumberOfClusters();
+      // if (n>4) cerr<<n<<"AliTPCtrack::GetYat: can't evaluate the y-coord !\n";
+       return 0;
+    } 
+    Double_t r2=TMath::Sqrt(1.- c2*c2);
     return fP0 + (xk-fX)*(c1+c2)/(r1+r2);
 }
 
@@ -308,12 +325,13 @@ Int_t AliTPCtrack::PropagateTo(Double_t xk,Double_t /*x0*/,Double_t rho) {
   //-----------------------------------------------------------------
   // This function propagates a track to a reference plane x=xk.
   //-----------------------------------------------------------------
-  if (TMath::Abs(fP4*xk - fP2) >= 0.9) {
+  if (TMath::Abs(fP4*xk - fP2) >= AliTPCReconstructor::GetMaxSnpTrack()) {
     //    Int_t n=GetNumberOfClusters();
     //if (n>4) cerr<<n<<" AliTPCtrack warning: Propagation failed !\n";
     return 0;
   }
-  
+  Double_t lcc=GetLocalConvConst();  
+
   // old position for time [SR, GSI 17.02.2003]
   Double_t oldX = fX;
   Double_t oldY = fP0;
@@ -359,32 +377,60 @@ Int_t AliTPCtrack::PropagateTo(Double_t xk,Double_t /*x0*/,Double_t rho) {
 
   fX=x2;
 
-  //Multiple scattering******************
+  //Change of the magnetic field *************
+  SaveLocalConvConst();
+  cc=fP4;
+  fP4*=lcc/GetLocalConvConst();
+  fP2+=fX*(fP4-cc);
+
+  //Multiple scattering ******************
   Double_t d=sqrt((x1-fX)*(x1-fX)+(y1-fP0)*(y1-fP0)+(z1-fP1)*(z1-fP1));
   Double_t p2=(1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt());
   Double_t beta2=p2/(p2 + GetMass()*GetMass());
+  beta2 = TMath::Min(beta2,0.99999999999);
   //Double_t theta2=14.1*14.1/(beta2*p2*1e6)*d/x0*rho;
   Double_t theta2=1.0259e-6*10*10/20/(beta2*p2)*d*rho;
 
   Double_t ey=fP4*fX - fP2, ez=fP3;
   Double_t xz=fP4*ez, zz1=ez*ez+1, xy=fP2+ey;
-
+    
   fC22 += (2*ey*ez*ez*fP2+1-ey*ey+ez*ez+fP2*fP2*ez*ez)*theta2;
   fC32 += ez*zz1*xy*theta2;
   fC33 += zz1*zz1*theta2;
   fC42 += xz*ez*xy*theta2;
   fC43 += xz*zz1*theta2;
   fC44 += xz*xz*theta2;
-
-  //Energy losses************************
+  /*
+  //
+  //MI coeficients
+  Double_t dc22 = (1-ey*ey+xz*xz*fX*fX)*theta2;
+  Double_t dc32 = (xz*fX*zz1)*theta2;
+  Double_t dc33 = (zz1*zz1)*theta2;
+  Double_t dc42 = (xz*fX*xz)*theta2;
+  Double_t dc43 = (zz1*xz)*theta2;
+  Double_t dc44 = (xz*xz)*theta2; 
+  fC22 += dc22;
+  fC32 += dc32;
+  fC33 += dc33;
+  fC42 += dc42;
+  fC43 += dc43;
+  fC44 += dc44;
+  */
+  //Energy losses ************************
   Double_t dE=0.153e-3/beta2*(log(5940*beta2/(1-beta2)) - beta2)*d*rho;
   if (x1 < x2) dE=-dE;
   cc=fP4;
+
+  //Double_t E = sqrt(p2+GetMass()*GetMass());
+  //Double_t mifac  = TMath::Sqrt(1.+dE*dE/p2+2*E*dE/p2)-1;
+  //Double_t belfac = E*dE/p2;
+                              //
   fP4*=(1.- sqrt(p2+GetMass()*GetMass())/p2*dE);
   fP2+=fX*(fP4-cc);
 
   // Integrated Time [SR, GSI, 17.02.2003]
-  if (IsStartedTimeIntegral()) {
+ if (x1 < x2)
+ if (IsStartedTimeIntegral()) {
     Double_t l2 = (fX-oldX)*(fX-oldX)+(fP0-oldY)*(fP0-oldY)+(fP1-oldZ)*(fP1-oldZ);
     AddTimeStep(TMath::Sqrt(l2));
   }
@@ -411,14 +457,6 @@ Int_t AliTPCtrack::Update(const AliCluster *c, Double_t chisq, UInt_t index) {
   //-----------------------------------------------------------------
   // This function associates a cluster with this track.
   //-----------------------------------------------------------------
-
-  // update the number of wrong SR[20.03.2003]
-  Int_t absLabel = TMath::Abs(GetLabel());
-  if ( (c->GetLabel(0) != absLabel) && 
-       (c->GetLabel(0) != absLabel) &&
-       (c->GetLabel(0) != absLabel)) fNWrong++;
-  //
-
   Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
   r00+=fC00; r01+=fC10; r11+=fC11;
   Double_t det=r00*r11 - r01*r01;
@@ -432,7 +470,7 @@ Int_t AliTPCtrack::Update(const AliCluster *c, Double_t chisq, UInt_t index) {
 
   Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
   Double_t cur=fP4 + k40*dy + k41*dz, eta=fP2 + k20*dy + k21*dz;
-  if (TMath::Abs(cur*fX-eta) >= 0.9) {
+  if (TMath::Abs(cur*fX-eta) >= AliTPCReconstructor::GetMaxSnpTrack()) {
     //    Int_t n=GetNumberOfClusters();
     //if (n>4) cerr<<n<<" AliTPCtrack warning: Filtering failed !\n";
     return 0;
@@ -477,9 +515,6 @@ Int_t AliTPCtrack::Rotate(Double_t alpha)
   //-----------------------------------------------------------------
   // This function rotates this track.
   //-----------------------------------------------------------------
-
-  if (alpha != 0) fNRotation++;  // [SR, 01.04.2003]
-
   fAlpha += alpha;
   if (fAlpha<-TMath::Pi()) fAlpha += 2*TMath::Pi();
   if (fAlpha>=TMath::Pi()) fAlpha -= 2*TMath::Pi();
@@ -488,21 +523,23 @@ Int_t AliTPCtrack::Rotate(Double_t alpha)
   Double_t ca=cos(alpha), sa=sin(alpha);
   Double_t r1=fP4*fX - fP2;
   
+  if (TMath::Abs(r1)>=AliTPCReconstructor::GetMaxSnpTrack()) return 0; //patch 01 jan 06
+
   fX = x1*ca + y1*sa;
   fP0=-x1*sa + y1*ca;
   fP2=fP2*ca + (fP4*y1 + sqrt(1.- r1*r1))*sa;
   
   Double_t r2=fP4*fX - fP2;
-  if (TMath::Abs(r2) >= 0.99999) {
-    Int_t n=GetNumberOfClusters();
-    if (n>4) cerr<<n<<" AliTPCtrack warning: Rotation failed !\n";
+  if (TMath::Abs(r2) >= AliTPCReconstructor::GetMaxSnpTrack()) {
+    //Int_t n=GetNumberOfClusters();
+    //    if (n>4) cerr<<n<<" AliTPCtrack warning: Rotation failed !\n";
     return 0;
   }
   
   Double_t y0=fP0 + sqrt(1.- r2*r2)/fP4;
   if ((fP0-y0)*fP4 >= 0.) {
-    Int_t n=GetNumberOfClusters();
-    if (n>4) cerr<<n<<" AliTPCtrack warning: Rotation failed !!!\n";
+    //Int_t n=GetNumberOfClusters();
+    //    if (n>4) cerr<<n<<" AliTPCtrack warning: Rotation failed !!!\n";
     return 0;
   }
 
@@ -641,3 +678,75 @@ Double_t AliTPCtrack::GetD(Double_t x, Double_t y) const {
   delta -= TMath::Abs(r);
   return delta;  
 }
+
+//
+//
+
+void  AliTPCtrack::UpdatePoints()
+{
+  //--------------------------------------------------
+  //calculates first ,amx dens and last points
+  //--------------------------------------------------
+  Float_t density[160];
+  for (Int_t i=0;i<160;i++) density[i]=-1.;
+  fPoints[0]= 160;
+  fPoints[1] = -1;
+  //
+  Int_t ngood=0;
+  Int_t undeff=0;
+  Int_t nall =0;
+  Int_t range=20;
+  for (Int_t i=0;i<160;i++){
+    Int_t last = i-range;
+    if (nall<range) nall++;
+    if (last>=0){
+      if (fIndex[last]>0&& (fIndex[last]&0x8000)==0) ngood--;
+      if (fIndex[last]==-1) undeff--;
+    }
+    if (fIndex[i]>0&& (fIndex[i]&0x8000)==0)   ngood++;
+    if (fIndex[i]==-1) undeff++;
+    if (nall==range &&undeff<range/2) density[i-range/2] = Float_t(ngood)/Float_t(nall-undeff);
+  }
+  Float_t maxdens=0;
+  Int_t indexmax =0;
+  for (Int_t i=0;i<160;i++){
+    if (density[i]<0) continue;
+    if (density[i]>maxdens){
+      maxdens=density[i];
+      indexmax=i;
+    }
+  }
+  //
+  //max dens point
+  fPoints[3] = maxdens;
+  fPoints[1] = indexmax;
+  //
+  // last point
+  for (Int_t i=indexmax;i<160;i++){
+    if (density[i]<0) continue;
+    if (density[i]<maxdens/2.) {
+      break;
+    }
+    fPoints[2]=i;
+  }
+  //
+  // first point
+  for (Int_t i=indexmax;i>0;i--){
+    if (density[i]<0) continue;
+    if (density[i]<maxdens/2.) {
+      break;
+    }
+    fPoints[0]=i;
+  }
+  //
+}
+
+Double_t AliTPCtrack::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();
+}