Belle II Software
light-2205-abys
Main Page
Modules
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
z
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
Variables
Typedefs
a
b
c
d
l
m
n
p
r
s
w
Enumerations
Enumerator
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
_
c
d
e
f
h
i
m
o
p
r
s
t
v
w
Enumerations
b
c
e
g
h
m
p
s
t
v
Enumerator
b
c
k
t
Related Functions
Files
File List
File Members
All
Functions
variablesToNtuple.py
1
#!/usr/bin/env python3
2
3
10
11
# The VariablesToNtuple module saves variables from the VariableManager
12
# to a candidate-based (or event-based) TTree
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 VariablesToNtuple module explicitly.
29
# This will write out one row per candidate in the D0 list
30
mypath.add_module(
'VariablesToNtuple'
,
31
particleList=
'D0'
,
32
variables=[
'dM'
,
'isSignal'
,
'mcErrors'
,
'p'
,
'E'
,
33
'daughter(0, kaonID)'
,
'daughter(1, pionID)'
],
34
fileName=
'CandidateVariables.root'
)
35
36
# Add another instance of the VariablesToNtuple module.
37
# If the particle list is empty one row per event is written to the Ntuple,
38
# but all the variables to specify have to be event-based
39
mypath.add_module(
'VariablesToNtuple'
,
40
particleList=
''
,
41
variables=[
'nTracks'
,
'isMC'
,
'year'
],
42
fileName=
'EventVariables.root'
)
43
44
# you might also like to uncomment the following, and read the help for the
45
# convenient wrapper function:
46
# print(help(ma.variablesToNtuple))
47
48
# process the data
49
basf2.process(mypath)
50
print(basf2.statistics)
analysis
examples
VariableManager
variablesToNtuple.py
Generated on Thu Jun 9 2022 01:34:27 for Belle II Software by
1.9.1