10 #include <tracking/trackFindingCDC/findlets/base/Findlet.h>
12 #include <tracking/trackFindingCDC/utilities/Relation.h>
13 #include <tracking/trackFindingCDC/utilities/Range.h>
15 #include <framework/logging/Logger.h>
25 class ModuleParamList;
26 namespace TrackFindingCDC {
50 template <
class AStateRejecter,
class AState,
class AResult = std::vector<const AState*> >
75 void apply(
const std::vector<const AState*>& seededStates,
77 std::vector<AResult>& results)
override;
83 std::vector<AResult>& results);
90 template <
class AStateRejecter,
class AState,
class AResult>
92 const std::vector<const AState*>& seededStates,
94 std::vector<AResult>& results)
96 B2ASSERT(
"Expected relation to be sorted",
97 std::is_sorted(stateRelations.begin(), stateRelations.end()));
99 std::vector<const AState*> path;
100 for (
const AState* state : seededStates) {
101 B2DEBUG(50,
"Starting with new seed...");
102 path.push_back(state);
103 traverseTree(path, stateRelations, results);
105 B2DEBUG(50,
"... finished with seed");
107 assert(path.empty());
110 template <
class AStateRejecter,
class AState,
class AResult>
112 std::vector<const AState*>& path,
114 std::vector<AResult>& results)
118 const AState* currentState = path.back();
120 std::equal_range(stateRelations.begin(), stateRelations.end(), currentState);
122 std::vector<AState*> childStates;
124 AState* childState = continuation.getTo();
125 childStates.push_back(childState);
130 const std::vector<const AState*>& constPath = path;
131 m_stateRejecter.apply(constPath, childStates);
133 if (childStates.empty()) {
134 B2DEBUG(50,
"Terminating this route, as there are no possible child states.");
135 results.emplace_back(path);
140 B2DEBUG(50,
"Having found " << childStates.size() <<
" child states.");
141 for (
const AState* childState : childStates) {
142 if (std::count(path.begin(), path.end(), childState)) {
147 path.push_back(childState);
148 traverseTree(path, stateRelations, results);
The Module parameter list class.
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
Interface for a minimal algorithm part that wants to expose some parameters to a module.
Type for two related objects.
General implementation of a tree search algorithm using a given classes as state and results and one ...
void traverseTree(std::vector< const AState * > &path, const std::vector< Relation< AState >> &stateRelations, std::vector< AResult > &results)
Implementation of the traverseTree function.
void apply(const std::vector< const AState * > &seededStates, const std::vector< Relation< AState >> &stateRelations, std::vector< AResult > &results) override
Main function of this findlet: traverse a tree starting from a given seed states.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters of the subfindlet.
AStateRejecter m_stateRejecter
State rejecter to decide which available continuations should be traversed next.
TreeTraversal()
Construct this findlet and add the subfindlet as listener.
Abstract base class for different kinds of events.