Belle II Software development
SimpleSegmentPairFilter.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/segmentPair/SimpleSegmentPairFilter.h>
9
10#include <tracking/trackFindingCDC/fitting/CDCAxialStereoFusion.h>
11
12#include <tracking/trackingUtilities/eventdata/tracks/CDCSegmentPair.h>
13#include <tracking/trackingUtilities/eventdata/segments/CDCSegment2D.h>
14#include <tracking/trackingUtilities/eventdata/trajectories/CDCTrajectory3D.h>
15#include <tracking/trackingUtilities/eventdata/trajectories/CDCTrajectory2D.h>
16
17#include <tracking/trackingUtilities/geometry/Vector2D.h>
18
19using namespace Belle2;
20using namespace TrackFindingCDC;
21using namespace TrackingUtilities;
22
24{
25 const CDCSegment2D* ptrFromSegment = segmentPair.getFromSegment();
26 const CDCSegment2D* ptrToSegment = segmentPair.getToSegment();
27
28 assert(ptrFromSegment);
29 assert(ptrToSegment);
30
31 const CDCSegment2D& fromSegment = *ptrFromSegment;
32 const CDCSegment2D& toSegment = *ptrToSegment;
33
34 // Do fits
35 const CDCTrajectory2D& fromFit = getFittedTrajectory2D(fromSegment);
36 const CDCTrajectory2D& toFit = getFittedTrajectory2D(toSegment);
37
38 // Check if segments are coaligned
39 bool toSegmentIsCoaligned = fromFit.getTotalArcLength2D(toSegment) >= 0.0;
40 bool fromSegmentIsCoaligned = toFit.getTotalArcLength2D(fromSegment) >= 0.0;
41
42 if (not toSegmentIsCoaligned or not fromSegmentIsCoaligned) {
43 return NAN;
44 }
45
46 // Check if there is a positive gap between from and to segment
47 double fromFitGap = fromFit.getArcLength2DGap(fromSegment, toSegment);
48 double toFitGap = toFit.getArcLength2DGap(fromSegment, toSegment);
49
50 if (fromFitGap < -5 or fromFitGap > 50 or toFitGap < -5 or toFitGap > 50) {
51 return NAN;
52 }
53
54 double fromFitFrontOffset = fromFit.getArcLength2DFrontOffset(fromSegment, toSegment);
55 double toFitBackOffset = toFit.getArcLength2DBackOffset(fromSegment, toSegment);
56
57 if (fromFitFrontOffset < 0 or
58 fromFitFrontOffset > 50 or
59 toFitBackOffset < 0 or
60 toFitBackOffset > 50) {
61 return NAN;
62 }
63
64 Vector2D fromBackRecoPos2D = fromSegment.back().getRecoPos2D();
65 Vector2D toFrontRecoPos2D = toSegment.front().getRecoPos2D();
66
67 // Momentum agreement cut
68 Vector2D fromMom2DAtFromBack = fromFit.getFlightDirection2D(fromBackRecoPos2D);
69 Vector2D toMom2DAtToFront = toFit.getFlightDirection2D(toFrontRecoPos2D);
70
71 Vector2D fromMom2DAtToFront = fromFit.getFlightDirection2D(toFrontRecoPos2D);
72 Vector2D toMom2DAtFromBack = toFit.getFlightDirection2D(fromBackRecoPos2D);
73
74 double momAngleAtFromBack = fromMom2DAtFromBack.angleWith(toMom2DAtFromBack);
75 double momAngleAtToFront = toMom2DAtToFront.angleWith(fromMom2DAtToFront);
76
77 if (fabs(momAngleAtToFront) > 1.0 or fabs(momAngleAtFromBack) > 1.0) {
78 return NAN;
79 }
80
81 // Proximity cut
82 double fromFit_dist2DToFront_toSegment = fromFit.getDist2D(toSegment.front().getRecoPos2D());
83 double toFit_dist2DToBack_fromSegment = toFit.getDist2D(fromSegment.back().getRecoPos2D());
84
85 if (fromFit_dist2DToFront_toSegment < 10 and toFit_dist2DToBack_fromSegment < 10) {
86 getFittedTrajectory3D(segmentPair);
87 return fromSegment.size() + toSegment.size();
88 } else {
89 return NAN;
90 }
91}
92
94{
95 CDCTrajectory2D& trajectory2D = segment.getTrajectory2D();
96 if (not trajectory2D.isFitted()) {
97 getRiemannFitter().update(trajectory2D, segment);
98 }
99 return trajectory2D;
100}
101
103{
104 const CDCSegment2D* ptrFromSegment = segmentPair.getFromSegment();
105 const CDCSegment2D* ptrToSegment = segmentPair.getToSegment();
106
107 const CDCSegment2D& fromSegment = *ptrFromSegment;
108 const CDCSegment2D& toSegment = *ptrToSegment;
109
110 // Do fits if still necessary.
111 getFittedTrajectory2D(fromSegment);
112 getFittedTrajectory2D(toSegment);
113
114 CDCAxialStereoFusion fusionFit;
115 fusionFit.reconstructFuseTrajectories(segmentPair);
116 return segmentPair.getTrajectory3D();
117}
Utility class implementing the Kalmanesk combination of to two dimensional trajectories to one three ...
void reconstructFuseTrajectories(const TrackingUtilities::CDCSegmentPair &segmentPair)
Combine the two trajectories of the segments in the pair and assign the resulting three dimensional t...
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::CDCSegment2D &segment) const
Returns the trajectory of the segment. Also fits it if necessary.
TrackingUtilities::Weight operator()(const TrackingUtilities::CDCSegmentPair &segmentPair) final
Checks if a pair of segments is a good combination.
const TrackingUtilities::CDCTrajectory3D & getFittedTrajectory3D(const TrackingUtilities::CDCSegmentPair &segmentPair) const
Returns the three dimensional trajectory of the axial stereo segment pair.
A reconstructed sequence of two dimensional hits in one super layer.
Class representing a pair of one reconstructed axial segment and one stereo segment in adjacent super...
const CDCSegment2D * getToSegment() const
Getter for the to segment.
CDCTrajectory3D & getTrajectory3D() const
Getter for the three dimensional trajectory.
const CDCSegment2D * getFromSegment() const
Getter for the from 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.
Particle full three dimensional trajectory.
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.