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