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
eventlimiter.py
1
#!/usr/bin/env python3
2
3
10
11
import
basf2
12
from
ROOT
import
Belle2
13
14
15
num_events = {}
16
17
18
class
CountEvents
(basf2.Module):
19
20
"""
21
Count the number of events passing this module and create a dictionary
22
of {(exp,run): events}
23
"""
24
25
def
initialize
(self):
26
"""Not implemented"""
27
25
def
initialize
(self):
…
28
def
beginRun
(self):
29
"""Creates an entry in the global num_events dictionary"""
30
global
num_events
31
evtmetadata =
Belle2.PyStoreObj
(
'EventMetaData'
)
32
run = evtmetadata.obj().getRun()
33
exp = evtmetadata.obj().getExperiment()
34
if
(exp, run)
not
in
num_events:
35
num_events[(exp, run)] = 0
36
28
def
beginRun
(self):
…
37
def
event
(self):
38
"""Increments the right (Exp,Run) entry in the num_events dictionary"""
39
global
num_events
40
evtmetadata =
Belle2.PyStoreObj
(
'EventMetaData'
)
41
run = evtmetadata.obj().getRun()
42
exp = evtmetadata.obj().getExperiment()
43
num_events[(exp, run)] += 1
44
45
37
def
event
(self):
…
18
class
CountEvents
(basf2.Module):
…
46
input_events = 1000
47
max_events = 500
48
49
main = basf2.Path()
50
main.add_module(
"EventInfoSetter"
, evtNumList=[input_events] * 3, expList=[0, 0, 1], runList=[0, 1, 0])
51
eventlimiter_mod = main.add_module(
'EventLimiter'
, maxEventsPerRun=500)
52
53
success_path = basf2.Path()
54
success_count = success_path.add_module(
CountEvents
())
55
eventlimiter_mod.if_true(success_path)
56
57
basf2.process(main)
58
59
print(basf2.statistics)
60
61
for
passing_events
in
num_events.values():
62
assert
passing_events == max_events
Belle2::PyStoreObj
a (simplified) python wrapper for StoreObjPtr.
Definition
PyStoreObj.h:67
eventlimiter.CountEvents
Definition
eventlimiter.py:18
eventlimiter.CountEvents.initialize
initialize(self)
Definition
eventlimiter.py:25
eventlimiter.CountEvents.event
event(self)
Definition
eventlimiter.py:37
eventlimiter.CountEvents.beginRun
beginRun(self)
Definition
eventlimiter.py:28
framework
tests
eventlimiter.py
Generated on Sun May 18 2025 02:57:43 for Belle II Software by
1.13.2