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