Belle II Software development
MCSegmentRelationFilter Class Reference

Filter for the construction of segment relations based on MC information. More...

#include <MCSegmentRelationFilter.h>

Inheritance diagram for MCSegmentRelationFilter:
MCSymmetric< BaseSegmentRelationFilter > BaseSegmentRelationFilter RelationFilter< const CDCSegment2D > Filter< AObject > CompositeProcessingSignalListener ProcessingSignalListener

Public Types

using Object = AObject
 Type of the object to be analysed.
 
using Interface = Filter<AObject>
 Mark this class as the basic interface.
 

Public Member Functions

 MCSegmentRelationFilter (bool allowReverse=true)
 Constructor.
 
void exposeParameters (ModuleParamList *moduleParamList, const std::string &prefix) final
 Expose the set of parameters of the filter to the module parameter list.
 
void initialize () override
 Initialize the before event processing.
 
void initialize () override
 Initialize the before event processing.
 
void beginEvent () override
 Signal the beginning of a new event.
 
void beginEvent () override
 Signal the beginning of a new event.
 
bool needsTruthInformation () final
 Indicates that the filter requires Monte Carlo information.
 
bool needsTruthInformation () final
 Indicates that the filter requires Monte Carlo information.
 
virtual void setAllowReverse (bool allowReverse)
 Setter for the allow reverse parameter.
 
virtual void setAllowReverse (bool allowReverse)
 Setter for the allow reverse parameter.
 
bool getAllowReverse () const
 Getter for the allow reverse parameter.
 
bool getAllowReverse () const
 Getter for the allow reverse parameter.
 
std::vector< const CDCSegment2D * > getPossibleTos (const CDCSegment2D *from, const std::vector< const CDCSegment2D * > &segments) const final
 Returns all equivalent segment in the range.
 
virtual std::vector< const CDCSegment2D * > getPossibleTos (const CDCSegment2D *from, const std::vector< const CDCSegment2D * > &objects) const
 Selects the objects possibly related to the given one from the given pool of objects.
 
Weight operator() (const Relation< const CDCSegment2D > &relation) override
 Main filter method overriding the filter interface method.
 
virtual Weight operator() (const const CDCSegment2D &from, const const CDCSegment2D &to)
 Main filter method returning the weight of the neighborhood relation.
 
virtual std::vector< float > operator() (const std::vector< Relation< const CDCSegment2D > * > &objs) override
 Filter over a vector of relations.
 
virtual Weight operator() (const const CDCSegment2D &from, const const CDCSegment2D &to)
 Main filter method returning the weight of the neighborhood relation.
 
Weight operator() (const Relation< const CDCSegment2D > &relation) override
 Main filter method overriding the filter interface method.
 
virtual Weight operator() (const Object &obj)
 Function to evaluate the object.
 
Weight operator() (const Object *obj)
 Function to evaluate the object.
 
virtual std::vector< float > operator() (const std::vector< Object * > &objs)
 Function to evaluate a vector of objects Base implementation applies the function to each object.
 
void beginRun () override
 Receive and dispatch signal for the beginning of a new run.
 
void endRun () override
 Receive and dispatch signal for the end of the run.
 
void terminate () override
 Receive and dispatch Signal for termination of the event processing.
 

Protected Member Functions

void addProcessingSignalListener (ProcessingSignalListener *psl)
 Register a processing signal listener to be notified.
 
int getNProcessingSignalListener ()
 Get the number of currently registered listeners.
 

Private Types

using Super = MCSymmetric<BaseSegmentRelationFilter >
 Type of the super class.
 

Private Member Functions

Weight operator() (const CDCSegment2D &fromSegment, const CDCSegment2D &toSegment) final
 Checks if a segment relation is a good combination.
 

Private Attributes

bool m_param_requireRLPure = false
 Parameter : Switch to require the segment combination contain mostly correct rl information.
 
bool m_param_allowReverse
 Switch to indicate if the reversed version of the object shall also be accepted (default is true).
 
bool m_param_allowReverse
 Switch to indicate if the reversed version of the object shall also be accepted (default is true).
 
std::vector< ProcessingSignalListener * > m_subordinaryProcessingSignalListeners
 References to subordinary signal processing listener contained in this findlet.
 
bool m_initialized = false
 Flag to keep track whether initialization happened before.
 
bool m_terminated = false
 Flag to keep track whether termination happened before.
 
std::string m_initializedAs
 Name of the type during initialisation.
 

Detailed Description

