Belle II Software development
SegmentPairCreator Class Referenceabstract

Class providing construction combinatorics for the axial stereo segment pairs. More...

#include <SegmentPairCreator.h>

Inheritance diagram for SegmentPairCreator:
Findlet< const TrackingUtilities::CDCSegment2D, TrackingUtilities::CDCSegmentPair > CompositeProcessingSignalListener ProcessingSignalListener

Public Types

using IOTypes
 Types that should be served to apply on invocation.
 
using IOTypes
 Types that should be served to apply on invocation.
 
using IOVectors
 Vector types that should be served to apply on invocation.
 
using IOVectors
 Vector types that should be served to apply on invocation.
 

Public Member Functions

 SegmentPairCreator ()
 Constructor adding the filter as a subordinary processing signal listener.
 
std::string getDescription () final
 Short description of the findlet.
 
void exposeParameters (ModuleParamList *moduleParamList, const std::string &prefix) final
 Expose the parameters to a module.
 
void apply (const std::vector< TrackingUtilities::CDCSegment2D > &inputSegments, std::vector< TrackingUtilities::CDCSegmentPair > &segmentPairs) final
 Main method constructing pairs in adjacent super layers.
 
virtual void apply (ToVector< AIOTypes > &... ioVectors)=0
 Main function executing the algorithm.
 
void initialize () override
 Receive and dispatch signal before the start of the event processing.
 
void beginRun () override
 Receive and dispatch signal for the beginning of a new run.
 
void beginEvent () override
 Receive and dispatch signal for the start of a new event.
 
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 Types

using ToVector
 Short hand for ToRangeImpl.
 
using ToVector
 Short hand for ToRangeImpl.
 

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 = TrackingUtilities::Findlet<const TrackingUtilities::CDCSegment2D, TrackingUtilities::CDCSegmentPair>
 Type of the base class.
 

Private Member Functions

void create (const std::vector< const TrackingUtilities::CDCSegment2D * > &fromSegments, const std::vector< const TrackingUtilities::CDCSegment2D * > &toSegments, std::vector< TrackingUtilities::CDCSegmentPair > &segmentPairs)
 Creates segment pairs from a combination of from segments and to segments.
 

Private Attributes

bool m_param_axialBridging = false
 Parameter : Switch to enable the search for axial to axial pairs to enable more stable reconstruction of the middle stereo.
 
AxialSegmentPairCreator m_axialSegmentPairCreator
 Findlet responsible for the creation of axial axial segment pairs.
 
ChooseableSegmentPairFilter m_segmentPairFilter
 The filter to be used for the segment pair generation.
 
std::array< std::vector< const TrackingUtilities::CDCSegment2D * >, CDC::ISuperLayerUtil::c_Nm_segmentsBySuperLayer
 Structure for the segments grouped by super layer id.
 
std::vector< ProcessingSignalListener * > m_subordinaryProcessingSignalListeners
 References to subordinary signal processing listener contained in this findlet.
 
bool m_initialized
 Flag to keep track whether initialization happened before.
 
bool m_terminated
 Flag to keep track whether termination happened before.
 
std::string m_initializedAs
 Name of the type during initialisation.
 

Detailed Description

Class providing construction combinatorics for the axial stereo segment pairs.

Definition at line 37 of file SegmentPairCreator.h.

Member Typedef Documentation

◆ IOTypes [1/2]

using IOTypes
inherited

Types that should be served to apply on invocation.

Definition at line 30 of file Findlet.h.

◆ IOTypes [2/2]

using IOTypes
inherited

Types that should be served to apply on invocation.

Definition at line 30 of file Findlet.h.

◆ IOVectors [1/2]

using IOVectors
inherited

Vector types that should be served to apply on invocation.

Definition at line 53 of file Findlet.h.

◆ IOVectors [2/2]

using IOVectors
inherited

Vector types that should be served to apply on invocation.

Definition at line 53 of file Findlet.h.

◆ Super

Type of the base class.

Definition at line 42 of file SegmentPairCreator.h.

◆ ToVector [1/2]

using ToVector
protectedinherited

Short hand for ToRangeImpl.

Definition at line 49 of file Findlet.h.

◆ ToVector [2/2]

using ToVector
protectedinherited

Short hand for ToRangeImpl.

Definition at line 49 of file Findlet.h.

Constructor & Destructor Documentation

◆ SegmentPairCreator()

Constructor adding the filter as a subordinary processing signal listener.

Definition at line 28 of file SegmentPairCreator.cc.

