Belle II Software
release-05-02-19
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
k
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
u
v
w
x
z
Typedefs
a
b
c
d
e
h
i
l
m
n
p
r
s
t
v
w
Enumerations
Enumerator
c
d
f
p
t
u
v
w
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
variablesToEventBasedTree.py
1
#!/usr/bin/env python3
2
3
# The VariablesToEventBasedTree module saves variables from the VariableManager
4
# to an event-based TTree
5
#
6
# Thomas Keck and Sam Cunliffe
7
#
8
# For full documentation please refer to https://software.belle2.org
9
# Anything unclear? Ask questions at https://questions.belle2.org
10
11
import
basf2
12
import
modularAnalysis
as
ma
# a shorthand for the analysis tools namespace
13
14
mypath = basf2.Path()
# create a new path
15
16
# add input data and ParticleLoader modules to the path
17
ma.inputMdstList(
'default'
, [basf2.find_file(
'analysis/tests/mdst.root'
)], path=mypath)
18
ma.fillParticleLists([(
'K-'
,
'kaonID > 0.2'
), (
'pi+'
,
'pionID > 0.2'
)], path=mypath)
19
ma.reconstructDecay(
'D0 -> K- pi+'
,
'1.750 < M < 1.95'
, path=mypath)
20
ma.matchMCTruth(
'D0'
, path=mypath)
21
22
# This will write out one row per event in the TTree
23
# The branches of the TTree are arrays containing the variables for each D0 candidate in the event
24
# The event_variables are handled differently, the branches of these event_variables are just floats,
25
# you can use this to write out candidate independent information (aka event-based variables)
26
mypath.add_module(
'VariablesToEventBasedTree'
,
27
particleList=
'D0'
,
28
variables=[
'dM'
,
'isSignal'
,
'mcErrors'
,
'p'
,
'E'
,
29
'daughter(0, kaonID)'
,
'daughter(1, pionID)'
],
30
event_variables=[
'nTracks'
,
'isMC'
])
31
# It's possible to have multiple event-based trees in the same output file.
32
# Of course their names have to be different.
33
mypath.add_module(
'VariablesToEventBasedTree'
,
34
particleList=
'K-'
,
35
treeName=
'kaon'
,
36
variables=[
'isSignal'
,
'mcErrors'
,
'p'
,
'E'
,
'kaonID'
],
37
event_variables=[
'nTracks'
,
'isMC'
])
38
39
# process the data
40
basf2.process
(mypath)
41
print(basf2.statistics)
basf2.process
def process(path, max_event=0)
Definition:
__init__.py:25
analysis
examples
VariableManager
variablesToEventBasedTree.py
Generated on Tue Jan 4 2022 02:49:52 for Belle II Software by
1.8.17