Belle II Software development
SegmentFitter Class Referenceabstract

Fits segments with the Riemann method. More...

#include <SegmentFitter.h>

Inheritance diagram for SegmentFitter:
Findlet< 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 () override
 Short description of the findlet.
 
void exposeParameters (ModuleParamList *moduleParamList, const std::string &prefix) override
 Expose the parameters to a module.
 
void initialize () override
 Signals the beginning of the event processing.
 
void apply (std::vector< CDCSegment2D > &outputSegments) override
 Main algorithm applying the fit to each segment.
 
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<CDCSegment2D&>
 Type of the base class.
 

Private Attributes

bool m_param_karimakiFit = false
 Parameter : Switch to use Karimaki fit.
 
std::string m_param_fitPosString = "recoPos"
 Parameter : Option string which positional information from the hits should be used.
 
std::string m_param_fitVarianceString = "proper"
 Parameter : Option string which variance information from the hits should be used.
 
bool m_param_updateDriftLength = true
 Parameter : Switch to reestimate the drift length before the fit.
 
bool m_param_updateRecoPos = false
 Parameter : Switch to reevaluate the position and right left passage information based in the fit.
 
EFitPos m_fitPos = EFitPos::c_RecoPos
 Option which positional information from the hits should be used.
 
EFitVariance m_fitVariance = EFitVariance::c_Proper
 Option which variance information from the hits should be used.
 
CDCRiemannFitter m_riemannFitter
 Instance of the riemann fitter to be used.
 
CDCKarimakiFitter m_karimakiFitter
 Instance of the karimaki fitter to be used.
 
DriftLengthEstimator m_driftLengthEstimator
 Instance of the drift length estimator to be used.
 
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

Fits segments with the Riemann method.

Definition at line 34 of file SegmentFitter.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<CDCSegment2D&>
private

Type of the base class.

Definition at line 39 of file SegmentFitter.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 ( std::vector< CDCSegment2D > & outputSegments)
override

Main algorithm applying the fit to each segment.

Definition at line 87 of file SegmentFitter.cc.

88{
89 // Update the drift length
91 for (CDCSegment2D& segment : outputSegments) {
92 m_driftLengthEstimator.updateDriftLength(segment);
93 }
94 }
95
96 for (const CDCSegment2D& segment : outputSegments) {
97 CDCObservations2D observations2D(m_fitPos, m_fitVariance);
98 observations2D.appendRange(segment);
99
100 if (m_param_karimakiFit or observations2D.size() < 4) {
101 // Karimaki only works with the reconstructed position
102 if (m_fitPos != EFitPos::c_RecoPos) {
103 observations2D.clear();
104 observations2D.setFitPos(EFitPos::c_RecoPos);
105 observations2D.appendRange(segment);
106 }
107 CDCTrajectory2D trajectory2D = m_karimakiFitter.fit(observations2D);
108 segment.setTrajectory2D(trajectory2D);
109 } else {
110
111 CDCTrajectory2D trajectory2D = m_riemannFitter.fit(observations2D);
112 segment.setTrajectory2D(trajectory2D);
113 }
114 }
115
117 for (CDCSegment2D& segment : outputSegments) {
118 const CDCTrajectory2D& trajectory2D = segment.getTrajectory2D();
119 if (not trajectory2D.isFitted()) continue;
120 int nRLChanges = 0;
121 for (CDCRecoHit2D& recoHit2D : segment) {
122 ERightLeft rlInfo = trajectory2D.isRightOrLeft(recoHit2D.getRefPos2D());
123 if (rlInfo != recoHit2D.getRLInfo()) ++nRLChanges;
124 recoHit2D.setRLInfo(rlInfo);
125 const CDCRLWireHit& rlWireHit = recoHit2D.getRLWireHit();
126 Vector2D recoPos2D = rlWireHit.reconstruct2D(trajectory2D);
127 recoHit2D.setRecoPos2D(recoPos2D);
128 }
129 if (nRLChanges > 0) B2DEBUG(25, "RL changes " << nRLChanges);
130 }
131 }
132}
Vector2D reconstruct2D(const CDCTrajectory2D &trajectory2D) const
Reconstructs a position of primary ionisation on the drift circle.
bool isFitted() const
Checks if the circle is already set to a valid value.
ERightLeft isRightOrLeft(const Vector2D &point) const
Checks if the given point is to the right or to the left of the trajectory.
EFitPos m_fitPos
Option which positional information from the hits should be used.
DriftLengthEstimator m_driftLengthEstimator
Instance of the drift length estimator to be used.
bool m_param_karimakiFit
Parameter : Switch to use Karimaki fit.
CDCKarimakiFitter m_karimakiFitter
Instance of the karimaki fitter to be used.
bool m_param_updateDriftLength
Parameter : Switch to reestimate the drift length before the fit.
CDCRiemannFitter m_riemannFitter
Instance of the riemann fitter to be used.
EFitVariance m_fitVariance
Option which variance information from the hits should be used.
bool m_param_updateRecoPos
Parameter : Switch to reevaluate the position and right left passage information based in the fit.
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
Definition ERightLeft.h:25

