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
usingCollections.py
1
#!/usr/bin/env python3
2
3
# The VariablesToNtuple (and VariablesToTree) module support collections of variables.
4
# You specify a collection instead of a variable name, and the collection will be automatically
5
# resolved to a set of variable names
6
# the Python module variables.collections defines some default collections, just import it
7
#
8
# Thomas Keck and Sam Cunliffe
9
#
10
# For full documentation please refer to https://software.belle2.org
11
# Anything unclear? Ask questions at https://questions.belle2.org
12
13
import
basf2
14
import
variables.collections
# collections of variables
15
import
modularAnalysis
as
ma
# a shorthand for the analysis tools namespace
16
from
variables
import
variables
as
vm
# shorthand name for the VariableManager instance
17
18
# You can also define collections yourself
19
vm.addCollection(
'MyCollection'
,
variables.std_vector
(
'daughter(0, kaonID)'
,
'daughter(1, pionID)'
))
20
21
mypath = basf2.Path()
# create a new path
22
23
# add input data and ParticleLoader modules to the path
24
ma.inputMdstList(
'default'
, [basf2.find_file(
'analysis/tests/mdst.root'
)], path=mypath)
25
ma.fillParticleLists([(
'K-'
,
'kaonID > 0.2'
), (
'pi+'
,
'pionID > 0.2'
)], path=mypath)
26
ma.reconstructDecay(
'D0 -> K- pi+'
,
'1.750 < M < 1.95'
, path=mypath)
27
ma.matchMCTruth(
'D0'
, path=mypath)
28
29
# Add the VariablesToNtuple module explicitly
30
# this will write out one row per candidate in the D0 list
31
mypath.add_module(
'VariablesToNtuple'
,
32
particleList=
'D0'
,
33
variables=[
'kinematics'
,
'mc_truth'
,
'MyCollection'
],
34
fileName=
'CollectionVariables.root'
)
35
36
# Important note: In order to specify variable collections by string, e.g.
37
# "kinematics", "mc_truth", etc. you need to import variables.collections, even
38
# if you do not explicitly use any of its symbols (importing
39
# variables.collections sets up some default collections).
40
41
# you might also like to uncomment the following, and read the help for the
42
# convenient wrapper function:
43
# print(help(ma.variablesToNtuple))
44
45
# process the data
46
basf2.process
(mypath)
47
print(basf2.statistics)
basf2.process
def process(path, max_event=0)
Definition:
__init__.py:25
variables.std_vector
def std_vector(*args)
Definition:
__init__.py:20
variables.collections
Definition:
collections.py:1
analysis
examples
VariableManager
usingCollections.py
Generated on Tue Jan 4 2022 02:49:52 for Belle II Software by
1.8.17