Belle II Software development
Helix Class Reference

Extension of the generalized circle also caching the perigee coordinates. More...

#include <Helix.h>

Public Member Functions

 Helix ()
 Default constructor for ROOT compatibility.
 
 Helix (const PerigeeCircle &circleXY, const SZLine &szLine)
 Constructor combining a two dimensional circle with the linear augment in the sz space.
 
 Helix (const HelixParameters &parameters)
 Constructor taking all stored parameters for internal use.
 
 Helix (double curvature, double phi0, double impact, double tanLambda, double z0)
 Constructor from all helix parameter.
 
 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.
 
void invalidate ()
 Sets all circle parameters to zero.
 
bool isInvalid () const
 Indicates if the stored parameter combination designates a valid helix.
 
void reverse ()
 Flips the travel direction of the helix in place, pivot point is unchanged.
 
Helix reversed () const
 Returns a copy of the helix with flips the travel direction, pivot point is the same.
 
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 point.
 
double arcLength2DToXY (const ROOT::Math::XYVector &point) const
 Calculates the two dimensional arc length that is closest to two dimensional point in the xy projection.
 
double arcLength2DToCylindricalR (double cylindricalR) const
 Calculates the two dimensional arc length that first reaches a cylindrical radius on the helix Returns NAN if the radius cannot be reached.
 
ROOT::Math::XYZVector closest (const ROOT::Math::XYZVector &point, bool firstPeriod=true) const
 Calculates the point on the helix with the smallest total distance.
 
ROOT::Math::XYZVector closestXY (const ROOT::Math::XYVector &pointXY) const
 Calculates the point on the helix with the smallest perpendicular (xy) distance.
 
double distance (const ROOT::Math::XYZVector &point) const
 Calculates the distance of the point to the point of closest approach on the helix.
 
double distanceXY (const ROOT::Math::XYVector &point) const
 Calculates the distance of the line parallel to the z axes through the given point.
 
double passiveMoveBy (const ROOT::Math::XYZVector &by)
 Moves the coordinates system by the given vector.
 
HelixJacobian passiveMoveByJacobian (const ROOT::Math::XYZVector &by) const
 Computes the Jacobi matrix for a move of the coordinate system by the given vector.
 
double shiftPeriod (int nPeriods)
 Adjust the arclength measure to start n periods later.
 
ROOT::Math::XYZVector atArcLength2D (double s) const
 Calculates the point, which lies at the give perpendicular travel distance (counted from the perigee)
 
ROOT::Math::XYZVector atZ (double z) const
 Calculates the point, which lies at the given z coordinate.
 
ROOT::Math::XYVector xyAtZ (double z) const
 Calculates the point, which lies at the given z coordinate.
 
double minimalCylindricalR () const
 Gives the minimal cylindrical radius the circle reaches (unsigned)
 
double maximalCylindricalR () const
 Gives the maximal cylindrical radius the circle reaches.
 
double curvatureXY () const
 Getter for the signed curvature in the xy projection.
 
double impactXY () const
 Getter for the signed distance to the z axes at the perigee point.
 
double omega () const
 Getter for the omega parameter of the common helix parameterisation.
 
double d0 () const
 Getter for the signed distance to the z axes at the perigee point.
 
ROOT::Math::XYVector perigeeXY () const
 Getter for the perigee point in the xy projection.
 
ROOT::Math::XYZVector perigee () const
 Getter for the perigee point of the helix.
 
double tanLambda () const
 Getter for the proportinality factor from arc length in xy space to z.
 
double cotTheta () const
 Getter for the proportinality factor from arc length in xy space to z.
 
double z0 () const
 Getter for z coordinate at the perigee point of the helix.
 
double zPeriod () const
 Getter for the distance in z at which the two points on the helix coincide in the xy projection.
 
double arcLength2DPeriod () const
 Getter for the arc length of one trip around the helix.
 
double perimeterXY () const
 Getter for the perimeter of the circle in the xy projection.
 
double radiusXY () const
 Getter for the radius of the circle in the xy projection.
 
ROOT::Math::XYVector centerXY () const
 Getter for the central point of the helix.
 
ROOT::Math::XYZVector tangential () const
 Getter for the unit three dimensional tangential vector at the perigee point of the helix.
 
const ROOT::Math::XYVector & phi0Vec () const
 Getter for the direction vector in the xy projection at the perigee of the helix.
 
