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