15 def add_svd_reconstruction(path, isROIsimulation=False, createRecoDigits=False, applyMasking=False):
17 Adds the SVD reconstruction to the path.
19 Reconstruction starts with :ref:`SVDShaperDigits<svdshapers>`
20 and :ref:`SVDEventInfo<svdeventinfo>` and provides
21 :ref:`SVDClusters<svdclusters>` and :ref:`SVDSpacePoints<svdsps>`.
23 @param path: add the modules to this basf2 path.
24 @param isROIsimulation: SVD reconstruction can be run during simulation\
25 in order to simulate the PXD Data Reduction with ROI finding.
26 @param createRecoDigits: if True, :ref:`SVDRecoDigits<svdrecos>` are created.
27 @param applyMasking: if True, hot strips found in :ref:`SVDHotStripsCalibration<svdhotstrips>` are masked.
32 nameTrackingInfoModule =
"RegisterEventLevelTrackingInfo__ROI"
33 nameEventTrackingInfo =
"EventLevelTrackingInfo__ROI"
34 nameSVDTrackingEventLevelMdstInfoFiller =
"SVDTrackingEventLevelMdstInfoFiller__ROI"
36 nameTrackingInfoModule =
"RegisterEventLevelTrackingInfo"
37 nameEventTrackingInfo =
"EventLevelTrackingInfo"
38 nameSVDTrackingEventLevelMdstInfoFiller =
"SVDTrackingEventLevelMdstInfoFiller"
40 if nameTrackingInfoModule
not in path:
41 registerEventlevelTrackingInfo = b2.register_module(
'RegisterEventLevelTrackingInfo')
42 registerEventlevelTrackingInfo.set_name(nameTrackingInfoModule)
43 registerEventlevelTrackingInfo.param(
'EventLevelTrackingInfoName', nameEventTrackingInfo)
44 path.add_module(registerEventlevelTrackingInfo)
47 clusterizerName =
'__ROISVDClusterizer'
48 timeGroupComposerName =
'__ROISVDTimeGrouping'
49 recocreatorName =
'__ROISVDRecoDigitCreator'
50 dataFormatName =
'__ROISVDDataFormat'
52 clustersName =
'__ROIsvdClusters'
54 missingAPVsClusterCreatorName =
'__ROISVDMissingAPVsClusterCreator'
56 clusterizerName =
'SVDClusterizer'
57 timeGroupComposerName =
'SVDTimeGrouping'
58 recocreatorName =
'SVDRecoDigitCreator'
59 dataFormatName =
'SVDDataFormat'
63 missingAPVsClusterCreatorName =
'SVDMissingAPVsClusterCreator'
68 shaperDigitsName =
'__ROISVDShaperDigitsUnmasked'
69 maskingName =
'__ROISVDStripMasking'
71 shaperDigitsName =
'SVDShaperDigitsUnmasked'
72 maskingName =
'SVDStripMasking'
74 if maskingName
not in [e.name()
for e
in path.modules()]:
75 masking = b2.register_module(
'SVDStripMasking')
76 masking.set_name(maskingName)
77 masking.param(
'ShaperDigitsUnmasked', shaperDigitsName)
78 path.add_module(masking)
81 if dataFormatName
not in [e.name()
for e
in path.modules()]:
82 dataFormat = b2.register_module(
'SVDDataFormatCheck')
83 dataFormat.param(
'ShaperDigits', shaperDigitsName)
85 if clusterizerName
not in [e.name()
for e
in path.modules()]:
86 clusterizer = b2.register_module(
'SVDClusterizer')
87 clusterizer.set_name(clusterizerName)
88 clusterizer.param(
'ShaperDigits', shaperDigitsName)
89 clusterizer.param(
'Clusters', clustersName)
90 path.add_module(clusterizer)
92 if missingAPVsClusterCreatorName
not in [e.name()
for e
in path.modules()]:
93 missingAPVCreator = b2.register_module(
'SVDMissingAPVsClusterCreator')
94 missingAPVCreator.set_name(missingAPVsClusterCreatorName)
95 path.add_module(missingAPVCreator)
97 if nameSVDTrackingEventLevelMdstInfoFiller
not in path:
98 svdTrackingEventLevelMdstInfoFiller = b2.register_module(
'SVDTrackingEventLevelMdstInfoFiller')
99 svdTrackingEventLevelMdstInfoFiller.set_name(nameSVDTrackingEventLevelMdstInfoFiller)
100 svdTrackingEventLevelMdstInfoFiller.param(
'EventLevelTrackingInfoName', nameEventTrackingInfo)
101 svdTrackingEventLevelMdstInfoFiller.param(
'svdClustersName', clustersName)
102 path.add_module(svdTrackingEventLevelMdstInfoFiller)
104 if timeGroupComposerName
not in [e.name()
for e
in path.modules()]:
105 svdTimeGrouping = b2.register_module(
'SVDTimeGrouping')
106 svdTimeGrouping.set_name(timeGroupComposerName)
107 svdTimeGrouping.param(
'SVDClusters', clustersName)
108 path.add_module(svdTimeGrouping)
111 add_svd_SPcreation(path, isROIsimulation)
113 if createRecoDigits
and not isROIsimulation:
116 add_svd_create_recodigits(path, recocreatorName, shaperDigitsName)
119 def add_svd_create_recodigits(path, recocreatorName="SVDRecoDigitCreator", shaperDigitsName=""):
121 Adds the strip reconstruction to the path.
123 Produce :ref:`SVDRecoDigits<svdrecos>` from :ref:`SVDShaperDigits<svdshapers>`.
125 @param path: add the modules to this basf2 path.
126 @param recocreatorName: name of the module.
127 @param shaperDigitsName: name of the SVDShaperDigits StoreArray.
130 if recocreatorName
not in [e.name()
for e
in path.modules()]:
131 recoDigitCreator = b2.register_module(
'SVDRecoDigitCreator')
132 recoDigitCreator.param(
'ShaperDigits', shaperDigitsName)
133 recoDigitCreator.param(
'timeAlgorithm6Samples',
"CoG3")
134 recoDigitCreator.param(
'timeAlgorithm3Samples',
"CoG3")
135 recoDigitCreator.param(
'chargeAlgorithm6Samples',
"MaxSample")
136 recoDigitCreator.param(
'chargeAlgorithm3Samples',
"MaxSample")
137 recoDigitCreator.param(
'useDB',
False)
138 path.add_module(recoDigitCreator)
141 def add_rel5_svd_reconstruction(path, isROIsimulation=False, applyMasking=False):
143 Adds the old (up to release-05) SVD recontruction to the path.
145 Reconstruction starts with :ref:`SVDShaperDigits<svdshapers>` and
146 :ref:`SVDEventInfo<svdeventinfo>` and provides :ref:`SVDClusters<svdclusters>`
147 and :ref:`SVDSpacePoints<svdsps>`.
149 @param path: add the modules to this basf2 path.
150 @param isROIsimulation: SVD reconstruction can be run during simulation\
151 in order to simulate the PXD Data Reduction with ROI finding.
152 @param applyMasking: if True, hot strips found in :ref:`SVDHotStripsCalibration<svdhotstrips>` are masked.
157 nameTrackingInfoModule =
"RegisterEventLevelTrackingInfo__ROI"
158 nameEventTrackingInfo =
"EventLevelTrackingInfo__ROI"
159 nameSVDTrackingEventLevelMdstInfoFiller =
"SVDTrackingEventLevelMdstInfoFiller__ROI"
161 nameTrackingInfoModule =
"RegisterEventLevelTrackingInfo"
162 nameEventTrackingInfo =
"EventLevelTrackingInfo"
163 nameSVDTrackingEventLevelMdstInfoFiller =
"SVDTrackingEventLevelMdstInfoFiller"
165 if nameTrackingInfoModule
not in path:
166 registerEventlevelTrackingInfo = b2.register_module(
'RegisterEventLevelTrackingInfo')
167 registerEventlevelTrackingInfo.set_name(nameTrackingInfoModule)
168 registerEventlevelTrackingInfo.param(
'EventLevelTrackingInfoName', nameEventTrackingInfo)
169 path.add_module(registerEventlevelTrackingInfo)
172 fitterName =
'__ROISVDCoGTimeEstimator'
173 clusterizerName =
'__ROISVDSimpleClusterizer'
174 timeGroupComposerName =
'__ROISVDTimeGrouping'
175 dataFormatName =
'__ROISVDDataFormat'
176 clusterName =
'__ROIsvdClusters'
177 recoDigitsName =
'__ROIsvdRecoDigits'
178 shaperDigitsName =
""
179 missingAPVsClusterCreatorName =
'__ROISVDMissingAPVsClusterCreator'
181 fitterName =
'SVDCoGTimeEstimator'
182 clusterizerName =
'SVDSimpleClusterizer'
183 timeGroupComposerName =
'SVDTimeGrouping'
184 dataFormatName =
'SVDDataFormat'
187 shaperDigitsName =
""
188 missingAPVsClusterCreatorName =
'SVDMissingAPVsClusterCreator'
193 shaperDigitsName =
'__ROISVDShaperDigitsUnmasked'
194 maskingName =
'__ROISVDStripMasking'
196 shaperDigitsName =
'SVDShaperDigitsUnmasked'
197 maskingName =
'SVDStripMasking'
199 if maskingName
not in [e.name()
for e
in path.modules()]:
200 masking = b2.register_module(
'SVDStripMasking')
201 masking.set_name(maskingName)
202 masking.param(
'ShaperDigitsUnmasked', shaperDigitsName)
203 path.add_module(masking)
205 if dataFormatName
not in [e.name()
for e
in path.modules()]:
206 dataFormat = b2.register_module(
'SVDDataFormatCheck')
207 dataFormat.param(
'ShaperDigits', shaperDigitsName)
209 if fitterName
not in [e.name()
for e
in path.modules()]:
210 fitter = b2.register_module(
'SVDCoGTimeEstimator')
211 fitter.set_name(fitterName)
212 fitter.param(
'RecoDigits', recoDigitsName)
213 path.add_module(fitter)
215 if clusterizerName
not in [e.name()
for e
in path.modules()]:
216 clusterizer = b2.register_module(
'SVDSimpleClusterizer')
217 clusterizer.set_name(clusterizerName)
218 clusterizer.param(
'RecoDigits', recoDigitsName)
219 clusterizer.param(
'Clusters', clusterName)
220 clusterizer.param(
'useDB',
True)
221 path.add_module(clusterizer)
223 if missingAPVsClusterCreatorName
not in [e.name()
for e
in path.modules()]:
224 missingAPVCreator = b2.register_module(
'SVDMissingAPVsClusterCreator')
225 missingAPVCreator.set_name(missingAPVsClusterCreatorName)
226 path.add_module(missingAPVCreator)
228 if nameSVDTrackingEventLevelMdstInfoFiller
not in path:
229 svdTrackingEventLevelMdstInfoFiller = b2.register_module(
'SVDTrackingEventLevelMdstInfoFiller')
230 svdTrackingEventLevelMdstInfoFiller.set_name(nameSVDTrackingEventLevelMdstInfoFiller)
231 svdTrackingEventLevelMdstInfoFiller.param(
'EventLevelTrackingInfoName', nameEventTrackingInfo)
232 svdTrackingEventLevelMdstInfoFiller.param(
'svdClustersName', clusterName)
233 path.add_module(svdTrackingEventLevelMdstInfoFiller)
235 if timeGroupComposerName
not in [e.name()
for e
in path.modules()]:
236 svdTimeGrouping = b2.register_module(
'SVDTimeGrouping')
237 svdTimeGrouping.set_name(timeGroupComposerName)
238 svdTimeGrouping.param(
'SVDClusters', clusterName)
239 path.add_module(svdTimeGrouping)
242 add_svd_SPcreation(path, isROIsimulation)
245 def add_svd_simulation(path, useConfigFromDB=False, daqMode=2, relativeShift=9):
247 Adds the SVD simulation to the path.
249 Simulation ends with :ref:`SVDShaperDigits<svdshapers>` and :ref:`SVDEventInfo<svdeventinfo>`.
251 @param path: add the modules to this basf2 path.
252 @param useConfigFromDB: if True, read the SVD configuration from :ref:`SVDGlobalConfigParameters<svdglobalconfig>`.
253 @param daqMode: = 2 for the default 6-sample mode, = 1 for the 3-sample mode, = 3 for the 3-mixed-6 sample mode.
254 @param relativeShift: relative time shift between the 3-sample and the 6-sample mode in units of 1/4 of APV clock.\
255 If ``useConfigFromDB`` is True, the value of this parameter is overwritten.
258 svdevtinfoset = b2.register_module(
"SVDEventInfoSetter")
259 svdevtinfoset.param(
"useDB", useConfigFromDB)
260 path.add_module(svdevtinfoset)
262 digitizer = b2.register_module(
'SVDDigitizer')
263 path.add_module(digitizer)
265 if not useConfigFromDB:
266 if daqMode != 2
and daqMode != 1
and daqMode != 3:
267 message =
'OOPS the acquisition mode that you want to simulate is not available.\n' \
268 'Please choose among daqMode = 2 (6-sample) and daqMode = 1 (3-sample).'
272 svdevtinfoset.param(
"daqMode", daqMode)
273 svdevtinfoset.param(
"relativeShift", relativeShift)
276 def add_svd_unpacker(path):
278 Adds the SVD Unpacker to the path.
280 The unpacker produces :ref:`SVDShaperDigits<svdshapers>` and :ref:`SVDEventInfo<svdeventinfo>`.
282 @param path: add the modules to this basf2 path.
285 unpacker = b2.register_module(
'SVDUnpacker')
286 path.add_module(unpacker)
289 def add_svd_unpacker_simulate3sampleDAQ(path, latencyShift=-1, relativeShift=-1):
291 Adds the SVD Unpacker to the path, emulating the 3-sample mode from the 6-sample mode.
293 @param path: add the modules to this basf2 path.
294 @param latencyShift: relative time shift between the 3-sample and the 6-sample mode, in APV clocks.\
295 0 <= latencyShift <=3
296 @param relativeShift: relative time shift between the 3-sample and the 6-sample mode, in units of 1/4 of APV clock.\
297 0 <= relativeShift <=12
299 .. warning:: at least one between ``relativeShift`` and ``latencyShift`` should be set (different from -1).
302 if relativeShift != -1
and latencyShift != -1:
303 b2.B2FATAL(
"OOPS please choose only one between relativeShift and latencyShift. Exiting now.")
305 unpacker = b2.register_module(
'SVDUnpacker')
306 unpacker.param(
"SVDEventInfo",
"SVDEventInfoOriginal")
307 unpacker.param(
"svdShaperDigitListName",
"SVDShaperDigitsOriginal")
308 path.add_module(unpacker)
311 emulator = b2.register_module(
"SVD3SamplesEmulator")
312 emulator.param(
"SVDEventInfo",
"SVDEventInfoOriginal")
313 emulator.param(
"SVDShaperDigits",
"SVDShaperDigitsOriginal")
314 if latencyShift == -1:
315 emulator.param(
"chooseStartingSample",
False)
317 emulator.param(
"chooseStartingSample",
True)
318 if latencyShift < 0
or latencyShift > 3:
319 b2.B2FATAL(
"the latencyShift must be an integer >=0 and <= 3")
321 emulator.param(
"StartingSample", latencyShift)
323 if relativeShift == -1:
324 emulator.param(
"chooseRelativeShift",
False)
326 emulator.param(
"chooseRelativeShift",
True)
327 if relativeShift < 0
or relativeShift > 12:
328 b2.B2FATAL(
"the relativeShift must be an integer >=0 and <= 12")
330 emulator.param(
"relativeShift", relativeShift)
332 emulator.param(
"outputSVDEventInfo",
"SVDEventInfo")
333 emulator.param(
"outputSVDShaperDigits",
"SVDShaperDigits3SampleAll")
334 path.add_module(emulator)
337 zsonline = b2.register_module(
"SVDZeroSuppressionEmulator")
338 zsonline.param(
"ShaperDigits",
"SVDShaperDigits3SampleAll")
339 zsonline.param(
"ShaperDigitsIN",
"SVDShaperDigits")
340 path.add_module(zsonline)
343 def add_svd_packer(path):
345 Adds the SVD Packer to the path.
347 @param path: add the modules to this basf2 path.
350 packer = b2.register_module(
'SVDPacker')
351 path.add_module(packer)
354 def add_svd_SPcreation(path, isROIsimulation=False):
356 Adds the SVD SpacePoint Creator to the path.
358 @param path: add the modules to this basf2 path.
359 @param isROIsimulation: SVD reconstruction can be run during simulation\
360 in order to simulate the PXD Data Reduction with ROI finding.
365 nameTrackingInfoModule =
"RegisterEventLevelTrackingInfo__ROI"
366 nameEventTrackingInfo =
"EventLevelTrackingInfo__ROI"
368 nameTrackingInfoModule =
"RegisterEventLevelTrackingInfo"
369 nameEventTrackingInfo =
"EventLevelTrackingInfo"
371 if nameTrackingInfoModule
not in path:
372 registerEventlevelTrackingInfo = b2.register_module(
'RegisterEventLevelTrackingInfo')
373 registerEventlevelTrackingInfo.set_name(nameTrackingInfoModule)
374 registerEventlevelTrackingInfo.param(
'EventLevelTrackingInfoName', nameEventTrackingInfo)
375 path.add_module(registerEventlevelTrackingInfo)
378 svdSPCreatorName =
'__ROISVDSpacePointCreator'
379 svd_clusters =
'__ROIsvdClusters'
380 nameSPs =
'SVDSpacePoints__ROI'
382 svdSPCreatorName =
'SVDSpacePointCreator'
384 nameSPs =
'SVDSpacePoints'
386 if svdSPCreatorName
not in [e.name()
for e
in path.modules()]:
387 spCreatorSVD = b2.register_module(
'SVDSpacePointCreator')
388 spCreatorSVD.set_name(svdSPCreatorName)
389 spCreatorSVD.param(
'NameOfInstance',
'SVDSpacePoints')
390 spCreatorSVD.param(
'SpacePoints', nameSPs)
391 spCreatorSVD.param(
'SVDClusters', svd_clusters)
392 spCreatorSVD.param(
'EventLevelTrackingInfoName', nameEventTrackingInfo)
393 path.add_module(spCreatorSVD)