StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
AliHLTTPCCATrackParamVector.cxx
1 // $Id: AliHLTTPCCATrackParamVector.cxx,v 1.1 2016/02/05 23:27:29 fisyak Exp $
2 // **************************************************************************
3 // This file is property of and copyright by the ALICE HLT Project *
4 // ALICE Experiment at CERN, All rights reserved. *
5 // *
6 // Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
7 // Ivan Kisel <kisel@kip.uni-heidelberg.de> *
8 // for The ALICE HLT Project. *
9 // *
10 // Developed by: Igor Kulakov <I.Kulakov@gsi.de> *
11 // Maksym Zyzak <M.Zyzak@gsi.de> *
12 // *
13 // Permission to use, copy, modify and distribute this software and its *
14 // documentation strictly for non-commercial purposes is hereby granted *
15 // without fee, provided that the above copyright notice appears in all *
16 // copies and that both the copyright notice and this permission notice *
17 // appear in the supporting documentation. The authors make no claims *
18 // about the suitability of this software for any purpose. It is *
19 // provided "as is" without express or implied warranty. *
20 // *
21 //***************************************************************************
22 
23 
24 #include "AliHLTTPCCATrackParamVector.h"
25 #include "AliHLTTPCCAMath.h"
26 #include "AliHLTTPCCATrackLinearisationVector.h"
27 #include <iostream>
28 #include <iomanip>
29 
30 #include <assert.h>
31 #include "debug.h"
32 
33 //
34 // Circle in XY:
35 //
36 // kCLight = 0.000299792458;
37 // Kappa = Bz*kCLight*QPt;
38 // R = 1/CAMath::Abs(Kappa);
39 // Xc = X - sin(Phi)/Kappa;
40 // Yc = Y + cos(Phi)/Kappa;
41 //
42 
43 sfloat_v AliHLTTPCCATrackParamVector::GetDist2( const AliHLTTPCCATrackParamVector &t ) const
44 {
45  // get squared distance between tracks
46 
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;
51 }
52 
53 sfloat_v AliHLTTPCCATrackParamVector::GetDistXZ2( const AliHLTTPCCATrackParamVector &t ) const
54 {
55  // get squared distance between tracks in X&Z
56 
57  const sfloat_v &dx = GetX() - t.GetX();
58  const sfloat_v &dz = GetZ() - t.GetZ();
59  return dx*dx + dz*dz;
60 }
61 
62 
63 sfloat_v AliHLTTPCCATrackParamVector::GetS( const sfloat_v &_x, const sfloat_v &_y, const sfloat_v &Bz ) const
64 {
65  //* Get XY path length to the given point
66 
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;
76  }
77  return dS;
78 }
79 
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
82 {
83  //* Get the track point closest to the (x,y,z)
84 
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;
102 }
103 
104 
105 //*
106 //* Transport routines
107 //*
108 
109 
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 )
111 {
112  //* Transport the track parameters to X=x, using linearization at t0, and the field value Bz
113  //* maxSinPhi is the max. allowed value for |t0.SinPhi()|
114  //* linearisation of trajectory t0 is also transported to X=x,
115  //* returns 1 if OK
116  //*
117 
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();
122 
123  sfloat_v ey1 = k * dx + ey;
124 
125  // check for intersection with X=x
126 
127  sfloat_v ex1 = CAMath::Sqrt( 1.f - ey1 * ey1 );
128  ex1( ex < Vc::Zero ) = -ex1;
129 
130  const sfloat_v dx2 = dx * dx;
131  const sfloat_v ss = ey + ey1;
132  const sfloat_v cc = ex + ex1;
133 
134  const sfloat_v cci = 1.f / cc;
135  const sfloat_v exi = 1.f / ex;
136  const sfloat_v ex1i = 1.f / ex1;
137 
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;
139 
140  const sfloat_v tg = ss * cci; // tan((phi1+phi)/2)
141 
142  const sfloat_v dy = dx * tg;
143  sfloat_v dl = dx * CAMath::Sqrt( 1.f + tg * tg );
144 
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();
149 
150  if ( DL ) {
151  ( *DL )( mask ) = -dS * CAMath::Sqrt( 1.f + t0.DzDs() * t0.DzDs() );
152  }
153 
154  const sfloat_v d[3] = { fP[2] - t0.SinPhi(), fP[3] - t0.DzDs(), fP[4] - t0.QPt() };
155 
156  //float H0[5] = { 1,0, h2, 0, h4 };
157  //float H1[5] = { 0, 1, 0, dS, 0 };
158  //float H2[5] = { 0, 0, 1, 0, dxBz };
159  //float H3[5] = { 0, 0, 0, 1, 0 };
160  //float H4[5] = { 0, 0, 0, 0, 1 };
161 
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;
165 
166  ex1( !mask ) = ex;
167  ey1( !mask ) = ey;
168  t0.SetCosPhi( ex1 );
169  t0.SetSinPhi( ey1 );
170 
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();
176 
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];
192 
193  fC[0]( mask ) = ( c00 + h2 * h2 * c22 + h4 * h4 * c44
194  + 2.f * ( h2 * c20 + h4 * c40 + h2 * h4 * c42 ) );
195 
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;
198 
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;
202 
203  fC[6]( mask ) = c30 + h2 * c32 + h4 * c43;
204  fC[7]( mask ) = c31 + dS * c33;
205  fC[8]( mask ) = c32 + dxBz * c43;
206  fC[9]( mask ) = c33;
207 
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;
213 
214  debugKF() << mask << "\n" << *this << std::endl;
215  return mask;
216 }
217 
218 
219 sfloat_m AliHLTTPCCATrackParamVector::TransportToX( const sfloat_v &x, const sfloat_v &Bz,
220  const float maxSinPhi, const sfloat_m &mask )
221 {
222  //* Transport the track parameters to X=x
223 
224 // assert( ( x == 0 && mask ).isEmpty() );
225 
227 
228  return TransportToX( x, t0, Bz, maxSinPhi, 0, mask );
229 }
230 
231 
232 
233 sfloat_m AliHLTTPCCATrackParamVector::TransportToXWithMaterial( const sfloat_v &x, AliHLTTPCCATrackLinearisationVector &t0, AliHLTTPCCATrackFitParam &par, const sfloat_v &Bz, const float maxSinPhi, const sfloat_m &mask_ )
234 {
235  //* Transport the track parameters to X=x taking into account material budget
236 
237  const float kRho = 1.025e-3f;//0.9e-3;
238 // const float kRadLen = 29.532f;//28.94;
239 // const float kRhoOverRadLen = kRho / kRadLen;
240  const float kRhoOverRadLen = 7.68e-5;
241  sfloat_v dl;
242 
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 );
246  }
247 
248  return mask;
249 }
250 
251 
252 sfloat_m AliHLTTPCCATrackParamVector::TransportToXWithMaterial( const sfloat_v &x, AliHLTTPCCATrackFitParam &par, const sfloat_v &Bz, const float maxSinPhi )
253 {
254  //* Transport the track parameters to X=x taking into account material budget
255 
257  return TransportToXWithMaterial( x, t0, par, Bz, maxSinPhi );
258 }
259 
260 sfloat_m AliHLTTPCCATrackParamVector::TransportToXWithMaterial( const sfloat_v &x, const sfloat_v &Bz, const float maxSinPhi )
261 {
262  //* Transport the track parameters to X=x taking into account material budget
263 
264  AliHLTTPCCATrackFitParam par;
265  CalculateFitParameters( par );
266  return TransportToXWithMaterial( x, par, Bz, maxSinPhi );
267 }
268 
269 
270 //*
271 //* Multiple scattering and energy losses
272 //*
273 
274 
275 sfloat_v AliHLTTPCCATrackParamVector::BetheBlochGeant( const sfloat_v &bg2,
276  const sfloat_v &kp0,
277  const sfloat_v &kp1,
278  const sfloat_v &kp2,
279  const sfloat_v &kp3,
280  const sfloat_v &kp4 )
281 {
282  //
283  // This is the parameterization of the Bethe-Bloch formula inspired by Geant.
284  //
285  // bg2 - (beta*gamma)^2
286  // kp0 - density [g/cm^3]
287  // kp1 - density effect first junction point
288  // kp2 - density effect second junction point
289  // kp3 - mean excitation energy [GeV]
290  // kp4 - mean Z/A
291  //
292  // The default values for the kp* parameters are for silicon.
293  // The returned value is in [GeV/(g/cm^2)].
294  //
295 
296  const float mK = 0.307075e-3f; // [GeV*cm^2/g]
297  const float _2me = 1.022e-3f; // [GeV/c^2]
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; // neglecting the electron mass
304 
305  //*** Density effect
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;
312 
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 );
314 }
315 
316 sfloat_v AliHLTTPCCATrackParamVector::BetheBlochSolid( const sfloat_v &bg )
317 {
318  //------------------------------------------------------------------
319  // This is an approximation of the Bethe-Bloch formula,
320  // reasonable for solid materials.
321  // All the parameters are, in fact, for Si.
322  // The returned value is in [GeV]
323  //------------------------------------------------------------------
324 
325  return BetheBlochGeant( bg );
326 }
327 
328 sfloat_v AliHLTTPCCATrackParamVector::BetheBlochGas( const sfloat_v &bg )
329 {
330  //------------------------------------------------------------------
331  // This is an approximation of the Bethe-Bloch formula,
332  // reasonable for gas materials.
333  // All the parameters are, in fact, for Ne.
334  // The returned value is in [GeV]
335  //------------------------------------------------------------------
336 
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;
342 
343  return BetheBlochGeant( bg, rho, x0, x1, mI, mZA );
344 }
345 
346 
347 
348 
349 sfloat_v AliHLTTPCCATrackParamVector::ApproximateBetheBloch( const sfloat_v &beta2 )
350 {
351  //------------------------------------------------------------------
352  // This is an approximation of the Bethe-Bloch formula with
353  // the density effect taken into account at beta*gamma > 3.5
354  // (the approximation is reasonable only for solid materials)
355  //------------------------------------------------------------------
356 
357  const sfloat_v &beta2_1subBeta2 = beta2 / ( sfloat_v( Vc::One ) - beta2 ); // beta2 * CAMath::Reciprocal( sfloat_v( Vc::One ) - beta2 );
358  const sfloat_v &_0p000153_beta2 = 0.153e-3f / beta2;
359  const float log_3p5mul5940 = 9.942227380852058f; // log( 3.5 * 5940 )
360  const float log_5940 = 8.68946441235669f; // log( 5940 )
361  const sfloat_v &log_beta2_1subBeta2 = CAMath::Log( beta2_1subBeta2 );
362 
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 ) );
367  return ret;
368 }
369 
370 
371 void AliHLTTPCCATrackParamVector::CalculateFitParameters( AliHLTTPCCATrackFitParam &par, const sfloat_v &mass )
372 {
373  //*!
374 
375  const sfloat_v p2 = ( sfloat_v( Vc::One ) + fP[3] * fP[3] );
376  // const sfloat_v k2 = fP[4] * fP[4];
377  sfloat_v k2 = fP[4] * fP[4];
378  const sfloat_v mass2 = mass * mass;
379  const sfloat_v beta2 = p2 / ( p2 + mass2 * k2 );
380 
381  // sfloat_v pp2 = 10000.f; pp2( k2 > 1.e-8f ) = p2 / k2; // impuls 2
382  const sfloat_m badK2 = k2 <= 1.e-8f;
383  k2(badK2) = 1.f;
384  sfloat_v pp2 = 10000.f; pp2( !badK2 ) = p2 / k2; // impuls 2
385 
386  //par.fBethe = BetheBlochGas( pp2/mass2);
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;
391 
392  // Approximate energy loss fluctuation (M.Ivanov)
393 
394  const float knst = 0.07f; // To be tuned.
395  par.fSigmadE2 = knst * par.fEP2 * fP[4];
396  par.fSigmadE2 = par.fSigmadE2 * par.fSigmadE2;
397 
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];
402 }
403 
404 
405 sfloat_m AliHLTTPCCATrackParamVector::CorrectForMeanMaterial( const sfloat_v &xOverX0, const sfloat_v &xTimesRho, const AliHLTTPCCATrackFitParam &par, const sfloat_m &_mask )
406 {
407  //------------------------------------------------------------------
408  // This function corrects the track parameters for the crossed material.
409  // "xOverX0" - X/X0, the thickness in units of the radiation length.
410  // "xTimesRho" - is the product length*density (g/cm^2).
411  //------------------------------------------------------------------
412 
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];
420 
421  //Energy losses************************
422 
423  const sfloat_v &dE = par.fBethe * xTimesRho;
424  sfloat_m mask = _mask && CAMath::Abs( dE ) <= 0.3f * par.fE; //30% energy loss is too much!
425  const sfloat_v &corr = ( sfloat_v( Vc::One ) - par.fEP2 * dE );
426  mask &= corr >= 0.3f && corr <= 1.3f;
427 
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 );
435 
436  //Multiple scattering******************
437 
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;
443 
444  return mask;
445 }
446 
447 sfloat_m AliHLTTPCCATrackParamVector::Rotate( const sfloat_v &alpha, AliHLTTPCCATrackLinearisationVector &t0,
448  const float maxSinPhi, const sfloat_m &mask )
449 {
450  //* Rotate the coordinate system in XY on the angle alpha
451 
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;
457 
458  sfloat_m ReturnMask(mask);
459  ReturnMask &= (!( CAMath::Abs( sinPhi ) > maxSinPhi || CAMath::Abs( cosPhi ) < 1.e-2f || CAMath::Abs( cP ) < 1.e-2f ));
460 
461  //float J[5][5] = { { j0, 0, 0, 0, 0 }, // Y
462  // { 0, 1, 0, 0, 0 }, // Z
463  // { 0, 0, j2, 0, 0 }, // SinPhi
464  // { 0, 0, 0, 1, 0 }, // DzDs
465  // { 0, 0, 0, 0, 1 } }; // Kappa
466 
467  const sfloat_v j0 = cP / cosPhi;
468  const sfloat_v j2 = cosPhi / cP;
469  const sfloat_v d = SinPhi() - sP;
470 
471  SetX( x0*cA + y0*sA, ReturnMask );
472  SetY(-x0*sA + y0*cA, ReturnMask );
473  t0.SetCosPhi( cosPhi );
474  t0.SetSinPhi( sinPhi );
475 
476  SetSinPhi( sinPhi + j2*d, ReturnMask );
477 
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;
483 
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;
489 
490  return ReturnMask;
491 }
492 
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 )
495 {
496  assert( maxSinPhi > 0.f );
497  //* Add the y,z measurement with the Kalman filter
498 
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];
504 // float c22 = fC[5];
505  const sfloat_v c30 = fC[6];
506  const sfloat_v c31 = fC[7];
507 // float c32 = fC[8];
508 // float c33 = fC[9];
509  const sfloat_v c40 = fC[10];
510  const sfloat_v c41 = fC[11];
511 // float c42 = fC[12];
512 // float c43 = fC[13];
513 // float c44 = fC[14];
514 
515  sfloat_v d = sfloat_v( Vc::One ) / ( err2Y*err2Z + err2Y*c11 + err2Z*c00 + c00*c11 - c10*c10 );
516  err2Y += c00;
517  err2Z += c11;
518 
519  const sfloat_v
520  z0 = y - fP[0],
521  z1 = z - fP[1];
522 
523  sfloat_m success = mask;// if ( ISUNLIKELY( err2Y < 1.e-8f ) || ISUNLIKELY( err2Z < 1.e-8f ) ) return 0;
524  success &= (err2Y > 1.e-8f ) && ( err2Z > 1.e-8f );
525 
526  const sfloat_v mS0 = err2Z*d;
527  const sfloat_v mS1 = -c10*d;
528  const sfloat_v mS2 = err2Y*d;
529 
530  // K = CHtS
531 
532  const sfloat_v
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;
538 
539  const sfloat_v sinPhi = fP[2] + k20 * z0 + k21 * z1;
540 
541  success &= CAMath::Abs( sinPhi ) < maxSinPhi;
542 
543  fNDF( static_cast<short_m>(success) ) += 2;
544  fChi2(success) += mS0 * z0 * z0 + mS2 * z1 * z1 + 2 * z0 * z1 * mS1;
545 
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;
551 
552  fC[ 0](success) -= (k00 * c00 + k01 * c10); //c00
553 
554  fC[ 1](success) -= (k10 * c00 + k11 * c10); //c10
555  fC[ 2](success) -= (k10 * c10 + k11 * c11); //c11
556 
557  fC[ 3](success) -= (k20 * c00 + k21 * c10); //c20
558  fC[ 4](success) -= (k20 * c10 + k21 * c11); //c21
559  fC[ 5](success) -= (k20 * c20 + k21 * c21); //c22
560 
561  fC[ 6](success) -= (k30 * c00 + k31 * c10); //c30
562  fC[ 7](success) -= (k30 * c10 + k31 * c11); //c31
563  fC[ 8](success) -= (k30 * c20 + k31 * c21); //c32
564  fC[ 9](success) -= (k30 * c30 + k31 * c31); //c33
565 
566  fC[10](success) -= (k40 * c00 + k41 * c10); //c40
567  fC[11](success) -= (k40 * c10 + k41 * c11); //c41
568  fC[12](success) -= (k40 * c20 + k41 * c21); //c42
569  fC[13](success) -= (k40 * c30 + k41 * c31); //c43
570  fC[14](success) -= (k40 * c40 + k41 * c41); //c44
571 
572  return success;
573 }
574 
575 #include <iostream>
576 
577 std::istream &operator>>( std::istream &in, AliHLTTPCCATrackParamVector &t )
578 {
579  sfloat_v::Memory x, s, p[5], c[15], chi2;
580  short_v::Memory ndf;
581  for ( int j = 0; j < ushort_v::Size; ++j ) {
582  in >> x[j];
583  in >> s[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];
586  in >> chi2[j];
587  in >> ndf[j];
588  }
589  t.fX.load( x );
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 );
594  t.fNDF.load( ndf );
595  return in;
596 }
597 
598 std::ostream &operator<<( std::ostream &out, const AliHLTTPCCATrackParamVector &t )
599 {
600  if ( &out == &std::cerr ) {
601  out << "------------------------------ Track Param ------------------------------"
602  << "\n X: " << t.X()
603  << "\n SignCosPhi: " << t.SignCosPhi()
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";
612  int i = 0;
613  out << std::setprecision( 2 );
614  for ( int step = 1; step <= 5; ++step ) {
615  int end = i + step;
616  for ( ; i < end; ++i ) {
617  out << t.Cov()[i] << '\t';
618  }
619  out << "\n";
620  }
621  out << std::setprecision( 6 );
622  return out << std::endl;
623  }
624  for ( int j = 0; j < ushort_v::Size; ++j ) {
625  out << t.X()[j] << " "
626  << t.SignCosPhi()[j] << " "
627  << t.Chi2()[j] << " "
628  << t.NDF()[j]
629  << std::endl;
630  for ( int i = 0; i < 5; i++ ) out << t.Par()[i][j] << " ";
631  out << std::endl;
632  for ( int i = 0; i < 15; i++ ) out << t.Cov()[i][j] << " ";
633  out << std::endl;
634  }
635  return out;
636 }