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
16#include <tracking/trackingUtilities/numerics/EForwardBackward.h>
17#include <tracking/trackingUtilities/numerics/ERightLeft.h>
18#include <tracking/trackingUtilities/numerics/ESign.h>
19
20#include <Math/Vector3D.h>
21#include <Math/Vector2D.h>
22
23#include <TMath.h>
24#include <cmath>
25#include <cstddef>
26#include <iosfwd>
27
28namespace Belle2 {
33 namespace CDC {
34 class WireLine;
35 }
36 namespace TrackingUtilities {
37
40
41 public:
44
50 explicit CDCTrajectory2D(const UncertainPerigeeCircle& perigeeCircle);
51
59 CDCTrajectory2D(const ROOT::Math::XYVector& localOrigin,
60 const UncertainPerigeeCircle& localPerigeeCircle,
61 double flightTime = NAN);
62
67 CDCTrajectory2D(const ROOT::Math::XYVector& pos2D,
68 double time,
69 const ROOT::Math::XYVector& mom2D,
70 double charge,
71 double bZ);
72
75 CDCTrajectory2D(const ROOT::Math::XYVector& pos2D, double time, const ROOT::Math::XYVector& mom2D, double charge);
76
77 public:
79 bool isFitted() const;
80
82 void clear();
83
84 public:
86 void reverse();
87
90
91 public:
101 std::array<double, 2> reconstructBothZ(const CDC::WireLine& wireLine, double distance = 0.0, double z = 0) const;
102
113 double reconstructZ(const CDC::WireLine& wireLine, double distance = 0.0, double z = 0) const;
114
124 std::array<ROOT::Math::XYZVector, 2> reconstructBoth3D(const CDC::WireLine& wireLine, double distance = 0.0, double z = 0) const;
125
138 ROOT::Math::XYZVector reconstruct3D(const CDC::WireLine& wireLine, double distance = 0.0, double z = 0) const;
139
141 ROOT::Math::XYVector getClosest(const ROOT::Math::XYVector& point) const;
142
143 private:
148 CDC::ISuperLayer getISuperLayerAfter(CDC::ISuperLayer iSuperLayer, bool movingOutward) const;
149
154 CDC::ISuperLayer getISuperLayerAfterStart(bool movingOutward) const;
155
160 CDC::ISuperLayer getISuperLayerAfterStart(EForwardBackward forwardBackwardInfo) const;
161
167 CDC::ISuperLayer getAxialISuperLayerAfterStart(EForwardBackward forwardBackwardInfo) const;
168
169 public:
173
177
181
185
188
191
194
195 public:
202 template <class AHits>
203 EForwardBackward isForwardOrBackwardTo(const AHits& hits) const
204 {
205 return static_cast<EForwardBackward>(sign(getTotalArcLength2D(hits)));
206 }
207
212 template <class AFromHits, class AToHits>
213 double getArcLength2DGap(const AFromHits& fromHits, const AToHits& toHits) const
214 {
215 const ROOT::Math::XYVector& fromRecoPos2D = fromHits.back().getRecoPos2D();
216 const ROOT::Math::XYVector& toRecoPos2D = toHits.front().getRecoPos2D();
217 return calcArcLength2DBetween(fromRecoPos2D, toRecoPos2D);
218 }
219
224 template <class AFromHits, class AToHits>
225 double getArcLength2DFrontOffset(const AFromHits& fromHits, const AToHits& toHits) const
226 {
227 const ROOT::Math::XYVector& fromRecoPos2D = fromHits.front().getRecoPos2D();
228 const ROOT::Math::XYVector& toRecoPos2D = toHits.front().getRecoPos2D();
229 return calcArcLength2DBetween(fromRecoPos2D, toRecoPos2D);
230 }
231
236 template <class AFromHits, class AToHits>
237 double getArcLength2DBackOffset(const AFromHits& fromHits, const AToHits& toHits) const
238 {
239 const ROOT::Math::XYVector& fromRecoPos2D = fromHits.back().getRecoPos2D();
240 const ROOT::Math::XYVector& toRecoPos2D = toHits.back().getRecoPos2D();
241 return calcArcLength2DBetween(fromRecoPos2D, toRecoPos2D);
242 }
243
246 template <class AHits>
247 double getTotalArcLength2D(const AHits& hits) const
248 {
249 ROOT::Math::XYVector frontRecoPos2D = hits.front().getRecoPos2D();
250 ROOT::Math::XYVector backRecoPos2D = hits.back().getRecoPos2D();
251 return calcArcLength2DBetween(frontRecoPos2D, backRecoPos2D);
252 }
253
263 double calcArcLength2D(const ROOT::Math::XYVector& point) const
264 {
265 return getLocalCircle()->arcLengthBetween(ROOT::Math::XYVector(0.0, 0.0), point - getLocalOrigin());
266 }
267
276 double calcArcLength2DBetween(const ROOT::Math::XYVector& fromPoint, const ROOT::Math::XYVector& toPoint) const
277 {
278 return getLocalCircle()->arcLengthBetween(fromPoint - getLocalOrigin(),
279 toPoint - getLocalOrigin());
280 }
281
282 double getArcLength2DPeriod() const
283 {
285 }
286
287 public:
289 void setPosMom2D(const ROOT::Math::XYVector& pos2D, const ROOT::Math::XYVector& mom2D, double charge);
290
292 ESign getChargeSign() const;
293
295 double getAbsMom2D(double bZ) const;
296
298 double getAbsMom2D() const;
299
301 ROOT::Math::XYVector getMom2DAtSupport(const double bZ) const
302 {
304 }
305
307 ROOT::Math::XYVector getMom2DAtSupport() const
308 {
310 }
311
313 ROOT::Math::XYVector getFlightDirection2D(const ROOT::Math::XYVector& point) const
314 {
315 return getLocalCircle()->tangential(point - getLocalOrigin());
316 }
317
319 ROOT::Math::XYVector getFlightDirection2DAtSupport() const
320 {
321 return getLocalCircle()->tangential();
322 }
323
326 bool isMovingOutward() const
327 {
328 return getFlightDirection2DAtSupport().Dot(getSupport()) > 0;
329 }
330
332 ROOT::Math::XYVector getPos2DAtArcLength2D(double arcLength2D)
333 {
334 return getLocalOrigin() + getLocalCircle()->atArcLength(arcLength2D);
335 }
336
338 ROOT::Math::XYVector getSupport() const
339 {
340 return getLocalCircle()->perigee() + getLocalOrigin();
341 }
342
344 ROOT::Math::XYVector getGlobalPerigee() const
345 {
347 }
348
350 ROOT::Math::XYVector getGlobalCenter() const
351 {
352 return getLocalCircle()->center() + m_localOrigin;
353 }
354
363 ROOT::Math::XYVector getOuterExit(double factor = 1) const;
364
372 ROOT::Math::XYVector getInnerExit() const;
373
382 ROOT::Math::XYVector getExit() const;
383
386 bool isCurler(double factor = 1) const;
387
390 bool isOriginer(double factor = 1) const;
391
394 {
395 return std::fabs(getGlobalImpact() + 2 * getLocalCircle()->radius());
396 }
397
401 {
402 return std::fabs(getGlobalImpact());
403 }
404
406 double getGlobalImpact() const
407 {
409 }
410
412 double getDist2D(const ROOT::Math::XYVector& point) const
413 {
414 return getLocalCircle()->distance(point - getLocalOrigin());
415 }
416
418 ERightLeft isRightOrLeft(const ROOT::Math::XYVector& point) const
419 {
420 return getLocalCircle()->isRightOrLeft(point - getLocalOrigin());
421 }
422
423 public:
425 double getCurvature() const
426 {
427 return getLocalCircle()->curvature();
428 }
429
431 double getLocalCovariance(EPerigeeParameter iRow, EPerigeeParameter iCol) const
432 {
433 return getLocalCircle().covariance(iRow, iCol);
434 }
435
438 double getLocalVariance(EPerigeeParameter i) const
439 {
440 return getLocalCircle().variance(i);
441 }
442
445 {
446 PerigeeCircle result = getLocalCircle();
447 result.passiveMoveBy(-getLocalOrigin());
448 return result;
449 }
450
452 void setGlobalCircle(const UncertainPerigeeCircle& perigeeCircle)
453 {
454 m_localPerigeeCircle = perigeeCircle;
455 m_localPerigeeCircle.passiveMoveBy(getLocalOrigin());
456 }
457
460 {
462 }
463
465 double getPValue() const
466 {
467 return TMath::Prob(getChi2(), getNDF());
468 }
469
471 double getChi2() const
472 {
473 return getLocalCircle().chi2();
474 }
475
477 void setChi2(const double chi2)
478 {
479 return m_localPerigeeCircle.setChi2(chi2);
480 }
481
483 size_t getNDF() const
484 {
485 return getLocalCircle().ndf();
486 }
487
489 void setNDF(std::size_t ndf)
490 {
491 return m_localPerigeeCircle.setNDF(ndf);
492 }
493
495 void setLocalCircle(const UncertainPerigeeCircle& localPerigeeCircle)
496 {
497 m_localPerigeeCircle = localPerigeeCircle;
498 }
499
501 const ROOT::Math::XYVector& getLocalOrigin() const
502 {
503 return m_localOrigin;
504 }
505
522 double setLocalOrigin(const ROOT::Math::XYVector& localOrigin);
523
525 double getFlightTime() const
526 {
527 return m_flightTime;
528 }
529
531 void setFlightTime(double flightTime)
532 {
533 m_flightTime = flightTime;
534 }
535
536 private:
538 ROOT::Math::XYVector m_localOrigin;
539
542
544 double m_flightTime = NAN;
545 };
546
548 std::ostream& operator<<(std::ostream& output, const CDCTrajectory2D& trajectory2D);
549 }
551}
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...
std::array< ROOT::Math::XYZVector, 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 getMaximalCylindricalR() const
Getter for the maximal distance from the origin.
ROOT::Math::XYVector m_localOrigin
Memory for local coordinate origin of the circle representing the trajectory in global coordinates.
CDCTrajectory2D reversed() const
Returns the reverse trajectory as a copy.
ROOT::Math::XYVector getSupport() const
Get the support point of the trajectory in global coordinates.
double calcArcLength2DBetween(const ROOT::Math::XYVector &fromPoint, const ROOT::Math::XYVector &toPoint) const
Calculate the travel distance between the two given positions Returns the travel distance on the traj...
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...
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.
ROOT::Math::XYVector getClosest(const ROOT::Math::XYVector &point) const
Calculates the closest approach on the trajectory to the given point.
double getFlightTime() const
Getter for the time when the particle reached the support point position.
ROOT::Math::XYVector getGlobalCenter() const
Getter for the center of the trajectory in global coordinates.
void setLocalCircle(const UncertainPerigeeCircle &localPerigeeCircle)
Setter for the generalized circle that describes the trajectory.
ESign getChargeSign() const
Gets the charge sign of the trajectory.
double calcArcLength2D(const ROOT::Math::XYVector &point) const
Calculate the travel distance from the start position of the trajectory.
CDC::ISuperLayer getISuperLayerAfterStart(bool movingOutward) const
Returns which superlayer is traversed after the current one following the trajectory outward or inwar...
double setLocalOrigin(const ROOT::Math::XYVector &localOrigin)
Setter for the origin of the local coordinate system.
ROOT::Math::XYVector getOuterExit(double factor=1) const
Calculates the point where the trajectory meets the outer wall of the CDC.
double getChi2() const
Getter for the chi2 value of the circle fit.
double getPValue() const
Getter for p-value.
void setPosMom2D(const ROOT::Math::XYVector &pos2D, const ROOT::Math::XYVector &mom2D, double charge)
Setter for start point and momentum at the start point subjected to the charge sign.
CDC::ISuperLayer getPreviousISuperLayer() const
Indicates which superlayer the trajectory traverses before the one, where the start point of the traj...
const ROOT::Math::XYVector & getLocalOrigin() const
Getter for the origin of the local coordinate system.
bool isCurler(double factor=1) const
Checks if the trajectory leaves the outer radius of the CDC times the given tolerance factor.
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.
ROOT::Math::XYVector getExit() const
Calculates the point where the trajectory leaves the CDC.
double getLocalCovariance(EPerigeeParameter iRow, EPerigeeParameter iCol) const
Getter for an individual element of the covariance matrix of the local helix parameters.
double getMinimalCylindricalR() const
Getter for the minimal distance from the origin - same as absolute value of the impact parameter.
ERightLeft isRightOrLeft(const ROOT::Math::XYVector &point) const
Checks if the given point is to the right or to the left of the trajectory.
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...
ROOT::Math::XYVector 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.
void setNDF(std::size_t ndf)
Setter for the number of degrees of freedom of the circle fit.
ROOT::Math::XYVector getPos2DAtArcLength2D(double arcLength2D)
Getter for the position at a given two dimensional arc length.
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.
ROOT::Math::XYVector getMom2DAtSupport() const
Get the momentum at the support point of the trajectory.
ROOT::Math::XYZVector 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...
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.
ROOT::Math::XYVector getGlobalPerigee() const
Getter for the closest approach on the trajectory to the global origin.
bool isMovingOutward() const
Indicates if the trajectory is moving outwards or inwards (to or away from the origin) from the start...
ROOT::Math::XYVector getInnerExit() const
Calculates the point where the trajectory meets the inner wall of the CDC.
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...
ROOT::Math::XYVector getMom2DAtSupport(const double bZ) const
Get the momentum at the support point of the trajectory.
void setChi2(const double chi2)
Setter for the chi square value of the circle fit.
double getDist2D(const ROOT::Math::XYVector &point) const
Calculates the distance from the point to the trajectory as seen from the xy projection.
size_t getNDF() const
Getter for the number of degrees of freedom of the circle fit.
ROOT::Math::XYVector getFlightDirection2D(const ROOT::Math::XYVector &point) const
Get the unit direction of flight at the given point, where arcLength2D = 0.
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.
Extension of the generalized circle also caching the perigee coordinates.
ROOT::Math::XYVector tangential(const ROOT::Math::XYVector &point) const
Tangential vector to the circle near the given position.
double arcLengthBetween(const ROOT::Math::XYVector &from, const ROOT::Math::XYVector &to) const
Calculates the arc length between two points of closest approach on the circle.
ROOT::Math::XYVector closest(const ROOT::Math::XYVector &point) const
Calculates the point of closest approach on the circle to the given point.
double distance(const ROOT::Math::XYVector &point) const
Getter for the proper signed distance of the point to the circle.
ERightLeft isRightOrLeft(const ROOT::Math::XYVector &point) const
Indicates if the point is on the right or left side of the circle.
ROOT::Math::XYVector perigee() const
Getter for the perigee point.
ROOT::Math::XYVector atArcLength(double arcLength) const
Calculates the point, which lies at the give perpendicular travel distance (counted from the perigee)
double curvature() const
Getter for the signed curvature.
ROOT::Math::XYVector center() const
Getter for the center of the circle. If it was a line both components will be infinity.
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.
signed short ISuperLayer
The type of the layer and superlayer ids.
Definition ISuperLayer.h:24
Abstract base class for different kinds of events.