Belle II Software development
MCSegmentPairRelationFilter Class Reference

Class filtering the neighborhood of axial stereo segment pairs with monte carlo information. More...

#include <MCSegmentPairRelationFilter.h>

Inheritance diagram for MCSegmentPairRelationFilter:
MCSymmetric< BaseSegmentPairRelationFilter > BaseSegmentPairRelationFilter RelationFilter< const CDCSegmentPair > 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

 MCSegmentPairRelationFilter (bool allowReverse=true)
 Constructor setting to default reversal symmetry.
 
void exposeParameters (ModuleParamList *moduleParamList, const std::string &prefix) final
 Expose the parameters to a module.
 
void initialize () final
 Initialize the before event processing.
 
Weight operator() (const CDCSegmentPair &fromSegmentPair, const CDCSegmentPair &toSegmentPair) final
 Main filter method returning the weight of the neighborhood relation.
 
void setAllowReverse (bool allowReverse) final
 Setter for the allow reverse parameter.
 
void beginEvent () override
 Signal the beginning of a new event.
 
bool needsTruthInformation () final
 Indicates that the filter requires Monte Carlo information.
 
bool getAllowReverse () const
 Getter for the allow reverse parameter.
 
std::vector< const CDCSegmentPair * > getPossibleTos (const CDCSegmentPair *from, const std::vector< const CDCSegmentPair * > &segmentPairs) const final
 Returns the segment pairs form the range that continue on the to site of the given segment pair.
 
virtual std::vector< const CDCSegmentPair * > getPossibleTos (const CDCSegmentPair *from, const std::vector< const CDCSegmentPair * > &objects) const
 Selects the objects possibly related to the given one from the given pool of objects.
 
virtual Weight operator() (const const CDCSegmentPair &from, const const CDCSegmentPair &to)
 Main filter method returning the weight of the neighborhood relation.
 
virtual std::vector< float > operator() (const std::vector< Relation< const CDCSegmentPair > * > &objs) override
 Filter over a vector of relations.
 
Weight operator() (const Relation< const CDCSegmentPair > &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< BaseSegmentPairRelationFilter >
 Type of the super class.
 

Private Attributes

MCSegmentPairFilter m_mcSegmentPairFilter
 Instance of the Monte Carlo axial stereo segment filter for rejection of false cells.
 
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

Class filtering the neighborhood of axial stereo segment pairs with monte carlo information.

Definition at line 23 of file MCSegmentPairRelationFilter.h.

Member Typedef Documentation

◆ Interface

using Interface = Filter<AObject>
inherited

Mark this class as the basic interface.

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

◆ Object

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 MCSegmentPairRelationFilter.h.

Constructor & Destructor Documentation

◆ MCSegmentPairRelationFilter()

MCSegmentPairRelationFilter ( bool  allowReverse = true)
explicit

Constructor setting to default reversal symmetry.

Definition at line 20 of file MCSegmentPairRelationFilter.cc.

21 : Super(allowReverse)
22 , m_mcSegmentPairFilter(allowReverse)
23{
25}
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
MCSymmetric< BaseSegmentPairRelationFilter > Super
Type of the super class.
MCSegmentPairFilter m_mcSegmentPairFilter
Instance of the Monte Carlo axial stereo segment filter for rejection of false cells.

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()

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 LayerRelationFilter< AFilter >, FourHitFilter, QualityIndicatorFilter, ThreeHitFilter, TwoHitVirtualIPFilter, TwoHitVirtualIPQIFilter, RecoTrackStorer, ROIFinder, SpacePointLoaderAndPreparer, and TrackCandidateResultRefiner.

Definition at line 23 of file CompositeProcessingSignalListener.cc.

24{
27 psl->beginRun();
28 }
29}
Interface for an algorithm part that needs to receive the module processing signals.
virtual void beginRun()
Receive signal for the beginning of a new run.

◆ 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 parameters to a module.

Reimplemented from Filter< AObject >.

Definition at line 27 of file MCSegmentPairRelationFilter.cc.

29{
30 m_mcSegmentPairFilter.exposeParameters(moduleParamList, prefix);
31}
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the set of parameters of the filter to the module parameter list.

◆ getAllowReverse()

bool getAllowReverse
inherited

Getter for the allow reverse parameter.

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

76 {
78 }
bool m_param_allowReverse
Switch to indicate if the reversed version of the object shall also be accepted (default is true).

◆ 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 CDCSegmentPair * > getPossibleTos ( const CDCSegmentPair from,
const std::vector< const CDCSegmentPair * > &  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 }

◆ getPossibleTos() [2/2]

std::vector< const CDCSegmentPair * > getPossibleTos ( const CDCSegmentPair from,
const std::vector< const CDCSegmentPair * > &  segmentPairs 
) const
finalinherited

Returns the segment pairs form the range that continue on the to site of the given segment pair.

Definition at line 29 of file BaseSegmentPairRelationFilter.cc.

32{
33 assert(std::is_sorted(segmentPairs.begin(), segmentPairs.end(), LessOf<Deref>()) &&
34 "Expected segment pairs to be sorted");
35
36 const CDCSegment2D* toSegment = from->getToSegment();
37
39 std::equal_range(segmentPairs.begin(), segmentPairs.end(), &toSegment, LessOf<Deref>())};
40 return {neighbors.begin(), neighbors.end()};
41}
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:39
const CDCSegment2D * getToSegment() const
Getter for the to segment.
A pair of iterators usable with the range base for loop.
Definition: Range.h:25
Iterator begin() const
Begin of the range for range based for.
Definition: Range.h:64
Functor factory turning a binary functor and two functors into a new functor which executes the binar...
Definition: Functional.h:127

