Belle II Software development
SegmentOrienter Class Referenceabstract

Fixes the orientation of segments by a simple heuristic. More...

#include <SegmentOrienter.h>

Inheritance diagram for SegmentOrienter:
Findlet< const CDCSegment2D, CDCSegment2D > CompositeProcessingSignalListener ProcessingSignalListener

Public Types

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

Public Member Functions

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 initialize () final
 Signals the beginning of the event processing.
 
void apply (const std::vector< CDCSegment2D > &inputSegments, std::vector< CDCSegment2D > &outputSegments) final
 Main algorithm applying the adjustment of the orientation.
 
virtual void apply (ToVector< AIOTypes > &... ioVectors)=0
 Main function executing the algorithm.
 
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.
 

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

Private Attributes

std::string m_param_segmentOrientationString = ""
 Parameter: String that states the desired segment orientation.
 
EPreferredDirection m_segmentOrientation = EPreferredDirection::c_None
 Encoded desired segment orientation.
 
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

Fixes the orientation of segments by a simple heuristic.

Definition at line 27 of file SegmentOrienter.h.

Member Typedef Documentation

◆ IOTypes

using IOTypes
inherited

Types that should be served to apply on invocation.

Definition at line 30 of file Findlet.h.

◆ IOVectors

using IOVectors
inherited

Vector types that should be served to apply on invocation.

Definition at line 53 of file Findlet.h.

◆ Super

using Super = Findlet<const CDCSegment2D, CDCSegment2D>
private

Type of the base class.

Definition at line 31 of file SegmentOrienter.h.

◆ ToVector

using ToVector
protectedinherited

Short hand for ToRangeImpl.

Definition at line 49 of file Findlet.h.

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< CDCSegment2D > & inputSegments,
std::vector< CDCSegment2D > & outputSegments )
final

Main algorithm applying the adjustment of the orientation.

Copy segments to output fixing their orientation

Definition at line 52 of file SegmentOrienter.cc.

54{
56 if (m_segmentOrientation == EPreferredDirection::c_None) {
57 // Copy the segments unchanged.
58 outputSegments = inputSegments;
59
60 } else if (m_segmentOrientation == EPreferredDirection::c_Symmetric) {
61 outputSegments.reserve(2 * inputSegments.size());
62 for (const CDCSegment2D& segment : inputSegments) {
63 outputSegments.push_back(segment);
64 if (segment->hasReverseFlag()) continue; // Already a reverse found in the facet ca
65 outputSegments.back()->setReverseFlag();
66 outputSegments.push_back(segment.reversed());
67 outputSegments.back()->setReverseFlag();
68 }
69
70 } else if (m_segmentOrientation == EPreferredDirection::c_Curling) {
71 // Only make a copy for segments that are curling inside the CDC
72 // Others fix to flighing outwards
73 outputSegments.reserve(1.5 * inputSegments.size());
74 for (const CDCSegment2D& segment : inputSegments) {
75 if (segment->hasReverseFlag()) {
76 outputSegments.push_back(segment);
77 continue; // Already a reverse found in the facet ca
78 }
79 const CDCTrajectory2D& trajectory2D = segment.getTrajectory2D();
80 bool isFitted = trajectory2D.isFitted();
81 bool isCurler = trajectory2D.isCurler(1.1);
82 bool isOriginer = trajectory2D.isOriginer();
83 // Trajectory is leaving the CDC starting in the inner volume
84 bool isLeaver = isFitted and (not isCurler) and isOriginer;
85 if (isLeaver) {
86 // Fix to outwards flying
87 const CDCRecoHit2D& firstHit = segment.front();
88 const CDCRecoHit2D& lastHit = segment.back();
89 if (lastHit.getRecoPos2D().cylindricalR() < firstHit.getRecoPos2D().cylindricalR()) {
90 outputSegments.push_back(segment.reversed());
91 } else {
92 outputSegments.push_back(segment);
93 }
94 } else {
95 // Ambiguous keep both options
96 outputSegments.push_back(segment);
97 outputSegments.back()->setReverseFlag();
98 outputSegments.push_back(segment.reversed());
99 outputSegments.back()->setReverseFlag();
100 }
101 }
102
103 } else if (m_segmentOrientation == EPreferredDirection::c_Outwards) {
104 outputSegments.reserve(inputSegments.size());
105 for (const CDCSegment2D& segment : inputSegments) {
106 const CDCRecoHit2D& firstHit = segment.front();
107 const CDCRecoHit2D& lastHit = segment.back();
108 if (lastHit.getRecoPos2D().cylindricalR() < firstHit.getRecoPos2D().cylindricalR()) {
109 outputSegments.push_back(segment.reversed());
110 } else {
111 outputSegments.push_back(segment);
112 }
113 }
114 } else if (m_segmentOrientation == EPreferredDirection::c_Downwards) {
115 outputSegments.reserve(inputSegments.size());
116 for (const CDCSegment2D& segment : inputSegments) {
117 const CDCRecoHit2D& firstHit = segment.front();
118 const CDCRecoHit2D& lastHit = segment.back();
119 if (lastHit.getRecoPos2D().y() > firstHit.getRecoPos2D().y()) {
120 outputSegments.push_back(segment.reversed());
121 } else {
122 outputSegments.push_back(segment);
123 }
124 }
125
126 } else {
127 B2WARNING("Unexpected 'SegmentOrientation' parameter of segment finder module : '" <<
129 "'. No segments are put out.");
130 }
131}
Vector2D getRecoPos2D() const
Getter for the position in the reference plane.
bool isOriginer(double factor=1) const
Checks if the trajectory intersects with the inner radius of the CDC time the given tolerance factor.
bool isCurler(double factor=1) const
Checks if the trajectory leaves the outer radius of the CDC times the given tolerance factor.
bool isFitted() const
Checks if the circle is already set to a valid value.
std::string m_param_segmentOrientationString
Parameter: String that states the desired segment orientation.
EPreferredDirection m_segmentOrientation
Encoded desired segment orientation.
double cylindricalR() const
Gives the cylindrical radius of the vector. Same as norm()
Definition Vector2D.h:557
double y() const
Getter for the y coordinate.
Definition Vector2D.h:605

