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 <Math/VectorUtil.h>
18#include <Math/Vector2D.h>
19
20using namespace Belle2;
21using namespace TrackFindingCDC;
22using namespace TrackingUtilities;
23
25{
26 const CDCSegment2D* ptrFromSegment = segmentPair.getFromSegment();
27 const CDCSegment2D* ptrToSegment = segmentPair.getToSegment();
28
29 assert(ptrFromSegment);
30 assert(ptrToSegment);
31
32 const CDCSegment2D& fromSegment = *ptrFromSegment;
33 const CDCSegment2D& toSegment = *ptrToSegment;
34
35 // Do fits
36 const CDCTrajectory2D& fromFit = getFittedTrajectory2D(fromSegment);
37 const CDCTrajectory2D& toFit = getFittedTrajectory2D(toSegment);
38
39 // Check if segments are coaligned
40 bool toSegmentIsCoaligned = fromFit.getTotalArcLength2D(toSegment) >= 0.0;
41 bool fromSegmentIsCoaligned = toFit.getTotalArcLength2D(fromSegment) >= 0.0;
42
43 if (not toSegmentIsCoaligned or not fromSegmentIsCoaligned) {
44 return NAN;
45 }
46
47 // Check if there is a positive gap between from and to segment
48 double fromFitGap = fromFit.getArcLength2DGap(fromSegment, toSegment);
49 double toFitGap = toFit.getArcLength2DGap(fromSegment, toSegment);
50
51 if (fromFitGap < -5 or fromFitGap > 50 or toFitGap < -5 or toFitGap > 50) {
52 return NAN;
53 }
54
55 double fromFitFrontOffset = fromFit.getArcLength2DFrontOffset(fromSegment, toSegment);
56 double toFitBackOffset = toFit.getArcLength2DBackOffset(fromSegment, toSegment);
57
58 if (fromFitFrontOffset < 0 or
59 fromFitFrontOffset > 50 or
60 toFitBackOffset < 0 or
61 toFitBackOffset > 50) {
62 return NAN;
63 }
64
65 ROOT::Math::XYVector fromBackRecoPos2D = fromSegment.back().getRecoPos2D();
66 ROOT::Math::XYVector toFrontRecoPos2D = toSegment.front().getRecoPos2D();
67
68 // Momentum agreement cut
69 ROOT::Math::XYVector fromMom2DAtFromBack = fromFit.getFlightDirection2D(fromBackRecoPos2D);
70 ROOT::Math::XYVector toMom2DAtToFront = toFit.getFlightDirection2D(toFrontRecoPos2D);
71
72 ROOT::Math::XYVector fromMom2DAtToFront = fromFit.getFlightDirection2D(toFrontRecoPos2D);
73 ROOT::Math::XYVector toMom2DAtFromBack = toFit.getFlightDirection2D(fromBackRecoPos2D);
74
75 double momAngleAtFromBack = ROOT::Math::VectorUtil::DeltaPhi(fromMom2DAtFromBack, toMom2DAtFromBack);
76 double momAngleAtToFront = ROOT::Math::VectorUtil::DeltaPhi(toMom2DAtToFront, fromMom2DAtToFront);
77
78 if (fabs(momAngleAtToFront) > 1.0 or fabs(momAngleAtFromBack) > 1.0) {
79 return NAN;
80 }
81
82 // Proximity cut
83 double fromFit_dist2DToFront_toSegment = fromFit.getDist2D(toSegment.front().getRecoPos2D());
84 double toFit_dist2DToBack_fromSegment = toFit.getDist2D(fromSegment.back().getRecoPos2D());
85
86 if (fromFit_dist2DToFront_toSegment < 10 and toFit_dist2DToBack_fromSegment < 10) {
87 getFittedTrajectory3D(segmentPair);
88 return fromSegment.size() + toSegment.size();
89 } else {
90 return NAN;
91 }
92}
93
95{
96 CDCTrajectory2D& trajectory2D = segment.getTrajectory2D();
97 if (not trajectory2D.isFitted()) {
98 getRiemannFitter().update(trajectory2D, segment);
99 }
100 return trajectory2D;
101}
102
104{
105 const CDCSegment2D* ptrFromSegment = segmentPair.getFromSegment();
106 const CDCSegment2D* ptrToSegment = segmentPair.getToSegment();
107
108 const CDCSegment2D& fromSegment = *ptrFromSegment;
109 const CDCSegment2D& toSegment = *ptrToSegment;
110
111 // Do fits if still necessary.
112 getFittedTrajectory2D(fromSegment);
113 getFittedTrajectory2D(toSegment);
114
115 CDCAxialStereoFusion fusionFit;
116 fusionFit.reconstructFuseTrajectories(segmentPair);
117 return segmentPair.getTrajectory3D();
118}
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...
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.
Particle full three dimensional trajectory.
Abstract base class for different kinds of events.