◆ initialize()

void initialize ( )
finalvirtual

Initialize the before event processing.

Reimplemented from ProcessingSignalListener.

Definition at line 33 of file MCSegmentPairRelationFilter.cc.

34{
37}
void setAllowReverse(bool allowReverse) final
Setter for the allow reverse parameter.
void initialize() override
Initialize the before event processing.
bool getAllowReverse() const
Getter for the allow reverse parameter.

◆ needsTruthInformation()

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/7]

Weight operator() ( const CDCSegmentPair fromSegmentPair,
const CDCSegmentPair toSegmentPair 
)
final

Main filter method returning the weight of the neighborhood relation.

Return NAN if relation shall be rejected.

Definition at line 39 of file MCSegmentPairRelationFilter.cc.

41{
42 Weight mcFromPairWeight = m_mcSegmentPairFilter(fromSegmentPair);
43 Weight mcToPairWeight = m_mcSegmentPairFilter(toSegmentPair);
44
45 ESign fromFBInfo = sign(mcFromPairWeight);
46 ESign toFBInfo = sign(mcToPairWeight);
47
48 if (isValid(fromFBInfo) and isValid(toFBInfo) and fromFBInfo == toFBInfo) {
49 ESign commonFBInfo = fromFBInfo;
50
51 size_t fromOverlapSize = fromSegmentPair.getToSegment()->size();
52 size_t fromSize = fromOverlapSize + fromSegmentPair.getFromSegment()->size();
53 Weight fromWeight = fromSegmentPair.getAutomatonCell().getCellWeight();
54
55 size_t toOverlapSize = toSegmentPair.getFromSegment()->size();
56 size_t toSize = toOverlapSize + toSegmentPair.getToSegment()->size();
57 Weight toWeight = toSegmentPair.getAutomatonCell().getCellWeight();
58 double overlapWeight =
59 (fromWeight * fromOverlapSize / fromSize + toWeight * toOverlapSize / toSize) / 2.0;
60
61 if (commonFBInfo < 0 and Super::getAllowReverse()) {
62 return -std::fabs(overlapWeight);
63 } else if (commonFBInfo > 0) {
64 return std::fabs(overlapWeight);
65 } else {
66 return NAN;
67 }
68 } else {
69 return NAN;
70 }
71}
Weight getCellWeight() const
Getter for the cell weight.
AutomatonCell & getAutomatonCell() const
Mutable getter for the automaton cell.
const CDCSegment2D * getFromSegment() const
Getter for the from segment.
ESign
Enumeration for the distinct sign values of floating point variables.
Definition: ESign.h:27
bool isValid(EForwardBackward eForwardBackward)
Check whether the given enum instance is one of the valid values.

◆ operator()() [2/7]

Weight operator() ( const const CDCSegmentPair from,
const const CDCSegmentPair 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()() [3/7]

◆ operator()() [4/7]

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 58 of file Filter.icc.h.

59 {
60 return obj ? operator()(*obj) : NAN;
61 }
virtual Weight operator()(const Object &obj)
Function to evaluate the object.
Definition: Filter.icc.h:52

◆ operator()() [5/7]

Weight operator() ( const Relation< const CDCSegmentPair > &  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 }
virtual Weight operator()(const const CDCSegmentPair &from, const const CDCSegmentPair &to)
Main filter method returning the weight of the neighborhood relation.

◆ operator()() [6/7]

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

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

65 {
66 std::vector<float> out;
67 for (const auto& obj : objs) {
68 out.push_back(operator()(obj));
69 }
70 return out;
71 }

◆ operator()() [7/7]

virtual std::vector< float > operator() ( const std::vector< Relation< const CDCSegmentPair > * > &  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.

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 }

◆ setAllowReverse()

void setAllowReverse ( bool  allowReverse)
inlinefinalvirtual

Setter for the allow reverse parameter.

Reimplemented from MCSymmetric< BaseSegmentPairRelationFilter >.

Definition at line 48 of file MCSegmentPairRelationFilter.h.

48 {
49 Super::setAllowReverse(allowReverse);
51 }
virtual void setAllowReverse(bool allowReverse)
Setter for the allow reverse parameter.

◆ terminate()

void terminate ( )
overridevirtualinherited

Receive and dispatch Signal for termination of the event processing.

Reimplemented from ProcessingSignalListener.

Reimplemented in StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::HyperHough >, StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::QuadraticLegendre >, and StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::Z0TanLambdaLegendre >.

Definition at line 47 of file CompositeProcessingSignalListener.cc.

48{
50 psl->terminate();
51 }
53}
virtual void terminate()
Receive Signal for termination of the event processing.

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_mcSegmentPairFilter

MCSegmentPairFilter m_mcSegmentPairFilter
private

Instance of the Monte Carlo axial stereo segment filter for rejection of false cells.

Definition at line 55 of file MCSegmentPairRelationFilter.h.

◆ m_param_allowReverse

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_subordinaryProcessingSignalListeners

std::vector<ProcessingSignalListener*> m_subordinaryProcessingSignalListeners
privateinherited

References to subordinary signal processing listener contained in this findlet.

Definition at line 52 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: