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