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