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/trackFindingCDC/eventdata/tracks/CDCAxialSegmentPair.h>
11#include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
12
13using namespace Belle2;
14using namespace TrackFindingCDC;
15
17{
19}
20
22{
23 const CDCAxialSegment2D* ptrStartSegment = axialSegmentPair.getStartSegment();
24 const CDCAxialSegment2D* ptrEndSegment = axialSegmentPair.getEndSegment();
25
26 assert(ptrStartSegment);
27 assert(ptrEndSegment);
28
29 const CDCAxialSegment2D& startSegment = *ptrStartSegment;
30 const CDCAxialSegment2D& endSegment = *ptrEndSegment;
31
32 // Do fits
33 const CDCTrajectory2D& startFit = getFittedTrajectory2D(startSegment);
34 const CDCTrajectory2D& endFit = getFittedTrajectory2D(endSegment);
35
36 // Check if segments are coaligned
37 bool endSegmentIsCoaligned = startFit.getTotalArcLength2D(endSegment) >= 0.0;
38 bool startSegmentIsCoaligned = endFit.getTotalArcLength2D(startSegment) >= 0.0;
39
40 if (not endSegmentIsCoaligned or not startSegmentIsCoaligned) {
41 return NAN;
42 }
43
44 // Check if there is a positive gap between start and end segment
45 double startFitGap = startFit.getArcLength2DGap(startSegment, endSegment);
46 double endFitGap = endFit.getArcLength2DGap(startSegment, endSegment);
47
48 if (startFitGap < 0 or startFitGap > 100 or endFitGap < 0 or endFitGap > 100) {
49 return NAN;
50 }
51
52 double startFitFrontOffset = startFit.getArcLength2DFrontOffset(startSegment, endSegment);
53 double endFitBackOffset = endFit.getArcLength2DBackOffset(startSegment, endSegment);
54
55 if (startFitFrontOffset < 0 or endFitBackOffset < 0) {
56 return NAN;
57 }
58
59 Vector2D startBackRecoPos2D = startSegment.back().getRecoPos2D();
60 Vector2D endFrontRecoPos2D = endSegment.front().getRecoPos2D();
61
62 // Momentum agreement cut
63 Vector2D startMom2DAtStartBack = startFit.getFlightDirection2D(startBackRecoPos2D);
64 Vector2D endMom2DAtEndFront = endFit.getFlightDirection2D(endFrontRecoPos2D);
65
66 Vector2D startMom2DAtEndFront = startFit.getFlightDirection2D(endFrontRecoPos2D);
67 Vector2D endMom2DAtStartBack = endFit.getFlightDirection2D(startBackRecoPos2D);
68
69 double momAngleAtStartBack = startMom2DAtStartBack.angleWith(endMom2DAtStartBack);
70 double momAngleAtEndFront = endMom2DAtEndFront.angleWith(startMom2DAtEndFront);
71
72 if (fabs(momAngleAtEndFront) > 2.0 or fabs(momAngleAtStartBack) > 2.0) {
73 return NAN;
74 }
75
76 // Proximity cut
77 double startFit_dist2DToFront_endSegment = startFit.getDist2D(endFrontRecoPos2D);
78 double endFit_dist2DToBack_startSegment = endFit.getDist2D(startBackRecoPos2D);
79
80 if (startFit_dist2DToFront_endSegment < 6 and endFit_dist2DToBack_startSegment < 6) {
81 return startSegment.size() + endSegment.size();
82 } else {
83 return NAN;
84 }
85
86}
87
88
89
91{
92
93 CDCTrajectory2D& trajectory2D = segment.getTrajectory2D();
94 if (not trajectory2D.isFitted()) {
95 getRiemannFitter().update(trajectory2D, segment);
96 }
97 return trajectory2D;
98
99}
100
101
102
104 axialSegmentPair) const
105{
106 CDCTrajectory2D& trajectory2D = axialSegmentPair.getTrajectory2D();
107 if (not trajectory2D.isFitted()) {
108 getRiemannFitter().update(trajectory2D, axialSegmentPair);
109 }
110 return trajectory2D;
111}
Class representing a pair of reconstructed axial segements 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.
void update(CDCTrajectory2D &trajectory2D, const CDCObservations2D &observations2D) const
Update the trajectory with a fit to the observations.
void useOnlyOrientation()
Setup the fitter to use only reference position and the drift length with right left orientation.
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:39
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.
const CDCRiemannFitter & getRiemannFitter() const
Returns the xy fitter instance that is used by this filter.
const CDCTrajectory2D & getFittedTrajectory2D(const CDCAxialSegment2D &segment) const
Returns the trajectory of the axial segment. Also fits it if necessary.
Weight operator()(const CDCAxialSegmentPair &axialSegmentPair) final
Checks if a pair of axial segments is a good combination.
CDCRiemannFitter m_riemannFitter
Memory of the Riemann fitter for the circle fits.
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.