Belle II Software  release-08-01-10
test-simulation.py
1 #!/usr/bin/env python3
2 
3 
10 
11 import basf2 as b2
12 
13 # Don't show all the messages :)
14 b2.set_log_level(b2.LogLevel.ERROR)
15 
16 # Register modules
17 
18 # lets generate empty events
19 eventinfosetter = b2.register_module('EventInfoSetter')
20 # and shoot some particles into them
21 particlegun = b2.register_module('ParticleGun')
22 # load the simulation parameters
23 gearbox = b2.register_module('Gearbox')
24 # build the microtpc geometry
25 geometry = b2.register_module('Geometry')
26 # simulate our microtpc detector
27 simulation = b2.register_module('FullSim')
28 # do something with the microtpc data
29 # analysis = register_module('Csi')
30 # analysis = register_module('He3tube')
31 # analysis = register_module('Bgo')
32 # analysis = register_module('Pindiode')
33 # analysis = register_module('Srsensor')
34 # analysis = register_module('Microtpc')
35 # analysis = register_module('FANGS')
36 analysis = b2.register_module('CLAWS')
37 # save the microtpc results
38 output = b2.register_module('RootOutput')
39 # an show some progress of the microtpc simulation
40 progress = b2.register_module('Progress')
41 
42 # Now lets set some parameters ...
43 
44 # Generate run 1 with 500 events
45 eventinfosetter.param({'evtNumList': [500], 'runList': [1]})
46 
47 # Set the parameters for the particle gun
48 particlegun.param({ # Shoot electrons and positrons
49  # 5 particles per event
50  # but let the number be poisson distributed
51  # with a fixed momentum
52  # of 7 GeV
53  # and a gaussian distributed theta angle
54  # with mean 0 degree and width 1 degree
55  # and a uniform distributed phi angle
56  # between 0 and 360 degree
57  # but from a fixed position
58  # namely 0,0,0
59  # and the same vertex vor all particles
60  'pdgCodes': [11, 22, -11],
61  'nTracks': 1000,
62  'varyNTracks': True,
63  'momentumGeneration': 'fixed',
64  'momentumParams': [0.00004],
65  'thetaGeneration': 'normal',
66  'thetaParams': [0.0, 1.0],
67  'phiGeneration': 'uniform',
68  'phiParams': [0, 360.0],
69  'vertexGeneration': 'fixed',
70  'xVertexParams': [0.0],
71  'yVertexParams': [0.0],
72  'zVertexParams': [0.0],
73  'independentVertices': False,
74 })
75 
76 # Main XML parameter file to load, relative to global data directory
77 # gearbox.param('fileName', 'beast/microtpc/detector.xml')
78 # gearbox.param('fileName', 'beast/fangs/detector.xml')
79 gearbox.param('fileName', 'beast/claws/detector.xml')
80 # gearbox.param('fileName', 'beast/he3tube/detector.xml')
81 # gearbox.param('fileName', 'beast/bgo/detector.xml')
82 # gearbox.param('fileName', 'beast/pindiode/detector.xml')
83 # gearbox.param('fileName', 'beast/srsensor/detector.xml')
84 # gearbox.param('fileName', 'beast/plume/detector.xml')
85 # gearbox.param('fileName', 'beast/csi/detector.xml')
86 # Lets see some more information on geometry building
87 geometry.set_log_level(b2.LogLevel.INFO)
88 
89 # and also on our own module
90 analysis.set_log_level(b2.LogLevel.INFO)
91 
92 # And write the results to microtpc-simulation.root
93 # output.param('outputFileName', 'microtpc-simulation.root')
94 # output.param('outputFileName', 'fangs-simulation.root')
95 output.param('outputFileName', 'claws-simulation.root')
96 # output.param('outputFileName', 'plume-simulation.root')
97 # output.param('outputFileName', 'csi-simulation.root')
98 # output.param('outputFileName', 'he3tube-simulation.root')
99 # output.param('outputFileName', 'bgo-simulation.root')
100 # output.param('outputFileName', 'pindiode-simulation.root')
101 # output.param('outputFileName', 'srsensor-simulation.root')
102 output.param('updateFileCatalog', False)
103 
104 # Here we create a processing path and add the modules
105 main = b2.create_path()
106 main.add_module(eventinfosetter)
107 main.add_module(gearbox)
108 main.add_module(geometry)
109 main.add_module(particlegun)
110 main.add_module(simulation)
111 main.add_module(analysis)
112 main.add_module(output)
113 main.add_module(progress)
114 
115 # Now lets do the processing of the microtpc events
116 b2.process(main)
117 
118 # Print call statistics of our microtpc event processing
119 print(b2.statistics)