Belle II Software  release-06-02-00
PXDRawDataGen.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 
19 
20 import basf2 as b2
21 
22 # show warnings during processing
23 b2.set_log_level(b2.LogLevel.WARNING)
24 
25 # Register modules
26 
27 # Particle gun module
28 particlegun = b2.register_module('ParticleGun')
29 # Create Event information
30 eventinfosetter = b2.register_module('EventInfoSetter')
31 # Show progress of processing
32 progress = b2.register_module('Progress')
33 # Load parameters
34 gearbox = b2.register_module('Gearbox')
35 # Create geometry
36 geometry = b2.register_module('Geometry')
37 # Run simulation
38 simulation = b2.register_module('FullSim')
39 # PXD digitization module
40 PXDDIGI = b2.register_module('PXDDigitizer')
41 # Convert digits to raw pxd data
42 PXDPACKER = b2.register_module('PXDPacker')
43 # Save output of simulation
44 output = b2.register_module('RootOutput')
45 
46 # ============================================================================
47 # Set a fixed random seed for particle generation:
48 b2.set_random_seed(1028307)
49 
50 # ============================================================================
51 # Setting the list of particle codes (PDG codes) for the generated particles
52 particlegun.param('pdgCodes', [-11, 11])
53 
54 # ============================================================================
55 # Setting the number of tracks to be generated per event:
56 particlegun.param('nTracks', 1)
57 
58 # ============================================================================
59 # Set the number of events to be processed (10 events)
60 eventinfosetter.param({'evtNumList': [100], 'runList': [1]})
61 
62 # ============================================================================
63 # Set output filename
64 output.param('outputFileName', 'PXDRawHit.root')
65 
66 # ============================================================================
67 # [[dhhc1, dhh1, dhh2, dhh3, dhh4, dhh5] [ ... ]]
68 # -1 is disable port
69 PXDPACKER.param('dhe_to_dhc', [
70  [0, 2, 4, 34, 36, 38],
71  [1, 6, 8, 40, 42, 44],
72  [2, 10, 12, 46, 48, 50],
73  [3, 14, 16, 52, 54, 56],
74  [4, 3, 5, 35, 37, 39],
75  [5, 7, 9, 41, 43, 45],
76  [6, 11, 13, 47, 49, 51],
77  [7, 15, 17, 53, 55, 57],
78 ])
79 
80 # ============================================================================
81 # Select subdetectors to be built
82 geometry.param('components', ['MagneticField', 'PXD'])
83 
84 # ============================================================================
85 # Do the simulation
86 
87 main = b2.create_path()
88 main.add_module(eventinfosetter)
89 main.add_module(progress)
90 main.add_module(gearbox)
91 main.add_module(geometry)
92 main.add_module(particlegun)
93 main.add_module(simulation)
94 main.add_module(PXDDIGI)
95 main.add_module(PXDPACKER)
96 main.add_module(output)
97 
98 # Process events
99 b2.process(main)
100 
101 # Print call statistics
102 print(b2.statistics)
103 #