Belle II Software development
onlyBGMixing.py
1#!/usr/bin/env python3
2
3
10
11import basf2 as b2
12import os
13import sys
14from simulation import add_simulation
15from reconstruction import add_reconstruction
16from mdst import add_mdst_output
17import glob
18
19# ----------------------------------------------------------------------------------
20# Example of simulation/reconstruction of events with beam background only.
21#
22# This example runs full simulation of beam BG only events using BeamBkgMixer module,
23# then runs full reconstruction and finaly writes the results to mdst file.
24# ----------------------------------------------------------------------------------
25
26b2.set_log_level(b2.LogLevel.ERROR)
27
28if 'BELLE2_BACKGROUND_MIXING_DIR' not in os.environ:
29 b2.B2ERROR('BELLE2_BACKGROUND_MIXING_DIR variable is not set - it must contain the path to BG mixing samples')
30 sys.exit()
31
32# background (collision) files
33bg = glob.glob(os.environ['BELLE2_BACKGROUND_MIXING_DIR'] + '/*.root')
34if len(bg) == 0:
35 b2.B2ERROR('No files found in ', os.environ['BELLE2_BACKGROUND_MIXING_DIR'])
36 sys.exit()
37
38# Create path
39main = b2.create_path()
40
41# Set number of events to generate
42eventinfosetter = b2.register_module('EventInfoSetter')
43eventinfosetter.param({'evtNumList': [10], 'runList': [1]})
44main.add_module(eventinfosetter)
45
46# Simulation
47add_simulation(main, bkgfiles=bg, bkgOverlay=False, simulateT0jitter=False)
48
49# Reconstruction
50add_reconstruction(main)
51
52# Mdst output
53add_mdst_output(main)
54
55# Show progress of processing
56progress = b2.register_module('Progress')
57main.add_module(progress)
58
59# Process events
60b2.process(main)
61
62# Print call statistics
63print(b2.statistics)