Belle II Software  release-06-02-00
PXDHitErrorGen.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 import basf2 as b2
13 from PXDHitErrorsTTree import PXDHitErrorsTTree
14 b2.logging.log_level = b2.LogLevel.WARNING
15 
16 # Particle gun module
17 particlegun = b2.register_module('ParticleGun')
18 # Create Event information
19 eventinfosetter = b2.register_module('EventInfoSetter')
20 # Show progress of processing
21 progress = b2.register_module('Progress')
22 # Load parameters
23 gearbox = b2.register_module('Gearbox')
24 # Create geometry
25 geometry = b2.register_module('Geometry')
26 # Run simulation
27 simulation = b2.register_module('FullSim')
28 # PXD digitization module
29 pxddigi = b2.register_module('PXDDigitizer')
30 # PXD clustering module
31 pxdclust = b2.register_module('PXDClusterizer')
32 # RootOutput
33 output = b2.register_module('RootOutput')
34 
35 analyze = PXDHitErrorsTTree()
36 
37 # Specify number of events to generate
38 eventinfosetter.param({'evtNumList': [10000], 'runList': [1]})
39 
40 # Set parameters for particlegun
41 particlegun.param({
42  # Generate 1 track (always)
43  'nTracks': 1,
44  # don't vary the number according to Poisson distribution
45  'varyNTracks': False,
46  # Generate pi+, pi-, e+ and e-
47  'pdgCodes': [211, -211, 11, -11],
48  # with a normal distributed transversal momentum
49  'momentumGeneration': 'normal',
50  # with a center of 2 GeV and a width of 0.2 GeV
51  'momentumParams': [2, 0.2],
52  # a uniform distributed phi angle,
53  'phiGeneration': 'uniform',
54  # full circle
55  'phiParams': [0, 360],
56  # Generate theta angles uniform in cos theta
57  'thetaGeneration': 'uniformCos',
58  # between 30 and 150 degree
59  'thetaParams': [30, 150],
60  # normal distributed vertex generation
61  'vertexGeneration': 'normal',
62  # around the origin with a sigma of 0.5cm in each direction
63  'xVertexParams': [0.0, 0.5],
64  'yVertexParams': [0.0, 0.5],
65  'zVertexParams': [0.0, 0.5],
66  # all one track sharing the same vertex per event
67  'independentVertices': False,
68 })
69 
70 # Select subdetectors to be built
71 geometry.param('components', ['MagneticField', 'PXD'])
72 
73 # pxddigi.param('statisticsFilename', 'digi.root')
74 pxddigi.param('ElectronicEffects', True)
75 pxddigi.param('SimpleDriftModel', False)
76 
77 # create processing path
78 main = b2.create_path()
79 main.add_module(eventinfosetter)
80 main.add_module(progress)
81 main.add_module(particlegun)
82 main.add_module(gearbox)
83 main.add_module(geometry)
84 main.add_module(simulation)
85 main.add_module(pxddigi)
86 main.add_module(pxdclust)
87 main.add_module(analyze)
88 # main.add_module(output)
89 
90 # generate events
91 b2.process(main)
92 
93 # show call statistics
94 print(b2.statistics)