FairRoot/PandaRoot
PndCATrackParam.cxx
Go to the documentation of this file.
1 // $Id: PndCATrackParam.cxx,v 1.6 2011/05/20 16:11:22 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 "PndCATrackParam.h"
25 #include "PndCAMath.h"
27 #include <iostream>
28 
29 //
30 // Circle in XY:
31 //
32 // kCLight = 0.000299792458;
33 // Kappa = Bz*kCLight*QPt;
34 // R = 1/CAMath::Abs(Kappa);
35 // Xc = X - sin(Phi)/Kappa;
36 // Yc = Y + cos(Phi)/Kappa;
37 //
38 
40 {
41  // get squared distance between tracks
42 
43  float dx = GetX() - t.GetX();
44  float dy = GetY() - t.GetY();
45  float dz = GetZ() - t.GetZ();
46  return dx*dx + dy*dy + dz*dz;
47 }
48 
50 {
51  // get squared distance between tracks in X&Z
52 
53  float dx = GetX() - t.GetX();
54  float dz = GetZ() - t.GetZ();
55  return dx*dx + dz*dz;
56 }
57 
58 
59 float PndCATrackParam::GetS( float x, float y, float Bz ) const
60 {
61  //* Get XY path length to the given point
62 
63  float k = GetKappa( Bz );
64  float ex = GetCosPhi();
65  float ey = GetSinPhi();
66  x -= GetX();
67  y -= GetY();
68  float dS = x * ex + y * ey;
69  if ( CAMath::Abs( k ) > 1.e-4 ) dS = CAMath::ATan2( k * dS, 1 + k * ( x * ey - y * ex ) ) / k;
70  return dS;
71 }
72 
73 void PndCATrackParam::GetDCAPoint( float x, float y, float z,
74  float &xp, float &yp, float &zp,
75  float Bz ) const
76 {
77  //* Get the track point closest to the (x,y,z)
78 
79  float x0 = GetX();
80  float y0 = GetY();
81  float k = GetKappa( Bz );
82  float ex = GetCosPhi();
83  float ey = GetSinPhi();
84  float dx = x - x0;
85  float dy = y - y0;
86  float ax = dx * k + ey;
87  float ay = dy * k - ex;
88  float a = sqrt( ax * ax + ay * ay );
89  xp = x0 + ( dx - ey * ( ( dx * dx + dy * dy ) * k - 2 * ( -dx * ey + dy * ex ) ) / ( a + 1 ) ) / a;
90  yp = y0 + ( dy + ex * ( ( dx * dx + dy * dy ) * k - 2 * ( -dx * ey + dy * ex ) ) / ( a + 1 ) ) / a;
91  float s = GetS( x, y, Bz );
92  zp = GetZ() + GetDzDs() * s;
93  if ( CAMath::Abs( k ) > 1.e-2 ) {
94  float dZ = CAMath::Abs( GetDzDs() * CAMath::TwoPi() / k );
95  if ( dZ > .1 ) {
96  zp += CAMath::Nint( ( z - zp ) / dZ ) * dZ;
97  }
98  }
99 }
100 
101 
102 //*
103 //* Transport routines
104 //*
105 
106 bool PndCATrackParam::TransportToX( float x, float sinPhi0, float cosPhi0, float Bz, float maxSinPhi )
107 {
108  //* Transport the track parameters to X=x, using linearization at phi0 with 0 curvature,
109  //* and the field value Bz
110  //* maxSinPhi is the max. allowed value for |t0.SinPhi()|
111  //* linearisation of trajectory t0 is also transported to X=x,
112  //* returns 1 if OK
113  //*
114 
115  const float ex = cosPhi0;
116  const float ey = sinPhi0;
117  const float dx = x - X();
118 
119  if ( CAMath::Abs( ex ) < 1.e-4 ) return 0;
120  const float exi = 1. / ex;
121 
122  const float dxBz = dx * Bz;
123  const float dS = dx * exi;
124  const float h2 = dS * exi * exi;
125  const float h4 = .5 * h2 * dxBz;
126 
127  //const float H0[5] = { 1,0, h2, 0, h4 };
128  //const float H1[5] = { 0, 1, 0, dS, 0 };
129  //const float H2[5] = { 0, 0, 1, 0, dxBz };
130  //const float H3[5] = { 0, 0, 0, 1, 0 };
131  //const float H4[5] = { 0, 0, 0, 0, 1 };
132 
133  const float sinPhi = SinPhi() + dxBz * QPt();
134  if ( maxSinPhi > 0 && CAMath::Abs( sinPhi ) > maxSinPhi ) return 0;
135 
136  fX = X() + dx;
137  fP[0] += dS * ey + h2 * ( SinPhi() - ey ) + h4 * QPt();
138  fP[1] += dS * DzDs();
139  fP[2] = sinPhi;
140 
141  const float c00 = fC[0];
142  const float c10 = fC[1];
143  const float c11 = fC[2];
144  const float c20 = fC[3];
145  const float c21 = fC[4];
146  const float c22 = fC[5];
147  const float c30 = fC[6];
148  const float c31 = fC[7];
149  const float c32 = fC[8];
150  const float c33 = fC[9];
151  const float c40 = fC[10];
152  const float c41 = fC[11];
153  const float c42 = fC[12];
154  const float c43 = fC[13];
155  const float c44 = fC[14];
156 
157 
158  fC[0] = ( c00 + h2 * h2 * c22 + h4 * h4 * c44
159  + 2 * ( h2 * c20 + h4 * c40 + h2 * h4 * c42 ) );
160 
161  fC[1] = c10 + h2 * c21 + h4 * c41 + dS * ( c30 + h2 * c32 + h4 * c43 );
162  fC[2] = c11 + 2 * dS * c31 + dS * dS * c33;
163 
164  fC[3] = c20 + h2 * c22 + h4 * c42 + dxBz * ( c40 + h2 * c42 + h4 * c44 );
165  fC[4] = c21 + dS * c32 + dxBz * ( c41 + dS * c43 );
166  fC[5] = c22 + 2 * dxBz * c42 + dxBz * dxBz * c44;
167 
168  fC[6] = c30 + h2 * c32 + h4 * c43;
169  fC[7] = c31 + dS * c33;
170  fC[8] = c32 + dxBz * c43;
171  fC[9] = c33;
172 
173  fC[10] = c40 + h2 * c42 + h4 * c44;
174  fC[11] = c41 + dS * c43;
175  fC[12] = c42 + dxBz * c44;
176  fC[13] = c43;
177  fC[14] = c44;
178 
179  return 1;
180 }
181 
182 bool PndCATrackParam::TransportToX( float x, float Bz, float maxSinPhi )
183 {
184  //* Transport the track parameters to X=x
185 
186  PndCATrackLinearisation t0( *this );
187 
188  return TransportToX( x, t0, Bz, maxSinPhi );
189 }
190 
191 bool PndCATrackParam::TransportToXWithMaterial( float x, float Bz, float maxSinPhi )
192 {
193  //* Transport the track parameters to X=x taking into account material budget
194 
196  CalculateFitParameters( par );
197  return TransportToXWithMaterial( x, par, Bz, maxSinPhi );
198 }
199 
200 
201 //*
202 //* Multiple scattering and energy losses
203 //*
204 
205 
207  float kp0,
208  float kp1,
209  float kp2,
210  float kp3,
211  float kp4 )
212 {
213  //
214  // This is the parameterization of the Bethe-Bloch formula inspired by Geant.
215  //
216  // bg2 - (beta*gamma)^2
217  // kp0 - density [g/cm^3]
218  // kp1 - density effect first junction point
219  // kp2 - density effect second junction point
220  // kp3 - mean excitation energy [GeV]
221  // kp4 - mean Z/A
222  //
223  // The default values for the kp* parameters are for silicon.
224  // The returned value is in [GeV/(g/cm^2)].
225  //
226 
227  const float mK = 0.307075e-3; // [GeV*cm^2/g]
228  const float me = 0.511e-3; // [GeV/c^2]
229  const float rho = kp0;
230  const float x0 = kp1 * 2.303;
231  const float x1 = kp2 * 2.303;
232  const float mI = kp3;
233  const float mZA = kp4;
234  const float maxT = 2 * me * bg2; // neglecting the electron mass
235 
236  //*** Density effect
237  float d2 = 0.;
238  const float x = 0.5 * CAMath::Log( bg2 );
239  const float lhwI = CAMath::Log( 28.816 * 1e-9 * CAMath::Sqrt( rho * mZA ) / mI );
240  if ( x > x1 ) {
241  d2 = lhwI + x - 0.5;
242  } else if ( x > x0 ) {
243  const float r = ( x1 - x ) / ( x1 - x0 );
244  d2 = lhwI + x - 0.5 + ( 0.5 - lhwI - x0 ) * r * r * r;
245  }
246 
247  return mK*mZA*( 1 + bg2 ) / bg2*( 0.5*CAMath::Log( 2*me*bg2*maxT / ( mI*mI ) ) - bg2 / ( 1 + bg2 ) - d2 );
248 }
249 
251 {
252  //------------------------------------------------------------------
253  // This is an approximation of the Bethe-Bloch formula,
254  // reasonable for solid materials.
255  // All the parameters are, in fact, for Si.
256  // The returned value is in [GeV]
257  //------------------------------------------------------------------
258 
259  return BetheBlochGeant( bg );
260 }
261 
263 {
264  //------------------------------------------------------------------
265  // This is an approximation of the Bethe-Bloch formula,
266  // reasonable for gas materials.
267  // All the parameters are, in fact, for Ne.
268  // The returned value is in [GeV]
269  //------------------------------------------------------------------
270 
271  const float rho = 0.9e-3;
272  const float x0 = 2.;
273  const float x1 = 4.;
274  const float mI = 140.e-9;
275  const float mZA = 0.49555;
276 
277  return BetheBlochGeant( bg, rho, x0, x1, mI, mZA );
278 }
279 
280 
281 
282 
283 
284 
285 //*
286 //* Rotation
287 //*
288 
289 
290 bool PndCATrackParam::Rotate( float alpha, float maxSinPhi )
291 {
292  //* Rotate the coordinate system in XY on the angle alpha
293 
294  const float cA = CAMath::Cos( alpha );
295  const float sA = CAMath::Sin( alpha );
296  const float x = X(), y = Y(), sP = SinPhi(), cP = GetCosPhi();
297  const float cosPhi = cP * cA + sP * sA;
298  const float sinPhi = -cP * sA + sP * cA;
299 
300  if ( CAMath::Abs( sinPhi ) > maxSinPhi || CAMath::Abs( cosPhi ) < 1.e-2 || CAMath::Abs( cP ) < 1.e-2 ) return 0;
301 
302  if ( fabs(alpha) > 3.1415 * 0.25 ) return 0; // allow turn by 45 degree only
303 
304  const float j0 = cP / cosPhi;
305  const float j2 = cosPhi / cP;
306 
307  SetX( x*cA + y*sA );
308  SetY( -x*sA + y*cA );
309  SetSignCosPhi( CAMath::Abs(cosPhi)/cosPhi );
310  SetSinPhi( sinPhi );
311 
312 
313  //float J[5][5] = { { j0, 0, 0, 0, 0 }, // Y
314  // { 0, 1, 0, 0, 0 }, // Z
315  // { 0, 0, j2, 0, 0 }, // SinPhi
316  // { 0, 0, 0, 1, 0 }, // DzDs
317  // { 0, 0, 0, 0, 1 } }; // Kappa
318  //cout<<"alpha="<<alpha<<" "<<x<<" "<<y<<" "<<sP<<" "<<cP<<" "<<j0<<" "<<j2<<endl;
319  //cout<<" "<<fC[0]<<" "<<fC[1]<<" "<<fC[6]<<" "<<fC[10]<<" "<<fC[4]<<" "<<fC[5]<<" "<<fC[8]<<" "<<fC[12]<<endl;
320  fC[0] *= j0 * j0;
321  fC[1] *= j0;
322  fC[3] *= j0;
323  fC[6] *= j0;
324  fC[10] *= j0;
325 
326  fC[3] *= j2;
327  fC[4] *= j2;
328  fC[5] *= j2 * j2;
329  fC[8] *= j2;
330  fC[12] *= j2;
331  //cout<<" "<<fC[0]<<" "<<fC[1]<<" "<<fC[6]<<" "<<fC[10]<<" "<<fC[4]<<" "<<fC[5]<<" "<<fC[8]<<" "<<fC[12]<<endl;
332 
333  fAlpha += alpha;
334 
335  return 1;
336 }
337 
338 bool PndCATrackParam::Rotate( float alpha, PndCATrackLinearisation &t0, float maxSinPhi )
339 {
340  //* Rotate the coordinate system in XY on the angle alpha
341 
342  const float cA = CAMath::Cos( alpha );
343  const float sA = CAMath::Sin( alpha );
344  const float x0 = X(), y0 = Y(), sP = t0.SinPhi(), cP = t0.CosPhi();
345  const float cosPhi = cP * cA + sP * sA;
346  const float sinPhi = -cP * sA + sP * cA;
347 
348  if ( CAMath::Abs( sinPhi ) > maxSinPhi || CAMath::Abs( cosPhi ) < 1.e-2 || CAMath::Abs( cP ) < 1.e-2 ) return 0;
349 
350  if ( fabs(alpha) > 3.1415 * 0.25 ) return 0; // allow turn by 45 degree only
351 
352  //float J[5][5] = { { j0, 0, 0, 0, 0 }, // Y
353  // { 0, 1, 0, 0, 0 }, // Z
354  // { 0, 0, j2, 0, 0 }, // SinPhi
355  // { 0, 0, 0, 1, 0 }, // DzDs
356  // { 0, 0, 0, 0, 1 } }; // Kappa
357 
358  const float j0 = cP / cosPhi;
359  const float j2 = cosPhi / cP;
360  const float d[2] = {Y() - y0, SinPhi() - sP};
361 
362  SetX( x0*cA + y0*sA );
363  SetY( -x0*sA + y0*cA + j0*d[0] );
364  t0.SetCosPhi( cosPhi );
365  t0.SetSinPhi( sinPhi );
366 
367  SetSinPhi( sinPhi + j2*d[1] );
368 
369  fC[0] *= j0 * j0;
370  fC[1] *= j0;
371  fC[3] *= j0;
372  fC[6] *= j0;
373  fC[10] *= j0;
374 
375  fC[3] *= j2;
376  fC[4] *= j2;
377  fC[5] *= j2 * j2;
378  fC[8] *= j2;
379  fC[12] *= j2;
380 
381  fAlpha += alpha;
382 
383  return 1;
384 }
385 
386 
387 
388 /*bool PndCATrackParam::Filter( float y, float z, float err2Y, float err2Z, float maxSinPhi )
389 {
390  assert( maxSinPhi > 0.f );
392 
393  float
394  c00 = fC[ 0],
395  c11 = fC[ 2],
396  c20 = fC[ 3],
397  c31 = fC[ 7],
398  c40 = fC[10];
399 
400  err2Y += c00;
401  err2Z += c11;
402 
403  float
404  z0 = y - fP[0],
405  z1 = z - fP[1];
406 
407  if ( ISUNLIKELY( err2Y < 1.e-8f ) || ISUNLIKELY( err2Z < 1.e-8f ) ) return 0;
408 
409  float mS0 = 1.f / err2Y;
410  float mS2 = 1.f / err2Z;
411 
412  // K = CHtS
413 
414  float k00, k11, k20, k31, k40;
415 
416  k00 = c00 * mS0;
417  k20 = c20 * mS0;
418  k40 = c40 * mS0;
419 
420  k11 = c11 * mS2;
421  k31 = c31 * mS2;
422 
423  float sinPhi = fP[2] + k20 * z0 ;
424 
425  if ( ISUNLIKELY( CAMath::Abs( sinPhi ) >= maxSinPhi ) ) return 0;
426 
427  fNDF += 2;
428  fChi2 += mS0 * z0 * z0 + mS2 * z1 * z1 ;
429 
430  fP[ 0] += k00 * z0 ;
431  fP[ 1] += k11 * z1 ;
432  fP[ 2] = sinPhi ;
433  fP[ 3] += k31 * z1 ;
434  fP[ 4] += k40 * z0 ;
435 
436  fC[ 0] -= k00 * c00 ;
437  fC[ 3] -= k20 * c00 ;
438  fC[ 5] -= k20 * c20 ;
439  fC[10] -= k40 * c00 ;
440  fC[12] -= k40 * c20 ;
441  fC[14] -= k40 * c40 ;
442 
443  fC[ 2] -= k11 * c11 ;
444  fC[ 7] -= k31 * c11 ;
445  fC[ 9] -= k31 * c31 ;
446 
447  return 1;
448 }*/
449 
450 
451 
452 
453 #if !defined(HLTCA_GPUCODE)
454 #include <iostream>
455 #endif
456 
458 {
459  //* print parameters
460 
461 #if !defined(HLTCA_GPUCODE)
462  std::cout << "track: x=" << GetX() << " c=" << GetSignCosPhi() << ", P= " << GetY() << " " << GetZ() << " " << GetSinPhi() << " " << GetDzDs() << " " << GetQPt() << std::endl;
463  std::cout << "errs2: " << GetErr2Y() << " " << GetErr2Z() << " " << GetErr2SinPhi() << " " << GetErr2DzDs() << " " << GetErr2QPt() << std::endl;
464 #endif
465 }
466 
467 // std::istream &operator>>( std::istream &in, PndCATrackParam &t )
468 // {
469 // in >> t.fX;
470 // in >> t.fSignCosPhi;
471 // in >> t.fChi2;
472 // in >> t.fNDF;
473 // for ( int i = 0; i < 5; i++ ) in >> t.fP[i];
474 // for ( int i = 0; i < 15; i++ ) in >> t.fC[i];
475 // return in;
476 // }
477 //
478 // std::ostream &operator<<( std::ostream &out, const PndCATrackParam &t )
479 // {
480 // out << t.X() << " "
481 // << t.SignCosPhi() << " "
482 // << t.Chi2() << " "
483 // << t.NDF()
484 // << '\n';
485 // for ( int i = 0; i < 5; i++ ) out << t.Par()[i] << " ";
486 // out << '\n';
487 // for ( int i = 0; i < 15; i++ ) out << t.Cov()[i] << " ";
488 // out << '\n';
489 // return out;
490 // }
491 
493 {
494  PndCATrackParam r = *this;
495  r.Rotate( -alpha );
496  return r;
497 }
498 
Double_t x0
Definition: checkhelixhit.C:70
void GetDCAPoint(float x, float y, float z, float &px, float &py, float &pz, float Bz) const
double mK
double dy
float GetErr2SinPhi() const
static float BetheBlochSolid(float bg)
TCanvas * c11
float QPt() const
float DzDs() const
double r
Definition: RiemannTest.C:14
TObjArray * d
static const double me
Definition: mzparameters.h:12
float GetKappa(float Bz) const
bool Rotate(float alpha, float maxSinPhi=.999)
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
float GetX() const
static T Sqrt(const T &x)
Definition: PndCAMath.h:37
PndCATrackParam GetGlobalParam(float alpha) const
TH1F * h4
TLorentzVector s
Definition: Pnd2DStar.C:50
float GetErr2Z() const
TCanvas * c10
static T Sin(const T &x)
Definition: PndCAMath.h:42
float GetY() const
float GetSignCosPhi() const
void SetSignCosPhi(float v)
Double_t par[3]
TCanvas * c21
float GetErr2DzDs() const
void SetX(float v)
float GetSinPhi() const
float GetQPt() const
static T Cos(const T &x)
Definition: PndCAMath.h:43
bool TransportToXWithMaterial(float x, float Bz, float maxSinPhi=.999)
static T Abs(const T &x)
Definition: PndCAMath.h:39
Int_t a
Definition: anaLmdDigi.C:126
void SetSinPhi(float v)
void Print() const
Int_t t0
Definition: hist-t7.C:106
float GetErr2Y() const
float GetZ() const
float GetDistXZ2(const PndCATrackParam &t) const
Double_t y0
Definition: checkhelixhit.C:71
static T ATan2(const T &y, const T &x)
float GetS(float x, float y, float Bz) const
float GetDist2(const PndCATrackParam &t) const
Double_t z
static float BetheBlochGeant(float bg, float kp0=2.33, float kp1=0.20, float kp2=3.00, float kp3=173e-9, float kp4=0.49848)
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
double dx
float GetErr2QPt() const
TCanvas * c22
TCanvas * c20
Double_t x
static T Log(const T &x)
Definition: PndCAMath.h:40
bool TransportToX(float x, float Bz, float maxSinPhi=.999)
static float TwoPi()
Definition: PndCAMath.h:61
float GetCosPhi() const
TTree * t
Definition: bump_analys.C:13
Double_t y
double alpha
Definition: f_Init.h:9
float SinPhi() const
static float BetheBlochGas(float bg)
float GetDzDs() const
void SetY(float v)
int Nint(float x)
Definition: PndCAMath.h:117
void CalculateFitParameters(PndCATrackFitParam &par, float mass=0.13957)
float X() const
float Y() const