Names changed in order to avoid clash with FLUKA.
[u/mrichter/AliRoot.git] / TRD / AliTRDtrack.cxx
CommitLineData
46d29e70 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$ */
46d29e70 17
a2cb5b3d 18#include <Riostream.h>
5443e65e 19#include <TObject.h>
46d29e70 20
46d29e70 21#include "AliTRDgeometry.h"
22#include "AliTRDcluster.h"
23#include "AliTRDtrack.h"
5443e65e 24#include "../TPC/AliTPCtrack.h"
79e94bf8 25#include "AliESDtrack.h"
46d29e70 26
b3a5a838 27
46d29e70 28ClassImp(AliTRDtrack)
29
30
31//_____________________________________________________________________________
32
a819a5f7 33AliTRDtrack::AliTRDtrack(const AliTRDcluster *c, UInt_t index,
5443e65e 34 const Double_t xx[5], const Double_t cc[15],
35 Double_t xref, Double_t alpha) : AliKalmanTrack() {
46d29e70 36 //-----------------------------------------------------------------
37 // This is the main track constructor.
38 //-----------------------------------------------------------------
5443e65e 39
40 fSeedLab = -1;
46d29e70 41
42 fAlpha=alpha;
5443e65e 43 if (fAlpha<-TMath::Pi()) fAlpha += 2*TMath::Pi();
44 if (fAlpha>=TMath::Pi()) fAlpha -= 2*TMath::Pi();
45
46d29e70 46 fX=xref;
47
b3a5a838 48 fY=xx[0]; fZ=xx[1]; fE=xx[2]; fT=xx[3]; fC=xx[4];
46d29e70 49
50 fCyy=cc[0];
51 fCzy=cc[1]; fCzz=cc[2];
b3a5a838 52 fCey=cc[3]; fCez=cc[4]; fCee=cc[5];
53 fCty=cc[6]; fCtz=cc[7]; fCte=cc[8]; fCtt=cc[9];
b8dc2353 54 fCcy=cc[10]; fCcz=cc[11]; fCce=cc[12]; fCct=cc[13]; fCcc=cc[14];
55
5443e65e 56 fIndex[0]=index;
57 SetNumberOfClusters(1);
58
59 fdEdx=0.;
a2b90f83 60
b3a5a838 61 fLhElectron = 0.0;
9c9d2487 62 fNWrong = 0;
63 fNRotate = 0;
b3a5a838 64
5443e65e 65 Double_t q = TMath::Abs(c->GetQ());
a819a5f7 66 Double_t s = fX*fC - fE, t=fT;
5443e65e 67 if(s*s < 1) q *= TMath::Sqrt((1-s*s)/(1+t*t));
68
69 fdQdl[0] = q;
0d5b5c27 70
71 // initialisation [SR, GSI 18.02.2003] (i startd for 1)
72 for(Int_t i=1; i<kMAX_CLUSTERS_PER_TRACK; i++) {
73 fdQdl[i] = 0;
74 fIndex[i] = 0;
75 }
46d29e70 76}
77
78//_____________________________________________________________________________
5443e65e 79AliTRDtrack::AliTRDtrack(const AliTRDtrack& t) : AliKalmanTrack(t) {
46d29e70 80 //
81 // Copy constructor.
82 //
b8dc2353 83
5443e65e 84 SetLabel(t.GetLabel());
85 fSeedLab=t.GetSeedLabel();
46d29e70 86
5443e65e 87 SetChi2(t.GetChi2());
46d29e70 88 fdEdx=t.fdEdx;
89
b3a5a838 90 fLhElectron = 0.0;
9c9d2487 91 fNWrong = t.fNWrong;
92 fNRotate = t.fNRotate;
b3a5a838 93
46d29e70 94 fAlpha=t.fAlpha;
95 fX=t.fX;
96
b8dc2353 97 fY=t.fY; fZ=t.fZ; fE=t.fE; fT=t.fT; fC=t.fC;
46d29e70 98
99 fCyy=t.fCyy;
100 fCzy=t.fCzy; fCzz=t.fCzz;
b3a5a838 101 fCey=t.fCey; fCez=t.fCez; fCee=t.fCee;
102 fCty=t.fCty; fCtz=t.fCtz; fCte=t.fCte; fCtt=t.fCtt;
b8dc2353 103 fCcy=t.fCcy; fCcz=t.fCcz; fCce=t.fCce; fCct=t.fCct; fCcc=t.fCcc;
46d29e70 104
5443e65e 105 Int_t n=t.GetNumberOfClusters();
106 SetNumberOfClusters(n);
107 for (Int_t i=0; i<n; i++) {
a819a5f7 108 fIndex[i]=t.fIndex[i];
109 fdQdl[i]=t.fdQdl[i];
110 }
b8dc2353 111
0d5b5c27 112 // initialisation (i starts from n) [SR, GSI, 18.02.2003]
113 for(Int_t i=n; i<kMAX_CLUSTERS_PER_TRACK; i++) {
114 fdQdl[i] = 0;
115 fIndex[i] = 0;
116 }
5443e65e 117}
118
119//_____________________________________________________________________________
b3a5a838 120AliTRDtrack::AliTRDtrack(const AliKalmanTrack& t, Double_t alpha)
121 :AliKalmanTrack(t) {
5443e65e 122 //
123 // Constructor from AliTPCtrack or AliITStrack .
124 //
125
126 SetLabel(t.GetLabel());
127 SetChi2(0.);
b8dc2353 128 SetMass(t.GetMass());
5443e65e 129 SetNumberOfClusters(0);
130
131 fdEdx=0;
132
b3a5a838 133 fLhElectron = 0.0;
9c9d2487 134 fNWrong = 0;
135 fNRotate = 0;
b3a5a838 136
5443e65e 137 fAlpha = alpha;
138 if (fAlpha < -TMath::Pi()) fAlpha += 2*TMath::Pi();
139 else if (fAlpha >= TMath::Pi()) fAlpha -= 2*TMath::Pi();
140
141 Double_t x, p[5]; t.GetExternalParameters(x,p);
142
143 fX=x;
144
145 x = GetConvConst();
146
b8dc2353 147 fY=p[0];
148 fZ=p[1];
b3a5a838 149 fT=p[3];
150 fC=p[4]/x;
b8dc2353 151 fE=fC*fX - p[2];
5443e65e 152
153 //Conversion of the covariance matrix
154 Double_t c[15]; t.GetExternalCovariance(c);
79e94bf8 155
156 c[10]/=x; c[11]/=x; c[12]/=x; c[13]/=x; c[14]/=x*x;
157
158 Double_t c22=fX*fX*c[14] - 2*fX*c[12] + c[5];
159 Double_t c32=fX*c[13] - c[8];
160 Double_t c20=fX*c[10] - c[3], c21=fX*c[11] - c[4], c42=fX*c[14] - c[12];
161
162 fCyy=c[0 ];
163 fCzy=c[1 ]; fCzz=c[2 ];
164 fCey=c20; fCez=c21; fCee=c22;
165 fCty=c[6 ]; fCtz=c[7 ]; fCte=c32; fCtt=c[9 ];
166 fCcy=c[10]; fCcz=c[11]; fCce=c42; fCct=c[13]; fCcc=c[14];
167
168 // Initialization [SR, GSI, 18.02.2003]
169 for(Int_t i=0; i<kMAX_CLUSTERS_PER_TRACK; i++) {
170 fdQdl[i] = 0;
171 fIndex[i] = 0;
172 }
173}
174//_____________________________________________________________________________
175AliTRDtrack::AliTRDtrack(const AliESDtrack& t)
176 :AliKalmanTrack() {
177 //
178 // Constructor from AliESDtrack
179 //
180
181 SetLabel(t.GetLabel());
182 SetChi2(0.);
183 SetMass(t.GetMass());
184 SetNumberOfClusters(0);
185 // WARNING: cluster indices are NOT copied !!!
186
187 fdEdx=0;
188
189 fLhElectron = 0.0;
190 fNWrong = 0;
191 fNRotate = 0;
192
193 fAlpha = t.GetAlpha();
194 if (fAlpha < -TMath::Pi()) fAlpha += 2*TMath::Pi();
195 else if (fAlpha >= TMath::Pi()) fAlpha -= 2*TMath::Pi();
196
197 Double_t x, p[5]; t.GetExternalParameters(x,p);
198
199 fX=x;
200
201 x = GetConvConst();
202
203 fY=p[0];
204 fZ=p[1];
205 fT=p[3];
206 fC=p[4]/x;
207 fE=fC*fX - p[2];
208
209 //Conversion of the covariance matrix
210 Double_t c[15]; t.GetExternalCovariance(c);
5443e65e 211
212 c[10]/=x; c[11]/=x; c[12]/=x; c[13]/=x; c[14]/=x*x;
213
214 Double_t c22=fX*fX*c[14] - 2*fX*c[12] + c[5];
215 Double_t c32=fX*c[13] - c[8];
216 Double_t c20=fX*c[10] - c[3], c21=fX*c[11] - c[4], c42=fX*c[14] - c[12];
217
b8dc2353 218 fCyy=c[0 ];
219 fCzy=c[1 ]; fCzz=c[2 ];
220 fCey=c20; fCez=c21; fCee=c22;
221 fCty=c[6 ]; fCtz=c[7 ]; fCte=c32; fCtt=c[9 ];
222 fCcy=c[10]; fCcz=c[11]; fCce=c42; fCct=c[13]; fCcc=c[14];
5443e65e 223
0d5b5c27 224 // Initialization [SR, GSI, 18.02.2003]
225 for(Int_t i=0; i<kMAX_CLUSTERS_PER_TRACK; i++) {
226 fdQdl[i] = 0;
227 fIndex[i] = 0;
228 }
5443e65e 229}
9c9d2487 230//_____________________________________________________________________________
231
232void AliTRDtrack::GetBarrelTrack(AliBarrelTrack *track) {
233 //
234 //
235 //
236
237 if (!track) return;
238 Double_t xr, vec[5], cov[15];
239
240 track->SetLabel(GetLabel());
241 track->SetX(fX, fAlpha);
242 track->SetNClusters(GetNumberOfClusters(), GetChi2());
243 track->SetNWrongClusters(fNWrong);
244 track->SetNRotate(fNRotate);
2b5dc063 245 Double_t times[10];
246 GetIntegratedTimes(times);
247 track->SetTime(times, GetIntegratedLength());
9c9d2487 248
2b5dc063 249 track->SetMass(GetMass());
250 track->SetdEdX(GetdEdx());
5443e65e 251
9c9d2487 252 GetExternalParameters(xr, vec);
253 track->SetStateVector(vec);
254
255 GetExternalCovariance(cov);
256 track->SetCovarianceMatrix(cov);
257}
5443e65e 258//____________________________________________________________________________
259void AliTRDtrack::GetExternalParameters(Double_t& xr, Double_t x[5]) const {
260 //
261 // This function returns external TRD track representation
262 //
263 xr=fX;
264 x[0]=GetY();
265 x[1]=GetZ();
266 x[2]=GetSnp();
267 x[3]=GetTgl();
b8dc2353 268 x[4]=Get1Pt();
5443e65e 269}
270
271//_____________________________________________________________________________
272void AliTRDtrack::GetExternalCovariance(Double_t cc[15]) const {
273 //
274 // This function returns external representation of the covriance matrix.
275 //
276 Double_t a=GetConvConst();
277
b3a5a838 278 Double_t c22=fX*fX*fCcc-2*fX*fCce+fCee;
279 Double_t c32=fX*fCct-fCte;
280 Double_t c20=fX*fCcy-fCey, c21=fX*fCcz-fCez, c42=fX*fCcc-fCce;
5443e65e 281
282 cc[0 ]=fCyy;
283 cc[1 ]=fCzy; cc[2 ]=fCzz;
284 cc[3 ]=c20; cc[4 ]=c21; cc[5 ]=c22;
285 cc[6 ]=fCty; cc[7 ]=fCtz; cc[8 ]=c32; cc[9 ]=fCtt;
b8dc2353 286 cc[10]=fCcy*a; cc[11]=fCcz*a; cc[12]=c42*a; cc[13]=fCct*a; cc[14]=fCcc*a*a;
287
5443e65e 288}
289
46d29e70 290
291//_____________________________________________________________________________
292void AliTRDtrack::GetCovariance(Double_t cc[15]) const {
b8dc2353 293
46d29e70 294 cc[0]=fCyy;
295 cc[1]=fCzy; cc[2]=fCzz;
b3a5a838 296 cc[3]=fCey; cc[4]=fCez; cc[5]=fCee;
297 cc[6]=fCcy; cc[7]=fCcz; cc[8]=fCce; cc[9]=fCcc;
298 cc[10]=fCty; cc[11]=fCtz; cc[12]=fCte; cc[13]=fCct; cc[14]=fCtt;
b8dc2353 299
46d29e70 300}
301
302//_____________________________________________________________________________
2a941f4e 303Int_t AliTRDtrack::Compare(const TObject *o) const {
46d29e70 304
5443e65e 305// Compares tracks according to their Y2 or curvature
46d29e70 306
307 AliTRDtrack *t=(AliTRDtrack*)o;
308 // Double_t co=t->GetSigmaY2();
309 // Double_t c =GetSigmaY2();
310
311 Double_t co=TMath::Abs(t->GetC());
312 Double_t c =TMath::Abs(GetC());
313
314 if (c>co) return 1;
315 else if (c<co) return -1;
316 return 0;
317}
318
319//_____________________________________________________________________________
a819a5f7 320void AliTRDtrack::CookdEdx(Double_t low, Double_t up) {
321 //-----------------------------------------------------------------
322 // Calculates dE/dX within the "low" and "up" cuts.
323 //-----------------------------------------------------------------
5443e65e 324
a819a5f7 325 Int_t i;
5443e65e 326 Int_t nc=GetNumberOfClusters();
a819a5f7 327
5443e65e 328 Float_t sorted[kMAX_CLUSTERS_PER_TRACK];
329 for (i=0; i < nc; i++) {
330 sorted[i]=fdQdl[i];
331 }
a819a5f7 332
333 Int_t swap;
5443e65e 334
a819a5f7 335 do {
336 swap=0;
337 for (i=0; i<nc-1; i++) {
338 if (sorted[i]<=sorted[i+1]) continue;
339 Float_t tmp=sorted[i];
340 sorted[i]=sorted[i+1]; sorted[i+1]=tmp;
341 swap++;
342 }
343 } while (swap);
344
345 Int_t nl=Int_t(low*nc), nu=Int_t(up*nc);
346 Float_t dedx=0;
347 for (i=nl; i<=nu; i++) dedx += sorted[i];
348 dedx /= (nu-nl+1);
5443e65e 349
a819a5f7 350 SetdEdx(dedx);
351}
352
353
a819a5f7 354//_____________________________________________________________________________
b3a5a838 355Int_t AliTRDtrack::PropagateTo(Double_t xk,Double_t x0,Double_t rho)
46d29e70 356{
357 // Propagates a track of particle with mass=pm to a reference plane
358 // defined by x=xk through media of density=rho and radiationLength=x0
359
9c9d2487 360 if (xk == fX) return 1;
361
46d29e70 362 if (TMath::Abs(fC*xk - fE) >= 0.99999) {
b8dc2353 363 Int_t n=GetNumberOfClusters();
9c9d2487 364 if (n>4) cerr << n << " AliTRDtrack: Propagation failed, \tPt = "
365 << GetPt() << "\t" << GetLabel() << "\t" << GetMass() << endl;
46d29e70 366 return 0;
367 }
368
0d5b5c27 369 // track Length measurement [SR, GSI, 17.02.2003]
370 Double_t oldX = fX, oldY = fY, oldZ = fZ;
371
46d29e70 372 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1, y1=fY, z1=fZ;
5443e65e 373 Double_t c1=fC*x1 - fE;
374 if((c1*c1) > 1) return 0;
375 Double_t r1=sqrt(1.- c1*c1);
b8dc2353 376 Double_t c2=fC*x2 - fE;
5443e65e 377 if((c2*c2) > 1) return 0;
378 Double_t r2=sqrt(1.- c2*c2);
46d29e70 379
380 fY += dx*(c1+c2)/(r1+r2);
381 fZ += dx*(c1+c2)/(c1*r2 + c2*r1)*fT;
382
383 //f = F - 1
384 Double_t rr=r1+r2, cc=c1+c2, xx=x1+x2;
b3a5a838 385 Double_t f02=-dx*(2*rr + cc*(c1/r1 + c2/r2))/(rr*rr);
386 Double_t f04= dx*(rr*xx + cc*(c1*x1/r1+c2*x2/r2))/(rr*rr);
46d29e70 387 Double_t cr=c1*r2+c2*r1;
b3a5a838 388 Double_t f12=-dx*fT*(2*cr + cc*(c2*c1/r1-r1 + c1*c2/r2-r2))/(cr*cr);
389 Double_t f13= dx*cc/cr;
b8dc2353 390 Double_t f14=dx*fT*(cr*xx-cc*(r1*x2-c2*c1*x1/r1+r2*x1-c1*c2*x2/r2))/(cr*cr);
46d29e70 391
392 //b = C*ft
b3a5a838 393 Double_t b00=f02*fCey + f04*fCcy, b01=f12*fCey + f14*fCcy + f13*fCty;
394 Double_t b10=f02*fCez + f04*fCcz, b11=f12*fCez + f14*fCcz + f13*fCtz;
395 Double_t b20=f02*fCee + f04*fCce, b21=f12*fCee + f14*fCce + f13*fCte;
396 Double_t b30=f02*fCte + f04*fCct, b31=f12*fCte + f14*fCct + f13*fCtt;
397 Double_t b40=f02*fCce + f04*fCcc, b41=f12*fCce + f14*fCcc + f13*fCct;
46d29e70 398
399 //a = f*b = f*C*ft
b3a5a838 400 Double_t a00=f02*b20+f04*b40,a01=f02*b21+f04*b41,a11=f12*b21+f14*b41+f13*b31;
46d29e70 401
402 //F*C*Ft = C + (a + b + bt)
403 fCyy += a00 + 2*b00;
404 fCzy += a01 + b01 + b10;
b3a5a838 405 fCey += b20;
406 fCty += b30;
407 fCcy += b40;
46d29e70 408 fCzz += a11 + 2*b11;
b3a5a838 409 fCez += b21;
410 fCtz += b31;
b8dc2353 411 fCcz += b41;
46d29e70 412
b8dc2353 413 fX=x2;
46d29e70 414
415 //Multiple scattering ******************
46d29e70 416 Double_t d=sqrt((x1-fX)*(x1-fX)+(y1-fY)*(y1-fY)+(z1-fZ)*(z1-fZ));
b8dc2353 417 Double_t p2=(1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt());
b3a5a838 418 Double_t beta2=p2/(p2 + GetMass()*GetMass());
b8dc2353 419 Double_t theta2=14.1*14.1/(beta2*p2*1e6)*d/x0*rho;
46d29e70 420
421 Double_t ey=fC*fX - fE, ez=fT;
422 Double_t xz=fC*ez, zz1=ez*ez+1, xy=fE+ey;
423
46d29e70 424 fCee += (2*ey*ez*ez*fE+1-ey*ey+ez*ez+fE*fE*ez*ez)*theta2;
425 fCte += ez*zz1*xy*theta2;
426 fCtt += zz1*zz1*theta2;
b3a5a838 427 fCce += xz*ez*xy*theta2;
428 fCct += xz*zz1*theta2;
429 fCcc += xz*xz*theta2;
46d29e70 430
46d29e70 431 //Energy losses************************
b8dc2353 432 if((5940*beta2/(1-beta2+1e-10) - beta2) < 0) return 0;
5443e65e 433
b8dc2353 434 Double_t dE=0.153e-3/beta2*(log(5940*beta2/(1-beta2+1e-10)) - beta2)*d*rho;
435 if (x1 < x2) dE=-dE;
436 cc=fC;
b3a5a838 437 fC*=(1.- sqrt(p2+GetMass()*GetMass())/p2*dE);
b8dc2353 438 fE+=fX*(fC-cc);
46d29e70 439
0d5b5c27 440 // track time measurement [SR, GSI 17.02.2002]
441 if (IsStartedTimeIntegral()) {
442 Double_t l2 = (fX-oldX)*(fX-oldX) + (fY-oldY)*(fY-oldY) + (fZ-oldZ)*(fZ-oldZ);
443 AddTimeStep(TMath::Sqrt(l2));
444 }
445
b8dc2353 446 return 1;
46d29e70 447}
448
fd621f36 449
46d29e70 450//_____________________________________________________________________________
fd621f36 451Int_t AliTRDtrack::Update(const AliTRDcluster *c, Double_t chisq, UInt_t index, Double_t h01)
46d29e70 452{
453 // Assignes found cluster to the track and updates track information
454
b8dc2353 455 Bool_t fNoTilt = kTRUE;
456 if(TMath::Abs(h01) > 0.003) fNoTilt = kFALSE;
fd621f36 457
b8dc2353 458 Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
459 r00+=fCyy; r01+=fCzy; r11+=fCzz;
46d29e70 460 Double_t det=r00*r11 - r01*r01;
461 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
462
b8dc2353 463 Double_t k00=fCyy*r00+fCzy*r01, k01=fCyy*r01+fCzy*r11;
464 Double_t k10=fCzy*r00+fCzz*r01, k11=fCzy*r01+fCzz*r11;
465 Double_t k20=fCey*r00+fCez*r01, k21=fCey*r01+fCez*r11;
466 Double_t k30=fCty*r00+fCtz*r01, k31=fCty*r01+fCtz*r11;
467 Double_t k40=fCcy*r00+fCcz*r01, k41=fCcy*r01+fCcz*r11;
46d29e70 468
469 Double_t dy=c->GetY() - fY, dz=c->GetZ() - fZ;
b3a5a838 470 Double_t cur=fC + k40*dy + k41*dz, eta=fE + k20*dy + k21*dz;
fd621f36 471
b3a5a838 472 Double_t c01=fCzy, c02=fCey, c03=fCty, c04=fCcy;
473 Double_t c12=fCez, c13=fCtz, c14=fCcz;
46d29e70 474
b8dc2353 475 if(fNoTilt) {
476 if (TMath::Abs(cur*fX-eta) >= 0.99999) {
477 Int_t n=GetNumberOfClusters();
478 if (n>4) cerr<<n<<" AliTRDtrack warning: Filtering failed !\n";
479 return 0;
480 }
481 fY += k00*dy + k01*dz;
482 fZ += k10*dy + k11*dz;
483 fE = eta;
9c9d2487 484 //fT += k30*dy + k31*dz;
b8dc2353 485 fC = cur;
486 }
487 else {
488 Double_t xu_factor = 100.; // empirical factor set by C.Xu
489 // in the first tilt version
490 r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2()*xu_factor;
491 r00+=(fCyy+2.0*h01*fCzy+h01*h01*fCzz);
492 r01+=(fCzy+h01*fCzz);
493 det=r00*r11 - r01*r01;
494 tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
495
496 k00=fCyy*r00+fCzy*(r01+h01*r00),k01=fCyy*r01+fCzy*(r11+h01*r01);
497 k10=fCzy*r00+fCzz*(r01+h01*r00),k11=fCzy*r01+fCzz*(r11+h01*r01);
498 k20=fCey*r00+fCez*(r01+h01*r00),k21=fCey*r01+fCez*(r11+h01*r01);
499 k30=fCty*r00+fCtz*(r01+h01*r00),k31=fCty*r01+fCtz*(r11+h01*r01);
500 k40=fCcy*r00+fCcz*(r01+h01*r00),k41=fCcy*r01+fCcz*(r11+h01*r01);
501
502 dy=c->GetY() - fY; dz=c->GetZ() - fZ;
503 dy=dy+h01*dz;
504
505 cur=fC + k40*dy + k41*dz; eta=fE + k20*dy + k21*dz;
506 if (TMath::Abs(cur*fX-eta) >= 0.99999) {
507 Int_t n=GetNumberOfClusters();
508 if (n>4) cerr<<n<<" AliTRDtrack warning: Filtering failed !\n";
509 return 0;
510 }
511 fY += k00*dy + k01*dz;
512 fZ += k10*dy + k11*dz;
513 fE = eta;
9c9d2487 514 //fT += k30*dy + k31*dz;
b8dc2353 515 fC = cur;
516
517 k01+=h01*k00;
518 k11+=h01*k10;
519 k21+=h01*k20;
520 k31+=h01*k30;
521 k41+=h01*k40;
522 }
523
46d29e70 524 fCyy-=k00*fCyy+k01*fCzy; fCzy-=k00*c01+k01*fCzz;
b3a5a838 525 fCey-=k00*c02+k01*c12; fCty-=k00*c03+k01*c13;
526 fCcy-=k00*c04+k01*c14;
b8dc2353 527
46d29e70 528 fCzz-=k10*c01+k11*fCzz;
b3a5a838 529 fCez-=k10*c02+k11*c12; fCtz-=k10*c03+k11*c13;
530 fCcz-=k10*c04+k11*c14;
b8dc2353 531
b3a5a838 532 fCee-=k20*c02+k21*c12; fCte-=k20*c03+k21*c13;
533 fCce-=k20*c04+k21*c14;
b8dc2353 534
b3a5a838 535 fCtt-=k30*c03+k31*c13;
b8dc2353 536 fCct-=k40*c03+k41*c13;
537
538 fCcc-=k40*c04+k41*c14;
46d29e70 539
b8dc2353 540 Int_t n=GetNumberOfClusters();
5443e65e 541 fIndex[n]=index;
b8dc2353 542 SetNumberOfClusters(n+1);
fd621f36 543
b8dc2353 544 SetChi2(GetChi2()+chisq);
46d29e70 545 // cerr<<"in update: fIndex["<<fN<<"] = "<<index<<endl;
5443e65e 546
b8dc2353 547 return 1;
46d29e70 548}
549
fd621f36 550
46d29e70 551//_____________________________________________________________________________
552Int_t AliTRDtrack::Rotate(Double_t alpha)
553{
554 // Rotates track parameters in R*phi plane
9c9d2487 555
556 fNRotate++;
46d29e70 557
558 fAlpha += alpha;
b3a5a838 559 if (fAlpha<-TMath::Pi()) fAlpha += 2*TMath::Pi();
b8dc2353 560 if (fAlpha>=TMath::Pi()) fAlpha -= 2*TMath::Pi();
46d29e70 561
562 Double_t x1=fX, y1=fY;
563 Double_t ca=cos(alpha), sa=sin(alpha);
564 Double_t r1=fC*fX - fE;
565
566 fX = x1*ca + y1*sa;
b8dc2353 567 fY =-x1*sa + y1*ca;
568 if((r1*r1) > 1) return 0;
46d29e70 569 fE=fE*ca + (fC*y1 + sqrt(1.- r1*r1))*sa;
570
571 Double_t r2=fC*fX - fE;
572 if (TMath::Abs(r2) >= 0.99999) {
b8dc2353 573 Int_t n=GetNumberOfClusters();
5443e65e 574 if (n>4) cerr<<n<<" AliTRDtrack warning: Rotation failed !\n";
46d29e70 575 return 0;
576 }
577
b8dc2353 578 if((r2*r2) > 1) return 0;
46d29e70 579 Double_t y0=fY + sqrt(1.- r2*r2)/fC;
580 if ((fY-y0)*fC >= 0.) {
b8dc2353 581 Int_t n=GetNumberOfClusters();
5443e65e 582 if (n>4) cerr<<n<<" AliTRDtrack warning: Rotation failed !!!\n";
46d29e70 583 return 0;
584 }
585
586 //f = F - 1
b3a5a838 587 Double_t f00=ca-1, f24=(y1 - r1*x1/sqrt(1.- r1*r1))*sa,
b8dc2353 588 f20=fC*sa, f22=(ca + sa*r1/sqrt(1.- r1*r1))-1;
46d29e70 589
590 //b = C*ft
b3a5a838 591 Double_t b00=fCyy*f00, b02=fCyy*f20+fCcy*f24+fCey*f22;
592 Double_t b10=fCzy*f00, b12=fCzy*f20+fCcz*f24+fCez*f22;
593 Double_t b20=fCey*f00, b22=fCey*f20+fCce*f24+fCee*f22;
594 Double_t b30=fCty*f00, b32=fCty*f20+fCct*f24+fCte*f22;
595 Double_t b40=fCcy*f00, b42=fCcy*f20+fCcc*f24+fCce*f22;
46d29e70 596
597 //a = f*b = f*C*ft
b3a5a838 598 Double_t a00=f00*b00, a02=f00*b02, a22=f20*b02+f24*b42+f22*b22;
46d29e70 599
46d29e70 600 //F*C*Ft = C + (a + b + bt)
601 fCyy += a00 + 2*b00;
602 fCzy += b10;
b3a5a838 603 fCey += a02+b20+b02;
604 fCty += b30;
605 fCcy += b40;
606 fCez += b12;
607 fCte += b32;
608 fCee += a22 + 2*b22;
609 fCce += b42;
46d29e70 610
b8dc2353 611 return 1;
46d29e70 612}
613
614
46d29e70 615//_____________________________________________________________________________
fd621f36 616Double_t AliTRDtrack::GetPredictedChi2(const AliTRDcluster *c, Double_t h01) const
46d29e70 617{
fd621f36 618
b8dc2353 619 Bool_t fNoTilt = kTRUE;
620 if(TMath::Abs(h01) > 0.003) fNoTilt = kFALSE;
621 Double_t chi2, dy, r00, r01, r11;
622
623 if(fNoTilt) {
624 dy=c->GetY() - fY;
625 r00=c->GetSigmaY2();
626 chi2 = (dy*dy)/r00;
46d29e70 627 }
b8dc2353 628 else {
629 r00=c->GetSigmaY2(); r01=0.; r11=c->GetSigmaZ2();
630 r00+=fCyy; r01+=fCzy; r11+=fCzz;
631
632 Double_t det=r00*r11 - r01*r01;
633 if (TMath::Abs(det) < 1.e-10) {
634 Int_t n=GetNumberOfClusters();
635 if (n>4) cerr<<n<<" AliTRDtrack warning: Singular matrix !\n";
636 return 1e10;
637 }
638 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
639 Double_t dy=c->GetY() - fY, dz=c->GetZ() - fZ;
640 dy=dy+h01*dz;
a819a5f7 641
b8dc2353 642 chi2 = (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
643 }
644 return chi2;
fd621f36 645}
46d29e70 646
647
648//_________________________________________________________________________
649void AliTRDtrack::GetPxPyPz(Double_t& px, Double_t& py, Double_t& pz) const
650{
651 // Returns reconstructed track momentum in the global system.
652
653 Double_t pt=TMath::Abs(GetPt()); // GeV/c
654 Double_t r=fC*fX-fE;
5443e65e 655
656 Double_t y0;
657 if(r > 1) { py = pt; px = 0; }
658 else if(r < -1) { py = -pt; px = 0; }
659 else {
660 y0=fY + sqrt(1.- r*r)/fC;
661 px=-pt*(fY-y0)*fC; //cos(phi);
662 py=-pt*(fE-fX*fC); //sin(phi);
663 }
46d29e70 664 pz=pt*fT;
665 Double_t tmp=px*TMath::Cos(fAlpha) - py*TMath::Sin(fAlpha);
666 py=px*TMath::Sin(fAlpha) + py*TMath::Cos(fAlpha);
667 px=tmp;
668
669}
670
5443e65e 671//_________________________________________________________________________
672void AliTRDtrack::GetGlobalXYZ(Double_t& x, Double_t& y, Double_t& z) const
46d29e70 673{
5443e65e 674 // Returns reconstructed track coordinates in the global system.
675
676 x = fX; y = fY; z = fZ;
677 Double_t tmp=x*TMath::Cos(fAlpha) - y*TMath::Sin(fAlpha);
678 y=x*TMath::Sin(fAlpha) + y*TMath::Cos(fAlpha);
679 x=tmp;
680
681}
3ab6f951 682
5443e65e 683//_________________________________________________________________________
684void AliTRDtrack::ResetCovariance() {
685 //
686 // Resets covariance matrix
687 //
46d29e70 688
5443e65e 689 fCyy*=10.;
b8dc2353 690 fCzy=0.; fCzz*=10.;
691 fCey=0.; fCez=0.; fCee*=10.;
692 fCty=0.; fCtz=0.; fCte=0.; fCtt*=10.;
693 fCcy=0.; fCcz=0.; fCce=0.; fCct=0.; fCcc*=10.;
5443e65e 694}
b8dc2353 695