Correct layer index for LayerSize() and LayerName() methods
[u/mrichter/AliRoot.git] / STEER / AliExternalTrackParam.cxx
CommitLineData
51ad6848 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/* $Id$ */
17
18///////////////////////////////////////////////////////////////////////////////
19// //
49d13e89 20// Implementation of the external track parameterisation class. //
51ad6848 21// //
49d13e89 22// This parameterisation is used to exchange tracks between the detectors. //
23// A set of functions returning the position and the momentum of tracks //
24// in the global coordinate system as well as the track impact parameters //
25// are implemented.
26// Origin: I.Belikov, CERN, Jouri.Belikov@cern.ch //
51ad6848 27///////////////////////////////////////////////////////////////////////////////
51ad6848 28#include "AliExternalTrackParam.h"
29#include "AliKalmanTrack.h"
5b77d93c 30#include "AliTracker.h"
31
51ad6848 32
33ClassImp(AliExternalTrackParam)
34
51ad6848 35//_____________________________________________________________________________
90e48c0c 36AliExternalTrackParam::AliExternalTrackParam() :
90e48c0c 37 fX(0),
c9ec41e8 38 fAlpha(0)
51ad6848 39{
90e48c0c 40 //
41 // default constructor
42 //
c9ec41e8 43 for (Int_t i = 0; i < 5; i++) fP[i] = 0;
44 for (Int_t i = 0; i < 15; i++) fC[i] = 0;
51ad6848 45}
46
47//_____________________________________________________________________________
48AliExternalTrackParam::AliExternalTrackParam(Double_t x, Double_t alpha,
49 const Double_t param[5],
90e48c0c 50 const Double_t covar[15]) :
90e48c0c 51 fX(x),
c9ec41e8 52 fAlpha(alpha)
51ad6848 53{
90e48c0c 54 //
55 // create external track parameters from given arguments
56 //
c9ec41e8 57 for (Int_t i = 0; i < 5; i++) fP[i] = param[i];
58 for (Int_t i = 0; i < 15; i++) fC[i] = covar[i];
51ad6848 59}
60
90e48c0c 61//_____________________________________________________________________________
62AliExternalTrackParam::AliExternalTrackParam(const AliKalmanTrack& track) :
c9ec41e8 63 fAlpha(track.GetAlpha())
51ad6848 64{
65 //
66 //
c9ec41e8 67 track.GetExternalParameters(fX,fP);
68 track.GetExternalCovariance(fC);
51ad6848 69}
70
51ad6848 71//_____________________________________________________________________________
c9ec41e8 72void AliExternalTrackParam::Set(const AliKalmanTrack& track) {
73 //
74 //
75 fAlpha=track.GetAlpha();
76 track.GetExternalParameters(fX,fP);
77 track.GetExternalCovariance(fC);
51ad6848 78}
79
80//_____________________________________________________________________________
c9ec41e8 81void AliExternalTrackParam::Reset() {
82 fX=fAlpha=0.;
83 for (Int_t i = 0; i < 5; i++) fP[i] = 0;
84 for (Int_t i = 0; i < 15; i++) fC[i] = 0;
51ad6848 85}
86
c9ec41e8 87Double_t AliExternalTrackParam::GetP() const {
88 //---------------------------------------------------------------------
89 // This function returns the track momentum
90 // Results for (nearly) straight tracks are meaningless !
91 //---------------------------------------------------------------------
92 if (TMath::Abs(fP[4])<=0) return 0;
93 return TMath::Sqrt(1.+ fP[3]*fP[3])/TMath::Abs(fP[4]);
51ad6848 94}
95
c9ec41e8 96//_______________________________________________________________________
97Double_t AliExternalTrackParam::GetD(Double_t b,Double_t x,Double_t y) const {
98 //------------------------------------------------------------------
99 // This function calculates the transverse impact parameter
100 // with respect to a point with global coordinates (x,y)
101 // in the magnetic field "b" (kG)
102 //------------------------------------------------------------------
49d13e89 103 Double_t rp4=kB2C*b*fP[4];
c9ec41e8 104
105 Double_t xt=fX, yt=fP[0];
106
107 Double_t sn=TMath::Sin(fAlpha), cs=TMath::Cos(fAlpha);
108 Double_t a = x*cs + y*sn;
109 y = -x*sn + y*cs; x=a;
110 xt-=x; yt-=y;
111
112 sn=rp4*xt - fP[2]; cs=rp4*yt + TMath::Sqrt(1.- fP[2]*fP[2]);
113 a=2*(xt*fP[2] - yt*TMath::Sqrt(1.- fP[2]*fP[2]))-rp4*(xt*xt + yt*yt);
114 if (rp4<0) a=-a;
115 return a/(1 + TMath::Sqrt(sn*sn + cs*cs));
51ad6848 116}
117
49d13e89 118//_______________________________________________________________________
119Double_t AliExternalTrackParam::GetLinearD(Double_t xv,Double_t yv) const {
120 //------------------------------------------------------------------
121 // This function calculates the transverse impact parameter
122 // with respect to a point with global coordinates (xv,yv)
123 // neglecting the track curvature.
124 //------------------------------------------------------------------
125 Double_t sn=TMath::Sin(fAlpha), cs=TMath::Cos(fAlpha);
126 Double_t x= xv*cs + yv*sn;
127 Double_t y=-xv*sn + yv*cs;
128
129 Double_t d = (fX-x)*fP[2] - (fP[0]-y)*TMath::Sqrt(1.- fP[2]*fP[2]);
130
131 return d;
132}
133
134Bool_t AliExternalTrackParam::Rotate(Double_t alpha) {
135 //------------------------------------------------------------------
136 // Transform this track to the local coord. system rotated
137 // by angle "alpha" (rad) with respect to the global coord. system.
138 //------------------------------------------------------------------
139 if (alpha < -TMath::Pi()) alpha += 2*TMath::Pi();
140 else if (alpha >= TMath::Pi()) alpha -= 2*TMath::Pi();
141
142 Double_t &fP0=fP[0];
143 Double_t &fP2=fP[2];
144 Double_t &fC00=fC[0];
145 Double_t &fC10=fC[1];
146 Double_t &fC20=fC[3];
147 Double_t &fC21=fC[4];
148 Double_t &fC22=fC[5];
149 Double_t &fC30=fC[6];
150 Double_t &fC32=fC[8];
151 Double_t &fC40=fC[10];
152 Double_t &fC42=fC[12];
153
154 Double_t x=fX;
155 Double_t ca=TMath::Cos(alpha-fAlpha), sa=TMath::Sin(alpha-fAlpha);
156 Double_t sf=fP2, cf=TMath::Sqrt(1.- fP2*fP2);
157
158 fAlpha = alpha;
159 fX = x*ca + fP0*sa;
160 fP0= -x*sa + fP0*ca;
161 fP2= sf*ca - cf*sa;
162
163 Double_t rr=(ca+sf/cf*sa);
164
165 fC00 *= (ca*ca);
166 fC10 *= ca;
167 fC20 *= ca*rr;
168 fC21 *= rr;
169 fC22 *= rr*rr;
170 fC30 *= ca;
171 fC32 *= rr;
172 fC40 *= ca;
173 fC42 *= rr;
174
175 return kTRUE;
176}
177
178Bool_t AliExternalTrackParam::PropagateTo(Double_t xk, Double_t b) {
179 //----------------------------------------------------------------
180 // Propagate this track to the plane X=xk (cm) in the field "b" (kG)
181 //----------------------------------------------------------------
182 Double_t crv=kB2C*b*fP[4];
183 Double_t dx=xk-fX;
184 Double_t f1=fP[2], f2=f1 + crv*dx;
bbefa4c4 185 if (TMath::Abs(f1) >= kAlmost1) return kFALSE;
49d13e89 186 if (TMath::Abs(f2) >= kAlmost1) return kFALSE;
187
188 Double_t &fP0=fP[0], &fP1=fP[1], &fP2=fP[2], &fP3=fP[3], &fP4=fP[4];
189 Double_t
190 &fC00=fC[0],
191 &fC10=fC[1], &fC11=fC[2],
192 &fC20=fC[3], &fC21=fC[4], &fC22=fC[5],
193 &fC30=fC[6], &fC31=fC[7], &fC32=fC[8], &fC33=fC[9],
194 &fC40=fC[10], &fC41=fC[11], &fC42=fC[12], &fC43=fC[13], &fC44=fC[14];
195
196 Double_t r1=TMath::Sqrt(1.- f1*f1), r2=TMath::Sqrt(1.- f2*f2);
197
198 fX=xk;
199 fP0 += dx*(f1+f2)/(r1+r2);
200 fP1 += dx*(f1+f2)/(f1*r2 + f2*r1)*fP3;
201 fP2 += dx*crv;
202
203 //f = F - 1
204
205 Double_t f02= dx/(r1*r1*r1); Double_t cc=crv/fP4;
206 Double_t f04=0.5*dx*dx/(r1*r1*r1); f04*=cc;
207 Double_t f12= dx*fP3*f1/(r1*r1*r1);
208 Double_t f14=0.5*dx*dx*fP3*f1/(r1*r1*r1); f14*=cc;
209 Double_t f13= dx/r1;
210 Double_t f24= dx; f24*=cc;
211
212 //b = C*ft
213 Double_t b00=f02*fC20 + f04*fC40, b01=f12*fC20 + f14*fC40 + f13*fC30;
214 Double_t b02=f24*fC40;
215 Double_t b10=f02*fC21 + f04*fC41, b11=f12*fC21 + f14*fC41 + f13*fC31;
216 Double_t b12=f24*fC41;
217 Double_t b20=f02*fC22 + f04*fC42, b21=f12*fC22 + f14*fC42 + f13*fC32;
218 Double_t b22=f24*fC42;
219 Double_t b40=f02*fC42 + f04*fC44, b41=f12*fC42 + f14*fC44 + f13*fC43;
220 Double_t b42=f24*fC44;
221 Double_t b30=f02*fC32 + f04*fC43, b31=f12*fC32 + f14*fC43 + f13*fC33;
222 Double_t b32=f24*fC43;
223
224 //a = f*b = f*C*ft
225 Double_t a00=f02*b20+f04*b40,a01=f02*b21+f04*b41,a02=f02*b22+f04*b42;
226 Double_t a11=f12*b21+f14*b41+f13*b31,a12=f12*b22+f14*b42+f13*b32;
227 Double_t a22=f24*b42;
228
229 //F*C*Ft = C + (b + bt + a)
230 fC00 += b00 + b00 + a00;
231 fC10 += b10 + b01 + a01;
232 fC20 += b20 + b02 + a02;
233 fC30 += b30;
234 fC40 += b40;
235 fC11 += b11 + b11 + a11;
236 fC21 += b21 + b12 + a12;
237 fC31 += b31;
238 fC41 += b41;
239 fC22 += b22 + b22 + a22;
240 fC32 += b32;
241 fC42 += b42;
242
243 return kTRUE;
244}
245
246Double_t
247AliExternalTrackParam::GetPredictedChi2(Double_t p[2],Double_t cov[3]) const {
248 //----------------------------------------------------------------
249 // Estimate the chi2 of the space point "p" with the cov. matrix "cov"
250 //----------------------------------------------------------------
251 Double_t sdd = fC[0] + cov[0];
252 Double_t sdz = fC[1] + cov[1];
253 Double_t szz = fC[2] + cov[2];
254 Double_t det = sdd*szz - sdz*sdz;
255
256 if (TMath::Abs(det) < kAlmost0) return kVeryBig;
257
258 Double_t d = fP[0] - p[0];
259 Double_t z = fP[1] - p[1];
260
261 return (d*szz*d - 2*d*sdz*z + z*sdd*z)/det;
262}
263
264Bool_t AliExternalTrackParam::Update(Double_t p[2], Double_t cov[3]) {
265 //------------------------------------------------------------------
266 // Update the track parameters with the space point "p" having
267 // the covariance matrix "cov"
268 //------------------------------------------------------------------
269 Double_t &fP0=fP[0], &fP1=fP[1], &fP2=fP[2], &fP3=fP[3], &fP4=fP[4];
270 Double_t
271 &fC00=fC[0],
272 &fC10=fC[1], &fC11=fC[2],
273 &fC20=fC[3], &fC21=fC[4], &fC22=fC[5],
274 &fC30=fC[6], &fC31=fC[7], &fC32=fC[8], &fC33=fC[9],
275 &fC40=fC[10], &fC41=fC[11], &fC42=fC[12], &fC43=fC[13], &fC44=fC[14];
276
277 Double_t r00=cov[0], r01=cov[1], r11=cov[2];
278 r00+=fC00; r01+=fC10; r11+=fC11;
279 Double_t det=r00*r11 - r01*r01;
280
281 if (TMath::Abs(det) < kAlmost0) return kFALSE;
282
283
284 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
285
286 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
287 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
288 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
289 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
290 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
291
292 Double_t dy=p[0] - fP0, dz=p[1] - fP1;
293 Double_t sf=fP2 + k20*dy + k21*dz;
294 if (TMath::Abs(sf) > kAlmost1) return kFALSE;
295
296 fP0 += k00*dy + k01*dz;
297 fP1 += k10*dy + k11*dz;
298 fP2 = sf;
299 fP3 += k30*dy + k31*dz;
300 fP4 += k40*dy + k41*dz;
301
302 Double_t c01=fC10, c02=fC20, c03=fC30, c04=fC40;
303 Double_t c12=fC21, c13=fC31, c14=fC41;
304
305 fC00-=k00*fC00+k01*fC10; fC10-=k00*c01+k01*fC11;
306 fC20-=k00*c02+k01*c12; fC30-=k00*c03+k01*c13;
307 fC40-=k00*c04+k01*c14;
308
309 fC11-=k10*c01+k11*fC11;
310 fC21-=k10*c02+k11*c12; fC31-=k10*c03+k11*c13;
311 fC41-=k10*c04+k11*c14;
312
313 fC22-=k20*c02+k21*c12; fC32-=k20*c03+k21*c13;
314 fC42-=k20*c04+k21*c14;
315
316 fC33-=k30*c03+k31*c13;
317 fC43-=k30*c04+k31*c14;
318
319 fC44-=k40*c04+k41*c14;
320
321 return kTRUE;
322}
323
c9ec41e8 324Bool_t Local2GlobalMomentum(Double_t p[3],Double_t alpha) {
325 //----------------------------------------------------------------
326 // This function performs local->global transformation of the
327 // track momentum.
328 // When called, the arguments are:
329 // p[0] = 1/pt of the track;
330 // p[1] = sine of local azim. angle of the track momentum;
331 // p[2] = tangent of the track momentum dip angle;
332 // alpha - rotation angle.
333 // The result is returned as:
334 // p[0] = px
335 // p[1] = py
336 // p[2] = pz
337 // Results for (nearly) straight tracks are meaningless !
338 //----------------------------------------------------------------
339 if (TMath::Abs(p[0])<=0) return kFALSE;
49d13e89 340 if (TMath::Abs(p[1])> kAlmost1) return kFALSE;
c9ec41e8 341
342 Double_t pt=1./TMath::Abs(p[0]);
343 Double_t cs=TMath::Cos(alpha), sn=TMath::Sin(alpha);
344 Double_t r=TMath::Sqrt(1 - p[1]*p[1]);
345 p[0]=pt*(r*cs - p[1]*sn); p[1]=pt*(p[1]*cs + r*sn); p[2]=pt*p[2];
a5e407e9 346
347 return kTRUE;
348}
349
c9ec41e8 350Bool_t Local2GlobalPosition(Double_t r[3],Double_t alpha) {
351 //----------------------------------------------------------------
352 // This function performs local->global transformation of the
353 // track position.
354 // When called, the arguments are:
355 // r[0] = local x
356 // r[1] = local y
357 // r[2] = local z
358 // alpha - rotation angle.
359 // The result is returned as:
360 // r[0] = global x
361 // r[1] = global y
362 // r[2] = global z
363 //----------------------------------------------------------------
364 Double_t cs=TMath::Cos(alpha), sn=TMath::Sin(alpha), x=r[0];
365 r[0]=x*cs - r[1]*sn; r[1]=x*sn + r[1]*cs;
a5e407e9 366
a5e407e9 367 return kTRUE;
51ad6848 368}
369
c9ec41e8 370Bool_t AliExternalTrackParam::GetPxPyPz(Double_t *p) const {
371 //---------------------------------------------------------------------
372 // This function returns the global track momentum components
373 // Results for (nearly) straight tracks are meaningless !
374 //---------------------------------------------------------------------
375 p[0]=fP[4]; p[1]=fP[2]; p[2]=fP[3];
376 return Local2GlobalMomentum(p,fAlpha);
377}
a5e407e9 378
c9ec41e8 379Bool_t AliExternalTrackParam::GetXYZ(Double_t *r) const {
380 //---------------------------------------------------------------------
381 // This function returns the global track position
382 //---------------------------------------------------------------------
383 r[0]=fX; r[1]=fP[0]; r[2]=fP[1];
384 return Local2GlobalPosition(r,fAlpha);
51ad6848 385}
386
c9ec41e8 387Bool_t AliExternalTrackParam::GetCovarianceXYZPxPyPz(Double_t cv[21]) const {
388 //---------------------------------------------------------------------
389 // This function returns the global covariance matrix of the track params
390 //
391 // Cov(x,x) ... : cv[0]
392 // Cov(y,x) ... : cv[1] cv[2]
393 // Cov(z,x) ... : cv[3] cv[4] cv[5]
394 // Cov(px,x)... : cv[6] cv[7] cv[8] cv[9]
395 // Cov(py,x)... : cv[10] cv[11] cv[12] cv[13] cv[14]
396 // Cov(pz,x)... : cv[15] cv[16] cv[17] cv[18] cv[19] cv[20]
a5e407e9 397 //
c9ec41e8 398 // Results for (nearly) straight tracks are meaningless !
399 //---------------------------------------------------------------------
400 if (TMath::Abs(fP[4])<=0) {
401 for (Int_t i=0; i<21; i++) cv[i]=0.;
402 return kFALSE;
a5e407e9 403 }
49d13e89 404 if (TMath::Abs(fP[2]) > kAlmost1) {
c9ec41e8 405 for (Int_t i=0; i<21; i++) cv[i]=0.;
406 return kFALSE;
407 }
408 Double_t pt=1./TMath::Abs(fP[4]);
409 Double_t cs=TMath::Cos(fAlpha), sn=TMath::Sin(fAlpha);
410 Double_t r=TMath::Sqrt(1-fP[2]*fP[2]);
411
412 Double_t m00=-sn, m10=cs;
413 Double_t m23=-pt*(sn + fP[2]*cs/r), m43=-pt*pt*(r*cs - fP[2]*sn);
414 Double_t m24= pt*(cs - fP[2]*sn/r), m44=-pt*pt*(r*sn + fP[2]*cs);
415 Double_t m35=pt, m45=-pt*pt*fP[3];
416
417 cv[0 ] = fC[0]*m00*m00;
418 cv[1 ] = fC[0]*m00*m10;
419 cv[2 ] = fC[0]*m10*m10;
420 cv[3 ] = fC[1]*m00;
421 cv[4 ] = fC[1]*m10;
422 cv[5 ] = fC[2];
423 cv[6 ] = m00*(fC[3]*m23 + fC[10]*m43);
424 cv[7 ] = m10*(fC[3]*m23 + fC[10]*m43);
425 cv[8 ] = fC[4]*m23 + fC[11]*m43;
426 cv[9 ] = m23*(fC[5]*m23 + fC[12]*m43) + m43*(fC[12]*m23 + fC[14]*m43);
427 cv[10] = m00*(fC[3]*m24 + fC[10]*m44);
428 cv[11] = m10*(fC[3]*m24 + fC[10]*m44);
429 cv[12] = fC[4]*m24 + fC[11]*m44;
430 cv[13] = m23*(fC[5]*m24 + fC[12]*m44) + m43*(fC[12]*m24 + fC[14]*m44);
431 cv[14] = m24*(fC[5]*m24 + fC[12]*m44) + m44*(fC[12]*m24 + fC[14]*m44);
432 cv[15] = m00*(fC[6]*m35 + fC[10]*m45);
433 cv[16] = m10*(fC[6]*m35 + fC[10]*m45);
434 cv[17] = fC[7]*m35 + fC[11]*m45;
435 cv[18] = m23*(fC[8]*m35 + fC[12]*m45) + m43*(fC[13]*m35 + fC[14]*m45);
436 cv[19] = m24*(fC[8]*m35 + fC[12]*m45) + m44*(fC[13]*m35 + fC[14]*m45);
437 cv[20] = m35*(fC[9]*m35 + fC[13]*m45) + m45*(fC[13]*m35 + fC[14]*m45);
51ad6848 438
c9ec41e8 439 return kTRUE;
51ad6848 440}
441
51ad6848 442
c9ec41e8 443Bool_t
444AliExternalTrackParam::GetPxPyPzAt(Double_t x, Double_t b, Double_t *p) const {
445 //---------------------------------------------------------------------
446 // This function returns the global track momentum extrapolated to
447 // the radial position "x" (cm) in the magnetic field "b" (kG)
448 //---------------------------------------------------------------------
c9ec41e8 449 p[0]=fP[4];
49d13e89 450 p[1]=fP[2]+(x-fX)*fP[4]*b*kB2C;
c9ec41e8 451 p[2]=fP[3];
452 return Local2GlobalMomentum(p,fAlpha);
51ad6848 453}
454
c9ec41e8 455Bool_t
456AliExternalTrackParam::GetXYZAt(Double_t x, Double_t b, Double_t *r) const {
457 //---------------------------------------------------------------------
458 // This function returns the global track position extrapolated to
459 // the radial position "x" (cm) in the magnetic field "b" (kG)
460 //---------------------------------------------------------------------
c9ec41e8 461 Double_t dx=x-fX;
49d13e89 462 Double_t f1=fP[2], f2=f1 + dx*fP[4]*b*kB2C;
c9ec41e8 463
49d13e89 464 if (TMath::Abs(f2) >= kAlmost1) return kFALSE;
c9ec41e8 465
466 Double_t r1=TMath::Sqrt(1.- f1*f1), r2=TMath::Sqrt(1.- f2*f2);
467 r[0] = x;
468 r[1] = fP[0] + dx*(f1+f2)/(r1+r2);
469 r[2] = fP[1] + dx*(f1+f2)/(f1*r2 + f2*r1)*fP[3];
470 return Local2GlobalPosition(r,fAlpha);
51ad6848 471}
472
473
474//_____________________________________________________________________________
475void AliExternalTrackParam::Print(Option_t* /*option*/) const
476{
477// print the parameters and the covariance matrix
478
479 printf("AliExternalTrackParam: x = %-12g alpha = %-12g\n", fX, fAlpha);
480 printf(" parameters: %12g %12g %12g %12g %12g\n",
c9ec41e8 481 fP[0], fP[1], fP[2], fP[3], fP[4]);
482 printf(" covariance: %12g\n", fC[0]);
483 printf(" %12g %12g\n", fC[1], fC[2]);
484 printf(" %12g %12g %12g\n", fC[3], fC[4], fC[5]);
51ad6848 485 printf(" %12g %12g %12g %12g\n",
c9ec41e8 486 fC[6], fC[7], fC[8], fC[9]);
51ad6848 487 printf(" %12g %12g %12g %12g %12g\n",
c9ec41e8 488 fC[10], fC[11], fC[12], fC[13], fC[14]);
51ad6848 489}
5b77d93c 490
491
492Bool_t AliExternalTrackParam::PropagateTo(Double_t xToGo, Double_t mass, Double_t maxStep, Bool_t rotateTo){
493 //----------------------------------------------------------------
494 // Propagate this track to the plane X=xk (cm)
495 // correction for unhomogenity of the magnetic field and the
496 // the correction for the material is included
497 //
498 // Require acces to magnetic field and geomanager
499 //
500 // mass - mass used in propagation - used for energy loss correction
501 // maxStep - maximal step for propagation
502 //----------------------------------------------------------------
503 const Double_t kEpsilon = 0.00001;
504 Double_t xpos = GetX();
505 Double_t dir = (xpos<xToGo) ? 1.:-1.;
506 //
507 while ( (xToGo-xpos)*dir > kEpsilon){
508 Double_t step = dir*TMath::Min(TMath::Abs(xToGo-xpos), maxStep);
509 Double_t x = xpos+step;
510 Double_t xyz0[3],xyz1[3],param[7];
511 GetXYZ(xyz0); //starting global position
512 Float_t pos0[3] = {xyz0[0],xyz0[1],xyz0[2]};
513 Double_t magZ = AliTracker::GetBz(pos0);
514 if (!GetXYZAt(x,magZ,xyz1)) return kFALSE; // no prolongation
515 AliKalmanTrack::MeanMaterialBudget(xyz0,xyz1,param);
516 if (!PropagateTo(x,magZ)) return kFALSE;
517 Double_t distance = param[4];
518 if (!CorrectForMaterial(distance,param[1],param[0],mass)) return kFALSE;
519 if (rotateTo){
520 GetXYZ(xyz0); // global position
521 Double_t alphan = TMath::ATan2(xyz0[1], xyz0[0]);
522 if (!Rotate(alphan)) return kFALSE;
523 }
524 xpos = GetX();
525 }
526 return kTRUE;
527}
528
529//_____________________________________________________________________________
530Bool_t AliExternalTrackParam::CorrectForMaterial(Double_t d, Double_t x0, Double_t rho, Double_t mass)
531{
532 //
533 // Take into account material effects assuming:
534 // x0 - mean rad length
535 // rho - mean density
536
537 //
538 // multiple scattering
539 //
540 if (mass<=0) {
541 AliError("Non-positive mass");
542 return kFALSE;
543 }
544 Double_t p2=(1.+ fP[3]*fP[3])/(fP[4]*fP[4]);
545 Double_t beta2=p2/(p2 + mass*mass);
546 Double_t theta2=14.1*14.1/(beta2*p2*1e6)*d/x0*rho;
547 //
548 fC[5] += theta2*(1.- fP[2]*fP[2])*(1. + fP[3]*fP[3]);
549 fC[9] += theta2*(1. + fP[3]*fP[3])*(1. + fP[3]*fP[3]);
550 fC[13] += theta2*fP[3]*fP[4]*(1. + fP[3]*fP[3]);
551 fC[14] += theta2*fP[3]*fP[4]*fP[3]*fP[4];
552 //
553 Double_t dE=0.153e-3/beta2*(log(5940*beta2/(1-beta2+1e-10)) - beta2)*d*rho;
554 fP[4] *=(1.- TMath::Sqrt(p2+mass*mass)/p2*dE);
555 //
556 Double_t sigmade = 0.02*TMath::Sqrt(TMath::Abs(dE)); // energy loss fluctuation
557 Double_t sigmac2 = sigmade*sigmade*fP[4]*fP[4]*(p2+mass*mass)/(p2*p2);
558 fC[14] += sigmac2;
559 return kTRUE;
560}
561
562