Belle II Software prerelease-11-00-00a
CDCCKFStateFilter Class Referenceabstract

A stack of pre-, helix-extrapolation- , Kalman-extrapolation- and Kalman-update-filters. More...

#include <CDCCKFStateFilter.h>

Inheritance diagram for CDCCKFStateFilter:
Collaboration diagram for CDCCKFStateFilter:

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

 CDCCKFStateFilter ()
 Add all sub findlets.
 
void exposeParameters (ModuleParamList *moduleParamList, const std::string &prefix) override
 Expose the parameters of the sub findlets.
 
void setMaximalHitCandidates (size_t maximalHitCandidates)
 Set maximal hit candidates for state filtering.
 
void apply (const CDCCKFPath &path, std::vector< CDCCKFState > &nextStates) override
 Apply the findlet and do the state selection.
 
virtual std::string getDescription ()
 Brief description of the purpose of the concrete findlet.
 
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.
 

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
 Type of the base class.
 

Private Member Functions

void reconstruct (CDCCKFState &state, const TrackingUtilities::CDCTrajectory3D &trajectory, const double lastArcLength) const
 Helper function to reconstruct the arc length and the hit distance of a state according to the trajectory.
 

Private Attributes

size_t m_maximalHitCandidates = 4
 Parameter: max number of candidates.
 
TrackingUtilities::ChooseableFilter< CDCStateFilterFactorym_preFilter
 Pre Filter.
 
TrackingUtilities::ChooseableFilter< CDCStateFilterFactorym_basicFilter
 Basic Filter (uses helix extrapolation)
 
TrackingUtilities::ChooseableFilter< CDCStateFilterFactorym_extrapolationFilter
 Extrapolation Filter (after Kalman extrapolation)
 
TrackingUtilities::ChooseableFilter< CDCStateFilterFactorym_finalSelection
 Final Selection Filter (after Kalman update)
 
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

A stack of pre-, helix-extrapolation- , Kalman-extrapolation- and Kalman-update-filters.

Definition at line 35 of file CDCCKFStateFilter.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
privateinherited

Type of the base class.

Definition at line 26 of file CompositeProcessingSignalListener.h.

◆ ToVector

using ToVector
protectedinherited

Short hand for ToRangeImpl.

Definition at line 49 of file Findlet.h.

Constructor & Destructor Documentation

◆ CDCCKFStateFilter()

CDCCKFStateFilter ( )
inline

Add all sub findlets.

Definition at line 38 of file CDCCKFStateFilter.h.

39 {
40 addProcessingSignalListener(&m_preFilter);
41 addProcessingSignalListener(&m_basicFilter);
42 addProcessingSignalListener(&m_extrapolationFilter);
43 addProcessingSignalListener(&m_finalSelection);
44 }

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 CDCCKFPath & path,
std::vector< CDCCKFState > & nextStates )
inlineoverride

Apply the findlet and do the state selection.

Definition at line 66 of file CDCCKFStateFilter.h.

67 {
68 const CDCCKFState& lastState = path.back();
69 const TrackingUtilities::CDCTrajectory3D& trajectory = lastState.getTrajectory();
70
71 TrackingUtilities::Weight weight;
72
73 B2DEBUG(29, "On layer: " << (lastState.isSeed() ? -1 : lastState.getWireHit()->getWire().getICLayer()));
74
75 for (CDCCKFState& nextState : nextStates) {
76 B2DEBUG(29, "Checking layer: " << nextState.getWireHit()->getWire().getICLayer());
77
78 weight = m_preFilter({&path, &nextState});
79 nextState.setWeight(weight);
80 if (std::isnan(weight)) {
81 B2DEBUG(29, "Fails PreFilter");
82 continue;
83 }
84
85 // Do a reconstruction based on the helix extrapolation from the last hit
86 reconstruct(nextState, trajectory, lastState.getArcLength());
87
88 weight = m_basicFilter({&path, &nextState});
89 nextState.setWeight(weight);
90 if (std::isnan(weight)) {
91 B2DEBUG(29, "Fails BasicFilter");
92 continue;
93 }
94
95 // Extrapolate and update
96 weight = m_extrapolationFilter({&path, &nextState});
97 nextState.setWeight(weight);
98 if (std::isnan(weight)) {
99 B2DEBUG(29, "Fails ExtrapolationFilter");
100 continue;
101 }
102
103 // Do a final hit selection based on the new state
104 const TrackingUtilities::CDCTrajectory3D& thisTrajectory = nextState.getTrajectory();
105 reconstruct(nextState, thisTrajectory, nextState.getArcLength());
106
107 weight = m_finalSelection({&path, &nextState});
108 nextState.setWeight(weight);
109 if (std::isnan(weight)) {
110 B2DEBUG(29, "Fails FinalFilter");
111 continue;
112 }
113 }
114
115 B2DEBUG(29, "Starting with " << nextStates.size() << " possible hits");
116
117 TrackingUtilities::erase_remove_if(nextStates,
118 TrackingUtilities::Composition<TrackingUtilities::IsNaN, TrackingUtilities::GetWeight>());
119
120 B2DEBUG(29, "Now have " << nextStates.size());
121
122 std::sort(nextStates.begin(), nextStates.end(), TrackingUtilities::GreaterWeight());
123
124 TrackingUtilities::only_best_N(nextStates, m_maximalHitCandidates);
125 }

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

