removal of effective c++ warnings (C.Zampolli)+ use of additional calib parameters...
[u/mrichter/AliRoot.git] / TOF / AliTOFtrack.cxx
CommitLineData
74ea065c 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 **************************************************************************/
74ea065c 15
0e46b9ae 16/* $Id$ */
d3c7bfac 17
0e46b9ae 18/////////////////////////////////////////////////////////////////////////////
19// //
20// AliTOFtrack class //
21// //
22// Authors: Bologna-CERN-ITEP-Salerno Group //
23// //
24// Description: class for handling ESD extracted tracks for TOF matching. //
25// //
26/////////////////////////////////////////////////////////////////////////////
d3c7bfac 27
74ea065c 28#include "AliESDtrack.h"
0e46b9ae 29#include "AliLog.h"
74ea065c 30
d3c7bfac 31#include "AliTOFGeometryV4.h"
0e46b9ae 32#include "AliTOFGeometry.h"
d3c7bfac 33#include "AliTOFtrack.h"
34
74ea065c 35ClassImp(AliTOFtrack)
36
37//_____________________________________________________________________________
38AliTOFtrack::AliTOFtrack(const AliTOFtrack& t) : AliKalmanTrack(t) {
39 //
40 // Copy constructor.
41 //
42
43 SetSeedIndex(t.GetSeedIndex());
44 SetLabel(t.GetLabel());
45 fSeedLab=t.GetSeedLabel();
46 SetChi2(t.GetChi2());
47
48 fAlpha=t.fAlpha;
49 fX=t.fX;
50
51 fY=t.fY; fZ=t.fZ; fE=t.fE; fT=t.fT; fC=t.fC;
52
53 fCyy=t.fCyy;
54 fCzy=t.fCzy; fCzz=t.fCzz;
55 fCey=t.fCey; fCez=t.fCez; fCee=t.fCee;
56 fCty=t.fCty; fCtz=t.fCtz; fCte=t.fCte; fCtt=t.fCtt;
57 fCcy=t.fCcy; fCcz=t.fCcz; fCce=t.fCce; fCct=t.fCct; fCcc=t.fCcc;
58
d3c7bfac 59 fTOFgeometry = new AliTOFGeometryV4();
74ea065c 60
61}
62
63//_____________________________________________________________________________
64AliTOFtrack::AliTOFtrack(const AliESDtrack& t)
65 :AliKalmanTrack() {
66 //
67 // Constructor from AliESDtrack
68 //
69
d3c7bfac 70 fTOFgeometry = new AliTOFGeometryV4();
71
74ea065c 72 SetSeedIndex(-1);
73 SetLabel(t.GetLabel());
74 SetChi2(0.);
75 SetMass(t.GetMass());
76
77 fAlpha = t.GetAlpha();
78 if (fAlpha < -TMath::Pi()) fAlpha += 2*TMath::Pi();
79 else if (fAlpha >= TMath::Pi()) fAlpha -= 2*TMath::Pi();
80 Double_t x, p[5]; t.GetExternalParameters(x,p);
81
82 fX=x;
83
74ea065c 84 fY=p[0];
c84a5e9e 85 fZ=p[1]; SaveLocalConvConst();
86 fT=p[3]; x=GetLocalConvConst();
74ea065c 87 fC=p[4]/x;
88 fE=fC*fX - p[2];
89
90 //Conversion of the covariance matrix
91 Double_t c[15]; t.GetExternalCovariance(c);
92
93 c[10]/=x; c[11]/=x; c[12]/=x; c[13]/=x; c[14]/=x*x;
94
95 Double_t c22=fX*fX*c[14] - 2*fX*c[12] + c[5];
96 Double_t c32=fX*c[13] - c[8];
97 Double_t c20=fX*c[10] - c[3], c21=fX*c[11] - c[4], c42=fX*c[14] - c[12];
98
99 fCyy=c[0 ];
100 fCzy=c[1 ]; fCzz=c[2 ];
101 fCey=c20; fCez=c21; fCee=c22;
102 fCty=c[6 ]; fCtz=c[7 ]; fCte=c32; fCtt=c[9 ];
103 fCcy=c[10]; fCcz=c[11]; fCce=c42; fCct=c[13]; fCcc=c[14];
104
105 if ((t.GetStatus()&AliESDtrack::kTIME) == 0) return;
106 StartTimeIntegral();
107 Double_t times[10]; t.GetIntegratedTimes(times); SetIntegratedTimes(times);
108 SetIntegratedLength(t.GetIntegratedLength());
109
110
111}
7aeeaf38 112
113//____________________________________________________________________________
114AliTOFtrack& AliTOFtrack::operator=(const AliTOFtrack &source)
115{
116 // ass. op.
117
118 this->fTOFgeometry=source.fTOFgeometry;
119 return *this;
120
121}
122
74ea065c 123//____________________________________________________________________________
124void AliTOFtrack::GetExternalParameters(Double_t& xr, Double_t x[5]) const {
125 //
126 // This function returns external TOF track representation
127 //
128 xr=fX;
129 x[0]=GetY();
130 x[1]=GetZ();
131 x[2]=GetSnp();
132 x[3]=GetTgl();
133 x[4]=Get1Pt();
134}
135
136//_____________________________________________________________________________
137void AliTOFtrack::GetExternalCovariance(Double_t cc[15]) const {
138 //
139 // This function returns external representation of the covriance matrix.
140 //
c84a5e9e 141 Double_t a=GetLocalConvConst();
74ea065c 142 Double_t c22=fX*fX*fCcc-2*fX*fCce+fCee;
143 Double_t c32=fX*fCct-fCte;
144 Double_t c20=fX*fCcy-fCey, c21=fX*fCcz-fCez, c42=fX*fCcc-fCce;
145
146 cc[0 ]=fCyy;
147 cc[1 ]=fCzy; cc[2 ]=fCzz;
148 cc[3 ]=c20; cc[4 ]=c21; cc[5 ]=c22;
149 cc[6 ]=fCty; cc[7 ]=fCtz; cc[8 ]=c32; cc[9 ]=fCtt;
150 cc[10]=fCcy*a; cc[11]=fCcz*a; cc[12]=c42*a; cc[13]=fCct*a; cc[14]=fCcc*a*a;
151
152}
153
154
155//_____________________________________________________________________________
156void AliTOFtrack::GetCovariance(Double_t cc[15]) const {
2c770f53 157 //
158 // Returns the covariance matrix.
159 //
74ea065c 160
161 cc[0]=fCyy;
162 cc[1]=fCzy; cc[2]=fCzz;
163 cc[3]=fCey; cc[4]=fCez; cc[5]=fCee;
164 cc[6]=fCcy; cc[7]=fCcz; cc[8]=fCce; cc[9]=fCcc;
165 cc[10]=fCty; cc[11]=fCtz; cc[12]=fCte; cc[13]=fCct; cc[14]=fCtt;
166
167}
168
169
170//_____________________________________________________________________________
171Int_t AliTOFtrack::PropagateTo(Double_t xk,Double_t x0,Double_t rho)
172{
173 // Propagates a track of particle with mass=pm to a reference plane
174 // defined by x=xk through media of density=rho and radiationLength=x0
175
176 if (xk == fX) return 1;
177
178 if (TMath::Abs(fC*xk - fE) >= 0.90000) {
179 return 0;
180 }
c84a5e9e 181 Double_t lcc=GetLocalConvConst();
74ea065c 182
183 // track Length measurement [SR, GSI, 17.02.2003]
184
185 Double_t oldX = fX, oldY = fY, oldZ = fZ;
186
187 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1, y1=fY, z1=fZ;
188 Double_t c1=fC*x1 - fE;
189 if((c1*c1) > 1){
190 return 0;}
191 Double_t r1=sqrt(1.- c1*c1);
192 Double_t c2=fC*x2 - fE;
193 if((c2*c2) > 1) {
194 return 0;
195 }
196 Double_t r2=sqrt(1.- c2*c2);
197
198 fY += dx*(c1+c2)/(r1+r2);
199 fZ += dx*(c1+c2)/(c1*r2 + c2*r1)*fT;
200
201 //f = F - 1
202 Double_t rr=r1+r2, cc=c1+c2, xx=x1+x2;
203 Double_t f02=-dx*(2*rr + cc*(c1/r1 + c2/r2))/(rr*rr);
204 Double_t f04= dx*(rr*xx + cc*(c1*x1/r1+c2*x2/r2))/(rr*rr);
205 Double_t cr=c1*r2+c2*r1;
206 Double_t f12=-dx*fT*(2*cr + cc*(c2*c1/r1-r1 + c1*c2/r2-r2))/(cr*cr);
207 Double_t f13= dx*cc/cr;
208 Double_t f14=dx*fT*(cr*xx-cc*(r1*x2-c2*c1*x1/r1+r2*x1-c1*c2*x2/r2))/(cr*cr);
209
210 //b = C*ft
211 Double_t b00=f02*fCey + f04*fCcy, b01=f12*fCey + f14*fCcy + f13*fCty;
212 Double_t b10=f02*fCez + f04*fCcz, b11=f12*fCez + f14*fCcz + f13*fCtz;
213 Double_t b20=f02*fCee + f04*fCce, b21=f12*fCee + f14*fCce + f13*fCte;
214 Double_t b30=f02*fCte + f04*fCct, b31=f12*fCte + f14*fCct + f13*fCtt;
215 Double_t b40=f02*fCce + f04*fCcc, b41=f12*fCce + f14*fCcc + f13*fCct;
216
217 //a = f*b = f*C*ft
218 Double_t a00=f02*b20+f04*b40,a01=f02*b21+f04*b41,a11=f12*b21+f14*b41+f13*b31;
219
220 //F*C*Ft = C + (a + b + bt)
221 fCyy += a00 + 2*b00;
222 fCzy += a01 + b01 + b10;
223 fCey += b20;
224 fCty += b30;
225 fCcy += b40;
226 fCzz += a11 + 2*b11;
227 fCez += b21;
228 fCtz += b31;
229 fCcz += b41;
230
231 fX=x2;
232
c84a5e9e 233 //Change of the magnetic field *************
234 SaveLocalConvConst();
235 cc=fC;
236 fC*=lcc/GetLocalConvConst();
237 fE+=fX*(fC-cc);
238
74ea065c 239 //Multiple scattering ******************
240 Double_t d=sqrt((x1-fX)*(x1-fX)+(y1-fY)*(y1-fY)+(z1-fZ)*(z1-fZ));
241 Double_t p2=(1.+ GetTgl()*GetTgl())/(Get1Pt()*Get1Pt());
242 Double_t beta2=p2/(p2 + GetMass()*GetMass());
243 Double_t theta2=14.1*14.1/(beta2*p2*1e6)*d/x0*rho;
244
245 Double_t ey=fC*fX - fE, ez=fT;
246 Double_t xz=fC*ez, zz1=ez*ez+1, xy=fE+ey;
247
248 fCee += (2*ey*ez*ez*fE+1-ey*ey+ez*ez+fE*fE*ez*ez)*theta2;
249 fCte += ez*zz1*xy*theta2;
250 fCtt += zz1*zz1*theta2;
251 fCce += xz*ez*xy*theta2;
252 fCct += xz*zz1*theta2;
253 fCcc += xz*xz*theta2;
254 /*
255 Double_t dc22 = (1-ey*ey+xz*xz*fX*fX)*theta2;
256 Double_t dc32 = (xz*fX*zz1)*theta2;
257 Double_t dc33 = (zz1*zz1)*theta2;
258 Double_t dc42 = (xz*fX*xz)*theta2;
259 Double_t dc43 = (zz1*xz)*theta2;
260 Double_t dc44 = (xz*xz)*theta2;
261 fCee += dc22;
262 fCte += dc32;
263 fCtt += dc33;
264 fCce += dc42;
265 fCct += dc43;
266 fCcc += dc44;
267 */
268 //Energy losses************************
269 if((5940*beta2/(1-beta2+1e-10) - beta2) < 0){return 0;}
270
271 Double_t dE=0.153e-3/beta2*(log(5940*beta2/(1-beta2+1e-10)) - beta2)*d*rho;
983ebc4f 272 //
273 // suspicious part - think about it ?
274 Double_t kinE = TMath::Sqrt(p2);
275 if (dE>0.8*kinE) dE = 0.8*kinE; //
276 if (dE<0) dE = 0.0; // not valid region for Bethe bloch
277 //
278 //
74ea065c 279 if (x1 < x2) dE=-dE;
280 cc=fC;
281 fC*=(1.- sqrt(p2+GetMass()*GetMass())/p2*dE);
282 fE+=fX*(fC-cc);
283
284 // track time measurement [SR, GSI 17.02.2002]
285 if (x1 < x2)
286 if (IsStartedTimeIntegral()) {
287 Double_t l2 = (fX-oldX)*(fX-oldX) + (fY-oldY)*(fY-oldY) + (fZ-oldZ)*(fZ-oldZ);
288 AddTimeStep(TMath::Sqrt(l2));
289 }
290
291 return 1;
292}
293
294//_____________________________________________________________________________
295Int_t AliTOFtrack::PropagateToInnerTOF( Bool_t holes)
296{
297 // Propagates a track of particle with mass=pm to a reference plane
298 // defined by x=xk through media of density=rho and radiationLength=x0
299
300
d3c7bfac 301 Double_t ymax=fTOFgeometry->RinTOF()*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
74ea065c 302 Bool_t skip = kFALSE;
d3c7bfac 303 Double_t y=GetYat(fTOFgeometry->RinTOF(),skip);
74ea065c 304 if(skip){
305 return 0;
306 }
307 if (y > ymax) {
2c770f53 308 if (!Rotate(AliTOFGeometry::GetAlpha())) {
74ea065c 309 return 0;
310 }
311 } else if (y <-ymax) {
2c770f53 312 if (!Rotate(-AliTOFGeometry::GetAlpha())) {
74ea065c 313 return 0;
314 }
315 }
316
317
2c770f53 318 Double_t x = GetX();
74ea065c 319 Int_t nsteps=Int_t((370.-x)/0.5); // 0.5 cm Steps
320 for (Int_t istep=0;istep<nsteps;istep++){
321 Float_t xp = x+istep*0.5;
322 Double_t param[2];
2c770f53 323 GetPropagationParameters(holes,param);
324 PropagateTo(xp,param[0],param[1]);
74ea065c 325
326 }
327
d3c7bfac 328 if(!PropagateTo(fTOFgeometry->RinTOF()))return 0;
74ea065c 329
330 return 1;
331
332}
333
334//_____________________________________________________________________________
335Int_t AliTOFtrack::Rotate(Double_t alpha)
336{
337 // Rotates track parameters in R*phi plane
338
339
340 fAlpha += alpha;
341 if (fAlpha<-TMath::Pi()) fAlpha += 2*TMath::Pi();
342 if (fAlpha>=TMath::Pi()) fAlpha -= 2*TMath::Pi();
343
344 Double_t x1=fX, y1=fY;
345 Double_t ca=cos(alpha), sa=sin(alpha);
346 Double_t r1=fC*fX - fE;
347
348 fX = x1*ca + y1*sa;
349 fY =-x1*sa + y1*ca;
350 if((r1*r1) > 1) return 0;
351 fE=fE*ca + (fC*y1 + sqrt(1.- r1*r1))*sa;
352
353 Double_t r2=fC*fX - fE;
354 if (TMath::Abs(r2) >= 0.90000) {
d076c8d5 355 AliWarning("Rotation failed !");
74ea065c 356 return 0;
357 }
358
359 if((r2*r2) > 1) return 0;
360 Double_t y0=fY + sqrt(1.- r2*r2)/fC;
361 if ((fY-y0)*fC >= 0.) {
d076c8d5 362 AliWarning("Rotation failed !!!");
74ea065c 363 return 0;
364 }
365
366 //f = F - 1
367 Double_t f00=ca-1, f24=(y1 - r1*x1/sqrt(1.- r1*r1))*sa,
368 f20=fC*sa, f22=(ca + sa*r1/sqrt(1.- r1*r1))-1;
369
370 //b = C*ft
371 Double_t b00=fCyy*f00, b02=fCyy*f20+fCcy*f24+fCey*f22;
372 Double_t b10=fCzy*f00, b12=fCzy*f20+fCcz*f24+fCez*f22;
373 Double_t b20=fCey*f00, b22=fCey*f20+fCce*f24+fCee*f22;
374 Double_t b30=fCty*f00, b32=fCty*f20+fCct*f24+fCte*f22;
375 Double_t b40=fCcy*f00, b42=fCcy*f20+fCcc*f24+fCce*f22;
376
377 //a = f*b = f*C*ft
378 Double_t a00=f00*b00, a02=f00*b02, a22=f20*b02+f24*b42+f22*b22;
379
380 //F*C*Ft = C + (a + b + bt)
381 fCyy += a00 + 2*b00;
382 fCzy += b10;
383 fCey += a02+b20+b02;
384 fCty += b30;
385 fCcy += b40;
386 fCez += b12;
387 fCte += b32;
388 fCee += a22 + 2*b22;
389 fCce += b42;
390
391 return 1;
392}
393
2c770f53 394//_________________________________________________________________________
4668c628 395Double_t AliTOFtrack::GetYat(Double_t xk, Bool_t & skip) const {
2c770f53 396//-----------------------------------------------------------------
397// This function calculates the Y-coordinate of a track at the plane x=xk.
398// Needed for matching with the TOF (I.Belikov)
399//-----------------------------------------------------------------
400 skip=kFALSE;
401 Double_t c1=fC*fX - fE, r1=TMath::Sqrt(TMath::Abs(1.- c1*c1));
402 Double_t c2=fC*xk - fE, r2=TMath::Sqrt(TMath::Abs(1.- c2*c2));
403 if( ((1.- c2*c2)<0) || ((1.- c1*c1)<0) ) skip=kTRUE;
404 return fY + (xk-fX)*(c1+c2)/(r1+r2);
405}
74ea065c 406//_________________________________________________________________________
407void AliTOFtrack::GetPxPyPz(Double_t& px, Double_t& py, Double_t& pz) const
408{
409 // Returns reconstructed track momentum in the global system.
410
411 Double_t pt=TMath::Abs(GetPt()); // GeV/c
412 Double_t r=fC*fX-fE;
413
414 Double_t y0;
415 if(r > 1) { py = pt; px = 0; }
416 else if(r < -1) { py = -pt; px = 0; }
417 else {
418 y0=fY + sqrt(1.- r*r)/fC;
419 px=-pt*(fY-y0)*fC; //cos(phi);
420 py=-pt*(fE-fX*fC); //sin(phi);
421 }
422 pz=pt*fT;
423 Double_t tmp=px*TMath::Cos(fAlpha) - py*TMath::Sin(fAlpha);
424 py=px*TMath::Sin(fAlpha) + py*TMath::Cos(fAlpha);
425 px=tmp;
426
427}
428
429//_________________________________________________________________________
430void AliTOFtrack::GetGlobalXYZ(Double_t& x, Double_t& y, Double_t& z) const
431{
432 // Returns reconstructed track coordinates in the global system.
433
434 x = fX; y = fY; z = fZ;
435 Double_t tmp=x*TMath::Cos(fAlpha) - y*TMath::Sin(fAlpha);
436 y=x*TMath::Sin(fAlpha) + y*TMath::Cos(fAlpha);
437 x=tmp;
438
439}
440
441//_________________________________________________________________________
442void AliTOFtrack::ResetCovariance() {
443 //
444 // Resets covariance matrix
445 //
446
447 fCyy*=10.;
448 fCzy=0.; fCzz*=10.;
449 fCey=0.; fCez=0.; fCee*=10.;
450 fCty=0.; fCtz=0.; fCte=0.; fCtt*=10.;
451 fCcy=0.; fCcz=0.; fCce=0.; fCct=0.; fCcc*=10.;
452}
453
454
455//_________________________________________________________________________
456void AliTOFtrack::ResetCovariance(Float_t mult) {
457 //
458 // Resets covariance matrix
459 //
460
461 fCyy*=mult;
462 fCzy*=0.; fCzz*=mult;
463 fCey*=0.; fCez*=0.; fCee*=mult;
464 fCty*=0.; fCtz*=0.; fCte*=0.; fCtt*=mult;
465 fCcy*=0.; fCcz*=0.; fCce*=0.; fCct*=0.; fCcc*=mult;
466}
467
468//_____________________________________________________________________________
469Int_t AliTOFtrack::Compare(const TObject *o) const {
470 //-----------------------------------------------------------------
471 // This function compares tracks according to the their curvature
472 //-----------------------------------------------------------------
473 AliTOFtrack *t=(AliTOFtrack*)o;
474 Double_t co=t->GetSigmaY2()*t->GetSigmaZ2();
475 Double_t c =GetSigmaY2()*GetSigmaZ2();
476 if (c>co) return 1;
477 else if (c<co) return -1;
478 return 0;
479}
480
481//_____________________________________________________________________________
482void AliTOFtrack::GetPropagationParameters(Bool_t holes, Double_t *param) {
483
2c770f53 484 //Get average medium density, x0 while propagating the track
485
486 //For TRD holes description
74ea065c 487
488 Double_t thetamin = (90.-31.1) * TMath::Pi()/180.;
489 Double_t thetamax = (90.+31.1) * TMath::Pi()/180.;
490
491 Double_t zmin = -55.;
492 Double_t zmax = 55.;
493
2c770f53 494 // Detector inner/outer radii
74ea065c 495 Double_t rTPC = 261.53;
496 Double_t rTPCTRD = 294.5;
497 Double_t rTRD = 369.1;
498
2c770f53 499 // Medium parameters
74ea065c 500 Double_t x0TPC = 40.;
501 Double_t rhoTPC =0.06124;
502
503 Double_t x0Air = 36.66;
504 Double_t rhoAir =1.2931e-3;
505
506 Double_t x0TRD = 171.7;
507 Double_t rhoTRD =0.33;
508
2c770f53 509 Int_t isec = GetSector();
74ea065c 510 Double_t xtr,ytr,ztr;
2c770f53 511 GetGlobalXYZ(xtr,ytr,ztr);
74ea065c 512 Float_t thetatr = TMath::ATan2(TMath::Sqrt(xtr*xtr+ytr*ytr),ztr);
513
514 if(holes){
515 if (isec == 0 || isec == 1 || isec == 2 ) {
516 if( thetatr>=thetamin && thetatr<=thetamax){
517 x0TRD= x0Air;
518 rhoTRD = rhoAir;
519 }
520 }
521 if (isec == 11 || isec == 12 || isec == 13 || isec == 14 || isec == 15 ) {
522 if( ztr>=zmin && ztr<=zmax){
523 x0TRD= x0Air;
524 rhoTRD = rhoAir;
525 }
526 }
527 }
528
2c770f53 529 if(GetX() <= rTPC)
74ea065c 530 {param[0]=x0TPC;param[1]=rhoTPC;}
2c770f53 531 else if(GetX() > rTPC && GetX() < rTPCTRD)
74ea065c 532 {param[0]=x0Air;param[1]=rhoAir;}
2c770f53 533 else if(GetX() >= rTPCTRD && GetX() < rTRD)
74ea065c 534 {param[0]=x0TRD;param[1]=rhoTRD;}
2c770f53 535 else if(GetX() >= rTRD )
74ea065c 536 {param[0]=x0Air;param[1]=rhoAir;}
74ea065c 537}