Belle II Software  release-08-01-10
Clusterizer< ACellHolder, ACluster > Class Template Referenceabstract

Implementation of the clustering Clusters elements of a given collection using the relations presented by a neighorhood. More...

#include <Clusterizer.h>

Inheritance diagram for Clusterizer< ACellHolder, ACluster >:
Collaboration diagram for Clusterizer< ACellHolder, ACluster >:

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

void apply (std::vector< ACellHolder * > const &cellHolders, std::vector< WeightedRelation< ACellHolder > > const &cellHolderRelations, std::vector< ACluster > &clusters) override
 Creates the clusters. More...
 
virtual std::string getDescription ()
 Brief description of the purpose of the concret findlet.
 
virtual void exposeParameters (ModuleParamList *moduleParamList, const std::string &prefix)
 Forward prefixed parameters of this findlet to the module parameter list.
 
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 = ProcessingSignalListener
 Type of the base class.
 

Private Member Functions

void expandCluster (std::vector< WeightedRelation< ACellHolder >> const &cellHolderRelations, std::vector< ACellHolder * > &cluster) const
 Helper function. Starting a new cluster and iterativelly expands it.
 
void setCellState (ACellHolder *cellHolder, Weight cellState) const
 Setter for the cell state of a pointed object that holds an AutomatonCell.
 
Weight getCellState (ACellHolder *cellHolder) const
 Getter for the cell state of a pointed object that holds an AutomatonCell.
 
void setCellWeight (ACellHolder *cellHolder, Weight cellWeight) const
 Setter for the cell weight of a pointed object that holds an AutomatonCell.
 

Private Attributes

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 ACellHolder, class ACluster = std::vector<ACellHolder*>>
class Belle2::TrackFindingCDC::Clusterizer< ACellHolder, ACluster >

Implementation of the clustering Clusters elements of a given collection using the relations presented by a neighorhood.

A cluster is essentially a connected subset of all cells that can reach each other by one more relations in a neighborhood. The algorithm is essentially an iterative expansion of the neighborhood relations keeping track of the already used cells by using the CellState of the AutomatonCell.

  • ACellHolder must therefore provide an AutomatonCell accessable by a getAutomatonCell() method. In case the objects you what to cluster do not contain an automaton cell already you may adopt it by using the WithAutomatonCell mixin.
  • ACluster can be anything that is default constructable and supports .insert(end(), ACellHolder*).

Definition at line 40 of file Clusterizer.h.

Member Function Documentation

◆ apply()

void apply ( std::vector< ACellHolder * > const &  cellHolders,
std::vector< WeightedRelation< ACellHolder > > const &  cellHolderRelations,
std::vector< ACluster > &  clusters 
)
inlineoverride

Creates the clusters.

Repeatly expands a neighborhood of referenced objects that have an AutomatonCell. The CellState after the clusterization is the index of the generated cluster. The CellWeight is set to the total number of neighbors of each cell.

Parameters
cellHoldersPointers to objects that should be clustered.
cellHolderRelationsRelations between the objects that should be clustered
[out]clustersGroups of connected objects in the neighborhood.

Definition at line 54 of file Clusterizer.h.

57  {
58  // Expect the relations to be sorted for lookup
59  assert(std::is_sorted(cellHolderRelations.begin(),
60  cellHolderRelations.end()));
61 
62  // Prepare some output clusters
63  clusters.reserve(30);
64 
65  // Prepare states
66  for (ACellHolder* cellHolder : cellHolders) {
67  setCellState(cellHolder, -1);
68  }
69 
70  // Work horse cluster
71  std::vector<ACellHolder*> cluster;
72 
73  // Go through each cell holder and start a cluster on each that is unassigned yet
74  int iCluster = -1;
75  for (ACellHolder* cellHolder : cellHolders) {
76  if (getCellState(cellHolder) != -1) continue;
77 
78  cluster.clear();
79 
80  ++iCluster;
81  setCellState(cellHolder, iCluster);
82  cluster.push_back(cellHolder);
83 
84  expandCluster(cellHolderRelations, cluster);
85 
86  clusters.emplace_back(std::move(cluster));
87  cluster.clear();
88  }
89  }
void setCellState(ACellHolder *cellHolder, Weight cellState) const
Setter for the cell state of a pointed object that holds an AutomatonCell.
Definition: Clusterizer.h:149
Weight getCellState(ACellHolder *cellHolder) const
Getter for the cell state of a pointed object that holds an AutomatonCell.
Definition: Clusterizer.h:156
void expandCluster(std::vector< WeightedRelation< ACellHolder >> const &cellHolderRelations, std::vector< ACellHolder * > &cluster) const
Helper function. Starting a new cluster and iterativelly expands it.
Definition: Clusterizer.h:93

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