Belle II Software
development
Toggle main menu visibility
Main Page
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
z
Variables
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
v
w
x
z
Typedefs
a
b
c
d
e
g
i
k
l
m
n
p
r
s
t
u
v
w
Enumerations
Enumerator
c
d
f
p
t
v
Classes
Class List
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Enumerations
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
Enumerator
a
b
c
d
e
f
g
h
k
l
m
n
o
p
r
s
t
u
v
w
z
Related Functions
b
c
d
g
i
o
r
s
t
Files
File List
File Members
All
Functions
Typedefs
Macros
variablesToHistogram.py
1
#!/usr/bin/env python3
2
3
10
11
# The VariablesToHistogram module saves variables from the VariableManager
12
# to TH1F and TH2F here is an example of how to use it.
13
#
14
# For full documentation please refer to https://software.belle2.org
15
# Anything unclear? Ask questions at https://questions.belle2.org
16
17
import
basf2
18
import
modularAnalysis
as
ma
# a shorthand for the analysis tools namespace
19
20
mypath = basf2.Path()
# create a new path
21
22
# add input data and ParticleLoader modules to the path
23
ma.inputMdstList([basf2.find_file(
'analysis/tests/mdst.root'
)], path=mypath)
24
ma.fillParticleLists([(
'K-'
,
'kaonID > 0.2'
), (
'pi+'
,
'pionID > 0.2'
)], path=mypath)
25
ma.reconstructDecay(
'D0 -> K- pi+'
,
'1.750 < M < 1.95'
, path=mypath)
26
ma.matchMCTruth(
'D0'
, path=mypath)
27
28
# add the VariablesToHistogram module explicitly
29
mypath.add_module(
'VariablesToHistogram'
,
30
particleList=
'D0'
,
31
variables=[(
'dM'
, 100, -2.0, 2.0),
32
(
'isSignal'
, 2, -0.5, 1.5),
33
(
'mcErrors'
, 1025, -0.5, 1024.5),
34
(
'p'
, 1000, 0.0, 5.0),
35
(
'E'
, 1000, 0.0, 5.0),
36
(
'daughter(0, kaonID)'
, 100, 0.0, 1.0),
37
(
'daughter(1, pionID)'
, 100, 0.0, 1.0)],
38
variables_2d=[(
'dM'
, 100, -2.0, 2.0,
'isSignal'
, 2, -0.5, 1.5),
39
(
'p'
, 100, -2.0, 2.0,
'isSignal'
, 2, -0.5, 1.5),
40
(
'dM'
, 100, -2.0, 2.0,
'mcErrors'
, 1025, -0.5, 1024.5)])
41
42
# you might also like to uncomment the following, and read the help for the
43
# convenient wrapper function:
44
# print(help(ma.variablesToHistogram))
45
46
# process the data
47
basf2.process(mypath)
48
print(basf2.statistics)
analysis
examples
VariableManager
variablesToHistogram.py
Generated on Wed Apr 9 2025 02:34:18 for Belle II Software by
1.9.6