Belle II Software  release-05-01-25
FitlessSegmentRelationVarSet.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/segmentRelation/FitlessSegmentRelationVarSet.h>
11 
12 #include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
13 
14 #include <tracking/trackFindingCDC/numerics/Angle.h>
15 
16 using namespace Belle2;
17 using namespace TrackFindingCDC;
18 
20 {
21  if (not ptrSegmentRelation) return false;
22 
23  const Relation<const CDCSegment2D>& segmentPair = *ptrSegmentRelation;
24 
25  const CDCSegment2D* ptrFromSegment = segmentPair.getFrom();
26  const CDCSegment2D* ptrToSegment = segmentPair.getTo();
27 
28  const CDCSegment2D& fromSegment = *ptrFromSegment;
29  const CDCSegment2D& toSegment = *ptrToSegment;
30 
31  // Segment fit should have been done at this point
32  const CDCTrajectory2D& fromFit = fromSegment.getTrajectory2D();
33  const CDCTrajectory2D& toFit = toSegment.getTrajectory2D();
34 
35  finitevar<named("from_ndf")>() = fromFit.getNDF();
36  finitevar<named("to_ndf")>() = toFit.getNDF();
37 
38  finitevar<named("from_chi2_over_ndf")>() = fabs(fromFit.getChi2() / fromFit.getNDF());
39  finitevar<named("to_chi2_over_ndf")>() = fabs(toFit.getChi2() / toFit.getNDF());
40 
41  finitevar<named("from_p_value")>() = fromFit.getPValue();
42  finitevar<named("to_p_value")>() = toFit.getPValue();
43 
44  // Direction agreement
45  using namespace NPerigeeParameterIndices;
46  const double fromCurv = fromFit.isFitted() ? fromFit.getCurvature() : NAN;
47  const double fromCurvVar = fromFit.getLocalVariance(c_Curv);
48 
49  const double toCurv = toFit.isFitted() ? toFit.getCurvature() : NAN;
50  const double toCurvVar = toFit.getLocalVariance(c_Curv);
51 
52  const double deltaCurvVar = fromCurvVar + toCurvVar;
53  const double avgPrecision = 1 / fromCurvVar + 1 / toCurvVar;
54  const double deltaCurvSigma = std::sqrt(deltaCurvVar);
55 
56  finitevar<named("abs_avg_curv")>() = std::fabs(toCurv / toCurvVar + fromCurv / fromCurvVar) / avgPrecision;
57  finitevar<named("delta_curv_var")>() = deltaCurvVar;
58  finitevar<named("delta_curv")>() = toCurv - fromCurv;
59  finitevar<named("delta_curv_pull")>() = (toCurv - fromCurv) / deltaCurvSigma;
60 
61  // Hits
62  // const CDCRecoHit2D& fromFirstHit = fromSegment.front();
63  const CDCRecoHit2D& fromLastHit = fromSegment.back();
64  const CDCRecoHit2D& toFirstHit = toSegment.front();
65  // const CDCRecoHit2D& toLastHit = toSegment.back();
66 
67  const Vector2D fromHitPos = fromLastHit.getRecoPos2D();
68  const Vector2D toHitPos = toFirstHit.getRecoPos2D();
69 
70  // Fit
71  const Vector2D fromFitPos = fromFit.getClosest(fromHitPos);
72  const Vector2D toFitPos = toFit.getClosest(toHitPos);
73  const Vector2D fromFitMom = fromFit.getFlightDirection2D(fromHitPos);
74  const Vector2D toFitMom = toFit.getFlightDirection2D(toHitPos);
75 
76  const Vector2D fromOtherFitMom = toFit.getFlightDirection2D(fromHitPos);
77  const Vector2D toOtherFitMom = fromFit.getFlightDirection2D(toHitPos);
78 
79  const double deltaPosPhi = fromFitPos.angleWith(toFitPos);
80  const double deltaMomPhi = fromFitMom.angleWith(toFitMom);
81  const double deltaAlpha = AngleUtil::normalised(deltaMomPhi - deltaPosPhi);
82 
83  finitevar<named("delta_pos_phi")>() = deltaPosPhi;
84  finitevar<named("delta_mom_phi")>() = deltaMomPhi;
85 
86  finitevar<named("from_delta_mom_phi")>() = fromFitMom.angleWith(fromOtherFitMom);
87  finitevar<named("to_delta_mom_phi")>() = toFitMom.angleWith(toOtherFitMom);
88  finitevar<named("delta_alpha")>() = deltaAlpha;
89 
90  finitevar<named("arc_length_front_offset")>() =
91  (fromFit.getArcLength2DFrontOffset(fromSegment, toSegment)
92  + toFit.getArcLength2DFrontOffset(fromSegment, toSegment)) / 2;
93 
94  finitevar<named("arc_length_back_offset")>() =
95  (fromFit.getArcLength2DBackOffset(fromSegment, toSegment)
96  + toFit.getArcLength2DBackOffset(fromSegment, toSegment)) / 2;
97 
98  finitevar<named("from_arc_length_total")>() = toFit.getTotalArcLength2D(fromSegment);
99  finitevar<named("to_arc_length_total")>() = fromFit.getTotalArcLength2D(toSegment);
100 
101  finitevar<named("arc_length_gap")>() =
102  (fromFit.getArcLength2DGap(fromSegment, toSegment)
103  + toFit.getArcLength2DGap(fromSegment, toSegment)) / 2;
104 
105  return true;
106 }
Belle2::TrackFindingCDC::Relation::getFrom
From * getFrom() const
Getter for the pointer to the from side object.
Definition: Relation.h:69
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::Relation
Type for two related objects.
Definition: CDCSegment2D.h:37
Belle2::TrackFindingCDC::FitlessSegmentRelationVarSet::extract
bool extract(const Relation< const CDCSegment2D > *ptrSegmentRelation) override
Generate and assign the contained variables.
Definition: FitlessSegmentRelationVarSet.cc:19
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::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< FitlessSegmentRelationVarNames >::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::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
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::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< FitlessSegmentRelationVarNames >::named
constexpr static int named(const char *name)
Getter for the index from the name.
Definition: VarSet.h:88
Belle2::TrackFindingCDC::Relation::getTo
To * getTo() const
Getter for the pointer to the to side object.
Definition: Relation.h:75
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