Belle II Software development
ClosedLowerBoundedSet.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <tracking/trackFindingVXD/filterMap/filterFramework/TBranchLeafType.h>
12#include <TBranch.h>
13#include <TTree.h>
14
15#include <framework/logging/Logger.h>
16
17namespace Belle2 {
29 template< typename MinType >
31 public:
32
34 explicit ClosedLowerBoundedSet(MinType min): m_min(min) {};
35
38
44 template< class VariableType >
45 inline bool contains(const VariableType& x) const { return m_min <= x ;};
46
56 void persist(TTree* t, const std::string& branchName, const std::string& variableName)
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 }
66
71 void setBranchAddress(TTree* t, const std::string& branchName,
72 const std::string& /*variableName*/)
73 {
74 if (t->SetBranchAddress(branchName.c_str(), & m_min) < 0) B2FATAL("ClosedLowerBoundedSet: branch address not valid");
75 }
76
78 MinType getInf(void) const { return m_min; } ;
79
80
86 std::string getNameAndReference(std::vector< std::pair<char, void*> >* pointers = nullptr, const std::string& varname = "X")
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 }
97
98 private:
100 MinType m_min;
101 };
102
103
105}
Represents a closed lower bounded set of arithmetic types.
MinType m_min
the minimum value for this range
ClosedLowerBoundedSet()
Constructor without argument.
MinType getInf(void) const
Accessor to the inf of the set (which coincides with the min)
ClosedLowerBoundedSet(MinType min)
Constructor.
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.
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
bool contains(const VariableType &x) const
Method used by the filter tools to decide on the fate of the pair.
void setBranchAddress(TTree *t, const std::string &branchName, const std::string &)
sets the branch address for m_min
char TBranchLeafType(const char *)
Overloading TBranchLeafType to be able to get identifier 'C' for type char*.
Abstract base class for different kinds of events.