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