Belle II Software development
prescale.py
1#!/usr/bin/env python3
2
3
10
11import basf2
12basf2.set_random_seed(501)
13
14
15class CountEvents(basf2.Module):
16 """Count the number of events passing this module"""
17
18 def initialize(self):
19 """Start number of events at zero"""
20
21 self.num_events = 0
22
23 def event(self):
24 """Increment number of events each event"""
25 self.num_events += 1
26
27
28input_events = 1000
29expected_success_events = 6
30
31main = basf2.Path()
32main.add_module("EventInfoSetter", evtNumList=[input_events], expList=[0], runList=[0])
33prescale_mod = main.add_module('Prescale', prescale=0.01)
34
35success_path = basf2.Path()
36success_count = success_path.add_module(CountEvents())
37prescale_mod.if_true(success_path)
38
39basf2.process(main)
40
41print(basf2.statistics)
42
43assert success_count.num_events == expected_success_events
def initialize(self)
Definition: prescale.py:18
num_events
Stores the total number of events passing this module.
Definition: prescale.py:21
def event(self)
Definition: prescale.py:23