Belle II Software
development
Toggle main menu visibility
Main Page
Topics
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
a
b
c
e
f
g
n
p
s
v
z
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 Symbols
b
c
d
g
i
o
r
s
t
Files
File List
File Members
All
Functions
Typedefs
Macros
▼
Belle II Software
►
Topics
►
Namespaces
►
Classes
▼
Files
▼
File List
►
alignment
►
analysis
►
arich
►
b2bii
►
background
►
beast
►
calibration
►
cdc
►
daq
►
decfiles
►
display
►
dqm
►
ecl
▼
framework
►
core
►
data
►
database
►
dataobjects
►
datastore
►
dbobjects
►
examples
►
gearbox
►
geometry
►
io
►
logging
►
modules
►
particledb
►
pcore
►
pybasf2
►
scripts
▼
tests
angle.cc
b2file-normalize.py
B2Vector3.cc
basf2_args.py
basf2_rootinit.py
BeamParameters.cc
binnedEventT0.cc
CalcMeanCov.cc
chain_input.py
check_globaltag_trim.py
check_payload_metadata.py
check_payload_names.py
checkRandomNumbers.py
conditional_iov.py
conditions.py
conditions_metadataprovider.cc
conditions_process2.py
const.cc
cutNodes.cc
database.cc
datastore.cc
dowhile.py
dry-run.py
emptyrelations.py
eventExtraInfo.cc
eventlimiter.py
eventT0.cc
evtmetadata.py
evtpdl.py
filemetadata.py
FileSystem.cc
findFile.py
foreach.py
formula_parser.cc
framework_cppcheck.py
framework_doxygen_check.py
gearbox.cc
generalCut.cc
hardwareClockSettings.cc
Helix.cc
HTML.cc
include_exclude_branches.py
independent_merge_path.py
independent_path.py
iointercept.cc
ioutils.cc
local_database_file.py
local_metadata_provider.py
logging.cc
logsummary.py
make_root_compatible.cc
mcevent_forwarding.py
merge_files.py
mixed_runs.py
module_paths.py
module_setparameters.py
modulelist.py
mrucache.cc
msghandler.cc
multiple_module_conditions.py
node_factory.cc
numberSequence.cc
parallel_processing.py
partialselect.py
path_serialisation.py
prescale.py
processstatistics.cc
prune_datastore.py
pylogging.py
pyroot_tfile.py
python_datastore.py
python_dbinterface.py
recommend.py
relations_consolidate.cc
relations_internal.cc
relationsobject.cc
root_input.py
root_output.py
root_output_split.py
root_returnvalues.py
ScopeGuards.cc
select_subset.cc
seqroot_input.py
seqroot_output.py
signals.py
sphinx_full_release.py
sphinx_light_release.py
sqlite.cc
stop_on_error.py
stream.cc
streamer_test.py
test_b2conditionsdb_commands.py
test_b2file-mix.py
test_b2help_recommendation.py
test_basf2_utils.py
test_calculation.py
test_calculationList.py
test_calculationProcess.py
test_calculationQueue.py
test_check_basf2_file.py
test_entities.py
test_environmentInformation.py
test_globaltag_forwarding.py
test_iov.py
test_IPythonHandler.py
test_light_dependencies.py
test_module_log_level.py
test_module_log_level_run.py
test_print_module_parameters.py
test_runningupdate.py
test_tag_merge.py
UncertainHelix.cc
unit.cc
utils.cc
►
tools
►
utilities
►
generators
►
geometry
►
hlt
►
ir
►
klm
►
masterclass
►
mdst
►
mva
►
online_book
►
pxd
►
rawdata
►
reconstruction
►
simulation
►
site_scons
►
structure
►
svd
►
top
►
tracking
►
trg
►
validation
►
vxd
Doxygen.h
resource_analyzer.py
►
File Members
root_input.py
1
#!/usr/bin/env python3
2
3
10
11
import
os
12
import
basf2
13
from
ROOT
import
Belle2
14
from
b2test_utils
import
safe_process, clean_working_directory
15
16
basf2.conditions.disable_globaltag_replay()
17
basf2.set_random_seed(
"something important"
)
18
# make sure FATAL messages don't have the function signature as this makes
19
# problems with clang printing namespaces differently
20
basf2.logging.set_info(basf2.LogLevel.FATAL, basf2.logging.get_info(basf2.LogLevel.ERROR))
21
basf2.logging.enable_summary(
False
)
22
23
24
class
NoopModule
(basf2.Module):
25
"""Doesn't do anything."""
26
27
24
class
NoopModule
(basf2.Module):
…
28
with
clean_working_directory():
29
for
filename
in
[
"root_input.root"
,
"chaintest_empty.root"
,
"chaintest_1.root"
,
"chaintest_2.root"
]:
30
os.symlink(basf2.find_file(f
'framework/tests/{filename}'
), filename)
31
32
main = basf2.Path()
33
# not used for anything, just checking whether the master module
34
# can be found if it's not the first module in the path.
35
main.add_module(
NoopModule
())
36
# load all branches, minus PXDClusters (relations with PXDClusters are automatically excluded)
37
# (yes, we also added PXDClusters in branchNames, to check if it's overridden by excludeBranchNames)
38
input_module = main.add_module(
"RootInput"
, inputFileName=
"root_input.root"
,
39
branchNames=[
'EventMetaData'
,
'PXDDigits'
,
'PXDTrueHits'
,
'PXDClusters'
],
40
excludeBranchNames=[
'PXDClusters'
], skipNEvents=1, logLevel=basf2.LogLevel.WARNING)
41
# print event information and datastore contents
42
main.add_module(
"EventInfoPrinter"
)
43
main.add_module(
"PrintCollections"
, printForEvent=0)
44
45
# Process events
46
assert
safe_process(main) == 0
47
48
# Test restricting the number of events per file
49
# This issues a warning because a part of the events is out of range
50
input_module.param(
'entrySequences'
, [
"0,3:10,23"
])
51
assert
safe_process(main) == 0
52
53
# Test starting directly with a given event. There will be a fatal error if the
54
# event is not found in the file so let's call process() in a child process to
55
# not be aborted
56
for
evtNo
in
range(1, 7):
57
main = basf2.Path()
58
main.add_module(
"RootInput"
, inputFileName=
'root_input.root'
,
59
branchNames=[
"EventMetaData"
], skipToEvent=[0, 1, evtNo], logLevel=basf2.LogLevel.WARNING)
60
main.add_module(
"EventInfoPrinter"
)
61
safe_process(main)
62
63
# Test eventSequences in detail
64
main = basf2.Path()
65
input_module = main.add_module(
'RootInput'
, inputFileNames=[
'chaintest_1.root'
,
'chaintest_2.root'
],
66
logLevel=basf2.LogLevel.WARNING)
67
# The first file contains the following event numbers (in this order)
68
# 2, 6, 5, 9, 10, 11, 8, 12, 1, 13, 15, 16
69
# We select more event than the file contains, to check if it works anyway
70
# The second file contains the following event numbers (in this order)
71
# 7, 6, 3, 8, 9, 12, 4, 11, 10, 16, 13, 17, 18, 14, 15
72
input_module.param(
'entrySequences'
, [
'0,3:4,10:100'
,
'1:2,4,12:13'
])
73
74
class
TestingModule
(basf2.Module):
75
"""
76
Test module which writes out the processed event numbers
77
into the global processed_event_numbers list
78
"""
79
80
def
__init__
(self, expected):
81
"""
82
Initialize this nice class with the list of expected event
83
numbers to see in the correct order
84
"""
85
super().
__init__
()
86
87
self.
emd
=
Belle2.PyStoreObj
(
'EventMetaData'
)
88
89
self.
_expected_event_numbers
= expected
90
91
self.
_processed_event_numbers
= []
92
80
def
__init__
(self, expected):
…
93
def
event
(self):
94
"""
95
Called for each event
96
"""
97
self.
_processed_event_numbers
.append(self.
emd
.getEvent())
98
93
def
event
(self):
…
99
def
terminate
(self):
100
"""
101
perform check
102
"""
103
# We only want to do the check if we actually execute the process() but
104
# since this script is called from basf2_args with --dry-run this is not
105
# always the case
106
assert
self.
_expected_event_numbers
== self.
_processed_event_numbers
107
108
main.add_module(
TestingModule
([2, 9, 10, 15, 16, 6, 3, 9, 18, 14]))
99
def
terminate
(self):
…
109
assert
safe_process(main) == 0
110
111
basf2.set_random_seed(
"something important"
)
112
# make sure FATAL messages don't have the function signature as this makes
113
# problems with clang printing namespaces differently
114
basf2.logging.set_info(basf2.LogLevel.FATAL, basf2.logging.get_info(basf2.LogLevel.ERROR))
115
116
# Test eventSequences parameter ':' in detail
117
main = basf2.Path()
118
input_module = main.add_module(
'RootInput'
, inputFileNames=[
'chaintest_1.root'
,
'chaintest_2.root'
],
119
logLevel=basf2.LogLevel.WARNING)
120
# The first file contains the following event numbers (in this order)
121
# 2, 6, 5, 9, 10, 11, 8, 12, 1, 13, 15, 16
122
# We select the complete first file.
123
# The second file contains the following event numbers (in this order)
124
# 7, 6, 3, 8, 9, 12, 4, 11, 10, 16, 13, 17, 18, 14, 15
125
input_module.param(
'entrySequences'
, [
':'
,
'1:2,4,12:13'
])
126
127
expected_event_numbers = [2, 6, 5, 9, 10, 11, 8, 12, 1, 13, 15, 16, 6, 3, 9, 18, 14]
128
main.add_module(
TestingModule
(expected_event_numbers))
129
130
assert
safe_process(main) == 0
131
132
full_list = [
"chaintest_empty.root"
,
"chaintest_1.root"
,
"chaintest_2.root"
,
"chaintest_1.root"
]
133
for
i
in
range(len(full_list)):
134
main = basf2.Path()
135
main.add_module(
'RootInput'
, inputFileNames=full_list[:i + 1])
136
main.add_module(
"EventInfoPrinter"
)
137
safe_process(main)
138
139
class
BrokenEventsModule
(basf2.Module):
140
"""
141
Small module to mark all events except for the ones in the given list as
142
discarded by the HLT
143
"""
144
145
def
__init__
(self, accepted):
146
"""
147
Initialize this nice class with the list/set of accepted event
148
numbers to see. Order not important. All other events will be flagged
149
as discarded.
150
"""
151
super().
__init__
()
152
153
self.
emd
=
Belle2.PyStoreObj
(
'EventMetaData'
)
154
155
self.
_accepted
= accepted
156
145
def
__init__
(self, accepted):
…
157
def
event
(self):
158
"""Set error flag if required"""
159
if
self.
emd
.getEvent()
not
in
self.
_accepted
:
160
error = Belle2.EventMetaData.c_HLTDiscard
if
self.
emd
.getEvent() % 2 == 0
else
\
161
Belle2.EventMetaData.c_HLTCrash
162
self.
emd
.addErrorFlag(error)
163
164
main = basf2.Path()
157
def
event
(self):
…
165
main.add_module(
"EventInfoSetter"
, evtNumList=10)
166
main.add_module(
BrokenEventsModule
({3, 5, 6, 8}))
167
main.add_module(
"RootOutput"
, outputFileName=
"brokenevents.root"
)
168
assert
safe_process(main) == 0
169
170
main = basf2.Path()
171
main.add_module(
"RootInput"
, inputFileName=
"brokenevents.root"
)
172
main.add_module(
TestingModule
([3, 5, 6, 8]))
173
assert
safe_process(main) == 0
139
class
BrokenEventsModule
(basf2.Module):
…
74
class
TestingModule
(basf2.Module):
…
Belle2::PyStoreObj
a (simplified) python wrapper for StoreObjPtr.
Definition
PyStoreObj.h:67
root_input.BrokenEventsModule
Definition
root_input.py:139
root_input.BrokenEventsModule._accepted
_accepted
list/set of accepted events
Definition
root_input.py:155
root_input.BrokenEventsModule.emd
emd
event metadata
Definition
root_input.py:153
root_input.BrokenEventsModule.__init__
__init__(self, accepted)
Definition
root_input.py:145
root_input.BrokenEventsModule.event
event(self)
Definition
root_input.py:157
root_input.NoopModule
Definition
root_input.py:24
root_input.TestingModule
Definition
root_input.py:74
root_input.TestingModule.terminate
terminate(self)
Definition
root_input.py:99
root_input.TestingModule._expected_event_numbers
list _expected_event_numbers
list of expected event numbers
Definition
root_input.py:89
root_input.TestingModule.emd
emd
event metadata
Definition
root_input.py:87
root_input.TestingModule._processed_event_numbers
list _processed_event_numbers
list of seen event numbers
Definition
root_input.py:91
root_input.TestingModule.__init__
__init__(self, expected)
Definition
root_input.py:80
root_input.TestingModule.event
event(self)
Definition
root_input.py:93
framework
tests
root_input.py
Generated on Sat May 17 2025 02:59:25 for Belle II Software by
1.13.2