Belle II Software development
Helix.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <tracking/trackingUtilities/geometry/PerigeeCircle.h>
11#include <tracking/trackingUtilities/geometry/SZLine.h>
12
13#include <tracking/trackingUtilities/geometry/HelixParameters.h>
14#include <tracking/trackingUtilities/geometry/VectorUtil.h>
15
16#include <Math/Vector3D.h>
17#include <Math/Vector2D.h>
18
19#include <iosfwd>
20#include <cmath>
21
22namespace Belle2 {
27 namespace TrackingUtilities {
28
30 class Helix {
31
32 public:
35 : m_circleXY()
36 , m_szLine()
37 {
38 }
39
46
48 explicit Helix(const HelixParameters& parameters)
49 : m_circleXY(HelixUtil::getPerigeeParameters(parameters))
50 , m_szLine(HelixUtil::getSZParameters(parameters))
51 {
52 }
53
55 Helix(double curvature, double phi0, double impact, double tanLambda, double z0)
56 : m_circleXY(curvature, phi0, impact)
58 {
59 }
60
62 Helix(double curvature, const ROOT::Math::XYVector& phi0Vec, double impact, double tanLambda, double z0)
63 : m_circleXY(curvature, phi0Vec, impact)
65 {
66 }
67
70 {
71 m_circleXY.invalidate();
72 m_szLine.invalidate();
73 }
74
76 bool isInvalid() const
77 {
78 return circleXY().isInvalid() and szLine().isInvalid();
79 }
80
82 void reverse()
83 {
84 m_circleXY.reverse();
85 m_szLine.reverse();
86 }
87
90 {
91 return Helix(circleXY().reversed(), szLine().reversed());
92 }
93
94 public:
97 double arcLength2DToClosest(const ROOT::Math::XYZVector& point, bool firstPeriod = true) const;
98
104 double arcLength2DToXY(const ROOT::Math::XYVector& point) const
105 {
106 return circleXY().arcLengthTo(point);
107 }
108
114 double arcLength2DToCylindricalR(double cylindricalR) const
115 {
116 return circleXY().arcLengthToCylindricalR(cylindricalR);
117 }
118
120 ROOT::Math::XYZVector closest(const ROOT::Math::XYZVector& point, bool firstPeriod = true) const
121 {
122 double arcLength2D = arcLength2DToClosest(point, firstPeriod);
123 return atArcLength2D(arcLength2D);
124 }
125
127 ROOT::Math::XYZVector closestXY(const ROOT::Math::XYVector& pointXY) const
128 {
129 double arcLength2D = arcLength2DToXY(pointXY);
130 return atArcLength2D(arcLength2D);
131 }
132
134 double distance(const ROOT::Math::XYZVector& point) const
135 {
136 return VectorUtil::Distance(point, closest(point));
137 }
138
140 double distanceXY(const ROOT::Math::XYVector& point) const
141 {
142 return m_circleXY.distance(point);
143 }
144
149 double passiveMoveBy(const ROOT::Math::XYZVector& by)
150 {
151 // First keep the necessary shift of the perpendicular travel distance to the new perigee
152 // point.
153 double byS = circleXY().arcLengthTo(VectorUtil::getXYVector(by));
154 m_circleXY.passiveMoveBy(VectorUtil::getXYVector(by));
155 ROOT::Math::XYVector bySZ(byS, by.z());
156 m_szLine.passiveMoveBy(bySZ);
157 return byS;
158 }
159
161 HelixJacobian passiveMoveByJacobian(const ROOT::Math::XYZVector& by) const;
162
167 double shiftPeriod(int nPeriods)
168 {
169 double arcLength2D = nPeriods * fabs(perimeterXY());
170 m_szLine.passiveMoveBy(ROOT::Math::XYVector(arcLength2D, 0.0));
171 return arcLength2D;
172 }
173
176 ROOT::Math::XYZVector atArcLength2D(double s) const
177 {
178 const auto& tmp = circleXY().atArcLength(s);
179 return ROOT::Math::XYZVector(tmp.X(), tmp.Y(), szLine().map(s));
180 }
181
183 ROOT::Math::XYZVector atZ(double z) const
184 {
185 const auto& tmp = xyAtZ(z);
186 return ROOT::Math::XYZVector(tmp.X(), tmp.Y(), z);
187 }
188
190 ROOT::Math::XYVector xyAtZ(double z) const
191 {
192 return ROOT::Math::XYVector(circleXY().atArcLength(szLine().inverseMap(z)));
193 }
194
196 double minimalCylindricalR() const
197 {
198 return circleXY().minimalCylindricalR();
199 }
200
202 double maximalCylindricalR() const
203 {
204 return circleXY().maximalCylindricalR();
205 }
206
208 double curvatureXY() const
209 {
210 return circleXY().curvature();
211 }
212
214 double impactXY() const
215 {
216 return circleXY().impact();
217 }
218
220 double omega() const
221 {
222 return circleXY().omega();
223 }
224
226 double d0() const
227 {
228 return circleXY().d0();
229 }
230
232 ROOT::Math::XYVector perigeeXY() const
233 {
234 return circleXY().perigee();
235 }
236
238 ROOT::Math::XYZVector perigee() const
239 {
240 const auto& tmp = perigeeXY();
241 return ROOT::Math::XYZVector(tmp.X(), tmp.Y(), z0());
242 }
243
245 double tanLambda() const
246 {
247 return m_szLine.tanLambda();
248 }
249
251 double cotTheta() const
252 {
253 return tanLambda();
254 }
255
257 double z0() const
258 {
259 return m_szLine.z0();
260 }
261
264 double zPeriod() const
265 {
266 return tanLambda() * arcLength2DPeriod();
267 }
268
270 double arcLength2DPeriod() const
271 {
272 return circleXY().arcLengthPeriod();
273 }
274
276 double perimeterXY() const
277 {
278 return circleXY().perimeter();
279 }
280
282 double radiusXY() const
283 {
284 return circleXY().radius();
285 }
286
288 ROOT::Math::XYVector centerXY() const
289 {
290 return circleXY().center();
291 }
292
294 ROOT::Math::XYZVector tangential() const
295 {
296 const auto& tmp = phi0Vec();
297 return VectorUtil::unit(ROOT::Math::XYZVector(tmp.X(), tmp.Y(), tanLambda()));
298 }
299
301 const ROOT::Math::XYVector& phi0Vec() const
302 {
303 return circleXY().phi0Vec();
304 }
305
307 double phi0() const
308 {
309 return circleXY().phi0();
310 }
311
313 HelixParameters helixParameters() const
314 {
315 HelixParameters result;
316 using namespace NHelixParameterIndices;
317 result(c_Curv) = curvatureXY();
318 result(c_Phi0) = phi0();
319 result(c_I) = impactXY();
320 result(c_TanL) = tanLambda();
321 result(c_Z0) = z0();
322 return result;
323 }
324
326 const PerigeeCircle& circleXY() const
327 {
328 return m_circleXY;
329 }
330
332 const SZLine& szLine() const
333 {
334 return m_szLine;
335 }
336
337 private:
340
344
345 };
346
348 std::ostream& operator<<(std::ostream& output, const Helix& helix);
349 }
351}
Extension of the generalized circle also caching the perigee coordinates.
Definition Helix.h:30
ROOT::Math::XYZVector perigee() const
Getter for the perigee point of the helix.
Definition Helix.h:238
PerigeeCircle m_circleXY
Memory of the projection of the helix in xy space.
Definition Helix.h:339
Helix(const HelixParameters &parameters)
Constructor taking all stored parameters for internal use.
Definition Helix.h:48
ROOT::Math::XYZVector closestXY(const ROOT::Math::XYVector &pointXY) const
Calculates the point on the helix with the smallest perpendicular (xy) distance.
Definition Helix.h:127
Helix(const PerigeeCircle &circleXY, const SZLine &szLine)
Constructor combining a two dimensional circle with the linear augment in the sz space.
Definition Helix.h:41
ROOT::Math::XYZVector closest(const ROOT::Math::XYZVector &point, bool firstPeriod=true) const
Calculates the point on the helix with the smallest total distance.
Definition Helix.h:120
double z0() const
Getter for z coordinate at the perigee point of the helix.
Definition Helix.h:257
double distance(const ROOT::Math::XYZVector &point) const
Calculates the distance of the point to the point of closest approach on the helix.
Definition Helix.h:134
double phi0() const
Getter for the azimuth angle of the direction of flight at the perigee.
Definition Helix.h:307
double cotTheta() const
Getter for the proportinality factor from arc length in xy space to z.
Definition Helix.h:251
bool isInvalid() const
Indicates if the stored parameter combination designates a valid helix.
Definition Helix.h:76
double minimalCylindricalR() const
Gives the minimal cylindrical radius the circle reaches (unsigned)
Definition Helix.h:196
void reverse()
Flips the travel direction of the helix in place, pivot point is unchanged.
Definition Helix.h:82
double perimeterXY() const
Getter for the perimeter of the circle in the xy projection.
Definition Helix.h:276
ROOT::Math::XYVector perigeeXY() const
Getter for the perigee point in the xy projection.
Definition Helix.h:232
ROOT::Math::XYZVector atZ(double z) const
Calculates the point, which lies at the given z coordinate.
Definition Helix.h:183
double impactXY() const
Getter for the signed distance to the z axes at the perigee point.
Definition Helix.h:214
ROOT::Math::XYZVector tangential() const
Getter for the unit three dimensional tangential vector at the perigee point of the helix.
Definition Helix.h:294
double omega() const
Getter for the omega parameter of the common helix parameterisation.
Definition Helix.h:220
Helix reversed() const
Returns a copy of the helix with flips the travel direction, pivot point is the same.
Definition Helix.h:89
double shiftPeriod(int nPeriods)
Adjust the arclength measure to start n periods later.
Definition Helix.h:167
double tanLambda() const
Getter for the proportinality factor from arc length in xy space to z.
Definition Helix.h:245
double maximalCylindricalR() const
Gives the maximal cylindrical radius the circle reaches.
Definition Helix.h:202
double curvatureXY() const
Getter for the signed curvature in the xy projection.
Definition Helix.h:208
double arcLength2DToCylindricalR(double cylindricalR) const
Calculates the two dimensional arc length that first reaches a cylindrical radius on the helix Return...
Definition Helix.h:114
ROOT::Math::XYVector xyAtZ(double z) const
Calculates the point, which lies at the given z coordinate.
Definition Helix.h:190
HelixParameters helixParameters() const
Getter for the five helix parameters in the order defined by EHelixParameter.h.
Definition Helix.h:313
double zPeriod() const
Getter for the distance in z at which the two points on the helix coincide in the xy projection.
Definition Helix.h:264
void invalidate()
Sets all circle parameters to zero.
Definition Helix.h:69
double radiusXY() const
Getter for the radius of the circle in the xy projection.
Definition Helix.h:282
double arcLength2DToXY(const ROOT::Math::XYVector &point) const
Calculates the two dimensional arc length that is closest to two dimensional point in the xy projecti...
Definition Helix.h:104
double passiveMoveBy(const ROOT::Math::XYZVector &by)
Moves the coordinates system by the given vector.
Definition Helix.h:149
HelixJacobian passiveMoveByJacobian(const ROOT::Math::XYZVector &by) const
Computes the Jacobi matrix for a move of the coordinate system by the given vector.
Definition Helix.cc:92
double arcLength2DPeriod() const
Getter for the arc length of one trip around the helix.
Definition Helix.h:270
Helix(double curvature, const ROOT::Math::XYVector &phi0Vec, double impact, double tanLambda, double z0)
Constructor from all helix parameter, phi given as a unit vector.
Definition Helix.h:62
ROOT::Math::XYVector centerXY() const
Getter for the central point of the helix.
Definition Helix.h:288
double d0() const
Getter for the signed distance to the z axes at the perigee point.
Definition Helix.h:226
double arcLength2DToClosest(const ROOT::Math::XYZVector &point, bool firstPeriod=true) const
Calculates the perpendicular travel distance at which the helix has the closest approach to the given...
Definition Helix.cc:31
SZLine m_szLine
Memory of the of the linear relation between perpendicular travel distance and the z position.
Definition Helix.h:343
const PerigeeCircle & circleXY() const
Getter for the projection into xy space.
Definition Helix.h:326
double distanceXY(const ROOT::Math::XYVector &point) const
Calculates the distance of the line parallel to the z axes through the given point.
Definition Helix.h:140
Helix()
Default constructor for ROOT compatibility.
Definition Helix.h:34
const ROOT::Math::XYVector & phi0Vec() const
Getter for the direction vector in the xy projection at the perigee of the helix.
Definition Helix.h:301
Helix(double curvature, double phi0, double impact, double tanLambda, double z0)
Constructor from all helix parameter.
Definition Helix.h:55
ROOT::Math::XYZVector atArcLength2D(double s) const
Calculates the point, which lies at the give perpendicular travel distance (counted from the perigee)
Definition Helix.h:176
const SZLine & szLine() const
Getter for the projection into xy space.
Definition Helix.h:332
Extension of the generalized circle also caching the perigee coordinates.
double arcLengthTo(const ROOT::Math::XYVector &point) const
Calculates the arc length between the perigee and the given point.
double phi0() const
Getter for the azimuth angle of the direction of flight at the perigee.
bool isInvalid() const
Indicates if all circle parameters are zero.
double minimalCylindricalR() const
Gives the minimal cylindrical radius the circle reaches (unsigned)
double radius() const
Gives the signed radius of the circle. If it was a line this will be infinity.
double omega() const
Getter for omega parameter of the common Belle2::Helix which is the wrong sign curvature.
double impact() const
Getter for the signed distance of the origin to the circle.
double maximalCylindricalR() const
Gives the maximal cylindrical radius the circle reaches.
ROOT::Math::XYVector perigee() const
Getter for the perigee point.
double perimeter() const
Gives the signed perimeter of the circle.
ROOT::Math::XYVector atArcLength(double arcLength) const
Calculates the point, which lies at the give perpendicular travel distance (counted from the perigee)
double curvature() const
Getter for the signed curvature.
double d0() const
Getter for d0 parameter of the common Belle2::Helix representation.
ROOT::Math::XYVector center() const
Getter for the center of the circle. If it was a line both components will be infinity.
const ROOT::Math::XYVector & phi0Vec() const
Getter for the unit vector of the direction of flight at the perigee.
double arcLengthPeriod() const
Getter for the arc length for a full round of the circle.
double arcLengthToCylindricalR(double cylindricalR) const
Calculates the two dimensional arc length till the cylindrical radius is reached If the radius can no...
A line in the sz space.
Definition SZLine.h:28
bool isInvalid() const
Indicates if the line parameters do not represent a valid line.
Definition SZLine.h:144
Namespace to hide the contained enum constants.
Abstract base class for different kinds of events.
Utility struct for functions and types related to the helix parameters.