10 #include <tracking/trackFindingCDC/findlets/base/Findlet.h>
12 #include <tracking/trackFindingCDC/numerics/WithWeight.h>
13 #include <tracking/trackFindingCDC/utilities/WeightedRelation.h>
14 #include <tracking/trackFindingCDC/utilities/Range.h>
16 #include <framework/logging/Logger.h>
26 class ModuleParamList;
27 namespace TrackFindingCDC {
51 template <
class AStateRejecter,
class AState,
class AResult = std::vector<const AState*>>
53 :
public Findlet<const AState* const, const WeightedRelation<AState>, AResult> {
77 void apply(
const std::vector<const AState*>& seededStates,
79 std::vector<AResult>& results)
override;
85 std::vector<AResult>& results);
92 template <
class AStateRejecter,
class AState,
class AResult>
94 const std::vector<const AState*>& seededStates,
96 std::vector<AResult>& results)
98 std::vector<const AState*> path;
99 for (
const AState* state : seededStates) {
100 B2DEBUG(50,
"Starting with new seed...");
101 path.push_back(state);
102 traverseTree(path, stateRelations, results);
104 B2DEBUG(50,
"... finished with seed");
106 assert(path.empty());
109 template <
class AStateRejecter,
class AState,
class AResult>
111 std::vector<const AState*>& path,
113 std::vector<AResult>& results)
117 const AState* currentState = path.back();
119 std::equal_range(stateRelations.begin(), stateRelations.end(), currentState);
121 std::vector<WithWeight<AState*>> childStates;
123 AState* childState = continuation.getTo();
124 Weight weight = continuation.getWeight();
125 childStates.push_back({childState, weight});
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.");
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 with a weight.
General implementation of a tree search algorithm using a given classes as state and results and one ...
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.
void apply(const std::vector< const AState * > &seededStates, const std::vector< WeightedRelation< AState >> &stateRelations, std::vector< AResult > &results) override
Main function of this findlet: traverse a tree starting from a given seed states.
void traverseTree(std::vector< const AState * > &path, const std::vector< WeightedRelation< AState >> &stateRelations, std::vector< AResult > &results)
Implementation of the traverseTree function.
WeightedTreeTraversal()
Construct this findlet and add the subfindlet as listener.
A mixin class to attach a weight to an object.
Abstract base class for different kinds of events.