29{
32}
ChooseableSegmentPairFilter m_segmentPairFilter
The filter to be used for the segment pair generation.
AxialSegmentPairCreator m_axialSegmentPairCreator
Findlet responsible for the creation of axial axial segment pairs.

Member Function Documentation

◆ addProcessingSignalListener()

void addProcessingSignalListener ( ProcessingSignalListener * psl)
protectedinherited

Register a processing signal listener to be notified.

Definition at line 53 of file CompositeProcessingSignalListener.cc.

56{
58}
Interface for a minimal algorithm part that wants to expose some parameters to a module.
Definition Findlet.h:26

◆ apply()

void apply ( const std::vector< TrackingUtilities::CDCSegment2D > & inputSegments,
std::vector< TrackingUtilities::CDCSegmentPair > & segmentPairs )
final

Main method constructing pairs in adjacent super layers.

Definition at line 51 of file SegmentPairCreator.cc.

53{
54 segmentPairs.reserve(500);
55
56 // Group the segments by their super layer id
57 for (std::vector<const CDCSegment2D*>& segmentsInSuperLayer : m_segmentsBySuperLayer) {
58 segmentsInSuperLayer.clear();
59 }
60
61 for (const CDCSegment2D& segment : inputSegments) {
62 if (segment.empty()) continue;
63 ISuperLayer iSuperLayer = segment.front().getISuperLayer();
64 if (not ISuperLayerUtil::isInvalid(iSuperLayer)) {
65 const CDCSegment2D* ptrSegment = &segment;
66 m_segmentsBySuperLayer[iSuperLayer].push_back(ptrSegment);
67 }
68 }
69
70 // Make pairs of closeby superlayers
71 for (ISuperLayer iSuperLayer = 0; iSuperLayer < ISuperLayerUtil::c_N; ++iSuperLayer) {
72 const std::vector<const CDCSegment2D*>& fromSegments = m_segmentsBySuperLayer[iSuperLayer];
73
74 // Make pairs of this superlayer and the superlayer more to the inside
75 ISuperLayer iSuperLayerIn = ISuperLayerUtil::getNextInwards(iSuperLayer);
76 if (ISuperLayerUtil::isInCDC(iSuperLayerIn)) {
77 const std::vector<const CDCSegment2D*>& toSegments = m_segmentsBySuperLayer[iSuperLayerIn];
78 create(fromSegments, toSegments, segmentPairs);
79 }
80
81 // Make pairs of this superlayer and the superlayer more to the outside
82 ISuperLayer iSuperLayerOut = ISuperLayerUtil::getNextOutwards(iSuperLayer);
83 if (ISuperLayerUtil::isInCDC(iSuperLayerOut)) {
84 const std::vector<const CDCSegment2D*>& toSegments = m_segmentsBySuperLayer[iSuperLayerOut];
85 create(fromSegments, toSegments, segmentPairs);
86 }
87 }
88
89 std::sort(segmentPairs.begin(), segmentPairs.end());
90
91 if (not m_param_axialBridging) return;
92
93 // Memory for the axial axial segment pairs.
94 std::vector<CDCAxialSegmentPair> axialSegmentPairs;
95
96 // Create the axial to axial bridges
97 m_axialSegmentPairCreator.apply(inputSegments, axialSegmentPairs);
98
99 // Make pairs by splitting the axial segment pairs and using the *common* fit as the 3d reconstruction bases
100 for (const CDCAxialSegmentPair& axialSegmentPair : axialSegmentPairs) {
101 const CDCSegment2D* startSegment = axialSegmentPair.getStartSegment();
102 const CDCSegment2D* endSegment = axialSegmentPair.getEndSegment();
103
104 CDCTrajectory2D startCommonTrajectory = axialSegmentPair.getTrajectory2D();
105 if (not startCommonTrajectory.isFitted()) continue;
106
107 CDCTrajectory2D startTrajectory2D = startSegment->getTrajectory2D();
108 startCommonTrajectory.setLocalOrigin(startTrajectory2D.getLocalOrigin());
109 startSegment->setTrajectory2D(startCommonTrajectory);
110 std::vector<const CDCSegment2D*> startSegments{startSegment};
111
112 CDCTrajectory2D endCommonTrajectory = axialSegmentPair.getTrajectory2D();
113 CDCTrajectory2D endTrajectory2D = endSegment->getTrajectory2D();
114 endCommonTrajectory.setLocalOrigin(endTrajectory2D.getLocalOrigin());
115 endSegment->setTrajectory2D(endCommonTrajectory);
116 std::vector<const CDCSegment2D*> endSegments{endSegment};
117
118 if (startSegment->getISuperLayer() == endSegment->getISuperLayer()) {
119 ISuperLayer iSuperLayerCommon = startSegment->getISuperLayer();
120
121 ISuperLayer iSuperLayerIn = ISuperLayerUtil::getNextInwards(iSuperLayerCommon);
122 if (ISuperLayerUtil::isInCDC(iSuperLayerIn)) {
123 const std::vector<const CDCSegment2D*>& middleSegments = m_segmentsBySuperLayer[iSuperLayerIn];
124 create(startSegments, middleSegments, segmentPairs);
125 create(middleSegments, endSegments, segmentPairs);
126 }
127
128 ISuperLayer iSuperLayerOut = ISuperLayerUtil::getNextOutwards(iSuperLayerCommon);
129 if (ISuperLayerUtil::isInCDC(iSuperLayerOut)) {
130 const std::vector<const CDCSegment2D*>& middleSegments = m_segmentsBySuperLayer[iSuperLayerOut];
131 create(startSegments, middleSegments, segmentPairs);
132 create(middleSegments, endSegments, segmentPairs);
133 }
134
135 } else {
136 ISuperLayer iSuperLayerMiddle =
137 (startSegment->getISuperLayer() + endSegment->getISuperLayer()) / 2;
138 const std::vector<const CDCSegment2D*>& middleSegments = m_segmentsBySuperLayer[iSuperLayerMiddle];
139 create(startSegments, middleSegments, segmentPairs);
140 create(middleSegments, endSegments, segmentPairs);
141 }
142 startSegment->setTrajectory2D(startTrajectory2D);
143 endSegment->setTrajectory2D(endTrajectory2D);
144 }
145
146 auto lessPairAndgreaterWeight = [](const CDCSegmentPair & lhs, const CDCSegmentPair & rhs) {
147 if (lhs < rhs) return true;
148 if (rhs < lhs) return false;
149 return lhs.getAutomatonCell().getCellWeight() > rhs.getAutomatonCell().getCellWeight();
150 };
151
152 std::sort(segmentPairs.begin(), segmentPairs.end(), lessPairAndgreaterWeight);
153
154 // auto samePair = [](const CDCSegmentPair& lhs, const CDCSegmentPair& rhs) {
155 // if (lhs < rhs) return false;
156 // if (rhs < lhs) return false;
157 // return true;
158 // };
159 // erase_unique(segmentPairs, samePair);
160}
std::array< std::vector< const TrackingUtilities::CDCSegment2D * >, CDC::ISuperLayerUtil::c_N > m_segmentsBySuperLayer
Structure for the segments grouped by super layer id.
bool m_param_axialBridging
Parameter : Switch to enable the search for axial to axial pairs to enable more stable reconstruction...
void create(const std::vector< const TrackingUtilities::CDCSegment2D * > &fromSegments, const std::vector< const TrackingUtilities::CDCSegment2D * > &toSegments, std::vector< TrackingUtilities::CDCSegmentPair > &segmentPairs)
Creates segment pairs from a combination of from segments and to segments.
Weight getCellWeight() const
Getter for the cell weight.
AutomatonCell & getAutomatonCell() const
Mutable getter for the automaton cell.
double setLocalOrigin(const Vector2D &localOrigin)
Setter for the origin of the local coordinate system.
bool isFitted() const
Checks if the circle is already set to a valid value.
const Vector2D & getLocalOrigin() const
Getter for the origin of the local coordinate system.
signed short ISuperLayer
The type of the layer and superlayer ids.
Definition ISuperLayer.h:24
static const ISuperLayer c_N
Constant representing the total number of cdc superlayers.
Definition ISuperLayer.h:56
static ISuperLayer getNextInwards(ISuperLayer iSuperLayer)
Returns the super layer that is inside of the given super layer.
static bool isInvalid(ISuperLayer iSuperLayer)
Indicates if the given number corresponds to a true cdc superlayer - excludes the logic ids for inner...
static ISuperLayer getNextOutwards(ISuperLayer iSuperLayer)
Returns the super layer that is outside of the given super layer.
static bool isInCDC(ISuperLayer iSuperLayer)
Indicates if the given number corresponds to a true cdc superlayer - excludes the logic ids for inner...

