Belle II Software  release-05-01-25
MakeMC.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
14 
15 from basf2 import *
16 import glob
17 from ROOT import Belle2
18 from modularAnalysis import *
19 from simulation import add_simulation
20 from reconstruction import add_reconstruction
21 from beamparameters import add_beamparameters
22 
23 particle_type = sys.argv[1] # particle mc pdg code
24 p_min = sys.argv[2] # input in MeV
25 p_max = sys.argv[3] # input in MeV
26 theta_min = sys.argv[4] # input in deg
27 theta_max = sys.argv[5] # input in deg
28 file_num = sys.argv[6] # file numbering scheme
29 
30 # Create paths
31 main = create_path()
32 
33 # Event setting and info
34 eventinfosetter = register_module('EventInfoSetter')
35 eventinfosetter.param({'evtNumList': [100], 'runList': [1]})
36 main.add_module(eventinfosetter)
37 
38 set_random_seed(123456)
39 set_log_level(LogLevel.ERROR)
40 
41 # generator settings
42 pGun = register_module('ParticleGun')
43 param_pGun = {
44  'pdgCodes': [int(particle_type)],
45  'nTracks': 1,
46  'momentumGeneration': 'uniform',
47  'momentumParams': [float(p_min) / 1000, float(p_max) / 1000],
48  'thetaGeneration': 'uniform',
49  'thetaParams': [float(theta_min), float(theta_max)],
50  'phiGeneration': 'uniform',
51  'phiParams': [0., 360.],
52  'vertexGeneration': 'uniform',
53  'xVertexParams': [0.0, 0.0],
54  'yVertexParams': [0.0, 0.0],
55  'zVertexParams': [0.0, 0.0],
56 }
57 pGun.param(param_pGun)
58 main.add_module(pGun)
59 
60 
61 # include beam background
62 bg = glob.glob('/group/belle2/BGFile/OfficialBKG/15thCampaign/bgoverlay_phase3/bgoverlay*.root')
63 add_simulation(main, bkgfiles=bg)
64 add_reconstruction(main)
65 
66 # output file
67 output = register_module('RootOutput')
68 output.param('outputFileName', './MDST_pdg'+str(particle_type)+'_BGx1_'+str(file_num)+'.root')
69 main.add_module(output)
70 
71 process(main)
72 print(statistics)