Belle II Software  release-08-01-10
TreeTraversal< AStateRejecter, AState, AResult > Class Template Referenceabstract

General implementation of a tree search algorithm using a given classes as state and results and one strategy class to decide, which child states should be traversed next. More...

#include <TreeTraversal.h>

Inheritance diagram for TreeTraversal< AStateRejecter, AState, AResult >:
Collaboration diagram for TreeTraversal< AStateRejecter, AState, AResult >:

Public Types

using IOTypes = std::tuple< AIOTypes... >
 Types that should be served to apply on invokation.
 
using IOVectors = std::tuple< std::vector< AIOTypes >... >
 Vector types that should be served to apply on invokation.
 

Public Member Functions

 TreeTraversal ()
 Construct this findlet and add the subfindlet as listener.
 
void exposeParameters (ModuleParamList *moduleParamList, const std::string &prefix) final
 Expose the parameters of the subfindlet.
 
void apply (const std::vector< const AState * > &seededStates, const std::vector< Relation< AState >> &stateRelations, std::vector< AResult > &results) override
 Main function of this findlet: traverse a tree starting from a given seed states. More...
 
virtual std::string getDescription ()
 Brief description of the purpose of the concret findlet.
 
virtual void apply (ToVector< AIOTypes > &... ioVectors)=0
 Main function executing the algorithm.
 
void initialize () override
 Receive and dispatch signal before the start of the event processing.
 
void beginRun () override
 Receive and dispatch signal for the beginning of a new run.
 
void beginEvent () override
 Receive and dispatch signal for the start of a new event.
 
void endRun () override
 Receive and dispatch signal for the end of the run.
 
void terminate () override
 Receive and dispatch Signal for termination of the event processing.
 

Protected Types

using ToVector = typename ToVectorImpl< T >::Type
 Short hand for ToRangeImpl.
 

Protected Member Functions

void addProcessingSignalListener (ProcessingSignalListener *psl)
 Register a processing signal listener to be notified.
 
int getNProcessingSignalListener ()
 Get the number of currently registered listeners.
 

Private Types

using Super = Findlet< const AState *const, const Relation< AState >, AResult >
 Parent class.
 

Private Member Functions

void traverseTree (std::vector< const AState * > &path, const std::vector< Relation< AState >> &stateRelations, std::vector< AResult > &results)
 Implementation of the traverseTree function.
 

Private Attributes

AStateRejecter m_stateRejecter
 State rejecter to decide which available continuations should be traversed next.
 
std::vector< ProcessingSignalListener * > m_subordinaryProcessingSignalListeners
 References to subordinary signal processing listener contained in this findlet.
 
bool m_initialized = false
 Flag to keep track whether initialization happend before.
 
bool m_terminated = false
 Flag to keep track whether termination happend before.
 
std::string m_initializedAs
 Name of the type during initialisation.
 

Detailed Description

template<class AStateRejecter, class AState, class AResult = std::vector<const AState*>>
class Belle2::TrackFindingCDC::TreeTraversal< AStateRejecter, AState, AResult >

General implementation of a tree search algorithm using a given classes as state and results and one strategy class to decide, which child states should be traversed next.

Requirements for the template parameters:

  • AState: No requirements
  • AResult: Must be constructable from std::vector<const AState*>
  • AStateRejecter: Should be roughly of type Findlet<const AState* const, AState*> with an apply methode like:

    apply(const std::vector<const AState*>& currentPath, std::vector<AState*>& nextStates);

    Therefore it receives the current path and a list of potential next states, that it should sort out for viable continuations to traverse next.

    The StateRejecter is allowed to adjust the nextStates for book keeping purposes, but should generally avoid to adjust the states in the currentPath to not interfere with the traversal of earlier siblings.

Definition at line 51 of file TreeTraversal.h.

Member Function Documentation

◆ apply()

void apply ( const std::vector< const AState * > &  seededStates,
const std::vector< Relation< AState >> &  stateRelations,
std::vector< AResult > &  results 
)
override

Main function of this findlet: traverse a tree starting from a given seed states.

ATTENTION: As described above, the states themselves can be altered during the tree traversal.

Definition at line 92 of file TreeTraversal.h.

96  {
97  B2ASSERT("Expected relation to be sorted",
98  std::is_sorted(stateRelations.begin(), stateRelations.end()));
99 
100  std::vector<const AState*> path;
101  for (const AState* state : seededStates) {
102  B2DEBUG(25, "Starting with new seed...");
103  path.push_back(state);
104  traverseTree(path, stateRelations, results);
105  path.pop_back();
106  B2DEBUG(25, "... finished with seed");
107  }
108  assert(path.empty());
109  }
void traverseTree(std::vector< const AState * > &path, const std::vector< Relation< AState >> &stateRelations, std::vector< AResult > &results)
Implementation of the traverseTree function.

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