Belle II Software
development
EventCountLimiter.py
1
#!/usr/bin/env python3
2
3
10
11
# Purpose:
12
# basf module to return false if the event counter equals or exceeds the user-defined limit
13
#
14
import
basf2
15
16
# =========================================================================
17
#
18
# EventCountLimiter
19
#
20
# =========================================================================
21
22
23
class
EventCountLimiter
(basf2.Module):
24
"""Report when the event counter has reached or exceeded its limit"""
25
26
def
__init__
(self, maxCount):
27
"""Constructor
28
29
Argument:
30
maxCount (int): number of events to be processed
31
"""
32
super().
__init__
()
33
34
self.
maxCount
= maxCount
if
(maxCount >= 0)
else
(1 << 31)
35
36
self.
eventCounter
= 0
37
38
def
initialize
(self):
39
"""Handle job initialization (nothing to do here)"""
40
41
def
terminate
(self):
42
"""Handle job termination (nothing to do here)"""
43
44
def
beginRun
(self):
45
"""Handle begin of run (nothing to do here)"""
46
47
def
endRun
(self):
48
"""Handle end of run (nothing to do here)"""
49
50
def
event
(self):
51
"""Process one event: has eventCounter reached or exceeded its limit?"""
52
self.eventCounter += 1
53
super().return_value(self.eventCounter < self.maxCount)
EventCountLimiter.EventCountLimiter
Definition:
EventCountLimiter.py:23
EventCountLimiter.EventCountLimiter.maxCount
maxCount
internal copy of the event-counter upper limit
Definition:
EventCountLimiter.py:34
EventCountLimiter.EventCountLimiter.terminate
def terminate(self)
Definition:
EventCountLimiter.py:41
EventCountLimiter.EventCountLimiter.beginRun
def beginRun(self)
Definition:
EventCountLimiter.py:44
EventCountLimiter.EventCountLimiter.eventCounter
eventCounter
internal event counter
Definition:
EventCountLimiter.py:36
EventCountLimiter.EventCountLimiter.__init__
def __init__(self, maxCount)
Definition:
EventCountLimiter.py:26
EventCountLimiter.EventCountLimiter.initialize
def initialize(self)
Definition:
EventCountLimiter.py:38
EventCountLimiter.EventCountLimiter.endRun
def endRun(self)
Definition:
EventCountLimiter.py:47
EventCountLimiter.EventCountLimiter.event
def event(self)
Definition:
EventCountLimiter.py:50
klm
bklm
scripts
EventCountLimiter.py
Generated on Fri Nov 8 2024 02:39:30 for Belle II Software by
1.9.6