Belle II Software development
SZLine.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/SZParameters.h>
11#include <tracking/trackingUtilities/numerics/Quadratic.h>
12
13#include <Math/Vector2D.h>
14
15namespace Belle2 {
20 namespace TrackingUtilities {
21
28 class SZLine {
29
30 public:
33 : m_tanLambda(NAN)
34 , m_z0(NAN)
35 {
36 }
37
39 SZLine(double tanLambda, double z0)
41 , m_z0(z0)
42 {
43 }
44
46 explicit SZLine(const SZParameters& szParameters)
47 : m_tanLambda(szParameters(ESZParameter::c_TanL))
48 , m_z0(szParameters(ESZParameter::c_Z0))
49 {
50 }
51
52 public:
54 double tanLambda() const
55 {
56 return m_tanLambda;
57 }
58
60 double slope() const
61 {
62 return m_tanLambda;
63 }
64
66 double inverseSlope() const
67 {
68 return 1 / tanLambda();
69 }
70
72 double theta() const
73 {
74 return m_tanLambda;
75 }
76
79 {
81 }
82
84 double z0() const
85 {
86 return m_z0;
87 }
88
90 double intercept() const
91 {
92 return m_z0;
93 }
94
96 void setZ0(double z0)
97 {
98 m_z0 = z0;
99 }
100
102 SZParameters szParameters() const
103 {
104 using namespace NSZParameterIndices;
105 SZParameters result;
106 result(c_TanL) = tanLambda();
107 result(c_Z0) = z0();
108 return result;
109 }
110
112 double zero() const
113 {
114 return -intercept() / slope();
115 }
116
118 double map(double s) const
119 {
120 return tanLambda() * s + z0();
121 }
122
124 double operator()(double s) const
125 {
126 return map(s);
127 }
128
130 double inverseMap(double z) const
131 {
132 return (z - z0()) / tanLambda();
133 }
134
135 public:
138 {
139 setZ0(NAN);
140 setTanLambda(NAN);
141 }
142
144 bool isInvalid() const
145 {
146 return not std::isfinite(tanLambda()) or not std::isfinite(z0());
147 }
148
150 void reverse()
151 {
153 }
154
157 {
158 return SZLine(-tanLambda(), z0());
159 }
160
161 public:
167 double distance(const ROOT::Math::XYVector& szPoint) const
168 {
169 return distance(szPoint.X(), szPoint.Y());
170 }
171
177 double distance(double s, double z) const
178 {
179 return (map(s) - z) / hypot2(1, tanLambda());
180 }
181
183 ROOT::Math::XYVector intersection(const SZLine& szLine) const;
184
186 void passiveMoveBy(const ROOT::Math::XYVector& bySZ)
187 {
188 passiveMoveBy(bySZ.X(), bySZ.Y());
189 }
190
192 void passiveMoveBy(double s, double z)
193 {
194 m_z0 = map(s) - z;
195 }
196
198 SZLine passiveMovedBy(const ROOT::Math::XYVector& bySZ) const
199 {
200 return passiveMovedBy(bySZ.X(), bySZ.Y());
201 }
202
204 SZLine passiveMovedBy(double s, double z) const
205 {
206 return SZLine(tanLambda(), map(s) - z);
207 }
208
210 static SZJacobian passiveMoveByJacobian(const ROOT::Math::XYVector& bySZ)
211 {
212 using namespace NSZParameterIndices;
213 SZJacobian result = SZUtil::identity();
214 result(c_Z0, c_TanL) = bySZ.X();
215 return result;
216 }
217
218 private:
221
223 double m_z0;
224
225 };
226 }
228}
A line in the sz space.
Definition SZLine.h:28
static SZJacobian passiveMoveByJacobian(const ROOT::Math::XYVector &bySZ)
Computes the Jacobi matrix for a move of the coordinate system by the given vector.
Definition SZLine.h:210
double m_tanLambda
Memory for the tan lambda parameter.
Definition SZLine.h:220
SZLine passiveMovedBy(double s, double z) const
Return a line passively move by the given s and z coordinates as a copy.
Definition SZLine.h:204
void passiveMoveBy(const ROOT::Math::XYVector &bySZ)
Passively move the coordinate system in place by the given sz vector.
Definition SZLine.h:186
double z0() const
Getter for the z0 parameter.
Definition SZLine.h:84
void setZ0(double z0)
Getter for the z0 parameter.
Definition SZLine.h:96
double zero() const
Returns the the two dimensional arc length s where the z coordinate approaches zero.
Definition SZLine.h:112
SZParameters szParameters() const
Getter for the sz parameters.
Definition SZLine.h:102
bool isInvalid() const
Indicates if the line parameters do not represent a valid line.
Definition SZLine.h:144
void reverse()
Reverse the arc length direction in place.
Definition SZLine.h:150
double slope() const
Getter for the slope in the sz space which is equivalent to tan lambda.
Definition SZLine.h:60
double distance(double s, double z) const
Calculates the signed distance of the point given by its to coordinates to the line.
Definition SZLine.h:177
double intercept() const
Getter for the intercept in the sz space which is equivalent to z0.
Definition SZLine.h:90
ROOT::Math::XYVector intersection(const SZLine &szLine) const
Calculates the intersection point of two line. Infinity for parallels.
Definition SZLine.cc:14
void setTanLambda(double tanLambda)
Getter for the tan lambda parameter.
Definition SZLine.h:78
double inverseSlope() const
Returns the slope over the second coordinate.
Definition SZLine.h:66
double tanLambda() const
Getter for the tan lambda parameter.
Definition SZLine.h:54
void invalidate()
Sets the parameters to a invalid representation.
Definition SZLine.h:137
SZLine()
Default constructor for ROOT compatibility.
Definition SZLine.h:32
SZLine(double tanLambda, double z0)
Constructor from slope and intercept in the sz space.
Definition SZLine.h:39
double map(double s) const
Maps the two dimensional arc length s to z.
Definition SZLine.h:118
SZLine passiveMovedBy(const ROOT::Math::XYVector &bySZ) const
Return a line passively move by the given vector as a copy.
Definition SZLine.h:198
double distance(const ROOT::Math::XYVector &szPoint) const
Calculates the signed distance of the point to the line.
Definition SZLine.h:167
double inverseMap(double z) const
Maps the z coordinate to the two dimensional arc length s.
Definition SZLine.h:130
void passiveMoveBy(double s, double z)
Passively move the coordinate system in place by the given s and z coordinates.
Definition SZLine.h:192
double m_z0
Memory for the z0 parameter.
Definition SZLine.h:223
SZLine(const SZParameters &szParameters)
Constructor from the sz parameters.
Definition SZLine.h:46
double operator()(double s) const
Maps the two dimensional arc length s to z.
Definition SZLine.h:124
double theta() const
Getter for the theta dip angle.
Definition SZLine.h:72
SZLine reversed() const
Returns a copy of the line with reversed the arc length direction.
Definition SZLine.h:156
Namespace to hide the contained enum constants.
Abstract base class for different kinds of events.