Belle II Software development
CDCTrajectory2D.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/topology/ISuperLayer.h>
11
12#include <tracking/trackFindingCDC/geometry/UncertainPerigeeCircle.h>
13#include <tracking/trackFindingCDC/geometry/PerigeeCircle.h>
14#include <tracking/trackFindingCDC/geometry/PerigeeParameters.h>
15#include <tracking/trackFindingCDC/geometry/Vector3D.h>
16#include <tracking/trackFindingCDC/geometry/Vector2D.h>
17
18#include <tracking/trackFindingCDC/numerics/EForwardBackward.h>
19#include <tracking/trackFindingCDC/numerics/ERightLeft.h>
20#include <tracking/trackFindingCDC/numerics/ESign.h>
21
22#include <TMath.h>
23#include <cmath>
24#include <cstddef>
25#include <iosfwd>
26
27namespace Belle2 {
32 namespace TrackFindingCDC {
33 class WireLine;
34
37
38 public:
41
47 explicit CDCTrajectory2D(const UncertainPerigeeCircle& perigeeCircle);
48
56 CDCTrajectory2D(const Vector2D& localOrigin,
57 const UncertainPerigeeCircle& localPerigeeCircle,
58 double flightTime = NAN);
59
64 CDCTrajectory2D(const Vector2D& pos2D,
65 double time,
66 const Vector2D& mom2D,
67 double charge,
68 double bZ);
69
72 CDCTrajectory2D(const Vector2D& pos2D, double time, const Vector2D& mom2D, double charge);
73
74 public:
76 bool isFitted() const;
77
79 void clear();
80
81 public:
83 void reverse();
84
87
88 public:
98 std::array<double, 2> reconstructBothZ(const WireLine& wireLine, double distance = 0.0, double z = 0) const;
99
110 double reconstructZ(const WireLine& wireLine, double distance = 0.0, double z = 0) const;
111
121 std::array<Vector3D, 2> reconstructBoth3D(const WireLine& wireLine, double distance = 0.0, double z = 0) const;
122
135 Vector3D reconstruct3D(const WireLine& wireLine, double distance = 0.0, double z = 0) const;
136
138 Vector2D getClosest(const Vector2D& point) const;
139
140 private:
145 ISuperLayer getISuperLayerAfter(ISuperLayer iSuperLayer, bool movingOutward) const;
146
151 ISuperLayer getISuperLayerAfterStart(bool movingOutward) const;
152
157 ISuperLayer getISuperLayerAfterStart(EForwardBackward forwardBackwardInfo) const;
158
164 ISuperLayer getAxialISuperLayerAfterStart(EForwardBackward forwardBackwardInfo) const;
165
166 public:
169 ISuperLayer getNextISuperLayer() const;
170
173 ISuperLayer getPreviousISuperLayer() const;
174
177 ISuperLayer getNextAxialISuperLayer() const;
178
181 ISuperLayer getPreviousAxialISuperLayer() const;
182
184 ISuperLayer getMaximalISuperLayer() const;
185
187 ISuperLayer getStartISuperLayer() const;
188
190 ISuperLayer getMinimalISuperLayer() const;
191
192 public:
199 template <class AHits>
201 {
202 return static_cast<EForwardBackward>(sign(getTotalArcLength2D(hits)));
203 }
204
209 template <class AFromHits, class AToHits>
210 double getArcLength2DGap(const AFromHits& fromHits, const AToHits& toHits) const
211 {
212 const Vector2D& fromRecoPos2D = fromHits.back().getRecoPos2D();
213 const Vector2D& toRecoPos2D = toHits.front().getRecoPos2D();
214 return calcArcLength2DBetween(fromRecoPos2D, toRecoPos2D);
215 }
216
221 template <class AFromHits, class AToHits>
222 double getArcLength2DFrontOffset(const AFromHits& fromHits, const AToHits& toHits) const
223 {
224 const Vector2D& fromRecoPos2D = fromHits.front().getRecoPos2D();
225 const Vector2D& toRecoPos2D = toHits.front().getRecoPos2D();
226 return calcArcLength2DBetween(fromRecoPos2D, toRecoPos2D);
227 }
228
233 template <class AFromHits, class AToHits>
234 double getArcLength2DBackOffset(const AFromHits& fromHits, const AToHits& toHits) const
235 {
236 const Vector2D& fromRecoPos2D = fromHits.back().getRecoPos2D();
237 const Vector2D& toRecoPos2D = toHits.back().getRecoPos2D();
238 return calcArcLength2DBetween(fromRecoPos2D, toRecoPos2D);
239 }
240
243 template <class AHits>
244 double getTotalArcLength2D(const AHits& hits) const
245 {
246 Vector2D frontRecoPos2D = hits.front().getRecoPos2D();
247 Vector2D backRecoPos2D = hits.back().getRecoPos2D();
248 return calcArcLength2DBetween(frontRecoPos2D, backRecoPos2D);
249 }
250
260 double calcArcLength2D(const Vector2D& point) const
261 {
262 return getLocalCircle()->arcLengthBetween(Vector2D(0.0, 0.0), point - getLocalOrigin());
263 }
264
273 double calcArcLength2DBetween(const Vector2D& fromPoint, const Vector2D& toPoint) const
274 {
275 return getLocalCircle()->arcLengthBetween(fromPoint - getLocalOrigin(),
276 toPoint - getLocalOrigin());
277 }
279 double getArcLength2DPeriod() const
280 {
282 }
283
284 public:
286 void setPosMom2D(const Vector2D& pos2D, const Vector2D& mom2D, double charge);
287
289 ESign getChargeSign() const;
290
292 double getAbsMom2D(double bZ) const;
293
295 double getAbsMom2D() const;
296
298 Vector2D getMom2DAtSupport(const double bZ) const
299 {
301 }
302
305 {
307 }
308
311 {
312 return getLocalCircle()->tangential(point - getLocalOrigin());
313 }
314
317 {
318 return getLocalCircle()->tangential();
319 }
320
323 bool isMovingOutward() const
324 {
326 }
327
329 Vector2D getPos2DAtArcLength2D(double arcLength2D)
330 {
331 return getLocalOrigin() + getLocalCircle()->atArcLength(arcLength2D);
332 }
333
336 {
337 return getLocalCircle()->perigee() + getLocalOrigin();
338 }
339
342 {
344 }
345
348 {
349 return getLocalCircle()->center() + m_localOrigin;
350 }
351
360 Vector2D getOuterExit(double factor = 1) const;
361
369 Vector2D getInnerExit() const;
370
379 Vector2D getExit() const;
380
383 bool isCurler(double factor = 1) const;
384
387 bool isOriginer(double factor = 1) const;
388
391 {
392 return std::fabs(getGlobalImpact() + 2 * getLocalCircle()->radius());
393 }
394
398 {
399 return std::fabs(getGlobalImpact());
400 }
401
403 double getGlobalImpact() const
404 {
406 }
407
409 double getDist2D(const Vector2D& point) const
410 {
411 return getLocalCircle()->distance(point - getLocalOrigin());
412 }
413
416 {
417 return getLocalCircle()->isRightOrLeft(point - getLocalOrigin());
418 }
419
420 public:
422 double getCurvature() const
423 {
424 return getLocalCircle()->curvature();
425 }
426
429 {
430 return getLocalCircle().covariance(iRow, iCol);
431 }
432
436 {
437 return getLocalCircle().variance(i);
438 }
439
442 {
443 PerigeeCircle result = getLocalCircle();
444 result.passiveMoveBy(-getLocalOrigin());
445 return result;
446 }
447
449 void setGlobalCircle(const UncertainPerigeeCircle& perigeeCircle)
450 {
451 m_localPerigeeCircle = perigeeCircle;
453 }
454
457 {
459 }
460
462 double getPValue() const
463 {
464 return TMath::Prob(getChi2(), getNDF());
465 }
466
468 double getChi2() const
469 {
470 return getLocalCircle().chi2();
471 }
472
474 void setChi2(const double chi2)
475 {
476 return m_localPerigeeCircle.setChi2(chi2);
477 }
478
480 size_t getNDF() const
481 {
482 return getLocalCircle().ndf();
483 }
484
486 void setNDF(std::size_t ndf)
487 {
488 return m_localPerigeeCircle.setNDF(ndf);
489 }
490
492 void setLocalCircle(const UncertainPerigeeCircle& localPerigeeCircle)
493 {
494 m_localPerigeeCircle = localPerigeeCircle;
495 }
496
499 {
500 return m_localOrigin;
501 }
502
519 double setLocalOrigin(const Vector2D& localOrigin);
520
522 double getFlightTime() const
523 {
524 return m_flightTime;
525 }
526
528 void setFlightTime(double flightTime)
529 {
530 m_flightTime = flightTime;
531 }
532
533 private:
536
539
541 double m_flightTime = NAN;
542 };
543
545 std::ostream& operator<<(std::ostream& output, const CDCTrajectory2D& trajectory2D);
546 }
548}
Particle trajectory as it is seen in xy projection represented as a circle.
double getTotalArcLength2D(const AHits &hits) const
Calculates the perpendicular travel distance from the first position of the hits to the last position...
void setPosMom2D(const Vector2D &pos2D, const Vector2D &mom2D, double charge)
Setter for start point and momentum at the start point subjected to the charge sign.
double getMaximalCylindricalR() const
Getter for the maximal distance from the origin.
CDCTrajectory2D reversed() const
Returns the reverse trajectory as a copy.
Vector2D getMom2DAtSupport(const double bZ) const
Get the momentum at the support point of the trajectory.
PerigeeCircle getGlobalCircle() const
Getter for the circle in global coordinates.
ISuperLayer getAxialISuperLayerAfterStart(EForwardBackward forwardBackwardInfo) const
Indicates which axial superlayer is traversed after the one, where the start point of the trajectory ...
Vector2D getOuterExit(double factor=1) const
Calculates the point where the trajectory meets the outer wall of the CDC.
double getGlobalImpact() const
Getter for the signed impact parameter of the trajectory.
ISuperLayer getISuperLayerAfter(ISuperLayer iSuperLayer, bool movingOutward) const
Returns which superlayer is traversed after the current one following the trajectory outward or inwar...
EForwardBackward isForwardOrBackwardTo(const AHits &hits) const
Calculates if this trajectory and the hits are coaligned Returns:
std::array< double, 2 > reconstructBothZ(const WireLine &wireLine, double distance=0.0, double z=0) const
Gives the two z positions where the given drift circle on the wire line touches the trajectory.
void reverse()
Reverses the trajectory in place.
bool isOriginer(double factor=1) const
Checks if the trajectory intersects with the inner radius of the CDC time the given tolerance factor.
ISuperLayer getStartISuperLayer() const
Indicates the superlayer the trajectory starts in.
double getFlightTime() const
Getter for the time when the particle reached the support point position.
Vector2D m_localOrigin
Memory for local coordinate origin of the circle representing the trajectory in global coordinates.
double setLocalOrigin(const Vector2D &localOrigin)
Setter for the origin of the local coordinate system.
void setLocalCircle(const UncertainPerigeeCircle &localPerigeeCircle)
Setter for the generalized circle that describes the trajectory.
double calcArcLength2D(const Vector2D &point) const
Calculate the travel distance from the start position of the trajectory.
ESign getChargeSign() const
Gets the charge sign of the trajectory.
ISuperLayer getISuperLayerAfterStart(bool movingOutward) const
Returns which superlayer is traversed after the current one following the trajectory outward or inwar...
double getChi2() const
Getter for the chi2 value of the circle fit.
double calcArcLength2DBetween(const Vector2D &fromPoint, const Vector2D &toPoint) const
Calculate the travel distance between the two given positions Returns the travel distance on the traj...
double getPValue() const
Getter for p-value.
ISuperLayer getPreviousISuperLayer() const
Indicates which superlayer the trajectory traverses before the one, where the start point of the traj...
bool isCurler(double factor=1) const
Checks if the trajectory leaves the outer radius of the CDC times the given tolerance factor.
Vector2D getPos2DAtArcLength2D(double arcLength2D)
Getter for the position at a given two dimensional arc length.
ISuperLayer getMinimalISuperLayer() const
Indicates the minimal superlayer the trajectory traverses.
void setGlobalCircle(const UncertainPerigeeCircle &perigeeCircle)
Setter for the generalized circle that describes the trajectory.
double reconstructZ(const WireLine &wireLine, double distance=0.0, double z=0) const
Gives the one z positions within the CDC closest to the given z where the given drift circle on the w...
bool isFitted() const
Checks if the circle is already set to a valid value.
double getLocalVariance(EPerigeeParameter i) const
Getter for an individual diagonal element of the covariance matrix of the local helix parameters.
double getLocalCovariance(EPerigeeParameter iRow, EPerigeeParameter iCol) const
Getter for an individual element of the covariance matrix of the local helix parameters.
Vector2D getSupport() const
Get the support point of the trajectory in global coordinates.
double getMinimalCylindricalR() const
Getter for the minimal distance from the origin - same as absolute value of the impact parameter.
const Vector2D & getLocalOrigin() const
Getter for the origin of the local coordinate system.
ISuperLayer getPreviousAxialISuperLayer() const
Indicates which axial superlayer the trajectory traverses before the one, where the start point of th...
double getArcLength2DGap(const AFromHits &fromHits, const AToHits &toHits) const
Calculates the perpendicular travel distance from the last position of the fromHits to the first posi...
std::array< Vector3D, 2 > reconstructBoth3D(const WireLine &wireLine, double distance=0.0, double z=0) const
Gives the two three dimensional points where the drift circle touches the wire line.
Vector2D getFlightDirection2DAtSupport() const
Get the unit direction of flight at the support point, where arcLength2D = 0.
double getArcLength2DPeriod() const
Getter for the arc length for one round trip around the trajectory.
ISuperLayer getMaximalISuperLayer() const
Indicates the maximal superlayer the trajectory traverses.
ERightLeft isRightOrLeft(const Vector2D &point) const
Checks if the given point is to the right or to the left of the trajectory.
Vector2D getClosest(const Vector2D &point) const
Calculates the closest approach on the trajectory to the given point.
Vector2D getExit() const
Calculates the point where the trajectory leaves the CDC.
void setNDF(std::size_t ndf)
Setter for the number of degrees of freedom of the circle fit.
double getAbsMom2D() const
Get the estimation for the absolute value of the transvers momentum.
const UncertainPerigeeCircle & getLocalCircle() const
Getter for the circle in local coordinates.
Vector2D getGlobalCenter() const
Getter for the center of the trajectory in global coordinates.
UncertainPerigeeCircle m_localPerigeeCircle
Memory for the generalized circle describing the trajectory in coordinates from the local origin.
double getArcLength2DBackOffset(const AFromHits &fromHits, const AToHits &toHits) const
Calculates the perpendicular travel distance from the last position of the fromHits to the last posit...
CDCTrajectory2D()
Default constructor for ROOT compatibility.
void clear()
Clears all information from this trajectory.
void setFlightTime(double flightTime)
Setter for the time when the particle reached the support point position.
Vector2D getFlightDirection2D(const Vector2D &point) const
Get the unit direction of flight at the given point, where arcLength2D = 0.
bool isMovingOutward() const
Indicates if the trajectory is moving outwards or inwards (to or away from the origin) from the start...
ISuperLayer getNextISuperLayer() const
Indicates which superlayer the trajectory traverses after the one, where the start point of the traje...
double getArcLength2DFrontOffset(const AFromHits &fromHits, const AToHits &toHits) const
Calculates the perpendicular travel distance from the first position of the fromHits to the first pos...
ISuperLayer getNextAxialISuperLayer() const
Indicates which axial superlayer the trajectory traverses after the one, where the start point of the...
void setChi2(const double chi2)
Setter for the chi square value of the circle fit.
size_t getNDF() const
Getter for the number of degrees of freedom of the circle fit.
Vector2D getGlobalPerigee() const
Getter for the closest approach on the trajectory to the global origin.
Vector2D getInnerExit() const
Calculates the point where the trajectory meets the inner wall of the CDC.
Vector3D reconstruct3D(const WireLine &wireLine, double distance=0.0, double z=0) const
Gives the one three dimensional positions within the CDC closest to the given z where the given drift...
double getDist2D(const Vector2D &point) const
Calculates the distance from the point to the trajectory as seen from the xy projection.
double m_flightTime
Memory for the estimation of the time at which the particle arrived at the support point.
double getCurvature() const
Getter for the curvature as seen from the xy projection.
Vector2D getMom2DAtSupport() const
Get the momentum at the support point of the trajectory.
Extension of the generalized circle also caching the perigee coordinates.
Definition: PerigeeCircle.h:36
Vector2D atArcLength(double arcLength) const
Calculates the point, which lies at the give perpendicular travel distance (counted from the perigee)
Vector2D perigee() const
Getter for the perigee point.
Vector2D tangential(const Vector2D &point) const
Tangential vector to the circle near the given position.
double arcLengthBetween(const Vector2D &from, const Vector2D &to) const
Calculates the arc length between two points of closest approach on the circle.
double distance(const Vector2D &point) const
Getter for the proper signed distance of the point to the circle.
Vector2D center() const
Getter for the center of the circle. If it was a line both components will be infinity.
ERightLeft isRightOrLeft(const Vector2D &point) const
Indicates if the point is on the right or left side of the circle.
double curvature() const
Getter for the signed curvature.
Vector2D closest(const Vector2D &point) const
Calculates the point of closest approach on the circle to the given point.
double arcLengthPeriod() const
Getter for the arc length for a full round of the circle.
Adds an uncertainty matrix to the circle in perigee parameterisation.
double covariance(const EPerigeeParameter &iRow, const EPerigeeParameter &iCol) const
Getter for individual elements of the covariance matrix.
void passiveMoveBy(const Vector2D &by)
Moves the coordinate system by the vector by and calculates the new perigee and its covariance matrix...
double variance(const EPerigeeParameter &i) const
Getter for individual diagonal elements of the covariance matrix.
double chi2() const
Getter for the chi square value of the circle fit.
void setNDF(std::size_t ndf)
Setter for the number of degrees of freediom used in the circle fit.
void setChi2(const double chi2)
Setter for the chi square value of the circle fit.
std::size_t ndf() const
Getter for the number of degrees of freediom used in the circle fit.
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
Definition: Vector2D.h:32
double dot(const Vector2D &rhs) const
Calculates the two dimensional dot product.
Definition: Vector2D.h:158
A three dimensional vector.
Definition: Vector3D.h:33
A three dimensional limited line represented by its closest approach to the z-axes (reference positio...
Definition: WireLine.h:31
ESign
Enumeration for the distinct sign values of floating point variables.
Definition: ESign.h:27
EForwardBackward
Enumeration to represent the distinct possibilities of the right left passage information.
EPerigeeParameter
Enumeration to address the individual perigee parameters in a vector or matrix.
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
Definition: ERightLeft.h:25
Abstract base class for different kinds of events.