Belle II Software light-2406-ragdoll
variableManager.py
1#!/usr/bin/env python3
2
3
10
11# The variableManager provides helpful tools for managing your variables.
12#
13# For full documentation please refer to https://software.belle2.org
14# Anything unclear? Ask questions at https://questions.belle2.org
15
16import ROOT
17import variables
18from variables import variables as vm # shorthand name for the VariableManager instance
19
20# Get information about a variable:
21var = vm.getVariable('M')
22print("Name and Description of Variable M")
23print(var.name)
24print(var.description)
25
26# Also see variablesToExtraInfo.py
27vm.addAlias('sigProb', 'extraInfo(SignalProbability)')
28var = vm.getVariable('sigProb')
29print("Real name of sigProb: ", var.name)
30
31# We can also define collections of variables. For more on this, see usingCollections.py
32vm.addCollection('Kinematics', variables.std_vector('px', 'py', 'pz'))
33var = vm.getCollection('Kinematics')
34print("Collection named Kinematics: ", list(var))
35
36result = vm.evaluate('constant(123)', ROOT.nullptr)
37print("Result of evaluating the variable 'constant(123)' ", result)
38
39# the variable names can contain special characters like (,:
40# Therefore we have to escape the variable names before putting them into ROOT files.
41# You can get the branch-names outputted by modules like VariablesToHistogram, VariablesToNtuple and
42# VariablesToTree using the makeROOTCompatible function
43var = "extraInfo(SignalProbability)"
44print("Root Compatible name of ", var, " is ", ROOT.Belle2.MakeROOTCompatible.makeROOTCompatible(var))
45
46print("You can get a full list of all available variables using 'basf2 variables.py'")
def std_vector(*args)
Definition: __init__.py:135