Belle II Software  release-05-01-25
SimpleAxialSegmentPairFilter.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2014 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <tracking/trackFindingCDC/filters/axialSegmentPair/SimpleAxialSegmentPairFilter.h>
11 
12 #include <tracking/trackFindingCDC/eventdata/tracks/CDCAxialSegmentPair.h>
13 #include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
14 
15 using namespace Belle2;
16 using namespace TrackFindingCDC;
17 
19 {
21 }
22 
24 {
25  const CDCAxialSegment2D* ptrStartSegment = axialSegmentPair.getStartSegment();
26  const CDCAxialSegment2D* ptrEndSegment = axialSegmentPair.getEndSegment();
27 
28  assert(ptrStartSegment);
29  assert(ptrEndSegment);
30 
31  const CDCAxialSegment2D& startSegment = *ptrStartSegment;
32  const CDCAxialSegment2D& endSegment = *ptrEndSegment;
33 
34  // Do fits
35  const CDCTrajectory2D& startFit = getFittedTrajectory2D(startSegment);
36  const CDCTrajectory2D& endFit = getFittedTrajectory2D(endSegment);
37 
38  // Check if segments are coaligned
39  bool endSegmentIsCoaligned = startFit.getTotalArcLength2D(endSegment) >= 0.0;
40  bool startSegmentIsCoaligned = endFit.getTotalArcLength2D(startSegment) >= 0.0;
41 
42  if (not endSegmentIsCoaligned or not startSegmentIsCoaligned) {
43  return NAN;
44  }
45 
46  // Check if there is a positive gap between start and end segment
47  double startFitGap = startFit.getArcLength2DGap(startSegment, endSegment);
48  double endFitGap = endFit.getArcLength2DGap(startSegment, endSegment);
49 
50  if (startFitGap < 0 or startFitGap > 100 or endFitGap < 0 or endFitGap > 100) {
51  return NAN;
52  }
53 
54  double startFitFrontOffset = startFit.getArcLength2DFrontOffset(startSegment, endSegment);
55  double endFitBackOffset = endFit.getArcLength2DBackOffset(startSegment, endSegment);
56 
57  if (startFitFrontOffset < 0 or endFitBackOffset < 0) {
58  return NAN;
59  }
60 
61  Vector2D startBackRecoPos2D = startSegment.back().getRecoPos2D();
62  Vector2D endFrontRecoPos2D = endSegment.front().getRecoPos2D();
63 
64  // Momentum agreement cut
65  Vector2D startMom2DAtStartBack = startFit.getFlightDirection2D(startBackRecoPos2D);
66  Vector2D endMom2DAtEndFront = endFit.getFlightDirection2D(endFrontRecoPos2D);
67 
68  Vector2D startMom2DAtEndFront = startFit.getFlightDirection2D(endFrontRecoPos2D);
69  Vector2D endMom2DAtStartBack = endFit.getFlightDirection2D(startBackRecoPos2D);
70 
71  double momAngleAtStartBack = startMom2DAtStartBack.angleWith(endMom2DAtStartBack);
72  double momAngleAtEndFront = endMom2DAtEndFront.angleWith(startMom2DAtEndFront);
73 
74  if (fabs(momAngleAtEndFront) > 2.0 or fabs(momAngleAtStartBack) > 2.0) {
75  return NAN;
76  }
77 
78  // Proximity cut
79  double startFit_dist2DToFront_endSegment = startFit.getDist2D(endFrontRecoPos2D);
80  double endFit_dist2DToBack_startSegment = endFit.getDist2D(startBackRecoPos2D);
81 
82  if (startFit_dist2DToFront_endSegment < 6 and endFit_dist2DToBack_startSegment < 6) {
83  return startSegment.size() + endSegment.size();
84  } else {
85  return NAN;
86  }
87 
88 }
89 
90 
91 
93 {
94 
95  CDCTrajectory2D& trajectory2D = segment.getTrajectory2D();
96  if (not trajectory2D.isFitted()) {
97  getRiemannFitter().update(trajectory2D, segment);
98  }
99  return trajectory2D;
100 
101 }
102 
103 
104 
106  axialSegmentPair) const
107 {
108  CDCTrajectory2D& trajectory2D = axialSegmentPair.getTrajectory2D();
109  if (not trajectory2D.isFitted()) {
110  getRiemannFitter().update(trajectory2D, axialSegmentPair);
111  }
112  return trajectory2D;
113 }
Belle2::TrackFindingCDC::CDCTrajectory2D::getArcLength2DFrontOffset
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...
Definition: CDCTrajectory2D.h:232
Belle2::TrackFindingCDC::CDCTrajectory2D::getTotalArcLength2D
double getTotalArcLength2D(const AHits &hits) const
Calculates the perpendicular travel distance from the first position of the hits to the last position...
Definition: CDCTrajectory2D.h:254
Belle2::TrackFindingCDC::CDCAxialSegmentPair::getStartSegment
const CDCAxialSegment2D * getStartSegment() const
Getter for the start segment.
Definition: CDCAxialSegmentPair.h:99
Belle2::TrackFindingCDC::Vector2D
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:37
Belle2::TrackFindingCDC::SimpleAxialSegmentPairFilter::getRiemannFitter
const CDCRiemannFitter & getRiemannFitter() const
Returns the xy fitter instance that is used by this filter.
Definition: SimpleAxialSegmentPairFilter.h:50
Belle2::TrackFindingCDC::SimpleAxialSegmentPairFilter::getFittedTrajectory2D
const CDCTrajectory2D & getFittedTrajectory2D(const CDCAxialSegment2D &segment) const
Returns the trajectory of the axial segment. Also fits it if necessary.
Definition: SimpleAxialSegmentPairFilter.cc:92
Belle2::TrackFindingCDC::CDCFitter2D::useOnlyOrientation
void useOnlyOrientation()
Setup the fitter to use only reference position and the drift length with right left orientation.
Definition: CDCFitter2D.icc.h:216
Belle2::TrackFindingCDC::CDCTrajectory2D
Particle trajectory as it is seen in xy projection represented as a circle.
Definition: CDCTrajectory2D.h:46
Belle2::TrackFindingCDC::CDCAxialSegmentPair::getEndSegment
const CDCAxialSegment2D * getEndSegment() const
Getter for the end segment.
Definition: CDCAxialSegmentPair.h:111
Belle2::TrackFindingCDC::CDCFitter2D::update
void update(CDCTrajectory2D &trajectory2D, const CDCObservations2D &observations2D) const
Update the trajectory with a fit to the observations.
Definition: CDCFitter2D.icc.h:62
Belle2::TrackFindingCDC::SimpleAxialSegmentPairFilter::operator()
Weight operator()(const CDCAxialSegmentPair &axialSegmentPair) final
Checks if a pair of axial segments is a good combination.
Definition: SimpleAxialSegmentPairFilter.cc:23
Belle2::TrackFindingCDC::CDCAxialSegmentPair
Class representing a pair of reconstructed axial segements in adjacent superlayer.
Definition: CDCAxialSegmentPair.h:41
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::SimpleAxialSegmentPairFilter::m_riemannFitter
CDCRiemannFitter m_riemannFitter
Memory of the Riemann fitter for the circle fits.
Definition: SimpleAxialSegmentPairFilter.h:55
Belle2::TrackFindingCDC::CDCTrajectory2D::getFlightDirection2D
Vector2D getFlightDirection2D(const Vector2D &point) const
Get the unit direction of flight at the given point, where arcLength2D = 0.
Definition: CDCTrajectory2D.h:320
Belle2::TrackFindingCDC::CDCAxialSegmentPair::getTrajectory2D
CDCTrajectory2D & getTrajectory2D() const
Getter for the trajectory of the two dimensional trajectory.
Definition: CDCAxialSegmentPair.h:131
Belle2::TrackFindingCDC::CDCTrajectory2D::isFitted
bool isFitted() const
Checks if the circle is already set to a valid value.
Definition: CDCTrajectory2D.cc:85
Belle2::TrackFindingCDC::CDCTrajectory2D::getArcLength2DGap
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...
Definition: CDCTrajectory2D.h:220
Belle2::TrackFindingCDC::CDCSegment2D
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:40
Belle2::TrackFindingCDC::CDCTrajectory2D::getDist2D
double getDist2D(const Vector2D &point) const
Calculates the distance from the point to the trajectory as seen from the xy projection.
Definition: CDCTrajectory2D.h:419
Belle2::TrackFindingCDC::Vector2D::angleWith
double angleWith(const Vector2D &rhs) const
The angle between this and rhs.
Definition: Vector2D.h:211
Belle2::TrackFindingCDC::CDCTrajectory2D::getArcLength2DBackOffset
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...
Definition: CDCTrajectory2D.h:244
Belle2::TrackFindingCDC::SimpleAxialSegmentPairFilter::SimpleAxialSegmentPairFilter
SimpleAxialSegmentPairFilter()
Constructor.
Definition: SimpleAxialSegmentPairFilter.cc:18