Expose the parameters of the sub findlets.

Reimplemented from CompositeProcessingSignalListener.

Definition at line 48 of file CDCCKFStateFilter.h.

49 {
50 moduleParamList->addParameter(TrackingUtilities::prefixed(prefix, "maximalHitCandidates"),
51 m_maximalHitCandidates, "Maximal hit candidates to test",
52 m_maximalHitCandidates);
53 m_preFilter.exposeParameters(moduleParamList, TrackingUtilities::prefixed(prefix, "pre"));
54 m_basicFilter.exposeParameters(moduleParamList, TrackingUtilities::prefixed(prefix, "basic"));
55 m_extrapolationFilter.exposeParameters(moduleParamList, TrackingUtilities::prefixed(prefix, "extrapolation"));
56 m_finalSelection.exposeParameters(moduleParamList, TrackingUtilities::prefixed(prefix, "final"));
57 }

◆ getDescription()

virtual std::string getDescription ( )
inlinevirtualinherited

Brief description of the purpose of the concrete findlet.

Definition at line 60 of file Findlet.h.

61 {
62 return "(no description)";
63 }

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

◆ reconstruct()

void reconstruct ( CDCCKFState & state,
const TrackingUtilities::CDCTrajectory3D & trajectory,
const double lastArcLength ) const
inlineprivate

Helper function to reconstruct the arc length and the hit distance of a state according to the trajectory.

Definition at line 140 of file CDCCKFStateFilter.h.

141 {
142 // TODO: actually we do not need to do any trajectory creation here. We could save some computing time!
143 const TrackingUtilities::CDCTrajectory2D& trajectory2D = trajectory.getTrajectory2D();
144 const TrackingUtilities::CDCTrajectorySZ& trajectorySZ = trajectory.getTrajectorySZ();
145
146 const TrackingUtilities::CDCWireHit* wireHit = state.getWireHit();
147
148 TrackingUtilities::Vector2D recoPos2D;
149 if (wireHit->isAxial()) {
150 recoPos2D = wireHit->reconstruct2D(trajectory2D);
151 } else {
152 const CDC::CDCWire& wire = wireHit->getWire();
153 const TrackingUtilities::Vector2D& posOnXYPlane = wireHit->reconstruct2D(trajectory2D);
154
155 const double arcLength = trajectory2D.calcArcLength2D(posOnXYPlane);
156 const double z = trajectorySZ.mapSToZ(arcLength);
157
158 const TrackingUtilities::Vector2D& wirePos2DAtZ = wire.getWirePos2DAtZ(z);
159
160 const TrackingUtilities::Vector2D& recoPosOnTrajectory = trajectory2D.getClosest(wirePos2DAtZ);
161 const double driftLength = wireHit->getRefDriftLength();
162 TrackingUtilities::Vector2D disp2D = recoPosOnTrajectory - wirePos2DAtZ;
163 disp2D.normalizeTo(driftLength);
164 recoPos2D = wirePos2DAtZ + disp2D;
165 }
166
167 const double arcLength = trajectory2D.calcArcLength2D(recoPos2D);
168 const double z = trajectorySZ.mapSToZ(arcLength);
169 const double distanceToHit = trajectory2D.getDist2D(recoPos2D);
170
171 state.setArcLength(lastArcLength + arcLength);
172 state.setHitDistance(distanceToHit);
173 state.setReconstructedZ(z);
174 }

◆ setMaximalHitCandidates()

void setMaximalHitCandidates ( size_t maximalHitCandidates)
inline

Set maximal hit candidates for state filtering.

Parameters
maximalHitCandidatesMaximum number of hit candidates to test

Definition at line 63 of file CDCCKFStateFilter.h.

63{ m_maximalHitCandidates = maximalHitCandidates; }

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

Basic Filter (uses helix extrapolation)

Definition at line 133 of file CDCCKFStateFilter.h.

◆ m_extrapolationFilter

Extrapolation Filter (after Kalman extrapolation)

Definition at line 135 of file CDCCKFStateFilter.h.

◆ m_finalSelection

Final Selection Filter (after Kalman update)

Definition at line 137 of file CDCCKFStateFilter.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_maximalHitCandidates

size_t m_maximalHitCandidates = 4
private

Parameter: max number of candidates.

Definition at line 129 of file CDCCKFStateFilter.h.

◆ m_preFilter

Pre Filter.

Definition at line 131 of file CDCCKFStateFilter.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 file: