1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //-----------------------------------------------------------------
19 // Implementation of the TPC track class
20 // This class is used by the AliTPCtracker class
21 // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
22 //-----------------------------------------------------------------
24 #include <Riostream.h>
26 #include "AliTPCtrack.h"
27 #include "AliCluster.h"
28 #include "AliTracker.h"
29 #include "AliESDtrack.h"
33 //_________________________________________________________________________
34 AliTPCtrack::AliTPCtrack():
48 //-------------------------------------------------
49 // default constructor
50 //-------------------------------------------------
51 for (Int_t i=0; i<kMaxRow;i++) fIndex[i]=-2;
52 for (Int_t i=0; i<4;i++) fPoints[i]=0.;
53 for (Int_t i=0; i<12;i++) fKinkPoint[i]=0.;
54 for (Int_t i=0; i<3;i++) fKinkIndexes[i]=0;
55 for (Int_t i=0; i<3;i++) fV0Indexes[i]=0;
58 //_________________________________________________________________________
62 AliTPCtrack::AliTPCtrack(Double_t x, Double_t alpha, const Double_t p[5],
63 const Double_t cov[15], Int_t index) :
77 //-----------------------------------------------------------------
78 // This is the main track constructor.
79 //-----------------------------------------------------------------
80 Double_t cnv=1./(AliTracker::GetBz()*kB2C);
90 Double_t c22 = x*x*cov[14] - 2*x*cov[12] + cov[5];
91 Double_t c32 = x*cov[13] - cov[8];
92 Double_t c20 = x*cov[10] - cov[3],
93 c21 = x*cov[11] - cov[4], c42 = x*cov[14] - cov[12];
99 cov[6 ], cov[7 ], c32, cov[9 ],
100 cov[10]*cnv, cov[11]*cnv, c42*cnv, cov[13]*cnv, cov[14]*cnv*cnv
103 Double_t mostProbablePt=AliExternalTrackParam::GetMostProbablePt();
104 Double_t p0=TMath::Sign(1/mostProbablePt,pp[4]);
105 Double_t w0=cc[14]/(cc[14] + p0*p0), w1=p0*p0/(cc[14] + p0*p0);
106 pp[4] = w0*p0 + w1*pp[4];
107 cc[10]*=w1; cc[11]*=w1; cc[12]*=w1; cc[13]*=w1; cc[14]*=w1;
111 SetNumberOfClusters(1);
114 for (Int_t i=1; i<kMaxRow;i++) fIndex[i]=-2;
115 for (Int_t i=0; i<4;i++) fPoints[i]=0.;
116 for (Int_t i=0; i<12;i++) fKinkPoint[i]=0.;
117 for (Int_t i=0; i<3;i++) fKinkIndexes[i]=0;
118 for (Int_t i=0; i<3;i++) fV0Indexes[i]=0;
121 //_____________________________________________________________________________
122 AliTPCtrack::AliTPCtrack(const AliESDtrack& t) :
124 fdEdx(t.GetTPCsignal()),
136 //-----------------------------------------------------------------
137 // Conversion AliESDtrack -> AliTPCtrack.
138 //-----------------------------------------------------------------
139 SetNumberOfClusters(t.GetTPCclusters(fIndex));
140 SetLabel(t.GetLabel());
141 SetMass(t.GetMass());
142 for (Int_t i=0; i<4;i++) fPoints[i]=0.;
143 for (Int_t i=0; i<12;i++) fKinkPoint[i]=0.;
144 for (Int_t i=0; i<3;i++) fKinkIndexes[i]=0;
145 for (Int_t i=0; i<3;i++) fV0Indexes[i]=0;
147 Set(t.GetX(),t.GetAlpha(),t.GetParameter(),t.GetCovariance());
149 if ((t.GetStatus()&AliESDtrack::kTIME) == 0) return;
151 Double_t times[10]; t.GetIntegratedTimes(times); SetIntegratedTimes(times);
152 SetIntegratedLength(t.GetIntegratedLength());
155 //_____________________________________________________________________________
156 AliTPCtrack::AliTPCtrack(const AliTPCtrack& t) :
160 fNFoundable(t.fNFoundable),
161 fBConstrain(t.fBConstrain),
162 fLastPoint(t.fLastPoint),
163 fFirstPoint(t.fFirstPoint),
164 fRemoval(t.fRemoval),
165 fTrackType(t.fTrackType),
167 fNShared(t.fNShared),
168 fReference(t.fReference)
171 //-----------------------------------------------------------------
172 // This is a track copy constructor.
173 //-----------------------------------------------------------------
174 Set(t.GetX(),t.GetAlpha(),t.GetParameter(),t.GetCovariance());
176 for (Int_t i=0; i<kMaxRow; i++) fIndex[i]=t.fIndex[i];
177 for (Int_t i=0; i<4;i++) fPoints[i]=t.fPoints[i];
178 for (Int_t i=0; i<12;i++) fKinkPoint[i]=t.fKinkPoint[i];
179 for (Int_t i=0; i<3;i++) fKinkIndexes[i]=t.fKinkIndexes[i];
180 for (Int_t i=0; i<3;i++) fV0Indexes[i]=t.fV0Indexes[i];
183 //_____________________________________________________________________________
184 Int_t AliTPCtrack::Compare(const TObject *o) const {
185 //-----------------------------------------------------------------
186 // This function compares tracks according to the their curvature
187 //-----------------------------------------------------------------
188 AliTPCtrack *t=(AliTPCtrack*)o;
189 //Double_t co=TMath::Abs(t->Get1Pt());
190 //Double_t c =TMath::Abs(Get1Pt());
191 Double_t co=t->GetSigmaY2()*t->GetSigmaZ2();
192 Double_t c =GetSigmaY2()*GetSigmaZ2();
194 else if (c<co) return -1;
198 Double_t AliTPCtrack::GetPredictedChi2(const AliCluster *c) const {
199 //-----------------------------------------------------------------
200 // This function calculates a predicted chi2 increment.
201 //-----------------------------------------------------------------
202 Double_t p[2]={c->GetY(), c->GetZ()};
203 Double_t cov[3]={c->GetSigmaY2(), 0., c->GetSigmaZ2()};
204 return AliExternalTrackParam::GetPredictedChi2(p,cov);
207 //_____________________________________________________________________________
208 Bool_t AliTPCtrack::PropagateTo(Double_t xk,Double_t rho,Double_t x0) {
209 //-----------------------------------------------------------------
210 // This function propagates a track to a reference plane x=xk.
211 // rho - density of the crossed matrial (g/cm^3)
212 // x0 - radiation length of the crossed material (g/cm^2)
213 //-----------------------------------------------------------------
214 Double_t oldX=GetX(), oldY=GetY(), oldZ=GetZ();
217 if (!AliExternalTrackParam::PropagateTo(xk,bz)) return kFALSE;
219 Double_t d = TMath::Sqrt((GetX()-oldX)*(GetX()-oldX) +
220 (GetY()-oldY)*(GetY()-oldY) +
221 (GetZ()-oldZ)*(GetZ()-oldZ));
222 if (IsStartedTimeIntegral() && GetX()>oldX) AddTimeStep(d);
224 if (oldX < xk) d = -d;
225 if (!AliExternalTrackParam::CorrectForMaterial(d*rho/x0,x0,GetMass()))
231 //_____________________________________________________________________________
233 AliTPCtrack::PropagateToVertex(const AliESDVertex *v,Double_t d,Double_t x0)
235 //-----------------------------------------------------------------
236 // This function propagates tracks to the vertex.
237 //-----------------------------------------------------------------
239 if (PropagateToDCA(v,bz,kVeryBig))
240 if (AliExternalTrackParam::CorrectForMaterial(d,x0,GetMass())) return kTRUE;
244 //_____________________________________________________________________________
245 Bool_t AliTPCtrack::Update(const AliCluster *c, Double_t chisq, Int_t index) {
246 //-----------------------------------------------------------------
247 // This function associates a cluster with this track.
248 //-----------------------------------------------------------------
249 Double_t p[2]={c->GetY(), c->GetZ()};
250 Double_t cov[3]={c->GetSigmaY2(), 0., c->GetSigmaZ2()};
252 if (!AliExternalTrackParam::Update(p,cov)) return kFALSE;
254 Int_t n=GetNumberOfClusters();
256 SetNumberOfClusters(n+1);
257 SetChi2(GetChi2()+chisq);
262 ////////////////////////////////////////////////////////////////////////
265 Float_t AliTPCtrack::Density(Int_t row0, Int_t row1)
268 // calculate cluster density
271 //if (row0<fFirstPoint) row0 = fFirstPoint;
272 if (row1>fLastPoint) row1 = fLastPoint;
275 for (Int_t i=row0;i<=row1;i++){
276 // Int_t index = fClusterIndex[i];
277 Int_t index = fIndex[i];
278 if (index!=-1) good++;
279 if (index>0) found++;
282 if (good>0) density = Float_t(found)/Float_t(good);
287 Float_t AliTPCtrack::Density2(Int_t row0, Int_t row1)
290 // calculate cluster density
294 for (Int_t i=row0;i<=row1;i++){
295 Int_t index = fIndex[i];
296 if (index!=-1) good++;
297 if (index>0) found++;
300 if (good>0) density = Float_t(found)/Float_t(good);
304 void AliTPCtrack::UpdatePoints()
306 //--------------------------------------------------
307 //calculates first ,amx dens and last points
308 //--------------------------------------------------
309 Float_t density[160];
310 for (Int_t i=0;i<160;i++) density[i]=-1.;
318 for (Int_t i=0;i<160;i++){
319 Int_t last = i-range;
320 if (nall<range) nall++;
322 if (fIndex[last]>0&& (fIndex[last]&0x8000)==0) ngood--;
323 if (fIndex[last]==-1) undeff--;
325 if (fIndex[i]>0&& (fIndex[i]&0x8000)==0) ngood++;
326 if (fIndex[i]==-1) undeff++;
327 if (nall==range &&undeff<range/2) density[i-range/2] = Float_t(ngood)/Float_t(nall-undeff);
331 for (Int_t i=0;i<160;i++){
332 if (density[i]<0) continue;
333 if (density[i]>maxdens){
340 fPoints[3] = maxdens;
341 fPoints[1] = indexmax;
344 for (Int_t i=indexmax;i<160;i++){
345 if (density[i]<0) continue;
346 if (density[i]<maxdens/2.) {
353 for (Int_t i=indexmax;i>0;i--){
354 if (density[i]<0) continue;
355 if (density[i]<maxdens/2.) {
363 Double_t AliTPCtrack::GetBz() const {
365 // returns Bz component of the magnetic field (kG)
367 if (AliTracker::UniformField()) return AliTracker::GetBz();
368 Double_t r[3]; GetXYZ(r);
369 return AliTracker::GetBz(r);