1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.8.10.2 2002/07/24 10:09:31 alibrary
21 Revision 1.11 2002/06/13 12:09:58 hristov
24 Revision 1.10 2002/06/12 09:54:35 cblume
25 Update of tracking code provided by Sergei
27 Revision 1.8 2001/05/30 12:17:47 hristov
28 Loop variables declared once
30 Revision 1.7 2001/05/28 17:07:58 hristov
31 Last minute changes; ExB correction in AliTRDclusterizerV1; taking into account of material in G10 TEC frames and material between TEC planes (C.Blume,S.Sedykh)
33 Revision 1.4 2000/12/08 16:07:02 cblume
34 Update of the tracking by Sergei
36 Revision 1.3 2000/10/15 23:40:01 cblume
39 Revision 1.2 2000/10/06 16:49:46 cblume
42 Revision 1.1.2.1 2000/09/22 14:47:52 cblume
50 #include "AliTRDgeometry.h"
51 #include "AliTRDcluster.h"
52 #include "AliTRDtrack.h"
53 #include "../TPC/AliTPCtrack.h"
58 //_____________________________________________________________________________
60 AliTRDtrack::AliTRDtrack(const AliTRDcluster *c, UInt_t index,
61 const Double_t xx[5], const Double_t cc[15],
62 Double_t xref, Double_t alpha) : AliKalmanTrack() {
63 //-----------------------------------------------------------------
64 // This is the main track constructor.
65 //-----------------------------------------------------------------
70 if (fAlpha<-TMath::Pi()) fAlpha += 2*TMath::Pi();
71 if (fAlpha>=TMath::Pi()) fAlpha -= 2*TMath::Pi();
75 fY=xx[0]; fZ=xx[1]; fC=xx[2]; fE=xx[3]; fT=xx[4];
78 fCzy=cc[1]; fCzz=cc[2];
79 fCcy=cc[3]; fCcz=cc[4]; fCcc=cc[5];
80 fCey=cc[6]; fCez=cc[7]; fCec=cc[8]; fCee=cc[9];
81 fCty=cc[10]; fCtz=cc[11]; fCtc=cc[12]; fCte=cc[13]; fCtt=cc[14];
84 SetNumberOfClusters(1);
88 Double_t q = TMath::Abs(c->GetQ());
89 Double_t s = fX*fC - fE, t=fT;
90 if(s*s < 1) q *= TMath::Sqrt((1-s*s)/(1+t*t));
95 //_____________________________________________________________________________
96 AliTRDtrack::AliTRDtrack(const AliTRDtrack& t) : AliKalmanTrack(t) {
101 SetLabel(t.GetLabel());
102 fSeedLab=t.GetSeedLabel();
104 SetChi2(t.GetChi2());
110 fY=t.fY; fZ=t.fZ; fC=t.fC; fE=t.fE; fT=t.fT;
113 fCzy=t.fCzy; fCzz=t.fCzz;
114 fCcy=t.fCcy; fCcz=t.fCcz; fCcc=t.fCcc;
115 fCey=t.fCey; fCez=t.fCez; fCec=t.fCec; fCee=t.fCee;
116 fCty=t.fCty; fCtz=t.fCtz; fCtc=t.fCtc; fCte=t.fCte; fCtt=t.fCtt;
118 Int_t n=t.GetNumberOfClusters();
119 SetNumberOfClusters(n);
120 for (Int_t i=0; i<n; i++) {
121 fIndex[i]=t.fIndex[i];
126 //_____________________________________________________________________________
127 AliTRDtrack::AliTRDtrack(const AliKalmanTrack& t, Double_t alpha) {
129 // Constructor from AliTPCtrack or AliITStrack .
132 SetLabel(t.GetLabel());
134 SetNumberOfClusters(0);
139 if (fAlpha < -TMath::Pi()) fAlpha += 2*TMath::Pi();
140 else if (fAlpha >= TMath::Pi()) fAlpha -= 2*TMath::Pi();
142 Double_t x, p[5]; t.GetExternalParameters(x,p);
148 fY=p[0]; fZ=p[1]; fC=p[4]/x;
149 fE=fX*fC-p[2]; fT=p[3];
151 //Conversion of the covariance matrix
152 Double_t c[15]; t.GetExternalCovariance(c);
154 c[10]/=x; c[11]/=x; c[12]/=x; c[13]/=x; c[14]/=x*x;
156 Double_t c22=fX*fX*c[14] - 2*fX*c[12] + c[5];
157 Double_t c32=fX*c[13] - c[8];
158 Double_t c20=fX*c[10] - c[3], c21=fX*c[11] - c[4], c42=fX*c[14] - c[12];
161 fCzy=c[1 ]; fCzz=c[2 ];
162 fCcy=c[10]; fCcz=c[11]; fCcc=c[14];
163 fCey=c20; fCez=c21; fCec=c42; fCee=c22;
164 fCty=c[6 ]; fCtz=c[7 ]; fCtc=c[13]; fCte=c32; fCtt=c[9 ];
168 //____________________________________________________________________________
169 void AliTRDtrack::GetExternalParameters(Double_t& xr, Double_t x[5]) const {
171 // This function returns external TRD track representation
178 x[4]=fC*GetConvConst();
181 //_____________________________________________________________________________
182 void AliTRDtrack::GetExternalCovariance(Double_t cc[15]) const {
184 // This function returns external representation of the covriance matrix.
186 Double_t a=GetConvConst();
188 Double_t c22=fX*fX*fCcc-2*fX*fCec+fCee;
189 Double_t c32=fX*fCtc-fCte;
190 Double_t c20=fX*fCcy-fCey, c21=fX*fCcz-fCez, c42=fX*fCcc-fCec;
193 cc[1 ]=fCzy; cc[2 ]=fCzz;
194 cc[3 ]=c20; cc[4 ]=c21; cc[5 ]=c22;
195 cc[6 ]=fCty; cc[7 ]=fCtz; cc[8 ]=c32; cc[9 ]=fCtt;
196 cc[10]=fCcy*a; cc[11]=fCcz*a; cc[12]=c42*a; cc[13]=fCtc*a; cc[14]=fCcc*a*a;
200 //_____________________________________________________________________________
201 void AliTRDtrack::GetCovariance(Double_t cc[15]) const {
203 cc[1]=fCzy; cc[2]=fCzz;
204 cc[3]=fCcy; cc[4]=fCcz; cc[5]=fCcc;
205 cc[6]=fCey; cc[7]=fCez; cc[8]=fCec; cc[9]=fCee;
206 cc[10]=fCty; cc[11]=fCtz; cc[12]=fCtc; cc[13]=fCte; cc[14]=fCtt;
209 //_____________________________________________________________________________
210 Int_t AliTRDtrack::Compare(const TObject *o) const {
212 // Compares tracks according to their Y2 or curvature
214 AliTRDtrack *t=(AliTRDtrack*)o;
215 // Double_t co=t->GetSigmaY2();
216 // Double_t c =GetSigmaY2();
218 Double_t co=TMath::Abs(t->GetC());
219 Double_t c =TMath::Abs(GetC());
222 else if (c<co) return -1;
226 //_____________________________________________________________________________
227 void AliTRDtrack::CookdEdx(Double_t low, Double_t up) {
228 //-----------------------------------------------------------------
229 // Calculates dE/dX within the "low" and "up" cuts.
230 //-----------------------------------------------------------------
233 Int_t nc=GetNumberOfClusters();
235 Float_t sorted[kMAX_CLUSTERS_PER_TRACK];
236 for (i=0; i < nc; i++) {
244 for (i=0; i<nc-1; i++) {
245 if (sorted[i]<=sorted[i+1]) continue;
246 Float_t tmp=sorted[i];
247 sorted[i]=sorted[i+1]; sorted[i+1]=tmp;
252 Int_t nl=Int_t(low*nc), nu=Int_t(up*nc);
254 for (i=nl; i<=nu; i++) dedx += sorted[i];
262 //_____________________________________________________________________________
263 Int_t AliTRDtrack::PropagateTo(Double_t xk,Double_t x0,Double_t rho,Double_t pm)
265 // Propagates a track of particle with mass=pm to a reference plane
266 // defined by x=xk through media of density=rho and radiationLength=x0
269 if (TMath::Abs(fC*xk - fE) >= 0.99999) {
270 Int_t n=GetNumberOfClusters();
271 if (n>4) cerr<<n<<" AliTRDtrack warning: Propagation failed !\n";
275 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1, y1=fY, z1=fZ;
276 Double_t c1=fC*x1 - fE;
277 if((c1*c1) > 1) return 0;
278 Double_t r1=sqrt(1.- c1*c1);
279 Double_t c2=fC*x2 - fE;
280 if((c2*c2) > 1) return 0;
281 Double_t r2=sqrt(1.- c2*c2);
283 fY += dx*(c1+c2)/(r1+r2);
284 fZ += dx*(c1+c2)/(c1*r2 + c2*r1)*fT;
287 Double_t rr=r1+r2, cc=c1+c2, xx=x1+x2;
288 Double_t f02= dx*(rr*xx + cc*(c1*x1/r1+c2*x2/r2))/(rr*rr);
289 Double_t f03=-dx*(2*rr + cc*(c1/r1 + c2/r2))/(rr*rr);
290 Double_t cr=c1*r2+c2*r1;
291 Double_t f12= dx*fT*(cr*xx-cc*(r1*x2-c2*c1*x1/r1+r2*x1-c1*c2*x2/r2))/(cr*cr);
292 Double_t f13=-dx*fT*(2*cr + cc*(c2*c1/r1-r1 + c1*c2/r2-r2))/(cr*cr);
293 Double_t f14= dx*cc/cr;
296 Double_t b00=f02*fCcy + f03*fCey, b01=f12*fCcy + f13*fCey + f14*fCty;
297 Double_t b10=f02*fCcz + f03*fCez, b11=f12*fCcz + f13*fCez + f14*fCtz;
298 Double_t b20=f02*fCcc + f03*fCec, b21=f12*fCcc + f13*fCec + f14*fCtc;
299 Double_t b30=f02*fCec + f03*fCee, b31=f12*fCec + f13*fCee + f14*fCte;
300 Double_t b40=f02*fCtc + f03*fCte, b41=f12*fCtc + f13*fCte + f14*fCtt;
303 Double_t a00=f02*b20+f03*b30,a01=f02*b21+f03*b31,a11=f12*b21+f13*b31+f14*b41;
305 //F*C*Ft = C + (a + b + bt)
307 fCzy += a01 + b01 + b10;
319 //Multiple scattering ******************
321 Double_t d=sqrt((x1-fX)*(x1-fX)+(y1-fY)*(y1-fY)+(z1-fZ)*(z1-fZ));
322 Double_t p2=GetPt()*GetPt()*(1.+fT*fT);
323 p2 = TMath::Min(p2,1e+08); // to avoid division by (1-1) for stiff tracks
324 Double_t beta2=p2/(p2 + pm*pm);
326 Double_t ey=fC*fX - fE, ez=fT;
327 Double_t xz=fC*ez, zz1=ez*ez+1, xy=fE+ey;
329 Double_t theta2=14.1*14.1/(beta2*p2*1e6)*d/x0*rho;
330 fCcc += xz*xz*theta2;
331 fCec += xz*ez*xy*theta2;
332 fCtc += xz*zz1*theta2;
333 fCee += (2*ey*ez*ez*fE+1-ey*ey+ez*ez+fE*fE*ez*ez)*theta2;
334 fCte += ez*zz1*xy*theta2;
335 fCtt += zz1*zz1*theta2;
338 //Energy losses************************
340 Double_t dE=0.153e-3/beta2*(log(5940*beta2/(1-beta2)) - beta2)*d*rho;
341 //PH SetLength(GetLength()+d);
344 fC*=(1.- sqrt(p2+pm*pm)/p2*dE);
351 //_____________________________________________________________________________
352 Int_t AliTRDtrack::Update(const AliTRDcluster *c, Double_t chisq, UInt_t index)
354 // Assignes found cluster to the track and updates track information
356 Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
357 r00+=fCyy; r01+=fCzy; r11+=fCzz;
358 Double_t det=r00*r11 - r01*r01;
359 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
361 Double_t k00=fCyy*r00+fCzy*r01, k01=fCyy*r01+fCzy*r11;
362 Double_t k10=fCzy*r00+fCzz*r01, k11=fCzy*r01+fCzz*r11;
363 Double_t k20=fCcy*r00+fCcz*r01, k21=fCcy*r01+fCcz*r11;
364 Double_t k30=fCey*r00+fCez*r01, k31=fCey*r01+fCez*r11;
365 Double_t k40=fCty*r00+fCtz*r01, k41=fCty*r01+fCtz*r11;
367 Double_t dy=c->GetY() - fY, dz=c->GetZ() - fZ;
368 Double_t cur=fC + k20*dy + k21*dz, eta=fE + k30*dy + k31*dz;
369 if (TMath::Abs(cur*fX-eta) >= 0.99999) {
370 Int_t n=GetNumberOfClusters();
371 if (n>4) cerr<<n<<" AliTRDtrack warning: Filtering failed !\n";
375 fY += k00*dy + k01*dz;
376 fZ += k10*dy + k11*dz;
379 fT += k40*dy + k41*dz;
381 Double_t c01=fCzy, c02=fCcy, c03=fCey, c04=fCty;
382 Double_t c12=fCcz, c13=fCez, c14=fCtz;
384 fCyy-=k00*fCyy+k01*fCzy; fCzy-=k00*c01+k01*fCzz;
385 fCcy-=k00*c02+k01*c12; fCey-=k00*c03+k01*c13;
386 fCty-=k00*c04+k01*c14;
388 fCzz-=k10*c01+k11*fCzz;
389 fCcz-=k10*c02+k11*c12; fCez-=k10*c03+k11*c13;
390 fCtz-=k10*c04+k11*c14;
392 fCcc-=k20*c02+k21*c12; fCec-=k20*c03+k21*c13;
393 fCtc-=k20*c04+k21*c14;
395 fCee-=k30*c03+k31*c13;
396 fCte-=k30*c04+k31*c14;
398 fCtt-=k40*c04+k41*c14;
400 Int_t n=GetNumberOfClusters();
402 SetNumberOfClusters(n+1);
404 SetChi2(GetChi2()+chisq);
405 // cerr<<"in update: fIndex["<<fN<<"] = "<<index<<endl;
410 //_____________________________________________________________________________
411 Int_t AliTRDtrack::Rotate(Double_t alpha)
413 // Rotates track parameters in R*phi plane
417 Double_t x1=fX, y1=fY;
418 Double_t ca=cos(alpha), sa=sin(alpha);
419 Double_t r1=fC*fX - fE;
421 if (TMath::Abs(r1) >= 0.99999) {
422 Int_t n=GetNumberOfClusters();
423 if (n>4) cerr<<n<<" AliTRDtrack warning: Rotation failed !\n";
429 fE=fE*ca + (fC*y1 + sqrt(1.- r1*r1))*sa;
431 Double_t r2=fC*fX - fE;
432 if (TMath::Abs(r2) >= 0.99999) {
433 Int_t n=GetNumberOfClusters();
434 if (n>4) cerr<<n<<" AliTRDtrack warning: Rotation failed !\n";
438 Double_t y0=fY + sqrt(1.- r2*r2)/fC;
439 if ((fY-y0)*fC >= 0.) {
440 Int_t n=GetNumberOfClusters();
441 if (n>4) cerr<<n<<" AliTRDtrack warning: Rotation failed !!!\n";
446 Double_t f00=ca-1, f32=(y1 - r1*x1/sqrt(1.- r1*r1))*sa,
447 f30=fC*sa, f33=(ca + sa*r1/sqrt(1.- r1*r1))-1;
450 Double_t b00=fCyy*f00, b03=fCyy*f30+fCcy*f32+fCey*f33;
451 Double_t b10=fCzy*f00, b13=fCzy*f30+fCcz*f32+fCez*f33;
452 Double_t b20=fCcy*f00, b23=fCcy*f30+fCcc*f32+fCec*f33;
453 Double_t b30=fCey*f00, b33=fCey*f30+fCec*f32+fCee*f33;
454 Double_t b40=fCty*f00, b43=fCty*f30+fCtc*f32+fCte*f33;
457 Double_t a00=f00*b00, a03=f00*b03, a33=f30*b03+f32*b23+f33*b33;
459 // *** Double_t dy2=fCyy;
461 //F*C*Ft = C + (a + b + bt)
472 // *** fCyy+=dy2*sa*sa*r1*r1/(1.- r1*r1);
473 // *** fCzz+=d2y*sa*sa*fT*fT/(1.- r1*r1);
479 //_____________________________________________________________________________
480 Double_t AliTRDtrack::GetPredictedChi2(const AliTRDcluster *c) const
483 Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
484 r00+=fCyy; r01+=fCzy; r11+=fCzz;
486 Double_t det=r00*r11 - r01*r01;
487 if (TMath::Abs(det) < 1.e-10) {
488 if (fN>4) cerr<<fN<<" AliTRDtrack warning: Singular matrix !\n";
491 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
493 Double_t dy=c->GetY() - fY, dz=c->GetZ() - fZ;
495 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
498 Double_t dy=c->GetY() - fY;
499 Double_t r00=c->GetSigmaY2();
506 //_________________________________________________________________________
507 void AliTRDtrack::GetPxPyPz(Double_t& px, Double_t& py, Double_t& pz) const
509 // Returns reconstructed track momentum in the global system.
511 Double_t pt=TMath::Abs(GetPt()); // GeV/c
515 if(r > 1) { py = pt; px = 0; }
516 else if(r < -1) { py = -pt; px = 0; }
518 y0=fY + sqrt(1.- r*r)/fC;
519 px=-pt*(fY-y0)*fC; //cos(phi);
520 py=-pt*(fE-fX*fC); //sin(phi);
523 Double_t tmp=px*TMath::Cos(fAlpha) - py*TMath::Sin(fAlpha);
524 py=px*TMath::Sin(fAlpha) + py*TMath::Cos(fAlpha);
529 //_________________________________________________________________________
530 void AliTRDtrack::GetGlobalXYZ(Double_t& x, Double_t& y, Double_t& z) const
532 // Returns reconstructed track coordinates in the global system.
534 x = fX; y = fY; z = fZ;
535 Double_t tmp=x*TMath::Cos(fAlpha) - y*TMath::Sin(fAlpha);
536 y=x*TMath::Sin(fAlpha) + y*TMath::Cos(fAlpha);
541 //_________________________________________________________________________
542 void AliTRDtrack::ResetCovariance() {
544 // Resets covariance matrix
549 fCcy=0.; fCcz=0.; fCcc*=10.;
550 fCey=0.; fCez=0.; fCec=0.; fCee*=10.;
551 fCty=0.; fCtz=0.; fCtc=0.; fCte=0.; fCtt*=10.;