CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
Reconstruction/TrackUtil/TrackUtil-00-00-12/TrackUtil/Helix.h
Go to the documentation of this file.
1//
2// $Id: Helix.h,v 1.7 2020/05/11 02:38: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"
21
22#include "CLHEP/Matrix/Vector.h"
23#include "CLHEP/Matrix/SymMatrix.h"
24//#ifndef CLHEP_THREEVECTOR_H
25#include "CLHEP/Vector/ThreeVector.h"
26//#endif
27#include "CLHEP/Vector/LorentzVector.h"
28//#ifndef CLHEP_POINT3D_H
29#include "CLHEP/Geometry/Point3D.h"
30//#endif
31
32#ifndef ENABLE_BACKWARDS_COMPATIBILITY
34#endif
35using namespace CLHEP;
36
38
39typedef CLHEP::HepVector Vector;
40typedef CLHEP::HepSymMatrix SymMatrix;
41typedef CLHEP::Hep3Vector Vector3;
42typedef CLHEP::HepLorentzVector VectorL;
43typedef CLHEP::HepLorentzVector Vector4;
44typedef CLHEP::HepMatrix Matrix;
45
46using CLHEP::HepVector;
47using CLHEP::HepSymMatrix;
48using CLHEP::Hep3Vector;
49using CLHEP::HepLorentzVector;
50
51
52/// Helix parameter class
53class Helix {
54
55 public:
56 Helix();
57 /// Constructor with pivot, helix parameter a, and its error matrix.
58 Helix(const HepPoint3D & pivot,
59 const HepVector & a,
60 const HepSymMatrix & Ea);
61
62 /// Constructor without error matrix.
63 Helix(const HepPoint3D & pivot,
64 const HepVector & a);
65
66 /// Constructor with position, momentum, and charge.
67 Helix(const HepPoint3D & position,
68 const Hep3Vector & momentum,
69 double charge);
70
71 Helix(const Helix& i);
72
73 /// Destructor
74 virtual ~Helix();
75
76 public:// Selectors
77 /// returns position of helix center(z = 0.);
78 const HepPoint3D & center(void) const;
79
80 /// returns pivot position.
81 const HepPoint3D & pivot(void) const;
82
83 /// returns radious of helix.
84 double radius(void) const;
85
86 /// returns position after rotating angle dPhi in phi direction.
87 HepPoint3D x(double dPhi = 0.) const;
88 double * x(double dPhi, double p[3]) const;
89
90 /// returns position and convariance matrix(Ex) after rotation.
91 HepPoint3D x(double dPhi, HepSymMatrix & Ex) const;
92
93 /// returns direction vector after rotating angle dPhi in phi direction.
94 Hep3Vector direction(double dPhi = 0.) const;
95
96 /// returns momentum vector after rotating angle dPhi in phi direction.
97 Hep3Vector momentum(double dPhi = 0.) const;
98
99 /// returns momentum vector after rotating angle dPhi in phi direction.
100 Hep3Vector momentum(double dPhi, HepSymMatrix & Em) const;
101
102 /// returns 4momentum vector after rotating angle dPhi in phi direction.
103 HepLorentzVector momentum(double dPhi, double mass) const;
104
105 /// returns 4momentum vector after rotating angle dPhi in phi direction.
106 HepLorentzVector momentum(double dPhi, double mass, HepSymMatrix & Em) const;
107
108 /// returns 4momentum vector after rotating angle dPhi in phi direction.
109 HepLorentzVector momentum(double dPhi, double mass, HepPoint3D & x, HepSymMatrix & Emx) const;
110
111 public:// Parametrization dependent functions. Prepared for tracking codes. Users should not use them.
112 /// returns an element of parameters.
113 double dr(void) const;
114 double phi0(void) const;
115 double kappa(void) const;
116 double dz(void) const;
117 double tanl(void) const;
118 double curv(void) const;
119 double sinPhi0(void) const;
120 double cosPhi0(void) const;
121 double alpha(void) const;
122
123 /// returns helix parameters.
124 const HepVector & a(void) const;
125
126 /// returns error matrix.
127 const HepSymMatrix & Ea(void) const;
128
129 double pt(void) const{ return m_pt; }
130 double cosTheta(void) const{ return m_a[4]/sqrt(1.+ m_a[4]*m_a[4]); }
131 public:// Modifiers
132 /// sets helix parameters.
133 const HepVector & a(const HepVector & newA);
134
135 /// sets helix paramters and error matrix.
136 const HepSymMatrix & Ea(const HepSymMatrix & newdA);
137
138 /// sets pivot position.
139 const HepPoint3D & pivot(const HepPoint3D & newPivot);
140
141 /// sets helix pivot position, parameters, and error matrix.
142 void set(const HepPoint3D & pivot,
143 const HepVector & a,
144 const HepSymMatrix & Ea);
145
146 /// unsets error matrix. Error calculations will be ignored after this function call until an error matrix be set again. 0 matrix will be return as a return value for error matrix when you call functions which returns an error matrix.
147 void ignoreErrorMatrix(void);
148
149 /// sets/returns z componet of the magnetic field.
150 double bFieldZ(double);
151 double bFieldZ(void) const;
152
153 public:// Operators
154 /// Copy operator
155 Helix & operator = (const Helix &);
156
157 public:// Mathmatical functions
158 HepMatrix delApDelA(const HepVector & ap) const;
159 HepMatrix delXDelA(double phi) const;
160 HepMatrix delMDelA(double phi) const;
161 HepMatrix del4MDelA(double phi, double mass) const;
162 HepMatrix del4MXDelA(double phi, double mass) const;
163 double IntersectCylinder(double r) const;
164 double flightArc(HepPoint3D& hit)const;
165 double flightArc(double r)const;
166 double flightLength(HepPoint3D& hit)const;
167 double dPhi(HepPoint3D& hit) const;
168
169 //private:
170 protected:
172 double m_bField;
173 double m_alpha;
174
175 private:
176 void updateCache(void);
177
178 public:
179 /// Constant alpha for uniform field.
180 static const double ConstantAlpha;
181
182 private:
183 //double m_bField;
184 //double m_alpha;
185 HepPoint3D m_pivot;
186 HepVector m_a;
187 HepSymMatrix m_Ea;
188 bool m_matrixValid;
189
190 private: // caches
191 HepPoint3D m_center;
192 double m_cp;
193 double m_sp;
194 double m_pt;
195 double m_r;
196 double m_ac[5];
197};
198
199//-----------------------------------------------------------------------------
200
201#ifdef Helix_NO_INLINE
202#define inline
203#else
204#undef inline
205#define Helix_INLINE_DEFINE_HERE
206#endif
207
208#ifdef Helix_INLINE_DEFINE_HERE
209
210inline
211const HepPoint3D &
212Helix::center(void) const {
213 return m_center;
214}
215
216inline
217const HepPoint3D &
218Helix::pivot(void) const {
219 return m_pivot;
220}
221
222inline
223double
224Helix::radius(void) const {
225 return m_r;
226}
227
228inline
229Hep3Vector
230Helix::direction(double phi) const {
231 return momentum(phi).unit();
232}
233
234inline
235double
236Helix::dr(void) const {
237 return m_ac[0];
238}
239
240inline
241double
242Helix::phi0(void) const {
243 return m_ac[1];
244}
245
246inline
247double
248Helix::kappa(void) const {
249 return m_ac[2];
250}
251
252inline
253double
254Helix::dz(void) const {
255 return m_ac[3];
256}
257
258inline
259double
260Helix::tanl(void) const {
261 return m_ac[4];
262}
263
264inline
265double
266Helix::curv(void) const {
267 return m_r;
268}
269
270inline
271const HepVector &
272Helix::a(void) const {
273 return m_a;
274}
275
276inline
277const HepSymMatrix &
278Helix::Ea(void) const {
279 return m_Ea;
280}
281
282inline
283const HepVector &
284Helix::a(const HepVector & i) {
285 m_a = i;
286 updateCache();
287 return m_a;
288}
289
290inline
291const HepSymMatrix &
292Helix::Ea(const HepSymMatrix & i) {
293 return m_Ea = i;
294}
295
296inline
297double
298Helix::bFieldZ(double a) {
299 m_bField = a;
300 m_alpha = 10000. / 2.99792458 / m_bField;
301 updateCache();
302 return m_bField;
303}
304
305inline
306double
307Helix::alpha(void) const {
308
309 return m_alpha;
310}
311
312
313inline
314double
315Helix::bFieldZ(void) const {
316 return m_bField;
317}
318
319inline
320double
321Helix::sinPhi0(void) const {
322 return m_sp;
323}
324
325inline
326double
327Helix::cosPhi0(void) const {
328 return m_cp;
329}
330
331#endif
332
333#undef inline
334
335#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
Double_t x[10]
const double alpha
NTuple::Item< double > m_pt
Definition MdcHistItem.h:76
double bFieldZ(double)
sets/returns z componet of the magnetic field.
const HepPoint3D & center(void) const
returns position of helix center(z = 0.);
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 radius(void) const
returns radious of helix.
double dr(void) const
returns an element of parameters.
const HepVector & a(void) const
returns helix parameters.
const HepPoint3D & pivot(void) const
returns pivot position.
Hep3Vector direction(double dPhi=0.) const
returns direction vector after rotating angle dPhi in phi direction.