Filter for the construction of segment relations based on MC information.

Definition at line 23 of file MCSegmentRelationFilter.h.

Member Typedef Documentation

◆ Interface

template<class AObject>
using Interface = Filter<AObject>
inherited

Mark this class as the basic interface.

Definition at line 38 of file Filter.dcl.h.

◆ Object

template<class AObject>
using Object = AObject
inherited

Type of the object to be analysed.

Definition at line 35 of file Filter.dcl.h.

◆ Super

Type of the super class.

Definition at line 27 of file MCSegmentRelationFilter.h.

Constructor & Destructor Documentation

◆ MCSegmentRelationFilter()

MCSegmentRelationFilter ( bool allowReverse = true)
explicit

Constructor.

Definition at line 27 of file MCSegmentRelationFilter.cc.

28 : Super(allowReverse)
29{
30}
MCSymmetric< BaseSegmentRelationFilter > Super
Type of the super class.

Member Function Documentation

◆ addProcessingSignalListener()

void addProcessingSignalListener ( ProcessingSignalListener * psl)
protectedinherited

Register a processing signal listener to be notified.

Definition at line 55 of file CompositeProcessingSignalListener.cc.

56{
58}
std::vector< ProcessingSignalListener * > m_subordinaryProcessingSignalListeners
References to subordinary signal processing listener contained in this findlet.

◆ beginEvent() [1/2]

void beginEvent ( )
overridevirtualinherited

Signal the beginning of a new event.

Reimplemented from CompositeProcessingSignalListener.

◆ beginEvent() [2/2]

void beginEvent ( )
overridevirtualinherited

Signal the beginning of a new event.

Reimplemented from CompositeProcessingSignalListener.

Definition at line 43 of file MCSymmetricFilter.icc.h.

57 {
58 CDCMCManager::getInstance().fill();
59 Super::beginEvent();
60 }

◆ beginRun()

void beginRun ( )
overridevirtualinherited

Receive and dispatch signal for the beginning of a new run.

Reimplemented from ProcessingSignalListener.

Reimplemented in DATCONSVDClusterizer, LayerPXDRelationFilter< AFilter, APrefilter >, LayerPXDRelationFilter< TrackFindingCDC::ChooseableFilter< PXDPairFilterFactory > >, LayerPXDRelationFilter< TrackFindingCDC::ChooseableFilter< PXDPairFilterFactory > >, LayerSVDRelationFilter< AFilter, APrefilter >, LayerSVDRelationFilter< TrackFindingCDC::ChooseableFilter< SVDPairFilterFactory > >, LayerSVDRelationFilter< TrackFindingCDC::ChooseableFilter< SVDPairFilterFactory > >, SectorMapBasedSVDPairFilter, SimplePXDStateFilter, SimpleSVDStateFilter, CutsFromDBWireHitFilter, MVA< Filter< AVarSet::Object > >, MVA< Filter< typename AVarSet::Object > >, MVA< Filter< typename AVarSet::Object > >, WireHitCreator, FourHitFilter, LayerRelationFilter< AFilter >, LayerRelationFilter< TrackFindingCDC::ChooseableFilter< RelationFilterFactory > >, LayerRelationFilter< TrackFindingCDC::ChooseableFilter< RelationFilterFactory > >, QualityIndicatorFilter, RecoTrackStorer, ROIFinder, SpacePointLoaderAndPreparer, ThreeHitFilter, TrackCandidateResultRefiner, TwoHitVirtualIPFilter, and TwoHitVirtualIPQIFilter.

Definition at line 23 of file CompositeProcessingSignalListener.cc.

24{
27 psl->beginRun();
28 }
29}
virtual void beginRun()
Receive signal for the beginning of a new run.
ProcessingSignalListener()
Allow default construction.

◆ endRun()

void endRun ( )
overridevirtualinherited

Receive and dispatch signal for the end of the run.

Reimplemented from ProcessingSignalListener.

Definition at line 39 of file CompositeProcessingSignalListener.cc.

40{
42 psl->endRun();
43 }
45}
virtual void endRun()
Receive signal for the end of the run.

◆ exposeParameters()

void exposeParameters ( ModuleParamList * moduleParamList,
const std::string & prefix )
finalvirtual

Expose the set of parameters of the filter to the module parameter list.

Reimplemented from CompositeProcessingSignalListener.

Definition at line 32 of file MCSegmentRelationFilter.cc.

