Belle II Software development
SingleElementSet< Type > Class Template Reference

Represents a set containing a single element;. More...

#include <SingleElementSet.h>

Public Member Functions

 SingleElementSet (Type element)
 Constructor.
 
template<class VariableType >
bool contains (const VariableType &x) const
 Method used by the filter tools to decide on the fate of the pair.
 
void persist (TTree *t, const std::string &branchName, const std::string &variableName)
 Creates and sets the addresses of the leaves to store the min and max values.
 
Type getElement (void) const
 Accessor to the sup of the set.
 
std::string getNameAndReference (std::vector< std::pair< char, void * > > *pointers=nullptr, const std::string &varname="x")
 generates a "name" and fills the vector with the variable references
 

Private Attributes

Type m_element
 Member variable for the single element of the set.
 

Detailed Description

template<typename Type>
class Belle2::SingleElementSet< Type >

Represents a set containing a single element;.

SingleElementSet is used in conjunction with the SelectionVariable to define one of the building blocks of the Filters

Definition at line 27 of file SingleElementSet.h.

Constructor & Destructor Documentation

◆ SingleElementSet()

SingleElementSet ( Type  element)
inlineexplicit

Constructor.

Definition at line 32 of file SingleElementSet.h.

32: m_element(element) {};
Type m_element
Member variable for the single element of the set.

Member Function Documentation

◆ contains()

bool contains ( const VariableType &  x) const
inline

Method used by the filter tools to decide on the fate of the pair.

Parameters
xis the result of some SelectionVariable applied to a pair of objects. The return value is true if x belongs to the open set ( -infinity, m_sup )

Definition at line 40 of file SingleElementSet.h.

40{ return x == m_element;};

◆ getElement()

Type getElement ( void  ) const
inline

Accessor to the sup of the set.

Definition at line 64 of file SingleElementSet.h.

64{ return m_element; } ;

◆ getNameAndReference()

std::string getNameAndReference ( std::vector< std::pair< char, void * > > *  pointers = nullptr,
const std::string &  varname = "x" 
)
inline

generates a "name" and fills the vector with the variable references

Parameters
pointerspointer to vector which contains a pair of char which indicates the type object pointed to and the actual pointers to the bounds, if equal to nullptr it will not be filled
varnameoptional name of the filter this range is attached to make the output look nicer

Definition at line 71 of file SingleElementSet.h.

72 {
73 std::string val = std::to_string(m_element);
74 // if pointer to vector is provided fill it
75 if (pointers != nullptr) {
76 // use the position in the vector as unique identifier
77 val = "#" + std::to_string(pointers->size());
78 (*pointers).push_back({TBranchLeafType(m_element), &m_element});
79 }
80 return ("(" + val + " == " + varname + ")");
81 }
char TBranchLeafType(const char *)
Overloading TBranchLeafType to be able to get identifier 'C' for type char*.

◆ persist()

void persist ( TTree *  t,
const std::string &  branchName,
const std::string &  variableName 
)
inline

Creates and sets the addresses of the leaves to store the min and max values.

Parameters
tthe pointer to the TTree that will contain the TBranch of this range.
branchNamethe name of the TBranch that will host this range.
variableNamethe name of the selection variable this range is applied to.

The leaves will be named as the selection variable name with the "_sup" suffixes for the m_sup value.

Definition at line 51 of file SingleElementSet.h.

52 {
53
54 std::string leafList;
55 leafList += variableName;
56 leafList += "_sup/";
57 leafList += TBranchLeafType(m_element);
58
59 TBranch* branch = new TBranch(t, branchName.c_str(), & m_element, leafList.c_str());
60 t->GetListOfBranches()->Add(branch);
61 }

Member Data Documentation

◆ m_element

Type m_element
private

Member variable for the single element of the set.

Definition at line 29 of file SingleElementSet.h.


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