Belle II Software  release-06-02-00
Simulation.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 # Reconstruction of generated ee->mumu(ISR) events.
13 
14 import glob
15 import os
16 import sys
17 import basf2
18 from simulation import add_simulation
19 from reconstruction import add_reconstruction, add_cdst_output
20 
21 # Set the global log level
22 basf2.set_log_level(basf2.LogLevel.INFO)
23 
24 input = basf2.register_module('RootInput')
25 input.param('inputFileName', sys.argv[1])
26 
27 # Create the main path and add the modules
28 main = basf2.create_path()
29 main.add_module(input)
30 
31 background_files = None
32 if 'BELLE2_BACKGROUND_DIR' in os.environ:
33  background_directory = os.environ['BELLE2_BACKGROUND_DIR']
34  background_files = glob.glob(background_directory + '/*.root')
35 else:
36  basf2.B2WARNING('The variable BELLE2_BACKGROUND_DIR is not set. '
37  'Beam background is not used in the simulation')
38 add_simulation(main, bkgfiles=background_files)
39 
40 add_reconstruction(main, reconstruct_cdst='rawFormat')
41 add_cdst_output(main, filename=sys.argv[2])
42 main.add_module('Progress')
43 
44 # generate events
45 basf2.process(main)
46 
47 # show call statistics
48 print(basf2.statistics)