MarlinTrk  02.08
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HelixTrack.cc
Go to the documentation of this file.
1 
3 #include "MarlinTrk/HelixTrack.h"
4 #include <cmath>
5 #include <TVector3.h>
6 #include <kaltest/THelicalTrack.h>
7 
8 #include "streamlog/streamlog.h"
9 
10 // defines if s of the helix increases in the direction of x2 to x3
11 bool HelixTrack::forwards = true;
12 
13 HelixTrack::HelixTrack( const double* x1, const double* x2, const double* x3, double Bz, bool direction ){
14 
15  // Make a KalTest THelicalTrack
16  TVector3 p1( x1[0], x1[1], x1[2] );
17  TVector3 p2( x2[0], x2[1], x2[2] );
18  TVector3 p3( x3[0], x3[1], x3[2] );
19 
20  streamlog_out(DEBUG2) << "HelixTrack::HelixTrack Create from hits: \n "
21  << "P1 x = " << p1.x() << " y = " << p1.y() << " z = " << p1.z() << " r = " << p1.Perp() << "\n "
22  << "P2 x = " << p2.x() << " y = " << p2.y() << " z = " << p2.z() << " r = " << p2.Perp() << "\n "
23  << "P3 x = " << p3.x() << " y = " << p3.y() << " z = " << p3.z() << " r = " << p3.Perp() << "\n "
24  << "Bz = " << Bz << " direction = " << direction
25  << std::endl;
26 
27  THelicalTrack helicalTrack( p1, p2, p3, Bz, direction );
28 
29  // Set the track parameters and convert from the KalTest system to the lcio system
30 
31  _phi0 = toBaseRange( helicalTrack.GetPhi0() + M_PI/2. ) ;
32  _omega = 1. / helicalTrack.GetRho();
33  _z0 = helicalTrack.GetDz();
34  _d0 = - helicalTrack.GetDrho();
35  _tanLambda = helicalTrack.GetTanLambda();
36 
37  _ref_point_x = helicalTrack.GetPivot().X() ;
38  _ref_point_y = helicalTrack.GetPivot().Y() ;
39  _ref_point_z = helicalTrack.GetPivot().Z() ;
40 
41 }
42 
43 
44 HelixTrack::HelixTrack( const double* position, const double* p, double charge, double Bz ){
45 
46  _ref_point_x = position[0] ;
47  _ref_point_y = position[1] ;
48  _ref_point_z = position[2] ;
49 
50  _d0 = 0.0 ;
51  _z0 = 0.0 ;
52 
53  const double pt = sqrt(p[0]*p[0]+p[1]*p[1]) ;
54 
55  double radius = pt / (2.99792458E-4*Bz) ; // for r in mm, p in GeV and Bz in Tesla
56 
57  _omega = charge/radius ;
58  _tanLambda = p[2]/pt ;
59 
60  _phi0 = atan2(p[1],p[0]);
61 
63 
64 }
65 
66 double HelixTrack::moveRefPoint( double x, double y, double z){
67 
68  const double radius = 1.0/_omega ;
69 
70  const double sinPhi0 = sin(_phi0) ;
71  const double cosPhi0 = cos(_phi0) ;
72 
73  const double deltaX = x - _ref_point_x ;
74  const double deltaY = y - _ref_point_y ;
75 
76  double phi0Prime = atan2( sinPhi0 - (deltaX/(radius-_d0)) , cosPhi0 + (deltaY/(radius-_d0)) ) ;
77 
78  while ( phi0Prime < 0 ) phi0Prime += 2.0*M_PI ;
79  while ( phi0Prime >= 2.0*M_PI ) phi0Prime -= 2.0*M_PI ;
80 
81  const double d0Prime = _d0 + deltaX*sinPhi0 - deltaY*cosPhi0 + ( ( deltaX*cosPhi0 + deltaY*sinPhi0 ) * tan( (phi0Prime-_phi0) / 2.0) ) ;
82 
83  // In order to have terms which behave well as Omega->0 we make use of deltaX and deltaY to replace sin( phi0Prime - phi0 ) and cos( phi0Prime - phi0 )
84 
85  const double sinDeltaPhi = ( -_omega / ( 1.0 - ( _omega * d0Prime ) ) ) * ( deltaX * cosPhi0 + deltaY * sinPhi0 ) ;
86 
87  const double cosDeltaPhi = 1.0 + ( _omega*_omega / ( 2.0 * ( 1.0 - _omega * d0Prime ) ) ) * ( d0Prime*d0Prime - ( deltaX + _d0 * sinPhi0 )*( deltaX + _d0 * sinPhi0 ) - ( deltaY - _d0 * cosPhi0 )*( deltaY - _d0 * cosPhi0 ) ) ;
88 
89  const double s = atan2(-sinDeltaPhi,cosDeltaPhi) / _omega ;
90 
91  const double z0Prime = _ref_point_z - z + _z0 + _tanLambda * s ;
92 
93  phi0Prime = toBaseRange(phi0Prime);
94 
95  _d0 = d0Prime ;
96  _phi0 = phi0Prime ;
97  _z0 = z0Prime ;
98 
99  _ref_point_x = x;
100  _ref_point_y = y;
101  _ref_point_z = z;
102 
103  return (s/radius);
104 
105 }
106 
107 
108 
109 
110 
double toBaseRange(double phi) const
helper function to restrict the range of the azimuthal angle to ]-pi,pi]
Definition: HelixTrack.h:49
#define M_PI
T endl(T...args)
double _tanLambda
Definition: HelixTrack.h:46
HelixTrack(double ref_point_x, double ref_point_y, double ref_point_z, double d0, double z0, double phi0, double omega, double tanLambda)
Definition: HelixTrack.h:10
double _omega
Definition: HelixTrack.h:45
double _ref_point_y
Definition: HelixTrack.h:40
double _z0
Definition: HelixTrack.h:43
double _ref_point_z
Definition: HelixTrack.h:41
static bool forwards
Definition: HelixTrack.h:35
double _phi0
Definition: HelixTrack.h:44
double moveRefPoint(double x, double y, double z)
Definition: HelixTrack.cc:66
double _ref_point_x
Definition: HelixTrack.h:39
double _d0
Definition: HelixTrack.h:42