Belle II Software development
CDCCKFStateFilter Class Referenceabstract

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

#include <CDCCKFStateFilter.h>

Inheritance diagram for CDCCKFStateFilter:
Findlet< const CDCCKFState, CDCCKFState > 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

 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.
 

Static Private Member Functions

static void reconstruct (CDCCKFState &state, const TrackingUtilities::CDCTrajectory3D &trajectory, const double lastArcLength)
 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 36 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 39 of file CDCCKFStateFilter.h.

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

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 67 of file CDCCKFStateFilter.h.

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

◆ 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 49 of file CDCCKFStateFilter.h.

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

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

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

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

Definition at line 142 of file CDCCKFStateFilter.h.

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

◆ 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 64 of file CDCCKFStateFilter.h.

64{ 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 135 of file CDCCKFStateFilter.h.

◆ m_extrapolationFilter

Extrapolation Filter (after Kalman extrapolation)

Definition at line 137 of file CDCCKFStateFilter.h.

◆ m_finalSelection

Final Selection Filter (after Kalman update)

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

◆ m_preFilter

Pre Filter.

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