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
13using namespace Belle2;
14using namespace TrackFindingCDC;
15using namespace TrackingUtilities;
16
21
23{
24 const CDCAxialSegment2D* ptrStartSegment = axialSegmentPair.getStartSegment();
25 const CDCAxialSegment2D* ptrEndSegment = axialSegmentPair.getEndSegment();
26
27 assert(ptrStartSegment);
28 assert(ptrEndSegment);
29
30 const CDCAxialSegment2D& startSegment = *ptrStartSegment;
31 const CDCAxialSegment2D& endSegment = *ptrEndSegment;
32
33 // Do fits
34 const CDCTrajectory2D& startFit = getFittedTrajectory2D(startSegment);
35 const CDCTrajectory2D& endFit = getFittedTrajectory2D(endSegment);
36
37 // Check if segments are coaligned
38 bool endSegmentIsCoaligned = startFit.getTotalArcLength2D(endSegment) >= 0.0;
39 bool startSegmentIsCoaligned = endFit.getTotalArcLength2D(startSegment) >= 0.0;
40
41 if (not endSegmentIsCoaligned or not startSegmentIsCoaligned) {
42 return NAN;
43 }
44
45 // Check if there is a positive gap between start and end segment
46 double startFitGap = startFit.getArcLength2DGap(startSegment, endSegment);
47 double endFitGap = endFit.getArcLength2DGap(startSegment, endSegment);
48
49 if (startFitGap < 0 or startFitGap > 100 or endFitGap < 0 or endFitGap > 100) {
50 return NAN;
51 }
52
53 double startFitFrontOffset = startFit.getArcLength2DFrontOffset(startSegment, endSegment);
54 double endFitBackOffset = endFit.getArcLength2DBackOffset(startSegment, endSegment);
55
56 if (startFitFrontOffset < 0 or endFitBackOffset < 0) {
57 return NAN;
58 }
59
60 Vector2D startBackRecoPos2D = startSegment.back().getRecoPos2D();
61 Vector2D endFrontRecoPos2D = endSegment.front().getRecoPos2D();
62
63 // Momentum agreement cut
64 Vector2D startMom2DAtStartBack = startFit.getFlightDirection2D(startBackRecoPos2D);
65 Vector2D endMom2DAtEndFront = endFit.getFlightDirection2D(endFrontRecoPos2D);
66
67 Vector2D startMom2DAtEndFront = startFit.getFlightDirection2D(endFrontRecoPos2D);
68 Vector2D endMom2DAtStartBack = endFit.getFlightDirection2D(startBackRecoPos2D);
69
70 double momAngleAtStartBack = startMom2DAtStartBack.angleWith(endMom2DAtStartBack);
71 double momAngleAtEndFront = endMom2DAtEndFront.angleWith(startMom2DAtEndFront);
72
73 if (fabs(momAngleAtEndFront) > 2.0 or fabs(momAngleAtStartBack) > 2.0) {
74 return NAN;
75 }
76
77 // Proximity cut
78 double startFit_dist2DToFront_endSegment = startFit.getDist2D(endFrontRecoPos2D);
79 double endFit_dist2DToBack_startSegment = endFit.getDist2D(startBackRecoPos2D);
80
81 if (startFit_dist2DToFront_endSegment < 6 and endFit_dist2DToBack_startSegment < 6) {
82 return startSegment.size() + endSegment.size();
83 } else {
84 return NAN;
85 }
86
87}
88
89
90
91const CDCTrajectory2D& SimpleAxialSegmentPairFilter::getFittedTrajectory2D(const CDCAxialSegment2D& segment) const
92{
93
94 CDCTrajectory2D& trajectory2D = segment.getTrajectory2D();
95 if (not trajectory2D.isFitted()) {
96 getRiemannFitter().update(trajectory2D, segment);
97 }
98 return trajectory2D;
99
100}
101
102
103
105 axialSegmentPair) const
106{
107 CDCTrajectory2D& trajectory2D = axialSegmentPair.getTrajectory2D();
108 if (not trajectory2D.isFitted()) {
109 getRiemannFitter().update(trajectory2D, axialSegmentPair);
110 }
111 return trajectory2D;
112}
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...
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...
double getDist2D(const Vector2D &point) const
Calculates the distance from the point to the trajectory as seen from the xy projection.
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
Definition Vector2D.h:36
double angleWith(const Vector2D &rhs) const
The angle between this and rhs.
Definition Vector2D.h:228
Abstract base class for different kinds of events.