16 def add_svd_reconstruction(path, isROIsimulation=False, createRecoDigits=False, applyMasking=False):
18 Adds the SVD reconstruction to the path.
20 Reconstruction starts with :ref:`SVDShaperDigits<svdshapers>`
21 and :ref:`SVDEventInfo<svdeventinfo>` and provides
22 :ref:`SVDClusters<svdclusters>` and :ref:`SVDSpacePoints<svdsps>`.
24 @param path: add the modules to this basf2 path.
25 @param isROIsimulation: SVD reconstruction can be run during simulation\
26 in order to simulate the PXD Data Reduction with ROI finding.
27 @param createRecoDigits: if True, :ref:`SVDRecoDigits<svdrecos>` are created.
28 @param applyMasking: if True, hot strips found in :ref:`SVDHotStripsCalibration<svdhotstrips>` are masked.
33 nameTrackingInfoModule =
"RegisterEventLevelTrackingInfo__ROI"
34 nameEventTrackingInfo =
"EventLevelTrackingInfo__ROI"
35 nameSVDTrackingEventLevelMdstInfoFiller =
"SVDTrackingEventLevelMdstInfoFiller__ROI"
37 nameTrackingInfoModule =
"RegisterEventLevelTrackingInfo"
38 nameEventTrackingInfo =
"EventLevelTrackingInfo"
39 nameSVDTrackingEventLevelMdstInfoFiller =
"SVDTrackingEventLevelMdstInfoFiller"
41 if nameTrackingInfoModule
not in path:
42 registerEventlevelTrackingInfo = b2.register_module(
'RegisterEventLevelTrackingInfo')
43 registerEventlevelTrackingInfo.set_name(nameTrackingInfoModule)
44 registerEventlevelTrackingInfo.param(
'EventLevelTrackingInfoName', nameEventTrackingInfo)
45 path.add_module(registerEventlevelTrackingInfo)
48 clusterizerName =
'__ROISVDClusterizer'
49 recocreatorName =
'__ROISVDRecoDigitCreator'
50 dataFormatName =
'__ROISVDDataFormat'
52 clustersName =
'__ROIsvdClusters'
54 missingAPVsClusterCreatorName =
'__ROISVDMissingAPVsClusterCreator'
56 clusterizerName =
'SVDClusterizer'
57 recocreatorName =
'SVDRecoDigitCreator'
58 dataFormatName =
'SVDDataFormat'
62 missingAPVsClusterCreatorName =
'SVDMissingAPVsClusterCreator'
67 shaperDigitsName =
'__ROISVDShaperDigitsUnmasked'
68 maskingName =
'__ROISVDStripMasking'
70 shaperDigitsName =
'SVDShaperDigitsUnmasked'
71 maskingName =
'SVDStripMasking'
73 if maskingName
not in [e.name()
for e
in path.modules()]:
74 masking = b2.register_module(
'SVDStripMasking')
75 masking.set_name(maskingName)
76 masking.param(
'ShaperDigitsUnmasked', shaperDigitsName)
77 path.add_module(masking)
80 if dataFormatName
not in [e.name()
for e
in path.modules()]:
81 dataFormat = b2.register_module(
'SVDDataFormatCheck')
82 dataFormat.param(
'ShaperDigits', shaperDigitsName)
84 if clusterizerName
not in [e.name()
for e
in path.modules()]:
85 clusterizer = b2.register_module(
'SVDClusterizer')
86 clusterizer.set_name(clusterizerName)
87 clusterizer.param(
'ShaperDigits', shaperDigitsName)
88 clusterizer.param(
'Clusters', clustersName)
89 path.add_module(clusterizer)
91 if missingAPVsClusterCreatorName
not in [e.name()
for e
in path.modules()]:
92 missingAPVCreator = b2.register_module(
'SVDMissingAPVsClusterCreator')
93 missingAPVCreator.set_name(missingAPVsClusterCreatorName)
94 path.add_module(missingAPVCreator)
96 if nameSVDTrackingEventLevelMdstInfoFiller
not in path:
97 svdTrackingEventLevelMdstInfoFiller = b2.register_module(
'SVDTrackingEventLevelMdstInfoFiller')
98 svdTrackingEventLevelMdstInfoFiller.set_name(nameSVDTrackingEventLevelMdstInfoFiller)
99 svdTrackingEventLevelMdstInfoFiller.param(
'EventLevelTrackingInfoName', nameEventTrackingInfo)
100 svdTrackingEventLevelMdstInfoFiller.param(
'svdClustersName', clustersName)
101 path.add_module(svdTrackingEventLevelMdstInfoFiller)
104 add_svd_SPcreation(path, isROIsimulation)
106 if createRecoDigits
and not isROIsimulation:
109 add_svd_create_recodigits(path, recocreatorName, shaperDigitsName)
112 def add_svd_create_recodigits(path, recocreatorName="SVDRecoDigitCreator", shaperDigitsName=""):
114 Adds the strip reconstruction to the path.
116 Produce :ref:`SVDRecoDigits<svdrecos>` from :ref:`SVDShaperDigits<svdshapers>`.
118 @param path: add the modules to this basf2 path.
119 @param recocreatorName: name of the module.
120 @param shaperDigitsName: name of the SVDShaperDigits StoreArray.
123 if recocreatorName
not in [e.name()
for e
in path.modules()]:
124 recoDigitCreator = b2.register_module(
'SVDRecoDigitCreator')
125 recoDigitCreator.param(
'ShaperDigits', shaperDigitsName)
126 recoDigitCreator.param(
'timeAlgorithm6Samples',
"CoG3")
127 recoDigitCreator.param(
'timeAlgorithm3Samples',
"CoG3")
128 recoDigitCreator.param(
'chargeAlgorithm6Samples',
"MaxSample")
129 recoDigitCreator.param(
'chargeAlgorithm3Samples',
"MaxSample")
130 recoDigitCreator.param(
'useDB',
False)
131 path.add_module(recoDigitCreator)
134 def add_rel5_svd_reconstruction(path, isROIsimulation=False, applyMasking=False):
136 Adds the old (up to release-05) SVD recontruction to the path.
138 Reconstruction starts with :ref:`SVDShaperDigits<svdshapers>` and
139 :ref:`SVDEventInfo<svdeventinfo>` and provides :ref:`SVDClusters<svdclusters>`
140 and :ref:`SVDSpacePoints<svdsps>`.
142 @param path: add the modules to this basf2 path.
143 @param isROIsimulation: SVD reconstruction can be run during simulation\
144 in order to simulate the PXD Data Reduction with ROI finding.
145 @param applyMasking: if True, hot strips found in :ref:`SVDHotStripsCalibration<svdhotstrips>` are masked.
150 nameTrackingInfoModule =
"RegisterEventLevelTrackingInfo__ROI"
151 nameEventTrackingInfo =
"EventLevelTrackingInfo__ROI"
152 nameSVDTrackingEventLevelMdstInfoFiller =
"SVDTrackingEventLevelMdstInfoFiller__ROI"
154 nameTrackingInfoModule =
"RegisterEventLevelTrackingInfo"
155 nameEventTrackingInfo =
"EventLevelTrackingInfo"
156 nameSVDTrackingEventLevelMdstInfoFiller =
"SVDTrackingEventLevelMdstInfoFiller"
158 if nameTrackingInfoModule
not in path:
159 registerEventlevelTrackingInfo = b2.register_module(
'RegisterEventLevelTrackingInfo')
160 registerEventlevelTrackingInfo.set_name(nameTrackingInfoModule)
161 registerEventlevelTrackingInfo.param(
'EventLevelTrackingInfoName', nameEventTrackingInfo)
162 path.add_module(registerEventlevelTrackingInfo)
165 fitterName =
'__ROISVDCoGTimeEstimator'
166 clusterizerName =
'__ROISVDSimpleClusterizer'
167 dataFormatName =
'__ROISVDDataFormat'
168 clusterName =
'__ROIsvdClusters'
169 recoDigitsName =
'__ROIsvdRecoDigits'
170 shaperDigitsName =
""
171 missingAPVsClusterCreatorName =
'__ROISVDMissingAPVsClusterCreator'
173 fitterName =
'SVDCoGTimeEstimator'
174 clusterizerName =
'SVDSimpleClusterizer'
175 dataFormatName =
'SVDDataFormat'
178 shaperDigitsName =
""
179 missingAPVsClusterCreatorName =
'SVDMissingAPVsClusterCreator'
184 shaperDigitsName =
'__ROISVDShaperDigitsUnmasked'
185 maskingName =
'__ROISVDStripMasking'
187 shaperDigitsName =
'SVDShaperDigitsUnmasked'
188 maskingName =
'SVDStripMasking'
190 if maskingName
not in [e.name()
for e
in path.modules()]:
191 masking = b2.register_module(
'SVDStripMasking')
192 masking.set_name(maskingName)
193 masking.param(
'ShaperDigitsUnmasked', shaperDigitsName)
194 path.add_module(masking)
196 if dataFormatName
not in [e.name()
for e
in path.modules()]:
197 dataFormat = b2.register_module(
'SVDDataFormatCheck')
198 dataFormat.param(
'ShaperDigits', shaperDigitsName)
200 if fitterName
not in [e.name()
for e
in path.modules()]:
201 fitter = b2.register_module(
'SVDCoGTimeEstimator')
202 fitter.set_name(fitterName)
203 fitter.param(
'RecoDigits', recoDigitsName)
204 path.add_module(fitter)
206 if clusterizerName
not in [e.name()
for e
in path.modules()]:
207 clusterizer = b2.register_module(
'SVDSimpleClusterizer')
208 clusterizer.set_name(clusterizerName)
209 clusterizer.param(
'RecoDigits', recoDigitsName)
210 clusterizer.param(
'Clusters', clusterName)
211 clusterizer.param(
'useDB',
True)
212 path.add_module(clusterizer)
214 if missingAPVsClusterCreatorName
not in [e.name()
for e
in path.modules()]:
215 missingAPVCreator = b2.register_module(
'SVDMissingAPVsClusterCreator')
216 missingAPVCreator.set_name(missingAPVsClusterCreatorName)
217 path.add_module(missingAPVCreator)
219 if nameSVDTrackingEventLevelMdstInfoFiller
not in path:
220 svdTrackingEventLevelMdstInfoFiller = b2.register_module(
'SVDTrackingEventLevelMdstInfoFiller')
221 svdTrackingEventLevelMdstInfoFiller.set_name(nameSVDTrackingEventLevelMdstInfoFiller)
222 svdTrackingEventLevelMdstInfoFiller.param(
'EventLevelTrackingInfoName', nameEventTrackingInfo)
223 svdTrackingEventLevelMdstInfoFiller.param(
'svdClustersName', clustersName)
224 path.add_module(svdTrackingEventLevelMdstInfoFiller)
227 add_svd_SPcreation(path, isROIsimulation)
230 def add_svd_simulation(path, useConfigFromDB=False, daqMode=2, relativeShift=9):
232 Adds the SVD simulation to the path.
234 Simulation ends with :ref:`SVDShaperDigits<svdshapers>` and :ref:`SVDEventInfo<svdeventinfo>`.
236 @param path: add the modules to this basf2 path.
237 @param useConfigFromDB: if True, read the SVD configuration from :ref:`SVDGlobalConfigParameters<svdglobalconfig>`.
238 @param daqMode: = 2 for the default 6-sample mode, = 1 for the 3-sample mode, = 3 for the 3-mixed-6 sample mode.
239 @param relativeShift: relative time shift between the 3-sample and the 6-sample mode in units of 1/4 of APV clock.\
240 If ``useConfigFromDB`` is True, the value of this parameter is overwritten.
243 svdevtinfoset = b2.register_module(
"SVDEventInfoSetter")
244 svdevtinfoset.param(
"useDB", useConfigFromDB)
245 path.add_module(svdevtinfoset)
247 digitizer = b2.register_module(
'SVDDigitizer')
248 path.add_module(digitizer)
250 if not useConfigFromDB:
251 if daqMode != 2
and daqMode != 1
and daqMode != 3:
252 print(
"OOPS the acquisition mode that you want to simulate is not available.")
253 print(
"Please choose among daqMode = 2 (6-sample) and daqMode = 1 (3-sample). Exiting now.")
257 svdevtinfoset.param(
"daqMode", daqMode)
258 svdevtinfoset.param(
"relativeShift", relativeShift)
261 def add_svd_unpacker(path):
263 Adds the SVD Unpacker to the path.
265 The unpacker produces :ref:`SVDShaperDigits<svdshapers>` and :ref:`SVDEventInfo<svdeventinfo>`.
267 @param path: add the modules to this basf2 path.
270 unpacker = b2.register_module(
'SVDUnpacker')
271 path.add_module(unpacker)
274 def add_svd_unpacker_simulate3sampleDAQ(path, latencyShift=-1, relativeShift=-1):
276 Adds the SVD Unpacker to the path, emulating the 3-sample mode from the 6-sample mode.
278 @param path: add the modules to this basf2 path.
279 @param latencyShift: relative time shift between the 3-sample and the 6-sample mode, in APV clocks.\
280 0 <= latencyShift <=3
281 @param relativeShift: relative time shift between the 3-sample and the 6-sample mode, in units of 1/4 of APV clock.\
282 0 <= relativeShift <=12
284 .. warning:: at least one between ``relativeShift`` and ``latencyShift`` should be set (different from -1).
287 if relativeShift != -1
and latencyShift != -1:
288 print(
"OOPS please choose only one between relativeShift and latencyShift. Exiting now.")
291 unpacker = b2.register_module(
'SVDUnpacker')
292 unpacker.param(
"SVDEventInfo",
"SVDEventInfoOriginal")
293 unpacker.param(
"svdShaperDigitListName",
"SVDShaperDigitsOriginal")
294 path.add_module(unpacker)
297 emulator = b2.register_module(
"SVD3SamplesEmulator")
298 emulator.param(
"SVDEventInfo",
"SVDEventInfoOriginal")
299 emulator.param(
"SVDShaperDigits",
"SVDShaperDigitsOriginal")
300 if latencyShift == -1:
301 emulator.param(
"chooseStartingSample",
False)
303 emulator.param(
"chooseStartingSample",
True)
304 if latencyShift < 0
or latencyShift > 3:
305 B2FATAL(
"the latencyShift must be an integer >=0 and <= 3")
307 emulator.param(
"StartingSample", latencyShift)
309 if relativeShift == -1:
310 emulator.param(
"chooseRelativeShift",
False)
312 emulator.param(
"chooseRelativeShift",
True)
313 if relativeShift < 0
or relativeShift > 12:
314 B2FATAL(
"the relativeShift must be an integer >=0 and <= 12")
316 emulator.param(
"relativeShift", relativeShift)
318 emulator.param(
"outputSVDEventInfo",
"SVDEventInfo")
319 emulator.param(
"outputSVDShaperDigits",
"SVDShaperDigits3SampleAll")
320 path.add_module(emulator)
323 zsonline = b2.register_module(
"SVDZeroSuppressionEmulator")
324 zsonline.param(
"ShaperDigits",
"SVDShaperDigits3SampleAll")
325 zsonline.param(
"ShaperDigitsIN",
"SVDShaperDigits")
326 path.add_module(zsonline)
329 def add_svd_packer(path):
331 Adds the SVD Packer to the path.
333 @param path: add the modules to this basf2 path.
336 packer = b2.register_module(
'SVDPacker')
337 path.add_module(packer)
340 def add_svd_SPcreation(path, isROIsimulation=False):
342 Adds the SVD SpacePoint Creator to the path.
344 @param path: add the modules to this basf2 path.
345 @param isROIsimulation: SVD reconstruction can be run during simulation\
346 in order to simulate the PXD Data Reduction with ROI finding.
351 nameTrackingInfoModule =
"RegisterEventLevelTrackingInfo__ROI"
352 nameEventTrackingInfo =
"EventLevelTrackingInfo__ROI"
354 nameTrackingInfoModule =
"RegisterEventLevelTrackingInfo"
355 nameEventTrackingInfo =
"EventLevelTrackingInfo"
357 if nameTrackingInfoModule
not in path:
358 registerEventlevelTrackingInfo = b2.register_module(
'RegisterEventLevelTrackingInfo')
359 registerEventlevelTrackingInfo.set_name(nameTrackingInfoModule)
360 registerEventlevelTrackingInfo.param(
'EventLevelTrackingInfoName', nameEventTrackingInfo)
361 path.add_module(registerEventlevelTrackingInfo)
364 svdSPCreatorName =
'__ROISVDSpacePointCreator'
365 svd_clusters =
'__ROIsvdClusters'
366 nameSPs =
'SVDSpacePoints__ROI'
368 svdSPCreatorName =
'SVDSpacePointCreator'
370 nameSPs =
'SVDSpacePoints'
372 if svdSPCreatorName
not in [e.name()
for e
in path.modules()]:
373 spCreatorSVD = b2.register_module(
'SVDSpacePointCreator')
374 spCreatorSVD.set_name(svdSPCreatorName)
375 spCreatorSVD.param(
'NameOfInstance',
'SVDSpacePoints')
376 spCreatorSVD.param(
'SpacePoints', nameSPs)
377 spCreatorSVD.param(
'SVDClusters', svd_clusters)
378 spCreatorSVD.param(
'EventLevelTrackingInfoName', nameEventTrackingInfo)
379 path.add_module(spCreatorSVD)