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