Belle II Software development
event_limit.py
1#!/usr/bin/env python3
2
3
10
11"""
12This steering file demonstrates the capabilities of EventLimiter module.
13
14EventInfoSetter generates 200 events.
15
16Then, the filtering with EventLimiter makes it so that only 150 events
17pass into EventInfoPrinter
18
19If EventLimit payload was previously generated using add_event_limit.py,
20then the event limit will be adjusted based on payload contents.
21"""
22
23import basf2 as b2
24
25# Register necessary modules
26# Create paths
27main = b2.Path()
28
29# Generate 200 events
30main.add_module('EventInfoSetter', expList=[0], runList=[0], evtNumList=[200])
31
32# If no EventLimit payload in the database, discard
33# all events with event number >= 150.
34#
35# If EventLimit payload is available, get an actual
36# threshold value instead of 150.
37main.add_module('EventLimiter')
38limiter = main.add_module('EventLimiter', loadFromDB=True, maxEventsPerRun=150)
39limiter.if_value("==0", b2.Path(), b2.AfterConditionPath.END)
40
41# Print event meta info
42main.add_module('EventInfoPrinter')
43
44# Load payloads from the local database
45b2.conditions.reset()
46b2.conditions.prepend_testing_payloads('localdb/database.txt')
47
48# Process data
49b2.process(main)
50print(b2.statistics)