Belle II Software  release-08-01-10
RelationElement Class Reference

Class to store a single element of a relation. More...

#include <RelationElement.h>

Inheritance diagram for RelationElement:
Collaboration diagram for RelationElement:

Public Types

typedef unsigned int index_type
 type used for indices.
 
typedef float weight_type
 type used for weights.
 

Public Member Functions

 RelationElement ()
 Empty constructor for ROOT.
 
 RelationElement (index_type from, index_type to, weight_type weight=1.0)
 Constructor for a 1:1 relation. More...
 
 RelationElement (index_type from, const std::vector< index_type > &to, const std::vector< weight_type > &weights)
 Constructor for a 1:n relation. More...
 
template<class InputIterator >
 RelationElement (index_type from, const InputIterator &begin, const InputIterator &end)
 Constructor for a 1:n relation. More...
 
index_type getFromIndex () const
 Get index we point from.
 
size_t getSize () const
 Get number of indices we points to.
 
std::pair< index_type, weight_typegetTo (size_t n=0) const
 Get nth pair of index,weight we point to.
 
index_type getToIndex (size_t n=0) const
 Get nth index we point to.
 
weight_type getWeight (size_t n=0) const
 Get nth weight we point to.
 
const std::vector< index_type > & getToIndices () const
 Get vector of indices we point to.
 
const std::vector< weight_type > & getWeights () const
 Get vector of weights we point to.
 
void setFromIndex (index_type from)
 Set index we point from.
 
void setToIndex (index_type to, weight_type weight=1.0)
 Set index we point to, converts relation to 1:1 and discards all existing to-indices.
 
template<class InputIterator >
void setToIndices (InputIterator begin, const InputIterator &end)
 Set new indices and weights we point to. More...
 

Protected Member Functions

 ClassDef (RelationElement, 1)
 Class to store a single element of a relation.
 

Protected Attributes

index_type m_from
 index we point from.
 
std::vector< index_typem_to
 indices we point to.
 
std::vector< weight_typem_weights
 weights for to-indices.
 

Detailed Description

Class to store a single element of a relation.

Supports 1:n relations with individual weights.

Definition at line 25 of file RelationElement.h.

Constructor & Destructor Documentation

◆ RelationElement() [1/3]

RelationElement ( index_type  from,
index_type  to,
weight_type  weight = 1.0 
)
inline

Constructor for a 1:1 relation.

Parameters
fromindex to point from
toindex to point to
weightweight of the relation

Definition at line 44 of file RelationElement.h.

44  :
45  TObject(), m_from(from), m_to(1, to), m_weights(1, weight) {}
index_type m_from
index we point from.
std::vector< weight_type > m_weights
weights for to-indices.
std::vector< index_type > m_to
indices we point to.

◆ RelationElement() [2/3]

RelationElement ( index_type  from,
const std::vector< index_type > &  to,
const std::vector< weight_type > &  weights 
)

Constructor for a 1:n relation.

Parameters
fromindex to point from
toindices to point to
weightsweights of the relation

Definition at line 18 of file RelationElement.cc.

18  :
19  TObject(),
20  m_from(from),
21  m_to(to.begin(), to.end()),
22  m_weights(weights.begin(), weights.end())
23 {
24  if (to.size() != weights.size()) {
25  B2FATAL("Index and weight vector sizes differ!");
26  }
27 }

◆ RelationElement() [3/3]

RelationElement ( index_type  from,
const InputIterator &  begin,
const InputIterator &  end 
)
inline

Constructor for a 1:n relation.

Parameters
fromindex to point from
beginiterator pointing to the begin of a sequence of std::pair<index_type,weight_type> or compatible
enditerator pointing to the end of a sequence of std::pair<index_type,weight_type> or compatible

Definition at line 63 of file RelationElement.h.

Member Function Documentation

◆ setToIndices()

void setToIndices ( InputIterator  begin,
const InputIterator &  end 
)
inline

Set new indices and weights we point to.

Parameters
beginiterator pointing to the begin of a sequence of std::pair<index_type,weight_type> or compatible
enditerator pointing to the end of a sequence of std::pair<index_type,weight_type> or compatible

Definition at line 107 of file RelationElement.h.


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