Belle II Software  release-08-01-10
particleGun-noBF.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 # -------------------------------------------------------------------------------------------------------
5 # Example on how to simulate/reconstruct single particle events w/o intoducing bunch finder inefficiency.
6 # Could be useful for AI training.
7 #
8 # usage: basf2 particleGunSimu-noBF.py -o <my_output_filename.root> -n <events_to_generate>
9 # -------------------------------------------------------------------------------------------------------
10 
11 import basf2 as b2
12 from simulation import add_simulation
13 from reconstruction import add_reconstruction
14 from mdst import add_mdst_output
15 
16 main = b2.create_path()
17 main.add_module('EventInfoSetter')
18 main.add_module('ParticleGun',
19  pdgCodes=[321, -321],
20  nTracks=1,
21  varyNTracks=False, # will generate single kaon per event
22  momentumGeneration='uniform',
23  momentumParams=[0.05, 5.0],
24  thetaGeneration='uniformCos', # this makes angular distribution uniform in the solid angle
25  phiGeneration='uniform')
26 add_simulation(main, simulateT0jitter=False) # switch-off simulation of L1 trigger time jitter
27 add_reconstruction(main)
28 main = b2.remove_module(main, 'TOPBunchFinder') # remove bunch finder from the path
29 
30 # output to file: use -o option to specify file name
31 add_mdst_output(main)
32 
33 main.add_module('Progress')
34 b2.process(main)
35 
36 # Print call statistics
37 print(b2.statistics)