double phi0 () const
 Getter for the azimuth angle of the direction of flight at the perigee.
 
HelixParameters helixParameters () const
 Getter for the five helix parameters in the order defined by EHelixParameter.h.
 
const PerigeeCirclecircleXY () const
 Getter for the projection into xy space.
 
const SZLineszLine () const
 Getter for the projection into xy space.
 

Private Attributes

PerigeeCircle m_circleXY
 Memory of the projection of the helix in xy space.
 
SZLine m_szLine
 Memory of the of the linear relation between perpendicular travel distance and the z position.
 

Detailed Description

Extension of the generalized circle also caching the perigee coordinates.

Definition at line 30 of file Helix.h.

Constructor & Destructor Documentation

◆ Helix() [1/5]

Helix ( )
inline

Default constructor for ROOT compatibility.

Definition at line 34 of file Helix.h.

35 : m_circleXY()
36 , m_szLine()
37 {
38 }

◆ Helix() [2/5]

Helix ( const PerigeeCircle & circleXY,
const SZLine & szLine )
inline

Constructor combining a two dimensional circle with the linear augment in the sz space.

Definition at line 41 of file Helix.h.

42 : m_circleXY(circleXY)
43 , m_szLine(szLine)
44 {
45 }

◆ Helix() [3/5]

Helix ( const HelixParameters & parameters)
inlineexplicit

Constructor taking all stored parameters for internal use.

Definition at line 48 of file Helix.h.

49 : m_circleXY(HelixUtil::getPerigeeParameters(parameters))
50 , m_szLine(HelixUtil::getSZParameters(parameters))
51 {
52 }

◆ Helix() [4/5]

Helix ( double curvature,
double phi0,
double impact,
double tanLambda,
double z0 )
inline

Constructor from all helix parameter.

Definition at line 55 of file Helix.h.

56 : m_circleXY(curvature, phi0, impact)
57 , m_szLine(tanLambda, z0)
58 {
59 }

◆ Helix() [5/5]

Helix ( double curvature,
const ROOT::Math::XYVector & phi0Vec,
double impact,
double tanLambda,
double z0 )
inline

Constructor from all helix parameter, phi given as a unit vector.

Definition at line 62 of file Helix.h.

63 : m_circleXY(curvature, phi0Vec, impact)
64 , m_szLine(tanLambda, z0)
65 {
66 }

Member Function Documentation

◆ arcLength2DPeriod()

double arcLength2DPeriod ( ) const
inline

Getter for the arc length of one trip around the helix.

Definition at line 270 of file Helix.h.

271 {
272 return circleXY().arcLengthPeriod();
273 }

◆ arcLength2DToClosest()

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 point.

Definition at line 31 of file Helix.cc.

32{
33 // The point may happen to lie in the center of the helix.
34 double loc_d0 = circleXY().distance(VectorUtil::getXYVector(point));
35 double denominator = 1 + curvatureXY() * loc_d0;
36 if (denominator == 0) {
37 // When this happens we can optimise the z distance for the closest point
38 double arcLength2D = (point.z() - z0()) / tanLambda();
39 if (not std::isfinite(arcLength2D)) {
40 return 0.0;
41 } else {
42 return arcLength2D;
43 }
44 }
45
46 // First approximation optimising the xy distance.
47 double arcLength2D = circleXY().arcLengthTo(VectorUtil::getXYVector(point));
48 // In case the helix is a flat circle with no extend into z this is the actual solution
49 if (tanLambda() == 0) {
50 return arcLength2D;
51 }
52
53 double deltaZ = point.z() - szLine().map(arcLength2D);
54 if (not firstPeriod) {
55 if (fabs(deltaZ) > zPeriod() / 2) {
56 double newDeltaZ = std::remainder(deltaZ, zPeriod());
57 double nPeriodShift = (deltaZ - newDeltaZ) / zPeriod();
58 arcLength2D += nPeriodShift * perimeterXY();
59 deltaZ = newDeltaZ;
60 }
61 }
62
63 using boost::math::tools::brent_find_minima;
64
65 auto distance3D = [this, &point](const double & s) -> double {
66 ROOT::Math::XYZVector pos = atArcLength2D(s);
67 return VectorUtil::Distance(pos, point);
68 };
69
70 double searchWidth = std::fmin(perimeterXY(), 2 * deltaZ / tanLambda());
71
72 double lowerS = arcLength2D - searchWidth;
73 double upperS = arcLength2D + searchWidth;
74
75 int bits = std::numeric_limits<double>::digits;
76 size_t nMaxIter = 100;
77
78 std::pair<double, double> sBounds = brent_find_minima(distance3D, lowerS, upperS, bits, nMaxIter);
79
80 // Stopped before iterations were exhausted?
81 // bool converged = nMaxIter > 0;
82
83 double firstDistance = distance3D(sBounds.first);
84 double secondDistance = distance3D(sBounds.second);
85 if (firstDistance < secondDistance) {
86 return sBounds.first;
87 } else {
88 return sBounds.second;
89 }
90}
double z0() const
Getter for z coordinate at the perigee point of the helix.
Definition Helix.h:257
double perimeterXY() const
Getter for the perimeter of the circle in the xy projection.
Definition Helix.h:276
double tanLambda() const
Getter for the proportinality factor from arc length in xy space to z.
Definition Helix.h:245
double curvatureXY() const
Getter for the signed curvature in the xy projection.
Definition Helix.h:208
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
const PerigeeCircle & circleXY() const
Getter for the projection into xy space.
Definition Helix.h:326
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

