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