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