Belle II Software development
083_module.py
1#!/usr/bin/env python3
2
3import basf2 as b2
4
5
6class MinModule(b2.Module):
7 """A minimal example of a basf2 module in python."""
8
9 def __init__(self):
10 """Constructor"""
11 # call constructor of base class, required if you implement __init__
12 # yourself!
13 super().__init__()
14 # and do whatever else is necessary like declaring member variables
15
16 def initialize(self):
17 """Called once in the beginning just before starting processing"""
18 b2.B2INFO("initialize()")
19
20 def beginRun(self):
21 """Called every time a run changes before the actual events in that run
22 are processed
23 """
24 b2.B2INFO("beginRun()")
25
26 def event(self):
27 """Called once for each event"""
28 b2.B2INFO("event()")
29
30 def endRun(self):
31 """Called every time a run changes after the actual events in that run
32 were processed
33 """
34 b2.B2INFO("endRun()")
35
36 def terminate(self):
37 """Called once after all the processing is complete"""
38 b2.B2INFO("terminate()")
39
40
41# create a path
42main = b2.Path()
43
44# set to generate 10 dummy events
45main.add_module("EventInfoSetter", evtNumList=[10])
46
47# and add our module
48main.add_module(MinModule())
49
50# run the path
51b2.process(main)
def terminate(self)
Definition: 083_module.py:36
def beginRun(self)
Definition: 083_module.py:20
def initialize(self)
Definition: 083_module.py:16
def __init__(self)
Definition: 083_module.py:9