Belle II Software development
FitlessAxialSegmentPairVarSet.cc
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#include <tracking/trackFindingCDC/filters/axialSegmentPair/FitlessAxialSegmentPairVarSet.h>
9
10#include <tracking/trackingUtilities/eventdata/tracks/CDCAxialSegmentPair.h>
11#include <tracking/trackingUtilities/eventdata/segments/CDCSegment2D.h>
12#include <tracking/trackingUtilities/eventdata/hits/CDCRecoHit2D.h>
13#include <tracking/trackingUtilities/eventdata/trajectories/CDCTrajectory2D.h>
14
15#include <tracking/trackingUtilities/numerics/Angle.h>
16
17#include <Math/Vector2D.h>
18#include <Math/VectorUtil.h>
19
20using namespace Belle2;
21using namespace TrackFindingCDC;
22using namespace TrackingUtilities;
23
25{
26 if (not ptrAxialSegmentPair) return false;
27
28 const CDCAxialSegmentPair& axialSegmentPair = *ptrAxialSegmentPair;
29
30 const CDCSegment2D* ptrFromSegment = axialSegmentPair.getStartSegment();
31 const CDCSegment2D* ptrToSegment = axialSegmentPair.getEndSegment();
32
33 const CDCSegment2D& fromSegment = *ptrFromSegment;
34 const CDCSegment2D& toSegment = *ptrToSegment;
35
36 // Segment fit should have been done at this point
37 const CDCTrajectory2D& fromFit = fromSegment.getTrajectory2D();
38 const CDCTrajectory2D& toFit = toSegment.getTrajectory2D();
39
40 finitevar<named("from_ndf")>() = fromFit.getNDF();
41 finitevar<named("to_ndf")>() = toFit.getNDF();
42
43 finitevar<named("from_chi2_over_ndf")>() = fabs(fromFit.getChi2() / fromFit.getNDF());
44 finitevar<named("to_chi2_over_ndf")>() = fabs(toFit.getChi2() / toFit.getNDF());
45
46 finitevar<named("from_p_value")>() = fromFit.getPValue();
47 finitevar<named("to_p_value")>() = toFit.getPValue();
48
49 // Direction agreement
50 using namespace NPerigeeParameterIndices;
51 const double fromCurv = fromFit.isFitted() ? fromFit.getCurvature() : NAN;
52 const double fromCurvVar = fromFit.getLocalVariance(c_Curv);
53
54 const double toCurv = toFit.isFitted() ? toFit.getCurvature() : NAN;
55 const double toCurvVar = toFit.getLocalVariance(c_Curv);
56
57 const double deltaCurvVar = fromCurvVar + toCurvVar;
58 const double avgPrecision = 1 / fromCurvVar + 1 / toCurvVar;
59 const double deltaCurvSigma = std::sqrt(deltaCurvVar);
60
61 finitevar<named("abs_avg_curv")>() = std::fabs(toCurv / toCurvVar + fromCurv / fromCurvVar) / avgPrecision;
62 finitevar<named("delta_curv_var")>() = deltaCurvVar;
63 finitevar<named("delta_curv")>() = toCurv - fromCurv;
64 finitevar<named("delta_curv_pull")>() = (toCurv - fromCurv) / deltaCurvSigma;
65
66 // Hits
67 // const CDCRecoHit2D& fromFirstHit = fromSegment.front();
68 const CDCRecoHit2D& fromLastHit = fromSegment.back();
69 const CDCRecoHit2D& toFirstHit = toSegment.front();
70 // const CDCRecoHit2D& toLastHit = toSegment.back();
71
72 const ROOT::Math::XYVector fromHitPos = fromLastHit.getRecoPos2D();
73 const ROOT::Math::XYVector toHitPos = toFirstHit.getRecoPos2D();
74
75 // Fit
76 const ROOT::Math::XYVector fromFitPos = fromFit.getClosest(fromHitPos);
77 const ROOT::Math::XYVector toFitPos = toFit.getClosest(toHitPos);
78 const ROOT::Math::XYVector fromFitMom = fromFit.getFlightDirection2D(fromHitPos);
79 const ROOT::Math::XYVector toFitMom = toFit.getFlightDirection2D(toHitPos);
80
81 const ROOT::Math::XYVector fromOtherFitMom = toFit.getFlightDirection2D(fromHitPos);
82 const ROOT::Math::XYVector toOtherFitMom = fromFit.getFlightDirection2D(toHitPos);
83
84 const double deltaPosPhi = ROOT::Math::VectorUtil::DeltaPhi(fromFitPos, toFitPos);
85 const double deltaMomPhi = ROOT::Math::VectorUtil::DeltaPhi(fromFitMom, toFitMom);
86 const double deltaAlpha = AngleUtil::normalised(deltaMomPhi - deltaPosPhi);
87
88 finitevar<named("delta_pos_phi")>() = deltaPosPhi;
89 finitevar<named("delta_mom_phi")>() = deltaMomPhi;
90
91 finitevar<named("from_delta_mom_phi")>() = ROOT::Math::VectorUtil::DeltaPhi(fromFitMom, fromOtherFitMom);
92 finitevar<named("to_delta_mom_phi")>() = ROOT::Math::VectorUtil::DeltaPhi(toFitMom, toOtherFitMom);
93 finitevar<named("delta_alpha")>() = deltaAlpha;
94
95 finitevar<named("arc_length_front_offset")>() =
96 (fromFit.getArcLength2DFrontOffset(fromSegment, toSegment)
97 + toFit.getArcLength2DFrontOffset(fromSegment, toSegment)) / 2;
98
99 finitevar<named("arc_length_back_offset")>() =
100 (fromFit.getArcLength2DBackOffset(fromSegment, toSegment)
101 + toFit.getArcLength2DBackOffset(fromSegment, toSegment)) / 2;
102
103 finitevar<named("from_arc_length_total")>() = toFit.getTotalArcLength2D(fromSegment);
104 finitevar<named("to_arc_length_total")>() = fromFit.getTotalArcLength2D(toSegment);
105
106 finitevar<named("arc_length_gap")>() =
107 (fromFit.getArcLength2DGap(fromSegment, toSegment)
108 + toFit.getArcLength2DGap(fromSegment, toSegment)) / 2;
109
110 return true;
111}
bool extract(const TrackingUtilities::CDCAxialSegmentPair *ptrAxialSegmentPair) override
Generate and assign the contained variables.
Class representing a pair of reconstructed axial segments in adjacent superlayer.
const CDCAxialSegment2D * getEndSegment() const
Getter for the end segment.
const CDCAxialSegment2D * getStartSegment() const
Getter for the start segment.
Class representing a two dimensional reconstructed hit in the central drift chamber.
ROOT::Math::XYVector getRecoPos2D() const
Getter for the position in the reference plane.
A reconstructed sequence of two dimensional hits in one super layer.
CDCTrajectory2D & getTrajectory2D() const
Getter for the two dimensional trajectory fitted to the segment.
Definition CDCSegment.h:69
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...
ROOT::Math::XYVector getClosest(const ROOT::Math::XYVector &point) const
Calculates the closest approach on the trajectory to the given point.
double getChi2() const
Getter for the chi2 value of the circle fit.
double getPValue() const
Getter for p-value.
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 getArcLength2DGap(const AFromHits &fromHits, const AToHits &toHits) const
Calculates the perpendicular travel distance from the last position of the fromHits to the first posi...
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...
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...
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 getCurvature() const
Getter for the curvature as seen from the xy projection.
Namespace to hide the contained enum constants.
Abstract base class for different kinds of events.
static double normalised(const double angle)
Normalise an angle to lie in the range from [-pi, pi].
Definition Angle.h:33