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 <cdc/topology/ISuperLayer.h>
11
12#include <tracking/trackingUtilities/geometry/UncertainPerigeeCircle.h>
13#include <tracking/trackingUtilities/geometry/PerigeeCircle.h>
14#include <tracking/trackingUtilities/geometry/PerigeeParameters.h>
15#include <tracking/trackingUtilities/geometry/Vector3D.h>
16#include <tracking/trackingUtilities/geometry/Vector2D.h>
17
18#include <tracking/trackingUtilities/numerics/EForwardBackward.h>
19#include <tracking/trackingUtilities/numerics/ERightLeft.h>
20#include <tracking/trackingUtilities/numerics/ESign.h>
21
22#include <TMath.h>
23#include <cmath>
24#include <cstddef>
25#include <iosfwd>
26
27namespace Belle2 {
32 namespace CDC {
33 class WireLine;
34 }
35 namespace TrackingUtilities {
36
39
40 public:
43
49 explicit CDCTrajectory2D(const UncertainPerigeeCircle& perigeeCircle);
50
58 CDCTrajectory2D(const Vector2D& localOrigin,
59 const UncertainPerigeeCircle& localPerigeeCircle,
60 double flightTime = NAN);
61
66 CDCTrajectory2D(const Vector2D& pos2D,
67 double time,
68 const Vector2D& mom2D,
69 double charge,
70 double bZ);
71
74 CDCTrajectory2D(const Vector2D& pos2D, double time, const Vector2D& mom2D, double charge);
75
76 public:
78 bool isFitted() const;
79
81 void clear();
82
83 public:
85 void reverse();
86
89
90 public:
100 std::array<double, 2> reconstructBothZ(const CDC::WireLine& wireLine, double distance = 0.0, double z = 0) const;
101
112 double reconstructZ(const CDC::WireLine& wireLine, double distance = 0.0, double z = 0) const;
113
123 std::array<Vector3D, 2> reconstructBoth3D(const CDC::WireLine& wireLine, double distance = 0.0, double z = 0) const;
124
137 Vector3D reconstruct3D(const CDC::WireLine& wireLine, double distance = 0.0, double z = 0) const;
138
140 Vector2D getClosest(const Vector2D& point) const;
141
142 private:
147 CDC::ISuperLayer getISuperLayerAfter(CDC::ISuperLayer iSuperLayer, bool movingOutward) const;
148
153 CDC::ISuperLayer getISuperLayerAfterStart(bool movingOutward) const;
154
159 CDC::ISuperLayer getISuperLayerAfterStart(EForwardBackward forwardBackwardInfo) const;
160
166 CDC::ISuperLayer getAxialISuperLayerAfterStart(EForwardBackward forwardBackwardInfo) const;
167
168 public:
172
176
180
184
187
190
193
194 public:
201 template <class AHits>
202 EForwardBackward isForwardOrBackwardTo(const AHits& hits) const
203 {
204 return static_cast<EForwardBackward>(sign(getTotalArcLength2D(hits)));
205 }
206
211 template <class AFromHits, class AToHits>
212 double getArcLength2DGap(const AFromHits& fromHits, const AToHits& toHits) const
213 {
214 const Vector2D& fromRecoPos2D = fromHits.back().getRecoPos2D();
215 const Vector2D& toRecoPos2D = toHits.front().getRecoPos2D();
216 return calcArcLength2DBetween(fromRecoPos2D, toRecoPos2D);
217 }
218
223 template <class AFromHits, class AToHits>
224 double getArcLength2DFrontOffset(const AFromHits& fromHits, const AToHits& toHits) const
225 {
226 const Vector2D& fromRecoPos2D = fromHits.front().getRecoPos2D();
227 const Vector2D& toRecoPos2D = toHits.front().getRecoPos2D();
228 return calcArcLength2DBetween(fromRecoPos2D, toRecoPos2D);
229 }
230
235 template <class AFromHits, class AToHits>
236 double getArcLength2DBackOffset(const AFromHits& fromHits, const AToHits& toHits) const
237 {
238 const Vector2D& fromRecoPos2D = fromHits.back().getRecoPos2D();
239 const Vector2D& toRecoPos2D = toHits.back().getRecoPos2D();
240 return calcArcLength2DBetween(fromRecoPos2D, toRecoPos2D);
241 }
242
245 template <class AHits>
246 double getTotalArcLength2D(const AHits& hits) const
247 {
248 Vector2D frontRecoPos2D = hits.front().getRecoPos2D();
249 Vector2D backRecoPos2D = hits.back().getRecoPos2D();
250 return calcArcLength2DBetween(frontRecoPos2D, backRecoPos2D);
251 }
252
262 double calcArcLength2D(const Vector2D& point) const
263 {
264 return getLocalCircle()->arcLengthBetween(Vector2D(0.0, 0.0), point - getLocalOrigin());
265 }
266
275 double calcArcLength2DBetween(const Vector2D& fromPoint, const Vector2D& toPoint) const
276 {
277 return getLocalCircle()->arcLengthBetween(fromPoint - getLocalOrigin(),
278 toPoint - getLocalOrigin());
279 }
280
281 double getArcLength2DPeriod() const
282 {
284 }
285
286 public:
288 void setPosMom2D(const Vector2D& pos2D, const Vector2D& mom2D, double charge);
289
291 ESign getChargeSign() const;
292
294 double getAbsMom2D(double bZ) const;
295
297 double getAbsMom2D() const;
298
300 Vector2D getMom2DAtSupport(const double bZ) const
301 {
303 }
304
310
313 {
314 return getLocalCircle()->tangential(point - getLocalOrigin());
315 }
316
322
325 bool isMovingOutward() const
326 {
328 }
329
331 Vector2D getPos2DAtArcLength2D(double arcLength2D)
332 {
333 return getLocalOrigin() + getLocalCircle()->atArcLength(arcLength2D);
334 }
335
338 {
339 return getLocalCircle()->perigee() + getLocalOrigin();
340 }
341
347
350 {
351 return getLocalCircle()->center() + m_localOrigin;
352 }
353
362 Vector2D getOuterExit(double factor = 1) const;
363
371 Vector2D getInnerExit() const;
372
381 Vector2D getExit() const;
382
385 bool isCurler(double factor = 1) const;
386
389 bool isOriginer(double factor = 1) const;
390
393 {
394 return std::fabs(getGlobalImpact() + 2 * getLocalCircle()->radius());
395 }
396
400 {
401 return std::fabs(getGlobalImpact());
402 }
403
405 double getGlobalImpact() const
406 {
408 }
409
411 double getDist2D(const Vector2D& point) const
412 {
413 return getLocalCircle()->distance(point - getLocalOrigin());
414 }
415
417 ERightLeft isRightOrLeft(const Vector2D& point) const
418 {
419 return getLocalCircle()->isRightOrLeft(point - getLocalOrigin());
420 }
421
422 public:
424 double getCurvature() const
425 {
426 return getLocalCircle()->curvature();
427 }
428
430 double getLocalCovariance(EPerigeeParameter iRow, EPerigeeParameter iCol) const
431 {
432 return getLocalCircle().covariance(iRow, iCol);
433 }
434
437 double getLocalVariance(EPerigeeParameter i) const
438 {
439 return getLocalCircle().variance(i);
440 }
441
444 {
445 PerigeeCircle result = getLocalCircle();
446 result.passiveMoveBy(-getLocalOrigin());
447 return result;
448 }
449
451 void setGlobalCircle(const UncertainPerigeeCircle& perigeeCircle)
452 {
453 m_localPerigeeCircle = perigeeCircle;
454 m_localPerigeeCircle.passiveMoveBy(getLocalOrigin());
455 }
456
459 {
461 }
462
464 double getPValue() const
465 {
466 return TMath::Prob(getChi2(), getNDF());
467 }
468
470 double getChi2() const
471 {
472 return getLocalCircle().chi2();
473 }
474
476 void setChi2(const double chi2)
477 {
478 return m_localPerigeeCircle.setChi2(chi2);
479 }
480
482 size_t getNDF() const
483 {
484 return getLocalCircle().ndf();
485 }
486
488 void setNDF(std::size_t ndf)
489 {
490 return m_localPerigeeCircle.setNDF(ndf);
491 }
492
494 void setLocalCircle(const UncertainPerigeeCircle& localPerigeeCircle)
495 {
496 m_localPerigeeCircle = localPerigeeCircle;
497 }
498
501 {
502 return m_localOrigin;
503 }
504
521 double setLocalOrigin(const Vector2D& localOrigin);
522
524 double getFlightTime() const
525 {
526 return m_flightTime;
527 }
528
530 void setFlightTime(double flightTime)
531 {
532 m_flightTime = flightTime;
533 }
534
535 private:
538
541
543 double m_flightTime = NAN;
544 };
545
547 std::ostream& operator<<(std::ostream& output, const CDCTrajectory2D& trajectory2D);
548 }
550}
A three dimensional limited line represented by its closest approach to the z-axes (reference positio...
Definition WireLine.h:33
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.
CDC::ISuperLayer getAxialISuperLayerAfterStart(EForwardBackward forwardBackwardInfo) const
Indicates which axial superlayer is traversed after the one, where the start point of the trajectory ...
CDC::ISuperLayer getISuperLayerAfter(CDC::ISuperLayer iSuperLayer, bool movingOutward) const
Returns which superlayer is traversed after the current one following the trajectory outward or inwar...
Vector2D getOuterExit(double factor=1) const
Calculates the point where the trajectory meets the outer wall of the CDC.
double reconstructZ(const CDC::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...
double getGlobalImpact() const
Getter for the signed impact parameter of the trajectory.
EForwardBackward isForwardOrBackwardTo(const AHits &hits) const
Calculates if this trajectory and the hits are coaligned Returns:
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.
CDC::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.
CDC::ISuperLayer getISuperLayerAfterStart(bool movingOutward) const
Returns which superlayer is traversed after the current one following the trajectory outward or inwar...
std::array< Vector3D, 2 > reconstructBoth3D(const CDC::WireLine &wireLine, double distance=0.0, double z=0) const
Gives the two three dimensional points where the drift circle touches the wire line.
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.
CDC::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.
CDC::ISuperLayer getMinimalISuperLayer() const
Indicates the minimal superlayer the trajectory traverses.
void setGlobalCircle(const UncertainPerigeeCircle &perigeeCircle)
Setter for the generalized circle that describes the trajectory.
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.
CDC::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...
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.
CDC::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.
std::array< double, 2 > reconstructBothZ(const CDC::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.
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...
CDC::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...
CDC::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 CDC::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.
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.
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.
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:36
double dot(const Vector2D &rhs) const
Calculates the two dimensional dot product.
Definition Vector2D.h:178
A three dimensional vector.
Definition Vector3D.h:34
signed short ISuperLayer
The type of the layer and superlayer ids.
Definition ISuperLayer.h:24
Abstract base class for different kinds of events.