Belle II Software development
UpperBoundedSet< SupType > Class Template Reference

Represents an upper bounded set of arithmetic types. More...

#include <UpperBoundedSet.h>

Public Member Functions

 UpperBoundedSet (SupType sup)
 Constructor.
 
 UpperBoundedSet ()
 Constructor without argument.
 
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 sup value.
 
void setBranchAddress (TTree *t, const std::string &branchName, const std::string &)
 Setting the branch address for a filter in a TTree.
 
SupType getSup (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

SupType m_sup
 Supremum of the set.
 

Detailed Description

template<typename SupType>
class Belle2::UpperBoundedSet< SupType >

Represents an upper bounded set of arithmetic types.

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

Definition at line 29 of file UpperBoundedSet.h.

Constructor & Destructor Documentation

◆ UpperBoundedSet() [1/2]

UpperBoundedSet ( SupType  sup)
inlineexplicit

Constructor.

Definition at line 35 of file UpperBoundedSet.h.

35: m_sup(sup) {};
SupType m_sup
Supremum of the set.

◆ UpperBoundedSet() [2/2]

UpperBoundedSet ( )
inline

Constructor without argument.

Definition at line 38 of file UpperBoundedSet.h.

38: m_sup(0) {};

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 46 of file UpperBoundedSet.h.

46{ return x < m_sup;};

◆ 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 88 of file UpperBoundedSet.h.

89 {
90 std::string maxVal = std::to_string(m_sup);
91 // if pointer to vector is provided fill it
92 if (pointers != nullptr) {
93 // use the position in the vector as unique identifier
94 maxVal = "#" + std::to_string(pointers->size());
95 (*pointers).push_back({TBranchLeafType(m_sup), &m_sup});
96 }
97 return ("(" + varname + " < " + maxVal + ")");
98 }
char TBranchLeafType(const char *)
Overloading TBranchLeafType to be able to get identifier 'C' for type char*.

◆ getSup()

SupType getSup ( void  ) const
inline

Accessor to the sup of the set.

Definition at line 80 of file UpperBoundedSet.h.

80{ return m_sup; } ;

◆ persist()

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

Creates and sets the addresses of the leaves to store sup value.

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 57 of file UpperBoundedSet.h.

58 {
59
60 std::string leafList;
61 leafList += variableName;
62 leafList += "_sup/";
63 leafList += TBranchLeafType(m_sup);
64
65 TBranch* branch = new TBranch(t, branchName.c_str(), & m_sup, leafList.c_str());
66 t->GetListOfBranches()->Add(branch);
67 }

◆ setBranchAddress()

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

Setting the branch address for a filter in a TTree.

Parameters
t: the TTree in which the branch address shall be set
branchName: name of the branch

Definition at line 73 of file UpperBoundedSet.h.

75 {
76 if (t->SetBranchAddress(branchName, & m_sup) < 0) B2FATAL("UpperBoundedSet: branch address not valid!");
77 }

Member Data Documentation

◆ m_sup

SupType m_sup
private

Supremum of the set.

Definition at line 32 of file UpperBoundedSet.h.


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