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
40 Manager::getVariables().
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))
54 Wrapper around Manager::printAliases().
56 instance = PythonVariableManager._instance()
57 instance.printAliases()
61 Wrapper around Manager::clearAliases().
63 instance = PythonVariableManager._instance()
64 instance.clearAliases()
68 Wrapper around Manager::resolveAlias(const std::string& alias).
70 instance = PythonVariableManager._instance()
71 return instance.resolveAlias(alias)
75 Wrapper around Manager::addCollection(const std::string& collection, const std::vector<std::string>& variables)
77 instance = PythonVariableManager._instance()
78 assert(instance.addCollection(*args))
82 Wrapper around Manager::getCollection(const std::string& collection).
84 instance = PythonVariableManager._instance()
85 return instance.getCollection(collection)
89 Wrapper around Manager::resolveCollections(const std::vector<std::string>& variables).
91 instance = PythonVariableManager._instance()
92 return instance.resolveCollections(*args)
96 Wrapper around Manager::checkDeprecatedVariable(const std::string& name).
98 instance = PythonVariableManager._instance()
99 instance.checkDeprecatedVariable(variable)
103 Wrapper around Manager::evaluate(const std::string& varName, const Particle* p).
105 instance = PythonVariableManager._instance()
106 return instance.evaluate(variable, particle)
110 Wrapper around Manager::getNames().
112 instance = PythonVariableManager._instance()
113 return instance.getNames()
117 Wrapper around Manager::getAliasNames().
119 instance = PythonVariableManager._instance()
120 return instance.getAliasNames()
124 Wrapper around Manager::assertValidName(const std::string& name).
126 instance = PythonVariableManager._instance()
127 instance.assertValidName(variable)
134 def std_vector(*args):
136 Creates an std::vector which can be passed to pyROOT
140 v = ROOT.std.vector(type(args[0]))()
146 def getCommandLineOptions():
147 """ Parses the command line options and returns the corresponding arguments. """
148 parser = argparse.ArgumentParser()
149 parser.add_argument(
'--no-pager', dest=
'pager', default=
True, action=
'store_false',
150 help=
'Use a pager to show output or print to terminal.')
151 args = parser.parse_args()
155 def printVars(changedVariableNames=None, listVars=None):
157 Print list of all available variables.
160 if changedVariableNames:
161 print(changedVariableNames)
162 print(
'Available variables in Variable::Manager:')
165 listVars = variables.getVariables()
167 listVars = [variables.getVariable(name)
for name
in listVars]
169 dict_VariableDataType = {0:
'double', 1:
'int', 2:
'bool'}
173 vars.append((v.group, v.name, v.description,
174 dict_VariableDataType[v.variabletype]))
178 for (group, name, description, vartype)
in sorted(vars):
179 if current_group != group:
180 current_group = group
182 rows.append([name, description, vartype])
183 b2utils.pretty_print_description_list(rows)
186 def printVariableType(listVars=None):
188 if isinstance(listVars, str):
189 listVars = [listVars]
191 dict_VariableDataType = {0:
'double', 1:
'int', 2:
'bool'}
193 for var_name
in listVars:
194 var = variables.getVariable(var_name)
195 print(f
"{var_name}: {dict_VariableDataType[var.variabletype]}")
198 def getAllTrgNames():
200 Return all PSNM trigger bit names
204 bits = ROOT.Belle2.PyDBObj(
'TRGGDLDBFTDLBits')
205 evt = ROOT.Belle2.EventMetaData()
206 ROOT.Belle2.DBStore.Instance().update(evt)
207 size = ROOT.Belle2.TRGSummary.c_ntrgWords * ROOT.Belle2.TRGSummary.c_trgWordSize
208 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)