12 #include <tracking/trackFindingCDC/findlets/base/Findlet.h>
14 #include <tracking/trackFindingCDC/numerics/WithWeight.h>
15 #include <tracking/trackFindingCDC/utilities/WeightedRelation.h>
16 #include <tracking/trackFindingCDC/utilities/Range.h>
18 #include <framework/logging/Logger.h>
28 class ModuleParamList;
29 namespace TrackFindingCDC {
53 template <
class AStateRejecter,
class AState,
class AResult = std::vector<const AState*>>
54 class WeightedTreeTraversal
55 :
public Findlet<const AState* const, const WeightedRelation<AState>, AResult> {
58 using Super = Findlet<const AState* const, const WeightedRelation<AState>, AResult>;
79 void apply(
const std::vector<const AState*>& seededStates,
81 std::vector<AResult>& results)
override;
87 std::vector<AResult>& results);
94 template <
class AStateRejecter,
class AState,
class AResult>
96 const std::vector<const AState*>& seededStates,
97 const std::vector<WeightedRelation<AState>>& stateRelations,
98 std::vector<AResult>& results)
100 std::vector<const AState*> path;
101 for (
const AState* state : seededStates) {
102 B2DEBUG(50,
"Starting with new seed...");
103 path.push_back(state);
104 traverseTree(path, stateRelations, results);
106 B2DEBUG(50,
"... finished with seed");
108 assert(path.empty());
111 template <
class AStateRejecter,
class AState,
class AResult>
113 std::vector<const AState*>& path,
114 const std::vector<WeightedRelation<AState>>& stateRelations,
115 std::vector<AResult>& results)
119 const AState* currentState = path.back();
121 std::equal_range(stateRelations.begin(), stateRelations.end(), currentState);
123 std::vector<WithWeight<AState*>> childStates;
125 AState* childState = continuation.getTo();
126 Weight weight = continuation.getWeight();
127 childStates.push_back({childState, weight});
132 const std::vector<const AState*>& constPath = path;
133 m_stateRejecter.apply(constPath, childStates);
135 if (childStates.empty()) {
136 B2DEBUG(50,
"Terminating this route, as there are no possible child states.");
137 results.emplace_back(path);
142 B2DEBUG(50,
"Having found " << childStates.size() <<
" child states.");
143 for (WithWeight<AState*> childState : childStates) {
144 if (std::count(path.begin(), path.end(), childState)) {
149 path.push_back(childState);
150 traverseTree(path, stateRelations, results);