BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Reconstruction/TrackUtil/include/TrackUtil/Helix.h
Go to the documentation of this file.
1//
2// $Id: Helix.h,v 1.4 2011/05/12 10:25:28 wangll Exp $
3//
4// Class Helix
5//
6// Author Date comments
7// Y.Ohnishi 03/01/1997 original version
8// Y.Ohnishi 06/03/1997 updated
9// Y.Iwasaki 17/02/1998 BFILED removed, func. name changed, func. added
10// J.Tanaka 06/12/1998 add some utilities.
11// Y.Iwasaki 07/07/1998 cache added to speed up
12// Y.Iwasaki 25/04/2001 cache m_ac[5] added to speed up
13//
14#ifndef Helix_FLAG_
15#define Helix_FLAG_
16#include "GaudiKernel/IInterface.h"
17#include "GaudiKernel/Kernel.h"
18#include "GaudiKernel/Service.h"
19#include "MagneticFieldSvc/IBesMagFieldSvc.h"
20
21#include "CLHEP/Matrix/SymMatrix.h"
22#include "CLHEP/Matrix/Vector.h"
23// #ifndef CLHEP_THREEVECTOR_H
24#include "CLHEP/Vector/ThreeVector.h"
25// #endif
26#include "CLHEP/Vector/LorentzVector.h"
27// #ifndef CLHEP_POINT3D_H
28#include "CLHEP/Geometry/Point3D.h"
29// #endif
30
31#ifndef ENABLE_BACKWARDS_COMPATIBILITY
32typedef HepGeom::Point3D<double> HepPoint3D;
33#endif
34using namespace CLHEP;
35
36using HepGeom::Point3D;
37
38typedef CLHEP::HepVector Vector;
39typedef CLHEP::HepSymMatrix SymMatrix;
40typedef CLHEP::Hep3Vector Vector3;
41typedef CLHEP::HepLorentzVector VectorL;
42typedef CLHEP::HepLorentzVector Vector4;
43typedef CLHEP::HepMatrix Matrix;
44
45using CLHEP::Hep3Vector;
46using CLHEP::HepLorentzVector;
47using CLHEP::HepSymMatrix;
48using CLHEP::HepVector;
49
50/// Helix parameter class
51class Helix {
52
53public:
54 /// Constructor with pivot, helix parameter a, and its error matrix.
55 Helix( const HepPoint3D& pivot, const HepVector& a, const HepSymMatrix& Ea );
56
57 /// Constructor without error matrix.
58 Helix( const HepPoint3D& pivot, const HepVector& a );
59
60 /// Constructor with position, momentum, and charge.
61 Helix( const HepPoint3D& position, const Hep3Vector& momentum, double charge );
62
63 /// Destructor
64 virtual ~Helix();
65
66public: // Selectors
67 /// returns position of helix center(z = 0.);
68 const HepPoint3D& center( void ) const;
69
70 /// returns pivot position.
71 const HepPoint3D& pivot( void ) const;
72
73 /// returns radious of helix.
74 double radius( void ) const;
75
76 /// returns position after rotating angle dPhi in phi direction.
77 HepPoint3D x( double dPhi = 0. ) const;
78 double* x( double dPhi, double p[3] ) const;
79
80 /// returns position and convariance matrix(Ex) after rotation.
81 HepPoint3D x( double dPhi, HepSymMatrix& Ex ) const;
82
83 /// returns direction vector after rotating angle dPhi in phi direction.
84 Hep3Vector direction( double dPhi = 0. ) const;
85
86 /// returns momentum vector after rotating angle dPhi in phi direction.
87 Hep3Vector momentum( double dPhi = 0. ) const;
88
89 /// returns momentum vector after rotating angle dPhi in phi direction.
90 Hep3Vector momentum( double dPhi, HepSymMatrix& Em ) const;
91
92 /// returns 4momentum vector after rotating angle dPhi in phi direction.
93 HepLorentzVector momentum( double dPhi, double mass ) const;
94
95 /// returns 4momentum vector after rotating angle dPhi in phi direction.
96 HepLorentzVector momentum( double dPhi, double mass, HepSymMatrix& Em ) const;
97
98 /// returns 4momentum vector after rotating angle dPhi in phi direction.
99 HepLorentzVector momentum( double dPhi, double mass, HepPoint3D& x,
100 HepSymMatrix& Emx ) const;
101
102public: // Parametrization dependent functions. Prepared for tracking codes. Users should not
103 // use them.
104 /// returns an element of parameters.
105 double dr( void ) const;
106 double phi0( void ) const;
107 double kappa( void ) const;
108 double dz( void ) const;
109 double tanl( void ) const;
110 double curv( void ) const;
111 double sinPhi0( void ) const;
112 double cosPhi0( void ) const;
113
114 /// returns helix parameters.
115 const HepVector& a( void ) const;
116
117 /// returns error matrix.
118 const HepSymMatrix& Ea( void ) const;
119
120 double pt( void ) const { return m_pt; }
121 double cosTheta( void ) const { return m_a[4] / sqrt( 1. + m_a[4] * m_a[4] ); }
122
123public: // Modifiers
124 /// sets helix parameters.
125 const HepVector& a( const HepVector& newA );
126
127 /// sets helix paramters and error matrix.
128 const HepSymMatrix& Ea( const HepSymMatrix& newdA );
129
130 /// sets pivot position.
131 const HepPoint3D& pivot( const HepPoint3D& newPivot );
132
133 /// sets helix pivot position, parameters, and error matrix.
134 void set( const HepPoint3D& pivot, const HepVector& a, const HepSymMatrix& Ea );
135
136 /// unsets error matrix. Error calculations will be ignored after this function call until an
137 /// error matrix be set again. 0 matrix will be return as a return value for error matrix
138 /// when you call functions which returns an error matrix.
139 void ignoreErrorMatrix( void );
140
141 /// sets/returns z componet of the magnetic field.
142 double bFieldZ( double );
143 double bFieldZ( void ) const;
144
145public: // Operators
146 /// Copy operator
148
149public: // Mathmatical functions
150 HepMatrix delApDelA( const HepVector& ap ) const;
151 HepMatrix delXDelA( double phi ) const;
152 HepMatrix delMDelA( double phi ) const;
153 HepMatrix del4MDelA( double phi, double mass ) const;
154 HepMatrix del4MXDelA( double phi, double mass ) const;
155
156 // private:
157protected:
159 double m_bField;
160 double m_alpha;
161
162private:
163 void updateCache( void );
164
165public:
166 /// Constant alpha for uniform field.
167 static const double ConstantAlpha;
168
169private:
170 // double m_bField;
171 // double m_alpha;
172 HepPoint3D m_pivot;
173 HepVector m_a;
174 HepSymMatrix m_Ea;
175 bool m_matrixValid;
176
177private: // caches
178 HepPoint3D m_center;
179 double m_cp;
180 double m_sp;
181 double m_pt;
182 double m_r;
183 double m_ac[5];
184};
185
186//-----------------------------------------------------------------------------
187
188#ifdef Helix_NO_INLINE
189# define inline
190#else
191# undef inline
192# define Helix_INLINE_DEFINE_HERE
193#endif
194
195#ifdef Helix_INLINE_DEFINE_HERE
196
197inline const HepPoint3D& Helix::center( void ) const { return m_center; }
198
199inline const HepPoint3D& Helix::pivot( void ) const { return m_pivot; }
200
201inline double Helix::radius( void ) const { return m_r; }
202
203inline Hep3Vector Helix::direction( double phi ) const { return momentum( phi ).unit(); }
204
205inline double Helix::dr( void ) const { return m_ac[0]; }
206
207inline double Helix::phi0( void ) const { return m_ac[1]; }
208
209inline double Helix::kappa( void ) const { return m_ac[2]; }
210
211inline double Helix::dz( void ) const { return m_ac[3]; }
212
213inline double Helix::tanl( void ) const { return m_ac[4]; }
214
215inline double Helix::curv( void ) const { return m_r; }
216
217inline const HepVector& Helix::a( void ) const { return m_a; }
218
219inline const HepSymMatrix& Helix::Ea( void ) const { return m_Ea; }
220
221inline const HepVector& Helix::a( const HepVector& i ) {
222 m_a = i;
223 updateCache();
224 return m_a;
225}
226
227inline const HepSymMatrix& Helix::Ea( const HepSymMatrix& i ) { return m_Ea = i; }
228
229inline double Helix::bFieldZ( double a ) {
230 m_bField = a;
231 m_alpha = 10000. / 2.99792458 / m_bField;
232 updateCache();
233 return m_bField;
234}
235
236inline double Helix::bFieldZ( void ) const { return m_bField; }
237
238inline double Helix::sinPhi0( void ) const { return m_sp; }
239
240inline double Helix::cosPhi0( void ) const { return m_cp; }
241
242#endif
243
244#undef inline
245
246#endif /* Helix_FLAG_ */
**********INTEGER nmxhep !maximum number of particles DOUBLE PRECISION vhep INTEGER jdahep COMMON hepevt $ !serial number $ !number of particles $ !status code $ !particle ident KF $ !parent particles $ !childreen particles $ !four momentum
double mass
HepGeom::Point3D< double > HepPoint3D
HepGeom::Point3D< double > HepPoint3D
HepLorentzVector momentum(double dPhi, double mass, HepPoint3D &x, HepSymMatrix &Emx) const
returns 4momentum vector after rotating angle dPhi in phi direction.
Helix(const HepPoint3D &pivot, const HepVector &a)
Constructor without error matrix.
HepMatrix delApDelA(const HepVector &ap) const
double cosPhi0(void) const
HepMatrix delMDelA(double phi) const
HepPoint3D x(double dPhi, HepSymMatrix &Ex) const
returns position and convariance matrix(Ex) after rotation.
double sinPhi0(void) const
const HepPoint3D & pivot(const HepPoint3D &newPivot)
sets pivot position.
double phi0(void) const
double bFieldZ(double)
sets/returns z componet of the magnetic field.
const HepPoint3D & center(void) const
returns position of helix center(z = 0.);
virtual ~Helix()
Destructor.
void set(const HepPoint3D &pivot, const HepVector &a, const HepSymMatrix &Ea)
sets helix pivot position, parameters, and error matrix.
Helix(const HepPoint3D &position, const Hep3Vector &momentum, double charge)
Constructor with position, momentum, and charge.
void ignoreErrorMatrix(void)
double tanl(void) const
Helix & operator=(const Helix &)
Copy operator.
HepMatrix del4MXDelA(double phi, double mass) const
Hep3Vector momentum(double dPhi=0.) const
returns momentum vector after rotating angle dPhi in phi direction.
const HepVector & a(const HepVector &newA)
sets helix parameters.
HepLorentzVector momentum(double dPhi, double mass) const
returns 4momentum vector after rotating angle dPhi in phi direction.
const HepSymMatrix & Ea(const HepSymMatrix &newdA)
sets helix paramters and error matrix.
static const double ConstantAlpha
Constant alpha for uniform field.
const HepSymMatrix & Ea(void) const
returns error matrix.
HepPoint3D x(double dPhi=0.) const
returns position after rotating angle dPhi in phi direction.
double bFieldZ(void) const
double curv(void) const
double * x(double dPhi, double p[3]) const
HepMatrix del4MDelA(double phi, double mass) const
double dz(void) const
HepMatrix delXDelA(double phi) const
double radius(void) const
returns radious of helix.
double dr(void) const
returns an element of parameters.
const HepVector & a(void) const
returns helix parameters.
Hep3Vector momentum(double dPhi, HepSymMatrix &Em) const
returns momentum vector after rotating angle dPhi in phi direction.
Helix(const HepPoint3D &pivot, const HepVector &a, const HepSymMatrix &Ea)
Constructor with pivot, helix parameter a, and its error matrix.
const HepPoint3D & pivot(void) const
returns pivot position.
Hep3Vector direction(double dPhi=0.) const
returns direction vector after rotating angle dPhi in phi direction.
HepLorentzVector momentum(double dPhi, double mass, HepSymMatrix &Em) const
returns 4momentum vector after rotating angle dPhi in phi direction.
double kappa(void) const