Belle II Software  release-08-01-10
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 <tracking/trackFindingCDC/geometry/Vector3D.h>
11 #include <tracking/trackFindingCDC/geometry/Vector2D.h>
12 
13 #include <cmath>
14 
15 namespace Belle2 {
20  namespace TrackFindingCDC {
31  class WireLine {
32 
33  public:
36  {}
37 
39  WireLine(const Vector3D& forward, const Vector3D& backward, double sagCoeff);
40 
42  WireLine movedBy(const Vector3D& offset) const;
43 
45  WireLine movedBy(const Vector2D& offset) const;
46 
48  Vector3D nominalPos3DAtZ(const double z) const
49  { return Vector3D(nominalPos2DAtZ(z), z); }
50 
52  Vector2D nominalPos2DAtZ(const double z) const
53  { return refPos2D() + nominalMovePerZ() * z; }
54 
56  Vector3D sagPos3DAtZ(const double z) const
57  { return Vector3D(sagPos2DAtZ(z), z); }
58 
60  Vector2D sagPos2DAtZ(const double z) const
61  {
63  Vector2D pos2D = nominalPos2DAtZ(z);
64  double xzFactorSquared = 1 + nominalMovePerZ().x() * nominalMovePerZ().x();
65  double sagY = - sagCoeff() * xzFactorSquared * (forwardZ() - z) * (z - backwardZ());
66  pos2D.setY(pos2D.y() + sagY);
67  return pos2D;
68  }
69 
71  const Vector2D& nominalMovePerZ() const
72  { return m_nominalMovePerZ; }
73 
75  Vector2D sagMovePerZ(const double z) const
76  {
78  Vector2D movePerZ = nominalMovePerZ();
79  double xzFactorSquared = 1 + nominalMovePerZ().x() * nominalMovePerZ().x();
80  double sagDYDZ = - sagCoeff() * xzFactorSquared * (forwardZ() + backwardZ() - 2 * z);
81  movePerZ.setY(movePerZ.y() + sagDYDZ);
82  return movePerZ;
83  }
84 
86  double nominalDistance(const Vector3D& pos3D) const
87  { return (pos3D - refPos3D()).orthogonalComp(Vector3D(nominalMovePerZ(), 1)); }
88 
90  double sagDistance(const Vector3D& pos3D) const
91  {
92  Vector3D wirePos3D = sagPos3DAtZ(pos3D.z());
93  Vector3D movePerZ(sagMovePerZ(pos3D.z()), 1);
94  return (pos3D - wirePos3D).orthogonalComp(movePerZ);
95  }
96 
98  Vector3D nominalClosest3D(const Vector3D& point) const
99  { return refPos3D() - (point - refPos3D()).parallelVector(Vector3D(nominalMovePerZ(), 1)); }
100 
102  Vector3D sagClosest3D(const Vector3D& point) const
103  {
104  Vector3D wirePos3D = sagPos3DAtZ(point.z());
105  Vector3D movePerZ(sagMovePerZ(point.z()), 1);
106  return wirePos3D - (point - wirePos3D).parallelVector(movePerZ);
107  }
108 
111  { return nominalPos3DAtZ(forwardZ()); }
112 
115  { return nominalPos2DAtZ(forwardZ()); }
116 
119  { return nominalPos3DAtZ(backwardZ()); }
120 
123  { return nominalPos2DAtZ(backwardZ()); }
124 
127  { return Vector3D(nominalMovePerZ() * deltaZ(), deltaZ()); }
128 
130  double forwardZ() const
131  { return m_forwardZ; }
132 
134  double backwardZ() const
135  { return m_backwardZ; }
136 
138  double deltaZ() const
139  { return forwardZ() - backwardZ(); }
140 
142  double outOfZBoundsFactor(double z) const
143  { return std::fmax(backwardZ() - z, z - forwardZ()) / deltaZ(); }
144 
146  double forwardPhi() const
147  { return forward2D().phi(); }
148 
150  double backwardPhi() const
151  { return backward2D().phi(); }
152 
154  double forwardCylindricalR() const
155  { return forward2D().cylindricalR(); }
156 
158  double backwardCylindricalR() const
159  { return backward2D().cylindricalR(); }
160 
162  double forwardPhiToRef() const
163  { return forward2D().angleWith(refPos2D()); }
164 
166  double backwardPhiToRef() const
167  { return backward2D().angleWith(refPos2D()); }
168 
170  /* backwardToForwardAngle means how far the backward position has to be rotated in the xy projection
171  in the mathematical positiv sense that it seems to be coaligned with the forward position. */
172  double backwardToForwardAngle() const
173  { return backward2D().angleWith(forward2D()) ; }
174 
176  double tanLambda() const
177  { return 1 / nominalMovePerZ().norm(); }
178 
180  double lambda() const
181  { return std::atan(tanLambda()); }
182 
187  double tanTheta() const
188  { return std::atan(nominalMovePerZ().norm()); }
189 
191  double theta() const
192  { return std::atan(nominalMovePerZ().norm()); }
193 
195  double nominalPerigeeZ() const
196  { return -refPos2D().dot(nominalMovePerZ()) / nominalMovePerZ().normSquared(); }
197 
200  { return nominalPos3DAtZ(nominalPerigeeZ()); }
201 
204  { return refPos2D().orthogonalVector(nominalMovePerZ()); }
205 
207  double refX() const
208  { return m_refPos3D.x(); }
209 
211  double refY() const
212  { return m_refPos3D.y(); }
213 
215  double refZ() const
216  { return m_refPos3D.z(); }
217 
219  double refCylindricalRSquared() const
220  { return m_refPos3D.cylindricalRSquared(); }
221 
223  const Vector2D& refPos2D() const
224  { return m_refPos3D.xy(); }
225 
227  const Vector3D& refPos3D() const
228  { return m_refPos3D; }
229 
231  double sagCoeff() const
232  { return m_sagCoeff; }
233 
234  private:
237 
240 
242  double m_forwardZ = 0.0;
243 
245  double m_backwardZ = 0.0;
246 
248  double m_sagCoeff = 0.0;
249 
250  };
251  }
253 }
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:35
double dot(const Vector2D &rhs) const
Calculates the two dimensional dot product.
Definition: Vector2D.h:170
double cylindricalR() const
Gives the cylindrical radius of the vector. Same as norm()
Definition: Vector2D.h:569
Vector2D orthogonalVector(const Vector2D &relativTo) const
Calculates the part of this vector that is parallel to the given vector.
Definition: Vector2D.h:450
double x() const
Getter for the x coordinate.
Definition: Vector2D.h:607
double phi() const
Gives the azimuth angle being the angle to the x axes ( range -M_PI to M_PI )
Definition: Vector2D.h:581
double normSquared() const
Calculates .
Definition: Vector2D.h:181
void setY(const double y)
Setter for the y coordinate.
Definition: Vector2D.h:622
double y() const
Getter for the y coordinate.
Definition: Vector2D.h:617
double angleWith(const Vector2D &rhs) const
The angle between this and rhs.
Definition: Vector2D.h:209
double norm() const
Calculates the length of the vector.
Definition: Vector2D.h:187
A three dimensional vector.
Definition: Vector3D.h:33
double x() const
Getter for the x coordinate.
Definition: Vector3D.h:472
const Vector2D & xy() const
Getter for the xy projected vector ( reference ! )
Definition: Vector3D.h:508
double cylindricalRSquared() const
Getter for the squared cylindrical radius ( xy projected squared norm )
Definition: Vector3D.h:528
double y() const
Getter for the y coordinate.
Definition: Vector3D.h:484
double z() const
Getter for the z coordinate.
Definition: Vector3D.h:496
A three dimensional limited line represented by its closest approach to the z-axes (reference positio...
Definition: WireLine.h:31
Vector2D backward2D() const
Gives the xy position of the backward point.
Definition: WireLine.h:122
double refX() const
Returns the the x coordinate of the reference point.
Definition: WireLine.h:207
double forwardPhiToRef() const
Gives the azimuth angle of the forward position relative to the reference position.
Definition: WireLine.h:162
double m_backwardZ
Memory for the backward end z coordinate.
Definition: WireLine.h:245
Vector2D 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:75
Vector3D 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:48
Vector3D nominalPerigee3D() const
Returns the point of nominal closest approach to the z axes.
Definition: WireLine.h:199
double lambda() const
Returns the nominal lambda angle of the line.
Definition: WireLine.h:180
double refCylindricalRSquared() const
Returns the cylindrical radius of the reference position.
Definition: WireLine.h:219
double backwardCylindricalR() const
Gives the cylindrical radius of the backward position.
Definition: WireLine.h:158
double backwardPhiToRef() const
Gives the azimuth angle of the backward position relative to the reference position.
Definition: WireLine.h:166
WireLine()
Default constructor initialising to all members to zero.
Definition: WireLine.h:35
double backwardZ() const
Gives the backward z coodinate.
Definition: WireLine.h:134
double forwardPhi() const
Gives the forward azimuth angle.
Definition: WireLine.h:146
double refZ() const
Returns the the z coordinate of the reference point.
Definition: WireLine.h:215
double backwardToForwardAngle() const
Gives the azimuth angle difference from backward to forward position.
Definition: WireLine.h:172
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:187
double forwardZ() const
Gives the forward z coodinate.
Definition: WireLine.h:130
double deltaZ() const
Returns the difference between forward and backward z.
Definition: WireLine.h:138
double tanLambda() const
Returns the nominal tan lambda of the line. Also know as dz / ds.
Definition: WireLine.h:176
Vector2D nominalPerigee2D() const
Returns the point of nominal closest approach to the z axes.
Definition: WireLine.h:203
Vector2D m_nominalMovePerZ
Memory for the nominal movement of the xy position per z unit off the reference.
Definition: WireLine.h:239
Vector3D 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:56
Vector3D sagClosest3D(const Vector3D &point) const
Returns the closest approach on the wire with wire sag effect to the give point.
Definition: WireLine.h:102
double nominalPerigeeZ() const
Returns the z coordinate of the point of nominal closest approach to the z axes.
Definition: WireLine.h:195
Vector3D backward3D() const
Gives the position of the backward point.
Definition: WireLine.h:118
double forwardCylindricalR() const
Gives the cylindrical radius of the forward position.
Definition: WireLine.h:154
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:142
double sagCoeff() const
Returns the wire sag coefficient due to gravity.
Definition: WireLine.h:231
const Vector3D & refPos3D() const
Returns the reference position.
Definition: WireLine.h:227
Vector2D 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:60
double m_forwardZ
Memory for the forward end z coordinate.
Definition: WireLine.h:242
double sagDistance(const Vector3D &pos3D) const
Calculates the distance of the given point to the wire with wire sag effect.
Definition: WireLine.h:90
Vector3D wireVector() const
Getter for the vector from backward to the forward position.
Definition: WireLine.h:126
double nominalDistance(const Vector3D &pos3D) const
Calculates the distance of the given point to the wire without wire sag effect.
Definition: WireLine.h:86
double refY() const
Returns the the y coordinate of the reference point.
Definition: WireLine.h:211
Vector3D forward3D() const
Gives the position of the forward point.
Definition: WireLine.h:110
Vector3D nominalClosest3D(const Vector3D &point) const
Returns the closest approach on the wire without wire sag effect to the give point.
Definition: WireLine.h:98
WireLine movedBy(const Vector3D &offset) const
Returns a copy of the wire line moved by a three dimensional offset.
Definition: WireLine.cc:27
double m_sagCoeff
Memory for the wire sag coeffiecent.
Definition: WireLine.h:248
const Vector2D & refPos2D() const
Returns the xy vector of the reference position.
Definition: WireLine.h:223
Vector3D m_refPos3D
Memory for the reference postion.
Definition: WireLine.h:236
const Vector2D & nominalMovePerZ() const
Gives the positional move in the xy projection per unit z.
Definition: WireLine.h:71
double theta() const
Returns the nominal opening angle between tangential vector and the z axes.
Definition: WireLine.h:191
Vector2D forward2D() const
Gives the xy position of the forward point.
Definition: WireLine.h:114
Vector2D 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:52
double backwardPhi() const
Gives the backward azimuth angle.
Definition: WireLine.h:150
double atan(double a)
atan for double
Definition: beamHelpers.h:34
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition: Cell.h:34
Abstract base class for different kinds of events.