34{
35 Super::exposeParameters(moduleParamList, prefix);
36 moduleParamList->addParameter(prefixed(prefix, "requireRLPure"),
38 "Switch to require the segment combination contain mostly correct rl information",
40
41}
bool m_param_requireRLPure
Parameter : Switch to require the segment combination contain mostly correct rl information.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.

◆ getAllowReverse()

bool getAllowReverse ( ) const
inherited

Getter for the allow reverse parameter.

Definition at line 53 of file MCSymmetricFilter.icc.h.

76 {
77 return m_param_allowReverse;
78 }

◆ getNProcessingSignalListener()

int getNProcessingSignalListener ( )
protectedinherited

Get the number of currently registered listeners.

Definition at line 60 of file CompositeProcessingSignalListener.cc.

61{
63}

◆ getPossibleTos() [1/2]

std::vector< const CDCSegment2D * > getPossibleTos ( const CDCSegment2D * from,
const std::vector< const CDCSegment2D * > & segments ) const
finalvirtualinherited

Returns all equivalent segment in the range.

Reimplemented from RelationFilter< const CDCSegment2D >.

Definition at line 36 of file BaseSegmentRelationFilter.cc.

39{
40 assert(std::is_sorted(segments.begin(), segments.end(), LessOf<Deref>()) &&
41 "Expected segments to be sorted");
42
43 ConstVectorRange<const CDCSegment2D*> tos{
44 std::equal_range(segments.begin(), segments.end(), from, LessOf<Deref>())};
45
46 return {tos.begin(), tos.end()};
47}

◆ getPossibleTos() [2/2]

std::vector< const CDCSegment2D * > getPossibleTos ( const CDCSegment2D * from,
const std::vector< const CDCSegment2D * > & objects ) const
virtualinherited

Selects the objects possibly related to the given one from the given pool of objects.

Definition at line 39 of file RelationFilter.icc.h.

30 {
31 return objects;
32 }

◆ initialize() [1/2]

void initialize ( )
overridevirtualinherited

Initialize the before event processing.

Reimplemented from CompositeProcessingSignalListener.

◆ initialize() [2/2]

void initialize ( )
overridevirtualinherited

Initialize the before event processing.

Reimplemented from CompositeProcessingSignalListener.

Definition at line 40 of file MCSymmetricFilter.icc.h.

50 {
51 CDCMCManager::getInstance().requireTruthInformation();
52 Super::initialize();
53 }

◆ needsTruthInformation() [1/2]

bool needsTruthInformation ( )
finalvirtualinherited

Indicates that the filter requires Monte Carlo information.

Reimplemented from Filter< AObject >.

◆ needsTruthInformation() [2/2]

bool needsTruthInformation ( )
finalvirtualinherited

Indicates that the filter requires Monte Carlo information.

Reimplemented from Filter< AObject >.

Definition at line 46 of file MCSymmetricFilter.icc.h.

64 {
65 return true;
66 }

◆ operator()() [1/9]

virtual Weight operator() ( const const CDCSegment2D & from,
const const CDCSegment2D & to )
virtualinherited

Main filter method returning the weight of the neighborhood relation.

Return always returns NAN to reject all segment neighbors.

Reimplemented from RelationFilter< const CDCSegment2D >.

◆ operator()() [2/9]

Weight operator() ( const Relation< const CDCSegment2D > & relation)
overrideinherited

Main filter method overriding the filter interface method.

Checks the validity of the pointers in the relation and unpacks the relation to the method implementing the rejection.

Definition at line 49 of file BaseSegmentRelationFilter.cc.

50{
51 const CDCSegment2D* from = relation.getFrom();
52 const CDCSegment2D* to = relation.getTo();
53 if (from == to) return NAN; // Prevent relation to same.
54 if ((from == nullptr) or (to == nullptr)) return NAN;
55
56 // Make an overlap check to prevent aliases and reverse segments to be linked
57 std::vector<const CDCWireHit*> fromWireHits;
58 fromWireHits.reserve(from->size());
59 for (const CDCRecoHit2D& recoHit2D : *from) {
60 fromWireHits.push_back(&recoHit2D.getWireHit());
61 }
62 std::sort(fromWireHits.begin(), fromWireHits.end());
63 int nOverlap = 0;
64 for (const CDCRecoHit2D& recoHit2D : *to) {
65 if (std::binary_search(fromWireHits.begin(), fromWireHits.end(), &recoHit2D.getWireHit())) {
66 ++nOverlap;
67 }
68 }
69
70 if (1.0 * nOverlap / from->size() > 0.8) {
71 return NAN;
72 }
73
74 return this->operator()(*from, *to);
75}
Weight operator()(const Relation< const CDCSegment2D > &relation) override
Main filter method overriding the filter interface method.
From * getFrom() const
Getter for the pointer to the from side object.
Definition Relation.h:59
To * getTo() const
Getter for the pointer to the to side object.
Definition Relation.h:65

◆ operator()() [3/9]

virtual std::vector< float > operator() ( const std::vector< Relation< const CDCSegment2D > * > & objs)
inlineoverridevirtualinherited

Filter over a vector of relations.

We need to override it since derived relation classes do not implement a call with a pointer to a relation.

Reimplemented from RelationFilter< const CDCSegment2D >.

Definition at line 51 of file RelationFilter.dcl.h.

52 {
53 std::vector<float> out(objs.size());
54 for (size_t iObj = 0; iObj < objs.size(); iObj += 1) {
55 if (objs[iObj]) {
56 out[iObj] = operator()(*objs[iObj]);
57 } else {
58 out[iObj] = NAN;
59 }
60 }
61 return out;
62 }

◆ operator()() [4/9]

template<class AObject>
Weight operator() ( const Object & obj)
virtualinherited

Function to evaluate the object.

Base implementation accepts all objects.

Parameters
objThe object to be accepted or rejected.
Returns
A finite float value if the object is accepted. NAN if the object is rejected.

Reimplemented in AllPXDStateFilter, AllSVDStateFilter, ArcLengthBasedCDCfromEclPathPairFilter, ArcLengthBasedCDCPathPairFilter, Chi2BasedCDCPathPairFilter, DistanceBasedCDCPathPairFilter, DistanceCDCStateFilter, DuplicateCDCPathPairFilter, ExtrapolateAndUpdateCDCStateFilter, HitDistanceBasedCDCPathPairFilter, MCTruthCDCPathPairFilter, MCTruthCDCStateFilter, MCTruthEclSeedFilter, NonIPCrossingStateFilter< AllPXDStateFilter >, NonIPCrossingStateFilter< AllSVDStateFilter >, ResidualSVDStateFilter, RoughCDCfromEclStateFilter, RoughCDCStateFilter, SeedChargeCDCPathFilter, SimplePXDStateFilter, SimpleSVDStateFilter, SizeCDCPathFilter, AllAxialSegmentPairFilter, AllClusterFilter, AllFacetFilter, AllSegmentPairFilter, AllSegmentTripleFilter, AllWireHitFilter, Chi2FacetFilter, CutsFromDBWireHitFilter, FeasibleRLFacetFilter, MCAxialSegmentPairFilter, MCFacetFilter, MCSegmentPairFilter, MCSegmentTripleFilter, MVA< Filter< typename AVarSet::Object > >, OnVarSet< Filter< typename AVarSet::Object > >, RealisticFacetFilter, Recording< Filter< typename AVarSet::Object > >, SimpleAxialSegmentPairFilter, SimpleFacetFilter, SimpleSegmentPairFilter, SimpleSegmentTripleFilter, TruthVarFilter< ATruthVarSet >, and WeightSVDResultFilter.

Definition at line 46 of file Filter.icc.h.

47 {
48 return 1;
49 }

◆ operator()() [5/9]

template<class AObject>
Weight operator() ( const Object * obj)
inherited

Function to evaluate the object.

Base implementation accepts all objects, except nullptr.

Parameters
objThe object to be accepted or rejected.
Returns
A finit float value if the object is accepted. NAN if the object is rejected. Nullptr is always rejected.

Definition at line 52 of file Filter.icc.h.

53 {
54 return obj ? operator()(*obj) : NAN;
55 }

◆ operator()() [6/9]

template<class AObject>
std::vector< float > operator() ( const std::vector< Object * > & objs)
virtualinherited

Function to evaluate a vector of objects Base implementation applies the function to each object.

Can be optimized for MVA filters

Parameters
objsA vector of pointers to objects
Returns
A vector of float or NAN values. See above

Reimplemented in MVA< Filter< typename AVarSet::Object > >.

Definition at line 58 of file Filter.icc.h.

59 {
60 std::vector<float> out;
61 for (const auto& obj : objs) {
62 out.push_back(operator()(obj));
63 }
64 return out;
65 }

◆ operator()() [7/9]

Weight operator() ( const CDCSegment2D & fromSegment,
const CDCSegment2D & toSegment )
finalprivate

Checks if a segment relation is a good combination.

Definition at line 43 of file MCSegmentRelationFilter.cc.

45{
46 const CDCMCSegment2DLookUp& mcSegmentLookUp = CDCMCSegment2DLookUp::getInstance();
47
48 // Check if the segments are aligned correctly along the Monte Carlo track
49 EForwardBackward pairFBInfo =
51 ? mcSegmentLookUp.areAlignedInMCTrackWithRLCheck(&fromSegment, &toSegment)
52 : mcSegmentLookUp.areAlignedInMCTrack(&fromSegment, &toSegment);
53
54 if (pairFBInfo == EForwardBackward::c_Invalid) return NAN;
55
56 if (pairFBInfo == EForwardBackward::c_Forward or
57 (getAllowReverse() and pairFBInfo == EForwardBackward::c_Backward)) {
58
59 // Final check for the distance between the segment
60 Index fromNPassedSuperLayers = mcSegmentLookUp.getLastNPassedSuperLayers(&fromSegment);
61 if (fromNPassedSuperLayers == c_InvalidIndex) return NAN;
62
63 Index toNPassedSuperLayers = mcSegmentLookUp.getFirstNPassedSuperLayers(&toSegment);
64 if (toNPassedSuperLayers == c_InvalidIndex) return NAN;
65
66 // Allow relations only from the same super layer
67 if (fromNPassedSuperLayers != toNPassedSuperLayers) return NAN;
68
69 return fromSegment.size() + toSegment.size();
70 }
71
72 return NAN;
73}
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...
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 ...
static const CDCMCSegment2DLookUp & getInstance()
Getter for the singletone instance.
EForwardBackward
Enumeration to represent the distinct possibilities of the right left passage information.

◆ operator()() [8/9]

Weight operator() ( const const CDCSegment2D & from,
const const CDCSegment2D & to )
virtualinherited

Main filter method returning the weight of the neighborhood relation.

Return always returns NAN to reject all segment neighbors.

Definition at line 46 of file RelationFilter.icc.h.

37 {
38 return 1;
39 }

◆ operator()() [9/9]

Weight operator() ( const Relation< const CDCSegment2D > & relation)
overrideinherited

Main filter method overriding the filter interface method.

Checks the validity of the pointers in the relation and unpacks the relation to the method implementing the rejection.

Definition at line 69 of file RelationFilter.icc.h.

43 {
44 const AObject* from = relation.getFrom();
45 const AObject* to = relation.getTo();
46
47 if (from == to) return NAN; // Prevent relation to same.
48 if ((from == nullptr) or (to == nullptr)) return NAN;
49 return operator()(*from, *to);
50 }

◆ setAllowReverse()

void setAllowReverse ( bool allowReverse)
virtualinherited

Setter for the allow reverse parameter.

Definition at line 50 of file MCSymmetricFilter.icc.h.

70 {
71 m_param_allowReverse = allowReverse;
72 }

◆ terminate()

Member Data Documentation

◆ m_initialized

bool m_initialized = false
privateinherited

Flag to keep track whether initialization happened before.

Definition at line 52 of file ProcessingSignalListener.h.

◆ m_initializedAs

std::string m_initializedAs
privateinherited

Name of the type during initialisation.

Definition at line 58 of file ProcessingSignalListener.h.

◆ m_param_allowReverse [1/2]

bool m_param_allowReverse
privateinherited

Switch to indicate if the reversed version of the object shall also be accepted (default is true).

Definition at line 57 of file MCSymmetricFilter.dcl.h.

◆ m_param_allowReverse [2/2]

bool m_param_allowReverse
privateinherited

Switch to indicate if the reversed version of the object shall also be accepted (default is true).

Definition at line 57 of file MCSymmetricFilter.dcl.h.

◆ m_param_requireRLPure

bool m_param_requireRLPure = false
private

Parameter : Switch to require the segment combination contain mostly correct rl information.

Definition at line 41 of file MCSegmentRelationFilter.h.

◆ m_subordinaryProcessingSignalListeners

std::vector<ProcessingSignalListener*> m_subordinaryProcessingSignalListeners
privateinherited

References to subordinary signal processing listener contained in this findlet.

Definition at line 60 of file CompositeProcessingSignalListener.h.

◆ m_terminated

bool m_terminated = false
privateinherited

Flag to keep track whether termination happened before.

Definition at line 55 of file ProcessingSignalListener.h.


The documentation for this class was generated from the following files: