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