Belle II Software development
__init__.py
1#!/usr/bin/env python3
2
3
10
11import basf2 as b2
12import math
13
14
15def add_pxd_unpacker(path):
16 pxdunpacker = b2.register_module('PXDUnpacker')
17 path.add_module(pxdunpacker)
18
19 pxderrorcheck = b2.register_module('PXDPostErrorChecker')
20 path.add_module(pxderrorcheck)
21
22 pxdhitsorter = b2.register_module('PXDRawHitSorter')
23 path.add_module(pxdhitsorter)
24 if 'ActivatePXDPixelMasker' not in [e.name() for e in path.modules()]:
25 path.add_module('ActivatePXDPixelMasker')
26
27
28def add_pxd_packer(path):
29 pxdpacker = b2.register_module('PXDPacker')
30 pxdpacker.param('dhe_to_dhc', [
31 [
32 0,
33 2,
34 4,
35 34,
36 36,
37 38,
38 ],
39 [
40 1,
41 6,
42 8,
43 40,
44 42,
45 44,
46 ],
47 [
48 2,
49 10,
50 12,
51 46,
52 48,
53 50,
54 ],
55 [
56 3,
57 14,
58 16,
59 52,
60 54,
61 56,
62 ],
63 [
64 4,
65 3,
66 5,
67 35,
68 37,
69 39,
70 ],
71 [
72 5,
73 7,
74 9,
75 41,
76 43,
77 45,
78 ],
79 [
80 6,
81 11,
82 13,
83 47,
84 49,
85 51,
86 ],
87 [
88 7,
89 15,
90 17,
91 53,
92 55,
93 57,
94 ],
95 ])
96
97 path.add_module(pxdpacker)
98
99
100def add_pxd_reconstruction(
101 path,
102 clusterName=None,
103 digitsName=None,
104 usePXDClusterShapes=False,
105 spacePointsName='PXDSpacePoints'):
106 """
107 Add the PXD reconstruction modules
108 RegisterEventLevelTrackingInfo (if not already in path)
109 ActivatePXDClusterPositionEstimator (if required by usePXDClusterShapes and not already in path)
110 PXDClusterizer
111 PXDTrackingEventLevelMdstInfoFilter
112 PXDSpacePointCreator (if not already in path)
113 to the path.
114 :param path The path to add the modules tu
115 :param clusterName Name of the PXDCluster StoreArray if it should be custom
116 :param digitsName Name of the PXDDigits StoreArray if it should be custom
117 :param usePXDClusterShapes If True, use ActivatePXDClusterPositionEstimator for estimating PXDClusterPositions
118 :param spacePointsName Name of the PXDSpacePoints, defaults to PXDSpacePoints
119 """
120
121 # register EventTrackingInfo
122 if 'RegisterEventLevelTrackingInfo' not in path:
123 path.add_module('RegisterEventLevelTrackingInfo')
124
125 if usePXDClusterShapes:
126 if 'ActivatePXDClusterPositionEstimator' not in [e.name() for e in path.modules()]:
127 shape_activator = b2.register_module('ActivatePXDClusterPositionEstimator')
128 shape_activator.set_name('ActivatePXDClusterPositionEstimator')
129 path.add_module(shape_activator)
130
131 if 'PXDClusterizer' not in [e.name() for e in path.modules()]:
132 clusterizer = b2.register_module('PXDClusterizer')
133 clusterizer.set_name('PXDClusterizer')
134 if clusterName:
135 clusterizer.param('Clusters', clusterName)
136 if digitsName:
137 clusterizer.param('Digits', digitsName)
138 path.add_module(clusterizer)
139
140 path.add_module('PXDTrackingEventLevelMdstInfoFiller')
141
142 path.add_module('PXDSpacePointCreator',
143 PXDClusters=clusterName if clusterName else '',
144 SpacePoints=spacePointsName)
145
146
147def add_pxd_simulation(path, digitsName=None, activatePixelMasks=True, activateGainCorrection=True):
148
149 if activatePixelMasks and 'ActivatePXDPixelMasker' not in [e.name() for e in path.modules()]:
150 path.add_module('ActivatePXDPixelMasker')
151 if activateGainCorrection and 'ActivatePXDGainCalibrator' not in [e.name() for e in path.modules()]:
152 path.add_module('ActivatePXDGainCalibrator')
153
154 digitizer = b2.register_module('PXDDigitizer')
155 if digitsName:
156 digitizer.param('Digits', digitsName)
157 path.add_module(digitizer)
158
159
160def add_pxd_fullframe(path, min_ladders=(1, 1), max_ladders=(8, 12)):
161 modules = []
162 for layer in [1, 2]:
163 min_ladder = min_ladders[layer - 1]
164 max_ladder = max_ladders[layer - 1]
165 for ladder in range(min_ladder, max_ladder + 1):
166 for sensor in [1, 2]:
167 modules.append((layer, ladder, sensor))
168
169 for (layer, ladder, sensor) in modules:
170 path.add_module('ROIGenerator', ROIListName='ROIs', nROIs=1, TrigDivider=1,
171 Layer=layer, Ladder=ladder, Sensor=sensor,
172 MinU=0, MaxU=249, MinV=0, MaxV=767)
173
174
175def add_pxd_fullframe_phase3_early(path):
176 add_pxd_fullframe(path, min_ladders=(1, 4), max_ladders=(8, 5))
177
178
179def add_pxd_percentframe(path, min_ladders=(1, 1), max_ladders=(8, 12), fraction=0.1, random_position=False):
180 modules = []
181 for layer in [1, 2]:
182 min_ladder = min_ladders[layer - 1]
183 max_ladder = max_ladders[layer - 1]
184 for ladder in range(min_ladder, max_ladder + 1):
185 for sensor in [1, 2]:
186 modules.append((layer, ladder, sensor))
187
188 # Center ROI and make them a bit more realistic, enlarge in z ;-)
189 # Random position not supported yet -> need change in module code
190 s = math.sqrt(fraction)
191 MinU = max(0, int(250 / 2 * (1 - 0.5 * s)))
192 MaxU = 249 - MinU
193 MinV = max(0, int(768 / 2 * (1 - 2.0 * s)))
194 MaxV = 767 - MinV
195
196 for (layer, ladder, sensor) in modules:
197 path.add_module('ROIGenerator', ROIListName='ROIs', nROIs=1, TrigDivider=1,
198 Layer=layer, Ladder=ladder, Sensor=sensor,
199 MinU=MinU, MaxU=MaxU, MinV=MinV, MaxV=MaxV, Random=random_position)
200
201
202def add_pxd_percentframe_phase3_early(path, fraction=0.1, random_position=False):
203 add_pxd_percentframe(path, min_ladders=(1, 4), max_ladders=(8, 5), fraction=fraction, random_position=random_position)
204
205
206def add_roi_payload_assembler(path, ignore_hlt_decision):
207 path.add_module('ROIPayloadAssembler',
208 ROIListName='ROIs', ROIpayloadName='ROIpayload',
209 SendAllDownscaler=0, SendROIsDownscaler=1,
210 AcceptAll=ignore_hlt_decision, NoRejectFlag=False)
211
212
213def add_roi_finder(path):
214 """
215 Add the PXDDataReduction module to preserve the tracking informaiton for ROI calculation
216 :param path: The path to which the module should be added
217 :param calcROIs: True: turn on the ROI calculation, False: turn off
218 """
219
220 path.add_module('PXDROIFinder', recoTrackListName='RecoTracks',
221 PXDInterceptListName='PXDIntercepts', ROIListName='ROIs')