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