Belle II Software development
dedxPID_evtgen.py
1#!/usr/bin/env python3
2
3
10
11
21
22import basf2 as b2
23from tracking import add_tracking_reconstruction
24
25# change to True if you want to use PXD hits (fairly small benefit, if any)
26use_pxd = False
27
28# register necessary modules
29eventinfosetter = b2.register_module('EventInfoSetter')
30
31# --------------------
32# generation
33# --------------------
34
35eventinfosetter.param('expList', [0])
36eventinfosetter.param('runList', [1])
37eventinfosetter.param('evtNumList', [50])
38eventinfoprinter = b2.register_module('EventInfoPrinter')
39
40# create geometry
41gearbox = b2.register_module('Gearbox')
42geometry = b2.register_module('Geometry')
43geometry.param('excludedComponents', ['EKLM'])
44
45# EvtGen to provide generic BB events
46evtgeninput = b2.register_module('EvtGenInput')
47
48
49# --------------------
50# simulation
51# --------------------
52
53g4sim = b2.register_module('FullSim')
54# make the simulation less noisy
55g4sim.logging.log_level = b2.LogLevel.ERROR
56
57
58# -------------------
59# dE/dx reconstruction
60# --------------------
61
62# set up the CDC dE/dx module
63cdcdedx = b2.register_module('CDCDedxPID')
64cdcdedx_params = { # 'pdfFile': 'YourPDFFile.root',
65 'useIndividualHits': True,
66 'removeLowest': 0.05,
67 'removeHighest': 0.25,
68 'onlyPrimaryParticles': False,
69 'enableDebugOutput': True,
70 'ignoreMissingParticles': False,
71}
72cdcdedx.param(cdcdedx_params)
73
74# set up the VXD dE/dx module
75svddedx = b2.register_module('VXDDedxPID')
76svddedx_params = { # 'pdfFile': 'YourPDFFile.root',
77 'useIndividualHits': True,
78 'removeLowest': 0.05,
79 'removeHighest': 0.25,
80 'onlyPrimaryParticles': False,
81 'usePXD': use_pxd,
82 'useSVD': True,
83 'trackDistanceThreshold': 4.0,
84 'ignoreMissingParticles': False,
85}
86svddedx.param(svddedx_params)
87
88# write the results to file
89output = b2.register_module('RootOutput')
90output.param('outputFileName', 'dedxPID_evtgen.root')
91
92
93# create paths
94main = b2.create_path()
95
96
97# add modules to paths
98main.add_module(eventinfosetter)
99main.add_module(eventinfoprinter)
100main.add_module(gearbox)
101main.add_module(geometry)
102
103main.add_module(evtgeninput)
104main.add_module(g4sim)
105
106if use_pxd:
107 main.add_module(b2.register_module('PXDDigitizer'))
108 main.add_module(b2.register_module('PXDClusterizer'))
109main.add_module(b2.register_module('SVDDigitizer'))
110main.add_module(b2.register_module('SVDClusterizer'))
111main.add_module(b2.register_module('CDCDigitizer'))
112
113# tracking reconstruction does not include dE/dx measurements
114add_tracking_reconstruction(main)
115
116main.add_module(cdcdedx)
117main.add_module(svddedx)
118
119main.add_module(output)
120
121# process events and print call statistics
122b2.process(main)
123print(b2.statistics)