Belle II Software  release-06-01-15
awesome-simulation.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 '''
13 Minimal steering file to simulate the awesome detector.
14 '''
15 
16 import basf2 as b2
17 
18 # Don't show all the messages :)
19 b2.set_log_level(b2.LogLevel.ERROR)
20 
21 # Here we create a processing path and add the modules
22 main = b2.create_path()
23 
24 # create event meta-data
25 main.add_module('EventInfoSetter')
26 
27 # Main XML parameter file to load, relative to global data directory
28 main.add_module('Gearbox', fileName='online_book/awesome/detector.xml')
29 main.add_module('Geometry', useDB=False)
30 
31 # Shoot some particles into the detector
32 main.add_module('ParticleGun',
33  # Shoot electrons and positrons
34  pdgCodes=[11, -11],
35  # 5 particles per event
36  nTracks=5,
37  # but let the number be poisson distributed
38  varyNTracks=True,
39  # with a fixed momentum
40  momentumGeneration='fixed',
41  # of 7 GeV
42  momentumParams=[7.0],
43  # and a gaussian distributed theta angle
44  thetaGeneration='normal',
45  # with mean 0 degree and width 1 degree
46  thetaParams=[0.0, 1.0],
47  # and a uniform distributed phi angle
48  phiGeneration='uniform',
49  # between 0 and 360 degree
50  phiParams=[0, 360.0],
51  # but from a fixed position
52  vertexGeneration='fixed',
53  # namely 0,0,0
54  xVertexParams=[0.0],
55  yVertexParams=[0.0],
56  zVertexParams=[0.0],
57  # and the same vertex vor all particles
58  independentVertices=False)
59 
60 # Simulate our awesome detector
61 main.add_module('FullSim')
62 
63 # do something with the awesome data
64 main.add_module('AWESOMEBasic',
65  logLevel=b2.LogLevel.INFO)
66 
67 # save the awesome results
68 main.add_module('RootOutput', outputFileName='awesome-simulation.root')
69 
70 
71 # Now lets do the processing of the awesome events
72 b2.process(main)
73 
74 # Print call statistics of our awesome event processing
75 print(b2.statistics)