12from ROOT
import Belle2
21 Count the number of events passing this module and create a dictionary
22 of {(exp,run): events}
29 """Creates an entry in the global num_events dictionary"""
32 run = evtmetadata.obj().getRun()
33 exp = evtmetadata.obj().getExperiment()
34 if (exp, run)
not in num_events:
35 num_events[(exp, run)] = 0
38 """Increments the right (Exp,Run) entry in the num_events dictionary"""
41 run = evtmetadata.obj().getRun()
42 exp = evtmetadata.obj().getExperiment()
43 num_events[(exp, run)] += 1
50main.add_module(
"EventInfoSetter", evtNumList=[input_events] * 3, expList=[0, 0, 1], runList=[0, 1, 0])
51eventlimiter_mod = main.add_module(
'EventLimiter', maxEventsPerRun=500)
53success_path = basf2.Path()
54success_count = success_path.add_module(
CountEvents())
55eventlimiter_mod.if_true(success_path)
59print(basf2.statistics)
61for passing_events
in num_events.values():
62 assert passing_events == max_events
a (simplified) python wrapper for StoreObjPtr.