◆ arcLength2DToCylindricalR()

double arcLength2DToCylindricalR ( double cylindricalR) const
inline

Calculates the two dimensional arc length that first reaches a cylindrical radius on the helix Returns NAN if the radius cannot be reached.

Definition at line 114 of file Helix.h.

115 {
116 return circleXY().arcLengthToCylindricalR(cylindricalR);
117 }

◆ arcLength2DToXY()

double arcLength2DToXY ( const ROOT::Math::XYVector & point) const
inline

Calculates the two dimensional arc length that is closest to two dimensional point in the xy projection.

Always gives a solution in the first half period in the positive or negative direction

Definition at line 104 of file Helix.h.

105 {
106 return circleXY().arcLengthTo(point);
107 }

◆ atArcLength2D()

ROOT::Math::XYZVector atArcLength2D ( double s) const
inline

Calculates the point, which lies at the give perpendicular travel distance (counted from the perigee)

Definition at line 176 of file Helix.h.

177 {
178 const auto& tmp = circleXY().atArcLength(s);
179 return ROOT::Math::XYZVector(tmp.X(), tmp.Y(), szLine().map(s));
180 }

◆ atZ()

ROOT::Math::XYZVector atZ ( double z) const
inline

Calculates the point, which lies at the given z coordinate.

Definition at line 183 of file Helix.h.

184 {
185 const auto& tmp = xyAtZ(z);
186 return ROOT::Math::XYZVector(tmp.X(), tmp.Y(), z);
187 }

◆ centerXY()

ROOT::Math::XYVector centerXY ( ) const
inline

Getter for the central point of the helix.

Definition at line 288 of file Helix.h.

289 {
290 return circleXY().center();
291 }

◆ circleXY()

const PerigeeCircle & circleXY ( ) const
inline

Getter for the projection into xy space.

Definition at line 326 of file Helix.h.

327 {
328 return m_circleXY;
329 }

◆ closest()

ROOT::Math::XYZVector closest ( const ROOT::Math::XYZVector & point,
bool firstPeriod = true ) const
inline

Calculates the point on the helix with the smallest total distance.

Definition at line 120 of file Helix.h.

121 {
122 double arcLength2D = arcLength2DToClosest(point, firstPeriod);
123 return atArcLength2D(arcLength2D);
124 }

◆ closestXY()

ROOT::Math::XYZVector closestXY ( const ROOT::Math::XYVector & pointXY) const
inline

Calculates the point on the helix with the smallest perpendicular (xy) distance.

Definition at line 127 of file Helix.h.

128 {
129 double arcLength2D = arcLength2DToXY(pointXY);
130 return atArcLength2D(arcLength2D);
131 }

◆ cotTheta()

double cotTheta ( ) const
inline

Getter for the proportinality factor from arc length in xy space to z.

Definition at line 251 of file Helix.h.

252 {
253 return tanLambda();
254 }

◆ curvatureXY()

double curvatureXY ( ) const
inline

Getter for the signed curvature in the xy projection.

Definition at line 208 of file Helix.h.

209 {
210 return circleXY().curvature();
211 }

◆ d0()

double d0 ( ) const
inline

