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