10from pybasf2
import B2WARNING, B2FATAL
12from ROOT
import Belle2
14from basf2
import register_module
15from geometry
import is_detector_present, are_detectors_present, is_any_detector_present
16from ckf.path_functions import add_pxd_ckf, add_ckf_based_merger, add_svd_ckf, add_cosmics_svd_ckf, add_cosmics_pxd_ckf
17from pxd
import add_pxd_reconstruction
18from svd
import add_svd_reconstruction
22def use_local_sectormap(path, pathToLocalSM):
23 """ Helper function that sets up the SectorMapBootstrapModule in that way that a local sectormap will be
24 loaded instead the one from the DB. Has to be applied on the path after the SectorMapBootstrap was
25 put into the path (usually in add_reconstructin)
27 :param path: The path the SectorMapBootstrapModule is in.
28 :param pathToLocalSM: the local storage position of the sectormap (including the name)
31 B2WARNING(
"Warning will load local SectorMap from: " + pathToLocalSM)
32 adjust_module(path,
'SectorMapBootstrap', **{
"ReadSecMapFromDB":
False,
33 "ReadSectorMap":
True,
"SectorMapsInputFile": pathToLocalSM})
36def add_geometry_modules(path, components=None):
38 Helper function to add the geometry related modules needed for tracking
41 :param path: The path to add the tracking reconstruction modules to
42 :param components: the list of geometry components in use or None for all components.
45 if 'Geometry' not in path:
46 path.add_module(
'Geometry', useDB=
True)
47 if components
is not None:
48 B2WARNING(
"Custom detector components specified: Will still build full geometry")
51 if 'SetupGenfitExtrapolation' not in path:
52 path.add_module(
'SetupGenfitExtrapolation',
53 energyLossBrems=
False, noiseBrems=
False)
56def add_hit_preparation_modules(path, components=None, pxd_filtering_offline=False, create_intercepts_for_pxd_ckf=False):
58 Helper function to prepare the hit information to be used by tracking.
60 :param path: The path to add the tracking reconstruction modules to
61 :param components: the list of geometry components in use or None for all components.
62 :param pxd_filtering_offline: PXD data reduction is performed after CDC and SVD tracking,
63 so PXD reconstruction has to wait until the ROIs are calculated.
64 :param create_intercepts_for_pxd_ckf: If True, the PXDROIFinder is added to the path to create PXDIntercepts to be used
65 for hit filtering when creating the CKF relations. This independent of the offline PXD digit filtering which is
66 steered by 'pxd_filtering_offline'. This can be applied for both data and MC.
70 if is_detector_present(
"SVD", components):
71 add_svd_reconstruction(path)
74 if is_detector_present(
"PXD", components)
and not pxd_filtering_offline
and not create_intercepts_for_pxd_ckf:
75 add_pxd_reconstruction(path)
78def add_track_fit_and_track_creator(path, components=None, pruneTracks=False, trackFitHypotheses=None,
79 reco_tracks="RecoTracks", add_mva_quality_indicator=True, v0_finding=True):
81 Helper function to add the modules performing the
82 track fit, the V0 fit and the Belle2 track creation to the path.
84 :param path: The path to add the tracking reconstruction modules to
85 :param components: the list of geometry components in use or None for all components.
86 :param pruneTracks: Delete all hits expect the first and the last from the found tracks.
87 :param trackFitHypotheses: Which pdg hypotheses to fit. Defaults to [211, 321, 2212].
88 :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
89 :param v0_finding: if false, the V0Finder module is not executed
90 :param add_mva_quality_indicator: If true, add the MVA track quality estimation
91 to the path that sets the quality indicator property of the found tracks.
94 add_prefilter_track_fit_and_track_creator(path, components=components,
95 trackFitHypotheses=trackFitHypotheses,
96 reco_tracks=reco_tracks,
97 add_mva_quality_indicator=add_mva_quality_indicator)
99 add_postfilter_track_fit_and_track_creator(path,
100 trackFitHypotheses=trackFitHypotheses,
101 reco_tracks=reco_tracks)
105 path.add_module(
'V0Finder', RecoTracks=reco_tracks, v0FitterMode=1)
108 add_prune_tracks(path, components=components, reco_tracks=reco_tracks)
111def add_prefilter_track_fit_and_track_creator(path, components=None, trackFitHypotheses=None,
112 stopOnSuccessfulTrackFit=True,
113 reco_tracks="RecoTracks", add_mva_quality_indicator=True):
115 Helper function to add only the modules required to calculate HLT filter decision:
116 performing the track fit and the Belle2 track creation to the path.
118 :param path: The path to add the tracking reconstruction modules to
119 :param components: the list of geometry components in use or None for all components.
120 :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
121 :param trackFitHypotheses: Which pdg hypotheses to fit. Defaults to [211, 321, 2212].
122 :param stopOnSuccessfulTrackFit: If true (default), the TrackCreator will stop when a fit is successful
123 among the listed "trackFitHypotheses". Otherwise, all listed hypotheses are attempted.
124 :param add_mva_quality_indicator: If true, add the MVA track quality estimation
125 to the path that sets the quality indicator property of the found tracks.
129 path.add_module(
"IPTrackTimeEstimator",
130 recoTracksStoreArrayName=reco_tracks, useFittedInformation=
False)
132 path.add_module(
"DAFRecoFitter", recoTracksStoreArrayName=reco_tracks).set_name(
133 "Combined_DAFRecoFitter")
137 if add_mva_quality_indicator:
138 path.add_module(
"TrackQualityEstimatorMVA", collectEventFeatures=
True)
142 path.add_module(
'TrackCreator', recoTrackColName=reco_tracks,
143 pdgCodes=[211, 321, 2212]
if not trackFitHypotheses
else trackFitHypotheses,
144 stopOnSuccessfulTrackFit=stopOnSuccessfulTrackFit
145 ).set_name(
"TrackCreator_prefilter")
148def add_postfilter_track_fit_and_track_creator(path,
149 trackFitHypotheses=None,
150 reco_tracks="RecoTracks"):
152 Helper function to add the modules not required to calculate HLT filter decision,
153 and ran after the HLT decision calculation.
154 It performs track fit and creates Belle II tracks with additional mass hypotheses.
156 :param path: The path to add the tracking reconstruction modules to
157 :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
158 :param trackFitHypotheses: Which pdg hypotheses to fit. Defaults to [211, 321, 2212].
168 path.add_module(
'TrackCreator', recoTrackColName=reco_tracks,
169 pdgCodes=[211, 321, 2212]
if not trackFitHypotheses
else trackFitHypotheses,
170 stopOnSuccessfulTrackFit=
False,
171 ).set_name(
"TrackCreator_postfilter")
174def add_cr_track_fit_and_track_creator(path, components=None,
175 prune_tracks=False, event_timing_extraction=True,
176 reco_tracks="RecoTracks", tracks=""):
178 Helper function to add the modules performing the cdc cr track fit
179 and track creation to the path.
181 :param path: The path to which to add the tracking reconstruction modules
182 :param components: the list of geometry components in use or None for all components.
183 :param reco_tracks: The name of the reco tracks to use
184 :param tracks: the name of the output Belle tracks
185 :param prune_tracks: Delete all hits expect the first and the last from the found tracks.
186 :param event_timing_extraction: extract the event time
190 path.add_module(
"PlaneTriggerTrackTimeEstimator",
191 recoTracksStoreArrayName=reco_tracks,
192 pdgCodeToUseForEstimation=13,
193 triggerPlanePosition=[0., 0., 0.],
194 triggerPlaneDirection=[0., 1., 0.],
195 useFittedInformation=
False)
198 path.add_module(
"DAFRecoFitter",
199 recoTracksStoreArrayName=reco_tracks,
201 pdgCodesToUseForFitting=13).set_name(f
"DAFRecoFitter {reco_tracks}")
204 path.add_module(
"PlaneTriggerTrackTimeEstimator",
205 recoTracksStoreArrayName=reco_tracks,
206 pdgCodeToUseForEstimation=13,
207 triggerPlanePosition=[0., 0., 0.],
208 triggerPlaneDirection=[0., 1., 0.],
209 useFittedInformation=
True)
212 path.add_module(
"DAFRecoFitter",
213 recoTracksStoreArrayName=reco_tracks,
214 pdgCodesToUseForFitting=13
215 ).set_name(f
"DAFRecoFitter {reco_tracks}")
217 if event_timing_extraction:
219 path.add_module(
"FullGridChi2TrackTimeExtractor",
220 RecoTracksStoreArrayName=reco_tracks,
221 GridMaximalT0Value=40,
222 GridMinimalT0Value=-40,
227 path.add_module(
"DAFRecoFitter",
229 recoTracksStoreArrayName=reco_tracks,
230 pdgCodesToUseForFitting=13
231 ).set_name(f
"DAFRecoFitter {reco_tracks}")
234 path.add_module(
'TrackCreator',
236 recoTrackColName=reco_tracks,
238 useClosestHitToIP=
True,
244 add_prune_tracks(path=path, components=components, reco_tracks=reco_tracks)
247def add_mc_matcher(path, components=None, mc_reco_tracks="MCRecoTracks",
248 reco_tracks="RecoTracks", use_second_cdc_hits=False,
249 split_after_delta_t=-1.0, matching_method="hit",
250 relate_tracks_to_mcparticles=True,
251 chi2_cutoffs=[128024, 95, 173, 424, 90, 424],
254 Match the tracks to the MC truth. The matching works based on
255 the output of the TrackFinderMCTruthRecoTracks.
256 Alternatively one can use the Chi2MCTrackMatcher based on chi2 values
257 calculated from the helixparameters of Tracks and MCParticles.
259 :param path: The path to add the tracking reconstruction modules to
260 :param components: the list of geometry components in use or None for all components.
261 :param mc_reco_tracks: Name of the StoreArray where the mc reco tracks will be stored
262 :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
263 :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
264 :param split_after_delta_t: If positive, split MCRecoTrack into multiple MCRecoTracks if the time
265 distance between two adjacent SimHits is more than the given value
266 :param matching_method: hit: uses the hit-matching
267 chi2: uses the chi2-matching
268 :param relate_tracks_to_mcparticles: If True (default), Tracks are related to MCParticles. Only works
269 if the TrackCreator is in the path before. Needs to be set to False
270 if only track finding is performed, but no Tracks are created.
271 :param chi2_cutoffs: If chi2 matching method is used, this list defines the individual cut-off values
272 for the chi2 values. Thereby each charged stable particle gets its cut-off
273 value. The order of the pdgs is [11,13,211,2212,321,1000010020]. The default
274 values are determined from a small study investigating chi2 value distribution of
275 trivial matching pairs.
276 :param chi2_linalg: If chi2 matching is used, this defines package used to invert the covariance5
277 matrix. ROOT has been shown to be faster than eigen. If False ROOT is used. If True
280 if (matching_method ==
"hit"):
281 path.add_module(
'TrackFinderMCTruthRecoTracks',
282 RecoTracksStoreArrayName=mc_reco_tracks,
284 UseSecondCDCHits=use_second_cdc_hits,
285 UsePXDHits=is_detector_present(
"PXD", components),
286 UseSVDHits=is_detector_present(
"SVD", components),
287 UseCDCHits=is_detector_present(
"CDC", components),
288 SplitAfterDeltaT=split_after_delta_t)
290 path.add_module(
'MCRecoTracksMatcher',
291 mcRecoTracksStoreArrayName=mc_reco_tracks,
292 prRecoTracksStoreArrayName=reco_tracks,
293 UsePXDHits=is_detector_present(
"PXD", components),
294 UseSVDHits=is_detector_present(
"SVD", components),
295 UseCDCHits=is_detector_present(
"CDC", components))
297 if relate_tracks_to_mcparticles:
298 path.add_module(
'TrackToMCParticleRelator')
300 elif (matching_method ==
"chi2"):
301 print(
"Warning: The Chi2MCTrackMatcherModule is currently not fully developed and tested!")
302 path.add_module(
'Chi2MCTrackMatcherModule',
303 CutOffs=chi2_cutoffs,
307def add_prune_tracks(path, components=None, reco_tracks="RecoTracks"):
309 Adds removal of the intermediate states at each measurement from the fitted tracks.
311 :param path: The path to add the tracking reconstruction modules to
312 :param components: the list of geometry components in use or None for all components.
313 :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
317 if components
and not is_any_detector_present([
"SVD",
"CDC"], components):
320 path.add_module(
'PruneRecoTracks', storeArrayName=reco_tracks).set_name(
"PruneRecoTracks " + reco_tracks)
321 path.add_module(
"PruneGenfitTracks")
324def add_flipping_of_recoTracks(
327 reco_tracks="RecoTracks",
328 trackFitHypotheses=None,
329 reco_tracks_flipped="RecoTracks_flipped"):
331 This function adds the mva based selections and the flipping of the recoTracks
333 :param path: The path to add the tracking reconstruction modules to
334 :param fit_tracks: fit the flipped recotracks or not
335 :param reco_tracks: Name of the StoreArray where the reco tracks should be flipped
336 :param trackFitHypotheses: Which pdg hypotheses to fit. Defaults to [211, 321, 2212].
337 :param reco_tracks_flipped: Name of the temporary StoreArray for the flipped RecoTracks
340 path.add_module(
"FlipQuality", recoTracksStoreArrayName=reco_tracks,
341 identifier=
'TRKTrackFlipAndRefit_MVA1_weightfile',
342 indexOfFlippingMVA=1).set_name(
"FlipQuality_1stMVA")
344 path.add_module(
"RecoTracksReverter", inputStoreArrayName=reco_tracks,
345 outputStoreArrayName=reco_tracks_flipped)
347 path.add_module(
"DAFRecoFitter", recoTracksStoreArrayName=reco_tracks_flipped).set_name(
"Combined_DAFRecoFitter_flipped")
348 path.add_module(
"IPTrackTimeEstimator",
349 recoTracksStoreArrayName=reco_tracks_flipped, useFittedInformation=
False)
350 path.add_module(
"TrackCreator", trackColName=
"Tracks_flipped",
351 trackFitResultColName=
"TrackFitResults_flipped",
352 recoTrackColName=reco_tracks_flipped,
356 2212]
if not trackFitHypotheses
else trackFitHypotheses).set_name(
"TrackCreator_flipped")
357 path.add_module(
"FlipQuality", recoTracksStoreArrayName=reco_tracks,
358 identifier=
'TRKTrackFlipAndRefit_MVA2_weightfile',
359 indexOfFlippingMVA=2).set_name(
"FlipQuality_2ndMVA")
360 path.add_module(
"FlippedRecoTracksMerger",
361 inputStoreArrayName=reco_tracks,
362 inputStoreArrayNameFlipped=reco_tracks_flipped)
365def add_pxd_track_finding(path, components, input_reco_tracks, output_reco_tracks, use_mc_truth=False,
366 add_both_directions=False, temporary_reco_tracks="PXDRecoTracks", **kwargs):
367 """Add the pxd track finding to the path"""
368 if not is_detector_present(
"PXD", components):
373 path.add_module(
"MCRecoTracksMatcher", UsePXDHits=
False,
374 UseSVDHits=is_detector_present(
"SVD", components), UseCDCHits=is_detector_present(
"CDC", components),
375 mcRecoTracksStoreArrayName=
"MCRecoTracks",
376 prRecoTracksStoreArrayName=input_reco_tracks)
378 add_pxd_ckf(path, svd_cdc_reco_tracks=input_reco_tracks, pxd_reco_tracks=temporary_reco_tracks,
379 direction=
"backward", use_mc_truth=use_mc_truth, **kwargs)
381 if add_both_directions:
382 add_pxd_ckf(path, svd_cdc_reco_tracks=input_reco_tracks, pxd_reco_tracks=temporary_reco_tracks,
383 direction=
"forward", use_mc_truth=use_mc_truth, **kwargs)
385 path.add_module(
"RelatedTracksCombiner", CDCRecoTracksStoreArrayName=input_reco_tracks,
386 VXDRecoTracksStoreArrayName=temporary_reco_tracks, recoTracksStoreArrayName=output_reco_tracks)
389def add_pxd_cr_track_finding(path, components, input_reco_tracks, output_reco_tracks, use_mc_truth=False,
390 add_both_directions=False, temporary_reco_tracks="PXDRecoTracks", **kwargs):
391 """Add the pxd track finding to the path"""
392 if not is_detector_present(
"PXD", components):
397 path.add_module(
"MCRecoTracksMatcher", UsePXDHits=
False,
398 UseSVDHits=is_detector_present(
"SVD", components), UseCDCHits=is_detector_present(
"CDC", components),
399 mcRecoTracksStoreArrayName=
"MCRecoTracks",
400 prRecoTracksStoreArrayName=input_reco_tracks)
402 add_cosmics_pxd_ckf(path, svd_cdc_reco_tracks=input_reco_tracks, pxd_reco_tracks=temporary_reco_tracks,
403 direction=
"backward", use_mc_truth=use_mc_truth, **kwargs)
405 if add_both_directions:
406 add_cosmics_pxd_ckf(path, svd_cdc_reco_tracks=input_reco_tracks, pxd_reco_tracks=temporary_reco_tracks,
407 direction=
"forward", use_mc_truth=use_mc_truth, **kwargs)
409 path.add_module(
"RelatedTracksCombiner", CDCRecoTracksStoreArrayName=input_reco_tracks,
410 VXDRecoTracksStoreArrayName=temporary_reco_tracks, recoTracksStoreArrayName=output_reco_tracks)
413def add_svd_track_finding(
418 svd_ckf_mode="SVD_after",
420 add_both_directions=True,
421 temporary_reco_tracks="SVDRecoTracks",
422 temporary_svd_cdc_reco_tracks="SVDPlusCDCStandaloneRecoTracks",
423 use_svd_to_cdc_ckf=True,
424 prune_temporary_tracks=True,
425 add_mva_quality_indicator=False,
426 svd_standalone_mode="VXDTF2",
430 Add SVD track finding to the path.
432 :param path: The path to add the tracking reconstruction modules to
433 :param components: The list of geometry components in use or None for all components.
434 :param input_reco_tracks: Name of the StoreArray with the input reco tracks (usually from CDC) that are used in the
435 CKF track finding and are merged with the newly found SVD tracks into the ``output_reco_tracks``.
436 :param output_reco_tracks: Name of the StoreArray where the reco tracks outputted by the SVD track finding should be
438 :param svd_ckf_mode: String designating the mode of the CDC-to-SVD CKF, that is how it is combined with the SVD
439 standalone track finding. One of "SVD_after", "SVD_before", "SVD_before_with_second_ckf",
440 "only_ckf", "ckf_merger_plus_spacepoint_ckf", "SVD_alone", "cosmics".
441 :param use_mc_truth: Add mc matching and use the MC information in the CKF (but not in the VXDTF2)
442 :param add_both_directions: Whether to add the CKF with both forward and backward extrapolation directions instead
444 :param temporary_reco_tracks: Intermediate store array where the SVD tracks from the SVD standalone track finding
445 are stored, before they are merged with CDC tracks and extended via the CKF tracking.
446 :param temporary_svd_cdc_reco_tracks: Intermediate store array where the combination of ``temporary_reco_tracks``
447 (from SVD) and ``input_reco_tracks`` (from CDC standalone) is stored, before the CKF is applied.
448 It is only used if ``use_svd_to_cdc_ckf`` is true. Otherwise, the combination is stored directly in
449 ``output_reco_tracks``.
450 :param use_svd_to_cdc_ckf: Whether to enable the CKF extrapolation from the SVD into the CDC.
451 That CKF application is not affected by ``svd_ckf_mode``.
452 :param prune_temporary_tracks: Delete all hits expect the first and last from intermediate track objects.
453 :param add_mva_quality_indicator: Add the VXDQualityEstimatorMVA module to set the quality indicator
454 property for tracks from VXDTF2 standalone tracking
455 (ATTENTION: Standard triplet QI of VXDTF2 is replaced in this case
456 -> setting this option to 'True' will have some influence on the final track collection)
457 :param svd_standalone_mode: Which SVD standalone tracking is used.
458 Options are "VXDTF2", "SVDHough", "VXDTF2_and_SVDHough", and "SVDHough_and_VXDTF2".
460 :param cdc_backtrack_chain: The backtrack relation chain for finding the original CDC RecoTracks.
461 :param svd_backtrack_chain: The backtrack relation chain for finding the original SVD RecoTracks.
464 if not is_detector_present(
"SVD", components):
467 if not input_reco_tracks
or input_reco_tracks ==
"":
469 add_svd_standalone_tracking(path, components=[
"SVD"],
470 svd_standalone_mode=svd_standalone_mode,
471 reco_tracks=output_reco_tracks,
472 add_mva_quality_indicator=add_mva_quality_indicator)
477 path.add_module(
"MCRecoTracksMatcher", UsePXDHits=
False, UseSVDHits=
False,
478 UseCDCHits=is_detector_present(
"CDC", components),
479 mcRecoTracksStoreArrayName=
"MCRecoTracks",
480 prRecoTracksStoreArrayName=input_reco_tracks)
482 if svd_ckf_mode ==
"SVD_before":
483 add_svd_standalone_tracking(path, components=[
"SVD"],
484 svd_standalone_mode=svd_standalone_mode,
485 reco_tracks=temporary_reco_tracks,
486 add_mva_quality_indicator=add_mva_quality_indicator)
487 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
488 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
489 if add_both_directions:
490 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
491 use_mc_truth=use_mc_truth, direction=
"forward", **kwargs)
493 elif svd_ckf_mode ==
"SVD_before_with_second_ckf":
494 add_svd_standalone_tracking(path, components=[
"SVD"],
495 svd_standalone_mode=svd_standalone_mode,
496 reco_tracks=temporary_reco_tracks,
497 add_mva_quality_indicator=add_mva_quality_indicator)
498 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
499 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
500 if add_both_directions:
501 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
502 use_mc_truth=use_mc_truth, direction=
"forward", **kwargs)
503 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
504 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
505 if add_both_directions:
506 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
507 use_mc_truth=use_mc_truth, direction=
"forward", **kwargs)
509 elif svd_ckf_mode ==
"only_ckf":
510 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
511 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
512 if add_both_directions:
513 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
514 use_mc_truth=use_mc_truth, direction=
"forward", **kwargs)
517 elif svd_ckf_mode ==
"ckf_merger_plus_spacepoint_ckf":
518 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
519 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
520 if add_both_directions:
521 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
522 use_mc_truth=use_mc_truth, direction=
"forward", **kwargs)
523 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
524 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
525 if add_both_directions:
526 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
527 use_mc_truth=use_mc_truth, direction=
"forward", **kwargs)
529 elif svd_ckf_mode ==
"SVD_after":
530 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
531 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
532 if add_both_directions:
533 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
534 use_mc_truth=use_mc_truth, direction=
"forward", **kwargs)
536 add_svd_standalone_tracking(path, components=[
"SVD"],
537 svd_standalone_mode=svd_standalone_mode,
538 reco_tracks=temporary_reco_tracks,
539 add_mva_quality_indicator=add_mva_quality_indicator)
540 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
541 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
542 if add_both_directions:
543 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
544 use_mc_truth=use_mc_truth, direction=
"forward", **kwargs)
546 elif svd_ckf_mode ==
"SVD_alone":
547 add_svd_standalone_tracking(path, components=[
"SVD"],
548 svd_standalone_mode=svd_standalone_mode,
549 reco_tracks=temporary_reco_tracks,
550 add_mva_quality_indicator=add_mva_quality_indicator)
551 path.add_module(
'VXDCDCTrackMerger',
552 CDCRecoTrackColName=input_reco_tracks,
553 VXDRecoTrackColName=temporary_reco_tracks)
555 elif svd_ckf_mode ==
"cosmics":
556 add_cosmics_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
557 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
558 if add_both_directions:
559 add_cosmics_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
560 use_mc_truth=use_mc_truth, direction=
"forward", **kwargs)
563 raise ValueError(f
"Do not understand the svd_ckf_mode {svd_ckf_mode}")
565 if use_svd_to_cdc_ckf:
566 combined_svd_cdc_standalone_tracks = temporary_svd_cdc_reco_tracks
568 combined_svd_cdc_standalone_tracks = output_reco_tracks
571 path.add_module(
"RelatedTracksCombiner", VXDRecoTracksStoreArrayName=temporary_reco_tracks,
572 CDCRecoTracksStoreArrayName=input_reco_tracks,
573 recoTracksStoreArrayName=combined_svd_cdc_standalone_tracks)
575 if use_svd_to_cdc_ckf:
576 path.add_module(
"ToCDCCKF",
577 inputWireHits=
"CDCWireHitVector",
578 inputRecoTrackStoreArrayName=combined_svd_cdc_standalone_tracks,
579 relatedRecoTrackStoreArrayName=
"CKFCDCRecoTracks",
580 relationCheckForDirection=
"backward",
581 ignoreTracksWithCDChits=
True,
582 outputRecoTrackStoreArrayName=
"CKFCDCRecoTracks",
583 outputRelationRecoTrackStoreArrayName=combined_svd_cdc_standalone_tracks,
584 writeOutDirection=
"backward",
585 stateBasicFilterParameters={
"maximalHitDistance": 0.15},
586 pathFilter=
"arc_length",
589 path.add_module(
"CDCCKFTracksCombiner",
590 CDCRecoTracksStoreArrayName=
"CKFCDCRecoTracks",
591 VXDRecoTracksStoreArrayName=combined_svd_cdc_standalone_tracks,
592 recoTracksStoreArrayName=output_reco_tracks)
594 if prune_temporary_tracks:
595 for temp_reco_track
in [combined_svd_cdc_standalone_tracks,
"CKFCDCRecoTracks"]:
596 path.add_module(
'PruneRecoTracks', storeArrayName=temp_reco_track).set_name(
"PruneRecoTracks " + temp_reco_track)
599def add_svd_standalone_tracking(path,
602 svd_standalone_mode="VXDTF2",
603 reco_tracks="SVDRecoTracks",
604 add_mva_quality_indicator=False,
607 Convenience function to add the SVD standalone tracking
609 :param path: basf2 path
610 :param components: components to use, defaults to SVD
611 :param svd_clusters: Name of the SVDClusters StoreArray used for tracking
612 :param svd_standalone_mode: Which SVD standalone tracking is used.
613 Options are "VXDTF2", "SVDHough", "VXDTF2_and_SVDHough", and "SVDHough_and_VXDTF2".
615 :param reco_tracks: In case the only SVD standalone tracking is performed, these are the final RecoTracks,
616 otherwise it's an intermediate StoreaArray where the SVD tracks from the SVD standalone track finding
617 are stored, before they are merged with CDC tracks and extended via the CKF tracking.
618 :param add_mva_quality_indicator: Add the VXDQualityEstimatorMVA module to set the quality indicator
619 property for tracks from VXDTF2 standalone tracking
620 (ATTENTION: Standard triplet QI of VXDTF2 is replaced in this case
621 -> setting this option to 'True' will have some influence on the final track collection)
622 :param suffix: all names of intermediate Storearrays will have the suffix appended. Useful in cases someone needs to
623 put several instances of track finding in one path.
625 if svd_standalone_mode ==
"VXDTF2":
626 add_vxd_track_finding_vxdtf2(path, components=components, svd_clusters=svd_clusters, reco_tracks=reco_tracks,
627 add_mva_quality_indicator=add_mva_quality_indicator, suffix=suffix)
629 elif svd_standalone_mode ==
"SVDHough":
630 add_svd_hough_tracking(path, reco_tracks=reco_tracks, suffix=suffix)
632 elif svd_standalone_mode ==
"VXDTF2_and_SVDHough":
633 add_vxd_track_finding_vxdtf2(path,
634 components=components,
635 svd_clusters=svd_clusters,
636 nameSPTCs=
"SPTrackCands"+
"VXDTF2",
637 reco_tracks=reco_tracks+
"VXDTF2",
638 add_mva_quality_indicator=add_mva_quality_indicator,
640 add_svd_hough_tracking(path,
641 reco_tracks=reco_tracks+
"Hough",
642 svd_space_point_track_candidates=
"SPTrackCands"+
"Hough",
645 path.add_module(
'RecoTrackStoreArrayCombiner',
646 Temp1RecoTracksStoreArrayName=reco_tracks+
"VXDTF2", Temp1SPTrackCandsStoreArrayName=
"SPTrackCands"+
"VXDTF2",
647 Temp2RecoTracksStoreArrayName=reco_tracks+
"Hough", Temp2SPTrackCandsStoreArrayName=
"SPTrackCands"+
"Hough",
648 recoTracksStoreArrayName=reco_tracks)
649 path.add_module(
'PruneRecoTracks', storeArrayName=reco_tracks+
"VXDTF2").set_name(
"PruneRecoTracks " + reco_tracks+
"VXDTF2")
650 path.add_module(
'PruneRecoTracks', storeArrayName=reco_tracks+
"Hough").set_name(
"PruneRecoTracks " + reco_tracks+
"Hough")
652 elif svd_standalone_mode ==
"SVDHough_and_VXDTF2":
653 add_svd_hough_tracking(path,
654 reco_tracks=reco_tracks+
"Hough",
655 svd_space_point_track_candidates=
"SPTrackCands"+
"Hough",
657 add_vxd_track_finding_vxdtf2(path,
658 components=components,
659 svd_clusters=svd_clusters,
660 nameSPTCs=
"SPTrackCands"+
"VXDTF2",
661 reco_tracks=reco_tracks+
"VXDTF2",
662 add_mva_quality_indicator=add_mva_quality_indicator,
665 path.add_module(
'RecoTrackStoreArrayCombiner',
666 Temp1RecoTracksStoreArrayName=reco_tracks+
"Hough", Temp1SPTrackCandsStoreArrayName=
"SPTrackCands"+
"Hough",
667 Temp2RecoTracksStoreArrayName=reco_tracks+
"VXDTF2", Temp2SPTrackCandsStoreArrayName=
"SPTrackCands"+
"VXDTF2",
668 recoTracksStoreArrayName=reco_tracks)
669 path.add_module(
'PruneRecoTracks', storeArrayName=reco_tracks+
"Hough").set_name(
"PruneRecoTracks " + reco_tracks+
"Hough")
670 path.add_module(
'PruneRecoTracks', storeArrayName=reco_tracks+
"VXDTF2").set_name(
"PruneRecoTracks " + reco_tracks+
"VXDTF2")
673 raise ValueError(f
"Do not understand the svd_standalone_mode {svd_standalone_mode}")
676def add_cdc_track_finding(path, output_reco_tracks="RecoTracks", with_cdc_cellular_automaton=False,
677 use_second_hits=False, add_mva_quality_indicator=True,
678 reattach_hits=False, skip_WireHitPreparer=False, use_cat_finder=False):
680 Convenience function for adding all cdc track finder modules
683 The result is a StoreArray with name @param reco_tracks full of RecoTracks (not TrackCands any more!).
684 Use the GenfitTrackCandidatesCreator Module to convert back.
686 :param path: basf2 path
687 :param output_reco_tracks: Name of the output RecoTracks. Defaults to RecoTracks.
688 :param with_cdc_cellular_automaton: If true, the cellular automaton track finder algorithm will be used too,
689 after the global algorithm (Legendre)
690 :param use_second_hits: If true, the second hit information will be used in the CDC track finding.
691 :param add_mva_quality_indicator: Add the TFCDC_TrackQualityEstimator module to set the CDC quality
692 indicator property of the CDC ``output_reco_tracks``
693 :param cdc_quality_estimator_weightfile: Weightfile identifier for the TFCDC_TrackQualityEstimator
694 :param reattach_hits: if true, use the ReattachCDCWireHitsToRecoTracks module at the end of the CDC track finding
695 to read hits with bad ADC or TOT rejected by the TFCDC_WireHitPreparer module.
696 :param skip_WireHitPreparer: if True, the TFCDC_WireHitPreparer will be skipped. This is necessary if for instance
697 the SVD tracking and the ToCDCCKF are run before the full CDC tracking, as the ToCDCCKF already reqires the WireHits
698 to be present. Defaults to False, as for the default tracking chain it is required.
699 :param use_cat_finder: if True, it runs the CDC AI Track Finder (CATFinder) as CDC track finding algorithm
700 instead of the default one.
703 if 'RegisterEventLevelTrackingInfo' not in path:
704 path.add_module(
'RegisterEventLevelTrackingInfo')
706 if not use_cat_finder:
707 if not skip_WireHitPreparer:
709 path.add_module(
"TFCDC_WireHitPreparer",
710 wirePosition=
"aligned",
711 useSecondHits=use_second_hits,
712 flightTimeEstimation=
"outwards",
714 filterParameters={
'DBPayloadName':
'trackfindingcdc_WireHitBackgroundDetectorParameters'})
717 path.add_module(
"TFCDC_ClusterPreparer",
719 ClusterFilterParameters={})
722 path.add_module(
"TFCDC_SegmentFinderFacetAutomaton", SegmentRelationFilterParameters={
723 'DBPayloadName':
'trackfindingcdc_RealisticSegmentRelationFilterParameters'})
726 path.add_module(
"TFCDC_AxialTrackFinderLegendre")
729 path.add_module(
"TFCDC_TrackQualityAsserter",
733 path.add_module(
'TFCDC_StereoHitFinder')
736 path.add_module(
'TFCDC_SegmentTrackCombiner',
737 segmentTrackFilter=
"mva",
738 segmentTrackFilterParameters={
'DBPayloadName':
'trackfindingcdc_SegmentTrackFilterParameters'},
740 trackFilterParameters={
'DBPayloadName':
'trackfindingcdc_TrackFilterParameters'})
742 output_tracks =
"CDCTrackVector"
744 if with_cdc_cellular_automaton:
745 output_tracks =
"CombinedCDCTrackVector"
746 path.add_module(
"TFCDC_TrackFinderSegmentPairAutomaton",
747 tracks=
"CDCTrackVector2")
750 path.add_module(
"TFCDC_TrackCombiner",
751 inputTracks=
"CDCTrackVector",
752 secondaryInputTracks=
"CDCTrackVector2",
753 tracks=output_tracks)
756 path.add_module(
"TFCDC_TrackQualityAsserter",
757 inputTracks=output_tracks,
764 if with_cdc_cellular_automaton:
766 path.add_module(
"TFCDC_TrackCreatorSingleSegments",
767 inputTracks=output_tracks,
768 MinimalHitsBySuperLayerId={0: 15})
770 if add_mva_quality_indicator:
773 "TFCDC_TrackQualityEstimator",
774 inputTracks=output_tracks,
776 filterParameters={
'DBPayloadName':
'trackfindingcdc_TrackQualityEstimatorParameters'},
779 deactivateIfDeadBoard=
False,
780 minLayerJumpsForDeadBoards=4
784 path.add_module(
"TFCDC_TrackExporter",
785 inputTracks=output_tracks,
786 RecoTracksStoreArrayName=
"CDCRecoTracksBeforeReattaching" if reattach_hits
else output_reco_tracks)
790 if 'SetupGenfitExtrapolation' not in path:
792 path.add_module(
'SetupGenfitExtrapolation')
795 path.add_module(
"ReattachCDCWireHitsToRecoTracks",
796 inputRecoTracksStoreArrayName=
"CDCRecoTracksBeforeReattaching",
797 outputRecoTracksStoreArrayName=output_reco_tracks)
801 "TFCDC_WireHitPreparer",
802 wirePosition=
"aligned",
803 useSecondHits=use_second_hits,
804 flightTimeEstimation=
"outwards",
805 filter=
"cuts_from_DB",
810 recoTracksStoreArrayName=output_reco_tracks
814 path.add_module(
"IPTrackTimeEstimator",
815 useFittedInformation=
False,
816 recoTracksStoreArrayName=output_reco_tracks)
819 path.add_module(
"CDCHitBasedT0Extraction")
822 path.add_module(
"CDCTrackingEventLevelMdstInfoFillerFromHits")
823 if not use_cat_finder:
824 path.add_module(
"CDCTrackingEventLevelMdstInfoFillerFromSegments")
827def add_eclcdc_track_finding(path, components, output_reco_tracks="RecoTracks", prune_temporary_tracks=True):
829 Convenience function for adding all track finder modules to the path that are based on ecl seeds.
831 The result is a StoreArray with name @param reco_tracks full of RecoTracks.
832 Use the GenfitTrackCandidatesCreator Module to convert back.
834 :param path: basf2 path
835 :param components: the list of geometry components in use or None for all components.
836 :param output_reco_tracks: Name of the output RecoTracks. Defaults to RecoTracks.
837 :param pruneTracks: Delete all hits expect the first and the last from the found tracks.
839 if not are_detectors_present([
"CDC",
"ECL"], components):
842 ecl_cdc_reco_tracks =
"ECLCDCRecoTracks"
844 if not is_detector_present(
"SVD", components):
845 ecl_cdc_reco_tracks = output_reco_tracks
848 temporary_reco_track_list = []
850 path.add_module(
"ToCDCFromEclCKF",
851 inputWireHits=
"CDCWireHitVector",
852 minimalEnRequirementCluster=0.3,
853 eclSeedRecoTrackStoreArrayName=
'EclSeedRecoTracks',
854 hitFindingDirection=
"backward",
855 outputRecoTrackStoreArrayName=
"CDCRecoTracksFromEcl",
856 outputRelationRecoTrackStoreArrayName=
"EclSeedRecoTracks",
857 writeOutDirection=
"forward",
858 stateBasicFilterParameters={
"maximalHitDistance": 7.5,
"maximalHitDistanceEclSeed": 75.0},
859 stateExtrapolationFilterParameters={
"direction":
"backward"},
860 pathFilter=
"arc_length_fromEcl",
861 inputECLshowersStoreArrayName=
"ECLShowers",
862 trackFindingDirection=
"backward",
867 path.add_module(
"ToCDCCKF",
868 inputWireHits=
"CDCWireHitVector",
869 inputRecoTrackStoreArrayName=
"CDCRecoTracksFromEcl",
870 relatedRecoTrackStoreArrayName=ecl_cdc_reco_tracks,
871 relationCheckForDirection=
"backward",
872 outputRecoTrackStoreArrayName=ecl_cdc_reco_tracks,
873 outputRelationRecoTrackStoreArrayName=
"CDCRecoTracksFromEcl",
874 writeOutDirection=
"backward",
875 stateBasicFilterParameters={
"maximalHitDistance": 0.75},
876 stateExtrapolationFilterParameters={
"direction":
"forward"},
877 pathFilter=
"arc_length",
881 temporary_reco_track_list.append(
'CDCRecoTracksFromEcl')
898 if is_detector_present(
"SVD", components):
899 add_svd_track_finding(path, components=components, input_reco_tracks=ecl_cdc_reco_tracks,
900 output_reco_tracks=output_reco_tracks, use_mc_truth=
False,
901 svd_ckf_mode=
"only_ckf", add_both_directions=
False,
902 temporary_reco_tracks=
"ECLSVDRecoTracks", use_svd_to_cdc_ckf=
False,
903 prune_temporary_tracks=prune_temporary_tracks)
904 temporary_reco_track_list.append(ecl_cdc_reco_tracks)
905 temporary_reco_track_list.append(
'ECLSVDRecoTracks')
907 if prune_temporary_tracks:
908 for temporary_reco_track_name
in temporary_reco_track_list:
909 if temporary_reco_track_name != output_reco_tracks:
912 storeArrayName=temporary_reco_track_name).set_name(
914 temporary_reco_track_name)
917def add_cdc_cr_track_finding(path, output_reco_tracks="RecoTracks", trigger_point=(0, 0, 0), merge_tracks=
True,
918 use_second_cdc_hits=
False):
920 Convenience function for adding all cdc track finder modules currently dedicated for the CDC-TOP testbeam
923 The result is a StoreArray with name @param reco_tracks full of RecoTracks (not TrackCands any more!).
928 The path to be filled
929 output_reco_tracks: str
930 Name of the output RecoTracks. Defaults to RecoTracks.
932 The upper and lower half of the tracks should be merged together in one track
933 use_second_hits: bool
934 If true, the second hit information will be used in the CDC track finding.
938 path.add_module(
"TFCDC_WireHitPreparer",
939 useSecondHits=use_second_cdc_hits,
940 flightTimeEstimation=
"downwards",
941 filter=
"cuts_from_DB",
942 triggerPoint=trigger_point)
945 path.add_module(
"TFCDC_ClusterPreparer",
946 ClusterFilter=
"mva_bkg",
947 ClusterFilterParameters={
'DBPayloadName':
'trackfindingcdc_ClusterFilterParameters'})
950 path.add_module(
"TFCDC_SegmentFinderFacetAutomaton",
951 SegmentOrientation=
"downwards")
954 path.add_module(
"TFCDC_AxialTrackFinderLegendre")
957 path.add_module(
"TFCDC_TrackQualityAsserter",
961 path.add_module(
'TFCDC_StereoHitFinder')
964 path.add_module(
'TFCDC_SegmentTrackCombiner',
965 segmentTrackFilter=
"mva",
966 segmentTrackFilterParameters={
'DBPayloadName':
'trackfindingcdc_SegmentTrackFilterParameters'},
968 trackFilterParameters={
'DBPayloadName':
'trackfindingcdc_TrackFilterParameters'})
971 path.add_module(
"TFCDC_TrackQualityAsserter",
972 corrections=[
"LayerBreak",
"OneSuperlayer",
"Small"],
976 path.add_module(
"TFCDC_TrackOrienter",
977 inputTracks=
"CDCTrackVector",
978 tracks=
"OrientedCDCTrackVector",
979 TrackOrientation=
"downwards",
982 output_tracks =
"OrientedCDCTrackVector"
986 path.add_module(
"TFCDC_TrackLinker",
987 inputTracks=
"OrientedCDCTrackVector",
988 tracks=
"MergedCDCTrackVector",
991 output_tracks =
"MergedCDCTrackVector"
995 path.add_module(
"TFCDC_TrackFlightTimeAdjuster",
996 inputTracks=
"OrientedCDCTrackVector",
1000 path.add_module(
"TFCDC_TrackExporter",
1001 inputTracks=
"OrientedCDCTrackVector",
1002 RecoTracksStoreArrayName=
"NonMergedRecoTracks")
1005 path.add_module(
"TFCDC_TrackFlightTimeAdjuster",
1006 inputTracks=output_tracks,
1010 path.add_module(
"TFCDC_TrackExporter",
1011 inputTracks=output_tracks,
1012 RecoTracksStoreArrayName=output_reco_tracks)
1015 path.add_module(
"CDCHitBasedT0Extraction")
1018def add_vxd_track_finding_vxdtf2(
1021 reco_tracks="RecoTracks",
1022 nameSPTCs='SPTrackCands',
1025 useTwoStepSelection=True,
1027 sectormap_file=None,
1028 custom_setup_name=None,
1029 min_SPTC_quality=0.,
1030 filter_overlapping=True,
1031 add_mva_quality_indicator=False,
1034 Convenience function for adding all vxd track finder Version 2 modules
1037 The result is a StoreArray with name @param reco_tracks full of RecoTracks (not TrackCands any more!).
1038 Use the GenfitTrackCandidatesCreator Module to convert back.
1040 :param path: basf2 path
1041 :param svd_clusters: SVDCluster collection name
1042 :param reco_tracks: Name of the output RecoTracks, Defaults to RecoTracks.
1043 :param nameSPTCs: Name of the SpacePointTrackCands StoreArray
1044 :param components: List of the detector components to be used in the reconstruction. Defaults to None which means
1046 :param suffix: all names of intermediate Storearrays will have the suffix appended. Useful in cases someone needs to
1047 put several instances of track finding in one path.
1048 :param useTwoStepSelection: if True Families will be defined during path creation and will be used to create only
1049 the best candidate per family.
1050 :param PXDminSVDSPs: When using PXD require at least this number of SVD SPs for the SPTCs
1051 :param sectormap_file: if set to a finite value, a file will be used instead of the sectormap in the database.
1052 :param custom_setup_name: Set a custom setup name for the tree in the sector map.
1053 :param min_SPTC_quality: minimal qualityIndicator value to keeps SPTCs after the QualityEstimation.
1054 0 means no cut. Default: 0
1055 :param filter_overlapping: Whether to use SVDOverlapResolver, Default: True
1056 :param add_mva_quality_indicator: Whether to use the MVA Quality Estimator module for VXDTF2 tracks to set the
1057 quality_indicator property of the found ``reco_tracks``. Default: False.
1064 if is_detector_present(
"PXD", components):
1065 setup_name =
"SVDPXDDefault"
1066 db_sec_map_file =
"VXDSectorMap_v000.root"
1069 setup_name =
"SVDOnlyDefault"
1070 db_sec_map_file =
"SVDSectorMap_v000.root"
1079 nameTrackingInfoModule =
"RegisterEventLevelTrackingInfo" + suffix
1080 nameEventTrackingInfo =
"EventLevelTrackingInfo" + suffix
1081 if nameTrackingInfoModule
not in path:
1083 registerEventlevelTrackingInfo = register_module(
'RegisterEventLevelTrackingInfo')
1084 registerEventlevelTrackingInfo.set_name(nameTrackingInfoModule)
1085 registerEventlevelTrackingInfo.param(
'EventLevelTrackingInfoName', nameEventTrackingInfo)
1086 path.add_module(registerEventlevelTrackingInfo)
1088 nameSPs =
'SpacePoints' + suffix
1090 pxdSPCreatorName =
'PXDSpacePointCreator' + suffix
1091 if pxdSPCreatorName
not in [e.name()
for e
in path.modules()]:
1093 spCreatorPXD = register_module(
'PXDSpacePointCreator')
1094 spCreatorPXD.set_name(pxdSPCreatorName)
1095 spCreatorPXD.param(
'NameOfInstance',
'PXDSpacePoints')
1096 spCreatorPXD.param(
'SpacePoints',
"PXD" + nameSPs)
1097 path.add_module(spCreatorPXD)
1100 secMapBootStrap = register_module(
'SectorMapBootstrap')
1101 secMapBootStrap.param(
'ReadSectorMap', sectormap_file
is not None)
1102 secMapBootStrap.param(
'ReadSecMapFromDB', sectormap_file
is None)
1103 secMapBootStrap.param(
'SectorMapsInputFile', sectormap_file
or db_sec_map_file)
1104 secMapBootStrap.param(
'SetupToRead', custom_setup_name
or setup_name)
1105 secMapBootStrap.param(
'WriteSectorMap',
False)
1106 path.add_module(secMapBootStrap)
1113 spacePointArrayNames = [
"SVD" + nameSPs]
1115 spacePointArrayNames += [
"PXD" + nameSPs]
1117 nameSegNet =
'SegmentNetwork' + suffix
1119 segNetProducer = register_module(
'SegmentNetworkProducer')
1120 segNetProducer.param(
'NetworkOutputName', nameSegNet)
1121 segNetProducer.param(
'SpacePointsArrayNames', spacePointArrayNames)
1122 segNetProducer.param(
'sectorMapName', custom_setup_name
or setup_name)
1123 segNetProducer.param(
'EventLevelTrackingInfoName', nameEventTrackingInfo)
1124 path.add_module(segNetProducer)
1134 trackFinder = register_module(
'TrackFinderVXDCellOMat')
1135 trackFinder.param(
'NetworkName', nameSegNet)
1136 trackFinder.param(
'SpacePointTrackCandArrayName', nameSPTCs)
1137 trackFinder.param(
'printNetworks',
False)
1138 trackFinder.param(
'setFamilies', useTwoStepSelection)
1139 trackFinder.param(
'selectBestPerFamily', useTwoStepSelection)
1140 trackFinder.param(
'xBestPerFamily', 30)
1141 trackFinder.param(
'EventLevelTrackingInfoName', nameEventTrackingInfo)
1142 path.add_module(trackFinder)
1144 if useTwoStepSelection:
1145 subSetModule = register_module(
'AddVXDTrackCandidateSubSets')
1146 subSetModule.param(
'NameSpacePointTrackCands', nameSPTCs)
1147 path.add_module(subSetModule)
1156 pxdSVDCut = register_module(
'PXDSVDCut')
1157 pxdSVDCut.param(
'minSVDSPs', PXDminSVDSPs)
1158 pxdSVDCut.param(
'SpacePointTrackCandsStoreArrayName', nameSPTCs)
1159 path.add_module(pxdSVDCut)
1161 if add_mva_quality_indicator:
1163 "VXDQualityEstimatorMVA",
1164 SpacePointTrackCandsStoreArrayName=nameSPTCs,
1168 'QualityEstimatorVXD',
1169 EstimationMethod=
'tripletFit',
1170 SpacePointTrackCandsStoreArrayName=nameSPTCs,
1173 if min_SPTC_quality > 0.:
1174 qualityIndicatorCutter = register_module(
'VXDTrackCandidatesQualityIndicatorCutter')
1175 qualityIndicatorCutter.param(
'minRequiredQuality', min_SPTC_quality)
1176 qualityIndicatorCutter.param(
'NameSpacePointTrackCands', nameSPTCs)
1177 path.add_module(qualityIndicatorCutter)
1180 maxCandidateSelection = register_module(
'BestVXDTrackCandidatesSelector')
1181 maxCandidateSelection.param(
'NameSpacePointTrackCands', nameSPTCs)
1182 maxCandidateSelection.param(
'NewNameSpacePointTrackCands', nameSPTCs)
1183 maxCandidateSelection.param(
'SubsetCreation',
False)
1184 path.add_module(maxCandidateSelection)
1187 vIPRemover = register_module(
'SPTCvirtualIPRemover')
1188 vIPRemover.param(
'tcArrayName', nameSPTCs)
1190 vIPRemover.param(
'maxTCLengthForVIPKeeping', 0)
1191 path.add_module(vIPRemover)
1198 if filter_overlapping:
1199 overlapResolver = register_module(
'SVDOverlapResolver')
1200 overlapResolver.param(
'NameSpacePointTrackCands', nameSPTCs)
1201 overlapResolver.param(
'ResolveMethod',
'greedy')
1202 overlapResolver.param(
'NameSVDClusters', svd_clusters)
1203 path.add_module(overlapResolver)
1210 momSeedRetriever = register_module(
'SPTCmomentumSeedRetriever')
1211 momSeedRetriever.param(
'tcArrayName', nameSPTCs)
1212 path.add_module(momSeedRetriever)
1214 converter = register_module(
'SPTC2RTConverter')
1215 converter.param(
'recoTracksStoreArrayName', reco_tracks)
1216 converter.param(
'spacePointsTCsStoreArrayName', nameSPTCs)
1217 converter.param(
'svdClustersName', svd_clusters)
1218 converter.param(
'svdHitsStoreArrayName', svd_clusters)
1219 path.add_module(converter)
1222def add_svd_hough_tracking(path,
1223 svd_space_points='SVDSpacePoints',
1224 svd_clusters='SVDClusters',
1225 reco_tracks='RecoTracks',
1226 svd_space_point_track_candidates='SPTrackCands',
1229 Convenience function to add the SVDHoughTracking to the path.
1230 :param path: The path to add the SVDHoughTracking module to.
1231 :param svd_space_points: Name of the StoreArray containing the SVDSpacePoints
1232 :param svd_clusters: Name of the StoreArray containing the SVDClusters
1233 :param reco_tracks: Name of the StoreArray containing the RecoTracks
1234 :param svd_space_point_track_candidates: Name of the StoreArray containing the SpacePointTrackCandidates
1235 :param suffix: all names of intermediate StoreArrays will have the suffix appended. Useful in cases someone needs to
1236 put several instances of track finding in one path.
1239 path.add_module(
'SVDHoughTracking',
1240 SVDSpacePointStoreArrayName=svd_space_points + suffix,
1241 SVDClustersStoreArrayName=svd_clusters + suffix,
1242 finalOverlapResolverNameSVDClusters=svd_clusters + suffix,
1243 refinerOverlapResolverNameSVDClusters=svd_clusters + suffix,
1244 RecoTracksStoreArrayName=reco_tracks + suffix,
1245 SVDSpacePointTrackCandsStoreArrayName=svd_space_point_track_candidates + suffix,
1246 relationFilter=
'angleAndTime',
1247 twoHitUseNBestHits=2,
1248 threeHitUseNBestHits=3,
1249 fourHitUseNBestHits=3,
1250 fiveHitUseNBestHits=2,
1254def add_default_cdc_svd_tracking_chain(path,
1259 with_cdc_cellular_automaton=False,
1260 use_second_cdc_hits=False,
1261 add_cdcTrack_QI=True,
1263 svd_ckf_mode="SVD_after",
1264 add_both_directions=True,
1265 use_svd_to_cdc_ckf=True,
1266 svd_standalone_mode="VXDTF2",
1267 add_vxdTrack_QI=False,
1268 prune_temporary_tracks=True,
1269 use_cat_finder=False
1272 Add the default CDC based tracking chain to the path, i.e. CDC standalone followed by the ToSVDSpacePointCKF, the SVD standalone
1273 track finding, a CKF based merger for standalone tracks, and finally the SVDToCDCCKF (if setup as such).
1275 :param path: The path to add the tracking reconstruction modules to
1276 :param components: the list of geometry components in use or None for all components.
1277 :param svd_reco_tracks: name of the SVD standalone RecoTracks StoreArray
1278 :param cdc_reco_tracks: name of the CDC standalone RecoTracks StoreArray
1279 :param output_reco_tracks: name of the combined CDC+SVD RecoTracks StoreArray that is the final result of this tracking path
1280 :param with_cdc_cellular_automaton: If true, in the CDC track finding the cellular automaton algorithm will be used too,
1281 after the global algorithm (Legendre)
1282 :param use_second_cdc_hits: whether to use the secondary CDC hit during CDC track finding or not
1283 :param add_cdcTrack_QI: If true, add the MVA track quality estimation
1284 to the path that sets the quality indicator property of the found CDC standalone tracks
1285 :param use_mc_truth: Use the truth information in the CKF modules
1286 :param svd_ckf_mode: how to apply the CKF (with or without SVD standalone tracking). Defaults to "SVD_after".
1287 :param add_both_directions: Curlers may be found in the wrong orientation by the CDC track finder, so try to
1288 extrapolate also in the other direction.
1289 :param use_svd_to_cdc_ckf: if true, add SVD to CDC CKF module.
1290 :param svd_standalone_mode: Which SVD standalone tracking is used.
1291 Options are "VXDTF2", "SVDHough", "VXDTF2_and_SVDHough", and "SVDHough_and_VXDTF2".
1292 Defaults to "VXDTF2"
1293 :param add_vxdTrack_QI: If true, add the MVA track quality estimation
1294 to the path that sets the quality indicator property of the found VXDTF2 tracks
1295 (ATTENTION: Standard triplet QI of VXDTF2 is replaced in this case
1296 -> setting this option to 'True' will have some influence on the final track collection)
1297 :param prune_temporary_tracks: If false, store all information of the single CDC and VXD tracks before merging.
1298 If true, prune them.
1299 :param use_cat_finder: if True, it runs the CDC AI Track Finder (CATFinder) as CDC track finding algorithm
1300 instead of the default one.
1304 temporary_reco_track_list = []
1307 latest_reco_tracks =
None
1309 if is_detector_present(
"CDC", components):
1310 add_cdc_track_finding(
1312 with_cdc_cellular_automaton=with_cdc_cellular_automaton,
1313 use_second_hits=use_second_cdc_hits,
1314 output_reco_tracks=cdc_reco_tracks,
1315 add_mva_quality_indicator=add_cdcTrack_QI,
1316 use_cat_finder=use_cat_finder
1318 temporary_reco_track_list.append(cdc_reco_tracks)
1319 latest_reco_tracks = cdc_reco_tracks
1321 if is_detector_present(
"SVD", components):
1322 add_svd_track_finding(path,
1323 components=components,
1324 input_reco_tracks=latest_reco_tracks,
1325 output_reco_tracks=output_reco_tracks,
1326 use_mc_truth=use_mc_truth,
1327 temporary_reco_tracks=svd_reco_tracks,
1328 svd_ckf_mode=svd_ckf_mode,
1329 add_both_directions=add_both_directions,
1330 use_svd_to_cdc_ckf=use_svd_to_cdc_ckf,
1331 prune_temporary_tracks=prune_temporary_tracks,
1332 add_mva_quality_indicator=add_vxdTrack_QI,
1333 svd_standalone_mode=svd_standalone_mode)
1334 temporary_reco_track_list.append(svd_reco_tracks)
1335 temporary_reco_track_list.append(output_reco_tracks)
1336 latest_reco_tracks = output_reco_tracks
1338 return (latest_reco_tracks, temporary_reco_track_list)
1341def add_inverted_svd_cdc_tracking_chain(path,
1345 svd_cdc_reco_tracks,
1346 cdcckf_reco_tracks="CKFCDCRecoTracks",
1347 output_reco_tracks="CombinedSVDCDCRecoTracks",
1348 add_vxdTrack_QI=True,
1349 svd_standalone_mode="VXDTF2",
1350 with_cdc_cellular_automaton=False,
1351 use_second_cdc_hits=False,
1352 add_cdcTrack_QI=True,
1354 add_both_directions=True,
1355 prune_temporary_tracks=True,
1356 temporary_reco_tracks_merging_strategy='before_ToSVDCKF',
1359 Add an inverted SVD based tracking chain to the path, i.e. SVD standalone followed by the ToCDCCKF, the CDC standalone
1360 track finding, a CKF based merger for standalone tracks, and finally the CDCToSVDSpacePointCKF.
1362 ATTENTION: The inverted tracking chain is neither optimised nor guaranteed to be bug free.
1363 ATTENTION: Please remove this comment once the inverted tracking has been optimised and is assumed to be bug-free.
1365 :param path: The path to add the tracking reconstruction modules to
1366 :param components: the list of geometry components in use or None for all components.
1367 :param svd_reco_tracks: name of the SVD standalone RecoTracks StoreArray
1368 :param cdc_reco_tracks: name of the CDC standalone RecoTracks StoreArray
1369 :param svd_cdc_reco_tracks: name of the intermediate combined CDC+SVD RecoTracks StoreArray
1370 :param cdcckf_reco_tracks: name of the intermediate RecoTracks StoreArray from the SVDToCDCCKF
1371 :param output_reco_tracks: name of the combined CDC+SVD RecoTracks StoreArray that is the final result of this tracking path
1372 :param add_vxdTrack_QI: If true, add the MVA track quality estimation
1373 to the path that sets the quality indicator property of the found VXDTF2 tracks
1374 (ATTENTION: Standard triplet QI of VXDTF2 is replaced in this case
1375 -> setting this option to 'True' will have some influence on the final track collection)
1376 :param svd_standalone_mode: Which SVD standalone tracking is used.
1377 Options are "VXDTF2", "SVDHough", "VXDTF2_and_SVDHough", and "SVDHough_and_VXDTF2".
1378 Defaults to "VXDTF2"
1379 :param with_cdc_cellular_automaton: If true, in the CDC track finding the cellular automaton algorithm will be used too,
1380 after the global algorithm (Legendre)
1381 :param use_second_cdc_hits: whether to use the secondary CDC hit during CDC track finding or not
1382 :param add_cdcTrack_QI: If true, add the MVA track quality estimation
1383 to the path that sets the quality indicator property of the found CDC standalone tracks
1384 :param use_mc_truth: Use the truth information in the CKF modules
1385 :param add_both_directions: Curlers may be found in the wrong orientation by the CDC track finder, so try to
1386 extrapolate also in the other direction.
1387 :param prune_temporary_tracks: If false, store all information of the single CDC and VXD tracks before merging.
1388 If true, prune them.
1389 :param temporary_reco_tracks_merging_strategy: When are the temporary CDC RecoTracks merged? Before or after the ToSVDCKF?
1390 Allowed options: \"before_ToSVDCKF\" (default) and \"after_ToCDCCKF\".
1393 B2WARNING(
"ATTENTION: The inverted tracking chain starting from SVD is an experimental feature. "
1394 "It is neither well optimised nor tested for the time being. "
1395 "Please be careful when interpreting the results!")
1397 if temporary_reco_tracks_merging_strategy
not in [
"before_ToSVDCKF",
"after_ToCDCCKF"]:
1398 B2FATAL(
"Invalid option for 'temporary_reco_tracks_merging_strategy'. "
1399 "Allowed options are 'before_ToSVDCKF' and 'after_ToCDCCKF'.")
1402 temporary_reco_track_list = []
1405 latest_reco_tracks =
None
1407 if is_detector_present(
"SVD", components):
1408 add_svd_track_finding(path,
1409 components=components,
1410 input_reco_tracks=
"",
1411 output_reco_tracks=svd_reco_tracks,
1412 add_mva_quality_indicator=add_vxdTrack_QI,
1413 svd_standalone_mode=svd_standalone_mode)
1414 temporary_reco_track_list.append(svd_reco_tracks)
1415 latest_reco_tracks = svd_reco_tracks
1417 path.add_module(
"DAFRecoFitter", recoTracksStoreArrayName=svd_reco_tracks).set_name(f
"DAFRecoFitter {svd_reco_tracks}")
1419 if is_detector_present(
"CDC", components):
1420 path.add_module(
"TFCDC_WireHitPreparer",
1421 wirePosition=
"aligned",
1422 useSecondHits=use_second_cdc_hits,
1423 flightTimeEstimation=
"outwards",
1425 filterParameters={
'DBPayloadName':
'trackfindingcdc_WireHitBackgroundDetectorParameters'})
1427 path.add_module(
"ToCDCCKF",
1428 inputWireHits=
"CDCWireHitVector",
1429 inputRecoTrackStoreArrayName=svd_reco_tracks,
1430 relatedRecoTrackStoreArrayName=cdcckf_reco_tracks,
1431 relationCheckForDirection=
"backward",
1432 ignoreTracksWithCDChits=
True,
1433 outputRecoTrackStoreArrayName=cdcckf_reco_tracks,
1434 outputRelationRecoTrackStoreArrayName=svd_reco_tracks,
1435 writeOutDirection=
"backward",
1436 stateBasicFilterParameters={
"maximalHitDistance": 0.15},
1437 pathFilter=
"arc_length",
1440 path.add_module(
"CDCCKFTracksCombiner",
1441 CDCRecoTracksStoreArrayName=cdcckf_reco_tracks,
1442 VXDRecoTracksStoreArrayName=svd_reco_tracks,
1443 recoTracksStoreArrayName=svd_cdc_reco_tracks)
1445 temporary_reco_track_list.append(cdcckf_reco_tracks)
1446 temporary_reco_track_list.append(svd_cdc_reco_tracks)
1447 latest_reco_tracks = svd_cdc_reco_tracks
1449 add_cdc_track_finding(path,
1450 with_cdc_cellular_automaton=with_cdc_cellular_automaton,
1451 use_second_hits=use_second_cdc_hits,
1452 output_reco_tracks=cdc_reco_tracks,
1453 add_mva_quality_indicator=add_cdcTrack_QI,
1454 skip_WireHitPreparer=
True)
1455 temporary_reco_track_list.append(cdc_reco_tracks)
1456 latest_reco_tracks = cdc_reco_tracks
1458 if temporary_reco_tracks_merging_strategy ==
"before_ToSVDCKF":
1459 path.add_module(
"RecoTrackStoreArrayCombiner",
1460 Temp1RecoTracksStoreArrayName=latest_reco_tracks,
1461 Temp2RecoTracksStoreArrayName=svd_cdc_reco_tracks,
1462 recoTracksStoreArrayName=
"CombinedCDCSVDRecoTracks")
1463 temporary_reco_track_list.append(
"CombinedCDCSVDRecoTracks")
1464 latest_reco_tracks =
"CombinedCDCSVDRecoTracks"
1466 if is_detector_present(
"SVD", components):
1468 combined_reco_tracks_name =
"CDCSVDRecoTracks"
1473 tmp_output_reco_tracks = output_reco_tracks
if "before_ToSVDCKF" else combined_reco_tracks_name
1474 add_svd_track_finding(path,
1475 components=components,
1476 input_reco_tracks=latest_reco_tracks,
1477 output_reco_tracks=tmp_output_reco_tracks,
1478 temporary_reco_tracks=svd_reco_tracks,
1479 use_mc_truth=use_mc_truth,
1480 svd_ckf_mode=
"ckf_merger_plus_spacepoint_ckf",
1481 add_both_directions=add_both_directions,
1482 use_svd_to_cdc_ckf=
False,
1483 prune_temporary_tracks=prune_temporary_tracks)
1484 if temporary_reco_tracks_merging_strategy ==
"before_ToSVDCKF":
1485 temporary_reco_track_list.append(output_reco_tracks)
1486 latest_reco_tracks = output_reco_tracks
1487 elif temporary_reco_tracks_merging_strategy ==
"after_ToSVDCKF":
1488 temporary_reco_track_list.append(combined_reco_tracks_name)
1489 latest_reco_tracks = combined_reco_tracks_name
1491 if temporary_reco_tracks_merging_strategy ==
"after_ToSVDCKF":
1492 path.add_module(
"RecoTrackStoreArrayCombiner",
1493 Temp1RecoTracksStoreArrayName=latest_reco_tracks,
1494 Temp2RecoTracksStoreArrayName=svd_cdc_reco_tracks,
1495 recoTracksStoreArrayName=output_reco_tracks)
1496 temporary_reco_track_list.append(output_reco_tracks)
1497 latest_reco_tracks = output_reco_tracks
1499 return (latest_reco_tracks, temporary_reco_track_list)