SetSolenoidField method to set the L3 field strength. 2 kG is default.
[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$
a2b90f83 18Revision 1.5 2001/02/05 14:49:32 hristov
19Compare() declared const (R.Brun)
20
2a941f4e 21Revision 1.4 2000/12/08 16:07:02 cblume
22Update of the tracking by Sergei
23
bbf92647 24Revision 1.3 2000/10/15 23:40:01 cblume
25Remove AliTRDconst
26
0e9c2ad5 27Revision 1.2 2000/10/06 16:49:46 cblume
28Made Getters const
29
46d29e70 30Revision 1.1.2.1 2000/09/22 14:47:52 cblume
31Add the tracking code
32
33*/
34
35#include <iostream.h>
36
37#include <TObject.h>
38
39#include "AliTRD.h"
46d29e70 40#include "AliTRDgeometry.h"
41#include "AliTRDcluster.h"
42#include "AliTRDtrack.h"
43
44ClassImp(AliTRDtrack)
45
46
47//_____________________________________________________________________________
48
49AliTRDtrack::AliTRDtrack(UInt_t index, const Double_t xx[5],
50const Double_t cc[15], Double_t xref, Double_t alpha) {
51 //-----------------------------------------------------------------
52 // This is the main track constructor.
53 //-----------------------------------------------------------------
54 fLab=-1;
55 fChi2=0.;
56 fdEdx=0.;
57
58 fAlpha=alpha;
59 fX=xref;
60
61 fY=xx[0]; fZ=xx[1]; fC=xx[2]; fE=xx[3]; fT=xx[4];
62
63 fCyy=cc[0];
64 fCzy=cc[1]; fCzz=cc[2];
65 fCcy=cc[3]; fCcz=cc[4]; fCcc=cc[5];
66 fCey=cc[6]; fCez=cc[7]; fCec=cc[8]; fCee=cc[9];
67 fCty=cc[10]; fCtz=cc[11]; fCtc=cc[12]; fCte=cc[13]; fCtt=cc[14];
68
69 fN=0;
70 fIndex[fN++]=index;
a2b90f83 71
72 fLhPion = 0.0;
73 fLhElectron = 0.0;
74
46d29e70 75}
76
77//_____________________________________________________________________________
78AliTRDtrack::AliTRDtrack(const AliTRDtrack& t) {
79 //
80 // Copy constructor.
81 //
82
83 fLab=t.fLab;
84
85 fChi2=t.fChi2;
86 fdEdx=t.fdEdx;
87
88 fAlpha=t.fAlpha;
89 fX=t.fX;
90
91 fY=t.fY; fZ=t.fZ; fC=t.fC; fE=t.fE; fT=t.fT;
92
93 fCyy=t.fCyy;
94 fCzy=t.fCzy; fCzz=t.fCzz;
95 fCcy=t.fCcy; fCcz=t.fCcz; fCcc=t.fCcc;
96 fCey=t.fCey; fCez=t.fCez; fCec=t.fCec; fCee=t.fCee;
97 fCty=t.fCty; fCtz=t.fCtz; fCtc=t.fCtc; fCte=t.fCte; fCtt=t.fCtt;
98
99 fN=t.fN;
100 for (Int_t i=0; i<fN; i++) fIndex[i]=t.fIndex[i];
a2b90f83 101
102 fLhPion = t.fLhPion;
103 fLhElectron = t.fLhElectron;
104
46d29e70 105}
106
107//_____________________________________________________________________________
108void AliTRDtrack::GetCovariance(Double_t cc[15]) const {
109 cc[0]=fCyy;
110 cc[1]=fCzy; cc[2]=fCzz;
111 cc[3]=fCcy; cc[4]=fCcz; cc[5]=fCcc;
112 cc[6]=fCey; cc[7]=fCez; cc[8]=fCec; cc[9]=fCee;
113 cc[10]=fCty; cc[11]=fCtz; cc[12]=fCtc; cc[13]=fCte; cc[14]=fCtt;
114}
115
116//_____________________________________________________________________________
2a941f4e 117Int_t AliTRDtrack::Compare(const TObject *o) const {
46d29e70 118
119// Compares tracks according to their Y2
120
121 AliTRDtrack *t=(AliTRDtrack*)o;
122 // Double_t co=t->GetSigmaY2();
123 // Double_t c =GetSigmaY2();
124
125 Double_t co=TMath::Abs(t->GetC());
126 Double_t c =TMath::Abs(GetC());
127
128 if (c>co) return 1;
129 else if (c<co) return -1;
130 return 0;
131}
132
133//_____________________________________________________________________________
134Int_t AliTRDtrack::PropagateTo(Double_t xk,Double_t x0,Double_t rho,Double_t pm)
135{
136 // Propagates a track of particle with mass=pm to a reference plane
137 // defined by x=xk through media of density=rho and radiationLength=x0
138
139 if (TMath::Abs(fC*xk - fE) >= 0.99999) {
140 if (fN>4) cerr<<fN<<" AliTRDtrack warning: Propagation failed !\n";
141 return 0;
142 }
143
144 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1, y1=fY, z1=fZ;
145 Double_t c1=fC*x1 - fE, r1=sqrt(1.- c1*c1);
146 Double_t c2=fC*x2 - fE, r2=sqrt(1.- c2*c2);
147
148 fY += dx*(c1+c2)/(r1+r2);
149 fZ += dx*(c1+c2)/(c1*r2 + c2*r1)*fT;
150
151 //f = F - 1
152 Double_t rr=r1+r2, cc=c1+c2, xx=x1+x2;
153 Double_t f02= dx*(rr*xx + cc*(c1*x1/r1+c2*x2/r2))/(rr*rr);
154 Double_t f03=-dx*(2*rr + cc*(c1/r1 + c2/r2))/(rr*rr);
155 Double_t cr=c1*r2+c2*r1;
156 Double_t f12= dx*fT*(cr*xx-cc*(r1*x2-c2*c1*x1/r1+r2*x1-c1*c2*x2/r2))/(cr*cr);
157 Double_t f13=-dx*fT*(2*cr + cc*(c2*c1/r1-r1 + c1*c2/r2-r2))/(cr*cr);
158 Double_t f14= dx*cc/cr;
159
160 //b = C*ft
161 Double_t b00=f02*fCcy + f03*fCey, b01=f12*fCcy + f13*fCey + f14*fCty;
162 Double_t b10=f02*fCcz + f03*fCez, b11=f12*fCcz + f13*fCez + f14*fCtz;
163 Double_t b20=f02*fCcc + f03*fCec, b21=f12*fCcc + f13*fCec + f14*fCtc;
164 Double_t b30=f02*fCec + f03*fCee, b31=f12*fCec + f13*fCee + f14*fCte;
165 Double_t b40=f02*fCtc + f03*fCte, b41=f12*fCtc + f13*fCte + f14*fCtt;
166
167 //a = f*b = f*C*ft
168 Double_t a00=f02*b20+f03*b30,a01=f02*b21+f03*b31,a11=f12*b21+f13*b31+f14*b41;
169
170 //F*C*Ft = C + (a + b + bt)
171 fCyy += a00 + 2*b00;
172 fCzy += a01 + b01 + b10;
173 fCcy += b20;
174 fCey += b30;
175 fCty += b40;
176 fCzz += a11 + 2*b11;
177 fCcz += b21;
178 fCez += b31;
179 fCtz += b41;
180
181 fX=x2;
182
183
184 //Multiple scattering ******************
185
186 Double_t d=sqrt((x1-fX)*(x1-fX)+(y1-fY)*(y1-fY)+(z1-fZ)*(z1-fZ));
187 Double_t p2=GetPt()*GetPt()*(1.+fT*fT);
188 Double_t beta2=p2/(p2 + pm*pm);
189
190 Double_t ey=fC*fX - fE, ez=fT;
191 Double_t xz=fC*ez, zz1=ez*ez+1, xy=fE+ey;
192
193 Double_t theta2=14.1*14.1/(beta2*p2*1e6)*d/x0*rho;
194 fCcc += xz*xz*theta2;
195 fCec += xz*ez*xy*theta2;
196 fCtc += xz*zz1*theta2;
197 fCee += (2*ey*ez*ez*fE+1-ey*ey+ez*ez+fE*fE*ez*ez)*theta2;
198 fCte += ez*zz1*xy*theta2;
199 fCtt += zz1*zz1*theta2;
200
201
202 //Energy losses************************
203
204 Double_t dE=0.153e-3/beta2*(log(5940*beta2/(1-beta2)) - beta2)*d*rho;
205 if (x1 < x2) dE=-dE;
206 fC*=(1.- sqrt(p2+pm*pm)/p2*dE);
207 //fE*=(1.- sqrt(p2+pm*pm)/p2*dE);
208
209 return 1;
210
211}
212
213
214//_____________________________________________________________________________
215void AliTRDtrack::PropagateToVertex(Double_t x0,Double_t rho,Double_t pm)
216{
217 // This function propagates tracks to the "vertex".
218
219 Double_t c=fC*fX - fE;
220 Double_t tgf=-fE/(fC*fY + sqrt(1-c*c));
221 Double_t snf=tgf/sqrt(1.+ tgf*tgf);
222 Double_t xv=(fE+snf)/fC;
223 PropagateTo(xv,x0,rho,pm);
224}
225
226
227//_____________________________________________________________________________
228void AliTRDtrack::Update(const AliTRDcluster *c, Double_t chisq, UInt_t index)
229{
230 // Assignes found cluster to the track and updates track information
231
232 Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2()*12;
233 r00+=fCyy; r01+=fCzy; r11+=fCzz;
234 Double_t det=r00*r11 - r01*r01;
235 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
236
237 Double_t k00=fCyy*r00+fCzy*r01, k01=fCyy*r01+fCzy*r11;
238 Double_t k10=fCzy*r00+fCzz*r01, k11=fCzy*r01+fCzz*r11;
239 Double_t k20=fCcy*r00+fCcz*r01, k21=fCcy*r01+fCcz*r11;
240 Double_t k30=fCey*r00+fCez*r01, k31=fCey*r01+fCez*r11;
241 Double_t k40=fCty*r00+fCtz*r01, k41=fCty*r01+fCtz*r11;
242
243 Double_t dy=c->GetY() - fY, dz=c->GetZ() - fZ;
244 Double_t cur=fC + k20*dy + k21*dz, eta=fE + k30*dy + k31*dz;
245 if (TMath::Abs(cur*fX-eta) >= 0.99999) {
246 if (fN>4) cerr<<fN<<" AliTRDtrack warning: Filtering failed !\n";
247 return;
248 }
249
250 fY += k00*dy + k01*dz;
251 fZ += k10*dy + k11*dz;
252 fC = cur;
253 fE = eta;
254 fT += k40*dy + k41*dz;
255
256 Double_t c01=fCzy, c02=fCcy, c03=fCey, c04=fCty;
257 Double_t c12=fCcz, c13=fCez, c14=fCtz;
258
259 fCyy-=k00*fCyy+k01*fCzy; fCzy-=k00*c01+k01*fCzz;
260 fCcy-=k00*c02+k01*c12; fCey-=k00*c03+k01*c13;
261 fCty-=k00*c04+k01*c14;
262
263 fCzz-=k10*c01+k11*fCzz;
264 fCcz-=k10*c02+k11*c12; fCez-=k10*c03+k11*c13;
265 fCtz-=k10*c04+k11*c14;
266
267 fCcc-=k20*c02+k21*c12; fCec-=k20*c03+k21*c13;
268 fCtc-=k20*c04+k21*c14;
269
270 fCee-=k30*c03+k31*c13;
271 fCte-=k30*c04+k31*c14;
272
273 fCtt-=k40*c04+k41*c14;
274
275 fIndex[fN++]=index;
276 fChi2 += chisq;
277
278 // cerr<<"in update: fIndex["<<fN<<"] = "<<index<<endl;
279}
280
281//_____________________________________________________________________________
282Int_t AliTRDtrack::Rotate(Double_t alpha)
283{
284 // Rotates track parameters in R*phi plane
285
286 fAlpha += alpha;
287
288 Double_t x1=fX, y1=fY;
289 Double_t ca=cos(alpha), sa=sin(alpha);
290 Double_t r1=fC*fX - fE;
291
292 fX = x1*ca + y1*sa;
293 fY=-x1*sa + y1*ca;
294 fE=fE*ca + (fC*y1 + sqrt(1.- r1*r1))*sa;
295
296 Double_t r2=fC*fX - fE;
297 if (TMath::Abs(r2) >= 0.99999) {
298 if (fN>4) cerr<<fN<<" AliTRDtrack warning: Rotation failed !\n";
299 return 0;
300 }
301
302 Double_t y0=fY + sqrt(1.- r2*r2)/fC;
303 if ((fY-y0)*fC >= 0.) {
304 if (fN>4) cerr<<fN<<" AliTRDtrack warning: Rotation failed !!!\n";
305 return 0;
306 }
307
308 //f = F - 1
309 Double_t f00=ca-1, f32=(y1 - r1*x1/sqrt(1.- r1*r1))*sa,
310 f30=fC*sa, f33=(ca + sa*r1/sqrt(1.- r1*r1))-1;
311
312 //b = C*ft
313 Double_t b00=fCyy*f00, b03=fCyy*f30+fCcy*f32+fCey*f33;
314 Double_t b10=fCzy*f00, b13=fCzy*f30+fCcz*f32+fCez*f33;
315 Double_t b20=fCcy*f00, b23=fCcy*f30+fCcc*f32+fCec*f33;
316 Double_t b30=fCey*f00, b33=fCey*f30+fCec*f32+fCee*f33;
317 Double_t b40=fCty*f00, b43=fCty*f30+fCtc*f32+fCte*f33;
318
319 //a = f*b = f*C*ft
320 Double_t a00=f00*b00, a03=f00*b03, a33=f30*b03+f32*b23+f33*b33;
321
322 // *** Double_t dy2=fCyy;
323
324 //F*C*Ft = C + (a + b + bt)
325 fCyy += a00 + 2*b00;
326 fCzy += b10;
327 fCcy += b20;
328 fCey += a03+b30+b03;
329 fCty += b40;
330 fCez += b13;
331 fCec += b23;
332 fCee += a33 + 2*b33;
333 fCte += b43;
334
335 // *** fCyy+=dy2*sa*sa*r1*r1/(1.- r1*r1);
336 // *** fCzz+=d2y*sa*sa*fT*fT/(1.- r1*r1);
337
338 return 1;
339}
340
341
342
343
344//_____________________________________________________________________________
345Double_t AliTRDtrack::GetPredictedChi2(const AliTRDcluster *c) const
346{
347 Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2()*12;
348 r00+=fCyy; r01+=fCzy; r11+=fCzz;
349
350 Double_t det=r00*r11 - r01*r01;
351 if (TMath::Abs(det) < 1.e-10) {
352 if (fN>4) cerr<<fN<<" AliTRDtrack warning: Singular matrix !\n";
353 return 1e10;
354 }
355 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
356
357 Double_t dy=c->GetY() - fY, dz=c->GetZ() - fZ;
358
359 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
360}
361
362
363//_________________________________________________________________________
364void AliTRDtrack::GetPxPyPz(Double_t& px, Double_t& py, Double_t& pz) const
365{
366 // Returns reconstructed track momentum in the global system.
367
368 Double_t pt=TMath::Abs(GetPt()); // GeV/c
369 Double_t r=fC*fX-fE;
370 Double_t y0=fY + sqrt(1.- r*r)/fC;
371 px=-pt*(fY-y0)*fC; //cos(phi);
372 py=-pt*(fE-fX*fC); //sin(phi);
373 pz=pt*fT;
374 Double_t tmp=px*TMath::Cos(fAlpha) - py*TMath::Sin(fAlpha);
375 py=px*TMath::Sin(fAlpha) + py*TMath::Cos(fAlpha);
376 px=tmp;
377
378}
379
380//____________________________________________________________________________
381void AliTRDtrack::Streamer(TBuffer &R__b)
382{
383 if (R__b.IsReading()) {
384 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
385 TObject::Streamer(R__b);
386 R__b >> fLab;
387 R__b >> fChi2;
388 R__b >> fdEdx;
389 R__b >> fAlpha;
390 R__b >> fX;
391 R__b >> fY;
392 R__b >> fZ;
393 R__b >> fC;
394 R__b >> fE;
395 R__b >> fT;
396 R__b >> fCyy;
397 R__b >> fCzy;
398 R__b >> fCzz;
399 R__b >> fCcy;
400 R__b >> fCcz;
401 R__b >> fCcc;
402 R__b >> fCey;
403 R__b >> fCez;
404 R__b >> fCec;
405 R__b >> fCee;
406 R__b >> fCty;
407 R__b >> fCtz;
408 R__b >> fCtc;
409 R__b >> fCte;
410 R__b >> fCtt;
411 R__b >> fN;
412 for (Int_t i=0; i<fN; i++) R__b >> fIndex[i];
a2b90f83 413 if (R__v > 1) {
414 R__b >> fLhElectron;
415 R__b >> fLhPion;
416 }
46d29e70 417 } else {
418 R__b.WriteVersion(AliTRDtrack::IsA());
419 TObject::Streamer(R__b);
420 R__b << fLab;
421 R__b << fChi2;
422 R__b << fdEdx;
423 R__b << fAlpha;
424 R__b << fX;
425 R__b << fY;
426 R__b << fZ;
427 R__b << fC;
428 R__b << fE;
429 R__b << fT;
430 R__b << fCyy;
431 R__b << fCzy;
432 R__b << fCzz;
433 R__b << fCcy;
434 R__b << fCcz;
435 R__b << fCcc;
436 R__b << fCey;
437 R__b << fCez;
438 R__b << fCec;
439 R__b << fCee;
440 R__b << fCty;
441 R__b << fCtz;
442 R__b << fCtc;
443 R__b << fCte;
444 R__b << fCtt;
445 R__b << fN;
446 for (Int_t i=0; i<fN; i++) R__b << fIndex[i];
a2b90f83 447 R__b << fLhElectron;
448 R__b << fLhPion;
46d29e70 449 }
450}
451
46d29e70 452