◆ 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.

◆ 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 26 of file SegmentOrienter.cc.

27{
28 moduleParamList->addParameter(prefixed(prefix, "SegmentOrientation"),
30 "Option which orientation of segments shall be generate. "
31 "Valid options are '' (default of the finder), "
32 "'none' (one orientation, algorithm dependent), "
33 "'symmetric', "
34 "'curling', "
35 "'outwards', "
36 "'downwards'.",
38}
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 CDCSegment2D, CDCSegment2D >.

Definition at line 20 of file SegmentOrienter.cc.

21{
22 return "Fixes the flight direction of segments to a preferred orientation by simple heuristics.";
23}

◆ getNProcessingSignalListener()

int getNProcessingSignalListener ( )
protectedinherited

Get the number of currently registered listeners.

Definition at line 56 of file CompositeProcessingSignalListener.cc.

61{
63}

◆ initialize()

void initialize ( )
finalvirtual

Signals the beginning of the event processing.

Reimplemented from CompositeProcessingSignalListener.

Definition at line 40 of file SegmentOrienter.cc.

41{
43 if (m_param_segmentOrientationString != std::string("")) {
44 try {
46 } catch (std::invalid_argument& e) {
47 B2ERROR("Unexpected 'SegmentOrientation' parameter : '" << m_param_segmentOrientationString);
48 }
49 }
50}

◆ 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_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_segmentOrientationString

std::string m_param_segmentOrientationString = ""
private

Parameter: String that states the desired segment orientation.

Valid orientations are "none" (unchanged), "outwards", "downwards", "symmetric", "curling"

Definition at line 52 of file SegmentOrienter.h.

◆ m_segmentOrientation

EPreferredDirection m_segmentOrientation = EPreferredDirection::c_None
private

Encoded desired segment orientation.

Valid orientations are "c_None" (unchanged), "c_Outwards", "c_Downwards", "c_Symmetric", "c_Curling",

Definition at line 58 of file SegmentOrienter.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: