Bug fixes in RefitInward (Yu.Belikov)
[u/mrichter/AliRoot.git] / TPC / AliTPCtrack.cxx
CommitLineData
73042f01 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
803d1ab0 16/* $Id$ */
0938c7d3 17
73042f01 18//-----------------------------------------------------------------
19// Implementation of the TPC track class
7c27857f 20// This class is used by the AliTPCtracker class
21// Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
73042f01 22//-----------------------------------------------------------------
23
19364939 24#include <Riostream.h>
b19a0509 25
73042f01 26#include "AliTPCtrack.h"
7c27857f 27#include "AliCluster.h"
9c9d2487 28#include "AliBarrelTrack.h"
83d73500 29#include "AliESDtrack.h"
73042f01 30
31ClassImp(AliTPCtrack)
b9de75e1 32
e3f7105e 33//_________________________________________________________________________
34AliTPCtrack::AliTPCtrack(): AliKalmanTrack()
35{
36 fX = fP0 = fP1 = fP2 = fP3 = fP3 = fP4 = 0.0;
37 fAlpha = fdEdx = 0.0;
9c9d2487 38 fNWrong = fNRotation = fNumber = 0; // [SR, 01.04.2003]
e3f7105e 39}
40
73042f01 41//_________________________________________________________________________
42AliTPCtrack::AliTPCtrack(UInt_t index, const Double_t xx[5],
b19a0509 43const Double_t cc[15], Double_t xref, Double_t alpha) : AliKalmanTrack() {
73042f01 44 //-----------------------------------------------------------------
45 // This is the main track constructor.
46 //-----------------------------------------------------------------
73042f01 47 fX=xref;
be9c5115 48 fAlpha=alpha;
49 if (fAlpha<-TMath::Pi()) fAlpha += 2*TMath::Pi();
50 if (fAlpha>=TMath::Pi()) fAlpha -= 2*TMath::Pi();
51 fdEdx=0.;
73042f01 52
b19a0509 53 fP0=xx[0]; fP1=xx[1]; fP2=xx[2]; fP3=xx[3]; fP4=xx[4];
73042f01 54
b19a0509 55 fC00=cc[0];
56 fC10=cc[1]; fC11=cc[2];
57 fC20=cc[3]; fC21=cc[4]; fC22=cc[5];
58 fC30=cc[6]; fC31=cc[7]; fC32=cc[8]; fC33=cc[9];
59 fC40=cc[10]; fC41=cc[11]; fC42=cc[12]; fC43=cc[13]; fC44=cc[14];
73042f01 60
be9c5115 61 fIndex[0]=index;
62 SetNumberOfClusters(1);
51584047 63 //
64 //MI
65 fSdEdx = 0;
66 fNFoundable = 0;
67 fBConstrain = 0;
68 fLastPoint = 0;
69 fFirstPoint = 0;
70 fRemoval = 0;
71 fTrackType = 0;
72 fLab2 = 0;
b9de75e1 73}
74
75//_____________________________________________________________________________
e1a65e92 76AliTPCtrack::AliTPCtrack(const AliKalmanTrack& t,Double_t alpha) :
77AliKalmanTrack(t) {
b9de75e1 78 //-----------------------------------------------------------------
79 // Conversion AliKalmanTrack -> AliTPCtrack.
80 //-----------------------------------------------------------------
b9de75e1 81 SetChi2(0.);
82 SetNumberOfClusters(0);
b9de75e1 83
84 fdEdx = 0.;
85 fAlpha = alpha;
86 if (fAlpha < -TMath::Pi()) fAlpha += 2*TMath::Pi();
87 else if (fAlpha >= TMath::Pi()) fAlpha -= 2*TMath::Pi();
88
89 //Conversion of the track parameters
90 Double_t x,p[5]; t.GetExternalParameters(x,p);
91 fX=x; x=GetConvConst();
92 fP0=p[0];
93 fP1=p[1];
94 fP3=p[3];
95 fP4=p[4]/x;
96 fP2=fP4*fX - p[2];
97
98 //Conversion of the covariance matrix
99 Double_t c[15]; t.GetExternalCovariance(c);
100 c[10]/=x; c[11]/=x; c[12]/=x; c[13]/=x; c[14]/=x*x;
101
102 Double_t c22=fX*fX*c[14] - 2*fX*c[12] + c[5];
103 Double_t c32=fX*c[13] - c[8];
104 Double_t c20=fX*c[10] - c[3], c21=fX*c[11] - c[4], c42=fX*c[14] - c[12];
105
106 fC00=c[0 ];
107 fC10=c[1 ]; fC11=c[2 ];
108 fC20=c20; fC21=c21; fC22=c22;
109 fC30=c[6 ]; fC31=c[7 ]; fC32=c32; fC33=c[9 ];
110 fC40=c[10]; fC41=c[11]; fC42=c42; fC43=c[13]; fC44=c[14];
51584047 111 //
112 //MI
113 fSdEdx = 0;
114 fNFoundable = 0;
115 fBConstrain = 0;
116 fLastPoint = 0;
117 fFirstPoint = 0;
118 fRemoval = 0;
119 fTrackType = 0;
120 fLab2 = 0;
73042f01 121}
122
83d73500 123//_____________________________________________________________________________
124AliTPCtrack::AliTPCtrack(const AliESDtrack& t) : AliKalmanTrack() {
125 //-----------------------------------------------------------------
126 // Conversion AliESDtrack -> AliTPCtrack.
127 //-----------------------------------------------------------------
128 SetNumberOfClusters(t.GetTPCclusters(fIndex));
129 SetLabel(t.GetLabel());
130 SetMass(t.GetMass());
131
132 fdEdx = t.GetTPCsignal();
133 fAlpha = t.GetAlpha();
134 if (fAlpha < -TMath::Pi()) fAlpha += 2*TMath::Pi();
135 else if (fAlpha >= TMath::Pi()) fAlpha -= 2*TMath::Pi();
136
137 //Conversion of the track parameters
138 Double_t x,p[5]; t.GetExternalParameters(x,p);
139 fX=x; x=GetConvConst();
140 fP0=p[0];
141 fP1=p[1];
142 fP3=p[3];
143 fP4=p[4]/x;
144 fP2=fP4*fX - p[2];
145
146 //Conversion of the covariance matrix
147 Double_t c[15]; t.GetExternalCovariance(c);
148 c[10]/=x; c[11]/=x; c[12]/=x; c[13]/=x; c[14]/=x*x;
149
150 Double_t c22=fX*fX*c[14] - 2*fX*c[12] + c[5];
151 Double_t c32=fX*c[13] - c[8];
152 Double_t c20=fX*c[10] - c[3], c21=fX*c[11] - c[4], c42=fX*c[14] - c[12];
153
154 fC00=c[0 ];
155 fC10=c[1 ]; fC11=c[2 ];
156 fC20=c20; fC21=c21; fC22=c22;
157 fC30=c[6 ]; fC31=c[7 ]; fC32=c32; fC33=c[9 ];
158 fC40=c[10]; fC41=c[11]; fC42=c42; fC43=c[13]; fC44=c[14];
159
0798b21e 160 if ((t.GetStatus()&AliESDtrack::kTIME) == 0) return;
83d73500 161 StartTimeIntegral();
162 Double_t times[10]; t.GetIntegratedTimes(times); SetIntegratedTimes(times);
163 SetIntegratedLength(t.GetIntegratedLength());
51584047 164 //
165 //MI
166 fSdEdx = 0;
167 fNFoundable = 0;
168 fBConstrain = 0;
169 fLastPoint = 0;
170 fFirstPoint = 0;
171 fRemoval = 0;
172 fTrackType = 0;
173 fLab2 = 0;
83d73500 174}
175
73042f01 176//_____________________________________________________________________________
b19a0509 177AliTPCtrack::AliTPCtrack(const AliTPCtrack& t) : AliKalmanTrack(t) {
73042f01 178 //-----------------------------------------------------------------
179 // This is a track copy constructor.
180 //-----------------------------------------------------------------
be9c5115 181 fX=t.fX;
182 fAlpha=t.fAlpha;
73042f01 183 fdEdx=t.fdEdx;
184
be9c5115 185 fP0=t.fP0; fP1=t.fP1; fP2=t.fP2; fP3=t.fP3; fP4=t.fP4;
186
187 fC00=t.fC00;
188 fC10=t.fC10; fC11=t.fC11;
189 fC20=t.fC20; fC21=t.fC21; fC22=t.fC22;
190 fC30=t.fC30; fC31=t.fC31; fC32=t.fC32; fC33=t.fC33;
191 fC40=t.fC40; fC41=t.fC41; fC42=t.fC42; fC43=t.fC43; fC44=t.fC44;
192
176aff27 193 //Int_t n=GetNumberOfClusters();
51584047 194 for (Int_t i=0; i<kMaxRow; i++) fIndex[i]=t.fIndex[i];
195 //
196 //MI
197 fSdEdx = t.fSdEdx;
198 fNFoundable = t.fNFoundable;
199 fBConstrain = t.fBConstrain;
200 fLastPoint = t.fLastPoint;
201 fFirstPoint = t.fFirstPoint;
202 fRemoval = t.fRemoval ;
203 fTrackType = t.fTrackType;
204 fLab2 = t.fLab2;
205
be9c5115 206}
9c9d2487 207//_____________________________________________________________________________
208
209void AliTPCtrack::GetBarrelTrack(AliBarrelTrack *track) {
210 //
211 // Create a Barrel Track out of this track
212 // Current track is propagated to the reference plane
213 // by the tracker
214 //
215 // [SR, 01.04.2003]
216
217 if (!track) return;
218 Double_t xr, vec[5], cov[15];
219
220 track->SetLabel(GetLabel());
221 track->SetX(fX, fAlpha);
222 track->SetNClusters(GetNumberOfClusters(), GetChi2());
2b5dc063 223 Double_t times[10];
224 GetIntegratedTimes(times);
225 track->SetTime(times, GetIntegratedLength());
9c9d2487 226
2b5dc063 227 track->SetMass(GetMass());
228 track->SetdEdX(GetdEdx());
9c9d2487 229
230 track->SetNWrongClusters(fNWrong);
231 track->SetNRotate(fNRotation);
be9c5115 232
9c9d2487 233 GetExternalParameters(xr, vec);
234 track->SetStateVector(vec);
235
236 GetExternalCovariance(cov);
237 track->SetCovarianceMatrix(cov);
238
239}
be9c5115 240//_____________________________________________________________________________
241Int_t AliTPCtrack::Compare(const TObject *o) const {
242 //-----------------------------------------------------------------
243 // This function compares tracks according to the their curvature
244 //-----------------------------------------------------------------
245 AliTPCtrack *t=(AliTPCtrack*)o;
024a7fe9 246 //Double_t co=TMath::Abs(t->Get1Pt());
247 //Double_t c =TMath::Abs(Get1Pt());
248 Double_t co=t->GetSigmaY2()*t->GetSigmaZ2();
249 Double_t c =GetSigmaY2()*GetSigmaZ2();
be9c5115 250 if (c>co) return 1;
251 else if (c<co) return -1;
252 return 0;
253}
254
255//_____________________________________________________________________________
256void AliTPCtrack::GetExternalCovariance(Double_t cc[15]) const {
257 //-------------------------------------------------------------------------
258 // This function returns an external representation of the covriance matrix.
259 // (See comments in AliTPCtrack.h about external track representation)
260 //-------------------------------------------------------------------------
9b280d80 261 Double_t a=GetConvConst();
be9c5115 262
b9de75e1 263 Double_t c22=fX*fX*fC44-2*fX*fC42+fC22;
264 Double_t c32=fX*fC43-fC32;
265 Double_t c20=fX*fC40-fC20, c21=fX*fC41-fC21, c42=fX*fC44-fC42;
be9c5115 266
267 cc[0 ]=fC00;
268 cc[1 ]=fC10; cc[2 ]=fC11;
269 cc[3 ]=c20; cc[4 ]=c21; cc[5 ]=c22;
b9de75e1 270 cc[6 ]=fC30; cc[7 ]=fC31; cc[8 ]=c32; cc[9 ]=fC33;
271 cc[10]=fC40*a; cc[11]=fC41*a; cc[12]=c42*a; cc[13]=fC43*a; cc[14]=fC44*a*a;
be9c5115 272
273}
274
275//_____________________________________________________________________________
276Double_t AliTPCtrack::GetPredictedChi2(const AliCluster *c) const
277{
278 //-----------------------------------------------------------------
279 // This function calculates a predicted chi2 increment.
280 //-----------------------------------------------------------------
281 Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
282 r00+=fC00; r01+=fC10; r11+=fC11;
283
284 Double_t det=r00*r11 - r01*r01;
285 if (TMath::Abs(det) < 1.e-10) {
286 Int_t n=GetNumberOfClusters();
287 if (n>4) cerr<<n<<" AliKalmanTrack warning: Singular matrix !\n";
288 return 1e10;
289 }
290 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
291
292 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
293
294 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
73042f01 295}
296
c630aafd 297Double_t AliTPCtrack::GetYat(Double_t xk) const {
298//-----------------------------------------------------------------
299// This function calculates the Y-coordinate of a track at the plane x=xk.
300//-----------------------------------------------------------------
301 Double_t c1=fP4*fX - fP2, r1=TMath::Sqrt(1.- c1*c1);
df02fd67 302 Double_t c2=fP4*xk - fP2;
303 if (c2*c2>0.99999) {
304 Int_t n=GetNumberOfClusters();
305 if (n>4) cerr<<n<<"AliTPCtrack::GetYat: can't evaluate the y-coord !\n";
306 return 1e10;
307 }
308 Double_t r2=TMath::Sqrt(1.- c2*c2);
c630aafd 309 return fP0 + (xk-fX)*(c1+c2)/(r1+r2);
310}
311
73042f01 312//_____________________________________________________________________________
176aff27 313Int_t AliTPCtrack::PropagateTo(Double_t xk,Double_t /*x0*/,Double_t rho) {
73042f01 314 //-----------------------------------------------------------------
315 // This function propagates a track to a reference plane x=xk.
316 //-----------------------------------------------------------------
1627d1c4 317 if (TMath::Abs(fP4*xk - fP2) >= 0.9) {
318 // Int_t n=GetNumberOfClusters();
319 //if (n>4) cerr<<n<<" AliTPCtrack warning: Propagation failed !\n";
73042f01 320 return 0;
321 }
e3f7105e 322
323 // old position for time [SR, GSI 17.02.2003]
324 Double_t oldX = fX;
325 Double_t oldY = fP0;
326 Double_t oldZ = fP1;
327 //
73042f01 328
b19a0509 329 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1, y1=fP0, z1=fP1;
b9de75e1 330 Double_t c1=fP4*x1 - fP2, r1=sqrt(1.- c1*c1);
331 Double_t c2=fP4*x2 - fP2, r2=sqrt(1.- c2*c2);
73042f01 332
b19a0509 333 fP0 += dx*(c1+c2)/(r1+r2);
b9de75e1 334 fP1 += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
73042f01 335
336 //f = F - 1
337 Double_t rr=r1+r2, cc=c1+c2, xx=x1+x2;
b19a0509 338 Double_t f02=-dx*(2*rr + cc*(c1/r1 + c2/r2))/(rr*rr);
b9de75e1 339 Double_t f04= dx*(rr*xx + cc*(c1*x1/r1+c2*x2/r2))/(rr*rr);
73042f01 340 Double_t cr=c1*r2+c2*r1;
b9de75e1 341 Double_t f12=-dx*fP3*(2*cr + cc*(c2*c1/r1-r1 + c1*c2/r2-r2))/(cr*cr);
342 Double_t f13= dx*cc/cr;
343 Double_t f14=dx*fP3*(cr*xx-cc*(r1*x2-c2*c1*x1/r1+r2*x1-c1*c2*x2/r2))/(cr*cr);
73042f01 344
345 //b = C*ft
b9de75e1 346 Double_t b00=f02*fC20 + f04*fC40, b01=f12*fC20 + f14*fC40 + f13*fC30;
347 Double_t b10=f02*fC21 + f04*fC41, b11=f12*fC21 + f14*fC41 + f13*fC31;
348 Double_t b20=f02*fC22 + f04*fC42, b21=f12*fC22 + f14*fC42 + f13*fC32;
349 Double_t b30=f02*fC32 + f04*fC43, b31=f12*fC32 + f14*fC43 + f13*fC33;
350 Double_t b40=f02*fC42 + f04*fC44, b41=f12*fC42 + f14*fC44 + f13*fC43;
73042f01 351
352 //a = f*b = f*C*ft
b9de75e1 353 Double_t a00=f02*b20+f04*b40,a01=f02*b21+f04*b41,a11=f12*b21+f14*b41+f13*b31;
73042f01 354
355 //F*C*Ft = C + (a + b + bt)
b19a0509 356 fC00 += a00 + 2*b00;
357 fC10 += a01 + b01 + b10;
358 fC20 += b20;
359 fC30 += b30;
360 fC40 += b40;
361 fC11 += a11 + 2*b11;
362 fC21 += b21;
363 fC31 += b31;
364 fC41 += b41;
73042f01 365
366 fX=x2;
367
368 //Multiple scattering******************
b19a0509 369 Double_t d=sqrt((x1-fX)*(x1-fX)+(y1-fP0)*(y1-fP0)+(z1-fP1)*(z1-fP1));
be9c5115 370 Double_t p2=(1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt());
7f6ddf58 371 Double_t beta2=p2/(p2 + GetMass()*GetMass());
024a7fe9 372 //Double_t theta2=14.1*14.1/(beta2*p2*1e6)*d/x0*rho;
373 Double_t theta2=1.0259e-6*10*10/20/(beta2*p2)*d*rho;
73042f01 374
b9de75e1 375 Double_t ey=fP4*fX - fP2, ez=fP3;
376 Double_t xz=fP4*ez, zz1=ez*ez+1, xy=fP2+ey;
73042f01 377
b19a0509 378 fC22 += (2*ey*ez*ez*fP2+1-ey*ey+ez*ez+fP2*fP2*ez*ez)*theta2;
b9de75e1 379 fC32 += ez*zz1*xy*theta2;
380 fC33 += zz1*zz1*theta2;
381 fC42 += xz*ez*xy*theta2;
382 fC43 += xz*zz1*theta2;
383 fC44 += xz*xz*theta2;
73042f01 384
385 //Energy losses************************
386 Double_t dE=0.153e-3/beta2*(log(5940*beta2/(1-beta2)) - beta2)*d*rho;
387 if (x1 < x2) dE=-dE;
b9de75e1 388 cc=fP4;
7f6ddf58 389 fP4*=(1.- sqrt(p2+GetMass()*GetMass())/p2*dE);
b9de75e1 390 fP2+=fX*(fP4-cc);
73042f01 391
e3f7105e 392 // Integrated Time [SR, GSI, 17.02.2003]
0fa7dfa7 393 if (x1 < x2)
394 if (IsStartedTimeIntegral()) {
e3f7105e 395 Double_t l2 = (fX-oldX)*(fX-oldX)+(fP0-oldY)*(fP0-oldY)+(fP1-oldZ)*(fP1-oldZ);
396 AddTimeStep(TMath::Sqrt(l2));
397 }
398 //
399
73042f01 400 return 1;
401}
402
403//_____________________________________________________________________________
7f6ddf58 404Int_t AliTPCtrack::PropagateToVertex(Double_t x0,Double_t rho)
73042f01 405{
406 //-----------------------------------------------------------------
407 // This function propagates tracks to the "vertex".
408 //-----------------------------------------------------------------
b9de75e1 409 Double_t c=fP4*fX - fP2;
410 Double_t tgf=-fP2/(fP4*fP0 + sqrt(1-c*c));
73042f01 411 Double_t snf=tgf/sqrt(1.+ tgf*tgf);
b9de75e1 412 Double_t xv=(fP2+snf)/fP4;
7f6ddf58 413 return PropagateTo(xv,x0,rho);
73042f01 414}
415
416//_____________________________________________________________________________
be9c5115 417Int_t AliTPCtrack::Update(const AliCluster *c, Double_t chisq, UInt_t index) {
73042f01 418 //-----------------------------------------------------------------
419 // This function associates a cluster with this track.
420 //-----------------------------------------------------------------
9c9d2487 421
422 // update the number of wrong SR[20.03.2003]
423 Int_t absLabel = TMath::Abs(GetLabel());
424 if ( (c->GetLabel(0) != absLabel) &&
425 (c->GetLabel(0) != absLabel) &&
426 (c->GetLabel(0) != absLabel)) fNWrong++;
427 //
428
73042f01 429 Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
b19a0509 430 r00+=fC00; r01+=fC10; r11+=fC11;
73042f01 431 Double_t det=r00*r11 - r01*r01;
432 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
433
b19a0509 434 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
435 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
436 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
437 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
438 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
73042f01 439
b19a0509 440 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
b9de75e1 441 Double_t cur=fP4 + k40*dy + k41*dz, eta=fP2 + k20*dy + k21*dz;
1627d1c4 442 if (TMath::Abs(cur*fX-eta) >= 0.9) {
443 // Int_t n=GetNumberOfClusters();
444 //if (n>4) cerr<<n<<" AliTPCtrack warning: Filtering failed !\n";
be9c5115 445 return 0;
73042f01 446 }
447
b19a0509 448 fP0 += k00*dy + k01*dz;
449 fP1 += k10*dy + k11*dz;
450 fP2 = eta;
b9de75e1 451 fP3 += k30*dy + k31*dz;
452 fP4 = cur;
73042f01 453
b19a0509 454 Double_t c01=fC10, c02=fC20, c03=fC30, c04=fC40;
455 Double_t c12=fC21, c13=fC31, c14=fC41;
73042f01 456
b19a0509 457 fC00-=k00*fC00+k01*fC10; fC10-=k00*c01+k01*fC11;
458 fC20-=k00*c02+k01*c12; fC30-=k00*c03+k01*c13;
459 fC40-=k00*c04+k01*c14;
73042f01 460
b19a0509 461 fC11-=k10*c01+k11*fC11;
462 fC21-=k10*c02+k11*c12; fC31-=k10*c03+k11*c13;
463 fC41-=k10*c04+k11*c14;
73042f01 464
b19a0509 465 fC22-=k20*c02+k21*c12; fC32-=k20*c03+k21*c13;
466 fC42-=k20*c04+k21*c14;
73042f01 467
b19a0509 468 fC33-=k30*c03+k31*c13;
b9de75e1 469 fC43-=k40*c03+k41*c13;
73042f01 470
b19a0509 471 fC44-=k40*c04+k41*c14;
73042f01 472
be9c5115 473 Int_t n=GetNumberOfClusters();
474 fIndex[n]=index;
475 SetNumberOfClusters(n+1);
476 SetChi2(GetChi2()+chisq);
477
478 return 1;
73042f01 479}
480
481//_____________________________________________________________________________
482Int_t AliTPCtrack::Rotate(Double_t alpha)
483{
484 //-----------------------------------------------------------------
485 // This function rotates this track.
486 //-----------------------------------------------------------------
9c9d2487 487
488 if (alpha != 0) fNRotation++; // [SR, 01.04.2003]
489
73042f01 490 fAlpha += alpha;
be9c5115 491 if (fAlpha<-TMath::Pi()) fAlpha += 2*TMath::Pi();
492 if (fAlpha>=TMath::Pi()) fAlpha -= 2*TMath::Pi();
73042f01 493
b19a0509 494 Double_t x1=fX, y1=fP0;
73042f01 495 Double_t ca=cos(alpha), sa=sin(alpha);
b9de75e1 496 Double_t r1=fP4*fX - fP2;
73042f01 497
498 fX = x1*ca + y1*sa;
b19a0509 499 fP0=-x1*sa + y1*ca;
b9de75e1 500 fP2=fP2*ca + (fP4*y1 + sqrt(1.- r1*r1))*sa;
73042f01 501
b9de75e1 502 Double_t r2=fP4*fX - fP2;
73042f01 503 if (TMath::Abs(r2) >= 0.99999) {
be9c5115 504 Int_t n=GetNumberOfClusters();
505 if (n>4) cerr<<n<<" AliTPCtrack warning: Rotation failed !\n";
73042f01 506 return 0;
507 }
508
b9de75e1 509 Double_t y0=fP0 + sqrt(1.- r2*r2)/fP4;
510 if ((fP0-y0)*fP4 >= 0.) {
be9c5115 511 Int_t n=GetNumberOfClusters();
512 if (n>4) cerr<<n<<" AliTPCtrack warning: Rotation failed !!!\n";
73042f01 513 return 0;
514 }
515
516 //f = F - 1
b9de75e1 517 Double_t f00=ca-1, f24=(y1 - r1*x1/sqrt(1.- r1*r1))*sa,
518 f20=fP4*sa, f22=(ca + sa*r1/sqrt(1.- r1*r1))-1;
73042f01 519
520 //b = C*ft
b9de75e1 521 Double_t b00=fC00*f00, b02=fC00*f20+fC40*f24+fC20*f22;
522 Double_t b10=fC10*f00, b12=fC10*f20+fC41*f24+fC21*f22;
523 Double_t b20=fC20*f00, b22=fC20*f20+fC42*f24+fC22*f22;
524 Double_t b30=fC30*f00, b32=fC30*f20+fC43*f24+fC32*f22;
525 Double_t b40=fC40*f00, b42=fC40*f20+fC44*f24+fC42*f22;
73042f01 526
527 //a = f*b = f*C*ft
b9de75e1 528 Double_t a00=f00*b00, a02=f00*b02, a22=f20*b02+f24*b42+f22*b22;
73042f01 529
530 // *** Double_t dy2=fCyy;
531
532 //F*C*Ft = C + (a + b + bt)
b19a0509 533 fC00 += a00 + 2*b00;
534 fC10 += b10;
535 fC20 += a02+b20+b02;
536 fC30 += b30;
537 fC40 += b40;
538 fC21 += b12;
539 fC32 += b32;
540 fC22 += a22 + 2*b22;
541 fC42 += b42;
73042f01 542
543 // *** fCyy+=dy2*sa*sa*r1*r1/(1.- r1*r1);
544 // *** fCzz+=d2y*sa*sa*fT*fT/(1.- r1*r1);
545
546 return 1;
547}
548
b9de75e1 549void AliTPCtrack::ResetCovariance() {
550 //------------------------------------------------------------------
551 //This function makes a track forget its history :)
552 //------------------------------------------------------------------
553
554 fC00*=10.;
555 fC10=0.; fC11*=10.;
556 fC20=0.; fC21=0.; fC22*=10.;
557 fC30=0.; fC31=0.; fC32=0.; fC33*=10.;
558 fC40=0.; fC41=0.; fC42=0.; fC43=0.; fC44*=10.;
559
73042f01 560}
77e58468 561
562////////////////////////////////////////////////////////////////////////
563Double_t AliTPCtrack::Phi() const {
7c27857f 564//
565//
566//
77e58468 567 Double_t phi = TMath::ASin(GetSnp()) + fAlpha;
568 if (phi<0) phi+=2*TMath::Pi();
569 if (phi>=2*TMath::Pi()) phi-=2*TMath::Pi();
570 return phi;
571}
572////////////////////////////////////////////////////////////////////////
573
51584047 574
575
576////////////////////////////////////////////////////////////////////////
577// MI ADDITION
578
579Float_t AliTPCtrack::Density(Int_t row0, Int_t row1)
580{
581 //
582 // calculate cluster density
583 Int_t good = 0;
584 Int_t found = 0;
585 //if (row0<fFirstPoint) row0 = fFirstPoint;
586 if (row1>fLastPoint) row1 = fLastPoint;
587
588
589 for (Int_t i=row0;i<=row1;i++){
590 // Int_t index = fClusterIndex[i];
591 Int_t index = fIndex[i];
592 if (index!=-1) good++;
593 if (index>0) found++;
594 }
595 Float_t density=0;
596 if (good>0) density = Float_t(found)/Float_t(good);
597 return density;
598}
599
600
601Float_t AliTPCtrack::Density2(Int_t row0, Int_t row1)
602{
603 //
604 // calculate cluster density
605 Int_t good = 0;
606 Int_t found = 0;
607 //
608 for (Int_t i=row0;i<=row1;i++){
609 Int_t index = fIndex[i];
610 if (index!=-1) good++;
611 if (index>0) found++;
612 }
613 Float_t density=0;
614 if (good>0) density = Float_t(found)/Float_t(good);
615 return density;
616}
617
618
619Double_t AliTPCtrack::GetZat0() const
620{
621 //
622 // return virtual z - supposing that x = 0
623 if (TMath::Abs(fP2)>1) return 0;
624 if (TMath::Abs(fX*fP4-fP2)>1) return 0;
625 Double_t vz = fP1+fP3/fP4*(asin(-fP2)-asin(fX*fP4-fP2));
626 return vz;
627}
628
629
630Double_t AliTPCtrack::GetD(Double_t x, Double_t y) const {
631 //------------------------------------------------------------------
632 // This function calculates the transverse impact parameter
633 // with respect to a point with global coordinates (x,y)
634 //------------------------------------------------------------------
635 //Double_t xt=fX, yt=fP0;
636
637 Double_t sn=TMath::Sin(fAlpha), cs=TMath::Cos(fAlpha);
638 Double_t a = x*cs + y*sn;
639 y = -x*sn + y*cs; x=a;
640 //
641 Double_t r = TMath::Abs(1/fP4);
642 Double_t x0 = TMath::Abs(fP2*r);
643 Double_t y0 = fP0;
644 y0= fP0+TMath::Sqrt(1-(fP4*fX-fP2)*(fP4*fX-fP2))/fP4;
645
646 Double_t delta = TMath::Sqrt((x-x0)*(x-x0)+(y-y0)*(y-y0));
647 // Double_t delta = TMath::Sqrt(TMath::Abs(x*x-2*x0*x+x0*x0+ y*y-2*y*y0+y0*y0));
648 delta -= TMath::Abs(r);
649 return delta;
650}