Belle II Software development
ClosedUpperBoundedSet< MaxType > Class Template Reference

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

#include <ClosedUpperBoundedSet.h>

Public Member Functions

 ClosedUpperBoundedSet (MaxType max)
 constructor
 
 ClosedUpperBoundedSet ()
 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 the min and max values.
 
void setBranchAddress (TTree *t, const std::string &branchName, const std::string &)
 Set the branch address of the specified leafes to the data members.
 
MaxType getSup (void) const
 Accessor to the sup of the set (which is also the max)
 
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

MaxType m_max
 maximum of the set
 

Detailed Description

template<typename MaxType>
class Belle2::ClosedUpperBoundedSet< MaxType >

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 30 of file ClosedUpperBoundedSet.h.

Constructor & Destructor Documentation

◆ ClosedUpperBoundedSet() [1/2]

ClosedUpperBoundedSet ( MaxType  max)
inlineexplicit

constructor

Definition at line 37 of file ClosedUpperBoundedSet.h.

37: m_max(max) {};
MaxType m_max
maximum of the set

◆ ClosedUpperBoundedSet() [2/2]

constructor without argument

Definition at line 40 of file ClosedUpperBoundedSet.h.

40: m_max(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 closed set [ -infinity, m_max ]

Definition at line 49 of file ClosedUpperBoundedSet.h.

49{ return x <= m_max;};

◆ 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 92 of file ClosedUpperBoundedSet.h.

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

◆ getSup()

MaxType getSup ( void  ) const
inline

Accessor to the sup of the set (which is also the max)

Definition at line 84 of file ClosedUpperBoundedSet.h.

84{ return m_max; } ;

◆ 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 "_max" suffixes for the m_max value.

Definition at line 61 of file ClosedUpperBoundedSet.h.

62 {
63
64 std::string leafList;
65 leafList += variableName;
66 leafList += "_max/";
67 leafList += TBranchLeafType(m_max);
68
69 TBranch* branch = new TBranch(t, branchName.c_str(), & m_max, leafList.c_str());
70 t->GetListOfBranches()->Add(branch);
71 }

◆ setBranchAddress()

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

Set the branch address of the specified leafes to the data members.

Parameters
ttree for which the Branch addresses will be set
branchNamename of the branch

Definition at line 77 of file ClosedUpperBoundedSet.h.

79 {
80 if (t->SetBranchAddress(branchName.c_str(), & m_max) < 0) B2FATAL("ClosedUpperBoundedSet: branch address not valid!");
81 }

Member Data Documentation

◆ m_max

MaxType m_max
private

maximum of the set

Definition at line 33 of file ClosedUpperBoundedSet.h.


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