◆ beginEvent()

void beginEvent ( )
overrideinherited

Receive and dispatch signal for the start of a new event.

Definition at line 36 of file CompositeProcessingSignalListener.cc.

32{
35 psl->beginEvent();
36 }
37}
void beginEvent() override
Receive and dispatch signal for the start of a new event.
virtual void beginEvent()
Receive signal for the start of a new event.

◆ beginRun()

void beginRun ( )
overrideinherited

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

Definition at line 33 of file CompositeProcessingSignalListener.cc.

24{
27 psl->beginRun();
28 }
29}
void beginRun() override
Receive and dispatch signal for the beginning of a new run.
virtual void beginRun()
Receive signal for the beginning of a new run.

◆ create()

void create ( const std::vector< const TrackingUtilities::CDCSegment2D * > & fromSegments,
const std::vector< const TrackingUtilities::CDCSegment2D * > & toSegments,
std::vector< TrackingUtilities::CDCSegmentPair > & segmentPairs )
private

Creates segment pairs from a combination of from segments and to segments.

Definition at line 162 of file SegmentPairCreator.cc.

165{
166 CDCSegmentPair segmentPair;
167 for (const CDCSegment2D* ptrFromSegment : fromSegments) {
168 for (const CDCSegment2D* ptrToSegment : toSegments) {
169
170 if (ptrFromSegment == ptrToSegment) continue;
171 segmentPair.setSegments(ptrFromSegment, ptrToSegment);
172 segmentPair.clearTrajectory3D();
173
174 Weight pairWeight = m_segmentPairFilter(segmentPair);
175 if (not std::isnan(pairWeight)) {
176 segmentPair.getAutomatonCell().setCellWeight(pairWeight);
177 segmentPairs.push_back(segmentPair);
178 }
179 }
180 }
181}
void setCellWeight(Weight weight)
Setter for the cell weight.
void setSegments(const CDCSegment2D *fromSegment, const CDCSegment2D *toSegment)
Setter for both segments simultaneously.
void clearTrajectory3D() const
Invalides the currently stored trajectory information.