Getter for the signed distance to the z axes at the perigee point.

Definition at line 226 of file Helix.h.

227 {
228 return circleXY().d0();
229 }

◆ distance()

double distance ( const ROOT::Math::XYZVector & point) const
inline

Calculates the distance of the point to the point of closest approach on the helix.

Definition at line 134 of file Helix.h.

135 {
136 return VectorUtil::Distance(point, closest(point));
137 }

◆ distanceXY()

double distanceXY ( const ROOT::Math::XYVector & point) const
inline

Calculates the distance of the line parallel to the z axes through the given point.

Definition at line 140 of file Helix.h.

141 {
142 return m_circleXY.distance(point);
143 }

◆ helixParameters()

HelixParameters helixParameters ( ) const
inline

Getter for the five helix parameters in the order defined by EHelixParameter.h.

Definition at line 313 of file Helix.h.

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 }

◆ impactXY()

double impactXY ( ) const
inline

Getter for the signed distance to the z axes at the perigee point.

Definition at line 214 of file Helix.h.

215 {
216 return circleXY().impact();
217 }

◆ invalidate()

void invalidate ( )
inline

Sets all circle parameters to zero.

Definition at line 69 of file Helix.h.

70 {
71 m_circleXY.invalidate();
72 m_szLine.invalidate();
73 }

◆ isInvalid()

bool isInvalid ( ) const
inline

Indicates if the stored parameter combination designates a valid helix.

Definition at line 76 of file Helix.h.

77 {
78 return circleXY().isInvalid() and szLine().isInvalid();
79 }

◆ maximalCylindricalR()

double maximalCylindricalR ( ) const
inline

Gives the maximal cylindrical radius the circle reaches.

Definition at line 202 of file Helix.h.

203 {
204 return circleXY().maximalCylindricalR();
205 }

◆ minimalCylindricalR()

double minimalCylindricalR ( ) const
inline

Gives the minimal cylindrical radius the circle reaches (unsigned)

Definition at line 196 of file Helix.h.

197 {
198 return circleXY().minimalCylindricalR();
199 }

◆ omega()

double omega ( ) const
inline

Getter for the omega parameter of the common helix parameterisation.

Definition at line 220 of file Helix.h.

221 {
222 return circleXY().omega();
223 }

◆ passiveMoveBy()

double passiveMoveBy ( const ROOT::Math::XYZVector & by)
inline

Moves the coordinates system by the given vector.

Updates perigee point in place.

Returns
arcLength2D that has to be traversed to the new origin

Definition at line 149 of file Helix.h.

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 }

◆ passiveMoveByJacobian()

HelixJacobian passiveMoveByJacobian ( const ROOT::Math::XYZVector & by) const

Computes the Jacobi matrix for a move of the coordinate system by the given vector.

Definition at line 92 of file Helix.cc.

93{
94 // Fills the upper left 3x3 corner.
95 PerigeeJacobian perigeeJacobian = circleXY().passiveMoveByJacobian(VectorUtil::getXYVector(by));
96 SZJacobian szJacobian = SZUtil::identity();
97 HelixJacobian jacobian = HelixUtil::stackBlocks(perigeeJacobian, szJacobian);
98
99 double curv = curvatureXY();
100 double tanL = tanLambda();
101 double sArc = circleXY().arcLengthTo(VectorUtil::getXYVector(by));
102
103 using namespace NHelixParameterIndices;
104 jacobian(c_Z0, c_Curv) = tanL * (jacobian(c_Phi0, c_Curv) - sArc) / curv;
105 jacobian(c_Z0, c_Phi0) = tanL * (jacobian(c_Phi0, c_Phi0) - 1.) / curv;
106 jacobian(c_Z0, c_I) = tanL * jacobian(c_Phi0, c_I) / curv;
107 jacobian(c_Z0, c_TanL) = sArc;
108
109 return jacobian;
110}
double curv(void) const
Return curvature of helix.
Definition Helix.h:420
static HelixUtil::CovarianceMatrix stackBlocks(const PerigeeUtil::CovarianceMatrix &perigeeCov, const SZUtil::CovarianceMatrix &szCov)
Combine covariance matrices from the xy space and the sz space in their respective blocks.

◆ perigee()

ROOT::Math::XYZVector perigee ( ) const
inline

Getter for the perigee point of the helix.

Definition at line 238 of file Helix.h.

239 {
240 const auto& tmp = perigeeXY();
241 return ROOT::Math::XYZVector(tmp.X(), tmp.Y(), z0());
242 }

◆ perigeeXY()

ROOT::Math::XYVector perigeeXY ( ) const
inline

Getter for the perigee point in the xy projection.

Definition at line 232 of file Helix.h.

233 {
234 return circleXY().perigee();
235 }

◆ perimeterXY()

double perimeterXY ( ) const
inline

Getter for the perimeter of the circle in the xy projection.

Definition at line 276 of file Helix.h.

277 {
278 return circleXY().perimeter();
279 }

◆ phi0()

double phi0 ( ) const
inline

Getter for the azimuth angle of the direction of flight at the perigee.

Definition at line 307 of file Helix.h.

308 {
309 return circleXY().phi0();
310 }

◆ phi0Vec()

const ROOT::Math::XYVector & phi0Vec ( ) const
inline

Getter for the direction vector in the xy projection at the perigee of the helix.

Definition at line 301 of file Helix.h.

302 {
303 return circleXY().phi0Vec();
304 }

◆ radiusXY()

double radiusXY ( ) const
inline

Getter for the radius of the circle in the xy projection.

Definition at line 282 of file Helix.h.

283 {
284 return circleXY().radius();
285 }

◆ reverse()

void reverse ( )
inline

Flips the travel direction of the helix in place, pivot point is unchanged.

Definition at line 82 of file Helix.h.

83 {
84 m_circleXY.reverse();
85 m_szLine.reverse();
86 }

◆ reversed()

Helix reversed ( ) const
inline

Returns a copy of the helix with flips the travel direction, pivot point is the same.

Definition at line 89 of file Helix.h.

90 {
91 return Helix(circleXY().reversed(), szLine().reversed());
92 }
EForwardBackward reversed(EForwardBackward eForwardBackward)
Return the reversed forward backward indicator. Leaves EForwardBackward::c_Invalid the same.

◆ shiftPeriod()

double shiftPeriod ( int nPeriods)
inline

Adjust the arclength measure to start n periods later.

Returns
The arc length needed to travel n periods.

Definition at line 167 of file Helix.h.

168 {
169 double arcLength2D = nPeriods * fabs(perimeterXY());
170 m_szLine.passiveMoveBy(ROOT::Math::XYVector(arcLength2D, 0.0));
171 return arcLength2D;
172 }

◆ szLine()

const SZLine & szLine ( ) const
inline

Getter for the projection into xy space.

Definition at line 332 of file Helix.h.

333 {
334 return m_szLine;
335 }

◆ tangential()

ROOT::Math::XYZVector tangential ( ) const
inline

Getter for the unit three dimensional tangential vector at the perigee point of the helix.

Definition at line 294 of file Helix.h.

295 {
296 const auto& tmp = phi0Vec();
297 return VectorUtil::unit(ROOT::Math::XYZVector(tmp.X(), tmp.Y(), tanLambda()));
298 }

◆ tanLambda()

double tanLambda ( ) const
inline

Getter for the proportinality factor from arc length in xy space to z.

Definition at line 245 of file Helix.h.

246 {
247 return m_szLine.tanLambda();
248 }

◆ xyAtZ()

ROOT::Math::XYVector xyAtZ ( double z) const
inline

Calculates the point, which lies at the given z coordinate.

Definition at line 190 of file Helix.h.

191 {
192 return ROOT::Math::XYVector(circleXY().atArcLength(szLine().inverseMap(z)));
193 }

◆ z0()

double z0 ( ) const
inline

Getter for z coordinate at the perigee point of the helix.

Definition at line 257 of file Helix.h.

258 {
259 return m_szLine.z0();
260 }

◆ zPeriod()

double zPeriod ( ) const
inline

Getter for the distance in z at which the two points on the helix coincide in the xy projection.

Definition at line 264 of file Helix.h.

265 {
266 return tanLambda() * arcLength2DPeriod();
267 }

Member Data Documentation

◆ m_circleXY

PerigeeCircle m_circleXY
private

Memory of the projection of the helix in xy space.

Definition at line 339 of file Helix.h.

◆ m_szLine

SZLine m_szLine
private

Memory of the of the linear relation between perpendicular travel distance and the z position.

Definition at line 343 of file Helix.h.


The documentation for this class was generated from the following files: