10#include <tracking/trackFindingCDC/ca/CellularAutomaton.h>
11#include <tracking/trackFindingCDC/ca/CellularPathFollower.h>
13#include <tracking/trackFindingCDC/ca/Path.h>
14#include <tracking/trackFindingCDC/ca/CellHolder.h>
16#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
18#include <framework/core/ModuleParamList.h>
19#include <framework/logging/Logger.h>
28 namespace TrackFindingCDC {
35 template <
class ACellHolder>
43 static_assert_isCellHolder<ACellHolder>();
50 moduleParamList->
addParameter(prefixed(prefix,
"caMode"),
52 "Mode for the cellular automaton application"
53 "* * 'normal' normal path search for high value paths"
54 "* * 'cells' make path for each individual cell for debugging"
55 "* * 'relations' make path for each individual relation for debugging",
58 moduleParamList->
addParameter(prefixed(prefix,
"minState"),
60 "The minimal accumulated state to follow",
63 moduleParamList->
addParameter(prefixed(prefix,
"minPathLength"),
65 "The minimal path length to that is written to output",
71 void apply(
const std::vector<ACellHolder*>& cellHolders,
73 std::vector<Path<ACellHolder> >& paths)
75 B2ASSERT(
"Expected the relations to be sorted",
76 std::is_sorted(cellHolderRelations.begin(), cellHolderRelations.end()));
80 for (ACellHolder* cellHolder : cellHolders) {
81 paths.push_back({cellHolder});
89 paths.push_back({cellHolderRelation.getFrom(), cellHolderRelation.getTo()});
96 B2WARNING(
"Unrecognised caMode parameter value " <<
m_param_caMode);
104 for (ACellHolder* cellHolder : cellHolders) {
105 cellHolder->unsetAndForwardMaskedFlag();
108 B2DEBUG(25,
"Apply multipass cellular automat");
112 auto lessStartCellState = [
this](ACellHolder * lhs, ACellHolder * rhs) {
128 auto itStartCellHolder =
129 std::max_element(cellHolders.begin(), cellHolders.end(), lessStartCellState);
130 if (itStartCellHolder == cellHolders.end())
break;
131 else if (not(*itStartCellHolder)->getAutomatonCell().hasStartFlag())
break;
132 else if ((*itStartCellHolder)->getAutomatonCell().getCellState() <
m_param_minState)
break;
134 const ACellHolder* highestCellHolder = *itStartCellHolder;
140 if (newPath.empty())
break;
143 for (ACellHolder* cellHolderPtr : newPath) {
144 cellHolderPtr->setAndForwardMaskedFlag();
148 for (ACellHolder* cellHolder : cellHolders) {
149 cellHolder->receiveMaskedFlag();
153 paths.push_back(std::move(newPath));
The Module parameter list class.
Cell used by the cellular automata.
bool hasStartFlag() const
Gets the current state of the start marker flag.
Weight getCellState() const
Getter for the cell state.
bool hasPriorityPathFlag() const
Gets the current state of the priority path marker flag.
Implements the weighted cellular automaton algorithm.
Implements to pick up of the highest value path in neighborhood Following high value paths can be don...
Class to combine the run of the cellular automaton and the repeated path extraction.
CellularAutomaton< ACellHolder > m_cellularAutomaton
The cellular automaton to be used.
int m_param_minPathLength
The minimal path length to write to output.
void apply(const std::vector< ACellHolder * > &cellHolders, const std::vector< WeightedRelation< ACellHolder > > &cellHolderRelations, std::vector< Path< ACellHolder > > &paths)
Applies the cellular automaton to the collection and its relations.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Expose the parameters to a module.
Weight m_param_minState
The minimal accumulated state of the paths to follow.
CellularPathFollower< ACellHolder > m_cellularPathFollower
The path follower used to extract the path from the graph processed by the cellular automaton.
MultipassCellularPathFinder()
Default constructor also checking the validity of the template arguments.
std::string m_param_caMode
Mode for the cellular automaton application.
Type for two related objects with a weight.
void addParameter(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.