9 from pybasf2
import B2WARNING
11 from basf2
import register_module
12 from ckf.path_functions import add_pxd_ckf, add_ckf_based_merger, add_svd_ckf, add_cosmics_svd_ckf, add_cosmics_pxd_ckf
13 from pxd
import add_pxd_reconstruction
14 from svd
import add_svd_reconstruction
18 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):
55 Helper fucntion to prepare the hit information to be used by tracking.
59 if is_svd_used(components):
60 add_svd_reconstruction(path)
63 if is_pxd_used(components):
64 add_pxd_reconstruction(path)
67 def add_track_fit_and_track_creator(path, components=None, pruneTracks=False, trackFitHypotheses=None,
68 reco_tracks="RecoTracks", add_mva_quality_indicator=False):
70 Helper function to add the modules performing the
71 track fit, the V0 fit and the Belle2 track creation to the path.
73 :param path: The path to add the tracking reconstruction modules to
74 :param components: the list of geometry components in use or None for all components.
75 :param pruneTracks: Delete all hits expect the first and the last from the found tracks.
76 :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
77 :param add_mva_quality_indicator: If true, add the MVA track quality estimation
78 to the path that sets the quality indicator property of the found tracks.
81 add_prefilter_track_fit_and_track_creator(path,
82 trackFitHypotheses=trackFitHypotheses,
83 reco_tracks=reco_tracks,
84 add_mva_quality_indicator=add_mva_quality_indicator)
86 add_postfilter_track_fit(path, components=components, pruneTracks=pruneTracks, reco_tracks=reco_tracks)
89 def add_prefilter_track_fit_and_track_creator(path, trackFitHypotheses=None,
90 reco_tracks="RecoTracks", add_mva_quality_indicator=False):
92 Helper function to add only the modules required to calculate HLT filter decision:
93 performing the track fit and the Belle2 track creation to the path.
95 :param path: The path to add the tracking reconstruction modules to
96 :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
97 :param add_mva_quality_indicator: If true, add the MVA track quality estimation
98 to the path that sets the quality indicator property of the found tracks.
102 path.add_module(
"IPTrackTimeEstimator",
103 recoTracksStoreArrayName=reco_tracks, useFittedInformation=
False)
105 path.add_module(
"DAFRecoFitter", recoTracksStoreArrayName=reco_tracks).set_name(
106 "Combined_DAFRecoFitter")
109 if add_mva_quality_indicator:
110 path.add_module(
"TrackQualityEstimatorMVA", collectEventFeatures=
True)
118 path.add_module(
'TrackCreator', recoTrackColName=reco_tracks,
119 pdgCodes=[211, 321, 2212]
if not trackFitHypotheses
else trackFitHypotheses)
122 def add_postfilter_track_fit(path, components=None, pruneTracks=False, reco_tracks="RecoTracks"):
124 Helper function to add the modules not requred to calcualte HLT filter decision: performing
125 the V0 fit to the path.
127 :param path: The path to add the tracking reconstruction modules to
128 :param components: the list of geometry components in use or None for all components.
129 :param pruneTracks: Delete all hits expect the first and the last from the found tracks.
130 :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
134 path.add_module(
'V0Finder', RecoTracks=reco_tracks, v0FitterMode=1)
138 add_prune_tracks(path, components=components, reco_tracks=reco_tracks)
141 def add_cr_track_fit_and_track_creator(path, components=None,
142 prune_tracks=False, event_timing_extraction=True,
143 reco_tracks="RecoTracks", tracks=""):
145 Helper function to add the modules performing the cdc cr track fit
146 and track creation to the path.
148 :param path: The path to which to add the tracking reconstruction modules
149 :param components: the list of geometry components in use or None for all components.
150 :param reco_tracks: The name of the reco tracks to use
151 :param tracks: the name of the output Belle tracks
152 :param prune_tracks: Delete all hits expect the first and the last from the found tracks.
153 :param event_timing_extraction: extract the event time
157 path.add_module(
"PlaneTriggerTrackTimeEstimator",
158 recoTracksStoreArrayName=reco_tracks,
159 pdgCodeToUseForEstimation=13,
160 triggerPlanePosition=[0., 0., 0.],
161 triggerPlaneDirection=[0., 1., 0.],
162 useFittedInformation=
False)
165 path.add_module(
"DAFRecoFitter",
166 recoTracksStoreArrayName=reco_tracks,
168 pdgCodesToUseForFitting=13)
171 path.add_module(
"PlaneTriggerTrackTimeEstimator",
172 recoTracksStoreArrayName=reco_tracks,
173 pdgCodeToUseForEstimation=13,
174 triggerPlanePosition=[0., 0., 0.],
175 triggerPlaneDirection=[0., 1., 0.],
176 useFittedInformation=
True)
179 path.add_module(
"DAFRecoFitter",
180 recoTracksStoreArrayName=reco_tracks,
181 pdgCodesToUseForFitting=13
184 if event_timing_extraction:
186 path.add_module(
"FullGridChi2TrackTimeExtractor",
187 RecoTracksStoreArrayName=reco_tracks,
188 GridMaximalT0Value=40,
189 GridMinimalT0Value=-40,
194 path.add_module(
"DAFRecoFitter",
196 recoTracksStoreArrayName=reco_tracks,
197 pdgCodesToUseForFitting=13
201 path.add_module(
'TrackCreator',
203 recoTrackColName=reco_tracks,
205 useClosestHitToIP=
True,
211 add_prune_tracks(path=path, components=components,
212 reco_tracks=reco_tracks)
215 def add_mc_matcher(path, components=None, mc_reco_tracks="MCRecoTracks",
216 reco_tracks="RecoTracks", use_second_cdc_hits=False,
217 split_after_delta_t=-1.0):
219 Match the tracks to the MC truth. The matching works based on
220 the output of the TrackFinderMCTruthRecoTracks.
222 :param path: The path to add the tracking reconstruction modules to
223 :param components: the list of geometry components in use or None for all components.
224 :param mc_reco_tracks: Name of the StoreArray where the mc reco tracks will be stored
225 :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
226 :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
227 :param split_after_delta_t: If positive, split MCRecoTrack into multiple MCRecoTracks if the time
228 distance between two adjecent SimHits is more than the given value
230 path.add_module(
'TrackFinderMCTruthRecoTracks',
231 RecoTracksStoreArrayName=mc_reco_tracks,
233 UseSecondCDCHits=use_second_cdc_hits,
234 UsePXDHits=is_pxd_used(components),
235 UseSVDHits=is_svd_used(components),
236 UseCDCHits=is_cdc_used(components),
237 SplitAfterDeltaT=split_after_delta_t)
239 path.add_module(
'MCRecoTracksMatcher',
240 mcRecoTracksStoreArrayName=mc_reco_tracks,
241 prRecoTracksStoreArrayName=reco_tracks,
242 UsePXDHits=is_pxd_used(components),
243 UseSVDHits=is_svd_used(components),
244 UseCDCHits=is_cdc_used(components))
247 def add_prune_tracks(path, components=None, reco_tracks="RecoTracks"):
249 Adds removal of the intermediate states at each measurement from the fitted tracks.
251 :param path: The path to add the tracking reconstruction modules to
252 :param components: the list of geometry components in use or None for all components.
253 :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
257 if components
and not (
'SVD' in components
or 'CDC' in components):
260 path.add_module(
'PruneRecoTracks', storeArrayName=reco_tracks)
261 path.add_module(
"PruneGenfitTracks")
264 def add_pxd_track_finding(path, components, input_reco_tracks, output_reco_tracks, use_mc_truth=False,
265 add_both_directions=False, temporary_reco_tracks="PXDRecoTracks", **kwargs):
266 """Add the pxd track finding to the path"""
267 if not is_pxd_used(components):
272 path.add_module(
"MCRecoTracksMatcher", UsePXDHits=
False,
273 UseSVDHits=is_svd_used(components), UseCDCHits=is_cdc_used(components),
274 mcRecoTracksStoreArrayName=
"MCRecoTracks",
275 prRecoTracksStoreArrayName=input_reco_tracks)
277 add_pxd_ckf(path, svd_cdc_reco_tracks=input_reco_tracks, pxd_reco_tracks=temporary_reco_tracks,
278 direction=
"backward", use_mc_truth=use_mc_truth, **kwargs)
280 if add_both_directions:
281 add_pxd_ckf(path, svd_cdc_reco_tracks=input_reco_tracks, pxd_reco_tracks=temporary_reco_tracks,
282 direction=
"forward", use_mc_truth=use_mc_truth, **kwargs)
284 path.add_module(
"RelatedTracksCombiner", CDCRecoTracksStoreArrayName=input_reco_tracks,
285 VXDRecoTracksStoreArrayName=temporary_reco_tracks, recoTracksStoreArrayName=output_reco_tracks)
288 def add_pxd_cr_track_finding(path, components, input_reco_tracks, output_reco_tracks, use_mc_truth=False,
289 add_both_directions=False, temporary_reco_tracks="PXDRecoTracks", **kwargs):
290 """Add the pxd track finding to the path"""
291 if not is_pxd_used(components):
296 path.add_module(
"MCRecoTracksMatcher", UsePXDHits=
False,
297 UseSVDHits=is_svd_used(components), UseCDCHits=is_cdc_used(components),
298 mcRecoTracksStoreArrayName=
"MCRecoTracks",
299 prRecoTracksStoreArrayName=input_reco_tracks)
301 add_cosmics_pxd_ckf(path, svd_cdc_reco_tracks=input_reco_tracks, pxd_reco_tracks=temporary_reco_tracks,
302 direction=
"backward", use_mc_truth=use_mc_truth, **kwargs)
304 if add_both_directions:
305 add_cosmics_pxd_ckf(path, svd_cdc_reco_tracks=input_reco_tracks, pxd_reco_tracks=temporary_reco_tracks,
306 direction=
"forward", use_mc_truth=use_mc_truth, **kwargs)
308 path.add_module(
"RelatedTracksCombiner", CDCRecoTracksStoreArrayName=input_reco_tracks,
309 VXDRecoTracksStoreArrayName=temporary_reco_tracks, recoTracksStoreArrayName=output_reco_tracks)
312 def add_svd_track_finding(
317 svd_ckf_mode="VXDTF2_after",
319 add_both_directions=True,
320 temporary_reco_tracks="SVDRecoTracks",
321 temporary_svd_cdc_reco_tracks="SVDPlusCDCStandaloneRecoTracks",
322 use_svd_to_cdc_ckf=True,
323 prune_temporary_tracks=True,
324 add_mva_quality_indicator=False,
328 Add SVD track finding to the path.
330 :param path: The path to add the tracking reconstruction modules to
331 :param components: The list of geometry components in use or None for all components.
332 :param input_reco_tracks: Name of the StoreArray with the input reco tracks (usually from CDC) that are used in the
333 CKF track finding and are merged with the newly found SVD tracks into the ``output_reco_tracks``.
334 :param output_reco_tracks: Name of the StoreArray where the reco tracks outputted by the SVD track finding should be
336 :param svd_ckf_mode: String designating the mode of the CDC-to-SVD CKF, that is how it is combined with the VXDTF2
337 standalone track finding. One of "VXDTF2_after", "VXDTF2_before", "VXDTF2_before_with_second_ckf",
338 "only_ckf", "VXDTF2_alone", "cosmics".
339 :param use_mc_truth: Add mc matching and use the MC information in the CKF (but not in the VXDTF2)
340 :param add_both_directions: Whether to add the CKF with both forward and backward extrapolation directions instead
342 :param temporary_reco_tracks: Intermediate store array where the SVD tracks from the VXDTF2 standalone track finding
343 are stored, before they are merged with CDC tracks and extended via the CKF tracking.
344 :param temporary_svd_cdc_reco_tracks: Intermediate store array where the combination of ``temporary_reco_tracks``
345 (from SVD) and ``input_reco_tracks`` (from CDC standalone) is stored, before the CKF is applied.
346 It is only used if ``use_svd_to_cdc_ckf`` is true. Otherwise, the combination is stored directly in
347 ``output_reco_tracks``.
348 :param use_svd_to_cdc_ckf: Whether to enable the CKF extrapolation from the SVD into the CDC.
349 That CKF application is not affected by ``svd_ckf_mode``.
350 :param prune_temporary_tracks: Delete all hits expect the first and last from intermediate track objects.
351 :param add_mva_quality_indicator: Add the VVXDQualityEstimatorMVA module to set the quality indicator
352 property for tracks from VXDTF2 standalone tracking
353 (ATTENTION: Standard triplet QI of VXDTF2 is replaced in this case
354 -> setting this option to 'True' will have some influence on the final track collection)
357 if not is_svd_used(components):
360 if not input_reco_tracks:
362 add_vxd_track_finding_vxdtf2(path, components=[
"SVD"], reco_tracks=output_reco_tracks,
363 add_mva_quality_indicator=add_mva_quality_indicator)
368 path.add_module(
"MCRecoTracksMatcher", UsePXDHits=
False, UseSVDHits=
False,
369 UseCDCHits=is_cdc_used(components),
370 mcRecoTracksStoreArrayName=
"MCRecoTracks",
371 prRecoTracksStoreArrayName=input_reco_tracks)
373 if svd_ckf_mode ==
"VXDTF2_before":
374 add_vxd_track_finding_vxdtf2(path, components=[
"SVD"], reco_tracks=temporary_reco_tracks,
375 add_mva_quality_indicator=add_mva_quality_indicator)
376 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
377 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
378 if add_both_directions:
379 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
380 use_mc_truth=use_mc_truth, direction=
"forward", **kwargs)
382 elif svd_ckf_mode ==
"VXDTF2_before_with_second_ckf":
383 add_vxd_track_finding_vxdtf2(path, components=[
"SVD"], reco_tracks=temporary_reco_tracks,
384 add_mva_quality_indicator=add_mva_quality_indicator)
385 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
386 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
387 if add_both_directions:
388 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
389 use_mc_truth=use_mc_truth, direction=
"forward", **kwargs)
390 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
391 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
392 if add_both_directions:
393 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
394 use_mc_truth=use_mc_truth, direction=
"forward", filter_cut=0.01, **kwargs)
396 elif svd_ckf_mode ==
"only_ckf":
397 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
398 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
399 if add_both_directions:
400 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
401 use_mc_truth=use_mc_truth, direction=
"forward", filter_cut=0.01, **kwargs)
403 elif svd_ckf_mode ==
"VXDTF2_after":
404 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
405 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
406 if add_both_directions:
407 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
408 use_mc_truth=use_mc_truth, direction=
"forward", filter_cut=0.01, **kwargs)
410 add_vxd_track_finding_vxdtf2(path, components=[
"SVD"], reco_tracks=temporary_reco_tracks,
411 add_mva_quality_indicator=add_mva_quality_indicator)
412 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
413 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
414 if add_both_directions:
415 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
416 use_mc_truth=use_mc_truth, direction=
"forward", **kwargs)
418 elif svd_ckf_mode ==
"VXDTF2_alone":
419 add_vxd_track_finding_vxdtf2(path, components=[
"SVD"], reco_tracks=temporary_reco_tracks,
420 add_mva_quality_indicator=add_mva_quality_indicator)
421 path.add_module(
'VXDCDCTrackMerger',
422 CDCRecoTrackColName=input_reco_tracks,
423 VXDRecoTrackColName=temporary_reco_tracks)
425 elif svd_ckf_mode ==
"cosmics":
426 add_cosmics_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
427 use_mc_truth=use_mc_truth, direction=
"backward", **kwargs)
428 if add_both_directions:
429 add_cosmics_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
430 use_mc_truth=use_mc_truth, direction=
"forward", **kwargs)
433 raise ValueError(f
"Do not understand the svd_ckf_mode {svd_ckf_mode}")
435 if use_svd_to_cdc_ckf:
436 combined_svd_cdc_standalone_tracks = temporary_svd_cdc_reco_tracks
438 combined_svd_cdc_standalone_tracks = output_reco_tracks
441 path.add_module(
"RelatedTracksCombiner", VXDRecoTracksStoreArrayName=temporary_reco_tracks,
442 CDCRecoTracksStoreArrayName=input_reco_tracks,
443 recoTracksStoreArrayName=combined_svd_cdc_standalone_tracks)
445 if use_svd_to_cdc_ckf:
446 path.add_module(
"ToCDCCKF",
447 inputWireHits=
"CDCWireHitVector",
448 inputRecoTrackStoreArrayName=combined_svd_cdc_standalone_tracks,
449 relatedRecoTrackStoreArrayName=
"CKFCDCRecoTracks",
450 relationCheckForDirection=
"backward",
451 ignoreTracksWithCDChits=
True,
452 outputRecoTrackStoreArrayName=
"CKFCDCRecoTracks",
453 outputRelationRecoTrackStoreArrayName=combined_svd_cdc_standalone_tracks,
454 writeOutDirection=
"backward",
455 stateBasicFilterParameters={
"maximalHitDistance": 0.15},
456 pathFilter=
"arc_length",
459 path.add_module(
"CDCCKFTracksCombiner",
460 CDCRecoTracksStoreArrayName=
"CKFCDCRecoTracks",
461 VXDRecoTracksStoreArrayName=combined_svd_cdc_standalone_tracks,
462 recoTracksStoreArrayName=output_reco_tracks)
464 if prune_temporary_tracks:
465 for temp_reco_track
in [combined_svd_cdc_standalone_tracks,
"CKFCDCRecoTracks"]:
466 path.add_module(
'PruneRecoTracks', storeArrayName=temp_reco_track)
469 def add_cdc_track_finding(path, output_reco_tracks="RecoTracks", with_ca=False,
470 use_second_hits=False, add_mva_quality_indicator=True,
471 reattach_hits=False):
473 Convenience function for adding all cdc track finder modules
476 The result is a StoreArray with name @param reco_tracks full of RecoTracks (not TrackCands any more!).
477 Use the GenfitTrackCandidatesCreator Module to convert back.
479 :param path: basf2 path
480 :param output_reco_tracks: Name of the output RecoTracks. Defaults to RecoTracks.
481 :param use_second_hits: If true, the second hit information will be used in the CDC track finding.
482 :param add_mva_quality_indicator: Add the TFCDC_TrackQualityEstimator module to set the CDC quality
483 indicator property of the CDC ``output_reco_tracks``
484 :param cdc_quality_estimator_weightfile: Weightfile identifier for the TFCDC_TrackQualityEstimator
485 :param reattach_hits: if true, use the ReattachCDCWireHitsToRecoTracks module at the end of the CDC track finding
486 to readd hits with bad ADC or TOT rejected by the TFCDC_WireHitPreparer module.
489 if 'RegisterEventLevelTrackingInfo' not in path:
490 path.add_module(
'RegisterEventLevelTrackingInfo')
493 path.add_module(
"TFCDC_WireHitPreparer",
494 wirePosition=
"aligned",
495 useSecondHits=use_second_hits,
496 flightTimeEstimation=
"outwards",
497 filter=
"cuts_from_DB")
500 path.add_module(
"TFCDC_ClusterPreparer",
502 ClusterFilterParameters={})
505 path.add_module(
"TFCDC_SegmentFinderFacetAutomaton")
508 path.add_module(
"TFCDC_AxialTrackFinderLegendre")
511 path.add_module(
"TFCDC_TrackQualityAsserter",
515 path.add_module(
'TFCDC_StereoHitFinder')
518 path.add_module(
'TFCDC_SegmentTrackCombiner',
519 segmentTrackFilter=
"mva",
520 segmentTrackFilterParameters={
"cut": 0.74},
522 trackFilterParameters={
"cut": 0.1})
524 output_tracks =
"CDCTrackVector"
527 output_tracks =
"CombinedCDCTrackVector"
528 path.add_module(
"TFCDC_TrackFinderSegmentPairAutomaton",
529 tracks=
"CDCTrackVector2")
532 path.add_module(
"TFCDC_TrackCombiner",
533 inputTracks=
"CDCTrackVector",
534 secondaryInputTracks=
"CDCTrackVector2",
535 tracks=output_tracks)
538 path.add_module(
"TFCDC_TrackQualityAsserter",
539 inputTracks=output_tracks,
548 path.add_module(
"TFCDC_TrackCreatorSingleSegments",
549 inputTracks=output_tracks,
550 MinimalHitsBySuperLayerId={0: 15})
552 if add_mva_quality_indicator:
555 "TFCDC_TrackQualityEstimator",
556 inputTracks=output_tracks,
558 filterParameters={
"cut": 0.7},
564 path.add_module(
"TFCDC_TrackExporter",
565 inputTracks=output_tracks,
566 RecoTracksStoreArrayName=
"CDCRecoTracksBeforeReattaching" if reattach_hits
else output_reco_tracks)
570 if 'SetupGenfitExtrapolation' not in path:
572 path.add_module(
'SetupGenfitExtrapolation')
575 path.add_module(
"ReattachCDCWireHitsToRecoTracks",
576 inputRecoTracksStoreArrayName=
"CDCRecoTracksBeforeReattaching",
577 outputRecoTracksStoreArrayName=output_reco_tracks)
580 path.add_module(
"IPTrackTimeEstimator",
581 useFittedInformation=
False,
582 recoTracksStoreArrayName=output_reco_tracks)
585 path.add_module(
"CDCHitBasedT0Extraction")
588 path.add_module(
"CDCTrackingEventLevelMdstInfoFiller")
591 def add_eclcdc_track_finding(path, components, output_reco_tracks="RecoTracks", prune_temporary_tracks=True):
593 Convenience function for adding all track finder modules to the path that are based on ecl seeds.
595 The result is a StoreArray with name @param reco_tracks full of RecoTracks.
596 Use the GenfitTrackCandidatesCreator Module to convert back.
598 :param path: basf2 path
599 :param components: the list of geometry components in use or None for all components.
600 :param output_reco_tracks: Name of the output RecoTracks. Defaults to RecoTracks.
601 :param pruneTracks: Delete all hits expect the first and the last from the found tracks.
603 if not is_cdc_used(components)
or not is_ecl_used(components):
606 ecl_cdc_reco_tracks =
"ECLCDCRecoTracks"
608 if not is_svd_used(components):
609 ecl_cdc_reco_tracks = output_reco_tracks
612 temporary_reco_track_list = []
614 path.add_module(
"ToCDCFromEclCKF",
615 inputWireHits=
"CDCWireHitVector",
616 minimalEnRequirementCluster=0.3,
617 eclSeedRecoTrackStoreArrayName=
'EclSeedRecoTracks',
618 hitFindingDirection=
"backward",
619 outputRecoTrackStoreArrayName=
"CDCRecoTracksFromEcl",
620 outputRelationRecoTrackStoreArrayName=
"EclSeedRecoTracks",
621 writeOutDirection=
"forward",
622 stateBasicFilterParameters={
"maximalHitDistance": 7.5,
"maximalHitDistanceEclSeed": 75.0},
623 stateExtrapolationFilterParameters={
"direction":
"backward"},
624 pathFilter=
"arc_length_fromEcl",
625 inputECLshowersStoreArrayName=
"ECLShowers",
626 trackFindingDirection=
"backward",
631 path.add_module(
"ToCDCCKF",
632 inputWireHits=
"CDCWireHitVector",
633 inputRecoTrackStoreArrayName=
"CDCRecoTracksFromEcl",
634 relatedRecoTrackStoreArrayName=ecl_cdc_reco_tracks,
635 relationCheckForDirection=
"backward",
636 outputRecoTrackStoreArrayName=ecl_cdc_reco_tracks,
637 outputRelationRecoTrackStoreArrayName=
"CDCRecoTracksFromEcl",
638 writeOutDirection=
"backward",
639 stateBasicFilterParameters={
"maximalHitDistance": 0.75},
640 stateExtrapolationFilterParameters={
"direction":
"forward"},
641 pathFilter=
"arc_length",
645 temporary_reco_track_list.append(
'CDCRecoTracksFromEcl')
662 if is_svd_used(components):
663 add_svd_track_finding(path, components=components, input_reco_tracks=ecl_cdc_reco_tracks,
664 output_reco_tracks=output_reco_tracks, use_mc_truth=
False,
665 svd_ckf_mode=
"only_ckf", add_both_directions=
False,
666 temporary_reco_tracks=
"ECLSVDRecoTracks", use_svd_to_cdc_ckf=
False,
667 prune_temporary_tracks=prune_temporary_tracks)
668 temporary_reco_track_list.append(ecl_cdc_reco_tracks)
669 temporary_reco_track_list.append(
'ECLSVDRecoTracks')
671 if prune_temporary_tracks:
672 for temporary_reco_track_name
in temporary_reco_track_list:
673 if temporary_reco_track_name != output_reco_tracks:
674 path.add_module(
'PruneRecoTracks', storeArrayName=temporary_reco_track_name)
677 def add_cdc_cr_track_finding(path, output_reco_tracks="RecoTracks", trigger_point=(0, 0, 0), merge_tracks=
True,
678 use_second_cdc_hits=
False):
680 Convenience function for adding all cdc track finder modules currently dedicated for the CDC-TOP testbeam
683 The result is a StoreArray with name @param reco_tracks full of RecoTracks (not TrackCands any more!).
688 The path to be filled
689 output_reco_tracks: str
690 Name of the output RecoTracks. Defaults to RecoTracks.
692 The upper and lower half of the tracks should be merged together in one track
693 use_second_hits: bool
694 If true, the second hit information will be used in the CDC track finding.
698 path.add_module(
"TFCDC_WireHitPreparer",
699 useSecondHits=use_second_cdc_hits,
700 flightTimeEstimation=
"downwards",
701 filter=
"cuts_from_DB",
702 triggerPoint=trigger_point)
705 path.add_module(
"TFCDC_ClusterPreparer",
706 ClusterFilter=
"mva_bkg",
707 ClusterFilterParameters={
"cut": 0.2})
710 path.add_module(
"TFCDC_SegmentFinderFacetAutomaton",
711 SegmentOrientation=
"downwards")
714 path.add_module(
"TFCDC_AxialTrackFinderLegendre")
717 path.add_module(
"TFCDC_TrackQualityAsserter",
721 path.add_module(
'TFCDC_StereoHitFinder')
724 path.add_module(
'TFCDC_SegmentTrackCombiner',
725 segmentTrackFilter=
"mva",
726 segmentTrackFilterParameters={
"cut": 0.74},
728 trackFilterParameters={
"cut": 0.1})
731 path.add_module(
"TFCDC_TrackQualityAsserter",
732 corrections=[
"LayerBreak",
"OneSuperlayer",
"Small"],
736 path.add_module(
"TFCDC_TrackOrienter",
737 inputTracks=
"CDCTrackVector",
738 tracks=
"OrientedCDCTrackVector",
739 TrackOrientation=
"downwards",
742 output_tracks =
"OrientedCDCTrackVector"
746 path.add_module(
"TFCDC_TrackLinker",
747 inputTracks=
"OrientedCDCTrackVector",
748 tracks=
"MergedCDCTrackVector",
751 output_tracks =
"MergedCDCTrackVector"
755 path.add_module(
"TFCDC_TrackFlightTimeAdjuster",
756 inputTracks=
"OrientedCDCTrackVector",
760 path.add_module(
"TFCDC_TrackExporter",
761 inputTracks=
"OrientedCDCTrackVector",
762 RecoTracksStoreArrayName=
"NonMergedRecoTracks")
765 path.add_module(
"TFCDC_TrackFlightTimeAdjuster",
766 inputTracks=output_tracks,
770 path.add_module(
"TFCDC_TrackExporter",
771 inputTracks=output_tracks,
772 RecoTracksStoreArrayName=output_reco_tracks)
775 path.add_module(
"CDCHitBasedT0Extraction")
778 def add_vxd_track_finding_vxdtf2(
781 reco_tracks="RecoTracks",
784 useTwoStepSelection=True,
787 custom_setup_name=None,
789 filter_overlapping=True,
790 add_mva_quality_indicator=False,
793 Convenience function for adding all vxd track finder Version 2 modules
796 The result is a StoreArray with name @param reco_tracks full of RecoTracks (not TrackCands any more!).
797 Use the GenfitTrackCandidatesCreator Module to convert back.
799 :param path: basf2 path
800 :param svd_clusters: SVDCluster collection name
801 :param reco_tracks: Name of the output RecoTracks, Defaults to RecoTracks.
802 :param components: List of the detector components to be used in the reconstruction. Defaults to None which means
804 :param suffix: all names of intermediate Storearrays will have the suffix appended. Useful in cases someone needs to
805 put several instances of track finding in one path.
806 :param useTwoStepSelection: if True Families will be defined during path creation and will be used to create only
807 the best candidate per family.
808 :param PXDminSVDSPs: When using PXD require at least this number of SVD SPs for the SPTCs
809 :param sectormap_file: if set to a finite value, a file will be used instead of the sectormap in the database.
810 :param custom_setup_name: Set a custom setup name for the tree in the sector map.
811 :param min_SPTC_quality: minimal qualityIndicator value to keeps SPTCs after the QualityEstimation.
812 0 means no cut. Default: 0
813 :param filter_overlapping: Whether to use SVDOverlapResolver, Default: True
814 :param add_mva_quality_indicator: Whether to use the MVA Quality Estimator module for VXDTF2 tracks to set the
815 quality_indicator property of the found ``reco_tracks``. Default: False.
822 if is_pxd_used(components):
823 setup_name =
"SVDPXDDefault"
824 db_sec_map_file =
"VXDSectorMap_v000.root"
827 setup_name =
"SVDOnlyDefault"
828 db_sec_map_file =
"SVDSectorMap_v000.root"
837 nameTrackingInfoModule =
"RegisterEventLevelTrackingInfo" + suffix
838 nameEventTrackingInfo =
"EventLevelTrackingInfo" + suffix
839 if nameTrackingInfoModule
not in path:
841 registerEventlevelTrackingInfo = register_module(
'RegisterEventLevelTrackingInfo')
842 registerEventlevelTrackingInfo.set_name(nameTrackingInfoModule)
843 registerEventlevelTrackingInfo.param(
'EventLevelTrackingInfoName', nameEventTrackingInfo)
844 path.add_module(registerEventlevelTrackingInfo)
846 nameSPs =
'SpacePoints' + suffix
848 pxdSPCreatorName =
'PXDSpacePointCreator' + suffix
849 if pxdSPCreatorName
not in [e.name()
for e
in path.modules()]:
851 spCreatorPXD = register_module(
'PXDSpacePointCreator')
852 spCreatorPXD.set_name(pxdSPCreatorName)
853 spCreatorPXD.param(
'NameOfInstance',
'PXDSpacePoints')
854 spCreatorPXD.param(
'SpacePoints',
"PXD" + nameSPs)
855 path.add_module(spCreatorPXD)
858 secMapBootStrap = register_module(
'SectorMapBootstrap')
859 secMapBootStrap.param(
'ReadSectorMap', sectormap_file
is not None)
860 secMapBootStrap.param(
'ReadSecMapFromDB', sectormap_file
is None)
861 secMapBootStrap.param(
'SectorMapsInputFile', sectormap_file
or db_sec_map_file)
862 secMapBootStrap.param(
'SetupToRead', custom_setup_name
or setup_name)
863 secMapBootStrap.param(
'WriteSectorMap',
False)
864 path.add_module(secMapBootStrap)
871 spacePointArrayNames = [
"SVD" + nameSPs]
873 spacePointArrayNames += [
"PXD" + nameSPs]
875 nameSegNet =
'SegmentNetwork' + suffix
877 segNetProducer = register_module(
'SegmentNetworkProducer')
878 segNetProducer.param(
'NetworkOutputName', nameSegNet)
879 segNetProducer.param(
'SpacePointsArrayNames', spacePointArrayNames)
880 segNetProducer.param(
'sectorMapName', custom_setup_name
or setup_name)
881 segNetProducer.param(
'EventLevelTrackingInfoName', nameEventTrackingInfo)
882 path.add_module(segNetProducer)
890 nameSPTCs =
'SPTrackCands' + suffix
892 trackFinder = register_module(
'TrackFinderVXDCellOMat')
893 trackFinder.param(
'NetworkName', nameSegNet)
894 trackFinder.param(
'SpacePointTrackCandArrayName', nameSPTCs)
895 trackFinder.param(
'printNetworks',
False)
896 trackFinder.param(
'setFamilies', useTwoStepSelection)
897 trackFinder.param(
'selectBestPerFamily', useTwoStepSelection)
898 trackFinder.param(
'xBestPerFamily', 30)
899 trackFinder.param(
'EventLevelTrackingInfoName', nameEventTrackingInfo)
900 path.add_module(trackFinder)
902 if useTwoStepSelection:
903 subSetModule = register_module(
'AddVXDTrackCandidateSubSets')
904 subSetModule.param(
'NameSpacePointTrackCands', nameSPTCs)
905 path.add_module(subSetModule)
914 pxdSVDCut = register_module(
'PXDSVDCut')
915 pxdSVDCut.param(
'minSVDSPs', PXDminSVDSPs)
916 pxdSVDCut.param(
'SpacePointTrackCandsStoreArrayName', nameSPTCs)
917 path.add_module(pxdSVDCut)
919 if add_mva_quality_indicator:
921 "VXDQualityEstimatorMVA",
922 SpacePointTrackCandsStoreArrayName=nameSPTCs,
926 'QualityEstimatorVXD',
927 EstimationMethod=
'tripletFit',
928 SpacePointTrackCandsStoreArrayName=nameSPTCs,
931 if min_SPTC_quality > 0.:
932 qualityIndicatorCutter = register_module(
'VXDTrackCandidatesQualityIndicatorCutter')
933 qualityIndicatorCutter.param(
'minRequiredQuality', min_SPTC_quality)
934 qualityIndicatorCutter.param(
'NameSpacePointTrackCands', nameSPTCs)
935 path.add_module(qualityIndicatorCutter)
938 maxCandidateSelection = register_module(
'BestVXDTrackCandidatesSelector')
939 maxCandidateSelection.param(
'NameSpacePointTrackCands', nameSPTCs)
940 maxCandidateSelection.param(
'NewNameSpacePointTrackCands', nameSPTCs)
941 maxCandidateSelection.param(
'SubsetCreation',
False)
942 path.add_module(maxCandidateSelection)
945 vIPRemover = register_module(
'SPTCvirtualIPRemover')
946 vIPRemover.param(
'tcArrayName', nameSPTCs)
948 vIPRemover.param(
'maxTCLengthForVIPKeeping', 0)
949 path.add_module(vIPRemover)
956 if filter_overlapping:
957 overlapResolver = register_module(
'SVDOverlapResolver')
958 overlapResolver.param(
'NameSpacePointTrackCands', nameSPTCs)
959 overlapResolver.param(
'ResolveMethod',
'greedy')
960 overlapResolver.param(
'NameSVDClusters', svd_clusters)
961 path.add_module(overlapResolver)
968 momSeedRetriever = register_module(
'SPTCmomentumSeedRetriever')
969 momSeedRetriever.param(
'tcArrayName', nameSPTCs)
970 path.add_module(momSeedRetriever)
972 converter = register_module(
'SPTC2RTConverter')
973 converter.param(
'recoTracksStoreArrayName', reco_tracks)
974 converter.param(
'spacePointsTCsStoreArrayName', nameSPTCs)
975 converter.param(
'svdClustersName', svd_clusters)
976 converter.param(
'svdHitsStoreArrayName', svd_clusters)
977 path.add_module(converter)
980 def is_svd_used(components):
981 """Return true, if the SVD is present in the components list"""
982 return components
is None or 'SVD' in components
985 def is_pxd_used(components):
986 """Return true, if the PXD is present in the components list"""
987 return components
is None or 'PXD' in components
990 def is_cdc_used(components):
991 """Return true, if the CDC is present in the components list"""
992 return components
is None or 'CDC' in components
995 def is_ecl_used(components):
996 """Return true, if the ECL is present in the components list"""
997 return components
is None or 'ECL' in components