Belle II Software development
FitlessSegmentRelationVarSet.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/segmentRelation/FitlessSegmentRelationVarSet.h>
9
10#include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
11
12#include <tracking/trackFindingCDC/numerics/Angle.h>
13
14using namespace Belle2;
15using namespace TrackFindingCDC;
16
18{
19 if (not ptrSegmentRelation) return false;
20
21 const Relation<const CDCSegment2D>& segmentPair = *ptrSegmentRelation;
22
23 const CDCSegment2D* ptrFromSegment = segmentPair.getFrom();
24 const CDCSegment2D* ptrToSegment = segmentPair.getTo();
25
26 const CDCSegment2D& fromSegment = *ptrFromSegment;
27 const CDCSegment2D& toSegment = *ptrToSegment;
28
29 // Segment fit should have been done at this point
30 const CDCTrajectory2D& fromFit = fromSegment.getTrajectory2D();
31 const CDCTrajectory2D& toFit = toSegment.getTrajectory2D();
32
33 finitevar<named("from_ndf")>() = fromFit.getNDF();
34 finitevar<named("to_ndf")>() = toFit.getNDF();
35
36 finitevar<named("from_chi2_over_ndf")>() = fabs(fromFit.getChi2() / fromFit.getNDF());
37 finitevar<named("to_chi2_over_ndf")>() = fabs(toFit.getChi2() / toFit.getNDF());
38
39 finitevar<named("from_p_value")>() = fromFit.getPValue();
40 finitevar<named("to_p_value")>() = toFit.getPValue();
41
42 // Direction agreement
43 using namespace NPerigeeParameterIndices;
44 const double fromCurv = fromFit.isFitted() ? fromFit.getCurvature() : NAN;
45 const double fromCurvVar = fromFit.getLocalVariance(c_Curv);
46
47 const double toCurv = toFit.isFitted() ? toFit.getCurvature() : NAN;
48 const double toCurvVar = toFit.getLocalVariance(c_Curv);
49
50 const double deltaCurvVar = fromCurvVar + toCurvVar;
51 const double avgPrecision = 1 / fromCurvVar + 1 / toCurvVar;
52 const double deltaCurvSigma = std::sqrt(deltaCurvVar);
53
54 finitevar<named("abs_avg_curv")>() = std::fabs(toCurv / toCurvVar + fromCurv / fromCurvVar) / avgPrecision;
55 finitevar<named("delta_curv_var")>() = deltaCurvVar;
56 finitevar<named("delta_curv")>() = toCurv - fromCurv;
57 finitevar<named("delta_curv_pull")>() = (toCurv - fromCurv) / deltaCurvSigma;
58
59 // Hits
60 // const CDCRecoHit2D& fromFirstHit = fromSegment.front();
61 const CDCRecoHit2D& fromLastHit = fromSegment.back();
62 const CDCRecoHit2D& toFirstHit = toSegment.front();
63 // const CDCRecoHit2D& toLastHit = toSegment.back();
64
65 const Vector2D fromHitPos = fromLastHit.getRecoPos2D();
66 const Vector2D toHitPos = toFirstHit.getRecoPos2D();
67
68 // Fit
69 const Vector2D fromFitPos = fromFit.getClosest(fromHitPos);
70 const Vector2D toFitPos = toFit.getClosest(toHitPos);
71 const Vector2D fromFitMom = fromFit.getFlightDirection2D(fromHitPos);
72 const Vector2D toFitMom = toFit.getFlightDirection2D(toHitPos);
73
74 const Vector2D fromOtherFitMom = toFit.getFlightDirection2D(fromHitPos);
75 const Vector2D toOtherFitMom = fromFit.getFlightDirection2D(toHitPos);
76
77 const double deltaPosPhi = fromFitPos.angleWith(toFitPos);
78 const double deltaMomPhi = fromFitMom.angleWith(toFitMom);
79 const double deltaAlpha = AngleUtil::normalised(deltaMomPhi - deltaPosPhi);
80
81 finitevar<named("delta_pos_phi")>() = deltaPosPhi;
82 finitevar<named("delta_mom_phi")>() = deltaMomPhi;
83
84 finitevar<named("from_delta_mom_phi")>() = fromFitMom.angleWith(fromOtherFitMom);
85 finitevar<named("to_delta_mom_phi")>() = toFitMom.angleWith(toOtherFitMom);
86 finitevar<named("delta_alpha")>() = deltaAlpha;
87
88 finitevar<named("arc_length_front_offset")>() =
89 (fromFit.getArcLength2DFrontOffset(fromSegment, toSegment)
90 + toFit.getArcLength2DFrontOffset(fromSegment, toSegment)) / 2;
91
92 finitevar<named("arc_length_back_offset")>() =
93 (fromFit.getArcLength2DBackOffset(fromSegment, toSegment)
94 + toFit.getArcLength2DBackOffset(fromSegment, toSegment)) / 2;
95
96 finitevar<named("from_arc_length_total")>() = toFit.getTotalArcLength2D(fromSegment);
97 finitevar<named("to_arc_length_total")>() = fromFit.getTotalArcLength2D(toSegment);
98
99 finitevar<named("arc_length_gap")>() =
100 (fromFit.getArcLength2DGap(fromSegment, toSegment)
101 + toFit.getArcLength2DGap(fromSegment, toSegment)) / 2;
102
103 return true;
104}
Class representing a two dimensional reconstructed hit in the central drift chamber.
Definition: CDCRecoHit2D.h:47
Vector2D getRecoPos2D() const
Getter for the position in the reference plane.
Definition: CDCRecoHit2D.h:238
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:39
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...
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...
Vector2D getClosest(const Vector2D &point) const
Calculates the closest approach on the trajectory to the given point.
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...
Vector2D getFlightDirection2D(const Vector2D &point) const
Get the unit direction of flight at the given point, where arcLength2D = 0.
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.
double getCurvature() const
Getter for the curvature as seen from the xy projection.
bool extract(const Relation< const CDCSegment2D > *ptrSegmentRelation) override
Generate and assign the contained variables.
Type for two related objects.
Definition: Relation.h:21
From * getFrom() const
Getter for the pointer to the from side object.
Definition: Relation.h:59
To * getTo() const
Getter for the pointer to the to side object.
Definition: Relation.h:65
AssignFinite< Float_t > finitevar()
Reference getter for the value of the ith variable. Transforms non-finite values to finite value.
Definition: VarSet.h:130
static constexpr int named(const char *name)
Getter for the index from the name.
Definition: VarSet.h:78
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:32
double angleWith(const Vector2D &rhs) const
The angle between this and rhs.
Definition: Vector2D.h:197
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