◆ endRun()

void endRun ( )
overrideinherited

Receive and dispatch signal for the end of the run.

Definition at line 39 of file CompositeProcessingSignalListener.cc.

40{
42 psl->endRun();
43 }
45}
void endRun() override
Receive and dispatch signal for the end of the run.
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 CompositeProcessingSignalListener.

Definition at line 39 of file SegmentPairCreator.cc.

40{
41 m_segmentPairFilter.exposeParameters(moduleParamList, prefix);
42 m_axialSegmentPairCreator.exposeParameters(moduleParamList, prefixed("Axial", prefix));
43
44 moduleParamList->addParameter(prefixed(prefix, "axialBridging"),
46 "Switch to enable the search for axial to axial pairs "
47 "to enable more stable reconstruction of the middle stereo",
49}
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.

◆ getDescription()

std::string getDescription ( )
finalvirtual

Short description of the findlet.

Reimplemented from Findlet< const TrackingUtilities::CDCSegment2D, TrackingUtilities::CDCSegmentPair >.

Definition at line 34 of file SegmentPairCreator.cc.

35{
36 return "Creates axial stereo segment pairs from a set of segments filtered by some acceptance criterion";
37}

◆ getNProcessingSignalListener()

int getNProcessingSignalListener ( )
protectedinherited

Get the number of currently registered listeners.

Definition at line 56 of file CompositeProcessingSignalListener.cc.

61{
63}

◆ initialize()

void initialize ( )
overrideinherited

Receive and dispatch signal before the start of the event processing.

Definition at line 30 of file CompositeProcessingSignalListener.cc.

16{
19 psl->initialize();
20 }
21}
void initialize() override
Receive and dispatch signal before the start of the event processing.
virtual void initialize()
Receive signal before the start of the event processing.

◆ terminate()

void terminate ( )
overrideinherited

Receive and dispatch Signal for termination of the event processing.

Definition at line 42 of file CompositeProcessingSignalListener.cc.

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

Member Data Documentation

◆ m_axialSegmentPairCreator

AxialSegmentPairCreator m_axialSegmentPairCreator
private

Findlet responsible for the creation of axial axial segment pairs.

Definition at line 70 of file SegmentPairCreator.h.

◆ m_initialized

bool m_initialized
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_axialBridging

bool m_param_axialBridging = false
private

Parameter : Switch to enable the search for axial to axial pairs to enable more stable reconstruction of the middle stereo.

Definition at line 66 of file SegmentPairCreator.h.

◆ m_segmentPairFilter

ChooseableSegmentPairFilter m_segmentPairFilter
private

The filter to be used for the segment pair generation.

Definition at line 73 of file SegmentPairCreator.h.

◆ m_segmentsBySuperLayer

std::array<std::vector<const TrackingUtilities::CDCSegment2D*>, CDC::ISuperLayerUtil::c_N> m_segmentsBySuperLayer
private

Structure for the segments grouped by super layer id.

Definition at line 77 of file SegmentPairCreator.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
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: