Belle II Software development
PXDTest.py
1#!/usr/bin/env python3
2
3
10
11
20
21import basf2 as b2
22
23# show warnings during processing
24b2.set_log_level(b2.LogLevel.WARNING)
25
26# Register modules
27
28# Particle gun module
29particlegun = b2.register_module('ParticleGun')
30# Create Event information
31eventinfosetter = b2.register_module('EventInfoSetter')
32# Show progress of processing
33progress = b2.register_module('Progress')
34# Load parameters
35gearbox = b2.register_module('Gearbox')
36# Create geometry
37geometry = b2.register_module('Geometry')
38# Run simulation
39simulation = b2.register_module('FullSim')
40# PXD digitization module
41PXDDIGI = b2.register_module('PXDDigitizer')
42# PXD clusterizer
43PXDCLUST = b2.register_module('PXDClusterizer')
44# Save output of simulation
45output = b2.register_module('RootOutput')
46
47# ============================================================================
48# Set a fixed random seed for particle generation:
49b2.set_random_seed(1028307)
50
51# ============================================================================
52# Setting the list of particle codes (PDG codes) for the generated particles
53particlegun.param('pdgCodes', [-11, 11])
54
55# ============================================================================
56# Setting the number of tracks to be generated per event:
57particlegun.param('nTracks', 1)
58
59# ============================================================================
60# Set the number of events to be processed (10 events)
61eventinfosetter.param({'evtNumList': [1000], 'runList': [1]})
62
63# Set output filename
64output.param('outputFileName', 'PXDTestOutput.root')
65
66# Select subdetectors to be built
67geometry.param('components', ['MagneticField', 'PXD'])
68
69PXDDIGI.set_log_level(b2.LogLevel.INFO)
70
71PXDCLUST.set_log_level(b2.LogLevel.INFO)
72
73# ============================================================================
74# Do the simulation
75
76main = b2.create_path()
77main.add_module(eventinfosetter)
78main.add_module(progress)
79main.add_module(gearbox)
80main.add_module(geometry)
81main.add_module(particlegun)
82main.add_module(simulation)
83main.add_module(PXDDIGI)
84main.add_module(PXDCLUST)
85
86main.add_module(output)
87
88# Process events
89b2.process(main)
90
91# Print call statistics
92print(b2.statistics)
93#