Belle II Software development
ClosedLowerBoundedSet< MinType > Class Template Reference

Represents a closed lower bounded set of arithmetic types. More...

#include <ClosedLowerBoundedSet.h>

Public Member Functions

 ClosedLowerBoundedSet (MinType min)
 Constructor.
 
 ClosedLowerBoundedSet ()
 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 value.
 
void setBranchAddress (TTree *t, const std::string &branchName, const std::string &)
 sets the branch address for m_min
 
MinType getInf (void) const
 Accessor to the inf of the set (which coincides with the min)
 
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

MinType m_min
 the minimum value for this range
 

Detailed Description

template<typename MinType>
class Belle2::ClosedLowerBoundedSet< MinType >

Represents a closed lower bounded set of arithmetic types.

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

Definition at line 30 of file ClosedLowerBoundedSet.h.

Constructor & Destructor Documentation

◆ ClosedLowerBoundedSet() [1/2]

ClosedLowerBoundedSet ( MinType  min)
inlineexplicit

Constructor.

Definition at line 34 of file ClosedLowerBoundedSet.h.

34: m_min(min) {};
MinType m_min
the minimum value for this range

◆ ClosedLowerBoundedSet() [2/2]

Constructor without argument.

Definition at line 37 of file ClosedLowerBoundedSet.h.

37: m_min(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 [ m_min, infinity ]

Definition at line 45 of file ClosedLowerBoundedSet.h.

45{ return m_min <= x ;};

◆ getInf()

MinType getInf ( void  ) const
inline

Accessor to the inf of the set (which coincides with the min)

Definition at line 78 of file ClosedLowerBoundedSet.h.

78{ return m_min; } ;

◆ 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 86 of file ClosedLowerBoundedSet.h.

87 {
88 std::string minVal = std::to_string(m_min);
89 // if pointer to vector is provided fill it
90 if (pointers != nullptr) {
91 // use the position in the vector as unique identifier
92 minVal = "#" + std::to_string(pointers->size());
93 (*pointers).push_back({TBranchLeafType(m_min), &m_min});
94 }
95 return ("(" + minVal + " <= " + varname + ")");
96 }
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 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 "_min" suffix for the min value.

Definition at line 56 of file ClosedLowerBoundedSet.h.

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

◆ setBranchAddress()

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

sets the branch address for m_min

Parameters
tpointer to the tree that contains the branch
branchNamereference to name of the branch

Definition at line 71 of file ClosedLowerBoundedSet.h.

73 {
74 if (t->SetBranchAddress(branchName.c_str(), & m_min) < 0) B2FATAL("ClosedLowerBoundedSet: branch address not valid");
75 }

Member Data Documentation

◆ m_min

MinType m_min
private

the minimum value for this range

Definition at line 100 of file ClosedLowerBoundedSet.h.


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