Belle II Software  release-08-01-10
PathCollectorRecursive< ContainerType, NodeType, NeighbourContainerType, NodeCompatibilityCheckerType > Class Template Reference

Path finder for generic ContainerType. More...

#include <PathCollectorRecursive.h>

Public Types

using Path = std::vector< NodeType * >
 Using Path for vector of pointers to NodeTypes.
 

Public Member Functions

bool findPaths (ContainerType &aNetwork, std::vector< Path > &paths, unsigned int pathLimit, bool storeSubsets=false)
 Main functionality of this class Evaluates provided network and creates all allowed paths. More...
 

Static Public Member Functions

static std::string printPaths (const std::vector< Path > &allPaths)
 Prints information about all paths provided in a vector of paths.
 

Public Attributes

unsigned int minPathLength = 2
 public Data members: More...
 
unsigned int nTrees = 0
 Counter for number of trees found.
 
unsigned int nRecursiveCalls = 0
 Counter for number of recursive calls.
 
bool m_storeSubsets = false
 flag if subsets should be stored or not
 

Protected Member Functions

Path clone (const Path &aPath) const
 Copies path to create an identical one.
 
void storeAcceptedPath (Path newPath, std::vector< Path > &allNodePaths) const
 Tests length requirement on a path before adding it to path vector.
 
void findPathsRecursive (std::vector< Path > &allNodePaths, Path &currentPath, NeighbourContainerType &innerNeighbours)
 Recursive pathFinder: Collects all possible segment combinations to build paths.
 

Protected Attributes

NodeCompatibilityCheckerType m_compatibilityChecker
 protected Data members: More...
 

Detailed Description

template<class ContainerType, class NodeType, class NeighbourContainerType, class NodeCompatibilityCheckerType>
class Belle2::PathCollectorRecursive< ContainerType, NodeType, NeighbourContainerType, NodeCompatibilityCheckerType >

Path finder for generic ContainerType.

Uses recursive collection process and returns vector of paths, which are vectors of NodeType*.

Requirements for ContainerType:

  • must have begin() and end() with iterator pointing to pointers of entries ( = ContainerType< NodeType*>)

Requirements for NodeType:

  • must have function: bool NodeType::getMetaInfo().isSeed()
  • must have function: NeighbourContainerType& NodeType::getInnerNodes()
  • must have function: bool NodeType::getOuterNodes().empty()
  • other requirements depend on NodeCompatibilityCheckerType used.

Requirements for NeighbourContainerType:

  • must have function: bool NeighbourContainerType::empty()
  • must have function: unsigned int (or comparable) NeighbourContainerType::size()
  • must have access operator: NeighbourContainerType: operator [] returning a NodeType*

Requirements for NodeCompatibilityCheckerType:

  • must have function bool areCompatible(NodeType* outerNode, NodeType* innerNode);

Definition at line 44 of file PathCollectorRecursive.h.

Member Function Documentation

◆ findPaths()

bool findPaths ( ContainerType &  aNetwork,
std::vector< Path > &  paths,
unsigned int  pathLimit,
bool  storeSubsets = false 
)
inline

Main functionality of this class Evaluates provided network and creates all allowed paths.

All found paths are filled into the provided vector 'paths'. If storeSubsets is turned on, also the sub-paths are saved to vector 'paths'. If a defined limit on the number of possible paths is exceeded, the search is aborted, and false is returned.

Definition at line 57 of file PathCollectorRecursive.h.

58  {
59  m_storeSubsets = storeSubsets;
60 
61  std::vector<Path> allNodePaths;
62  for (NodeType* aNode : aNetwork) {
63  if (aNode->getMetaInfo().isSeed() == false) {
64  continue;
65  }
66 
67  NeighbourContainerType& innerNeighbours = aNode->getInnerNodes();
68  if (innerNeighbours.empty()) {
69  continue;
70  }
71  if (aNode->getOuterNodes().empty()) {
72  nTrees++;
73  }
74 
75  // creating unique_ptr of a new path:
76  Path newPath = Path{aNode};
77 
78  findPathsRecursive(allNodePaths, newPath, innerNeighbours);
79  storeAcceptedPath(newPath, allNodePaths);
80 
81  if (allNodePaths.size() > pathLimit) {
82  B2WARNING("Number of collected paths is too large: skipping the event and not processing it."
83  << LogVar("Number of node paths", allNodePaths.size()) << LogVar("Current limit of paths", pathLimit));
84  return false;
85  }
86  }
87  paths = allNodePaths;
88  return true;
89  }
void storeAcceptedPath(Path newPath, std::vector< Path > &allNodePaths) const
Tests length requirement on a path before adding it to path vector.
std::vector< NodeType * > Path
Using Path for vector of pointers to NodeTypes.
unsigned int nTrees
Counter for number of trees found.
void findPathsRecursive(std::vector< Path > &allNodePaths, Path &currentPath, NeighbourContainerType &innerNeighbours)
Recursive pathFinder: Collects all possible segment combinations to build paths.
bool m_storeSubsets
flag if subsets should be stored or not
Class to store variables with their name which were sent to the logging service.
NodeType
Enum of possible Nodes in parsing tree.

Member Data Documentation

◆ m_compatibilityChecker

NodeCompatibilityCheckerType m_compatibilityChecker
protected

protected Data members:

Stores mini-Class for checking compatibility of two nodes passed.

Definition at line 197 of file PathCollectorRecursive.h.

◆ minPathLength

unsigned int minPathLength = 2

public Data members:

parameter for setting minimal path length: path length == number of nodes collected in a row from given network, this is not necessarily number of hits!

Definition at line 183 of file PathCollectorRecursive.h.


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