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