◆ 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 )
overridevirtual

Expose the parameters to a module.

Reimplemented from CompositeProcessingSignalListener.

Definition at line 27 of file SegmentFitter.cc.

28{
29 moduleParamList->addParameter(prefixed(prefix, "karimakiFit"),
31 "Switch to select Karimaki method for fitting instead of Riemann fit",
33
34 moduleParamList->addParameter(prefixed(prefix, "fitPos"),
36 "Positional information of the hits to be used in the fit. "
37 "Options are 'recoPos', 'rlDriftCircle', 'wirePos'.",
39
40 moduleParamList->addParameter(prefixed(prefix, "fitVariance"),
42 "Positional information of the hits to be used in the fit. "
43 "Options are 'unit', 'driftLength', 'pseudo', 'proper'.",
45
46 moduleParamList->addParameter(prefixed(prefix, "updateDriftLength"),
48 "Switch to reestimate the drift length",
50
51 moduleParamList->addParameter(prefixed(prefix, "updateRecoPos"),
53 "Switch to reestimate the position and right left passage information",
55
56 m_driftLengthEstimator.exposeParameters(moduleParamList, prefix);
57}
std::string m_param_fitVarianceString
Parameter : Option string which variance information from the hits should be used.
std::string m_param_fitPosString
Parameter : Option string which positional information from the hits should be used.
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 ( )
overridevirtual

Short description of the findlet.

Reimplemented from Findlet< CDCSegment2D & >.

Definition at line 22 of file SegmentFitter.cc.

23{
24 return "Fits each segment with a selectable method";
25}

◆ getNProcessingSignalListener()

int getNProcessingSignalListener ( )
protectedinherited

Get the number of currently registered listeners.

Definition at line 56 of file CompositeProcessingSignalListener.cc.

61{
63}

◆ initialize()

void initialize ( )
overridevirtual

Signals the beginning of the event processing.

Reimplemented from CompositeProcessingSignalListener.

Definition at line 60 of file SegmentFitter.cc.

61{
63 if (m_param_fitPosString != std::string("")) {
64 try {
65 m_fitPos = getFitPos(m_param_fitPosString);
66 } catch (std::invalid_argument& e) {
67 B2ERROR("Unexpected fitPos parameter : '" << m_param_fitPosString);
68 }
69 }
70
71 if (m_param_fitVarianceString != std::string("")) {
72 try {
74 } catch (std::invalid_argument& e) {
75 B2ERROR("Unexpected fitVariance parameter : '" << m_param_fitVarianceString);
76 }
77 }
78
80 if (m_fitPos != EFitPos::c_RecoPos) {
81 B2WARNING("Karimaki fitter only works with the reconstructed position as input.");
82 }
83 m_fitPos = EFitPos::c_RecoPos;
84 }
85}

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

DriftLengthEstimator m_driftLengthEstimator
private

Instance of the drift length estimator to be used.

Definition at line 84 of file SegmentFitter.h.

◆ m_fitPos

EFitPos m_fitPos = EFitPos::c_RecoPos
private

Option which positional information from the hits should be used.

Definition at line 72 of file SegmentFitter.h.

◆ m_fitVariance

EFitVariance m_fitVariance = EFitVariance::c_Proper
private

Option which variance information from the hits should be used.

Definition at line 75 of file SegmentFitter.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_karimakiFitter

CDCKarimakiFitter m_karimakiFitter
private

Instance of the karimaki fitter to be used.

Definition at line 81 of file SegmentFitter.h.

◆ m_param_fitPosString

std::string m_param_fitPosString = "recoPos"
private

Parameter : Option string which positional information from the hits should be used.

Definition at line 60 of file SegmentFitter.h.

◆ m_param_fitVarianceString

std::string m_param_fitVarianceString = "proper"
private

Parameter : Option string which variance information from the hits should be used.

Definition at line 63 of file SegmentFitter.h.

◆ m_param_karimakiFit

bool m_param_karimakiFit = false
private

Parameter : Switch to use Karimaki fit.

Definition at line 57 of file SegmentFitter.h.

◆ m_param_updateDriftLength

bool m_param_updateDriftLength = true
private

Parameter : Switch to reestimate the drift length before the fit.

Definition at line 66 of file SegmentFitter.h.

◆ m_param_updateRecoPos

bool m_param_updateRecoPos = false
private

Parameter : Switch to reevaluate the position and right left passage information based in the fit.

Definition at line 69 of file SegmentFitter.h.

◆ m_riemannFitter

CDCRiemannFitter m_riemannFitter
private

Instance of the riemann fitter to be used.

Definition at line 78 of file SegmentFitter.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: