Belle II Software  release-05-01-25
FitlessAxialSegmentPairVarSet.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - 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 #include <tracking/trackFindingCDC/filters/axialSegmentPair/FitlessAxialSegmentPairVarSet.h>
11 
12 #include <tracking/trackFindingCDC/eventdata/tracks/CDCAxialSegmentPair.h>
13 #include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
14 #include <tracking/trackFindingCDC/eventdata/hits/CDCRecoHit2D.h>
15 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
16 
17 #include <tracking/trackFindingCDC/numerics/Angle.h>
18 
19 using namespace Belle2;
20 using namespace TrackFindingCDC;
21 
23 {
24  if (not ptrAxialSegmentPair) return false;
25 
26  const CDCAxialSegmentPair& axialSegmentPair = *ptrAxialSegmentPair;
27 
28  const CDCSegment2D* ptrFromSegment = axialSegmentPair.getStartSegment();
29  const CDCSegment2D* ptrToSegment = axialSegmentPair.getEndSegment();
30 
31  const CDCSegment2D& fromSegment = *ptrFromSegment;
32  const CDCSegment2D& toSegment = *ptrToSegment;
33 
34  // Segment fit should have been done at this point
35  const CDCTrajectory2D& fromFit = fromSegment.getTrajectory2D();
36  const CDCTrajectory2D& toFit = toSegment.getTrajectory2D();
37 
38  finitevar<named("from_ndf")>() = fromFit.getNDF();
39  finitevar<named("to_ndf")>() = toFit.getNDF();
40 
41  finitevar<named("from_chi2_over_ndf")>() = fabs(fromFit.getChi2() / fromFit.getNDF());
42  finitevar<named("to_chi2_over_ndf")>() = fabs(toFit.getChi2() / toFit.getNDF());
43 
44  finitevar<named("from_p_value")>() = fromFit.getPValue();
45  finitevar<named("to_p_value")>() = toFit.getPValue();
46 
47  // Direction agreement
48  using namespace NPerigeeParameterIndices;
49  const double fromCurv = fromFit.isFitted() ? fromFit.getCurvature() : NAN;
50  const double fromCurvVar = fromFit.getLocalVariance(c_Curv);
51 
52  const double toCurv = toFit.isFitted() ? toFit.getCurvature() : NAN;
53  const double toCurvVar = toFit.getLocalVariance(c_Curv);
54 
55  const double deltaCurvVar = fromCurvVar + toCurvVar;
56  const double avgPrecision = 1 / fromCurvVar + 1 / toCurvVar;
57  const double deltaCurvSigma = std::sqrt(deltaCurvVar);
58 
59  finitevar<named("abs_avg_curv")>() = std::fabs(toCurv / toCurvVar + fromCurv / fromCurvVar) / avgPrecision;
60  finitevar<named("delta_curv_var")>() = deltaCurvVar;
61  finitevar<named("delta_curv")>() = toCurv - fromCurv;
62  finitevar<named("delta_curv_pull")>() = (toCurv - fromCurv) / deltaCurvSigma;
63 
64  // Hits
65  // const CDCRecoHit2D& fromFirstHit = fromSegment.front();
66  const CDCRecoHit2D& fromLastHit = fromSegment.back();
67  const CDCRecoHit2D& toFirstHit = toSegment.front();
68  // const CDCRecoHit2D& toLastHit = toSegment.back();
69 
70  const Vector2D fromHitPos = fromLastHit.getRecoPos2D();
71  const Vector2D toHitPos = toFirstHit.getRecoPos2D();
72 
73  // Fit
74  const Vector2D fromFitPos = fromFit.getClosest(fromHitPos);
75  const Vector2D toFitPos = toFit.getClosest(toHitPos);
76  const Vector2D fromFitMom = fromFit.getFlightDirection2D(fromHitPos);
77  const Vector2D toFitMom = toFit.getFlightDirection2D(toHitPos);
78 
79  const Vector2D fromOtherFitMom = toFit.getFlightDirection2D(fromHitPos);
80  const Vector2D toOtherFitMom = fromFit.getFlightDirection2D(toHitPos);
81 
82  const double deltaPosPhi = fromFitPos.angleWith(toFitPos);
83  const double deltaMomPhi = fromFitMom.angleWith(toFitMom);
84  const double deltaAlpha = AngleUtil::normalised(deltaMomPhi - deltaPosPhi);
85 
86  finitevar<named("delta_pos_phi")>() = deltaPosPhi;
87  finitevar<named("delta_mom_phi")>() = deltaMomPhi;
88 
89  finitevar<named("from_delta_mom_phi")>() = fromFitMom.angleWith(fromOtherFitMom);
90  finitevar<named("to_delta_mom_phi")>() = toFitMom.angleWith(toOtherFitMom);
91  finitevar<named("delta_alpha")>() = deltaAlpha;
92 
93  finitevar<named("arc_length_front_offset")>() =
94  (fromFit.getArcLength2DFrontOffset(fromSegment, toSegment)
95  + toFit.getArcLength2DFrontOffset(fromSegment, toSegment)) / 2;
96 
97  finitevar<named("arc_length_back_offset")>() =
98  (fromFit.getArcLength2DBackOffset(fromSegment, toSegment)
99  + toFit.getArcLength2DBackOffset(fromSegment, toSegment)) / 2;
100 
101  finitevar<named("from_arc_length_total")>() = toFit.getTotalArcLength2D(fromSegment);
102  finitevar<named("to_arc_length_total")>() = fromFit.getTotalArcLength2D(toSegment);
103 
104  finitevar<named("arc_length_gap")>() =
105  (fromFit.getArcLength2DGap(fromSegment, toSegment)
106  + toFit.getArcLength2DGap(fromSegment, toSegment)) / 2;
107 
108  return true;
109 }
Belle2::TrackFindingCDC::CDCTrajectory2D::getPValue
double getPValue() const
Getter for p-value.
Definition: CDCTrajectory2D.h:472
Belle2::TrackFindingCDC::CDCTrajectory2D::getArcLength2DFrontOffset
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...
Definition: CDCTrajectory2D.h:232
Belle2::TrackFindingCDC::CDCTrajectory2D::getTotalArcLength2D
double getTotalArcLength2D(const AHits &hits) const
Calculates the perpendicular travel distance from the first position of the hits to the last position...
Definition: CDCTrajectory2D.h:254
Belle2::TrackFindingCDC::CDCTrajectory2D::getNDF
size_t getNDF() const
Getter for the number of degrees of freedom of the circle fit.
Definition: CDCTrajectory2D.h:490
Belle2::TrackFindingCDC::CDCAxialSegmentPair::getStartSegment
const CDCAxialSegment2D * getStartSegment() const
Getter for the start segment.
Definition: CDCAxialSegmentPair.h:99
Belle2::TrackFindingCDC::Vector2D
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:37
Belle2::TrackFindingCDC::CDCRecoHit2D::getRecoPos2D
Vector2D getRecoPos2D() const
Getter for the position in the reference plane.
Definition: CDCRecoHit2D.h:248
Belle2::TrackFindingCDC::VarSet< FitlessAxialSegmentPairVarNames >::finitevar
AssignFinite< Float_t > finitevar()
Reference getter for the value of the ith variable. Transforms non-finite values to finite value.
Definition: VarSet.h:140
Belle2::TrackFindingCDC::CDCTrajectory2D::getCurvature
double getCurvature() const
Getter for the curvature as seen from the xy projection.
Definition: CDCTrajectory2D.h:432
Belle2::TrackFindingCDC::CDCTrajectory2D::getClosest
Vector2D getClosest(const Vector2D &point) const
Calculates the closest approach on the trajectory to the given point.
Definition: CDCTrajectory2D.cc:173
Belle2::TrackFindingCDC::CDCTrajectory2D::getLocalVariance
double getLocalVariance(EPerigeeParameter i) const
Getter for an individual diagonal element of the covariance matrix of the local helix parameters.
Definition: CDCTrajectory2D.h:445
Belle2::TrackFindingCDC::CDCTrajectory2D::getChi2
double getChi2() const
Getter for the chi2 value of the circle fit.
Definition: CDCTrajectory2D.h:478
Belle2::TrackFindingCDC::CDCTrajectory2D
Particle trajectory as it is seen in xy projection represented as a circle.
Definition: CDCTrajectory2D.h:46
Belle2::TrackFindingCDC::CDCAxialSegmentPair::getEndSegment
const CDCAxialSegment2D * getEndSegment() const
Getter for the end segment.
Definition: CDCAxialSegmentPair.h:111
Belle2::TrackFindingCDC::CDCRecoHit2D
Class representing a two dimensional reconstructed hit in the central drift chamber.
Definition: CDCRecoHit2D.h:57
Belle2::TrackFindingCDC::CDCSegment::getTrajectory2D
CDCTrajectory2D & getTrajectory2D() const
Getter for the two dimensional trajectory fitted to the segment.
Definition: CDCSegment.h:79
Belle2::TrackFindingCDC::CDCAxialSegmentPair
Class representing a pair of reconstructed axial segements in adjacent superlayer.
Definition: CDCAxialSegmentPair.h:41
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::CDCTrajectory2D::getFlightDirection2D
Vector2D getFlightDirection2D(const Vector2D &point) const
Get the unit direction of flight at the given point, where arcLength2D = 0.
Definition: CDCTrajectory2D.h:320
Belle2::TrackFindingCDC::FitlessAxialSegmentPairVarSet::extract
bool extract(const CDCAxialSegmentPair *ptrAxialSegmentPair) override
Generate and assign the contained variables.
Definition: FitlessAxialSegmentPairVarSet.cc:22
Belle2::TrackFindingCDC::CDCTrajectory2D::isFitted
bool isFitted() const
Checks if the circle is already set to a valid value.
Definition: CDCTrajectory2D.cc:85
Belle2::TrackFindingCDC::CDCTrajectory2D::getArcLength2DGap
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...
Definition: CDCTrajectory2D.h:220
Belle2::TrackFindingCDC::CDCSegment2D
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:40
Belle2::TrackFindingCDC::VarSet< FitlessAxialSegmentPairVarNames >::named
constexpr static int named(const char *name)
Getter for the index from the name.
Definition: VarSet.h:88
Belle2::TrackFindingCDC::Vector2D::angleWith
double angleWith(const Vector2D &rhs) const
The angle between this and rhs.
Definition: Vector2D.h:211
Belle2::TrackFindingCDC::CDCTrajectory2D::getArcLength2DBackOffset
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...
Definition: CDCTrajectory2D.h:244
Belle2::TrackFindingCDC::AngleUtil::normalised
static double normalised(const double angle)
Normalise an angle to lie in the range from [-pi, pi].
Definition: Angle.h:43