Belle II Software  release-05-02-19
WireLine.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2012 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFindingCDC/geometry/Vector3D.h>
13 #include <tracking/trackFindingCDC/geometry/Vector2D.h>
14 
15 #include <cmath>
16 
17 namespace Belle2 {
22  namespace TrackFindingCDC {
33  class WireLine {
34 
35  public:
37  WireLine()
38  {}
39 
41  WireLine(const Vector3D& forward, const Vector3D& backward, double sagCoeff);
42 
44  WireLine movedBy(const Vector3D& offset) const;
45 
47  WireLine movedBy(const Vector2D& offset) const;
48 
50  Vector3D nominalPos3DAtZ(const double z) const
51  { return Vector3D(nominalPos2DAtZ(z), z); }
52 
54  Vector2D nominalPos2DAtZ(const double z) const
55  { return refPos2D() + nominalMovePerZ() * z; }
56 
58  Vector3D sagPos3DAtZ(const double z) const
59  { return Vector3D(sagPos2DAtZ(z), z); }
60 
62  Vector2D sagPos2DAtZ(const double z) const
63  {
65  Vector2D pos2D = nominalPos2DAtZ(z);
66  double xzFactorSquared = 1 + nominalMovePerZ().x() * nominalMovePerZ().x();
67  double sagY = - sagCoeff() * xzFactorSquared * (forwardZ() - z) * (z - backwardZ());
68  pos2D.setY(pos2D.y() + sagY);
69  return pos2D;
70  }
71 
73  const Vector2D& nominalMovePerZ() const
74  { return m_nominalMovePerZ; }
75 
77  Vector2D sagMovePerZ(const double z) const
78  {
80  Vector2D movePerZ = nominalMovePerZ();
81  double xzFactorSquared = 1 + nominalMovePerZ().x() * nominalMovePerZ().x();
82  double sagDYDZ = - sagCoeff() * xzFactorSquared * (forwardZ() + backwardZ() - 2 * z);
83  movePerZ.setY(movePerZ.y() + sagDYDZ);
84  return movePerZ;
85  }
86 
88  double nominalDistance(const Vector3D& pos3D) const
89  { return (pos3D - refPos3D()).orthogonalComp(Vector3D(nominalMovePerZ(), 1)); }
90 
92  double sagDistance(const Vector3D& pos3D) const
93  {
94  Vector3D wirePos3D = sagPos3DAtZ(pos3D.z());
95  Vector3D movePerZ(sagMovePerZ(pos3D.z()), 1);
96  return (pos3D - wirePos3D).orthogonalComp(movePerZ);
97  }
98 
100  Vector3D nominalClosest3D(const Vector3D& point) const
101  { return refPos3D() - (point - refPos3D()).parallelVector(Vector3D(nominalMovePerZ(), 1)); }
102 
104  Vector3D sagClosest3D(const Vector3D& point) const
105  {
106  Vector3D wirePos3D = sagPos3DAtZ(point.z());
107  Vector3D movePerZ(sagMovePerZ(point.z()), 1);
108  return wirePos3D - (point - wirePos3D).parallelVector(movePerZ);
109  }
110 
113  { return nominalPos3DAtZ(forwardZ()); }
114 
116  Vector2D forward2D() const
117  { return nominalPos2DAtZ(forwardZ()); }
118 
121  { return nominalPos3DAtZ(backwardZ()); }
122 
125  { return nominalPos2DAtZ(backwardZ()); }
126 
129  { return Vector3D(nominalMovePerZ() * deltaZ(), deltaZ()); }
130 
132  double forwardZ() const
133  { return m_forwardZ; }
134 
136  double backwardZ() const
137  { return m_backwardZ; }
138 
140  double deltaZ() const
141  { return forwardZ() - backwardZ(); }
142 
144  double outOfZBoundsFactor(double z) const
145  { return std::fmax(backwardZ() - z, z - forwardZ()) / deltaZ(); }
146 
148  double forwardPhi() const
149  { return forward2D().phi(); }
150 
152  double backwardPhi() const
153  { return backward2D().phi(); }
154 
156  double forwardCylindricalR() const
157  { return forward2D().cylindricalR(); }
158 
160  double backwardCylindricalR() const
161  { return backward2D().cylindricalR(); }
162 
164  double forwardPhiToRef() const
165  { return forward2D().angleWith(refPos2D()); }
166 
168  double backwardPhiToRef() const
169  { return backward2D().angleWith(refPos2D()); }
170 
172  /* backwardToForwardAngle means how far the backward position has to be rotated in the xy projection
173  in the mathematical positiv sense that it seems to be coaligned with the forward position. */
174  double backwardToForwardAngle() const
175  { return backward2D().angleWith(forward2D()) ; }
176 
178  double tanLambda() const
179  { return 1 / nominalMovePerZ().norm(); }
180 
182  double lambda() const
183  { return std::atan(tanLambda()); }
184 
189  double tanTheta() const
190  { return std::atan(nominalMovePerZ().norm()); }
191 
193  double theta() const
194  { return std::atan(nominalMovePerZ().norm()); }
195 
197  double nominalPerigeeZ() const
198  { return -refPos2D().dot(nominalMovePerZ()) / nominalMovePerZ().normSquared(); }
199 
202  { return nominalPos3DAtZ(nominalPerigeeZ()); }
203 
206  { return refPos2D().orthogonalVector(nominalMovePerZ()); }
207 
209  double refX() const
210  { return m_refPos3D.x(); }
211 
213  double refY() const
214  { return m_refPos3D.y(); }
215 
217  double refZ() const
218  { return m_refPos3D.z(); }
219 
221  double refCylindricalRSquared() const
222  { return m_refPos3D.cylindricalRSquared(); }
223 
225  const Vector2D& refPos2D() const
226  { return m_refPos3D.xy(); }
227 
229  const Vector3D& refPos3D() const
230  { return m_refPos3D; }
231 
233  double sagCoeff() const
234  { return m_sagCoeff; }
235 
236  private:
239 
242 
244  double m_forwardZ = 0.0;
245 
247  double m_backwardZ = 0.0;
248 
250  double m_sagCoeff = 0.0;
251 
252  };
253  }
255 }
Belle2::TrackFindingCDC::WireLine::sagClosest3D
Vector3D sagClosest3D(const Vector3D &point) const
Returns the closest approach on the wire with wire sag effect to the give point.
Definition: WireLine.h:112
Belle2::TrackFindingCDC::WireLine::sagCoeff
double sagCoeff() const
Returns the wire sag coefficient due to gravity.
Definition: WireLine.h:241
Belle2::TrackFindingCDC::WireLine::nominalPos2DAtZ
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:62
Belle2::TrackFindingCDC::WireLine::m_sagCoeff
double m_sagCoeff
Memory for the wire sag coeffiecent.
Definition: WireLine.h:258
Belle2::TrackFindingCDC::WireLine::theta
double theta() const
Returns the nominal opening angle between tangential vector and the z axes.
Definition: WireLine.h:201
Belle2::Vector3D
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition: Cell.h:35
Belle2::TrackFindingCDC::WireLine::nominalPerigee2D
Vector2D nominalPerigee2D() const
Returns the point of nominal closest approach to the z axes.
Definition: WireLine.h:213
Belle2::TrackFindingCDC::WireLine::forwardPhi
double forwardPhi() const
Gives the forward azimuth angle.
Definition: WireLine.h:156
Belle2::TrackFindingCDC::Vector2D::setY
void setY(const double y)
Setter for the y coordinate.
Definition: Vector2D.h:624
Belle2::TrackFindingCDC::Vector2D
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:37
Belle2::TrackFindingCDC::WireLine::wireVector
Vector3D wireVector() const
Getter for the vector from backward to the forward position.
Definition: WireLine.h:136
Belle2::TrackFindingCDC::WireLine::refY
double refY() const
Returns the the y coordinate of the reference point.
Definition: WireLine.h:221
Belle2::TrackFindingCDC::WireLine::sagMovePerZ
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:85
Belle2::TrackFindingCDC::WireLine::sagPos2DAtZ
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:70
Belle2::TrackFindingCDC::Vector2D::normSquared
double normSquared() const
Calculates .
Definition: Vector2D.h:183
Belle2::TrackFindingCDC::WireLine::backwardPhiToRef
double backwardPhiToRef() const
Gives the azimuth angle of the backward position relative to the reference position.
Definition: WireLine.h:176
Belle2::TrackFindingCDC::Vector2D::y
double y() const
Getter for the y coordinate.
Definition: Vector2D.h:619
Belle2::TrackFindingCDC::WireLine::nominalPerigeeZ
double nominalPerigeeZ() const
Returns the z coordinate of the point of nominal closest approach to the z axes.
Definition: WireLine.h:205
Belle2::TrackFindingCDC::WireLine::forward3D
Vector3D forward3D() const
Gives the position of the forward point.
Definition: WireLine.h:120
Belle2::TrackFindingCDC::WireLine::nominalPos3DAtZ
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:58
Belle2::TrackFindingCDC::Vector3D::x
double x() const
Getter for the x coordinate.
Definition: Vector3D.h:464
Belle2::TrackFindingCDC::WireLine::forwardCylindricalR
double forwardCylindricalR() const
Gives the cylindrical radius of the forward position.
Definition: WireLine.h:164
Belle2::TrackFindingCDC::Vector2D::phi
double phi() const
Gives the azimuth angle being the angle to the x axes ( range -M_PI to M_PI )
Definition: Vector2D.h:583
Belle2::TrackFindingCDC::WireLine::m_refPos3D
Vector3D m_refPos3D
Memory for the reference postion.
Definition: WireLine.h:246
Belle2::TrackFindingCDC::WireLine::sagDistance
double sagDistance(const Vector3D &pos3D) const
Calculates the distance of the given point to the wire with wire sag effect.
Definition: WireLine.h:100
Belle2::TrackFindingCDC::Vector2D::dot
double dot(const Vector2D &rhs) const
Calculates the two dimensional dot product.
Definition: Vector2D.h:172
Belle2::TrackFindingCDC::Vector3D::cylindricalRSquared
double cylindricalRSquared() const
Getter for the squared cylindrical radius ( xy projected squared norm )
Definition: Vector3D.h:520
Belle2::TrackFindingCDC::WireLine::deltaZ
double deltaZ() const
Returns the difference between forward and backward z.
Definition: WireLine.h:148
Belle2::TrackFindingCDC::WireLine::forward2D
Vector2D forward2D() const
Gives the xy position of the forward point.
Definition: WireLine.h:124
Belle2::TrackFindingCDC::WireLine::refPos2D
const Vector2D & refPos2D() const
Returns the xy vector of the reference position.
Definition: WireLine.h:233
Belle2::TrackFindingCDC::WireLine::m_backwardZ
double m_backwardZ
Memory for the backward end z coordinate.
Definition: WireLine.h:255
Belle2::TrackFindingCDC::WireLine::refZ
double refZ() const
Returns the the z coordinate of the reference point.
Definition: WireLine.h:225
Belle2::TrackFindingCDC::WireLine::backwardCylindricalR
double backwardCylindricalR() const
Gives the cylindrical radius of the backward position.
Definition: WireLine.h:168
Belle2::TrackFindingCDC::WireLine::backward2D
Vector2D backward2D() const
Gives the xy position of the backward point.
Definition: WireLine.h:132
Belle2::TrackFindingCDC::WireLine::sagPos3DAtZ
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:66
Belle2::TrackFindingCDC::Vector2D::orthogonalVector
Vector2D orthogonalVector(const Vector2D &relativTo) const
Calculates the part of this vector that is parallel to the given vector.
Definition: Vector2D.h:452
Belle2::TrackFindingCDC::WireLine::m_nominalMovePerZ
Vector2D m_nominalMovePerZ
Memory for the nominal movement of the xy position per z unit off the reference.
Definition: WireLine.h:249
Belle2::TrackFindingCDC::WireLine::forwardPhiToRef
double forwardPhiToRef() const
Gives the azimuth angle of the forward position relative to the reference position.
Definition: WireLine.h:172
Belle2::TrackFindingCDC::WireLine::nominalPerigee3D
Vector3D nominalPerigee3D() const
Returns the point of nominal closest approach to the z axes.
Definition: WireLine.h:209
Belle2::TrackFindingCDC::WireLine::lambda
double lambda() const
Returns the nominal lambda angle of the line.
Definition: WireLine.h:190
Belle2::TrackFindingCDC::WireLine::tanLambda
double tanLambda() const
Returns the nominal tan lambda of the line. Also know as dz / ds.
Definition: WireLine.h:186
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::WireLine
A three dimensional limited line represented by its closest approach to the z-axes (reference positio...
Definition: WireLine.h:41
Belle2::TrackFindingCDC::Vector3D
A three dimensional vector.
Definition: Vector3D.h:34
Belle2::TrackFindingCDC::Vector2D::cylindricalR
double cylindricalR() const
Gives the cylindrical radius of the vector. Same as norm()
Definition: Vector2D.h:571
Belle2::TrackFindingCDC::WireLine::WireLine
WireLine()
Default constructor initialising to all members to zero.
Definition: WireLine.h:45
Belle2::TrackFindingCDC::WireLine::refPos3D
const Vector3D & refPos3D() const
Returns the reference position.
Definition: WireLine.h:237
Belle2::TrackFindingCDC::Vector3D::y
double y() const
Getter for the y coordinate.
Definition: Vector3D.h:476
Belle2::TrackFindingCDC::WireLine::tanTheta
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:197
Belle2::TrackFindingCDC::WireLine::nominalMovePerZ
const Vector2D & nominalMovePerZ() const
Gives the positional move in the xy projection per unit z.
Definition: WireLine.h:81
Belle2::TrackFindingCDC::Vector3D::xy
const Vector2D & xy() const
Getter for the xy projected vector ( reference ! )
Definition: Vector3D.h:500
Belle2::TrackFindingCDC::WireLine::backward3D
Vector3D backward3D() const
Gives the position of the backward point.
Definition: WireLine.h:128
Belle2::TrackFindingCDC::Vector2D::x
double x() const
Getter for the x coordinate.
Definition: Vector2D.h:609
Belle2::TrackFindingCDC::WireLine::forwardZ
double forwardZ() const
Gives the forward z coodinate.
Definition: WireLine.h:140
Belle2::TrackFindingCDC::WireLine::nominalClosest3D
Vector3D nominalClosest3D(const Vector3D &point) const
Returns the closest approach on the wire without wire sag effect to the give point.
Definition: WireLine.h:108
Belle2::TrackFindingCDC::WireLine::outOfZBoundsFactor
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:152
Belle2::TrackFindingCDC::Vector2D::norm
double norm() const
Calculates the length of the vector.
Definition: Vector2D.h:189
Belle2::TrackFindingCDC::WireLine::backwardZ
double backwardZ() const
Gives the backward z coodinate.
Definition: WireLine.h:144
Belle2::TrackFindingCDC::WireLine::refX
double refX() const
Returns the the x coordinate of the reference point.
Definition: WireLine.h:217
Belle2::TrackFindingCDC::WireLine::backwardToForwardAngle
double backwardToForwardAngle() const
Gives the azimuth angle difference from backward to forward position.
Definition: WireLine.h:182
Belle2::TrackFindingCDC::Vector2D::angleWith
double angleWith(const Vector2D &rhs) const
The angle between this and rhs.
Definition: Vector2D.h:211
Belle2::TrackFindingCDC::Vector3D::z
double z() const
Getter for the z coordinate.
Definition: Vector3D.h:488
Belle2::TrackFindingCDC::WireLine::m_forwardZ
double m_forwardZ
Memory for the forward end z coordinate.
Definition: WireLine.h:252
Belle2::TrackFindingCDC::WireLine::movedBy
WireLine movedBy(const Vector3D &offset) const
Returns a copy of the wire line moved by a three dimensional offset.
Definition: WireLine.cc:29
Belle2::TrackFindingCDC::WireLine::backwardPhi
double backwardPhi() const
Gives the backward azimuth angle.
Definition: WireLine.h:160
Belle2::TrackFindingCDC::WireLine::refCylindricalRSquared
double refCylindricalRSquared() const
Returns the cylindrical radius of the reference position.
Definition: WireLine.h:229
Belle2::TrackFindingCDC::WireLine::nominalDistance
double nominalDistance(const Vector3D &pos3D) const
Calculates the distance of the given point to the wire without wire sag effect.
Definition: WireLine.h:96