Belle II Software development
SimpleAxialSegmentPairFilter.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/SimpleAxialSegmentPairFilter.h>
9
10#include <tracking/trackingUtilities/eventdata/tracks/CDCAxialSegmentPair.h>
11#include <tracking/trackingUtilities/eventdata/segments/CDCSegment2D.h>
12
13#include <Math/Vector2D.h>
14#include <Math/VectorUtil.h>
15
16using namespace Belle2;
17using namespace TrackFindingCDC;
18using namespace TrackingUtilities;
19
24
26{
27 const CDCAxialSegment2D* ptrStartSegment = axialSegmentPair.getStartSegment();
28 const CDCAxialSegment2D* ptrEndSegment = axialSegmentPair.getEndSegment();
29
30 assert(ptrStartSegment);
31 assert(ptrEndSegment);
32
33 const CDCAxialSegment2D& startSegment = *ptrStartSegment;
34 const CDCAxialSegment2D& endSegment = *ptrEndSegment;
35
36 // Do fits
37 const CDCTrajectory2D& startFit = getFittedTrajectory2D(startSegment);
38 const CDCTrajectory2D& endFit = getFittedTrajectory2D(endSegment);
39
40 // Check if segments are coaligned
41 bool endSegmentIsCoaligned = startFit.getTotalArcLength2D(endSegment) >= 0.0;
42 bool startSegmentIsCoaligned = endFit.getTotalArcLength2D(startSegment) >= 0.0;
43
44 if (not endSegmentIsCoaligned or not startSegmentIsCoaligned) {
45 return NAN;
46 }
47
48 // Check if there is a positive gap between start and end segment
49 double startFitGap = startFit.getArcLength2DGap(startSegment, endSegment);
50 double endFitGap = endFit.getArcLength2DGap(startSegment, endSegment);
51
52 if (startFitGap < 0 or startFitGap > 100 or endFitGap < 0 or endFitGap > 100) {
53 return NAN;
54 }
55
56 double startFitFrontOffset = startFit.getArcLength2DFrontOffset(startSegment, endSegment);
57 double endFitBackOffset = endFit.getArcLength2DBackOffset(startSegment, endSegment);
58
59 if (startFitFrontOffset < 0 or endFitBackOffset < 0) {
60 return NAN;
61 }
62
63 ROOT::Math::XYVector startBackRecoPos2D = startSegment.back().getRecoPos2D();
64 ROOT::Math::XYVector endFrontRecoPos2D = endSegment.front().getRecoPos2D();
65
66 // Momentum agreement cut
67 ROOT::Math::XYVector startMom2DAtStartBack = startFit.getFlightDirection2D(startBackRecoPos2D);
68 ROOT::Math::XYVector endMom2DAtEndFront = endFit.getFlightDirection2D(endFrontRecoPos2D);
69
70 ROOT::Math::XYVector startMom2DAtEndFront = startFit.getFlightDirection2D(endFrontRecoPos2D);
71 ROOT::Math::XYVector endMom2DAtStartBack = endFit.getFlightDirection2D(startBackRecoPos2D);
72
73 double momAngleAtStartBack = ROOT::Math::VectorUtil::DeltaPhi(startMom2DAtStartBack, endMom2DAtStartBack);
74 double momAngleAtEndFront = ROOT::Math::VectorUtil::DeltaPhi(endMom2DAtEndFront, startMom2DAtEndFront);
75
76 if (fabs(momAngleAtEndFront) > 2.0 or fabs(momAngleAtStartBack) > 2.0) {
77 return NAN;
78 }
79
80 // Proximity cut
81 double startFit_dist2DToFront_endSegment = startFit.getDist2D(endFrontRecoPos2D);
82 double endFit_dist2DToBack_startSegment = endFit.getDist2D(startBackRecoPos2D);
83
84 if (startFit_dist2DToFront_endSegment < 6 and endFit_dist2DToBack_startSegment < 6) {
85 return startSegment.size() + endSegment.size();
86 } else {
87 return NAN;
88 }
89
90}
91
92
93
94const CDCTrajectory2D& SimpleAxialSegmentPairFilter::getFittedTrajectory2D(const CDCAxialSegment2D& segment) const
95{
96
97 CDCTrajectory2D& trajectory2D = segment.getTrajectory2D();
98 if (not trajectory2D.isFitted()) {
99 getRiemannFitter().update(trajectory2D, segment);
100 }
101 return trajectory2D;
102
103}
104
105
106
108 axialSegmentPair) const
109{
110 CDCTrajectory2D& trajectory2D = axialSegmentPair.getTrajectory2D();
111 if (not trajectory2D.isFitted()) {
112 getRiemannFitter().update(trajectory2D, axialSegmentPair);
113 }
114 return trajectory2D;
115}
void update(TrackingUtilities::CDCTrajectory2D &trajectory2D, const CDCObservations2D &observations2D) const
Update the trajectory with a fit to the observations.
const CDCRiemannFitter & getRiemannFitter() const
Returns the xy fitter instance that is used by this filter.
const TrackingUtilities::CDCTrajectory2D & getFittedTrajectory2D(const TrackingUtilities::CDCAxialSegment2D &segment) const
Returns the trajectory of the axial segment. Also fits it if necessary.
CDCRiemannFitter m_riemannFitter
Memory of the Riemann fitter for the circle fits.
TrackingUtilities::Weight operator()(const TrackingUtilities::CDCAxialSegmentPair &axialSegmentPair) final
Checks if a pair of axial segments is a good combination.
Class representing a pair of reconstructed axial segments in adjacent superlayer.
const CDCAxialSegment2D * getEndSegment() const
Getter for the end segment.
CDCTrajectory2D & getTrajectory2D() const
Getter for the trajectory of the two dimensional trajectory.
const CDCAxialSegment2D * getStartSegment() const
Getter for the start segment.
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...
bool isFitted() const
Checks if the circle is already set to a valid value.
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...
double getDist2D(const ROOT::Math::XYVector &point) const
Calculates the distance from the point to the trajectory as seen from the xy projection.
ROOT::Math::XYVector getFlightDirection2D(const ROOT::Math::XYVector &point) const
Get the unit direction of flight at the given point, where arcLength2D = 0.
Abstract base class for different kinds of events.