10 from pybasf2
import B2WARNING
12 from basf2
import register_module
13 from ckf.path_functions import add_pxd_ckf, add_ckf_based_merger, add_svd_ckf, add_cosmics_svd_ckf, add_cosmics_pxd_ckf
14 from pxd
import add_pxd_reconstruction
15 from svd
import add_svd_reconstruction
19 def use_local_sectormap(path, pathToLocalSM):
20 """ Helper function that sets up the SectorMapBootstrapModule in that way that a local sectormap will be
21 loaded instead the one from the DB. Has to be applied on the path after the SectorMapBootstrap was
22 put into the path (usually in add_reconstructin)
24 :param path: The path the SectorMapBootstrapModule is in.
25 :param pathToLocalSM: the local storage position of the sectormap (including the name)
28 B2WARNING(
"Warning will load local SectorMap from: " + pathToLocalSM)
29 adjust_module(path,
'SectorMapBootstrap', **{
"ReadSecMapFromDB":
False,
30 "ReadSectorMap":
True,
"SectorMapsInputFile": pathToLocalSM})
33 def add_geometry_modules(path, components=None):
35 Helper function to add the geometry related modules needed for tracking
38 :param path: The path to add the tracking reconstruction modules to
39 :param components: the list of geometry components in use or None for all components.
42 if 'Geometry' not in path:
43 path.add_module(
'Geometry', useDB=
True)
44 if components
is not None:
45 B2WARNING(
"Custom detector components specified: Will still build full geometry")
48 if 'SetupGenfitExtrapolation' not in path:
49 path.add_module(
'SetupGenfitExtrapolation',
50 energyLossBrems=
False, noiseBrems=
False)
53 def add_hit_preparation_modules(path, components=None, pxd_filtering_offline=False):
55 Helper fucntion to prepare the hit information to be used by tracking.
57 :param path: The path to add the tracking reconstruction modules to
58 :param components: the list of geometry components in use or None for all components.
59 :param pxd_filtering_offline: PXD data reduction is performed after CDC and SVD tracking,
60 so PXD reconstruction has to wait until the ROIs are calculated.
64 if is_svd_used(components):
65 add_svd_reconstruction(path)
68 if is_pxd_used(components)
and not pxd_filtering_offline:
69 add_pxd_reconstruction(path)
72 def add_track_fit_and_track_creator(path, components=None, pruneTracks=False, trackFitHypotheses=None,
73 reco_tracks="RecoTracks", add_mva_quality_indicator=False, v0_finding=True):
75 Helper function to add the modules performing the
76 track fit, the V0 fit and the Belle2 track creation to the path.
78 :param path: The path to add the tracking reconstruction modules to
79 :param components: the list of geometry components in use or None for all components.
80 :param pruneTracks: Delete all hits expect the first and the last from the found tracks.
81 :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
82 :param v0_finding: if false, the V0Finder module is not executed
83 :param add_mva_quality_indicator: If true, add the MVA track quality estimation
84 to the path that sets the quality indicator property of the found tracks.
87 add_prefilter_track_fit_and_track_creator(path,
88 trackFitHypotheses=trackFitHypotheses,
89 reco_tracks=reco_tracks,
90 add_mva_quality_indicator=add_mva_quality_indicator)
94 path.add_module(
'V0Finder', RecoTracks=reco_tracks, v0FitterMode=1)
97 add_prune_tracks(path, components=components, reco_tracks=reco_tracks)
100 def add_prefilter_track_fit_and_track_creator(path, trackFitHypotheses=None,
101 reco_tracks="RecoTracks", add_mva_quality_indicator=False):
103 Helper function to add only the modules required to calculate HLT filter decision:
104 performing the track fit and the Belle2 track creation to the path.
106 :param path: The path to add the tracking reconstruction modules to
107 :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
108 :param add_mva_quality_indicator: If true, add the MVA track quality estimation
109 to the path that sets the quality indicator property of the found tracks.
113 path.add_module(
"IPTrackTimeEstimator",
114 recoTracksStoreArrayName=reco_tracks, useFittedInformation=
False)
116 path.add_module(
"DAFRecoFitter", recoTracksStoreArrayName=reco_tracks).set_name(
117 "Combined_DAFRecoFitter")
121 if add_mva_quality_indicator:
122 path.add_module(
"TrackQualityEstimatorMVA", collectEventFeatures=
True)
130 path.add_module(
'TrackCreator', recoTrackColName=reco_tracks,
131 pdgCodes=[211, 321, 2212]
if not trackFitHypotheses
else trackFitHypotheses)
134 def add_cr_track_fit_and_track_creator(path, components=None,
135 prune_tracks=False, event_timing_extraction=True,
136 reco_tracks="RecoTracks", tracks=""):
138 Helper function to add the modules performing the cdc cr track fit
139 and track creation to the path.
141 :param path: The path to which to add the tracking reconstruction modules
142 :param components: the list of geometry components in use or None for all components.
143 :param reco_tracks: The name of the reco tracks to use
144 :param tracks: the name of the output Belle tracks
145 :param prune_tracks: Delete all hits expect the first and the last from the found tracks.
146 :param event_timing_extraction: extract the event time
150 path.add_module(
"PlaneTriggerTrackTimeEstimator",
151 recoTracksStoreArrayName=reco_tracks,
152 pdgCodeToUseForEstimation=13,
153 triggerPlanePosition=[0., 0., 0.],
154 triggerPlaneDirection=[0., 1., 0.],
155 useFittedInformation=
False)
158 path.add_module(
"DAFRecoFitter",
159 recoTracksStoreArrayName=reco_tracks,
161 pdgCodesToUseForFitting=13)
164 path.add_module(
"PlaneTriggerTrackTimeEstimator",
165 recoTracksStoreArrayName=reco_tracks,
166 pdgCodeToUseForEstimation=13,
167 triggerPlanePosition=[0., 0., 0.],
168 triggerPlaneDirection=[0., 1., 0.],
169 useFittedInformation=
True)
172 path.add_module(
"DAFRecoFitter",
173 recoTracksStoreArrayName=reco_tracks,
174 pdgCodesToUseForFitting=13
177 if event_timing_extraction:
179 path.add_module(
"FullGridChi2TrackTimeExtractor",
180 RecoTracksStoreArrayName=reco_tracks,
181 GridMaximalT0Value=40,
182 GridMinimalT0Value=-40,
187 path.add_module(
"DAFRecoFitter",
189 recoTracksStoreArrayName=reco_tracks,
190 pdgCodesToUseForFitting=13
194 path.add_module(
'TrackCreator',
196 recoTrackColName=reco_tracks,
198 useClosestHitToIP=
True,
204 add_prune_tracks(path=path, components=components,
205 reco_tracks=reco_tracks)
208 def add_mc_matcher(path, components=None, mc_reco_tracks="MCRecoTracks",
209 reco_tracks="RecoTracks", use_second_cdc_hits=False,
210 split_after_delta_t=-1.0, matching_method="hit",
211 chi2_cutoffs=[128024, 95, 173, 424, 90, 424],
214 Match the tracks to the MC truth. The matching works based on
215 the output of the TrackFinderMCTruthRecoTracks.
216 Alternativly one can use the Chi2MCTrackMatcher based on chi2 values
217 calculated from the helixparameters of Tracks and MCParticles.
219 :param path: The path to add the tracking reconstruction modules to
220 :param components: the list of geometry components in use or None for all components.
221 :param mc_reco_tracks: Name of the StoreArray where the mc reco tracks will be stored
222 :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
223 :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
224 :param split_after_delta_t: If positive, split MCRecoTrack into multiple MCRecoTracks if the time
225 distance between two adjecent SimHits is more than the given value
226 :param matching_method: hit: uses the hit-matching
227 chi2: uses the chi2-matching
228 :param chi2_cutoffs: If chi2 matching method is used, this list defines the individual cut-off values
229 for the chi2 values. Thereby each charged stable particle gets its cut-off
230 value. The order of the pdgs is [11,13,211,2212,321,1000010020]. The default
231 values are determined from a small study investigating chi2 value distribution of
232 trivial matching pairs.
233 :param chi2_linalg: If chi2 matching is used, this defines package used to invert the covariance5
234 matrix. ROOT has been shown to be faster than eigen. If False ROOT is used. If True
237 if (matching_method ==
"hit"):
238 path.add_module(
'TrackFinderMCTruthRecoTracks',
239 RecoTracksStoreArrayName=mc_reco_tracks,
241 UseSecondCDCHits=use_second_cdc_hits,
242 UsePXDHits=is_pxd_used(components),
243 UseSVDHits=is_svd_used(components),
244 UseCDCHits=is_cdc_used(components),
245 SplitAfterDeltaT=split_after_delta_t)
247 path.add_module(
'MCRecoTracksMatcher',
248 mcRecoTracksStoreArrayName=mc_reco_tracks,
249 prRecoTracksStoreArrayName=reco_tracks,
250 UsePXDHits=is_pxd_used(components),
251 UseSVDHits=is_svd_used(components),
252 UseCDCHits=is_cdc_used(components))
254 path.add_module(
'TrackToMCParticleRelator')
256 elif (matching_method ==
"chi2"):
257 print(
"Warning: The Chi2MCTrackMatcherModule is currently not fully developed and tested!")
258 path.add_module(
'Chi2MCTrackMatcherModule',
259 CutOffs=chi2_cutoffs,
263 def add_prune_tracks(path, components=None, reco_tracks="RecoTracks"):
265 Adds removal of the intermediate states at each measurement from the fitted tracks.
267 :param path: The path to add the tracking reconstruction modules to
268 :param components: the list of geometry components in use or None for all components.
269 :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
273 if components
and not (
'SVD' in components
or 'CDC' in components):
276 path.add_module(
'PruneRecoTracks', storeArrayName=reco_tracks)
277 path.add_module(
"PruneGenfitTracks")
280 def add_flipping_of_recoTracks(path, fit_tracks=True, reco_tracks="RecoTracks", trackFitHypotheses=None):
282 This function adds the mva based selections and the flipping of the recoTracks
284 :param path: The path to add the tracking reconstruction modules to
285 :param fit_tracks: fit the flipped recotracks or not
286 :param reco_tracks: Name of the StoreArray where the reco tracks should be flipped
287 :param trackFitHypotheses: Which pdg hypothesis to fit. Defaults to [211, 321, 2212].
290 path.add_module(
"FlipQuality", recoTracksStoreArrayName=reco_tracks,
291 identifier=
'TRKTrackFlipAndRefit_MVA1_weightfile',
292 indexOfFlippingMVA=1).set_name(
"FlipQuality_1stMVA")
294 reco_tracks_flipped =
"RecoTracks_flipped"
295 path.add_module(
"RecoTracksReverter", inputStoreArrayName=reco_tracks,
296 outputStoreArrayName=reco_tracks_flipped)
298 path.add_module(
"DAFRecoFitter", recoTracksStoreArrayName=reco_tracks_flipped).set_name(
"Combined_DAFRecoFitter_flipped")
299 path.add_module(
"IPTrackTimeEstimator",
300 recoTracksStoreArrayName=reco_tracks_flipped, useFittedInformation=
False)
301 path.add_module(
"TrackCreator", trackColName=
"Tracks_flipped",
302 trackFitResultColName=
"TrackFitResults_flipped",
303 recoTrackColName=reco_tracks_flipped,
307 2212]
if not trackFitHypotheses
else trackFitHypotheses).set_name(
"TrackCreator_flipped")
308 path.add_module(
"FlipQuality", recoTracksStoreArrayName=reco_tracks,
309 identifier=
'TRKTrackFlipAndRefit_MVA2_weightfile',
310 indexOfFlippingMVA=2).set_name(
"FlipQuality_2ndMVA")
311 path.add_module(
"FlippedRecoTracksMerger",
312 inputStoreArrayName=reco_tracks,
313 inputStoreArrayNameFlipped=reco_tracks_flipped)
316 def add_pxd_track_finding(path, components, input_reco_tracks, output_reco_tracks, use_mc_truth=False,
317 add_both_directions=False, temporary_reco_tracks="PXDRecoTracks", **kwargs):
318 """Add the pxd track finding to the path"""
319 if not is_pxd_used(components):
324 path.add_module(
"MCRecoTracksMatcher", UsePXDHits=
False,
325 UseSVDHits=is_svd_used(components), UseCDCHits=is_cdc_used(components),
326 mcRecoTracksStoreArrayName=
"MCRecoTracks",
327 prRecoTracksStoreArrayName=input_reco_tracks)
329 add_pxd_ckf(path, svd_cdc_reco_tracks=input_reco_tracks, pxd_reco_tracks=temporary_reco_tracks,
330 direction=
"backward", use_mc_truth=use_mc_truth, **kwargs)
332 if add_both_directions:
333 add_pxd_ckf(path, svd_cdc_reco_tracks=input_reco_tracks, pxd_reco_tracks=temporary_reco_tracks,
334 direction=
"forward", use_mc_truth=use_mc_truth, **kwargs)
336 path.add_module(
"RelatedTracksCombiner", CDCRecoTracksStoreArrayName=input_reco_tracks,
337 VXDRecoTracksStoreArrayName=temporary_reco_tracks, recoTracksStoreArrayName=output_reco_tracks)
340 def add_pxd_cr_track_finding(path, components, input_reco_tracks, output_reco_tracks, use_mc_truth=False,
341 add_both_directions=False, temporary_reco_tracks="PXDRecoTracks", **kwargs):
342 """Add the pxd track finding to the path"""
343 if not is_pxd_used(components):
348 path.add_module(
"MCRecoTracksMatcher", UsePXDHits=
False,
349 UseSVDHits=is_svd_used(components), UseCDCHits=is_cdc_used(components),
350 mcRecoTracksStoreArrayName=
"MCRecoTracks",
351 prRecoTracksStoreArrayName=input_reco_tracks)
353 add_cosmics_pxd_ckf(path, svd_cdc_reco_tracks=input_reco_tracks, pxd_reco_tracks=temporary_reco_tracks,
354 direction=
"backward", use_mc_truth=use_mc_truth, **kwargs)
356 if add_both_directions:
357 add_cosmics_pxd_ckf(path, svd_cdc_reco_tracks=input_reco_tracks, pxd_reco_tracks=temporary_reco_tracks,
358 direction=
"forward", use_mc_truth=use_mc_truth, **kwargs)
360 path.add_module(
"RelatedTracksCombiner", CDCRecoTracksStoreArrayName=input_reco_tracks,
361 VXDRecoTracksStoreArrayName=temporary_reco_tracks, recoTracksStoreArrayName=output_reco_tracks)
364 def add_svd_track_finding(
369 svd_ckf_mode="SVD_after",
371 add_both_directions=True,
372 temporary_reco_tracks="SVDRecoTracks",
373 temporary_svd_cdc_reco_tracks="SVDPlusCDCStandaloneRecoTracks",
374 use_svd_to_cdc_ckf=True,
375 prune_temporary_tracks=True,
376 add_mva_quality_indicator=False,
377 svd_standalone_mode="VXDTF2",
381 Add SVD track finding to the path.
383 :param path: The path to add the tracking reconstruction modules to
384 :param components: The list of geometry components in use or None for all components.
385 :param input_reco_tracks: Name of the StoreArray with the input reco tracks (usually from CDC) that are used in the
386 CKF track finding and are merged with the newly found SVD tracks into the ``output_reco_tracks``.
387 :param output_reco_tracks: Name of the StoreArray where the reco tracks outputted by the SVD track finding should be
389 :param svd_ckf_mode: String designating the mode of the CDC-to-SVD CKF, that is how it is combined with the SVD
390 standalone track finding. One of "SVD_after", "SVD_before", "SVD_before_with_second_ckf",
391 "only_ckf", "SVD_alone", "cosmics".
392 :param use_mc_truth: Add mc matching and use the MC information in the CKF (but not in the VXDTF2)
393 :param add_both_directions: Whether to add the CKF with both forward and backward extrapolation directions instead
395 :param temporary_reco_tracks: Intermediate store array where the SVD tracks from the SVD standalone track finding
396 are stored, before they are merged with CDC tracks and extended via the CKF tracking.
397 :param temporary_svd_cdc_reco_tracks: Intermediate store array where the combination of ``temporary_reco_tracks``
398 (from SVD) and ``input_reco_tracks`` (from CDC standalone) is stored, before the CKF is applied.
399 It is only used if ``use_svd_to_cdc_ckf`` is true. Otherwise, the combination is stored directly in
400 ``output_reco_tracks``.
401 :param use_svd_to_cdc_ckf: Whether to enable the CKF extrapolation from the SVD into the CDC.
402 That CKF application is not affected by ``svd_ckf_mode``.
403 :param prune_temporary_tracks: Delete all hits expect the first and last from intermediate track objects.
404 :param add_mva_quality_indicator: Add the VXDQualityEstimatorMVA module to set the quality indicator
405 property for tracks from VXDTF2 standalone tracking
406 (ATTENTION: Standard triplet QI of VXDTF2 is replaced in this case
407 -> setting this option to 'True' will have some influence on the final track collection)
408 :param svd_standalone_mode: Which SVD standalone tracking is used.
409 Options are "VXDTF2", "SVDHough", "VXDTF2_and_SVDHough", and "SVDHough_and_VXDTF2".
413 if not is_svd_used(components):
416 if not input_reco_tracks:
418 add_svd_standalone_tracking(path, components=[
"SVD"],
419 svd_standalone_mode=svd_standalone_mode,
420 reco_tracks=output_reco_tracks,
421 add_mva_quality_indicator=add_mva_quality_indicator)
426 path.add_module(
"MCRecoTracksMatcher", UsePXDHits=
False, UseSVDHits=
False,
427 UseCDCHits=is_cdc_used(components),
428 mcRecoTracksStoreArrayName=
"MCRecoTracks",
429 prRecoTracksStoreArrayName=input_reco_tracks)
431 if svd_ckf_mode ==
"SVD_before":
432 add_svd_standalone_tracking(path, components=[
"SVD"],
433 svd_standalone_mode=svd_standalone_mode,
434 reco_tracks=temporary_reco_tracks,
435 add_mva_quality_indicator=add_mva_quality_indicator)
436 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
437 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
438 if add_both_directions:
439 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
440 use_mc_truth=use_mc_truth, direction=
"forward", **kwargs)
442 elif svd_ckf_mode ==
"SVD_before_with_second_ckf":
443 add_svd_standalone_tracking(path, components=[
"SVD"],
444 svd_standalone_mode=svd_standalone_mode,
445 reco_tracks=temporary_reco_tracks,
446 add_mva_quality_indicator=add_mva_quality_indicator)
447 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
448 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
449 if add_both_directions:
450 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
451 use_mc_truth=use_mc_truth, direction=
"forward", **kwargs)
452 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
453 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
454 if add_both_directions:
455 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
456 use_mc_truth=use_mc_truth, direction=
"forward", **kwargs)
458 elif svd_ckf_mode ==
"only_ckf":
459 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
460 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
461 if add_both_directions:
462 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
463 use_mc_truth=use_mc_truth, direction=
"forward", **kwargs)
465 elif svd_ckf_mode ==
"SVD_after":
466 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
467 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
468 if add_both_directions:
469 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
470 use_mc_truth=use_mc_truth, direction=
"forward", **kwargs)
472 add_svd_standalone_tracking(path, components=[
"SVD"],
473 svd_standalone_mode=svd_standalone_mode,
474 reco_tracks=temporary_reco_tracks,
475 add_mva_quality_indicator=add_mva_quality_indicator)
476 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
477 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
478 if add_both_directions:
479 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
480 use_mc_truth=use_mc_truth, direction=
"forward", **kwargs)
482 elif svd_ckf_mode ==
"SVD_alone":
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 path.add_module(
'VXDCDCTrackMerger',
488 CDCRecoTrackColName=input_reco_tracks,
489 VXDRecoTrackColName=temporary_reco_tracks)
491 elif svd_ckf_mode ==
"cosmics":
492 add_cosmics_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
493 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
494 if add_both_directions:
495 add_cosmics_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
496 use_mc_truth=use_mc_truth, direction=
"forward", **kwargs)
499 raise ValueError(f
"Do not understand the svd_ckf_mode {svd_ckf_mode}")
501 if use_svd_to_cdc_ckf:
502 combined_svd_cdc_standalone_tracks = temporary_svd_cdc_reco_tracks
504 combined_svd_cdc_standalone_tracks = output_reco_tracks
507 path.add_module(
"RelatedTracksCombiner", VXDRecoTracksStoreArrayName=temporary_reco_tracks,
508 CDCRecoTracksStoreArrayName=input_reco_tracks,
509 recoTracksStoreArrayName=combined_svd_cdc_standalone_tracks)
511 if use_svd_to_cdc_ckf:
512 path.add_module(
"ToCDCCKF",
513 inputWireHits=
"CDCWireHitVector",
514 inputRecoTrackStoreArrayName=combined_svd_cdc_standalone_tracks,
515 relatedRecoTrackStoreArrayName=
"CKFCDCRecoTracks",
516 relationCheckForDirection=
"backward",
517 ignoreTracksWithCDChits=
True,
518 outputRecoTrackStoreArrayName=
"CKFCDCRecoTracks",
519 outputRelationRecoTrackStoreArrayName=combined_svd_cdc_standalone_tracks,
520 writeOutDirection=
"backward",
521 stateBasicFilterParameters={
"maximalHitDistance": 0.15},
522 pathFilter=
"arc_length",
525 path.add_module(
"CDCCKFTracksCombiner",
526 CDCRecoTracksStoreArrayName=
"CKFCDCRecoTracks",
527 VXDRecoTracksStoreArrayName=combined_svd_cdc_standalone_tracks,
528 recoTracksStoreArrayName=output_reco_tracks)
530 if prune_temporary_tracks:
531 for temp_reco_track
in [combined_svd_cdc_standalone_tracks,
"CKFCDCRecoTracks"]:
532 path.add_module(
'PruneRecoTracks', storeArrayName=temp_reco_track)
535 def add_svd_standalone_tracking(path,
538 svd_standalone_mode="VXDTF2",
539 reco_tracks="SVDRecoTracks",
540 add_mva_quality_indicator=False,
543 Convenience function to add the SVD standalone tracking
545 :param path: basf2 path
546 :param components: components to use, defaults to SVD
547 :param svd_clusters: Name of the SVDClusters StoreArray used for tracking
548 :param svd_standalone_mode: Which SVD standalone tracking is used.
549 Options are "VXDTF2", "SVDHough", "VXDTF2_and_SVDHough", and "SVDHough_and_VXDTF2".
551 :param reco_tracks: In case the only SVD standalone tracking is performed, these are the final RecoTracks,
552 otherwise it's an intermediate StoreaArray where the SVD tracks from the SVD standalone track finding
553 are stored, before they are merged with CDC tracks and extended via the CKF tracking.
554 :param add_mva_quality_indicator: Add the VXDQualityEstimatorMVA module to set the quality indicator
555 property for tracks from VXDTF2 standalone tracking
556 (ATTENTION: Standard triplet QI of VXDTF2 is replaced in this case
557 -> setting this option to 'True' will have some influence on the final track collection)
558 :param suffix: all names of intermediate Storearrays will have the suffix appended. Useful in cases someone needs to
559 put several instances of track finding in one path.
561 if svd_standalone_mode ==
"VXDTF2":
562 add_vxd_track_finding_vxdtf2(path, components=components, svd_clusters=svd_clusters, reco_tracks=reco_tracks,
563 add_mva_quality_indicator=add_mva_quality_indicator, suffix=suffix)
565 elif svd_standalone_mode ==
"SVDHough":
566 add_svd_hough_tracking(path, reco_tracks=reco_tracks, suffix=suffix)
568 elif svd_standalone_mode ==
"VXDTF2_and_SVDHough":
569 add_vxd_track_finding_vxdtf2(path,
570 components=components,
571 svd_clusters=svd_clusters,
572 nameSPTCs=
"SPTrackCands"+
"VXDTF2",
573 reco_tracks=reco_tracks+
"VXDTF2",
574 add_mva_quality_indicator=add_mva_quality_indicator,
576 add_svd_hough_tracking(path,
577 reco_tracks=reco_tracks+
"Hough",
578 svd_space_point_track_candidates=
"SPTrackCands"+
"Hough",
581 path.add_module(
'RecoTrackStoreArrayCombiner',
582 Temp1RecoTracksStoreArrayName=reco_tracks+
"VXDTF2",
583 Temp2RecoTracksStoreArrayName=reco_tracks+
"Hough",
584 recoTracksStoreArrayName=reco_tracks)
585 path.add_module(
'PruneRecoTracks', storeArrayName=reco_tracks+
"VXDTF2")
586 path.add_module(
'PruneRecoTracks', storeArrayName=reco_tracks+
"Hough")
588 elif svd_standalone_mode ==
"SVDHough_and_VXDTF2":
589 add_svd_hough_tracking(path,
590 reco_tracks=reco_tracks+
"Hough",
591 svd_space_point_track_candidates=
"SPTrackCands"+
"Hough",
593 add_vxd_track_finding_vxdtf2(path,
594 components=components,
595 svd_clusters=svd_clusters,
596 nameSPTCs=
"SPTrackCands"+
"VXDTF2",
597 reco_tracks=reco_tracks+
"VXDTF2",
598 add_mva_quality_indicator=add_mva_quality_indicator,
601 path.add_module(
'RecoTrackStoreArrayCombiner',
602 Temp1RecoTracksStoreArrayName=reco_tracks+
"Hough",
603 Temp2RecoTracksStoreArrayName=reco_tracks+
"VXDTF2",
604 recoTracksStoreArrayName=reco_tracks)
605 path.add_module(
'PruneRecoTracks', storeArrayName=reco_tracks+
"Hough")
606 path.add_module(
'PruneRecoTracks', storeArrayName=reco_tracks+
"VXDTF2")
609 raise ValueError(f
"Do not understand the svd_standalone_mode {svd_standalone_mode}")
612 def add_cdc_track_finding(path, output_reco_tracks="RecoTracks", with_ca=False,
613 use_second_hits=False, add_mva_quality_indicator=True,
614 reattach_hits=False):
616 Convenience function for adding all cdc track finder modules
619 The result is a StoreArray with name @param reco_tracks full of RecoTracks (not TrackCands any more!).
620 Use the GenfitTrackCandidatesCreator Module to convert back.
622 :param path: basf2 path
623 :param output_reco_tracks: Name of the output RecoTracks. Defaults to RecoTracks.
624 :param use_second_hits: If true, the second hit information will be used in the CDC track finding.
625 :param add_mva_quality_indicator: Add the TFCDC_TrackQualityEstimator module to set the CDC quality
626 indicator property of the CDC ``output_reco_tracks``
627 :param cdc_quality_estimator_weightfile: Weightfile identifier for the TFCDC_TrackQualityEstimator
628 :param reattach_hits: if true, use the ReattachCDCWireHitsToRecoTracks module at the end of the CDC track finding
629 to readd hits with bad ADC or TOT rejected by the TFCDC_WireHitPreparer module.
632 if 'RegisterEventLevelTrackingInfo' not in path:
633 path.add_module(
'RegisterEventLevelTrackingInfo')
636 path.add_module(
"TFCDC_WireHitPreparer",
637 wirePosition=
"aligned",
638 useSecondHits=use_second_hits,
639 flightTimeEstimation=
"outwards",
640 filter=
"cuts_from_DB")
643 path.add_module(
"TFCDC_ClusterPreparer",
645 ClusterFilterParameters={})
648 path.add_module(
"TFCDC_SegmentFinderFacetAutomaton",
649 SegmentRelationFilterParameters={
'DBPayloadName':
'trackfindingcdc_RealisticSegmentRelationFilterParameters'})
652 path.add_module(
"TFCDC_AxialTrackFinderLegendre")
655 path.add_module(
"TFCDC_TrackQualityAsserter",
659 path.add_module(
'TFCDC_StereoHitFinder')
662 path.add_module(
'TFCDC_SegmentTrackCombiner',
663 segmentTrackFilter=
"mva",
664 segmentTrackFilterParameters={
'DBPayloadName':
'trackfindingcdc_SegmentTrackFilterParameters'},
666 trackFilterParameters={
'DBPayloadName':
'trackfindingcdc_TrackFilterParameters'})
668 output_tracks =
"CDCTrackVector"
671 output_tracks =
"CombinedCDCTrackVector"
672 path.add_module(
"TFCDC_TrackFinderSegmentPairAutomaton",
673 tracks=
"CDCTrackVector2")
676 path.add_module(
"TFCDC_TrackCombiner",
677 inputTracks=
"CDCTrackVector",
678 secondaryInputTracks=
"CDCTrackVector2",
679 tracks=output_tracks)
682 path.add_module(
"TFCDC_TrackQualityAsserter",
683 inputTracks=output_tracks,
692 path.add_module(
"TFCDC_TrackCreatorSingleSegments",
693 inputTracks=output_tracks,
694 MinimalHitsBySuperLayerId={0: 15})
696 if add_mva_quality_indicator:
699 "TFCDC_TrackQualityEstimator",
700 inputTracks=output_tracks,
702 filterParameters={
'DBPayloadName':
'trackfindingcdc_TrackQualityEstimatorParameters'},
708 path.add_module(
"TFCDC_TrackExporter",
709 inputTracks=output_tracks,
710 RecoTracksStoreArrayName=
"CDCRecoTracksBeforeReattaching" if reattach_hits
else output_reco_tracks)
714 if 'SetupGenfitExtrapolation' not in path:
716 path.add_module(
'SetupGenfitExtrapolation')
719 path.add_module(
"ReattachCDCWireHitsToRecoTracks",
720 inputRecoTracksStoreArrayName=
"CDCRecoTracksBeforeReattaching",
721 outputRecoTracksStoreArrayName=output_reco_tracks)
724 path.add_module(
"IPTrackTimeEstimator",
725 useFittedInformation=
False,
726 recoTracksStoreArrayName=output_reco_tracks)
729 path.add_module(
"CDCHitBasedT0Extraction")
732 path.add_module(
"CDCTrackingEventLevelMdstInfoFiller")
735 def add_eclcdc_track_finding(path, components, output_reco_tracks="RecoTracks", prune_temporary_tracks=True):
737 Convenience function for adding all track finder modules to the path that are based on ecl seeds.
739 The result is a StoreArray with name @param reco_tracks full of RecoTracks.
740 Use the GenfitTrackCandidatesCreator Module to convert back.
742 :param path: basf2 path
743 :param components: the list of geometry components in use or None for all components.
744 :param output_reco_tracks: Name of the output RecoTracks. Defaults to RecoTracks.
745 :param pruneTracks: Delete all hits expect the first and the last from the found tracks.
747 if not is_cdc_used(components)
or not is_ecl_used(components):
750 ecl_cdc_reco_tracks =
"ECLCDCRecoTracks"
752 if not is_svd_used(components):
753 ecl_cdc_reco_tracks = output_reco_tracks
756 temporary_reco_track_list = []
758 path.add_module(
"ToCDCFromEclCKF",
759 inputWireHits=
"CDCWireHitVector",
760 minimalEnRequirementCluster=0.3,
761 eclSeedRecoTrackStoreArrayName=
'EclSeedRecoTracks',
762 hitFindingDirection=
"backward",
763 outputRecoTrackStoreArrayName=
"CDCRecoTracksFromEcl",
764 outputRelationRecoTrackStoreArrayName=
"EclSeedRecoTracks",
765 writeOutDirection=
"forward",
766 stateBasicFilterParameters={
"maximalHitDistance": 7.5,
"maximalHitDistanceEclSeed": 75.0},
767 stateExtrapolationFilterParameters={
"direction":
"backward"},
768 pathFilter=
"arc_length_fromEcl",
769 inputECLshowersStoreArrayName=
"ECLShowers",
770 trackFindingDirection=
"backward",
775 path.add_module(
"ToCDCCKF",
776 inputWireHits=
"CDCWireHitVector",
777 inputRecoTrackStoreArrayName=
"CDCRecoTracksFromEcl",
778 relatedRecoTrackStoreArrayName=ecl_cdc_reco_tracks,
779 relationCheckForDirection=
"backward",
780 outputRecoTrackStoreArrayName=ecl_cdc_reco_tracks,
781 outputRelationRecoTrackStoreArrayName=
"CDCRecoTracksFromEcl",
782 writeOutDirection=
"backward",
783 stateBasicFilterParameters={
"maximalHitDistance": 0.75},
784 stateExtrapolationFilterParameters={
"direction":
"forward"},
785 pathFilter=
"arc_length",
789 temporary_reco_track_list.append(
'CDCRecoTracksFromEcl')
806 if is_svd_used(components):
807 add_svd_track_finding(path, components=components, input_reco_tracks=ecl_cdc_reco_tracks,
808 output_reco_tracks=output_reco_tracks, use_mc_truth=
False,
809 svd_ckf_mode=
"only_ckf", add_both_directions=
False,
810 temporary_reco_tracks=
"ECLSVDRecoTracks", use_svd_to_cdc_ckf=
False,
811 prune_temporary_tracks=prune_temporary_tracks)
812 temporary_reco_track_list.append(ecl_cdc_reco_tracks)
813 temporary_reco_track_list.append(
'ECLSVDRecoTracks')
815 if prune_temporary_tracks:
816 for temporary_reco_track_name
in temporary_reco_track_list:
817 if temporary_reco_track_name != output_reco_tracks:
818 path.add_module(
'PruneRecoTracks', storeArrayName=temporary_reco_track_name)
821 def add_cdc_cr_track_finding(path, output_reco_tracks="RecoTracks", trigger_point=(0, 0, 0), merge_tracks=
True,
822 use_second_cdc_hits=
False):
824 Convenience function for adding all cdc track finder modules currently dedicated for the CDC-TOP testbeam
827 The result is a StoreArray with name @param reco_tracks full of RecoTracks (not TrackCands any more!).
832 The path to be filled
833 output_reco_tracks: str
834 Name of the output RecoTracks. Defaults to RecoTracks.
836 The upper and lower half of the tracks should be merged together in one track
837 use_second_hits: bool
838 If true, the second hit information will be used in the CDC track finding.
842 path.add_module(
"TFCDC_WireHitPreparer",
843 useSecondHits=use_second_cdc_hits,
844 flightTimeEstimation=
"downwards",
845 filter=
"cuts_from_DB",
846 triggerPoint=trigger_point)
849 path.add_module(
"TFCDC_ClusterPreparer",
850 ClusterFilter=
"mva_bkg",
851 ClusterFilterParameters={
'DBPayloadName':
'trackfindingcdc_ClusterFilterParameters'})
854 path.add_module(
"TFCDC_SegmentFinderFacetAutomaton",
855 SegmentOrientation=
"downwards")
858 path.add_module(
"TFCDC_AxialTrackFinderLegendre")
861 path.add_module(
"TFCDC_TrackQualityAsserter",
865 path.add_module(
'TFCDC_StereoHitFinder')
868 path.add_module(
'TFCDC_SegmentTrackCombiner',
869 segmentTrackFilter=
"mva",
870 segmentTrackFilterParameters={
'DBPayloadName':
'trackfindingcdc_SegmentTrackFilterParameters'},
872 trackFilterParameters={
'DBPayloadName':
'trackfindingcdc_TrackFilterParameters'})
875 path.add_module(
"TFCDC_TrackQualityAsserter",
876 corrections=[
"LayerBreak",
"OneSuperlayer",
"Small"],
880 path.add_module(
"TFCDC_TrackOrienter",
881 inputTracks=
"CDCTrackVector",
882 tracks=
"OrientedCDCTrackVector",
883 TrackOrientation=
"downwards",
886 output_tracks =
"OrientedCDCTrackVector"
890 path.add_module(
"TFCDC_TrackLinker",
891 inputTracks=
"OrientedCDCTrackVector",
892 tracks=
"MergedCDCTrackVector",
895 output_tracks =
"MergedCDCTrackVector"
899 path.add_module(
"TFCDC_TrackFlightTimeAdjuster",
900 inputTracks=
"OrientedCDCTrackVector",
904 path.add_module(
"TFCDC_TrackExporter",
905 inputTracks=
"OrientedCDCTrackVector",
906 RecoTracksStoreArrayName=
"NonMergedRecoTracks")
909 path.add_module(
"TFCDC_TrackFlightTimeAdjuster",
910 inputTracks=output_tracks,
914 path.add_module(
"TFCDC_TrackExporter",
915 inputTracks=output_tracks,
916 RecoTracksStoreArrayName=output_reco_tracks)
919 path.add_module(
"CDCHitBasedT0Extraction")
922 def add_vxd_track_finding_vxdtf2(
925 reco_tracks="RecoTracks",
926 nameSPTCs='SPTrackCands',
929 useTwoStepSelection=True,
932 custom_setup_name=None,
934 filter_overlapping=True,
935 add_mva_quality_indicator=False,
938 Convenience function for adding all vxd track finder Version 2 modules
941 The result is a StoreArray with name @param reco_tracks full of RecoTracks (not TrackCands any more!).
942 Use the GenfitTrackCandidatesCreator Module to convert back.
944 :param path: basf2 path
945 :param svd_clusters: SVDCluster collection name
946 :param reco_tracks: Name of the output RecoTracks, Defaults to RecoTracks.
947 :param nameSPTCs: Name of the SpacePointTrackCands StoreArray
948 :param components: List of the detector components to be used in the reconstruction. Defaults to None which means
950 :param suffix: all names of intermediate Storearrays will have the suffix appended. Useful in cases someone needs to
951 put several instances of track finding in one path.
952 :param useTwoStepSelection: if True Families will be defined during path creation and will be used to create only
953 the best candidate per family.
954 :param PXDminSVDSPs: When using PXD require at least this number of SVD SPs for the SPTCs
955 :param sectormap_file: if set to a finite value, a file will be used instead of the sectormap in the database.
956 :param custom_setup_name: Set a custom setup name for the tree in the sector map.
957 :param min_SPTC_quality: minimal qualityIndicator value to keeps SPTCs after the QualityEstimation.
958 0 means no cut. Default: 0
959 :param filter_overlapping: Whether to use SVDOverlapResolver, Default: True
960 :param add_mva_quality_indicator: Whether to use the MVA Quality Estimator module for VXDTF2 tracks to set the
961 quality_indicator property of the found ``reco_tracks``. Default: False.
968 if is_pxd_used(components):
969 setup_name =
"SVDPXDDefault"
970 db_sec_map_file =
"VXDSectorMap_v000.root"
973 setup_name =
"SVDOnlyDefault"
974 db_sec_map_file =
"SVDSectorMap_v000.root"
983 nameTrackingInfoModule =
"RegisterEventLevelTrackingInfo" + suffix
984 nameEventTrackingInfo =
"EventLevelTrackingInfo" + suffix
985 if nameTrackingInfoModule
not in path:
987 registerEventlevelTrackingInfo = register_module(
'RegisterEventLevelTrackingInfo')
988 registerEventlevelTrackingInfo.set_name(nameTrackingInfoModule)
989 registerEventlevelTrackingInfo.param(
'EventLevelTrackingInfoName', nameEventTrackingInfo)
990 path.add_module(registerEventlevelTrackingInfo)
992 nameSPs =
'SpacePoints' + suffix
994 pxdSPCreatorName =
'PXDSpacePointCreator' + suffix
995 if pxdSPCreatorName
not in [e.name()
for e
in path.modules()]:
997 spCreatorPXD = register_module(
'PXDSpacePointCreator')
998 spCreatorPXD.set_name(pxdSPCreatorName)
999 spCreatorPXD.param(
'NameOfInstance',
'PXDSpacePoints')
1000 spCreatorPXD.param(
'SpacePoints',
"PXD" + nameSPs)
1001 path.add_module(spCreatorPXD)
1004 secMapBootStrap = register_module(
'SectorMapBootstrap')
1005 secMapBootStrap.param(
'ReadSectorMap', sectormap_file
is not None)
1006 secMapBootStrap.param(
'ReadSecMapFromDB', sectormap_file
is None)
1007 secMapBootStrap.param(
'SectorMapsInputFile', sectormap_file
or db_sec_map_file)
1008 secMapBootStrap.param(
'SetupToRead', custom_setup_name
or setup_name)
1009 secMapBootStrap.param(
'WriteSectorMap',
False)
1010 path.add_module(secMapBootStrap)
1017 spacePointArrayNames = [
"SVD" + nameSPs]
1019 spacePointArrayNames += [
"PXD" + nameSPs]
1021 nameSegNet =
'SegmentNetwork' + suffix
1023 segNetProducer = register_module(
'SegmentNetworkProducer')
1024 segNetProducer.param(
'NetworkOutputName', nameSegNet)
1025 segNetProducer.param(
'SpacePointsArrayNames', spacePointArrayNames)
1026 segNetProducer.param(
'sectorMapName', custom_setup_name
or setup_name)
1027 segNetProducer.param(
'EventLevelTrackingInfoName', nameEventTrackingInfo)
1028 path.add_module(segNetProducer)
1038 trackFinder = register_module(
'TrackFinderVXDCellOMat')
1039 trackFinder.param(
'NetworkName', nameSegNet)
1040 trackFinder.param(
'SpacePointTrackCandArrayName', nameSPTCs)
1041 trackFinder.param(
'printNetworks',
False)
1042 trackFinder.param(
'setFamilies', useTwoStepSelection)
1043 trackFinder.param(
'selectBestPerFamily', useTwoStepSelection)
1044 trackFinder.param(
'xBestPerFamily', 30)
1045 trackFinder.param(
'EventLevelTrackingInfoName', nameEventTrackingInfo)
1046 path.add_module(trackFinder)
1048 if useTwoStepSelection:
1049 subSetModule = register_module(
'AddVXDTrackCandidateSubSets')
1050 subSetModule.param(
'NameSpacePointTrackCands', nameSPTCs)
1051 path.add_module(subSetModule)
1060 pxdSVDCut = register_module(
'PXDSVDCut')
1061 pxdSVDCut.param(
'minSVDSPs', PXDminSVDSPs)
1062 pxdSVDCut.param(
'SpacePointTrackCandsStoreArrayName', nameSPTCs)
1063 path.add_module(pxdSVDCut)
1065 if add_mva_quality_indicator:
1067 "VXDQualityEstimatorMVA",
1068 SpacePointTrackCandsStoreArrayName=nameSPTCs,
1072 'QualityEstimatorVXD',
1073 EstimationMethod=
'tripletFit',
1074 SpacePointTrackCandsStoreArrayName=nameSPTCs,
1077 if min_SPTC_quality > 0.:
1078 qualityIndicatorCutter = register_module(
'VXDTrackCandidatesQualityIndicatorCutter')
1079 qualityIndicatorCutter.param(
'minRequiredQuality', min_SPTC_quality)
1080 qualityIndicatorCutter.param(
'NameSpacePointTrackCands', nameSPTCs)
1081 path.add_module(qualityIndicatorCutter)
1084 maxCandidateSelection = register_module(
'BestVXDTrackCandidatesSelector')
1085 maxCandidateSelection.param(
'NameSpacePointTrackCands', nameSPTCs)
1086 maxCandidateSelection.param(
'NewNameSpacePointTrackCands', nameSPTCs)
1087 maxCandidateSelection.param(
'SubsetCreation',
False)
1088 path.add_module(maxCandidateSelection)
1091 vIPRemover = register_module(
'SPTCvirtualIPRemover')
1092 vIPRemover.param(
'tcArrayName', nameSPTCs)
1094 vIPRemover.param(
'maxTCLengthForVIPKeeping', 0)
1095 path.add_module(vIPRemover)
1102 if filter_overlapping:
1103 overlapResolver = register_module(
'SVDOverlapResolver')
1104 overlapResolver.param(
'NameSpacePointTrackCands', nameSPTCs)
1105 overlapResolver.param(
'ResolveMethod',
'greedy')
1106 overlapResolver.param(
'NameSVDClusters', svd_clusters)
1107 path.add_module(overlapResolver)
1114 momSeedRetriever = register_module(
'SPTCmomentumSeedRetriever')
1115 momSeedRetriever.param(
'tcArrayName', nameSPTCs)
1116 path.add_module(momSeedRetriever)
1118 converter = register_module(
'SPTC2RTConverter')
1119 converter.param(
'recoTracksStoreArrayName', reco_tracks)
1120 converter.param(
'spacePointsTCsStoreArrayName', nameSPTCs)
1121 converter.param(
'svdClustersName', svd_clusters)
1122 converter.param(
'svdHitsStoreArrayName', svd_clusters)
1123 path.add_module(converter)
1126 def add_svd_hough_tracking(path,
1127 svd_space_points='SVDSpacePoints',
1128 svd_clusters='SVDClusters',
1129 reco_tracks='RecoTracks',
1130 svd_space_point_track_candidates='SPTrackCands',
1133 Convenience function to add the SVDHoughTracking to the path.
1134 :param path: The path to add the SVDHoughTracking module to.
1135 :param svd_space_points: Name of the StoreArray containing the SVDSpacePoints
1136 :param svd_clusters: Name of the StoreArray containing the SVDClusters
1137 :param reco_tracks: Name of the StoreArray containing the RecoTracks
1138 :param svd_space_point_track_candidates: Name of the StoreArray containing the SpacePointTrackCandidates
1139 :param suffix: all names of intermediate StoreArrays will have the suffix appended. Useful in cases someone needs to
1140 put several instances of track finding in one path.
1143 path.add_module(
'SVDHoughTracking',
1144 SVDSpacePointStoreArrayName=svd_space_points + suffix,
1145 SVDClustersStoreArrayName=svd_clusters + suffix,
1146 finalOverlapResolverNameSVDClusters=svd_clusters + suffix,
1147 refinerOverlapResolverNameSVDClusters=svd_clusters + suffix,
1148 RecoTracksStoreArrayName=reco_tracks + suffix,
1149 SVDSpacePointTrackCandsStoreArrayName=svd_space_point_track_candidates + suffix,
1150 relationFilter=
'angleAndTime',
1151 twoHitUseNBestHits=4,
1152 threeHitUseNBestHits=3,
1153 fourHitUseNBestHits=3,
1154 fiveHitUseNBestHits=2,
1158 def is_svd_used(components):
1159 """Return true, if the SVD is present in the components list"""
1160 return components
is None or 'SVD' in components
1163 def is_pxd_used(components):
1164 """Return true, if the PXD is present in the components list"""
1165 return components
is None or 'PXD' in components
1168 def is_cdc_used(components):
1169 """Return true, if the CDC is present in the components list"""
1170 return components
is None or 'CDC' in components
1173 def is_ecl_used(components):
1174 """Return true, if the ECL is present in the components list"""
1175 return components
is None or 'ECL' in components