Belle II Software development
test-simulation.py
1#!/usr/bin/env python3
2
3
10
11import basf2 as b2
12
13# Don't show all the messages :)
14b2.set_log_level(b2.LogLevel.ERROR)
15
16# Register modules
17
18# lets generate empty events
19eventinfosetter = b2.register_module('EventInfoSetter')
20# and shoot some particles into them
21particlegun = b2.register_module('ParticleGun')
22# load the simulation parameters
23gearbox = b2.register_module('Gearbox')
24# build the microtpc geometry
25geometry = b2.register_module('Geometry')
26# simulate our microtpc detector
27simulation = 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')
36analysis = b2.register_module('CLAWS')
37# save the microtpc results
38output = b2.register_module('RootOutput')
39# an show some progress of the microtpc simulation
40progress = b2.register_module('Progress')
41
42# Now lets set some parameters ...
43
44# Generate run 1 with 500 events
45eventinfosetter.param({'evtNumList': [500], 'runList': [1]})
46
47# Set the parameters for the particle gun
48particlegun.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')
79gearbox.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
87geometry.set_log_level(b2.LogLevel.INFO)
88
89# and also on our own module
90analysis.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')
95output.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')
102output.param('updateFileCatalog', False)
103
104# Here we create a processing path and add the modules
105main = b2.create_path()
106main.add_module(eventinfosetter)
107main.add_module(gearbox)
108main.add_module(geometry)
109main.add_module(particlegun)
110main.add_module(simulation)
111main.add_module(analysis)
112main.add_module(output)
113main.add_module(progress)
114
115# Now lets do the processing of the microtpc events
116b2.process(main)
117
118# Print call statistics of our microtpc event processing
119print(b2.statistics)