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