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