15 Wrapper around the variable manager class.
16 This
is necessary
for avoiding to
import ROOT globally when
'variables' is imported.
22 Return an instance to the variable manager.
26 instance = ROOT.Belle2.Variable.Manager.Instance()
31 Wrapper around Manager::getVariable(std::string name) and
32 Manager::
getVariable(const std::string& functionName, const std::vector<std::string>& functionArguments).
34 instance = PythonVariableManager._instance()
35 return instance.getVariable(*args)
39 Wrapper around Manager::getVariables(const std::vector<std::string>& variables) and
42 instance = PythonVariableManager._instance()
43 return instance.getVariables(*args)
47 Wrapper around Manager::addAlias(const std::string& alias, const std::string& variable).
49 instance = PythonVariableManager._instance()
50 assert(instance.addAlias(alias, variable))
57 instance = PythonVariableManager._instance()
58 instance.printAliases()
64 instance = PythonVariableManager._instance()
65 instance.clearAliases()
69 Wrapper around Manager::resolveAlias(const std::string& alias).
71 instance = PythonVariableManager._instance()
72 return instance.resolveAlias(alias)
76 Wrapper around Manager::addCollection(const std::string& collection, const std::vector<std::string>& variables)
78 instance = PythonVariableManager._instance()
79 assert(instance.addCollection(*args))
83 Wrapper around Manager::getCollection(const std::string& collection).
85 instance = PythonVariableManager._instance()
86 return instance.getCollection(collection)
92 instance = PythonVariableManager._instance()
93 return instance.resolveCollections(*args)
99 instance = PythonVariableManager._instance()
100 instance.checkDeprecatedVariable(variable)
104 Wrapper around Manager::evaluate(const std::string& varName, const Particle* p).
106 instance = PythonVariableManager._instance()
107 return instance.evaluate(variable, particle)
113 instance = PythonVariableManager._instance()
114 return instance.getNames()
120 instance = PythonVariableManager._instance()
121 return instance.getAliasNames()
127 instance = PythonVariableManager._instance()
128 instance.assertValidName(variable)
135def std_vector(*args):
137 Creates an std::vector which can be passed to pyROOT
141 v = ROOT.std.vector(type(args[0]))()
147def getCommandLineOptions():
148 """ Parses the command line options and returns the corresponding arguments. """
149 parser = argparse.ArgumentParser()
150 parser.add_argument(
'--no-pager', dest=
'pager', default=
True, action=
'store_false',
151 help=
'Use a pager to show output or print to terminal.')
152 args = parser.parse_args()
156def printVars(changedVariableNames=None, listVars=None):
158 Print list of all available variables.
161 if changedVariableNames:
162 print(changedVariableNames)
163 print(
'Available variables in Variable::Manager:')
166 listVars = variables.getVariables()
168 listVars = [variables.getVariable(name)
for name
in listVars]
170 dict_VariableDataType = {0:
'double', 1:
'int', 2:
'bool'}
174 vars.append((v.group, v.name, v.description,
175 dict_VariableDataType[v.variabletype]))
179 for (group, name, description, vartype)
in sorted(vars):
180 if current_group != group:
181 current_group = group
183 rows.append([name, description, vartype])
184 b2utils.pretty_print_description_list(rows)
187def printVariableType(listVars=None):
189 if isinstance(listVars, str):
190 listVars = [listVars]
192 dict_VariableDataType = {0:
'double', 1:
'int', 2:
'bool'}
194 for var_name
in listVars:
195 var = variables.getVariable(var_name)
196 print(f
"{var_name}: {dict_VariableDataType[var.variabletype]}")
201 Return all PSNM trigger bit names
205 bits = ROOT.Belle2.PyDBObj(
'TRGGDLDBFTDLBits')
206 evt = ROOT.Belle2.EventMetaData()
207 ROOT.Belle2.DBStore.Instance().update(evt)
208 size = ROOT.Belle2.TRGSummary.c_ntrgWords * ROOT.Belle2.TRGSummary.c_trgWordSize
209 return [bits.getoutbitname(i)
for i
in range(size)
if bits.getoutbitname(i) !=
'']
def evaluate(self, variable, particle)
def assertValidName(self, variable)
def addAlias(self, alias, variable)
def resolveAlias(self, alias)
def addCollection(self, *args)
def getCollection(self, collection)
def getVariables(self, *args)
def checkDeprecatedVariable(self, variable)
def getVariable(self, *args)
def resolveCollections(self, *args)