Belle II Software  release-08-01-10
variables_python.py
1 #!/usr/bin/env python3
2 
3 
10 
11 from variables import printVars
12 from variables import std_vector
13 from variables import variables as v
14 # used in FEI
15 import ROOT
16 
17 # some variables should be there
18 assert len(v.getVariables()) > 0
19 
20 printVars()
21 
22 var = v.getVariable('M')
23 assert 'M' == var.name
24 print(var.description)
25 
26 v.addAlias('sigProb', 'extraInfo(SignalProbability)')
27 var = v.getVariable('sigProb')
28 assert 'extraInfo(SignalProbability)' == var.name
29 
30 assert (v.evaluate('constant(123)', ROOT.nullptr) - 123) < 0.001
31 
32 v.addAlias('anotherAlias', 'daughter(1, p)')
33 
34 for vn in v.getAliasNames():
35  assert (vn == 'sigProb' or vn == 'anotherAlias')
36 
37 v.addAlias('formulaAlias', 'abs(3**2)')
38 assert v.evaluate('formulaAlias', ROOT.nullptr) == 9.0
39 
40 
41 assert 'extraInfo__boSignalProbability__bc' == ROOT.Belle2.MakeROOTCompatible.makeROOTCompatible('extraInfo(SignalProbability)')
42 assert 'extraInfo(SignalProbability)' == ROOT.Belle2.MakeROOTCompatible.invertMakeROOTCompatible(
43  'extraInfo__boSignalProbability__bc')
44 
45 v.addCollection('kin', std_vector('p', 'px', 'py', 'pz'))
46 vec = v.getCollection('kin')
47 assert vec[0] == 'p'
48 assert vec[1] == 'px'
49 assert vec[2] == 'py'
50 assert vec[3] == 'pz'