24 #include "AliHLTTPCCATrackParamVector.h"
25 #include "AliHLTTPCCAMath.h"
26 #include "AliHLTTPCCATrackLinearisationVector.h"
47 const sfloat_v &dx = GetX() - t.GetX();
48 const sfloat_v &dy = GetY() - t.GetY();
49 const sfloat_v &dz = GetZ() - t.GetZ();
50 return dx*dx + dy*dy + dz*dz;
57 const sfloat_v &dx = GetX() - t.GetX();
58 const sfloat_v &dz = GetZ() - t.GetZ();
63 sfloat_v AliHLTTPCCATrackParamVector::GetS(
const sfloat_v &_x,
const sfloat_v &_y,
const sfloat_v &Bz )
const
67 const sfloat_v &k = GetKappa( Bz );
68 const sfloat_v &ex = GetCosPhi();
69 const sfloat_v &ey = GetSinPhi();
70 const sfloat_v &x = _x - GetX();
71 const sfloat_v &y = _y - GetY();
72 sfloat_v dS = x * ex + y * ey;
73 const sfloat_m &mask = CAMath::Abs( k ) > 1.e-4f;
74 if ( !mask.isEmpty() ) {
75 dS( mask ) = CAMath::ATan2( k * dS, 1 + k * ( x * ey - y * ex ) ) / k;
80 void AliHLTTPCCATrackParamVector::GetDCAPoint(
const sfloat_v &x,
const sfloat_v &y,
const sfloat_v &z,
81 sfloat_v *xp, sfloat_v *yp, sfloat_v *zp,
const sfloat_v &Bz )
const
85 const sfloat_v &x0 = GetX();
86 const sfloat_v &y0 = GetY();
87 const sfloat_v &k = GetKappa( Bz );
88 const sfloat_v &ex = GetCosPhi();
89 const sfloat_v &ey = GetSinPhi();
90 const sfloat_v &dx = x - x0;
91 const sfloat_v &dy = y - y0;
92 const sfloat_v &ax = dx * k + ey;
93 const sfloat_v &ay = dy * k - ex;
94 const sfloat_v &a = sqrt( ax * ax + ay * ay );
95 *xp = x0 + ( dx - ey * ( ( dx * dx + dy * dy ) * k - 2.f * ( -dx * ey + dy * ex ) ) / ( a + 1.f ) ) / a;
96 *yp = y0 + ( dy + ex * ( ( dx * dx + dy * dy ) * k - 2.f * ( -dx * ey + dy * ex ) ) / ( a + 1.f ) ) / a;
97 const sfloat_v s = GetS( x, y, Bz );
98 *zp = GetZ() + GetDzDs() * s;
99 const sfloat_v dZ = CAMath::Abs( GetDzDs() * CAMath::TwoPi() / k );
100 const sfloat_m mask = CAMath::Abs( k ) > 1.e-2f && dZ > .1f;
101 ( *zp )( mask ) += CAMath::Round( ( z - *zp ) / dZ ) * dZ;
110 sfloat_m AliHLTTPCCATrackParamVector::TransportToX(
const sfloat_v &x,
AliHLTTPCCATrackLinearisationVector &t0,
const sfloat_v &Bz,
const float maxSinPhi, sfloat_v *DL,
const sfloat_m &_mask )
118 const sfloat_v ex = t0.CosPhi();
119 const sfloat_v ey = t0.SinPhi();
120 const sfloat_v k = t0.QPt() * Bz;
121 const sfloat_v dx = x - X();
123 sfloat_v ey1 = k * dx + ey;
127 sfloat_v ex1 = CAMath::Sqrt( 1.f - ey1 * ey1 );
128 ex1( ex < Vc::Zero ) = -ex1;
130 const sfloat_v dx2 = dx * dx;
131 const sfloat_v ss = ey + ey1;
132 const sfloat_v cc = ex + ex1;
134 const sfloat_v cci = 1.f / cc;
135 const sfloat_v exi = 1.f / ex;
136 const sfloat_v ex1i = 1.f / ex1;
138 sfloat_m mask = _mask && CAMath::Abs( ey1 ) <= maxSinPhi && CAMath::Abs( cc ) >= 1.e-4f && CAMath::Abs( ex ) >= 1.e-4f && CAMath::Abs( ex1 ) >= 1.e-4f;
140 const sfloat_v tg = ss * cci;
142 const sfloat_v dy = dx * tg;
143 sfloat_v dl = dx * CAMath::Sqrt( 1.f + tg * tg );
145 dl( cc < Vc::Zero ) = -dl;
146 const sfloat_v dSin = CAMath::Max( sfloat_v( -1.f ), CAMath::Min( sfloat_v( Vc::One ), dl * k * 0.5f ) );
147 const sfloat_v dS = ( CAMath::Abs( k ) > 1.e-4f ) ? ( 2 * CAMath::ASin( dSin ) / k ) : dl;
148 const sfloat_v dz = dS * t0.DzDs();
151 ( *DL )( mask ) = -dS * CAMath::Sqrt( 1.f + t0.DzDs() * t0.DzDs() );
154 const sfloat_v d[3] = { fP[2] - t0.SinPhi(), fP[3] - t0.DzDs(), fP[4] - t0.QPt() };
162 const sfloat_v h2 = dx * ( 1.f + ey * ey1 + ex * ex1 ) * exi * ex1i * cci;
163 const sfloat_v h4 = dx2 * ( cc + ss * ey1 * ex1i ) * cci * cci * Bz;
164 const sfloat_v dxBz = dx * Bz;
171 fX( mask ) = X() + dx;
172 fP[0]( mask ) = Y() + dy + h2 * d[0] + h4 * d[2];
173 fP[1]( mask ) = Z() + dz + dS * d[1];
174 fP[2]( mask ) = t0.SinPhi() + d[0] + dxBz * d[2];
175 fP[2]( CAMath::Abs(fP[2]) > maxSinPhi ) = t0.SinPhi();
177 const sfloat_v c00 = fC[0];
178 const sfloat_v c10 = fC[1];
179 const sfloat_v c11 = fC[2];
180 const sfloat_v c20 = fC[3];
181 const sfloat_v c21 = fC[4];
182 const sfloat_v c22 = fC[5];
183 const sfloat_v c30 = fC[6];
184 const sfloat_v c31 = fC[7];
185 const sfloat_v c32 = fC[8];
186 const sfloat_v c33 = fC[9];
187 const sfloat_v c40 = fC[10];
188 const sfloat_v c41 = fC[11];
189 const sfloat_v c42 = fC[12];
190 const sfloat_v c43 = fC[13];
191 const sfloat_v c44 = fC[14];
193 fC[0]( mask ) = ( c00 + h2 * h2 * c22 + h4 * h4 * c44
194 + 2.f * ( h2 * c20 + h4 * c40 + h2 * h4 * c42 ) );
196 fC[1]( mask ) = c10 + h2 * c21 + h4 * c41 + dS * ( c30 + h2 * c32 + h4 * c43 );
197 fC[2]( mask ) = c11 + 2.f * dS * c31 + dS * dS * c33;
199 fC[3]( mask ) = c20 + h2 * c22 + h4 * c42 + dxBz * ( c40 + h2 * c42 + h4 * c44 );
200 fC[4]( mask ) = c21 + dS * c32 + dxBz * ( c41 + dS * c43 );
201 fC[5]( mask ) = c22 + 2.f * dxBz * c42 + dxBz * dxBz * c44;
203 fC[6]( mask ) = c30 + h2 * c32 + h4 * c43;
204 fC[7]( mask ) = c31 + dS * c33;
205 fC[8]( mask ) = c32 + dxBz * c43;
208 fC[10]( mask ) = c40 + h2 * c42 + h4 * c44;
209 fC[11]( mask ) = c41 + dS * c43;
210 fC[12]( mask ) = c42 + dxBz * c44;
211 fC[13]( mask ) = c43;
212 fC[14]( mask ) = c44;
214 debugKF() << mask <<
"\n" << *
this << std::endl;
219 sfloat_m AliHLTTPCCATrackParamVector::TransportToX(
const sfloat_v &x,
const sfloat_v &Bz,
220 const float maxSinPhi,
const sfloat_m &mask )
228 return TransportToX( x, t0, Bz, maxSinPhi, 0, mask );
233 sfloat_m AliHLTTPCCATrackParamVector::TransportToXWithMaterial(
const sfloat_v &x,
AliHLTTPCCATrackLinearisationVector &t0, AliHLTTPCCATrackFitParam &par,
const sfloat_v &Bz,
const float maxSinPhi,
const sfloat_m &mask_ )
237 const float kRho = 1.025e-3f;
240 const float kRhoOverRadLen = 7.68e-5;
243 const sfloat_m &mask = mask_ && TransportToX( x, t0, Bz, maxSinPhi, &dl, mask_ );
244 if ( !mask.isEmpty() ) {
245 CorrectForMeanMaterial( dl * kRhoOverRadLen, dl * kRho, par, mask );
252 sfloat_m AliHLTTPCCATrackParamVector::TransportToXWithMaterial(
const sfloat_v &x, AliHLTTPCCATrackFitParam &par,
const sfloat_v &Bz,
const float maxSinPhi )
257 return TransportToXWithMaterial( x, t0, par, Bz, maxSinPhi );
260 sfloat_m AliHLTTPCCATrackParamVector::TransportToXWithMaterial(
const sfloat_v &x,
const sfloat_v &Bz,
const float maxSinPhi )
264 AliHLTTPCCATrackFitParam par;
265 CalculateFitParameters( par );
266 return TransportToXWithMaterial( x, par, Bz, maxSinPhi );
275 sfloat_v AliHLTTPCCATrackParamVector::BetheBlochGeant(
const sfloat_v &bg2,
280 const sfloat_v &kp4 )
296 const float mK = 0.307075e-3f;
297 const float _2me = 1.022e-3f;
298 const sfloat_v &rho = kp0;
299 const sfloat_v &x0 = kp1 * 2.303f;
300 const sfloat_v &x1 = kp2 * 2.303f;
301 const sfloat_v &mI = kp3;
302 const sfloat_v &mZA = kp4;
303 const sfloat_v &maxT = _2me * bg2;
306 sfloat_v d2( Vc::Zero );
307 const sfloat_v x = 0.5f * CAMath::Log( bg2 );
308 const sfloat_v lhwI = CAMath::Log( 28.816f * 1e-9f * CAMath::Sqrt( rho * mZA ) / mI );
309 d2( x > x1 ) = lhwI + x - 0.5f;
310 const sfloat_v &r = ( x1 - x ) / ( x1 - x0 );
311 d2( x > x0 && x <= x1 ) = lhwI + x - 0.5f + ( 0.5f - lhwI - x0 ) * r * r * r;
313 return mK*mZA*( sfloat_v( Vc::One ) + bg2 ) / bg2*( 0.5f*CAMath::Log( maxT * maxT / ( mI*mI ) ) - bg2 / ( sfloat_v( Vc::One ) + bg2 ) - d2 );
316 sfloat_v AliHLTTPCCATrackParamVector::BetheBlochSolid(
const sfloat_v &bg )
325 return BetheBlochGeant( bg );
328 sfloat_v AliHLTTPCCATrackParamVector::BetheBlochGas(
const sfloat_v &bg )
337 const sfloat_v rho = 0.9e-3f;
338 const sfloat_v x0 = 2.f;
339 const sfloat_v x1 = 4.f;
340 const sfloat_v mI = 140.e-9f;
341 const sfloat_v mZA = 0.49555f;
343 return BetheBlochGeant( bg, rho, x0, x1, mI, mZA );
349 sfloat_v AliHLTTPCCATrackParamVector::ApproximateBetheBloch(
const sfloat_v &beta2 )
357 const sfloat_v &beta2_1subBeta2 = beta2 / ( sfloat_v( Vc::One ) - beta2 );
358 const sfloat_v &_0p000153_beta2 = 0.153e-3f / beta2;
359 const float log_3p5mul5940 = 9.942227380852058f;
360 const float log_5940 = 8.68946441235669f;
361 const sfloat_v &log_beta2_1subBeta2 = CAMath::Log( beta2_1subBeta2 );
363 sfloat_v ret = _0p000153_beta2 * ( log_5940 + log_beta2_1subBeta2 - beta2 );
364 ret( beta2_1subBeta2 > 3.5f*3.5f ) =
365 _0p000153_beta2 * ( log_3p5mul5940 + 0.5f * log_beta2_1subBeta2 - beta2 );
366 ret.setZero( beta2 >= sfloat_v( Vc::One ) );
371 void AliHLTTPCCATrackParamVector::CalculateFitParameters( AliHLTTPCCATrackFitParam &par,
const sfloat_v &mass )
375 const sfloat_v p2 = ( sfloat_v( Vc::One ) + fP[3] * fP[3] );
377 sfloat_v k2 = fP[4] * fP[4];
378 const sfloat_v mass2 = mass * mass;
379 const sfloat_v beta2 = p2 / ( p2 + mass2 * k2 );
382 const sfloat_m badK2 = k2 <= 1.e-8f;
384 sfloat_v pp2 = 10000.f; pp2( !badK2 ) = p2 / k2;
387 par.fBethe = ApproximateBetheBloch( pp2 / mass2 );
388 par.fE = CAMath::Sqrt( pp2 + mass2 );
389 par.fTheta2 = 14.1f * 14.1f / ( beta2 * pp2 * 1.e6f );
390 par.fEP2 = par.fE / pp2;
394 const float knst = 0.07f;
395 par.fSigmadE2 = knst * par.fEP2 * fP[4];
396 par.fSigmadE2 = par.fSigmadE2 * par.fSigmadE2;
398 par.fK22 = ( sfloat_v( Vc::One ) + fP[3] * fP[3] );
399 par.fK33 = par.fK22 * par.fK22;
400 par.fK43 = fP[3] * fP[4] * par.fK22;
401 par.fK44 = fP[3] * fP[3] * fP[4] * fP[4];
405 sfloat_m AliHLTTPCCATrackParamVector::CorrectForMeanMaterial(
const sfloat_v &xOverX0,
const sfloat_v &xTimesRho,
const AliHLTTPCCATrackFitParam &par,
const sfloat_m &_mask )
413 sfloat_v &fC22 = fC[5];
414 sfloat_v &fC33 = fC[9];
415 sfloat_v &fC40 = fC[10];
416 sfloat_v &fC41 = fC[11];
417 sfloat_v &fC42 = fC[12];
418 sfloat_v &fC43 = fC[13];
419 sfloat_v &fC44 = fC[14];
423 const sfloat_v &dE = par.fBethe * xTimesRho;
424 sfloat_m mask = _mask && CAMath::Abs( dE ) <= 0.3f * par.fE;
425 const sfloat_v &corr = ( sfloat_v( Vc::One ) - par.fEP2 * dE );
426 mask &= corr >= 0.3f && corr <= 1.3f;
428 fP[4]( mask ) *= corr;
429 fC40 ( mask ) *= corr;
430 fC41 ( mask ) *= corr;
431 fC42 ( mask ) *= corr;
432 fC43 ( mask ) *= corr;
433 fC44 ( mask ) *= corr * corr;
434 fC44 ( mask ) += par.fSigmadE2 * CAMath::Abs( dE );
438 const sfloat_v &theta2 = par.fTheta2 * CAMath::Abs( xOverX0 );
439 fC22( mask ) += theta2 * par.fK22 * ( sfloat_v( Vc::One ) - fP[2] * fP[2] );
440 fC33( mask ) += theta2 * par.fK33;
441 fC43( mask ) += theta2 * par.fK43;
442 fC44( mask ) += theta2 * par.fK44;
448 const float maxSinPhi,
const sfloat_m &mask )
452 const sfloat_v cA = CAMath::Cos( alpha );
453 const sfloat_v sA = CAMath::Sin( alpha );
454 const sfloat_v x0 = X(),y0 = Y(), sP = t0.SinPhi(), cP = t0.CosPhi();
455 const sfloat_v cosPhi = cP * cA + sP * sA;
456 const sfloat_v sinPhi = -cP * sA + sP * cA;
458 sfloat_m ReturnMask(mask);
459 ReturnMask &= (!( CAMath::Abs( sinPhi ) > maxSinPhi || CAMath::Abs( cosPhi ) < 1.e-2f || CAMath::Abs( cP ) < 1.e-2f ));
467 const sfloat_v j0 = cP / cosPhi;
468 const sfloat_v j2 = cosPhi / cP;
469 const sfloat_v d = SinPhi() - sP;
471 SetX( x0*cA + y0*sA, ReturnMask );
472 SetY(-x0*sA + y0*cA, ReturnMask );
473 t0.SetCosPhi( cosPhi );
474 t0.SetSinPhi( sinPhi );
476 SetSinPhi( sinPhi + j2*d, ReturnMask );
478 fC[0](ReturnMask) *= j0 * j0;
479 fC[1](ReturnMask) *= j0;
480 fC[3](ReturnMask) *= j0;
481 fC[6](ReturnMask) *= j0;
482 fC[10](ReturnMask) *= j0;
484 fC[3](ReturnMask) *= j2;
485 fC[4](ReturnMask) *= j2;
486 fC[5](ReturnMask) *= j2 * j2;
487 fC[8](ReturnMask) *= j2;
488 fC[12](ReturnMask) *= j2;
493 sfloat_m AliHLTTPCCATrackParamVector::FilterWithMaterial(
const sfloat_v &y,
const sfloat_v &z, sfloat_v err2Y, sfloat_v err2Z,
494 float maxSinPhi,
const sfloat_m &mask )
496 assert( maxSinPhi > 0.f );
499 const sfloat_v c00 = fC[0];
500 const sfloat_v c10 = fC[1];
501 const sfloat_v c11 = fC[2];
502 const sfloat_v c20 = fC[3];
503 const sfloat_v c21 = fC[4];
505 const sfloat_v c30 = fC[6];
506 const sfloat_v c31 = fC[7];
509 const sfloat_v c40 = fC[10];
510 const sfloat_v c41 = fC[11];
515 sfloat_v d = sfloat_v( Vc::One ) / ( err2Y*err2Z + err2Y*c11 + err2Z*c00 + c00*c11 - c10*c10 );
523 sfloat_m success = mask;
524 success &= (err2Y > 1.e-8f ) && ( err2Z > 1.e-8f );
526 const sfloat_v mS0 = err2Z*d;
527 const sfloat_v mS1 = -c10*d;
528 const sfloat_v mS2 = err2Y*d;
533 k00 = c00 * mS0 + c10*mS1, k01 = c00 * mS1 + c10*mS2,
534 k10 = c10 * mS0 + c11*mS1, k11 = c10 * mS1 + c11*mS2,
535 k20 = c20 * mS0 + c21*mS1, k21 = c20 * mS1 + c21*mS2,
536 k30 = c30 * mS0 + c31*mS1, k31 = c30 * mS1 + c31*mS2,
537 k40 = c40 * mS0 + c41*mS1, k41 = c40 * mS1 + c41*mS2;
539 const sfloat_v sinPhi = fP[2] + k20 * z0 + k21 * z1;
541 success &= CAMath::Abs( sinPhi ) < maxSinPhi;
543 fNDF( static_cast<short_m>(success) ) += 2;
544 fChi2(success) += mS0 * z0 * z0 + mS2 * z1 * z1 + 2 * z0 * z1 * mS1;
546 fP[ 0](success) += k00 * z0 + k01 * z1;
547 fP[ 1](success) += k10 * z0 + k11 * z1;
548 fP[ 2](success) = sinPhi ;
549 fP[ 3](success) += k30 * z0 + k31 * z1;
550 fP[ 4](success) += k40 * z0 + k41 * z1;
552 fC[ 0](success) -= (k00 * c00 + k01 * c10);
554 fC[ 1](success) -= (k10 * c00 + k11 * c10);
555 fC[ 2](success) -= (k10 * c10 + k11 * c11);
557 fC[ 3](success) -= (k20 * c00 + k21 * c10);
558 fC[ 4](success) -= (k20 * c10 + k21 * c11);
559 fC[ 5](success) -= (k20 * c20 + k21 * c21);
561 fC[ 6](success) -= (k30 * c00 + k31 * c10);
562 fC[ 7](success) -= (k30 * c10 + k31 * c11);
563 fC[ 8](success) -= (k30 * c20 + k31 * c21);
564 fC[ 9](success) -= (k30 * c30 + k31 * c31);
566 fC[10](success) -= (k40 * c00 + k41 * c10);
567 fC[11](success) -= (k40 * c10 + k41 * c11);
568 fC[12](success) -= (k40 * c20 + k41 * c21);
569 fC[13](success) -= (k40 * c30 + k41 * c31);
570 fC[14](success) -= (k40 * c40 + k41 * c41);
579 sfloat_v::Memory x, s, p[5], c[15], chi2;
581 for (
int j = 0; j < ushort_v::Size; ++j ) {
584 for (
int i = 0; i < 5; i++ ) in >> p[i][j];
585 for (
int i = 0; i < 15; i++ ) in >> c[i][j];
590 t.fSignCosPhi.load( s );
591 for (
int i = 0; i < 5; i++ ) t.fP[i].load( p[i] );
592 for (
int i = 0; i < 5; i++ ) t.fC[i].load( c[i] );
593 t.fChi2.load( chi2 );
600 if ( &out == &std::cerr ) {
601 out <<
"------------------------------ Track Param ------------------------------"
604 <<
"\n Chi2: " << t.Chi2()
605 <<
"\n NDF: " << t.NDF()
606 <<
"\n Y: " << t.Par()[0]
607 <<
"\n Z: " << t.Par()[1]
608 <<
"\n SinPhi: " << t.Par()[2]
609 <<
"\n DzDs: " << t.Par()[3]
610 <<
"\n q/Pt: " << t.Par()[4]
611 <<
"\nCovariance Matrix\n";
613 out << std::setprecision( 2 );
614 for (
int step = 1; step <= 5; ++step ) {
616 for ( ; i < end; ++i ) {
617 out << t.Cov()[i] <<
'\t';
621 out << std::setprecision( 6 );
622 return out << std::endl;
624 for (
int j = 0; j < ushort_v::Size; ++j ) {
625 out << t.X()[j] <<
" "
627 << t.Chi2()[j] <<
" "
630 for (
int i = 0; i < 5; i++ ) out << t.Par()[i][j] <<
" ";
632 for (
int i = 0; i < 15; i++ ) out << t.Cov()[i][j] <<
" ";
sfloat_v SignCosPhi() const