5 from ROOT
import Belle2
14 Count the number of events passing this module and create a dictionary
15 of {(exp,run): events}
23 """Creates an entry in the global num_events dictionary"""
26 run = evtmetadata.obj().
getRun()
27 exp = evtmetadata.obj().getExperiment()
28 if (exp, run)
not in num_events:
29 num_events[(exp, run)] = 0
32 """Increments the right (Exp,Run) entry in the num_events dictionary"""
35 run = evtmetadata.obj().
getRun()
36 exp = evtmetadata.obj().getExperiment()
37 num_events[(exp, run)] += 1
44 main.add_module(
"EventInfoSetter", evtNumList=[input_events] * 3, expList=[0, 0, 1], runList=[0, 1, 0])
45 eventlimiter_mod = main.add_module(
'EventLimiter', maxEventsPerRun=500)
47 success_path = basf2.Path()
48 success_count = success_path.add_module(
CountEvents())
49 eventlimiter_mod.if_true(success_path)
53 print(basf2.statistics)
55 for passing_events
in num_events.values():
56 assert passing_events == max_events