Belle II Software  release-08-01-10
CellularPathFollower< ACellHolder > Class Template Reference

Implements to pick up of the highest value path in neighborhood Following high value paths can be done two ways. More...

#include <CellularPathFollower.h>

Public Member Functions

std::vector< Path< ACellHolder > > followAll (const std::vector< ACellHolder * > &cellHolders, const std::vector< WeightedRelation< ACellHolder >> &cellHolderRelations, Weight minStateToFollow=-INFINITY) const
 Follow paths from all start cells marked with the start flag.
 
Path< ACellHolder > followSingle (ACellHolder *startCellHolder, const std::vector< WeightedRelation< ACellHolder >> &cellHolderRelations, Weight minStateToFollow=-INFINITY) const
 Follows a single maximal path starting with the given start cell. More...
 

Private Member Functions

void growAllPaths (Path< ACellHolder > &path, const std::vector< WeightedRelation< ACellHolder >> &cellHolderRelations, std::vector< Path< ACellHolder > > &paths) const
 Helper function for recursively growing paths. More...
 

Static Private Member Functions

static bool validStartCell (const AutomatonCell &automatonCell, Weight minStateToFollow)
 Helper function to determine, if the cell has all flags indicating to be a start cell and that its state exceeds the minimal requirement.
 
static bool isHighestContinuation (const WeightedRelation< ACellHolder > &relation)
 Helper function determining if the given neighbor is one of the best to be followed. More...
 
static bool isHighestContinuation (ACellHolder &cellHolder, Weight relationWeight, ACellHolder &neighborCellHolder)
 Helper function determining if the given neighbor is one of the best to be followed. More...
 

Detailed Description

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

Implements to pick up of the highest value path in neighborhood Following high value paths can be done two ways.

First construct a single path that has the highest value of all. This carried out by follow single which uses the highest cell returned by the cellular automaton. Second construct all paths which are maximal. A maximal path means that there is no longer path including this path. If there are many disjoint paths this is the way to get them. However you most certainly pick up a lot of elements twice if there are many start culminating into a common long path. This is carried out recursively by followAll over the start cells marked with start flag.

Definition at line 38 of file CellularPathFollower.h.

Member Function Documentation

◆ followSingle()

Path<ACellHolder> followSingle ( ACellHolder *  startCellHolder,
const std::vector< WeightedRelation< ACellHolder >> &  cellHolderRelations,
Weight  minStateToFollow = -INFINITY 
) const
inline

Follows a single maximal path starting with the given start cell.

If the start cell is nullptr or has a state lower than the minimum state to follow an empty vector is returned.

Definition at line 81 of file CellularPathFollower.h.

84  {
85  assert(std::is_sorted(cellHolderRelations.begin(), cellHolderRelations.end()));
86 
87  Path<ACellHolder> path;
88  if (not startCellHolder) return path;
89  const AutomatonCell& startCell = startCellHolder->getAutomatonCell();
90  if (not validStartCell(startCell, minStateToFollow)) return path;
91 
92  // Start new path
93  path.reserve(20); // Just a guess
94 
95  // Insert a pointer to the cell into the path
96  path.push_back(startCellHolder);
97  bool grew = true;
98  while (grew) {
99  grew = false;
100  ACellHolder* cellHolder = path.back();
101 
102  auto continuations = asRange(std::equal_range(cellHolderRelations.begin(),
103  cellHolderRelations.end(),
104  cellHolder));
105 
106  for (const WeightedRelation<ACellHolder>& relation : continuations) {
107  // cppcheck-suppress useStlAlgorithm
108  if (isHighestContinuation(relation)) {
109  ACellHolder* neighbor = relation.getTo();
110  path.push_back(neighbor);
111  grew = true;
112  break;
113  }
114  }
115  }
116  return path;
117  }
static bool isHighestContinuation(const WeightedRelation< ACellHolder > &relation)
Helper function determining if the given neighbor is one of the best to be followed.
static bool validStartCell(const AutomatonCell &automatonCell, Weight minStateToFollow)
Helper function to determine, if the cell has all flags indicating to be a start cell and that its st...

◆ growAllPaths()

void growAllPaths ( Path< ACellHolder > &  path,
const std::vector< WeightedRelation< ACellHolder >> &  cellHolderRelations,
std::vector< Path< ACellHolder > > &  paths 
) const
inlineprivate

Helper function for recursively growing paths.

Parameters
[in]pathCurrent path to be extended
[in]cellHolderRelationsConsidered relations to follow to extend the path
[out]pathsLongest paths generated

Definition at line 126 of file CellularPathFollower.h.

◆ isHighestContinuation() [1/2]

static bool isHighestContinuation ( ACellHolder &  cellHolder,
Weight  relationWeight,
ACellHolder &  neighborCellHolder 
)
inlinestaticprivate

Helper function determining if the given neighbor is one of the best to be followed.

Since this is an algebraic property no comparision to the other alternatives is necessary.

Definition at line 190 of file CellularPathFollower.h.

◆ isHighestContinuation() [2/2]

static bool isHighestContinuation ( const WeightedRelation< ACellHolder > &  relation)
inlinestaticprivate

Helper function determining if the given neighbor is one of the best to be followed.

Since this is an algebraic property on comparision to the other alternatives is necessary.

Definition at line 172 of file CellularPathFollower.h.


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