11 #ifndef ALIHLTTPCCATRACKPARAM_H
12 #define ALIHLTTPCCATRACKPARAM_H
14 #include "AliHLTTPCCADef.h"
15 #include "AliHLTTPCCAMath.h"
16 #include "AliHLTTPCCATrackParamVector.h"
17 #include "AliHLTTPCCADef.h"
23 template<
typename T>
struct char_traits;
24 template<
typename _CharT,
typename _Traits>
class basic_istream;
25 typedef basic_istream<char, char_traits<char> > istream;
26 template<
typename _CharT,
typename _Traits>
class basic_ostream;
27 typedef basic_ostream<char, char_traits<char> > ostream;
50 for (
int j = 0; j < 5; ++j ) fP[j] = v.Par()[j][i];
51 for (
int j = 0; j < 15; ++j ) fC[j] = v.Cov()[j][i];
66 float X()
const {
return fX; }
67 float Y()
const {
return fP[0]; }
68 float Z()
const {
return fP[1]; }
69 float SinPhi()
const {
return fP[2]; }
70 float DzDs()
const {
return fP[3]; }
71 float QPt()
const {
return fP[4]; }
78 float Chi2()
const {
return fChi2; }
79 int NDF()
const {
return fNDF; }
81 float Err2Y()
const {
return fC[0]; }
82 float Err2Z()
const {
return fC[2]; }
83 float Err2SinPhi()
const {
return fC[5]; }
84 float Err2DzDs()
const {
return fC[9]; }
85 float Err2QPt()
const {
return fC[14]; }
87 float GetX()
const {
return fX; }
88 float GetY()
const {
return fP[0]; }
89 float GetZ()
const {
return fP[1]; }
90 float GetSinPhi()
const {
return fP[2]; }
91 float GetDzDs()
const {
return fP[3]; }
92 float GetQPt()
const {
return fP[4]; }
93 float GetSignCosPhi()
const {
return fSignCosPhi; }
94 float GetChi2()
const {
return fChi2; }
95 int GetNDF()
const {
return fNDF; }
97 float GetKappa(
float Bz )
const {
return fP[4]*Bz; }
98 float GetCosPhiPositive()
const {
return CAMath::Sqrt( 1 - SinPhi()*SinPhi() ); }
99 float GetCosPhi()
const {
return fSignCosPhi*CAMath::Sqrt( 1 - SinPhi()*SinPhi() ); }
101 float GetErr2Y()
const {
return fC[0]; }
102 float GetErr2Z()
const {
return fC[2]; }
103 float GetErr2SinPhi()
const {
return fC[5]; }
104 float GetErr2DzDs()
const {
return fC[9]; }
105 float GetErr2QPt()
const {
return fC[14]; }
107 const float *Par()
const {
return fP; }
108 const float *Cov()
const {
return fC; }
110 const float *GetPar()
const {
return fP; }
111 const float *GetCov()
const {
return fC; }
113 void SetPar(
int i,
float v ) { fP[i] = v; }
114 void SetCov(
int i,
float v ) { fC[i] = v; }
116 void SetX(
float v ) { fX = v; }
117 void SetY(
float v ) { fP[0] = v; }
118 void SetZ(
float v ) { fP[1] = v; }
119 void SetSinPhi(
float v ) { fP[2] = v; }
120 void SetDzDs(
float v ) { fP[3] = v; }
121 void SetQPt(
float v ) { fP[4] = v; }
122 void SetSignCosPhi(
float v ) { fSignCosPhi = v; }
123 void SetChi2(
float v ) { fChi2 = v; }
124 void SetNDF(
int v ) { fNDF = v; }
131 float GetS(
float x,
float y,
float Bz )
const;
133 void GetDCAPoint(
float x,
float y,
float z,
134 float &px,
float &py,
float &pz,
float Bz )
const;
137 bool TransportToX(
float x,
float Bz,
float maxSinPhi = .999 );
138 bool TransportToXWithMaterial(
float x,
float Bz,
float maxSinPhi = .999 );
141 float Bz,
float maxSinPhi = .999,
float *DL = 0 );
143 bool TransportToX(
float x,
float sinPhi0,
float cosPhi0,
float Bz,
float maxSinPhi = .999 );
147 AliHLTTPCCATrackFitParam &par,
float Bz,
float maxSinPhi = .999 );
149 bool TransportToXWithMaterial(
float x,
150 AliHLTTPCCATrackFitParam &par,
float Bz,
float maxSinPhi = .999 );
154 static float ApproximateBetheBloch(
float beta2 );
155 static float BetheBlochGeant(
float bg,
162 static float BetheBlochSolid(
float bg );
163 static float BetheBlochGas(
float bg );
166 void CalculateFitParameters( AliHLTTPCCATrackFitParam &par,
float mass = 0.13957 );
167 bool CorrectForMeanMaterial(
float xOverX0,
float xTimesRho,
const AliHLTTPCCATrackFitParam &par );
169 bool Rotate(
float alpha,
float maxSinPhi = .999 );
172 void RotateXY(
float alpha,
float &x,
float &y,
float &sin )
const;
173 bool Filter(
float y,
float z,
float err2Y,
float err2Z,
float maxSinPhi = .999 );
178 void ResetCovMatrix()
181 fC[1] = 0.f; fC[2] = 10.f;
182 fC[3] = 0.f; fC[4] = 0.f; fC[5] = 1.f;
183 fC[6] = 0.f; fC[7] = 0.f; fC[8] = 0.f; fC[9] = 1.f;
184 fC[10] = 0.f; fC[11] = 0.f; fC[12] = 0.f; fC[13] = 0.f; fC[14] = 10.f;
190 fX = 0; fSignCosPhi = 0;
191 for(
int i=0; i<5; i++) fP[i] = 0;
192 for(
int i=0; i<15; i++) fC[i] = 0;
205 inline void AliHLTTPCCATrackParam::RotateXY(
float alpha,
float &x,
float &y,
float &sin )
const
209 const float cA = CAMath::Cos( alpha );
210 const float sA = CAMath::Sin( alpha );
212 x = ( X()*cA + Y()*sA );
213 y = ( -X()*sA + Y()*cA );
214 sin = -GetCosPhi() * sA + SinPhi() * cA;
218 inline bool AliHLTTPCCATrackParam::Filter(
float y,
float z,
float err2Y,
float err2Z,
float maxSinPhi )
220 assert( maxSinPhi > 0.f );
223 const float c00 = fC[0];
224 const float c10 = fC[1];
225 const float c11 = fC[2];
226 const float c20 = fC[3];
227 const float c21 = fC[4];
229 const float c30 = fC[6];
230 const float c31 = fC[7];
233 const float c40 = fC[10];
234 const float c41 = fC[11];
239 float d = 1.f / ( err2Y*err2Z + err2Y*c11 + err2Z*c00 + c00*c11 - c10*c10 );
247 if ( ISUNLIKELY( err2Y < 1.e-8f ) || ISUNLIKELY( err2Z < 1.e-8f ) )
return 0;
249 const float mS0 = err2Z*d;
250 const float mS1 = -c10*d;
251 const float mS2 = err2Y*d;
256 k00 = c00 * mS0 + c10*mS1, k01 = c00 * mS1 + c10*mS2,
257 k10 = c10 * mS0 + c11*mS1, k11 = c10 * mS1 + c11*mS2,
258 k20 = c20 * mS0 + c21*mS1, k21 = c20 * mS1 + c21*mS2,
259 k30 = c30 * mS0 + c31*mS1, k31 = c30 * mS1 + c31*mS2,
260 k40 = c40 * mS0 + c41*mS1, k41 = c40 * mS1 + c41*mS2;
262 const float sinPhi = fP[2] + k20 * z0 + k21 * z1;
264 if ( ISUNLIKELY( CAMath::Abs( sinPhi ) >= maxSinPhi ) )
return 0;
267 fChi2 += mS0 * z0 * z0 + mS2 * z1 * z1 + 2 * z0 * z1 * mS1;
269 fP[ 0] += k00 * z0 + k01 * z1;
270 fP[ 1] += k10 * z0 + k11 * z1;
272 fP[ 3] += k30 * z0 + k31 * z1;
273 fP[ 4] += k40 * z0 + k41 * z1;
275 fC[ 0] -= (k00 * c00 + k01 * c10);
277 fC[ 1] -= (k10 * c00 + k11 * c10);
278 fC[ 2] -= (k10 * c10 + k11 * c11);
280 fC[ 3] -= (k20 * c00 + k21 * c10);
281 fC[ 4] -= (k20 * c10 + k21 * c11);
282 fC[ 5] -= (k20 * c20 + k21 * c21);
284 fC[ 6] -= (k30 * c00 + k31 * c10);
285 fC[ 7] -= (k30 * c10 + k31 * c11);
286 fC[ 8] -= (k30 * c20 + k31 * c21);
287 fC[ 9] -= (k30 * c30 + k31 * c31);
289 fC[10] -= (k40 * c00 + k41 * c10);
290 fC[11] -= (k40 * c10 + k41 * c11);
291 fC[12] -= (k40 * c20 + k41 * c21);
292 fC[13] -= (k40 * c30 + k41 * c31);
293 fC[14] -= (k40 * c40 + k41 * c41);
298 inline float AliHLTTPCCATrackParam::ApproximateBetheBloch(
float beta2 )
308 const float beta2_beta21i = beta2 / ( 1 - beta2 );
309 if ( beta2_beta21i > 12.25 )
310 return 0.153e-3 / beta2 * ( 9.94223 + 0.5 * log( beta2_beta21i ) - beta2 );
312 return 0.153e-3 / beta2 * ( 8.6895 + log( beta2_beta21i ) - beta2 );
316 inline void AliHLTTPCCATrackParam::CalculateFitParameters( AliHLTTPCCATrackFitParam &par,
float mass )
318 const float p2 = ( 1. + fP[3] * fP[3] );
319 const float k2 = fP[4] * fP[4];
320 const float mass2 = mass * mass;
322 const float beta2 = p2 / ( p2 + mass2 * k2 );
324 const float pp2 = ( k2 > 1.e-8 ) ? p2 / k2 : 10000;
327 par.fBethe = ApproximateBetheBloch( pp2 / mass2 );
328 par.fE = CAMath::Sqrt( pp2 + mass2 );
329 par.fTheta2 = 198.81e-6 / ( beta2 * pp2 );
330 par.fEP2 = par.fE / pp2;
334 const float knst = 0.07;
335 par.fSigmadE2 = knst * par.fEP2 * fP[4];
336 par.fSigmadE2 = par.fSigmadE2 * par.fSigmadE2;
339 par.fK33 = par.fK22 * par.fK22;
340 par.fK43 = fP[3] * fP[4] * par.fK22;
341 par.fK44 = (p2 - 1.f) * k2;
346 #include "AliHLTTPCCAMath.h"
347 #include "AliHLTTPCCATrackLinearisation.h"
357 const float ex = t0.CosPhi();
358 const float ey = t0.SinPhi();
359 const float k = t0.QPt() * Bz;
360 const float dx = x - X();
362 const float ey1 = k * dx + ey;
366 if ( CAMath::Abs( ey1 ) > maxSinPhi )
return 0;
368 float ex1 = CAMath::Sqrt( 1.f - ey1 * ey1 );
369 if ( ex < 0 ) ex1 = -ex1;
371 const float dx2 = dx * dx;
372 const float ss = ey + ey1;
373 const float cc = ex + ex1;
375 if ( ( CAMath::Abs( cc ) < 1.e-4 || CAMath::Abs( ex ) < 1.e-4 || CAMath::Abs( ex1 ) < 1.e-4 ) )
return 0;
377 const float cci = 1.f / cc;
378 const float exi = 1.f / ex;
379 const float ex1i = 1.f / ex1;
381 const float tg = ss * cci;
383 const float dy = dx * tg;
384 float dl = dx * CAMath::Sqrt( 1.f + tg * tg );
386 if ( cc < 0 ) dl = -dl;
387 float dSin = dl * k * 0.5;
388 if ( dSin > 1.f ) dSin = 1.f;
389 if ( dSin < -1.f ) dSin = -1.f;
390 const float dS = ( CAMath::Abs( k ) > 1.e-4 ) ? ( 2 * CAMath::ASin( dSin ) / k ) : dl;
391 const float dz = dS * t0.DzDs();
393 if ( DL ) *DL = -dS * CAMath::Sqrt( 1.f + t0.DzDs() * t0.DzDs() );
396 const float d[3] = { fP[2] - t0.SinPhi(), fP[3] - t0.DzDs(), fP[4] - t0.QPt() };
404 const float h2 = dx * ( 1.f + ey * ey1 + ex * ex1 ) * exi * ex1i * cci;
405 const float h4 = dx2 * ( cc + ss * ey1 * ex1i ) * cci * cci * Bz;
406 const float dxBz = dx * Bz;
412 fP[0] = Y() + dy + h2 * d[0] + h4 * d[2];
413 fP[1] = Z() + dz + dS * d[1];
414 fP[2] = t0.SinPhi() + d[0] + dxBz * d[2];
415 if(CAMath::Abs(fP[2]) > maxSinPhi) fP[2] = t0.SinPhi();
418 const float c00 = fC[0];
419 const float c10 = fC[1];
420 const float c11 = fC[2];
421 const float c20 = fC[3];
422 const float c21 = fC[4];
423 const float c22 = fC[5];
424 const float c30 = fC[6];
425 const float c31 = fC[7];
426 const float c32 = fC[8];
427 const float c33 = fC[9];
428 const float c40 = fC[10];
429 const float c41 = fC[11];
430 const float c42 = fC[12];
431 const float c43 = fC[13];
432 const float c44 = fC[14];
434 fC[0] = ( c00 + h2 * h2 * c22 + h4 * h4 * c44
435 + 2.f * ( h2 * c20 + h4 * c40 + h2 * h4 * c42 ) );
437 fC[1] = c10 + h2 * c21 + h4 * c41 + dS * ( c30 + h2 * c32 + h4 * c43 );
438 fC[2] = c11 + 2.f * dS * c31 + dS * dS * c33;
440 fC[3] = c20 + h2 * c22 + h4 * c42 + dxBz * ( c40 + h2 * c42 + h4 * c44 );
441 fC[4] = c21 + dS * c32 + dxBz * ( c41 + dS * c43 );
442 fC[5] = c22 + 2.f * dxBz * c42 + dxBz * dxBz * c44;
444 fC[6] = c30 + h2 * c32 + h4 * c43;
445 fC[7] = c31 + dS * c33;
446 fC[8] = c32 + dxBz * c43;
449 fC[10] = c40 + h2 * c42 + h4 * c44;
450 fC[11] = c41 + dS * c43;
451 fC[12] = c42 + dxBz * c44;
455 fC[0] = ( fC[0] + h2 * h2 * fC[5] + h4 * h4 * fC[14]
456 + 2 * ( h2 * fC[3] + h4 * fC[10] + h2 * h4 * fC[12] ) );
458 fC[1] = fC[1] + h2 * fC[4] + h4 * fC[11] + dS * ( fC[6] + h2 * fC[8] + h4 * fC[13] );
459 fC[2] = fC[2] + 2 * dS * fC[7] + dS * dS * fC[9];
461 fC[3] = fC[3] + h2 * fC[5] + h4 * fC[12] + dxBz * ( fC[10] + h2 * fC[12] + h4 * fC[14] );
462 fC[4] = fC[4] + dS * fC[8] + dxBz * ( fC[11] + dS * fC[13] );
463 fC[5] = fC[5] + 2 * dxBz * fC[12] + dxBz * dxBz * fC[14];
465 fC[6] = fC[6] + h2 * fC[8] + h4 * fC[13];
466 fC[7] = fC[7] + dS * fC[9];
467 fC[8] = fC[8] + dxBz * fC[13];
470 fC[10] = fC[10] + h2 * fC[12] + h4 * fC[14];
471 fC[11] = fC[11] + dS * fC[13];
472 fC[12] = fC[12] + dxBz * fC[14];
481 inline bool AliHLTTPCCATrackParam::CorrectForMeanMaterial(
float xOverX0,
float xTimesRho,
const AliHLTTPCCATrackFitParam &par )
498 const float dE = par.fBethe * xTimesRho;
499 if ( CAMath::Abs( dE ) > 0.3 * par.fE )
return 0;
500 const float corr = ( 1. - par.fEP2 * dE );
501 if ( corr < 0.3 || corr > 1.3 )
return 0;
508 fC[14] *= corr * corr;
509 fC[14] += par.fSigmadE2 * CAMath::Abs( dE );
514 const float theta2 = par.fTheta2 * CAMath::Abs( xOverX0 );
515 fC[5] += theta2 * par.fK22 * ( 1. - fP[2] * fP[2] );
516 fC[9] += theta2 * par.fK33;
517 fC[13] += theta2 * par.fK43;
518 fC[14] += theta2 * par.fK44;
523 inline bool AliHLTTPCCATrackParam::TransportToXWithMaterial(
float x,
AliHLTTPCCATrackLinearisation &t0, AliHLTTPCCATrackFitParam &par,
float Bz,
float maxSinPhi )
527 const float kRho = 1.54e-3;
530 const float kRhoOverRadLen = 7.68e-5;
533 if ( !TransportToX( x, t0, Bz, maxSinPhi, &dl ) )
return 0;
535 CorrectForMeanMaterial( dl*kRhoOverRadLen, dl*kRho, par );
539 inline bool AliHLTTPCCATrackParam::TransportToXWithMaterial(
float x, AliHLTTPCCATrackFitParam &par,
float Bz,
float maxSinPhi )
544 return TransportToXWithMaterial( x, t0, par, Bz, maxSinPhi );
sfloat_v SignCosPhi() const