Belle II Software development
WireLine.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 <framework/geometry/VectorUtil.h>
11#include <Math/Vector2D.h>
12#include <Math/Vector3D.h>
13#include <Math/VectorUtil.h>
14
15#include <cmath>
16
17namespace Belle2 {
22 namespace CDC {
33 class WireLine {
34
35 public:
38 {}
39
41 WireLine(const ROOT::Math::XYZVector& forward, const ROOT::Math::XYZVector& backward, double sagCoeff);
42
44 WireLine movedBy(const ROOT::Math::XYZVector& offset) const;
45
47 WireLine movedBy(const ROOT::Math::XYVector& offset) const;
48
50 ROOT::Math::XYZVector nominalPos3DAtZ(const double z) const
51 {
52 const ROOT::Math::XYVector& tmp = nominalPos2DAtZ(z);
53 return ROOT::Math::XYZVector(tmp.X(), tmp.Y(), z);
54 }
55
57 ROOT::Math::XYVector nominalPos2DAtZ(const double z) const
58 { return refPos2D() + nominalMovePerZ() * z; }
59
61 ROOT::Math::XYZVector sagPos3DAtZ(const double z) const
62 {
63 const ROOT::Math::XYVector& tmp = sagPos2DAtZ(z);
64 return ROOT::Math::XYZVector(tmp.X(), tmp.Y(), z);
65 }
66
68 ROOT::Math::XYVector sagPos2DAtZ(const double z) const
69 {
71 ROOT::Math::XYVector pos2D = nominalPos2DAtZ(z);
72 double xzFactorSquared = 1 + nominalMovePerZ().X() * nominalMovePerZ().X();
73 double sagY = - sagCoeff() * xzFactorSquared * (forwardZ() - z) * (z - backwardZ());
74 pos2D.SetY(pos2D.Y() + sagY);
75 return pos2D;
76 }
77
79 const ROOT::Math::XYVector& nominalMovePerZ() const
80 { return m_nominalMovePerZ; }
81
83 ROOT::Math::XYVector sagMovePerZ(const double z) const
84 {
86 ROOT::Math::XYVector movePerZ = nominalMovePerZ();
87 double xzFactorSquared = 1 + nominalMovePerZ().X() * nominalMovePerZ().X();
88 double sagDYDZ = - sagCoeff() * xzFactorSquared * (forwardZ() + backwardZ() - 2 * z);
89 movePerZ.SetY(movePerZ.Y() + sagDYDZ);
90 return movePerZ;
91 }
92
94 double nominalDistance(const ROOT::Math::XYZVector& pos3D) const
95 {
96 return ROOT::Math::VectorUtil::Perp((pos3D - refPos3D()), ROOT::Math::XYZVector(nominalMovePerZ().X(), nominalMovePerZ().Y(), 1));
97 }
98
100 double sagDistance(const ROOT::Math::XYZVector& pos3D) const
101 {
102 const ROOT::Math::XYZVector& wirePos3D = sagPos3DAtZ(pos3D.z());
103 const ROOT::Math::XYVector& tmp = sagMovePerZ(pos3D.z());
104 const ROOT::Math::XYZVector movePerZ(tmp.X(), tmp.Y(), 1);
105 return ROOT::Math::VectorUtil::Perp((pos3D - wirePos3D), movePerZ);
106 }
107
109 ROOT::Math::XYZVector nominalClosest3D(const ROOT::Math::XYZVector& point) const
110 {
111 return refPos3D() - ROOT::Math::VectorUtil::ProjVector((point - refPos3D()), ROOT::Math::XYZVector(nominalMovePerZ().X(),
112 nominalMovePerZ().Y(), 1));
113 }
114
116 ROOT::Math::XYZVector sagClosest3D(const ROOT::Math::XYZVector& point) const
117 {
118 const ROOT::Math::XYZVector& wirePos3D = sagPos3DAtZ(point.z());
119 const ROOT::Math::XYVector& tmp = sagMovePerZ(point.z());
120 const ROOT::Math::XYZVector movePerZ(tmp.X(), tmp.Y(), 1);
121 return wirePos3D - ROOT::Math::VectorUtil::ProjVector((point - wirePos3D), movePerZ);
122 }
123
125 ROOT::Math::XYZVector forward3D() const
126 { return nominalPos3DAtZ(forwardZ()); }
127
129 ROOT::Math::XYVector forward2D() const
130 { return nominalPos2DAtZ(forwardZ()); }
131
133 ROOT::Math::XYZVector backward3D() const
134 { return nominalPos3DAtZ(backwardZ()); }
135
137 ROOT::Math::XYVector backward2D() const
138 { return nominalPos2DAtZ(backwardZ()); }
139
141 ROOT::Math::XYZVector wireVector() const
142 {
143 const ROOT::Math::XYVector& tmp = nominalMovePerZ() * deltaZ();
144 return ROOT::Math::XYZVector(tmp.X(), tmp.Y(), deltaZ());
145 }
146
148 double forwardZ() const
149 { return m_forwardZ; }
150
152 double backwardZ() const
153 { return m_backwardZ; }
154
156 double deltaZ() const
157 { return forwardZ() - backwardZ(); }
158
160 double outOfZBoundsFactor(double z) const
161 { return std::fmax(backwardZ() - z, z - forwardZ()) / deltaZ(); }
162
164 double forwardPhi() const
165 { return forward2D().Phi(); }
166
168 double backwardPhi() const
169 { return backward2D().Phi(); }
170
172 double forwardCylindricalR() const
173 { return forward2D().R(); }
174
176 double backwardCylindricalR() const
177 { return backward2D().R(); }
178
180 double forwardPhiToRef() const
181 { return VectorUtil::Angle(forward2D(), refPos2D()); }
182
184 double backwardPhiToRef() const
185 { return VectorUtil::Angle(backward2D(), refPos2D()); }
186
188 /* backwardToForwardAngle means how far the backward position has to be rotated in the xy projection
189 in the mathematical positive sense that it seems to be coaligned with the forward position. */
191 { return VectorUtil::Angle(backward2D(), forward2D()); }
192
194 double tanLambda() const
195 { return 1 / nominalMovePerZ().R(); }
196
198 double lambda() const
199 { return std::atan(tanLambda()); }
200
205 double tanTheta() const
206 { return std::atan(nominalMovePerZ().R()); }
207
209 double theta() const
210 { return std::atan(nominalMovePerZ().R()); }
211
213 double nominalPerigeeZ() const
214 { return -refPos2D().Dot(nominalMovePerZ()) / nominalMovePerZ().Mag2(); }
215
217 ROOT::Math::XYZVector nominalPerigee3D() const
218 { return nominalPos3DAtZ(nominalPerigeeZ()); }
219
221 ROOT::Math::XYVector nominalPerigee2D() const
222 { return VectorUtil::orthogonalVector(refPos2D(), nominalMovePerZ()); }
223
225 double refX() const
226 { return m_refPos3D.x(); }
227
229 double refY() const
230 { return m_refPos3D.y(); }
231
233 double refZ() const
234 { return m_refPos3D.z(); }
235
238 { return m_refPos3D.Perp2(); }
239
241 const ROOT::Math::XYVector& refPos2D() const
242 { return m_refPos2D; }
243
245 const ROOT::Math::XYZVector& refPos3D() const
246 { return m_refPos3D; }
247
249 double sagCoeff() const
250 { return m_sagCoeff; }
251
252 private:
254 ROOT::Math::XYZVector m_refPos3D;
255
257 ROOT::Math::XYVector m_refPos2D;
258
260 ROOT::Math::XYVector m_nominalMovePerZ;
261
263 double m_forwardZ = 0.0;
264
266 double m_backwardZ = 0.0;
267
269 double m_sagCoeff = 0.0;
270
271 };
272 }
274}
double R
typedef autogenerated by FFTW
A three dimensional limited line represented by its closest approach to the z-axes (reference positio...
Definition WireLine.h:33
const ROOT::Math::XYVector & nominalMovePerZ() const
Gives the positional move in the xy projection per unit z.
Definition WireLine.h:79
double refX() const
Returns the the x coordinate of the reference point.
Definition WireLine.h:225
ROOT::Math::XYZVector wireVector() const
Getter for the vector from backward to the forward position.
Definition WireLine.h:141
ROOT::Math::XYZVector nominalPos3DAtZ(const double z) const
Gives the three dimensional position without wire sag effect of the line at the given z value.
Definition WireLine.h:50
double forwardPhiToRef() const
Gives the azimuth angle of the forward position relative to the reference position.
Definition WireLine.h:180
ROOT::Math::XYZVector backward3D() const
Gives the position of the backward point.
Definition WireLine.h:133
double m_backwardZ
Memory for the backward end z coordinate.
Definition WireLine.h:266
ROOT::Math::XYZVector m_refPos3D
Memory for the reference position.
Definition WireLine.h:254
double lambda() const
Returns the nominal lambda angle of the line.
Definition WireLine.h:198
double refCylindricalRSquared() const
Returns the cylindrical radius of the reference position.
Definition WireLine.h:237
double sagDistance(const ROOT::Math::XYZVector &pos3D) const
Calculates the distance of the given point to the wire with wire sag effect.
Definition WireLine.h:100
double backwardCylindricalR() const
Gives the cylindrical radius of the backward position.
Definition WireLine.h:176
ROOT::Math::XYVector sagPos2DAtZ(const double z) const
Gives the two dimensional position with wire sag effect of the line at the given z value.
Definition WireLine.h:68
double backwardPhiToRef() const
Gives the azimuth angle of the backward position relative to the reference position.
Definition WireLine.h:184
WireLine()
Default constructor initialising to all members to zero.
Definition WireLine.h:37
double backwardZ() const
Gives the backward z coordinate.
Definition WireLine.h:152
ROOT::Math::XYZVector nominalPerigee3D() const
Returns the point of nominal closest approach to the z axes.
Definition WireLine.h:217
double forwardPhi() const
Gives the forward azimuth angle.
Definition WireLine.h:164
double refZ() const
Returns the the z coordinate of the reference point.
Definition WireLine.h:233
double backwardToForwardAngle() const
Gives the azimuth angle difference from backward to forward position.
Definition WireLine.h:190
ROOT::Math::XYZVector forward3D() const
Gives the position of the forward point.
Definition WireLine.h:125
double tanTheta() const
Returns the tangent of the opening angle between tangential vector and the z axes Also know as ds / d...
Definition WireLine.h:205
ROOT::Math::XYZVector sagPos3DAtZ(const double z) const
Gives the three dimensional position with wire sag effect of the line at the given z value.
Definition WireLine.h:61
double forwardZ() const
Gives the forward z coordinate.
Definition WireLine.h:148
double deltaZ() const
Returns the difference between forward and backward z.
Definition WireLine.h:156
double tanLambda() const
Returns the nominal tan lambda of the line. Also know as dz / ds.
Definition WireLine.h:194
ROOT::Math::XYVector sagMovePerZ(const double z) const
Gives the two dimensional position with wire sag effect of the line at the given z value.
Definition WireLine.h:83
ROOT::Math::XYVector forward2D() const
Gives the xy position of the forward point.
Definition WireLine.h:129
ROOT::Math::XYVector nominalPos2DAtZ(const double z) const
Gives the two dimensional position without wire sag effect of the line at the given z value.
Definition WireLine.h:57
double nominalPerigeeZ() const
Returns the z coordinate of the point of nominal closest approach to the z axes.
Definition WireLine.h:213
double forwardCylindricalR() const
Gives the cylindrical radius of the forward position.
Definition WireLine.h:172
WireLine movedBy(const ROOT::Math::XYZVector &offset) const
Returns a copy of the wire line moved by a three dimensional offset.
Definition WireLine.cc:30
double outOfZBoundsFactor(double z) const
Returns the amount how much the given z position is outside the bounds in units of the wire length.
Definition WireLine.h:160
double sagCoeff() const
Returns the wire sag coefficient due to gravity.
Definition WireLine.h:249
ROOT::Math::XYZVector nominalClosest3D(const ROOT::Math::XYZVector &point) const
Returns the closest approach on the wire without wire sag effect to the give point.
Definition WireLine.h:109
ROOT::Math::XYVector m_refPos2D
Memory for the 2D reference position (to avoid [-Wreturn-stack-address] in refPos2D())
Definition WireLine.h:257
const ROOT::Math::XYVector & refPos2D() const
Returns the xy vector of the reference position.
Definition WireLine.h:241
ROOT::Math::XYVector m_nominalMovePerZ
Memory for the nominal movement of the xy position per z unit off the reference.
Definition WireLine.h:260
double m_forwardZ
Memory for the forward end z coordinate.
Definition WireLine.h:263
const ROOT::Math::XYZVector & refPos3D() const
Returns the reference position.
Definition WireLine.h:245
double nominalDistance(const ROOT::Math::XYZVector &pos3D) const
Calculates the distance of the given point to the wire without wire sag effect.
Definition WireLine.h:94
double refY() const
Returns the the y coordinate of the reference point.
Definition WireLine.h:229
ROOT::Math::XYZVector sagClosest3D(const ROOT::Math::XYZVector &point) const
Returns the closest approach on the wire with wire sag effect to the give point.
Definition WireLine.h:116
double m_sagCoeff
Memory for the wire sag coefficient.
Definition WireLine.h:269
ROOT::Math::XYVector backward2D() const
Gives the xy position of the backward point.
Definition WireLine.h:137
double theta() const
Returns the nominal opening angle between tangential vector and the z axes.
Definition WireLine.h:209
double backwardPhi() const
Gives the backward azimuth angle.
Definition WireLine.h:168
ROOT::Math::XYVector nominalPerigee2D() const
Returns the point of nominal closest approach to the z axes.
Definition WireLine.h:221
Abstract base class for different kinds of events.