Belle II Software development
MultipassCellularPathFinder< ACellHolder > Class Template Reference

Class to combine the run of the cellular automaton and the repeated path extraction. More...

#include <MultipassCellularPathFinder.h>

Public Member Functions

 MultipassCellularPathFinder ()
 Default constructor also checking the validity of the template arguments.
 
void exposeParameters (ModuleParamList *moduleParamList, const std::string &prefix)
 Expose the parameters to a module.
 
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.
 

Private Attributes

std::string m_param_caMode {"normal"}
 Mode for the cellular automaton application.
 
Weight m_param_minState = -INFINITY
 The minimal accumulated state of the paths to follow.
 
int m_param_minPathLength = 0
 The minimal path length to write to output.
 
CellularAutomaton< ACellHolder > m_cellularAutomaton
 The cellular automaton to be used.
 
CellularPathFollower< ACellHolder > m_cellularPathFollower
 The path follower used to extract the path from the graph processed by the cellular automaton.
 

Detailed Description

template<class ACellHolder>
class Belle2::TrackFindingCDC::MultipassCellularPathFinder< ACellHolder >

Class to combine the run of the cellular automaton and the repeated path extraction.

Execute the cellular automaton and extracting paths interatively blocking the already used knots until there is no more path fullfilling the minimal length / energy requirement given as minStateToFollow to the constructor.

Definition at line 36 of file MultipassCellularPathFinder.h.

Constructor & Destructor Documentation

◆ MultipassCellularPathFinder()

Default constructor also checking the validity of the template arguments.

Definition at line 39 of file MultipassCellularPathFinder.h.

40 {
41 // Experiment in how to specify the requirements of the template parameters
42 // Somewhat incomplete
43 static_assert_isCellHolder<ACellHolder>();
44 }

Member Function Documentation

◆ apply()

void apply ( const std::vector< ACellHolder * > &  cellHolders,
const std::vector< WeightedRelation< ACellHolder > > &  cellHolderRelations,
std::vector< Path< ACellHolder > > &  paths 
)
inline

Applies the cellular automaton to the collection and its relations.

Definition at line 71 of file MultipassCellularPathFinder.h.

74 {
75 B2ASSERT("Expected the relations to be sorted",
76 std::is_sorted(cellHolderRelations.begin(), cellHolderRelations.end()));
77
78 // Forward all cells as paths
79 if (m_param_caMode == "cells") {
80 for (ACellHolder* cellHolder : cellHolders) {
81 paths.push_back({cellHolder});
82 }
83 return;
84 }
85
86 // Forward all relations as paths
87 if (m_param_caMode == "relations") {
88 for (const WeightedRelation<ACellHolder>& cellHolderRelation : cellHolderRelations) {
89 paths.push_back({cellHolderRelation.getFrom(), cellHolderRelation.getTo()});
90 }
91 return;
92 }
93
94 // Everything else is just normal
95 if (m_param_caMode != "normal") {
96 B2WARNING("Unrecognised caMode parameter value " << m_param_caMode);
97 m_param_caMode = "normal";
98 }
99
100 // Multiple passes of the cellular automaton. One path is created
101 // at a time denying all knots it picked up, applying the
102 // cellular automaton again and so on. No best candidate
103 // analysis needed
104 for (ACellHolder* cellHolder : cellHolders) {
105 cellHolder->unsetAndForwardMaskedFlag();
106 }
107
108 B2DEBUG(25, "Apply multipass cellular automat");
109 do {
110 m_cellularAutomaton.applyTo(cellHolders, cellHolderRelations);
111
112 auto lessStartCellState = [this](ACellHolder * lhs, ACellHolder * rhs) {
113 const AutomatonCell& lhsCell = lhs->getAutomatonCell();
114 const AutomatonCell& rhsCell = rhs->getAutomatonCell();
115
116 // Cells with state lower than the minimal cell state are one lowest category
117 if (rhsCell.getCellState() < m_param_minState) return false;
118 if (lhsCell.getCellState() < m_param_minState) return true;
119
120 return (std::make_tuple(lhsCell.hasPriorityPathFlag(),
121 lhsCell.hasStartFlag(),
122 lhsCell.getCellState()) <
123 std::make_tuple(rhsCell.hasPriorityPathFlag(),
124 rhsCell.hasStartFlag(),
125 rhsCell.getCellState()));
126 };
127
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;
133
134 const ACellHolder* highestCellHolder = *itStartCellHolder;
135
136 Path<ACellHolder> newPath = m_cellularPathFollower.followSingle(highestCellHolder,
137 cellHolderRelations,
139
140 if (newPath.empty()) break;
141
142 // Block the used items
143 for (ACellHolder* cellHolderPtr : newPath) {
144 cellHolderPtr->setAndForwardMaskedFlag();
145 }
146
147 // Block the items that have already used components
148 for (ACellHolder* cellHolder : cellHolders) {
149 cellHolder->receiveMaskedFlag();
150 }
151
152 if (static_cast<int>(newPath.size()) >= m_param_minPathLength) {
153 paths.push_back(std::move(newPath));
154 }
155
156 } while (true);
157 }
CellularAutomaton< ACellHolder > m_cellularAutomaton
The cellular automaton to be used.
int m_param_minPathLength
The minimal path length to write to output.
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.
std::string m_param_caMode
Mode for the cellular automaton application.

◆ exposeParameters()

void exposeParameters ( ModuleParamList moduleParamList,
const std::string &  prefix 
)
inline

Expose the parameters to a module.

Definition at line 48 of file MultipassCellularPathFinder.h.

49 {
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",
57
58 moduleParamList->addParameter(prefixed(prefix, "minState"),
60 "The minimal accumulated state to follow",
62
63 moduleParamList->addParameter(prefixed(prefix, "minPathLength"),
65 "The minimal path length to that is written to output",
67
68 }

Member Data Documentation

◆ m_cellularAutomaton

CellularAutomaton<ACellHolder> m_cellularAutomaton
private

The cellular automaton to be used.

Definition at line 176 of file MultipassCellularPathFinder.h.

◆ m_cellularPathFollower

CellularPathFollower<ACellHolder> m_cellularPathFollower
private

The path follower used to extract the path from the graph processed by the cellular automaton.

Definition at line 179 of file MultipassCellularPathFinder.h.

◆ m_param_caMode

std::string m_param_caMode {"normal"}
private

Mode for the cellular automaton application.

  • 'normal' normal path search for high value paths
  • 'cells' make path for each individual cell for debugging
  • 'relations' make path for each individual relation for debugging

Definition at line 167 of file MultipassCellularPathFinder.h.

◆ m_param_minPathLength

int m_param_minPathLength = 0
private

The minimal path length to write to output.

Definition at line 173 of file MultipassCellularPathFinder.h.

◆ m_param_minState

Weight m_param_minState = -INFINITY
private

The minimal accumulated state of the paths to follow.

Definition at line 170 of file MultipassCellularPathFinder.h.


The documentation for this class was generated from the following file: