Belle II Software  release-05-01-25
MCSegmentPairFilter.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/segmentPair/MCSegmentPairFilter.h>
11 
12 #include <tracking/trackFindingCDC/mclookup/CDCMCSegment2DLookUp.h>
13 
14 #include <tracking/trackFindingCDC/eventdata/tracks/CDCSegmentPair.h>
15 #include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
16 
17 #include <tracking/trackFindingCDC/filters/base/MCSymmetricFilter.icc.h>
18 
19 #include <framework/core/ModuleParamList.templateDetails.h>
20 
21 using namespace Belle2;
22 using namespace TrackFindingCDC;
23 
25 
27  : Super(allowReverse)
28 {
29 }
30 
32  const std::string& prefix)
33 {
34  Super::exposeParameters(moduleParamList, prefix);
35  moduleParamList->addParameter(prefixed(prefix, "requireRLPure"),
37  "Switch to require the segment combination contain mostly correct rl information",
39 
40 
41  moduleParamList->addParameter(prefixed(prefix, "minSegmentSize"),
43  "Minimum segment size to pass as monte carlo truth",
45 
46 }
47 
49 {
50  const CDCSegment2D* ptrFromSegment = segmentPair.getFromSegment();
51  const CDCSegment2D* ptrToSegment = segmentPair.getToSegment();
52 
53  assert(ptrFromSegment);
54  assert(ptrToSegment);
55 
56  const CDCSegment2D& fromSegment = *ptrFromSegment;
57  const CDCSegment2D& toSegment = *ptrToSegment;
58 
59  if (static_cast<int>(fromSegment.size()) < m_param_minSegmentSize or
60  static_cast<int>(toSegment.size()) < m_param_minSegmentSize) {
61  return NAN;
62  }
63 
65 
66  // Check if the segments are aligned correctly along the Monte Carlo track
67  EForwardBackward pairFBInfo =
69  ? mcSegmentLookUp.areAlignedInMCTrackWithRLCheck(ptrFromSegment, ptrToSegment)
70  : mcSegmentLookUp.areAlignedInMCTrack(ptrFromSegment, ptrToSegment);
71 
72  if (pairFBInfo == EForwardBackward::c_Invalid) return NAN;
73 
74  if (pairFBInfo == EForwardBackward::c_Forward or
75  (getAllowReverse() and pairFBInfo == EForwardBackward::c_Backward)) {
76  // Final check for the distance between the segment
77  Index fromNPassedSuperLayers = mcSegmentLookUp.getLastNPassedSuperLayers(ptrFromSegment);
78  if (fromNPassedSuperLayers == c_InvalidIndex) return NAN;
79 
80  Index toNPassedSuperLayers = mcSegmentLookUp.getFirstNPassedSuperLayers(ptrToSegment);
81  if (toNPassedSuperLayers == c_InvalidIndex) return NAN;
82 
83  if (abs(fromNPassedSuperLayers - toNPassedSuperLayers) > 1) return NAN;
84 
85  // Do fits
86  if (not segmentPair.getTrajectory3D().isFitted()) {
87  CDCTrajectory3D mcTrajectory3D = mcSegmentLookUp.getTrajectory3D(ptrFromSegment);
88  if (pairFBInfo == EForwardBackward::c_Backward) {
89  mcTrajectory3D.reverse();
90  }
91  segmentPair.setTrajectory3D(mcTrajectory3D);
92  }
93  return pairFBInfo * static_cast<Weight>(fromSegment.size() + toSegment.size());
94  }
95  return NAN;
96 }
Belle2::TrackFindingCDC::MCSymmetric< BaseSegmentPairFilter >::getAllowReverse
bool getAllowReverse() const
Getter for the allow reverse parameter.
Definition: MCSymmetricFilter.icc.h:85
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::areAlignedInMCTrackWithRLCheck
EForwardBackward areAlignedInMCTrackWithRLCheck(const ACDCHitCollection *ptrFromHits, const ACDCHitCollection *ptrToHits) const
Returns if the second collection of hits follows the first collection of hits in their common Monte C...
Definition: CDCMCHitCollectionLookUp.icc.h:327
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::getFirstNPassedSuperLayers
Index getFirstNPassedSuperLayers(const ACDCHitCollection *ptrHits) const
Getter for number of passed superlayer till the first hit the collection of hits which has the Monte ...
Definition: CDCMCHitCollectionLookUp.h:143
Belle2::TrackFindingCDC::CDCSegmentPair
Class representing a pair of one reconstructed axial segement and one stereo segment in adjacent supe...
Definition: CDCSegmentPair.h:44
Belle2::TrackFindingCDC::CDCMCSegment2DLookUp
Specialisation of the lookup for the truth values of two dimensional segments.
Definition: CDCMCSegment2DLookUp.h:33
Belle2::TrackFindingCDC::CDCTrajectory3D::isFitted
bool isFitted() const
Checks if the trajectory has already been set to a valid value.
Definition: CDCTrajectory3D.h:126
Belle2::TrackFindingCDC::MCSymmetric< BaseSegmentPairFilter >
Belle2::TrackFindingCDC::MCSegmentPairFilter::operator()
Weight operator()(const CDCSegmentPair &segmentPair) final
Checks if a axial stereo segment pair is a good combination.
Definition: MCSegmentPairFilter.cc:48
Belle2::TrackFindingCDC::NForwardBackward::EForwardBackward
EForwardBackward
Enumeration to represent the distinct possibilities of the right left passage information.
Definition: EForwardBackward.h:35
Belle2::TrackFindingCDC::CDCMCSegment2DLookUp::getInstance
static const CDCMCSegment2DLookUp & getInstance()
Getter for the singletone instance.
Definition: CDCMCSegment2DLookUp.cc:23
Belle2::TrackFindingCDC::MCSegmentPairFilter::m_param_minSegmentSize
int m_param_minSegmentSize
Parameter : Minimum segment size to pass as monte carlo truth.
Definition: MCSegmentPairFilter.h:53
Belle2::TrackFindingCDC::CDCSegmentPair::getToSegment
const CDCSegment2D * getToSegment() const
Getter for the to segment.
Definition: CDCSegmentPair.h:132
Belle2::TrackFindingCDC::MCSegmentPairFilter::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the set of parameters of the filter to the module parameter list.
Definition: MCSegmentPairFilter.cc:31
Belle2::TrackFindingCDC::MCSegmentPairFilter::m_param_requireRLPure
bool m_param_requireRLPure
Parameter : Switch to require the segment combination contain mostly correct rl information.
Definition: MCSegmentPairFilter.h:50
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::areAlignedInMCTrack
EForwardBackward areAlignedInMCTrack(const ACDCHitCollection *ptrFromHits, const ACDCHitCollection *ptrToHits) const
Returns if the second collection of hits follows the first collection of hits in their common Monte C...
Definition: CDCMCHitCollectionLookUp.icc.h:210
Belle2::ModuleParamList::addParameter
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Definition: ModuleParamList.templateDetails.h:38
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::CDCSegment2D
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:40
Belle2::TrackFindingCDC::CDCSegmentPair::getTrajectory3D
CDCTrajectory3D & getTrajectory3D() const
Getter for the three dimensional trajectory.
Definition: CDCSegmentPair.h:213
Belle2::TrackFindingCDC::MCSegmentPairFilter::MCSegmentPairFilter
MCSegmentPairFilter(bool allowReverse=true)
Constructor.
Definition: MCSegmentPairFilter.cc:26
Belle2::TrackFindingCDC::CDCTrajectory3D::reverse
void reverse()
Reverses the trajectory in place.
Definition: CDCTrajectory3D.h:151
Belle2::ModuleParamList
The Module parameter list class.
Definition: ModuleParamList.h:46
Belle2::TrackFindingCDC::CDCSegmentPair::getFromSegment
const CDCSegment2D * getFromSegment() const
Getter for the from segment.
Definition: CDCSegmentPair.h:120
Belle2::TrackFindingCDC::CDCSegmentPair::setTrajectory3D
void setTrajectory3D(const CDCTrajectory3D &trajectory3D) const
Setter for the three dimensional trajectory.
Definition: CDCSegmentPair.h:207
Belle2::TrackFindingCDC::MCSymmetric< BaseSegmentPairFilter >::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the set of parameters of the filter to the module parameter list.
Definition: MCSymmetricFilter.icc.h:48
Belle2::TrackFindingCDC::CDCTrajectory3D
Particle full three dimensional trajectory.
Definition: CDCTrajectory3D.h:47
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::getTrajectory3D
CDCTrajectory3D getTrajectory3D(const ACDCHitCollection *ptrHits) const
Returns the trajectory of the collection of hits.
Definition: CDCMCHitCollectionLookUp.icc.h:359
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::getLastNPassedSuperLayers
Index getLastNPassedSuperLayers(const ACDCHitCollection *ptrHits) const
Getter for number of passed superlayer till the last hit the collection of hits which has the Monte C...
Definition: CDCMCHitCollectionLookUp.h:147