FairRoot/PandaRoot
PndCATrackParamVector.cxx
Go to the documentation of this file.
1 // $Id: PndCATrackParamVector.cxx,v 1.1.1.1 2010/07/26 20:55:38 ikulakov 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 "PndCATrackParamVector.h"
25 #include "PndCAMath.h"
27 #include "PndCAParam.h"
28 #include "PndCAHitsV.h"
29 #include "PndCATarget.h"
30 
31 #include <iostream>
32 #include <iomanip>
33 // #ifndef NVALGRIND
34 // #include <valgrind/memcheck.h>
35 // #endif
36 #include <assert.h>
37 //#include "debug.h"
38 
39 //
40 // Circle in XY:
41 //
42 // kCLight = 0.000299792458;
43 // Kappa = Bz*kCLight*QPt;
44 // R = 1/CAMath::Abs(Kappa);
45 // Xc = X - sin(Phi)/Kappa;
46 // Yc = Y + cos(Phi)/Kappa;
47 //
48 
50 {
51  SetCov( 0.f, 100.f );
52  SetCov( 1, 0.f );
53  SetCov( 2, 100.f );
54  SetCov( 3, 0.f );
55  SetCov( 4, 0.f );
56  SetCov( 5, 1.f );
57  SetCov( 6, 0.f );
58  SetCov( 7, 0.f );
59  SetCov( 8, 0.f );
60  SetCov( 9, 1.f );
61  SetCov(10, 0.f );
62  SetCov(11, 0.f );
63  SetCov(12, 0.f );
64  SetCov(13, 0.f );
65  SetCov(14, d2QMom );
66 
67  SetChi2( 0.f );
68 
69  SetNDF( -5 );
70 }
71 
73 {
74  SetX( t.X0() );
75  SetY( t.X1() );
76  SetZ( t.X2() );
77  SetSinPhi( 1.f );
78  SetSignCosPhi( 0.f );
79  SetDzDs( 0.f );
80  SetQPt( 0.f );
81  SetCov( 0.f, t.Err2X1() );
82  SetCov( 1, 0.f );
83  SetCov( 2, t.Err2X2() );
84  SetCov( 3, 0.f );
85  SetCov( 4, 0.f );
86  SetCov( 5, 1.f );
87  SetCov( 6, 0.f );
88  SetCov( 7, 0.f );
89  SetCov( 8, 0.f );
90  SetCov( 9, 1.f );
91  SetCov(10, 0.f );
92  SetCov(11, 0.f );
93  SetCov(12, 0.f );
94  SetCov(13, 0.f );
95  SetCov(14, t.Err2QMom() );
96 
97  SetChi2( 0.f );
98 
99  SetNDF( -5 + t.NDF() );
100 
101  // SetField( 0, t.B(), t.X0() );
102 }
103 
104 
105 void PndCATrackParamVector::InitByHit( const PndCAHitV& hit, const PndCAParam& param, const float_v& dQMom )
106 {
107  SetX( hit.X0() );
108  SetY( hit.X1() );
109  SetZ( hit.X2() );
110  SetSinPhi( 0.f );
111  SetSignCosPhi( 1.f );
112  SetDzDs( 0.f );
113  SetQPt( 0.f );
114  SetAngle( hit.Angle() );
115 
116  SetCov( 0, hit.Err2X1() );
117  SetCov( 1, 0.f );
118  SetCov( 2, hit.Err2X2() );
119  SetCov( 3, 0.f );
120  SetCov( 4, 0.f );
121  SetCov( 5, 1.f );
122  SetCov( 6, 0.f );
123  SetCov( 7, 0.f );
124  SetCov( 8, 0.f );
125  SetCov( 9, 1.f );
126  SetCov(10, 0.f );
127  SetCov(11, 0.f );
128  SetCov(12, 0.f );
129  SetCov(13, 0.f );
130  SetCov(14, dQMom*dQMom );
131 
132  SetChi2( 0.f );
133 
134  SetNDF( -3 );
135 
136  UNUSED_PARAM1(param);
137  // const int ista0 = hit.IStation();
138  // const PndCAStation sta0 = param.Station(ista0);
139 
140  // L1FieldValue B;
141  // sta0.fieldSlice.GetFieldValue( hit.X1(), hit.X2(), B );
142  // SetField( 1, B, sta0.z );
143 
144  // if ( ista0 > 0 ) {
145  // const L1Station staC = param.Station(ista0/2); // The field will be used to propaget to the target. Therefore take station in a middle between target and hit.
146  // const float_v tx1 = hit.X1()/hit.X0(); // suppose target is at 0
147  // const float_v tx2 = hit.X2()/hit.X0(); // suppose target is at 0
148  // staC.fieldSlice.GetFieldValue( tx1*staC.z, tx2*staC.z, B );
149  // SetField( 0, B, staC.z );
150  // }
151 }
152 
154 {
155  // get squared distance between tracks
156 
157  const float_v &dx = GetX() - t.GetX();
158  const float_v &dy = GetY() - t.GetY();
159  const float_v &dz = GetZ() - t.GetZ();
160  return dx*dx + dy*dy + dz*dz;
161 }
162 
164 {
165  // get squared distance between tracks in X&Z
166 
167  const float_v &dx = GetX() - t.GetX();
168  const float_v &dz = GetZ() - t.GetZ();
169  return dx*dx + dz*dz;
170 }
171 
172 
173 float_v PndCATrackParamVector::GetS( const float_v &_x, const float_v &_y, const float_v &Bz ) const
174 {
175  //* Get XY path length to the given point
176 
177  const float_v &k = GetKappa( Bz );
178  const float_v &ex = GetCosPhi();
179  const float_v &ey = GetSinPhi();
180  const float_v &x = _x - GetX();
181  const float_v &y = _y - GetY();
182  float_v dS = x * ex + y * ey;
183  const float_m &mask = CAMath::Abs( k ) > 1.e-4f;
184  if ( !mask.isEmpty() ) {
185  dS( mask ) = CAMath::ATan2( k * dS, 1 + k * ( x * ey - y * ex ) ) / k;
186  }
187  return dS;
188 }
189 
190 void PndCATrackParamVector::GetDCAPoint( const float_v &x, const float_v &y, const float_v &z,
191  float_v *xp, float_v *yp, float_v *zp, const float_v &Bz ) const
192 {
193  //* Get the track point closest to the (x,y,z)
194 
195  const float_v &x0 = GetX();
196  const float_v &y0 = GetY();
197  const float_v &k = GetKappa( Bz );
198  const float_v &ex = GetCosPhi();
199  const float_v &ey = GetSinPhi();
200  const float_v &dx = x - x0;
201  const float_v &dy = y - y0;
202  const float_v &ax = dx * k + ey;
203  const float_v &ay = dy * k - ex;
204  const float_v &a = sqrt( ax * ax + ay * ay );
205  *xp = x0 + ( dx - ey * ( ( dx * dx + dy * dy ) * k - 2.f * ( -dx * ey + dy * ex ) ) / ( a + 1.f ) ) / a;
206  *yp = y0 + ( dy + ex * ( ( dx * dx + dy * dy ) * k - 2.f * ( -dx * ey + dy * ex ) ) / ( a + 1.f ) ) / a;
207  const float_v s = GetS( x, y, Bz );
208  *zp = GetZ() + GetDzDs() * s;
209  const float_v dZ = CAMath::Abs( GetDzDs() * CAMath::TwoPi() / k );
210  const float_m mask = CAMath::Abs( k ) > 1.e-2f && dZ > .1f;
211  ( *zp )( mask ) += CAMath::Round( ( z - *zp ) / dZ ) * dZ;
212 }
213 
214 
215 //*
216 //* Transport routines
217 //*
218 
219 
220 float_m PndCATrackParamVector::TransportToX( const float_v &x, PndCATrackLinearisationVector &t0, const float_v &Bz, const float maxSinPhi, float_v *DL, const float_m &_mask )
221 {
222  //* Transport the track parameters to X=x, using linearization at t0, and the field value Bz
223  //* maxSinPhi is the max. allowed value for |t0.SinPhi()|
224  //* linearisation of trajectory t0 is also transported to X=x,
225  //* returns 1 if OK
226  //*
227 // std::cout << t0.QPt()[0] << " " << fP[4][0] << std::endl;
228  const float_v ex = t0.CosPhi();
229  const float_v ey = t0.SinPhi();
230  const float_v k = t0.QPt() * Bz;
231  const float_v dx = x - X();
232 
233  float_v ey1 = k * dx + ey;
234 
235  // check for intersection with X=x
236 
237  float_v ex1 = CAMath::Sqrt( 1.f - ey1 * ey1 );
238  ex1( ex < Vc::Zero ) = -ex1;
239 
240  const float_v dx2 = dx * dx;
241  const float_v ss = ey + ey1;
242  const float_v cc = ex + ex1;
243 
244  const float_v cci = 1.f / cc;
245  const float_v exi = 1.f / ex;
246  const float_v ex1i = 1.f / ex1;
247 
248  float_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;
249 
250  const float_v tg = ss * cci; // tan((phi1+phi)/2)
251 
252  const float_v dy = dx * tg;
253  float_v dl = dx * CAMath::Sqrt( 1.f + tg * tg );
254 
255  dl( cc < Vc::Zero ) = -dl;
256  const float_v dSin = CAMath::Max( float_v( -1.f ), CAMath::Min( float_v( Vc::One ), dl * k * 0.5f ) );
257  const float_v dS = ( CAMath::Abs( k ) > 1.e-4f ) ? ( 2 * CAMath::ASin( dSin ) / k ) : dl;
258  const float_v dz = dS * t0.DzDs();
259 
260  if ( DL ) {
261  ( *DL )( mask ) = -dS * CAMath::Sqrt( 1.f + t0.DzDs() * t0.DzDs() );
262  }
263 
264  const float_v d[3] = { fP[2] - t0.SinPhi(), fP[3] - t0.DzDs(), fP[4] - t0.QPt() };
265 
266  //float H0[5] = { 1,0, h2, 0, h4 };
267  //float H1[5] = { 0, 1, 0, dS, 0 };
268  //float H2[5] = { 0, 0, 1, 0, dxBz };
269  //float H3[5] = { 0, 0, 0, 1, 0 };
270  //float H4[5] = { 0, 0, 0, 0, 1 };
271 
272  const float_v h2 = dx * ( 1.f + ey * ey1 + ex * ex1 ) * exi * ex1i * cci;
273  const float_v h4 = dx2 * ( cc + ss * ey1 * ex1i ) * cci * cci * Bz;
274  const float_v dxBz = dx * Bz;
275 
276  ex1( !mask ) = ex;
277  ey1( !mask ) = ey;
278 
279 // std::cout << "QPt " << t0.QPt()[0] << " " << fP[4][0] <<
280 // " CosPhi " << t0.CosPhi()[0] << " " << ex1[0] << std::endl;
281 
282  t0.SetCosPhi( ex1 );
283  t0.SetSinPhi( ey1 );
284 
285  fX( mask ) = X() + dx;
286  fP[0]( mask ) = Y() + dy + h2 * d[0] + h4 * d[2];
287  fP[1]( mask ) = Z() + dz + dS * d[1];
288  fP[2]( mask ) = t0.SinPhi() + d[0] + dxBz * d[2];
289  fP[2]( CAMath::Abs(fP[2]) > maxSinPhi ) = t0.SinPhi();
290 
291  const float_v c00 = fC[0];
292  const float_v c10 = fC[1];
293  const float_v c11 = fC[2];
294  const float_v c20 = fC[3];
295  const float_v c21 = fC[4];
296  const float_v c22 = fC[5];
297  const float_v c30 = fC[6];
298  const float_v c31 = fC[7];
299  const float_v c32 = fC[8];
300  const float_v c33 = fC[9];
301  const float_v c40 = fC[10];
302  const float_v c41 = fC[11];
303  const float_v c42 = fC[12];
304  const float_v c43 = fC[13];
305  const float_v c44 = fC[14];
306 
307  fC[0]( mask ) = ( c00 + h2 * h2 * c22 + h4 * h4 * c44
308  + 2.f * ( h2 * c20 + h4 * c40 + h2 * h4 * c42 ) );
309 
310  fC[1]( mask ) = c10 + h2 * c21 + h4 * c41 + dS * ( c30 + h2 * c32 + h4 * c43 );
311  fC[2]( mask ) = c11 + 2.f * dS * c31 + dS * dS * c33;
312 
313  fC[3]( mask ) = c20 + h2 * c22 + h4 * c42 + dxBz * ( c40 + h2 * c42 + h4 * c44 );
314  fC[4]( mask ) = c21 + dS * c32 + dxBz * ( c41 + dS * c43 );
315  fC[5]( mask ) = c22 + 2.f * dxBz * c42 + dxBz * dxBz * c44;
316 
317  fC[6]( mask ) = c30 + h2 * c32 + h4 * c43;
318  fC[7]( mask ) = c31 + dS * c33;
319  fC[8]( mask ) = c32 + dxBz * c43;
320  fC[9]( mask ) = c33;
321 
322  fC[10]( mask ) = c40 + h2 * c42 + h4 * c44;
323  fC[11]( mask ) = c41 + dS * c43;
324  fC[12]( mask ) = c42 + dxBz * c44;
325  fC[13]( mask ) = c43;
326  fC[14]( mask ) = c44;
327 //std::cout << fC[10] << " " << fC[11] <<" " << h2 << " " << h4 << " " << c44 << " " << mask << " " << Bz << std::endl;
328  //debugKF() << mask << "\n" << *this << std::endl;
329  return mask;
330 }
331 
332 
333 float_m PndCATrackParamVector::TransportToX( const float_v &x, const float_v &Bz,
334  const float maxSinPhi, const float_m &mask )
335 {
336  //* Transport the track parameters to X=x
337 
338 // assert( ( x == 0 && mask ).isEmpty() );
339 
341 
342  return TransportToX( x, t0, Bz, maxSinPhi, 0, mask );
343 }
344 
345 
346 
348 const float_v &XThimesRho, const float_v &Bz, const float maxSinPhi, const float_m &mask_ )
349 {
350  //* Transport the track parameters to X=x taking into account material budget
351 // UNUSED_PARAM1(par);
352  // const float kRho = 1.025e-3f;//0.9e-3;
353 // const float kRadLen = 29.532f;//28.94;
354 // const float kRhoOverRadLen = kRho / kRadLen;
355  // const float kRhoOverRadLen = 7.68e-5;
356  float_v dl;
357 
358  float_m mask = mask_ && TransportToX( x, t0, Bz, maxSinPhi, &dl, mask_ );
359 // if ( !mask.isEmpty() ) {
360 // CorrectForMeanMaterial( dl * kRhoOverRadLen, dl * kRho, par, mask );
361 // }
362 
363  const float_v dzds2 = t0.DzDs()*t0.DzDs();
364  const float_v sphi2 = t0.SinPhi()*t0.SinPhi();
365  float_v koeff = sqrt( (1 + dzds2)*( 1 + sphi2 ) ); // = dr/dx
366  mask &= CorrectForMeanMaterial( XOverX0*koeff, XThimesRho*koeff, par, mask );
367 
368  return mask;
369 }
370 
371 
372 float_m PndCATrackParamVector::TransportToXWithMaterial( const float_v &x, PndCATrackFitParam &par, const float_v &XOverX0,
373 const float_v &XThimesRho, const float_v &Bz, const float maxSinPhi )
374 {
375  //* Transport the track parameters to X=x taking into account material budget
376 
378  return TransportToXWithMaterial( x, t0, par, XOverX0, XThimesRho, Bz, maxSinPhi );
379 }
380 
381 float_m PndCATrackParamVector::TransportToXWithMaterial( const float_v &x, const float_v &XOverX0,
382 const float_v &XThimesRho, const float_v &Bz, const float maxSinPhi )
383 {
384  //* Transport the track parameters to X=x taking into account material budget
385 
387  CalculateFitParameters( par );
388  return TransportToXWithMaterial( x, par, XOverX0, XThimesRho, Bz, maxSinPhi );
389 }
390 
391 
392 //*
393 //* Multiple scattering and energy losses
394 //*
395 
396 
397 float_v PndCATrackParamVector::BetheBlochGeant( const float_v &bg2,
398  const float_v &kp0,
399  const float_v &kp1,
400  const float_v &kp2,
401  const float_v &kp3,
402  const float_v &kp4 )
403 {
404  //
405  // This is the parameterization of the Bethe-Bloch formula inspired by Geant.
406  //
407  // bg2 - (beta*gamma)^2
408  // kp0 - density [g/cm^3]
409  // kp1 - density effect first junction point
410  // kp2 - density effect second junction point
411  // kp3 - mean excitation energy [GeV]
412  // kp4 - mean Z/A
413  //
414  // The default values for the kp* parameters are for silicon.
415  // The returned value is in [GeV/(g/cm^2)].
416  //
417 
418  const float mK = 0.307075e-3f; // [GeV*cm^2/g]
419  const float _2me = 1.022e-3f; // [GeV/c^2]
420  const float_v &rho = kp0;
421  const float_v &x0 = kp1 * 2.303f;
422  const float_v &x1 = kp2 * 2.303f;
423  const float_v &mI = kp3;
424  const float_v &mZA = kp4;
425  const float_v &maxT = _2me * bg2; // neglecting the electron mass
426 
427  //*** Density effect
428  float_v d2( Vc::Zero );
429  const float_v x = 0.5f * CAMath::Log( bg2 );
430  const float_v lhwI = CAMath::Log( 28.816f * 1e-9f * CAMath::Sqrt( rho * mZA ) / mI );
431  d2( x > x1 ) = lhwI + x - 0.5f;
432  const float_v &r = ( x1 - x ) / ( x1 - x0 );
433  d2( x > x0 && x <= x1 ) = lhwI + x - 0.5f + ( 0.5f - lhwI - x0 ) * r * r * r;
434 
435  return mK*mZA*( float_v( Vc::One ) + bg2 ) / bg2*( 0.5f*CAMath::Log( maxT * maxT / ( mI*mI ) ) - bg2 / ( float_v( Vc::One ) + bg2 ) - d2 );
436 }
437 
438 float_v PndCATrackParamVector::BetheBlochSolid( const float_v &bg )
439 {
440  //------------------------------------------------------------------
441  // This is an approximation of the Bethe-Bloch formula,
442  // reasonable for solid materials.
443  // All the parameters are, in fact, for Si.
444  // The returned value is in [GeV]
445  //------------------------------------------------------------------
446 
447  return BetheBlochGeant( bg );
448 }
449 
450 float_v PndCATrackParamVector::BetheBlochGas( const float_v &bg )
451 {
452  //------------------------------------------------------------------
453  // This is an approximation of the Bethe-Bloch formula,
454  // reasonable for gas materials.
455  // All the parameters are, in fact, for Ne.
456  // The returned value is in [GeV]
457  //------------------------------------------------------------------
458 
459  const float_v rho = 0.9e-3f;
460  const float_v x0 = 2.f;
461  const float_v x1 = 4.f;
462  const float_v mI = 140.e-9f;
463  const float_v mZA = 0.49555f;
464 
465  return BetheBlochGeant( bg, rho, x0, x1, mI, mZA );
466 }
467 
468 
469 
470 
471 float_v PndCATrackParamVector::ApproximateBetheBloch( const float_v &beta2 )
472 {
473  //------------------------------------------------------------------
474  // This is an approximation of the Bethe-Bloch formula with
475  // the density effect taken into account at beta*gamma > 3.5
476  // (the approximation is reasonable only for solid materials)
477  //------------------------------------------------------------------
478 
479  const float_v &beta2_1subBeta2 = beta2 / ( float_v( Vc::One ) - beta2 ); // beta2 * CAMath::Reciprocal( float_v( Vc::One ) - beta2 );
480  const float_v &_0p000153_beta2 = 0.153e-3f / beta2;
481  const float log_3p5mul5940 = 9.942227380852058f; // log( 3.5 * 5940 )
482  const float log_5940 = 8.68946441235669f; // log( 5940 )
483  const float_v log_beta2_1subBeta2 = CAMath::Log( beta2_1subBeta2 );
484 
485  float_v ret = _0p000153_beta2 * ( log_5940 + log_beta2_1subBeta2 - beta2 );
486  ret( beta2_1subBeta2 > 3.5f*3.5f ) =
487  _0p000153_beta2 * ( log_3p5mul5940 + 0.5f * log_beta2_1subBeta2 - beta2 );
488  ret.setZero( beta2 >= float_v( Vc::One ) );
489  return ret;
490 }
491 
492 
494 {
495  //*!
496 
497  const float_v p2 = ( float_v( Vc::One ) + fP[3] * fP[3] );
498  const float_v k2 = fP[4] * fP[4];
499  const float_v mass2 = mass * mass;
500  const float_v beta2 = p2 / ( p2 + mass2 * k2 );
501 
502  float_v pp2 = 10000.f; pp2( k2 > 1.e-8f ) = p2 / k2; // impuls 2
503 
504  //par.fBethe = BetheBlochGas( pp2/mass2);
505  // par.fBethe = ApproximateBetheBloch( pp2 / mass2 ); Why pp2 / mass2?, should be beta2.
506  par.fBethe = ApproximateBetheBloch( beta2 );
507  par.fE = CAMath::Sqrt( pp2 + mass2 );
508  par.fTheta2 = 14.1f * 14.1f / ( beta2 * pp2 * 1.e6f );
509  par.fEP2 = par.fE / pp2;
510 
511  // Approximate energy loss fluctuation (M.Ivanov)
512 
513  const float knst = 0.07f; // To be tuned.
514  par.fSigmadE2 = knst * par.fEP2 * fP[4];
515  par.fSigmadE2 = par.fSigmadE2 * par.fSigmadE2;
516 
517  par.fK22 = ( float_v( Vc::One ) + fP[3] * fP[3] );
518  par.fK33 = par.fK22 * par.fK22;
519  par.fK43 = fP[3] * fP[4] * par.fK22;
520  par.fK44 = fP[3] * fP[3] * fP[4] * fP[4];
521 }
522 
523 
524 float_m PndCATrackParamVector::CorrectForMeanMaterial( const float_v &xOverX0, const float_v &xTimesRho, const PndCATrackFitParam &par, const float_m &_mask )
525 {
526  //------------------------------------------------------------------
527  // This function corrects the track parameters for the crossed material.
528  // "xOverX0" - X/X0, the thickness in units of the radiation length.
529  // "xTimesRho" - is the product length*density (g/cm^2).
530  //------------------------------------------------------------------
531 
532  float_v &fC22 = fC[5];
533  float_v &fC33 = fC[9];
534  float_v &fC40 = fC[10];
535  float_v &fC41 = fC[11];
536  float_v &fC42 = fC[12];
537  float_v &fC43 = fC[13];
538  float_v &fC44 = fC[14];
539 
540  //Energy losses************************
541 
542  const float_v &dE = par.fBethe * xTimesRho;
543  assert( dE >= 0 );
544  float_m mask = _mask && dE <= 0.3f * par.fE; //30% energy loss is too much!
545  const float_v &corr = ( float_v( Vc::One ) - par.fEP2 * dE );
546  mask &= corr >= 0.3f && corr <= 1.3f;
547 
548  fP[4]( mask ) *= corr;
549  fC40 ( mask ) *= corr;
550  fC41 ( mask ) *= corr;
551  fC42 ( mask ) *= corr;
552  fC43 ( mask ) *= corr;
553  fC44 ( mask ) *= corr * corr;
554  fC44 ( mask ) += par.fSigmadE2 * CAMath::Abs( dE );
555 
556  //Multiple scattering******************
557 
558  assert( xOverX0 >= 0 );
559  const float_v &theta2 = par.fTheta2 * xOverX0;
560  fC22( mask ) += theta2 * par.fK22 * ( float_v( Vc::One ) - fP[2] * fP[2] );
561  fC33( mask ) += theta2 * par.fK33;
562  fC43( mask ) += theta2 * par.fK43;
563  fC44( mask ) += theta2 * par.fK44;
564 
565  return mask;
566 }
567 
569  const float maxSinPhi, const float_m &mask )
570 {
571  //* Rotate the coordinate system in XY on the angle alpha
572  if ( (CAMath::Abs(alpha) < 1e-6f || !mask).isFull() ) return mask;
573 
574  const float_v cA = CAMath::Cos( alpha );
575  const float_v sA = CAMath::Sin( alpha );
576  const float_v x0 = X(), y0 = Y(), sP = t0.SinPhi(), cP = t0.CosPhi();
577  const float_v cosPhi = cP * cA + sP * sA;
578  const float_v sinPhi = -cP * sA + sP * cA;
579 
580  float_m ReturnMask(mask);
581  ReturnMask &= (!( CAMath::Abs( sinPhi ) > maxSinPhi || CAMath::Abs( cosPhi ) < 1.e-4f || CAMath::Abs( cP ) < 1.e-4f ));
582 
583  float_v tmp = alpha*0.15915494f;// 1/(2.f*3.1415f);
584  ReturnMask &= abs(tmp - round(tmp)) < 0.167f; // allow turn by 60 degree only TODO scalar
585 
586  //float J[5][5] = { { j0, 0, 0, 0, 0 }, // Y
587  // { 0, 1, 0, 0, 0 }, // Z
588  // { 0, 0, j2, 0, 0 }, // SinPhi
589  // { 0, 0, 0, 1, 0 }, // DzDs
590  // { 0, 0, 0, 0, 1 } }; // Kappa
591 
592  const float_v j0 = cP / cosPhi;
593  const float_v j2 = cosPhi / cP;
594  const float_v d = SinPhi() - sP;
595 
596  SetX( x0*cA + y0*sA, ReturnMask );
597  SetY(-x0*sA + y0*cA, ReturnMask );
598  t0.SetCosPhi( cosPhi );
599  t0.SetSinPhi( sinPhi );
600 
601  SetSinPhi( sinPhi + j2*d, ReturnMask );
602 
603  fC[0](ReturnMask) *= j0 * j0;
604  fC[1](ReturnMask) *= j0;
605  fC[3](ReturnMask) *= j0;
606  fC[6](ReturnMask) *= j0;
607  fC[10](ReturnMask) *= j0;
608 
609  fC[3](ReturnMask) *= j2;
610  fC[4](ReturnMask) *= j2;
611  fC[5](ReturnMask) *= j2 * j2;
612  fC[8](ReturnMask) *= j2;
613  fC[12](ReturnMask) *= j2;
614 
615  fAlpha(ReturnMask) += alpha;
616 
617  return ReturnMask;
618 }
619 
620 float_m PndCATrackParamVector::FilterWithMaterial( const float_v &y, const float_v &z, float_v err2Y, float_v errYZ, float_v err2Z, float maxSinPhi, const float_m &mask, const int_v& hitNDF, const float_v& chi2Cut )
621 {
622  assert( maxSinPhi > 0.f );
623  //* Add the y,z measurement with the Kalman filter
624 
625  const float_v c00 = fC[0];
626  const float_v c10 = fC[1];
627  const float_v c11 = fC[2];
628  const float_v c20 = fC[3];
629  const float_v c21 = fC[4];
630 // float c22 = fC[5];
631  const float_v c30 = fC[6];
632  const float_v c31 = fC[7];
633 // float c32 = fC[8];
634 // float c33 = fC[9];
635  const float_v c40 = fC[10];
636  const float_v c41 = fC[11];
637 // float c42 = fC[12];
638 // float c43 = fC[13];
639 // float c44 = fC[14];
640 
641 
642  const float_v
643  z0 = y - fP[0],
644  z1 = z - fP[1];
645 
646  // foreach_bit( int i, mask ) {
647  // cout << i << " e = " << err2Y[i] << " " << errYZ[i] << " " << err2Z[i] << " c = " << c00[i] << " " << c10[i] << " " << c11[i] << " z = " << z0[i] << " " << z1[i] << " chi2 = " << fChi2[i]<< endl;
648  // }
649 
650  err2Y += c00;
651  err2Z += c11;
652  errYZ += c10;
653  float_v d = float_v( Vc::One ) / ( err2Y*err2Z - errYZ*errYZ );
654 
655 
656  float_m success = mask;// if ( ISUNLIKELY( err2Y < 1.e-8f ) || ISUNLIKELY( err2Z < 1.e-8f ) ) return 0;
657  success &= (err2Y > 1.e-8f ) && ( err2Z > 1.e-8f );
658 
659  const float_v mS0 = err2Z*d;
660  const float_v mS1 = -errYZ*d;
661  const float_v mS2 = err2Y*d;
662 
663  // K = CHtS
664 
665  const float_v
666  k00 = c00 * mS0 + c10*mS1, k01 = c00 * mS1 + c10*mS2,
667  k10 = c10 * mS0 + c11*mS1, k11 = c10 * mS1 + c11*mS2,
668  k20 = c20 * mS0 + c21*mS1, k21 = c20 * mS1 + c21*mS2,
669  k30 = c30 * mS0 + c31*mS1, k31 = c30 * mS1 + c31*mS2,
670  k40 = c40 * mS0 + c41*mS1, k41 = c40 * mS1 + c41*mS2;
671 
672  const float_v sinPhi = fP[2] + k20 * z0 + k21 * z1;
673 
674  success &= CAMath::Abs( sinPhi ) < maxSinPhi;
675 
676  fNDF( static_cast<int_m>(success) ) += hitNDF;
677  fChi2(success) += mS0 * z0 * z0 + 2 * z0 * z1 * mS1 + mS2 * z1 * z1;
678  success &= fChi2 < chi2Cut;
679  if ( success.isEmpty() ) return success; // TODO move upper
680 
681  // foreach_bit( int i, success ) {
682  // cout << i << " " << mS0[i] << " " << mS1[i] << " " << mS2[i] << " " << (mS0 * z0 * z0)[i] << " " << (2 * z0 * z1 * mS1)[i] << " " << (mS2 * z1 * z1)[i] << " " << fChi2[i] << endl;
683  // }
684  // std::cout << success << std::endl;
685  fP[ 0](success) += k00 * z0 + k01 * z1;
686  fP[ 1](success) += k10 * z0 + k11 * z1;
687  fP[ 2](success) = sinPhi ;
688  fP[ 3](success) += k30 * z0 + k31 * z1;
689  fP[ 4](success) += k40 * z0 + k41 * z1;
690  fC[ 0](success) -= (k00 * c00 + k01 * c10); //c00
691 
692  fC[ 1](success) -= (k10 * c00 + k11 * c10); //c10
693  fC[ 2](success) -= (k10 * c10 + k11 * c11); //c11
694 
695  fC[ 3](success) -= (k20 * c00 + k21 * c10); //c20
696  fC[ 4](success) -= (k20 * c10 + k21 * c11); //c21
697  fC[ 5](success) -= (k20 * c20 + k21 * c21); //c22
698 
699  fC[ 6](success) -= (k30 * c00 + k31 * c10); //c30
700  fC[ 7](success) -= (k30 * c10 + k31 * c11); //c31
701  fC[ 8](success) -= (k30 * c20 + k31 * c21); //c32
702  fC[ 9](success) -= (k30 * c30 + k31 * c31); //c33
703 
704  fC[10](success) -= (k40 * c00 + k41 * c10); //c40
705  fC[11](success) -= (k40 * c10 + k41 * c11); //c41
706 // std::cout << fC[11] << " " << fC[10] << std::endl;
707 
708  fC[12](success) -= (k40 * c20 + k41 * c21); //c42
709  fC[13](success) -= (k40 * c30 + k41 * c31); //c43
710  fC[14](success) -= (k40 * c40 + k41 * c41); //c44
711 
712  return success;
713 }
714 
715 float_m PndCATrackParamVector::FilterWithMaterial( const float_v &y, const float_v &z, const PndCAStripInfo &info, float_v err2, float maxSinPhi, const float_m &mask, const float_v& chi2Cut )
716  //* Adds the 1-D measurement with the Kalman filter
717  //* @beta is angle between the strip and z-axis, clockwise
718 {
719  assert( maxSinPhi > 0.f );
720  float_m success = mask;
721  success &= ( err2 > 1.e-8f );
722 
723  const float_v& c00 = fC[0];
724  const float_v& c10 = fC[1];
725  const float_v& c11 = fC[2];
726 
727  const float_v& sb = info.sin;
728  const float_v& cb = info.cos;
729 
730  const float_v u = cb*y + sb*z;
731  const float_v zeta = cb*fP[0] + sb*fP[1] - u;
732 
733  // F = CH'
734  const float_v F0 = cb*c00 + sb*c10;
735  const float_v F1 = cb*c10 + sb*c11;
736 
737  const float_v HCH = ( F0*cb + F1*sb );
738 
739  const float_v wi = 1/( err2 + HCH );
740  const float_v zetawi = zeta *wi;
741 
742  fChi2(success) += zeta * zetawi;
743  success &= fChi2 < chi2Cut;
744  if ( success.isEmpty() ) return success;
745 
746  const float_v& c20 = fC[3];
747  const float_v& c21 = fC[4];
748  const float_v& c30 = fC[6];
749  const float_v& c31 = fC[7];
750  const float_v& c40 = fC[10];
751  const float_v& c41 = fC[11];
752 
753  const float_v F2 = cb*c20 + sb*c21;
754  const float_v F3 = cb*c30 + sb*c31;
755  const float_v F4 = cb*c40 + sb*c41;
756 
757 
758  const float_v K1 = F1*wi;
759  const float_v K2 = F2*wi;
760  const float_v K3 = F3*wi;
761  const float_v K4 = F4*wi;
762 
763 
764  const float_v sinPhi = fP[2] - F2*zetawi;
765 
766  success &= CAMath::Abs( sinPhi ) < maxSinPhi;
767 
768  fNDF( static_cast<int_m>(success) ) += 1; // TODO
769 
770  fP[ 0](success) -= F0*zetawi;
771  fP[ 1](success) -= F1*zetawi;
772  fP[ 2](success) = sinPhi ;
773  fP[ 3](success) -= F3*zetawi;
774  fP[ 4](success) -= F4*zetawi;
775 
776  fC[ 0](success) -= F0*F0*wi;
777 
778  fC[ 1](success) -= K1*F0;
779  fC[ 2](success) -= K1*F1;
780 
781  fC[ 3](success) -= K2*F0;
782  fC[ 4](success) -= K2*F1;
783  fC[ 5](success) -= K2*F2;
784 
785  fC[ 6](success) -= K3*F0;
786  fC[ 7](success) -= K3*F1;
787  fC[ 8](success) -= K3*F2;
788  fC[ 9](success) -= K3*F3;
789 
790  fC[10](success) -= K4*F0;
791  fC[11](success) -= K4*F1;
792 
793  fC[12](success) -= K4*F2;
794  fC[13](success) -= K4*F3;
795  fC[14](success) -= K4*F4;
796 
797  return success;
798 }
799 
800 float_m PndCATrackParamVector::Transport( const int_v& ista, const PndCAParam& param, const float_m &mask )
801 {
802  float_m active = mask;
803  PndCATrackLinearisationVector tE( *this );
804  active &= TransportToX( param.GetR( ista, active ), tE, param.cBz(), 0.999f, NULL, active );
805  //SG!!
806  /*
807  PndCATrackFitParam fitPar;
808  CalculateFitParameters( fitPar );
809  PndCATrackLinearisationVector tE( *this );
810  active &= TransportToXWithMaterial( param.GetR( ista, active ), tE, fitPar, param.GetXOverX0(int_v(ista),active), param.GetXTimesRho(int_v(ista),active), param.cBz(), 0.999f, active );
811  */
812  return active;
813 }
814 
815 float_m PndCATrackParamVector::Transport( const PndCAHitV& hit, const PndCAParam& param, const float_m &mask )
816 {
817  if ( ((CAMath::Abs(-fAlpha + hit.Angle()) < 1e-6f && CAMath::Abs(-fX + hit.X0()) < 2e-4f) || !mask).isFull() ) return mask;
818  float_m active = mask & hit.IsValid();
819  PndCATrackLinearisationVector tR( *this );
820  active &= Rotate( -fAlpha + hit.Angle(), tR, .999f, active );
821  active &= TransportToX( hit.X0(), tR, param.cBz(), 0.999f, NULL, active );
822 
823  //SG!!
824  /*
825  PndCATrackFitParam fitPar;
826  CalculateFitParameters( fitPar );
827  active &= TransportToXWithMaterial( hit.X0(), tR, fitPar, param.GetXOverX0(hit.IStations(),active), param.GetXTimesRho(hit.IStations(),active), param.cBz(), 0.999f, active );
828  */
829  return active;
830 }
831 
832 float_m PndCATrackParamVector::Filter( const PndCAHitV& hit, const PndCAParam& param, const float_m &mask, const float_v& chi2Cut )
833 {
834  const int iSta = hit.IStations()[hit.IsValid().firstOne()];
835  if ( param.Station( iSta ).NDF == 1 ) {
836  float_m m = FilterWithMaterial( hit.X1Corrected(*this), hit.X2(), param.Station( iSta ).f, hit.Err2R(), 0.999f, mask, chi2Cut );
837  return m;
838  }
839  //SG!!
840  float_m m = FilterWithMaterial( hit.X1(), hit.X2(), float_v(3.f)*hit.Err2X1(), hit.ErrX12(), float_v(3.f)*hit.Err2X2(), 0.999f, mask, int_v(param.Station( hit.IStations()[0] ).NDF), chi2Cut );
841  return m;
842 }
843 
844 float_m PndCATrackParamVector::Transport( const PndCAHit& hit, const PndCAParam& param, const float_m &mask )
845 {
846  if ( ((CAMath::Abs(-fAlpha + hit.Angle()) < 1e-6f && CAMath::Abs(-fX + hit.X0()) < 2e-4f) || !mask).isFull() ) return mask;
847 
848  float_m active = mask;
849 
850  PndCATrackLinearisationVector tR( *this );
851  active &= Rotate( -fAlpha + hit.Angle(), tR, .999f, active );
852 
853  active &= TransportToX( hit.X0(), tR, param.cBz(), 0.999f, NULL, active );
854  /*
855  PndCATrackFitParam fitPar;
856  CalculateFitParameters( fitPar );
857  active &= TransportToXWithMaterial( hit.X0(), tR, fitPar, param.GetXOverX0(hit.IStation()), param.GetXTimesRho(hit.IStation()), param.cBz(), 0.999f, active );
858  */
859  return active;
860 }
861 
862 float_m PndCATrackParamVector::Filter( const PndCAHit& hit, const PndCAParam& param, const float_m &mask, const float_v& chi2Cut )
863 {
864  if ( param.Station( hit.IStation() ).NDF == 1 ) {
865  return FilterWithMaterial( hit.X1Corrected(this->SinPhi()), hit.X2(), param.Station( hit.IStation() ).f, hit.Err2R(), 0.999f, mask, chi2Cut );
866  }
867  return FilterWithMaterial( hit.X1(), hit.X2(), hit.Err2X1(), hit.ErrX12(), hit.Err2X2(), 0.999f, mask, int_v(param.Station( hit.IStation() ).NDF), chi2Cut );
868 }
869 
870 float_m PndCATrackParamVector::AddTarget( const PndCATarget& target, const float_m &mask )
871 {
872  float_m active = mask;
873 
874  float_v eY, eZ;
875  //float_v dz = target.X0() - X0();
876  float_v J[6];
877  // H = 1 0 J[0] J[1] J[2]
878  // 0 1 J[3] J[4] J[5]
879  active &= TransportJ0ToX0( target.X0(), static_cast<float_v>(target.B()), eY, eZ, J, active );
880  active &= FilterVtx( target.X1(), target.X2(), PndCAX1X2MeasurementInfo( target.Err2X1(), 0.f, target.Err2X2() ), eY, eZ, J, active );
881  fNDF (static_cast<int_m>(active)) += target.NDF();
882 
883  return active;
884 }
885 
886 #include <iostream>
887 
888 // std::istream &operator>>( std::istream &in, PndCATrackParamVector &t )
889 // {
890 // float_v::Memory x, s, p[5], c[15], chi2;
891 // int_v::Memory ndf;
892 // for ( int j = 0; j < uint_v::Size; ++j ) {
893 // in >> x[j];
894 // in >> s[j];
895 // for ( int i = 0; i < 5; i++ ) in >> p[i][j];
896 // for ( int i = 0; i < 15; i++ ) in >> c[i][j];
897 // in >> chi2[j];
898 // in >> ndf[j];
899 // }
900 // t.fX.load( x );
901 // t.fSignCosPhi.load( s );
902 // for ( int i = 0; i < 5; i++ ) t.fP[i].load( p[i] );
903 // for ( int i = 0; i < 5; i++ ) t.fC[i].load( c[i] );
904 // t.fChi2.load( chi2 );
905 // t.fNDF.load( ndf );
906 // return in;
907 // }
908 //
909 // std::ostream &operator<<( std::ostream &out, const PndCATrackParamVector &t )
910 // {
911 // if ( out == std::cerr ) {
912 // out << "------------------------------ Track Param ------------------------------"
913 // << "\n X: " << t.X()
914 // << "\n SignCosPhi: " << t.SignCosPhi()
915 // << "\n Chi2: " << t.Chi2()
916 // << "\n NDF: " << t.NDF()
917 // << "\n Y: " << t.Par()[0]
918 // << "\n Z: " << t.Par()[1]
919 // << "\n SinPhi: " << t.Par()[2]
920 // << "\n DzDs: " << t.Par()[3]
921 // << "\n q/Pt: " << t.Par()[4]
922 // << "\nCovariance Matrix\n";
923 // int i = 0;
924 // out << std::setprecision( 2 );
925 // for ( int step = 1; step <= 5; ++step ) {
926 // int end = i + step;
927 // for ( ; i < end; ++i ) {
928 // out << t.Cov()[i] << '\t';
929 // }
930 // out << "\n";
931 // }
932 // out << std::setprecision( 6 );
933 // return out << std::endl;
934 // }
935 // for ( int j = 0; j < uint_v::Size; ++j ) {
936 // out << t.X()[j] << " "
937 // << t.SignCosPhi()[j] << " "
938 // << t.Chi2()[j] << " "
939 // << t.NDF()[j]
940 // << std::endl;
941 // for ( int i = 0; i < 5; i++ ) out << t.Par()[i][j] << " ";
942 // out << std::endl;
943 // for ( int i = 0; i < 15; i++ ) out << t.Cov()[i][j] << " ";
944 // out << std::endl;
945 // }
946 // return out;
947 // }
948 
949 
950 
951 
952 
953 float_m PndCATrackParamVector::Transport0ToX( const float_v &x, const float_v &Bz, const float_m &_mask )
954 {
955  //* Transport the track parameters to X=x, using linearization at t0, and the field value Bz
956  //* maxSinPhi is the max. allowed value for |t0.SinPhi()|
957  //* linearisation of trajectory t0 is also transported to X=x,
958  //* returns 1 if OK
959  //*
960 
961  const float_v ey = SinPhi();
962  const float_v ex = CAMath::Sqrt( float_v( Vc::One ) - ey*ey );
963  const float_v dx = x - X();
964 
965  float_m mask = _mask && CAMath::Abs( ey ) <= .999f;
966 
967  const float_v exi = 1.f / ex;
968  const float_v dS = dx * exi;
969  const float_v h2 = dx * exi * exi *exi;
970  const float_v h4 = 0.5f*dx* Bz * h2;
971  const float_v dxBz = dx * Bz;
972 
973  fX += dx;
974  fP[0] += dS*ey + h4 * fP[4];
975  fP[1] += dS * DzDs();
976  fP[2] += dxBz * fP[4];
977 
978  const float_v c00 = fC[0];
979  const float_v c10 = fC[1];
980  const float_v c11 = fC[2];
981  const float_v c20 = fC[3];
982  const float_v c21 = fC[4];
983  const float_v c22 = fC[5];
984  const float_v c30 = fC[6];
985  const float_v c31 = fC[7];
986  const float_v c32 = fC[8];
987  const float_v c33 = fC[9];
988  const float_v c40 = fC[10];
989  const float_v c41 = fC[11];
990  const float_v c42 = fC[12];
991  const float_v c43 = fC[13];
992  const float_v c44 = fC[14];
993 
994  fC[0] = ( c00 + h2 * h2 * c22 + h4 * h4 * c44
995  + 2.f * ( h2 * c20 + h4 * c40 + h2 * h4 * c42 ) );
996 
997  fC[1] = c10 + h2 * c21 + h4 * c41 + dS * ( c30 + h2 * c32 + h4 * c43 );
998  fC[2] = c11 + 2.f * dS * c31 + dS * dS * c33;
999 
1000  fC[3] = c20 + h2 * c22 + h4 * c42 + dxBz * ( c40 + h2 * c42 + h4 * c44 );
1001  fC[4] = c21 + dS * c32 + dxBz * ( c41 + dS * c43 );
1002  fC[5] = c22 + 2.f * dxBz * c42 + dxBz * dxBz * c44;
1003 
1004  fC[6] = c30 + h2 * c32 + h4 * c43;
1005  fC[7] = c31 + dS * c33;
1006  fC[8] = c32 + dxBz * c43;
1007 
1008  fC[10] = c40 + h2 * c42 + h4 * c44;
1009  fC[11] = c41 + dS * c43;
1010  fC[12] = c42 + dxBz * c44;
1011  return mask;
1012 }
1013 
1014 float_m PndCATrackParamVector::Transport0( const PndCAHitV& hit, const PndCAParam& param, const float_m &mask )
1015 {
1016  //if ( ((CAMath::Abs(-fAlpha + hit.Angle()) < 1e-6f && CAMath::Abs(-fX + hit.X0()) < 2e-4f) || !mask).isFull() ) return mask;
1017  float_m active = mask & hit.IsValid();
1018  active &= Rotate( -fAlpha + hit.Angle(), .999f, active );
1019  active &= Transport0ToX( hit.X0(), param.cBz(), active );
1020  return active;
1021 }
1022 
1023 
1024 
1025 
1026 float_m PndCATrackParamVector::Accept( const PndCAHit& hit, const PndCAParam& param, const float_m &mask, const float_v& chi2Cut ) const
1027 {
1028  if ( param.Station( hit.IStation() ).NDF == 1 ) {
1029  return AcceptWithMaterial( hit.X1Corrected(this->SinPhi()), hit.X2(), param.Station( hit.IStation() ).f, hit.Err2R(), 0.999f, mask, chi2Cut );
1030  }
1031  return AcceptWithMaterial( hit.X1(), hit.X2(), hit.Err2X1(), hit.ErrX12(), hit.Err2X2(), 0.999f, mask, int_v(param.Station( hit.IStation() ).NDF), chi2Cut );
1032 }
1033 
1034 float_m PndCATrackParamVector::AcceptWithMaterial( const float_v &y, const float_v &z, float_v err2Y, float_v errYZ, float_v err2Z, float maxSinPhi, const float_m &mask, const int_v& /*hitNDF*/, const float_v& chi2Cut ) const
1035 {
1036  assert( maxSinPhi > 0.f );
1037  //* Add the y,z measurement with the Kalman filter
1038 
1039  const float_v c00 = fC[0];
1040  const float_v c10 = fC[1];
1041  const float_v c11 = fC[2];
1042  const float_v c20 = fC[3];
1043  const float_v c21 = fC[4];
1044  const float_v
1045  z0 = y - fP[0],
1046  z1 = z - fP[1];
1047 
1048  err2Y += c00;
1049  err2Z += c11;
1050  errYZ += c10;
1051  float_v d1 = ( err2Y*err2Z - errYZ*errYZ );
1052 
1053  float_m success = mask;// if ( ISUNLIKELY( err2Y < 1.e-8f ) || ISUNLIKELY( err2Z < 1.e-8f ) ) return 0;
1054  success &= (err2Y > 1.e-8f ) && ( err2Z > 1.e-8f );
1055 
1056  const float_v mS0 = err2Z;
1057  const float_v mS1 = -errYZ;
1058  const float_v mS2 = err2Y;
1059 
1060  // K = CHtS
1061 
1062  const float_v k20 = (c20 * mS0 + c21*mS1), k21 = (c20 * mS1 + c21*mS2);
1063  const float_v sinPhi = d1*fP[2] + ( k20 * z0 + k21 * z1 );
1064  success &= CAMath::Abs( sinPhi ) < maxSinPhi*d1;
1065  float_v chi2 = ( mS0 * z0 * z0 + 2 * z0 * z1 * mS1 + mS2 * z1 * z1 );
1066  success &= chi2 < d1*(chi2Cut-fChi2);
1067  return success;
1068 }
1069 
1070 
1071 float_m PndCATrackParamVector::AcceptWithMaterial( const float_v &y, const float_v &z, const PndCAStripInfo &info, float_v err2, float maxSinPhi, const float_m &mask, const float_v& chi2Cut ) const
1072  //* Adds the 1-D measurement with the Kalman filter
1073  //* @beta is angle between the strip and z-axis, clockwise
1074 {
1075  assert( maxSinPhi > 0.f );
1076  float_m success = mask;
1077  success &= ( err2 > 1.e-8f );
1078 
1079  const float_v& c00 = fC[0];
1080  const float_v& c10 = fC[1];
1081  const float_v& c11 = fC[2];
1082 
1083  const float_v& sb = info.sin;
1084  const float_v& cb = info.cos;
1085 
1086  const float_v u = cb*y + sb*z;
1087  const float_v zeta = cb*fP[0] + sb*fP[1] - u;
1088 
1089  // F = CH'
1090  const float_v F0 = cb*c00 + sb*c10;
1091  const float_v F1 = cb*c10 + sb*c11;
1092 
1093  const float_v HCH = ( F0*cb + F1*sb );
1094 
1095  const float_v w = ( err2 + HCH );
1096  success &= zeta*zeta < w*(chi2Cut - fChi2);
1097  return success;
1098 }
static T ASin(const T &x)
Double_t z0
Definition: checkhelixhit.C:62
Double_t x0
Definition: checkhelixhit.C:70
float_m FilterVtx(const float_v &xV, const float_v &yV, const PndCAX1X2MeasurementInfo &info, float_v &extrDx, float_v &extrDy, float_v J[], const float_m &active=float_m(true))
double mK
double dy
void InitByTarget(const PndCATarget &target)
TCanvas * c11
float Angle() const
Definition: PndCAHits.h:51
const PndCAFieldValue & B() const
Definition: PndCATarget.h:31
float_m TransportJ0ToX0(const float_v &x0, const float_v &cBz, float_v &extrDy, float_v &extrDz, float_v J[], const float_m &active=float_m(true))
double r
Definition: RiemannTest.C:14
TObjArray * d
float_m Rotate(const float_v &alpha, PndCATrackLinearisationVector &t0, const float maxSinPhi=.999f, const float_m &mask=float_m(true))
float_m TransportToX(const float_v &x, const float_v &Bz, const float maxSinPhi=.999f, const float_m &mask=float_m(true))
void CalculateFitParameters(PndCATrackFitParam &par, const float_v &mass=0.13957f)
float X0() const
Definition: PndCAHits.h:34
float_m Transport0ToX(const float_v &x, const float_v &Bz, const float_m &mask)
float_m FilterWithMaterial(const float_v &y, const float_v &z, float_v err2Y, float_v errYZ, float_v err2Z, float maxSinPhi=0.999f, const float_m &mask=float_m(true), const int_v &hitNDF=int_v(2), const float_v &chi2Cut=10e10f)
__m128 m
Definition: P4_F32vec4.h:28
PndPidCorrelator * corr
void SetAngle(const float_v &v)
static float_v BetheBlochGeant(const float_v &bg, const float_v &kp0=2.33f, const float_v &kp1=0.20f, const float_v &kp2=3.00f, const float_v &kp3=173e-9f, const float_v &kp4=0.49848f)
void SetSignCosPhi(const float_v &v)
void SetSinPhi(const float_v &v)
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
static T Sqrt(const T &x)
Definition: PndCAMath.h:37
void SetChi2(const float_v &v)
void GetDCAPoint(const float_v &x, const float_v &y, const float_v &z, float_v *px, float_v *py, float_v *pz, const float_v &Bz) const
TH1F * h4
TLorentzVector s
Definition: Pnd2DStar.C:50
TCanvas * c10
static T Sin(const T &x)
Definition: PndCAMath.h:42
float_v Err2R() const
Definition: PndCAHitsV.h:55
float X2() const
Definition: PndCAHits.h:36
Double_t par[3]
TCanvas * c21
float_v ErrX12() const
Definition: PndCAHitsV.h:48
const PndCAStation & Station(short i) const
Definition: PndCAParam.h:46
float_v GetS(const float_v &x, const float_v &y, const float_v &Bz) const
float_v Err2X1() const
Definition: PndCAHitsV.h:47
static float_v BetheBlochSolid(const float_v &bg)
float_v X1() const
Definition: PndCAHitsV.h:44
static T Round(const T &x)
int NDF() const
Definition: PndCATarget.h:32
static const fvec Zero
static T Cos(const T &x)
Definition: PndCAMath.h:43
float X2() const
Definition: PndCATarget.h:25
float X1() const
Definition: PndCAHits.h:35
PndCAStripInfo f
Definition: PndCAStation.h:21
static T Abs(const T &x)
Definition: PndCAMath.h:39
float_m Filter(const PndCAHitV &hit, const PndCAParam &param, const float_m &mask=float_m(true), const float_v &chi2Cut=10e10f)
float_m IsValid() const
Definition: PndCAHitsV.h:30
float_m Transport0(const int_v &ista, const PndCAParam &param, const float_m &mask=float_m(true))
float Err2X1() const
Definition: PndCAHits.h:38
float_m TransportToXWithMaterial(const float_v &x, const float_v &XOverX0, const float_v &XThimesRho, const float_v &Bz, const float maxSinPhi=.999f)
Int_t a
Definition: anaLmdDigi.C:126
float_m Accept(const PndCAHit &hit, const PndCAParam &param, const float_m &mask=float_m(true), const float_v &chi2Cut=10e10f) const
void InitCovMatrix(float_v d2QMom=0.f)
float_m AddTarget(const PndCATarget &target, const float_m &mask=float_m(true))
Int_t t0
Definition: hist-t7.C:106
void SetQPt(const float_v &v)
static T Min(const T &x, const T &y)
Definition: PndCAMath.h:35
static float_v BetheBlochGas(const float_v &bg)
float_v Err2X2() const
Definition: PndCAHitsV.h:49
void SetCov(int i, const float_v &v)
Double_t y0
Definition: checkhelixhit.C:71
float Err2X2() const
Definition: PndCAHits.h:40
Double_t dE
Definition: anasim.C:58
static float_v ApproximateBetheBloch(const float_v &beta2)
static T ATan2(const T &y, const T &x)
float_v GetDist2(const PndCATrackParamVector &t) const
float X0() const
Definition: PndCATarget.h:23
float_v X2() const
Definition: PndCAHitsV.h:45
TFile * f
Definition: bump_analys.C:12
void SetY(const float_v &v)
int_v IStations() const
Definition: PndCAHitsV.h:37
Double_t z
float_m CorrectForMeanMaterial(const float_v &xOverX0, const float_v &xTimesRho, const PndCATrackFitParam &par, const float_m &_mask)
float GetR(short iSt) const
Definition: PndCAParam.h:63
float_v X1Corrected(float_v sinPhi) const
Definition: PndCAHits.h:84
TPad * p2
Definition: hist-t7.C:117
double dx
float cBz() const
Definition: PndCAParam.h:49
TCanvas * c22
TCanvas * c20
static T Max(const T &x, const T &y)
Definition: PndCAMath.h:36
int hit(Int_t nEvents=0, TString inFile="sim.root", TString parFile="par.root", TString inDigi="digi.root", TString outFile="hit.root", Int_t timeBased=0)
Definition: hit.C:1
void SetX(const float_v &v)
float_m AcceptWithMaterial(const float_v &y, const float_v &z, float_v err2Y, float_v errYZ, float_v err2Z, float maxSinPhi=0.999f, const float_m &mask=float_m(true), const int_v &hitNDF=int_v(2), const float_v &chi2Cut=10e10f) const
float_v Angle() const
Definition: PndCAHitsV.h:59
Double_t x
static T Log(const T &x)
Definition: PndCAMath.h:40
static float TwoPi()
Definition: PndCAMath.h:61
void SetDzDs(const float_v &v)
float_v GetDistXZ2(const PndCATrackParamVector &t) const
float Err2QMom() const
Definition: PndCATarget.h:29
float_m Transport(const int_v &ista, const PndCAParam &param, const float_m &mask=float_m(true))
void InitByHit(const PndCAHitV &hit, const PndCAParam &param, const float_v &dQMom)
TTree * t
Definition: bump_analys.C:13
float_v GetKappa(const float_v &Bz) const
Double_t y
double alpha
Definition: f_Init.h:9
float Err2X2() const
Definition: PndCATarget.h:28
float_v X1Corrected(const PndCATrackParamVector &p) const
Definition: PndCAHitsV.h:82
float Err2X1() const
Definition: PndCATarget.h:27
static const fvec One
float ErrX12() const
Definition: PndCAHits.h:39
char IStation() const
Definition: PndCAHits.h:28
float X1() const
Definition: PndCATarget.h:24
float_v X0() const
Definition: PndCAHitsV.h:43
float Err2R() const
Definition: PndCAHits.h:45
void SetZ(const float_v &v)