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