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