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