15 add_default_cdc_svd_tracking_chain,
16 add_inverted_svd_cdc_tracking_chain,
17 add_cdc_cr_track_finding,
18 add_cr_track_fit_and_track_creator,
19 add_eclcdc_track_finding,
21 add_hit_preparation_modules,
24 add_flipping_of_recoTracks,
25 add_pxd_cr_track_finding,
26 add_pxd_track_finding,
27 add_svd_track_finding,
28 add_prefilter_track_fit_and_track_creator,
29 add_svd_standalone_tracking,
36from pxd
import add_pxd_reconstruction
39def add_tracking_reconstruction(path, components=None, pruneTracks=False, skipGeometryAdding=False,
40 mcTrackFinding=False, trackFitHypotheses=None,
41 reco_tracks="RecoTracks", prune_temporary_tracks=True, fit_tracks=True,
42 use_second_cdc_hits=False, skipHitPreparerAdding=False,
43 svd_standalone_mode="VXDTF2",
44 use_svd_to_cdc_ckf=True, use_ecl_to_cdc_ckf=False,
45 add_cdcTrack_QI=True, add_vxdTrack_QI=False, add_recoTrack_QI=False,
46 pxd_filtering_offline=False,
47 create_intercepts_for_pxd_ckf=False,
48 append_full_grid_cdc_eventt0=True,
49 v0_finding=True, flip_recoTrack=True,
50 skip_full_grid_cdc_eventt0_if_svd_time_present=True,
51 inverted_tracking=False):
53 This function adds the **standard tracking reconstruction** modules
56 #. first we find tracks using the CDC hits only, see :ref:`CDC Track Finding<tracking_trackFindingCDC>`
58 #. CDC tracks are extrapolated to SVD and SVD hits are attached, see :ref:`CDC to SVD SpacePoint CKF<tracking_cdc2svd_ckf>`
60 #. remaining SVD hits are used to find SVD tracks, see :ref:`SVD Track Finding<tracking_trackFindingSVD>`
62 #. CDC standalone tracks which don't have SVD hits attached to them from the \
63 :ref:`CDC to SVD CKF<tracking_cdc2svd_ckf>` are combined with SVD standalone tracks found in the previous step using the \
64 :ref:`CDC to SVD Seed CKF<tracking_svdcdc_merger_ckf>`
66 #. SVD tracks are extrapolated to CDC to attach CDC hits, see :ref:`SVD to CDC CKF<tracking_svd2cdc_ckf>`
68 #. SVD and CDC tracks are merged and fitted, see :ref:`Track Fitting<tracking_trackFitting>`
70 #. merged SVD+CDC tracks are extrapolated to PXD to attach PXD hits, see :ref:`SVD to PXD CKF<tracking_svd2pxd_ckf>`
74 PXD hits are not available on HLT. At the end of the tracking chain on HLT we have the\
75 :ref:`PXD Region Of Interest Finding<tracking_pxdDataReduction>`, that consists of extrapolating\
76 the tracks on the PXD sensors and defining regions in which we expect to find the hit.\
77 Only fired pixels inside these regions reach Event Builder 2.
79 #. after all the tracks from the IP are found, we look for special classes of tracks,\
80 in particular we search for displaced vertices to reconstruct K-short, Lambda and\
81 photon-conversions, see :ref:`V0 Finding<tracking_v0Finding>`.
83 #. If the reconstruction uses PXD, we finally look for tracks with a wrong charge,\
84 flip and refit them to fix the charge, see :ref:`Flip&Refit<trk_flipNrefit>`.
88 :param path: the path to add the tracking reconstruction modules to
89 :param components: the list of geometry components in use or None for all components.
90 :param pruneTracks: if true, delete all hits except the first and the last in the found tracks.
91 :param skipGeometryAdding: (advanced flag) the tracking modules need the geometry module and will add it,
92 if it is not already present in the path. In a setup with multiple (conditional) paths however, it can not
93 determine, if the geometry is already loaded. This flag can be used o just turn off the geometry adding at
94 all (but you will have to add it on your own then).
95 :param skipHitPreparerAdding: (advanced flag) if true, do not add the hit preparation (esp. VXD cluster creation
96 modules. This is useful if they have been added before already.
97 :param mcTrackFinding: if true, use the MC track finders instead of the realistic ones.
98 :param reco_tracks: name of the StoreArray where the reco tracks should be stored
99 :param prune_temporary_tracks: if false, store all information of the single CDC and VXD tracks before merging.
101 :param fit_tracks: if false, the final track find and the TrackCreator module will no be executed
102 :param use_second_cdc_hits: if true, the second hit information will be used in the CDC track finding.
103 :param trackFitHypotheses: which pdg hypothesis to fit. Defaults to [211, 321, 2212].
104 :param svd_standalone_mode: Which SVD standalone tracking is used.
105 Options are "VXDTF2", "SVDHough", "VXDTF2_and_SVDHough", and "SVDHough_and_VXDTF2".
107 :param use_svd_to_cdc_ckf: if true, add SVD to CDC CKF module.
108 :param use_ecl_to_cdc_ckf: if true, add ECL to CDC CKF module.
109 :param add_cdcTrack_QI: if true, add the MVA track quality estimation
110 to the path that sets the quality indicator property of the found CDC standalone tracks
111 :param add_vxdTrack_QI: if true, add the MVA track quality estimation
112 to the path that sets the quality indicator property of the found VXDTF2 tracks
113 (ATTENTION: Standard triplet QI of VXDTF2 is replaced in this case
114 -> setting this option to 'True' will have some influence on the final track collection)
115 :param add_recoTrack_QI: if true, add the MVA track quality estimation
116 to the path that sets the quality indicator property of all found reco tracks
117 (Both other QIs needed as input.)
118 :param pxd_filtering_offline: If True, PXD data reduction (ROI filtering) is applied during the track reconstruction.
119 The reconstructed SVD/CDC tracks are used to define the ROIs and reject all PXD clusters outside of these.
120 :param create_intercepts_for_pxd_ckf: If True, the PXDROIFinder is added to the path to create PXDIntercepts to be used
121 for hit filtering when creating the CKF relations. This independent of the offline PXD digit filtering which is
122 steered by 'pxd_filtering_offline'. This can be applied for both data and MC.
123 :param append_full_grid_cdc_eventt0: If True, the module FullGridChi2TrackTimeExtractor is added to the path
124 and provides the CDC temporary EventT0.
125 :param v0_finding: if false, the V0Finder module is not executed
126 :param flip_recoTrack: if true, add the recoTracks flipping function in the postfilter (only if PXD is present)
127 :param skip_full_grid_cdc_eventt0_if_svd_time_present: if true, and if also append_full_grid_cdc_eventt0 is true, the
128 FullGridChi2TrackTimeExtractor is only executed in the events where no SVD-based EventT0 is found. If false, but
129 append_full_grid_cdc_eventt0 is true, FullGridChi2TrackTimeExtractor will be executed in each event regardless of
130 SVD EventT0 being present. Has no effect if append_full_grid_cdc_eventt0 is false. Default: true
131 :param inverted_tracking: If true, start tracking with SVD standalone track finding, followed by ToCDCCKF,
132 the CDC standalone tracking, a CKF-based merger to merge the standalone RecoTracks, and finally the
133 CDCToSVDSpacePointCKF to add SVD hits to all CDC tracks that don't have SVD hits attached to them.
134 ATTENTION: The inverted tracking chain is neither optimised nor guaranteed to be bug free.
135 One known issue is a reduced hit efficiency when using the full chain.
136 Please remove this comment once the inverted tracking has been optimised and is assumed to be bug-free.
139 add_prefilter_tracking_reconstruction(
141 components=components,
142 skipGeometryAdding=skipGeometryAdding,
143 mcTrackFinding=mcTrackFinding,
144 trackFitHypotheses=trackFitHypotheses,
145 reco_tracks=reco_tracks,
146 prune_temporary_tracks=prune_temporary_tracks,
147 fit_tracks=fit_tracks,
148 use_second_cdc_hits=use_second_cdc_hits,
149 skipHitPreparerAdding=skipHitPreparerAdding,
150 svd_standalone_mode=svd_standalone_mode,
151 use_svd_to_cdc_ckf=use_svd_to_cdc_ckf,
152 use_ecl_to_cdc_ckf=use_ecl_to_cdc_ckf,
153 add_cdcTrack_QI=add_cdcTrack_QI,
154 add_vxdTrack_QI=add_vxdTrack_QI,
155 add_recoTrack_QI=add_recoTrack_QI,
156 pxd_filtering_offline=pxd_filtering_offline,
157 create_intercepts_for_pxd_ckf=create_intercepts_for_pxd_ckf,
158 append_full_grid_cdc_eventt0=append_full_grid_cdc_eventt0,
159 skip_full_grid_cdc_eventt0_if_svd_time_present=skip_full_grid_cdc_eventt0_if_svd_time_present,
160 inverted_tracking=inverted_tracking)
162 add_postfilter_tracking_reconstruction(path,
163 components=components,
164 pruneTracks=pruneTracks,
165 reco_tracks=reco_tracks,
166 use_second_cdc_hits=use_second_cdc_hits,
167 prune_temporary_tracks=prune_temporary_tracks,
168 v0_finding=v0_finding,
169 flip_recoTrack=flip_recoTrack,
170 mcTrackFinding=mcTrackFinding)
173def add_prefilter_tracking_reconstruction(path, components=None, skipGeometryAdding=False,
174 mcTrackFinding=False, trackFitHypotheses=None, reco_tracks="RecoTracks",
175 prune_temporary_tracks=True, fit_tracks=True,
176 use_second_cdc_hits=False, skipHitPreparerAdding=False,
177 svd_standalone_mode="VXDTF2",
178 use_svd_to_cdc_ckf=True, svd_ckf_mode="SVD_after", use_ecl_to_cdc_ckf=False,
179 add_cdcTrack_QI=True, add_vxdTrack_QI=False, add_recoTrack_QI=False,
180 pxd_filtering_offline=False,
181 create_intercepts_for_pxd_ckf=False,
182 append_full_grid_cdc_eventt0=True,
183 skip_full_grid_cdc_eventt0_if_svd_time_present=True,
184 inverted_tracking=False):
186 This function adds the tracking reconstruction modules required to calculate HLT filter decision
189 :param path: The path to add the tracking reconstruction modules to
190 :param components: the list of geometry components in use or None for all components.
191 :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module and will add it,
192 if it is not already present in the path. In a setup with multiple (conditional) paths however, it can not
193 determine, if the geometry is already loaded. This flag can be used o just turn off the geometry adding at
194 all (but you will have to add it on your own then).
195 :param skipHitPreparerAdding: Advanced flag: do not add the hit preparation (esp. VXD cluster creation
196 modules. This is useful if they have been added before already.
197 :param mcTrackFinding: Use the MC track finders instead of the realistic ones.
198 :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
199 :param prune_temporary_tracks: If false, store all information of the single CDC and VXD tracks before merging.
201 :param fit_tracks: If false, the final track find and the TrackCreator module will no be executed
202 :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
203 :param trackFitHypotheses: Which pdg hypothesis to fit. Defaults to [211, 321, 2212].
204 :param svd_standalone_mode: Which SVD standalone tracking is used.
205 Options are "VXDTF2", "SVDHough", "VXDTF2_and_SVDHough", and "SVDHough_and_VXDTF2".
207 :param use_svd_to_cdc_ckf: if true, add SVD to CDC CKF module.
208 :param svd_ckf_mode: how to apply the CKF (with or without SVD standalone tracking). Defaults to "SVD_after".
209 :param use_ecl_to_cdc_ckf: if true, add ECL to CDC CKF module.
210 :param add_cdcTrack_QI: If true, add the MVA track quality estimation
211 to the path that sets the quality indicator property of the found CDC standalone tracks
212 :param add_vxdTrack_QI: If true, add the MVA track quality estimation
213 to the path that sets the quality indicator property of the found VXDTF2 tracks
214 (ATTENTION: Standard triplet QI of VXDTF2 is replaced in this case
215 -> setting this option to 'True' will have some influence on the final track collection)
216 :param add_recoTrack_QI: If true, add the MVA track quality estimation
217 to the path that sets the quality indicator property of all found reco tracks
218 (Both other QIs needed as input.)
219 :param pxd_filtering_offline: If True, PXD data reduction (ROI filtering) is applied during the track reconstruction.
220 The reconstructed SVD/CDC tracks are used to define the ROIs and reject all PXD clusters outside of these.
221 :param create_intercepts_for_pxd_ckf: If True, the PXDROIFinder is added to the path to create PXDIntercepts to be used
222 for hit filtering when creating the CKF relations. This independent of the offline PXD digit filtering which is
223 steered by 'pxd_filtering_offline'. This can be applied for both data and MC.
224 :param append_full_grid_cdc_eventt0: If True, the module FullGridChi2TrackTimeExtractor is added to the path
225 and provides the CDC temporary EventT0.
226 :param skip_full_grid_cdc_eventt0_if_svd_time_present: if true, and if also append_full_grid_cdc_eventt0 is true, the
227 FullGridChi2TrackTimeExtractor is only executed in the events where no SVD-based EventT0 is found. If false, but
228 append_full_grid_cdc_eventt0 is true, FullGridChi2TrackTimeExtractor will be executed in each event regardless of
229 SVD EventT0 being present. Has no effect if append_full_grid_cdc_eventt0 is false. Default: true
230 :param inverted_tracking: If true, start tracking with SVD standalone track finding, followed by ToCDCCKF,
231 the CDC standalone tracking, a CKF-based merger to merge the standalone RecoTracks, and finally the
232 CDCToSVDSpacePointCKF to add SVD hits to all CDC tracks that don't have SVD hits attached to them.
233 ATTENTION: The inverted tracking chain is neither optimised nor guaranteed to be bug free.
234 One known issue is a reduced hit efficiency when using the full chain.
235 Please remove this comment once the inverted tracking has been optimised and is assumed to be bug-free.
238 if not is_svd_used(components)
and not is_cdc_used(components):
241 if (add_cdcTrack_QI
or add_vxdTrack_QI
or add_recoTrack_QI)
and not fit_tracks:
242 b2.B2ERROR(
"MVA track qualiy indicator requires `fit_tracks` to be enabled. Turning all off.")
243 add_cdcTrack_QI =
False
244 add_vxdTrack_QI =
False
245 add_recoTrack_QI =
False
247 if add_recoTrack_QI
and (
not add_cdcTrack_QI
or not add_vxdTrack_QI):
248 b2.B2ERROR(
"RecoTrack qualiy indicator requires CDC and VXD QI as input. Turning it all of.")
249 add_cdcTrack_QI =
False
250 add_vxdTrack_QI =
False
251 add_recoTrack_QI =
False
253 if not skipGeometryAdding:
254 add_geometry_modules(path, components=components)
256 if not skipHitPreparerAdding:
257 add_hit_preparation_modules(path,
258 components=components,
259 pxd_filtering_offline=pxd_filtering_offline,
260 create_intercepts_for_pxd_ckf=create_intercepts_for_pxd_ckf)
263 if 'SetupGenfitExtrapolation' not in path:
264 path.add_module(
'SetupGenfitExtrapolation',
265 energyLossBrems=
False, noiseBrems=
False)
268 add_mc_track_finding(path, components=components, reco_tracks=reco_tracks,
269 use_second_cdc_hits=use_second_cdc_hits)
271 add_track_finding(path, components=components, reco_tracks=reco_tracks,
272 prune_temporary_tracks=prune_temporary_tracks,
273 use_second_cdc_hits=use_second_cdc_hits,
274 svd_standalone_mode=svd_standalone_mode,
275 use_svd_to_cdc_ckf=use_svd_to_cdc_ckf,
276 svd_ckf_mode=svd_ckf_mode,
277 use_ecl_to_cdc_ckf=use_ecl_to_cdc_ckf,
278 add_cdcTrack_QI=add_cdcTrack_QI,
279 add_vxdTrack_QI=add_vxdTrack_QI,
280 pxd_filtering_offline=pxd_filtering_offline,
281 create_intercepts_for_pxd_ckf=create_intercepts_for_pxd_ckf,
282 inverted_tracking=inverted_tracking)
286 add_time_extraction(path, append_full_grid_cdc_eventt0, components=components,
287 skip_full_grid_cdc_eventt0_if_svd_time_present=skip_full_grid_cdc_eventt0_if_svd_time_present)
290 add_prefilter_track_fit_and_track_creator(path,
291 trackFitHypotheses=trackFitHypotheses,
292 reco_tracks=reco_tracks,
293 add_mva_quality_indicator=add_recoTrack_QI)
296def add_postfilter_tracking_reconstruction(path, components=None, pruneTracks=False, reco_tracks="RecoTracks",
297 use_second_cdc_hits=False, prune_temporary_tracks=True, v0_finding=True,
298 flip_recoTrack=True, mcTrackFinding=False, kink_finding=True):
300 This function adds the tracking reconstruction modules not required to calculate HLT filter
303 :param path: The path to add the tracking reconstruction modules to
304 :param components: the list of geometry components in use or None for all components.
305 :param pruneTracks: Delete all hits except the first and the last in the found tracks.
306 :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
307 :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
308 :param prune_temporary_tracks: If false, store all information of the single CDC and VXD tracks before merging.
310 :param v0_finding: If false, the V0 module will not be executed
311 :param flip_recoTrack: if true, add the recoTracks flipping function in the postfilter (only if PXD is part of
312 the ``components``). This flag is automatically set to false on HLT and ExpressReco.
313 :param mcTrackFinding: Use the MC track finders instead of the realistic ones.
314 :param kink_finding: if true, add the ``KinkFinder`` module to the path. This flag is automatically set to false
315 on HLT and ExpressReco.
319 if components
and not (
'SVD' in components
or 'CDC' in components):
322 flip_and_refit_temporary_RecoTracks =
"RecoTracks_flipped"
323 v0finder_temporary_RecoTracks =
"CopiedRecoTracks"
324 kinkfinder_temporary_RecoTracks =
"RecoTracksKinkTmp"
325 temporary_reco_track_list = []
328 if flip_recoTrack
and not mcTrackFinding
and is_pxd_used(components):
329 add_flipping_of_recoTracks(path, reco_tracks=
"RecoTracks", reco_tracks_flipped=flip_and_refit_temporary_RecoTracks)
330 temporary_reco_track_list.append(flip_and_refit_temporary_RecoTracks)
334 path.add_module(
'V0Finder', RecoTracks=reco_tracks, v0FitterMode=1, CopiedRecoTracks=v0finder_temporary_RecoTracks)
335 temporary_reco_track_list.append(v0finder_temporary_RecoTracks)
339 path.add_module(
'KinkFinder', RecoTracks=reco_tracks, CopiedRecoTracks=kinkfinder_temporary_RecoTracks)
340 temporary_reco_track_list.append(kinkfinder_temporary_RecoTracks)
343 path.add_module(
'TrackTimeEstimator')
345 add_mc_matcher(path, components=components, reco_tracks=reco_tracks,
346 use_second_cdc_hits=use_second_cdc_hits)
350 add_prune_tracks(path, components=components, reco_tracks=reco_tracks)
352 if prune_temporary_tracks
or pruneTracks:
353 path.add_module(
"PruneRecoHits")
355 if prune_temporary_tracks:
356 for temporary_reco_tracks
in temporary_reco_track_list:
359 storeArrayName=temporary_reco_tracks).set_name(
361 temporary_reco_tracks)
364def add_time_extraction(path, append_full_grid_cdc_eventt0=False, components=None,
365 skip_full_grid_cdc_eventt0_if_svd_time_present=True):
367 Add time extraction components via tracking
369 :param path: The path to add the tracking reconstruction modules to
370 :param append_full_grid_cdc_eventt0: If True, the module FullGridChi2TrackTimeExtractor is added to the path
371 and provides the CDC temporary EventT0.
372 :param components: the list of geometry components in use or None for all components.
373 :param skip_full_grid_cdc_eventt0_if_svd_time_present: if true, and if also append_full_grid_cdc_eventt0 is true, the
374 FullGridChi2TrackTimeExtractor is only executed in the events where no SVD-based EventT0 is found. If false, but
375 append_full_grid_cdc_eventt0 is true, FullGridChi2TrackTimeExtractor will be executed in each event regardless of
376 SVD EventT0 being present. Has no effect if append_full_grid_cdc_eventt0 is false. Default: true
380 if is_svd_used(components):
381 path.add_module(
"SVDEventT0Estimator")
383 if is_cdc_used(components)
and append_full_grid_cdc_eventt0:
384 path.add_module(
"FullGridChi2TrackTimeExtractor",
385 skipIfSVDEventT0Present=skip_full_grid_cdc_eventt0_if_svd_time_present)
388def add_cr_tracking_reconstruction(path, components=None, prune_tracks=False,
389 skip_geometry_adding=False, event_time_extraction=True,
390 merge_tracks=True, use_second_cdc_hits=False):
392 This function adds the reconstruction modules for cr tracking to a path.
394 :param path: The path to which to add the tracking reconstruction modules
396 :param components: the list of geometry components in use or None for all components.
397 :param prune_tracks: Delete all hits except the first and the last in the found tracks.
399 :param skip_geometry_adding: Advanced flag: The tracking modules need the geometry module and will add it,
400 if it is not already present in the path. In a setup with multiple (conditional) paths however, it cannot
401 determine if the geometry is already loaded. This flag can be used to just turn off the geometry adding
402 (but you will have to add it on your own).
403 :param event_time_extraction: extract the event time
404 :param merge_tracks: The upper and lower half of the tracks should be merged together in one track
405 :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
413 if not is_cdc_used(components):
416 if not skip_geometry_adding:
417 add_geometry_modules(path, components)
419 add_hit_preparation_modules(path, components=components, create_intercepts_for_pxd_ckf=
False)
422 if 'SetupGenfitExtrapolation' not in path:
423 path.add_module(
'SetupGenfitExtrapolation',
424 energyLossBrems=
False, noiseBrems=
False)
427 add_cr_track_finding(path, reco_tracks=
"RecoTracks", components=components,
428 merge_tracks=merge_tracks, use_second_cdc_hits=use_second_cdc_hits)
432 add_cr_track_fit_and_track_creator(path, components=components, prune_tracks=prune_tracks,
433 event_timing_extraction=event_time_extraction)
437 add_cr_track_fit_and_track_creator(path, components=components, prune_tracks=prune_tracks,
438 event_timing_extraction=
False,
439 reco_tracks=
"NonMergedRecoTracks", tracks=
"NonMergedTracks")
442def add_mc_tracking_reconstruction(path, components=None, pruneTracks=False, use_second_cdc_hits=False):
444 This function adds the standard reconstruction modules for MC tracking
447 :param path: The path to add the tracking reconstruction modules to
448 :param components: the list of geometry components in use or None for all components.
449 :param pruneTracks: Delete all hits expect the first and the last from the found tracks.
450 :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
452 add_tracking_reconstruction(path,
453 components=components,
454 pruneTracks=pruneTracks,
456 use_second_cdc_hits=use_second_cdc_hits)
459def add_track_finding(path, components=None, reco_tracks="RecoTracks",
460 prune_temporary_tracks=True, use_second_cdc_hits=False,
461 use_mc_truth=False, svd_ckf_mode="SVD_after", add_both_directions=True,
462 svd_standalone_mode="VXDTF2",
463 use_svd_to_cdc_ckf=True, use_ecl_to_cdc_ckf=False,
464 add_cdcTrack_QI=True, add_vxdTrack_QI=False,
465 pxd_filtering_offline=False, use_HLT_ROIs=False,
466 create_intercepts_for_pxd_ckf=False,
467 inverted_tracking=False):
469 Add the track finding chain to the path. Depending on the parameters, different tracking chains can be defined and attached.
470 :param path: The path to add the tracking reconstruction modules to
471 :param reco_tracks: The store array name where to output all tracks
472 :param use_mc_truth: Use the truth information in the CKF modules
473 :param svd_ckf_mode: how to apply the CKF (with or without SVD standalone tracking). Defaults to "SVD_after".
474 :param add_both_directions: Curlers may be found in the wrong orientation by the CDC track finder, so try to
475 extrapolate also in the other direction.
476 :param svd_standalone_mode: Which SVD standalone tracking is used.
477 Options are "VXDTF2", "SVDHough", "VXDTF2_and_SVDHough", and "SVDHough_and_VXDTF2".
479 :param use_second_cdc_hits: whether to use the secondary CDC hit during CDC track finding or not
480 :param components: the list of geometry components in use or None for all components.
481 :param prune_temporary_tracks: If false, store all information of the single CDC and VXD tracks before merging.
483 :param use_svd_to_cdc_ckf: if true, add SVD to CDC CKF module.
484 :param use_ecl_to_cdc_ckf: if true, add ECL to CDC CKF module.
485 :param add_cdcTrack_QI: If true, add the MVA track quality estimation
486 to the path that sets the quality indicator property of the found CDC standalone tracks
487 :param add_vxdTrack_QI: If true, add the MVA track quality estimation
488 to the path that sets the quality indicator property of the found VXDTF2 tracks
489 (ATTENTION: Standard triplet QI of VXDTF2 is replaced in this case
490 -> setting this option to 'True' will have some influence on the final track collection)
491 :param pxd_filtering_offline: If True, PXD data reduction (ROI filtering) is applied during the track reconstruction.
492 The reconstructed SVD/CDC tracks are used to define the ROIs and reject all PXD clusters outside of these.
493 :param use_HLT_ROIs: Don't calculate the ROIs here but use the ones from the HLT (does obviously not work for simulation)
494 :param create_intercepts_for_pxd_ckf: If True, the PXDROIFinder is added to the path to create PXDIntercepts to be used
495 for hit filtering when creating the CKF relations. This independent of the offline PXD digit filtering which is
496 steered by 'pxd_filtering_offline'. This can be applied for both data and MC.
497 :param inverted_tracking: If true, start tracking with SVD standalone track finding, followed by ToCDCCKF,
498 the CDC standalone tracking, a CKF-based merger to merge the standalone RecoTracks, and finally the
499 CDCToSVDSpacePointCKF to add SVD hits to all CDC tracks that don't have SVD hits attached to them.
500 ATTENTION: The inverted tracking chain is neither optimised nor guaranteed to be bug free.
501 One known issue is a reduced hit efficiency when using the full chain.
502 Please remove this comment once the inverted tracking has been optimised and is assumed to be bug-free.
504 if not is_svd_used(components)
and not is_cdc_used(components):
507 if use_ecl_to_cdc_ckf
and not is_cdc_used(components):
508 b2.B2WARNING(
"ECL CKF cannot be used without CDC. Turning it off.")
509 use_ecl_to_cdc_ckf =
False
511 if use_ecl_to_cdc_ckf
and not is_ecl_used(components):
512 b2.B2ERROR(
"ECL CKF cannot be used without ECL. Turning it off.")
513 use_ecl_to_cdc_ckf =
False
516 if 'RegisterEventLevelTrackingInfo' not in path:
517 path.add_module(
'RegisterEventLevelTrackingInfo')
520 cdc_reco_tracks =
"CDCRecoTracks"
521 svd_cdc_reco_tracks =
"SVDCDCRecoTracks"
522 ecl_reco_tracks =
"ECLRecoTracks"
523 combined_ecl_reco_tracks =
"combinedECLRecoTracks"
526 svd_reco_tracks =
"SVDRecoTracks"
527 pxd_reco_tracks =
"PXDRecoTracks"
530 temporary_reco_track_list = []
533 latest_reco_tracks =
None
535 if not is_pxd_used(components):
536 if use_ecl_to_cdc_ckf
and is_cdc_used(components):
537 combined_ecl_reco_tracks = reco_tracks
538 elif (
not use_ecl_to_cdc_ckf)
and is_svd_used(components):
539 svd_cdc_reco_tracks = reco_tracks
540 elif (
not use_ecl_to_cdc_ckf)
and (
not is_svd_used(components))
and is_cdc_used(components):
541 cdc_reco_tracks = reco_tracks
544 if not inverted_tracking:
545 latest_reco_tracks, tmp_reco_track_list = \
546 add_default_cdc_svd_tracking_chain(path,
547 components=components,
548 svd_reco_tracks=svd_reco_tracks,
549 cdc_reco_tracks=cdc_reco_tracks,
550 output_reco_tracks=svd_cdc_reco_tracks,
551 use_second_cdc_hits=use_second_cdc_hits,
552 add_cdcTrack_QI=add_cdcTrack_QI,
553 use_mc_truth=use_mc_truth,
554 svd_ckf_mode=svd_ckf_mode,
555 add_both_directions=add_both_directions,
556 use_svd_to_cdc_ckf=use_svd_to_cdc_ckf,
557 svd_standalone_mode=svd_standalone_mode,
558 add_vxdTrack_QI=add_vxdTrack_QI,
559 prune_temporary_tracks=prune_temporary_tracks)
561 temporary_reco_track_list.extend(tmp_reco_track_list)
567 latest_reco_tracks, tmp_reco_track_list = \
568 add_inverted_svd_cdc_tracking_chain(path,
569 components=components,
570 svd_reco_tracks=svd_reco_tracks,
571 cdc_reco_tracks=cdc_reco_tracks,
572 svd_cdc_reco_tracks=svd_cdc_reco_tracks,
573 use_second_cdc_hits=use_second_cdc_hits,
574 add_cdcTrack_QI=add_cdcTrack_QI,
575 use_mc_truth=use_mc_truth,
576 svd_ckf_mode=svd_ckf_mode,
577 add_both_directions=add_both_directions,
578 use_svd_to_cdc_ckf=use_svd_to_cdc_ckf,
579 svd_standalone_mode=svd_standalone_mode,
580 add_vxdTrack_QI=add_vxdTrack_QI,
581 prune_temporary_tracks=prune_temporary_tracks)
583 temporary_reco_track_list.extend(tmp_reco_track_list)
585 if use_ecl_to_cdc_ckf
and is_cdc_used(components):
586 add_eclcdc_track_finding(path, components=components, output_reco_tracks=ecl_reco_tracks,
587 prune_temporary_tracks=prune_temporary_tracks)
591 path.add_module(
"RecoTrackStoreArrayCombiner",
592 Temp1RecoTracksStoreArrayName=latest_reco_tracks,
593 Temp2RecoTracksStoreArrayName=ecl_reco_tracks,
594 recoTracksStoreArrayName=combined_ecl_reco_tracks)
595 temporary_reco_track_list.append(ecl_reco_tracks)
596 temporary_reco_track_list.append(combined_ecl_reco_tracks)
597 latest_reco_tracks = combined_ecl_reco_tracks
599 if is_pxd_used(components):
601 In case we want to use offline PXD hit filtering ('pxd_filtering_offline == True'), we can decide to either use ROIs
602 created by HLT ('use_HLT_ROIs == True') or to create ROIs on the fly ('use_HLT_ROIs == False').
603 In addition, we can also just run the ROI finder to create PXDIntercepts ('create_intercepts_for_pxd_ckf == True')
604 that can be used in the ToPXDCKF relation filters to reduce the number of relations that are created. In this case
605 there is no need to apply the ROI filtering.
607 if pxd_filtering_offline
or create_intercepts_for_pxd_ckf:
609 intercepts_name =
"PXDIntercepts"
610 if not use_HLT_ROIs
or create_intercepts_for_pxd_ckf:
611 path.add_module(
"DAFRecoFitter", recoTracksStoreArrayName=latest_reco_tracks).set_name(
612 f
"DAFRecoFitter {latest_reco_tracks}")
614 roiName =
"ROIs_offline"
615 intercepts_name =
"CKF" + intercepts_name
617 reco_tracks=latest_reco_tracks,
618 intercepts_name=intercepts_name,
621 if pxd_filtering_offline:
622 pxd_digifilter = b2.register_module(
'PXDdigiFilter')
623 pxd_digifilter.param(
'ROIidsName', roiName)
624 pxd_digifilter.param(
'PXDDigitsName',
'PXDDigits')
625 pxd_digifilter.param(
'PXDDigitsInsideROIName',
'PXDDigits')
626 pxd_digifilter.param(
'overrideDB',
True)
627 pxd_digifilter.param(
'usePXDDataReduction',
True)
628 path.add_module(pxd_digifilter)
630 if pxd_filtering_offline
or create_intercepts_for_pxd_ckf:
631 add_pxd_reconstruction(path)
633 add_pxd_track_finding(path, components=components, input_reco_tracks=latest_reco_tracks,
634 use_mc_truth=use_mc_truth, output_reco_tracks=reco_tracks,
635 temporary_reco_tracks=pxd_reco_tracks,
636 add_both_directions=add_both_directions)
637 temporary_reco_track_list.append(pxd_reco_tracks)
639 if prune_temporary_tracks:
640 for temporary_reco_track_name
in temporary_reco_track_list:
641 if temporary_reco_track_name != reco_tracks:
644 storeArrayName=temporary_reco_track_name).set_name(
646 temporary_reco_track_name)
649def add_cr_track_finding(path, reco_tracks="RecoTracks", components=None,
650 merge_tracks=True, use_second_cdc_hits=False):
653 if 'RegisterEventLevelTrackingInfo' not in path:
654 path.add_module(
'RegisterEventLevelTrackingInfo')
656 if not is_cdc_used(components):
657 b2.B2FATAL(
"CDC must be in components")
659 reco_tracks_from_track_finding = reco_tracks
661 reco_tracks_from_track_finding =
"NonMergedRecoTracks"
663 cdc_reco_tracks =
"CDCRecoTracks"
664 if not is_pxd_used(components)
and not is_svd_used(components):
665 cdc_reco_tracks = reco_tracks_from_track_finding
667 svd_cdc_reco_tracks =
"SVDCDCRecoTracks"
668 if not is_pxd_used(components):
669 svd_cdc_reco_tracks = reco_tracks_from_track_finding
671 full_reco_tracks = reco_tracks_from_track_finding
674 add_cdc_cr_track_finding(path, merge_tracks=
False, use_second_cdc_hits=use_second_cdc_hits,
675 output_reco_tracks=cdc_reco_tracks)
677 latest_reco_tracks = cdc_reco_tracks
679 if is_svd_used(components):
680 add_svd_track_finding(path, components=components, input_reco_tracks=latest_reco_tracks,
681 output_reco_tracks=svd_cdc_reco_tracks,
682 svd_ckf_mode=
"cosmics", add_both_directions=
True, svd_standalone_mode=
"VXDTF2")
683 latest_reco_tracks = svd_cdc_reco_tracks
685 if is_pxd_used(components):
686 add_pxd_cr_track_finding(path, components=components, input_reco_tracks=latest_reco_tracks,
687 output_reco_tracks=full_reco_tracks, add_both_directions=
True)
691 path.add_module(
"CosmicsTrackMerger", inputRecoTracks=reco_tracks_from_track_finding,
692 outputRecoTracks=reco_tracks)
695def add_mc_track_finding(path, components=None, reco_tracks="RecoTracks", use_second_cdc_hits=False):
697 Add the MC based TrackFinder to the path.
699 :param path: The path to add the tracking reconstruction modules to
700 :param components: the list of geometry components in use or None for all components.
701 :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
702 :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
704 if is_cdc_used(components)
or is_pxd_used(components)
or is_svd_used(components):
706 path.add_module(
'TrackFinderMCTruthRecoTracks',
707 RecoTracksStoreArrayName=reco_tracks,
708 UseSecondCDCHits=use_second_cdc_hits,
709 UsePXDHits=is_pxd_used(components),
710 UseSVDHits=is_svd_used(components),
711 UseCDCHits=is_cdc_used(components))
714def add_tracking_for_PXDDataReduction_simulation(path, components, svd_cluster='__ROIsvdClusters'):
716 This function adds the standard reconstruction modules for tracking to be used for the simulation of PXD data
719 :param path: The path to add the tracking reconstruction modules to
720 :param components: the list of geometry components in use or None for all components, always exclude the PXD.
723 if not is_svd_used(components):
727 if 'SetupGenfitExtrapolation' not in path:
728 material_effects = b2.register_module(
'SetupGenfitExtrapolation')
729 material_effects.set_name(
730 'SetupGenfitExtrapolationForPXDDataReduction')
731 path.add_module(material_effects)
734 svd_reco_tracks =
"__ROIsvdRecoTracks"
737 add_svd_standalone_tracking(path, components=[
'SVD'], reco_tracks=svd_reco_tracks, suffix=
"__ROI",
738 svd_clusters=svd_cluster)
741 dafRecoFitter = b2.register_module(
"DAFRecoFitter")
742 dafRecoFitter.set_name(
"SVD-only DAFRecoFitter")
743 dafRecoFitter.param(
'recoTracksStoreArrayName', svd_reco_tracks)
744 dafRecoFitter.param(
'svdHitsStoreArrayName', svd_cluster)
745 path.add_module(dafRecoFitter)
748def add_roiFinder(path, reco_tracks="RecoTracks", intercepts_name="PXDIntercepts", roiName="ROIs"):
750 Add the ROI finding to the path creating ROIs out of reco tracks by extrapolating them to the PXD volume.
751 :param path: Where to add the module to.
752 :param reco_tracks: Which tracks to use in the extrapolation step.
753 :param roiName: Name of the produced/stored ROIs.
755 path.add_module(
'PXDROIFinder', recoTrackListName=reco_tracks,
756 PXDInterceptListName=intercepts_name, ROIListName=roiName)
759def add_roi_payload_assembler(path, ignore_hlt_decision):
760 path.add_module(
'ROIPayloadAssembler',
761 ROIListName=
'ROIs', ROIpayloadName=
'ROIpayload',
762 SendAllDownscaler=0, SendROIsDownscaler=1,
763 AcceptAll=ignore_hlt_decision, NoRejectFlag=
False)
766def add_vxd_standalone_cosmics_finder(
768 reco_tracks="RecoTracks",
769 pxd_spacepoints_name="PXDSpacePoints",
770 svd_spacepoints_name="SVDSpacePoints",
775 Convenience function for adding VXD standalone cosmics track finding for B = 0 Tesla
778 The result is a StoreArray with name @param reco_tracks containing one or zero reco tracks per event.
779 This track candidates have an arbitrary but large momentum seed in the direction of the fitted line.
780 The position and momentum seed is obtained using a principal component analysis method.
782 :param path: basf2 path
783 :param reco_tracks: Name of the output RecoTracks; defaults to RecoTracks.
784 :param spacepoints_name: name of store array containing the spacepoints; defaults to SpacePoints
785 :param quality_cut: Cut on the chi squared value of the line fit; candidates with values above the cut will be
786 rejected; defaults to 0.0001
787 :param min_sps: Minimal number of SpacePoints required to build a track candidate; defaults to 3;
788 :param max_rejected_sps: Maximal number of retries to refit a track after the worst spacepoint was removed;
793 if 'RegisterEventLevelTrackingInfo' not in path:
794 path.add_module(
'RegisterEventLevelTrackingInfo')
796 if "PXDSpacePointCreator" not in [m.name()
for m
in path.modules()]:
797 path.add_module(
'PXDSpacePointCreator', SpacePoints=pxd_spacepoints_name)
801 track_finder = b2.register_module(
'TrackFinderVXDCosmicsStandalone')
802 track_finder.param(
'SpacePointTrackCandArrayName',
"")
803 track_finder.param(
'SpacePoints', [pxd_spacepoints_name, svd_spacepoints_name])
804 track_finder.param(
'QualityCut', quality_cut)
805 track_finder.param(
'MinSPs', min_sps)
806 track_finder.param(
'MaxRejectedSPs', max_rejected_sps)
807 path.add_module(track_finder)
809 converter = b2.register_module(
'SPTC2RTConverter')
810 converter.param(
'recoTracksStoreArrayName', reco_tracks)
811 path.add_module(converter)