Belle II Software development
path_utils.py
1
2
9
10from pybasf2 import B2WARNING
11
12from basf2 import register_module
13from ckf.path_functions import add_pxd_ckf, add_ckf_based_merger, add_svd_ckf, add_cosmics_svd_ckf, add_cosmics_pxd_ckf
14from pxd import add_pxd_reconstruction
15from svd import add_svd_reconstruction
16from tracking.adjustments import adjust_module
17
18
19def 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)
23
24 :param path: The path the SectorMapBootstrapModule is in.
25 :param pathToLocalSM: the local storage position of the sectormap (including the name)
26
27 """
28 B2WARNING("Warning will load local SectorMap from: " + pathToLocalSM)
29 adjust_module(path, 'SectorMapBootstrap', **{"ReadSecMapFromDB": False,
30 "ReadSectorMap": True, "SectorMapsInputFile": pathToLocalSM})
31
32
33def add_geometry_modules(path, components=None):
34 """
35 Helper function to add the geometry related modules needed for tracking
36 to the path.
37
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.
40 """
41 # check for detector geometry, necessary for track extrapolation in genfit
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")
46
47 # Material effects for all track extrapolations
48 if 'SetupGenfitExtrapolation' not in path:
49 path.add_module('SetupGenfitExtrapolation',
50 energyLossBrems=False, noiseBrems=False)
51
52
53def add_hit_preparation_modules(path, components=None, pxd_filtering_offline=False, create_intercepts_for_pxd_ckf=False):
54 """
55 Helper function to prepare the hit information to be used by tracking.
56
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.
61 :param create_intercepts_for_pxd_ckf: If True, the PXDROIFinder is added to the path to create PXDIntercepts to be used
62 for hit filtering when creating the CKF relations. This independent of the offline PXD digit filtering which is
63 steered by 'pxd_filtering_offline'. This can be applied for both data and MC.
64 """
65
66 # Preparation of the SVD clusters
67 if is_svd_used(components):
68 add_svd_reconstruction(path)
69
70 # Preparation of the PXD clusters
71 if is_pxd_used(components) and not pxd_filtering_offline and not create_intercepts_for_pxd_ckf:
72 add_pxd_reconstruction(path)
73
74
75def add_track_fit_and_track_creator(path, components=None, pruneTracks=False, trackFitHypotheses=None,
76 reco_tracks="RecoTracks", add_mva_quality_indicator=False, v0_finding=True):
77 """
78 Helper function to add the modules performing the
79 track fit, the V0 fit and the Belle2 track creation to the path.
80
81 :param path: The path to add the tracking reconstruction modules to
82 :param components: the list of geometry components in use or None for all components.
83 :param pruneTracks: Delete all hits expect the first and the last from the found tracks.
84 :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
85 :param v0_finding: if false, the V0Finder module is not executed
86 :param add_mva_quality_indicator: If true, add the MVA track quality estimation
87 to the path that sets the quality indicator property of the found tracks.
88 """
89
90 add_prefilter_track_fit_and_track_creator(path,
91 trackFitHypotheses=trackFitHypotheses,
92 reco_tracks=reco_tracks,
93 add_mva_quality_indicator=add_mva_quality_indicator)
94
95 # V0 finding
96 if v0_finding:
97 path.add_module('V0Finder', RecoTracks=reco_tracks, v0FitterMode=1)
98
99 if pruneTracks:
100 add_prune_tracks(path, components=components, reco_tracks=reco_tracks)
101
102
103def add_prefilter_track_fit_and_track_creator(path, trackFitHypotheses=None,
104 reco_tracks="RecoTracks", add_mva_quality_indicator=False):
105 """
106 Helper function to add only the modules required to calculate HLT filter decision:
107 performing the track fit and the Belle2 track creation to the path.
108
109 :param path: The path to add the tracking reconstruction modules to
110 :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
111 :param add_mva_quality_indicator: If true, add the MVA track quality estimation
112 to the path that sets the quality indicator property of the found tracks.
113 """
114
115 # Correct time seed
116 path.add_module("IPTrackTimeEstimator",
117 recoTracksStoreArrayName=reco_tracks, useFittedInformation=False)
118 # track fitting
119 path.add_module("DAFRecoFitter", recoTracksStoreArrayName=reco_tracks).set_name(
120 "Combined_DAFRecoFitter")
121 # Add MVA classifier that uses information not included in the calculation of the fit p-value
122 # to add a track quality indicator for classification of fake vs. MC-matched tracks
123
124 if add_mva_quality_indicator:
125 path.add_module("TrackQualityEstimatorMVA", collectEventFeatures=True)
126 # create Belle2 Tracks from the genfit Tracks
127 # The following particle hypothesis will be fitted: Pion, Kaon and Proton
128 # Muon fit is working but gives very similar as the Pion due to the closeness of masses
129 # -> therefore not in the default fit list
130 # Electron fit has as systematic bias and therefore not done here. Therefore, pion fits
131 # will be used for electrons which gives a better result as GenFit's current electron
132 # implementation.
133 path.add_module('TrackCreator', recoTrackColName=reco_tracks,
134 pdgCodes=[211, 321, 2212] if not trackFitHypotheses else trackFitHypotheses)
135
136
137def add_cr_track_fit_and_track_creator(path, components=None,
138 prune_tracks=False, event_timing_extraction=True,
139 reco_tracks="RecoTracks", tracks=""):
140 """
141 Helper function to add the modules performing the cdc cr track fit
142 and track creation to the path.
143
144 :param path: The path to which to add the tracking reconstruction modules
145 :param components: the list of geometry components in use or None for all components.
146 :param reco_tracks: The name of the reco tracks to use
147 :param tracks: the name of the output Belle tracks
148 :param prune_tracks: Delete all hits expect the first and the last from the found tracks.
149 :param event_timing_extraction: extract the event time
150 """
151
152 # Time seed
153 path.add_module("PlaneTriggerTrackTimeEstimator",
154 recoTracksStoreArrayName=reco_tracks,
155 pdgCodeToUseForEstimation=13,
156 triggerPlanePosition=[0., 0., 0.],
157 triggerPlaneDirection=[0., 1., 0.],
158 useFittedInformation=False)
159
160 # Initial track fitting
161 path.add_module("DAFRecoFitter",
162 recoTracksStoreArrayName=reco_tracks,
163 probCut=0.00001,
164 pdgCodesToUseForFitting=13)
165
166 # Correct time seed
167 path.add_module("PlaneTriggerTrackTimeEstimator",
168 recoTracksStoreArrayName=reco_tracks,
169 pdgCodeToUseForEstimation=13,
170 triggerPlanePosition=[0., 0., 0.],
171 triggerPlaneDirection=[0., 1., 0.],
172 useFittedInformation=True)
173
174 # Final Track fitting
175 path.add_module("DAFRecoFitter",
176 recoTracksStoreArrayName=reco_tracks,
177 pdgCodesToUseForFitting=13
178 )
179
180 if event_timing_extraction:
181 # Extract the time
182 path.add_module("FullGridChi2TrackTimeExtractor",
183 RecoTracksStoreArrayName=reco_tracks,
184 GridMaximalT0Value=40,
185 GridMinimalT0Value=-40,
186 GridGridSteps=6
187 )
188
189 # Track fitting
190 path.add_module("DAFRecoFitter",
191 # probCut=0.00001,
192 recoTracksStoreArrayName=reco_tracks,
193 pdgCodesToUseForFitting=13
194 )
195
196 # Create Belle2 Tracks from the genfit Tracks
197 path.add_module('TrackCreator',
198 pdgCodes=[13],
199 recoTrackColName=reco_tracks,
200 trackColName=tracks,
201 useClosestHitToIP=True,
202 useBFieldAtHit=True
203 )
204
205 # Prune genfit tracks
206 if prune_tracks:
207 add_prune_tracks(path=path, components=components,
208 reco_tracks=reco_tracks)
209
210
211def add_mc_matcher(path, components=None, mc_reco_tracks="MCRecoTracks",
212 reco_tracks="RecoTracks", use_second_cdc_hits=False,
213 split_after_delta_t=-1.0, matching_method="hit",
214 chi2_cutoffs=[128024, 95, 173, 424, 90, 424],
215 chi2_linalg=False):
216 """
217 Match the tracks to the MC truth. The matching works based on
218 the output of the TrackFinderMCTruthRecoTracks.
219 Alternatively one can use the Chi2MCTrackMatcher based on chi2 values
220 calculated from the helixparameters of Tracks and MCParticles.
221
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 adjacent SimHits is more than the given value
229 :param matching_method: hit: uses the hit-matching
230 chi2: uses the chi2-matching
231 :param chi2_cutoffs: If chi2 matching method is used, this list defines the individual cut-off values
232 for the chi2 values. Thereby each charged stable particle gets its cut-off
233 value. The order of the pdgs is [11,13,211,2212,321,1000010020]. The default
234 values are determined from a small study investigating chi2 value distribution of
235 trivial matching pairs.
236 :param chi2_linalg: If chi2 matching is used, this defines package used to invert the covariance5
237 matrix. ROOT has been shown to be faster than eigen. If False ROOT is used. If True
238 eigen is used.
239 """
240 if (matching_method == "hit"):
241 path.add_module('TrackFinderMCTruthRecoTracks',
242 RecoTracksStoreArrayName=mc_reco_tracks,
243 WhichParticles=[],
244 UseSecondCDCHits=use_second_cdc_hits,
245 UsePXDHits=is_pxd_used(components),
246 UseSVDHits=is_svd_used(components),
247 UseCDCHits=is_cdc_used(components),
248 SplitAfterDeltaT=split_after_delta_t)
249
250 path.add_module('MCRecoTracksMatcher',
251 mcRecoTracksStoreArrayName=mc_reco_tracks,
252 prRecoTracksStoreArrayName=reco_tracks,
253 UsePXDHits=is_pxd_used(components),
254 UseSVDHits=is_svd_used(components),
255 UseCDCHits=is_cdc_used(components))
256
257 path.add_module('TrackToMCParticleRelator')
258
259 elif (matching_method == "chi2"):
260 print("Warning: The Chi2MCTrackMatcherModule is currently not fully developed and tested!")
261 path.add_module('Chi2MCTrackMatcherModule',
262 CutOffs=chi2_cutoffs,
263 linalg=chi2_linalg)
264
265
266def add_prune_tracks(path, components=None, reco_tracks="RecoTracks"):
267 """
268 Adds removal of the intermediate states at each measurement from the fitted tracks.
269
270 :param path: The path to add the tracking reconstruction modules to
271 :param components: the list of geometry components in use or None for all components.
272 :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
273 """
274
275 # do not add any pruning, if no tracking detectors are in the components
276 if components and not ('SVD' in components or 'CDC' in components):
277 return
278
279 path.add_module('PruneRecoTracks', storeArrayName=reco_tracks)
280 path.add_module("PruneGenfitTracks")
281
282
283def add_flipping_of_recoTracks(
284 path,
285 fit_tracks=True,
286 reco_tracks="RecoTracks",
287 trackFitHypotheses=None,
288 reco_tracks_flipped="RecoTracks_flipped"):
289 """
290 This function adds the mva based selections and the flipping of the recoTracks
291
292 :param path: The path to add the tracking reconstruction modules to
293 :param fit_tracks: fit the flipped recotracks or not
294 :param reco_tracks: Name of the StoreArray where the reco tracks should be flipped
295 :param trackFitHypotheses: Which pdg hypothesis to fit. Defaults to [211, 321, 2212].
296 :param reco_tracks_flipped: Name of the temporary StoreArray for the flipped RecoTracks
297 """
298
299 path.add_module("FlipQuality", recoTracksStoreArrayName=reco_tracks,
300 identifier='TRKTrackFlipAndRefit_MVA1_weightfile',
301 indexOfFlippingMVA=1).set_name("FlipQuality_1stMVA")
302
303 path.add_module("RecoTracksReverter", inputStoreArrayName=reco_tracks,
304 outputStoreArrayName=reco_tracks_flipped)
305 if fit_tracks:
306 path.add_module("DAFRecoFitter", recoTracksStoreArrayName=reco_tracks_flipped).set_name("Combined_DAFRecoFitter_flipped")
307 path.add_module("IPTrackTimeEstimator",
308 recoTracksStoreArrayName=reco_tracks_flipped, useFittedInformation=False)
309 path.add_module("TrackCreator", trackColName="Tracks_flipped",
310 trackFitResultColName="TrackFitResults_flipped",
311 recoTrackColName=reco_tracks_flipped,
312 pdgCodes=[
313 211,
314 321,
315 2212] if not trackFitHypotheses else trackFitHypotheses).set_name("TrackCreator_flipped")
316 path.add_module("FlipQuality", recoTracksStoreArrayName=reco_tracks,
317 identifier='TRKTrackFlipAndRefit_MVA2_weightfile',
318 indexOfFlippingMVA=2).set_name("FlipQuality_2ndMVA")
319 path.add_module("FlippedRecoTracksMerger",
320 inputStoreArrayName=reco_tracks,
321 inputStoreArrayNameFlipped=reco_tracks_flipped)
322
323
324def add_pxd_track_finding(path, components, input_reco_tracks, output_reco_tracks, use_mc_truth=False,
325 add_both_directions=False, temporary_reco_tracks="PXDRecoTracks", **kwargs):
326 """Add the pxd track finding to the path"""
327 if not is_pxd_used(components):
328 return
329
330 if use_mc_truth:
331 # MC CKF needs MC matching information
332 path.add_module("MCRecoTracksMatcher", UsePXDHits=False,
333 UseSVDHits=is_svd_used(components), UseCDCHits=is_cdc_used(components),
334 mcRecoTracksStoreArrayName="MCRecoTracks",
335 prRecoTracksStoreArrayName=input_reco_tracks)
336
337 add_pxd_ckf(path, svd_cdc_reco_tracks=input_reco_tracks, pxd_reco_tracks=temporary_reco_tracks,
338 direction="backward", use_mc_truth=use_mc_truth, **kwargs)
339
340 if add_both_directions:
341 add_pxd_ckf(path, svd_cdc_reco_tracks=input_reco_tracks, pxd_reco_tracks=temporary_reco_tracks,
342 direction="forward", use_mc_truth=use_mc_truth, **kwargs)
343
344 path.add_module("RelatedTracksCombiner", CDCRecoTracksStoreArrayName=input_reco_tracks,
345 VXDRecoTracksStoreArrayName=temporary_reco_tracks, recoTracksStoreArrayName=output_reco_tracks)
346
347
348def add_pxd_cr_track_finding(path, components, input_reco_tracks, output_reco_tracks, use_mc_truth=False,
349 add_both_directions=False, temporary_reco_tracks="PXDRecoTracks", **kwargs):
350 """Add the pxd track finding to the path"""
351 if not is_pxd_used(components):
352 return
353
354 if use_mc_truth:
355 # MC CKF needs MC matching information
356 path.add_module("MCRecoTracksMatcher", UsePXDHits=False,
357 UseSVDHits=is_svd_used(components), UseCDCHits=is_cdc_used(components),
358 mcRecoTracksStoreArrayName="MCRecoTracks",
359 prRecoTracksStoreArrayName=input_reco_tracks)
360
361 add_cosmics_pxd_ckf(path, svd_cdc_reco_tracks=input_reco_tracks, pxd_reco_tracks=temporary_reco_tracks,
362 direction="backward", use_mc_truth=use_mc_truth, **kwargs)
363
364 if add_both_directions:
365 add_cosmics_pxd_ckf(path, svd_cdc_reco_tracks=input_reco_tracks, pxd_reco_tracks=temporary_reco_tracks,
366 direction="forward", use_mc_truth=use_mc_truth, **kwargs)
367
368 path.add_module("RelatedTracksCombiner", CDCRecoTracksStoreArrayName=input_reco_tracks,
369 VXDRecoTracksStoreArrayName=temporary_reco_tracks, recoTracksStoreArrayName=output_reco_tracks)
370
371
372def add_svd_track_finding(
373 path,
374 components,
375 input_reco_tracks,
376 output_reco_tracks,
377 svd_ckf_mode="SVD_after",
378 use_mc_truth=False,
379 add_both_directions=True,
380 temporary_reco_tracks="SVDRecoTracks",
381 temporary_svd_cdc_reco_tracks="SVDPlusCDCStandaloneRecoTracks",
382 use_svd_to_cdc_ckf=True,
383 prune_temporary_tracks=True,
384 add_mva_quality_indicator=False,
385 svd_standalone_mode="VXDTF2",
386 **kwargs,
387):
388 """
389 Add SVD track finding to the path.
390
391 :param path: The path to add the tracking reconstruction modules to
392 :param components: The list of geometry components in use or None for all components.
393 :param input_reco_tracks: Name of the StoreArray with the input reco tracks (usually from CDC) that are used in the
394 CKF track finding and are merged with the newly found SVD tracks into the ``output_reco_tracks``.
395 :param output_reco_tracks: Name of the StoreArray where the reco tracks outputted by the SVD track finding should be
396 stored.
397 :param svd_ckf_mode: String designating the mode of the CDC-to-SVD CKF, that is how it is combined with the SVD
398 standalone track finding. One of "SVD_after", "SVD_before", "SVD_before_with_second_ckf",
399 "only_ckf", "SVD_alone", "cosmics".
400 :param use_mc_truth: Add mc matching and use the MC information in the CKF (but not in the VXDTF2)
401 :param add_both_directions: Whether to add the CKF with both forward and backward extrapolation directions instead
402 of just one.
403 :param temporary_reco_tracks: Intermediate store array where the SVD tracks from the SVD standalone track finding
404 are stored, before they are merged with CDC tracks and extended via the CKF tracking.
405 :param temporary_svd_cdc_reco_tracks: Intermediate store array where the combination of ``temporary_reco_tracks``
406 (from SVD) and ``input_reco_tracks`` (from CDC standalone) is stored, before the CKF is applied.
407 It is only used if ``use_svd_to_cdc_ckf`` is true. Otherwise, the combination is stored directly in
408 ``output_reco_tracks``.
409 :param use_svd_to_cdc_ckf: Whether to enable the CKF extrapolation from the SVD into the CDC.
410 That CKF application is not affected by ``svd_ckf_mode``.
411 :param prune_temporary_tracks: Delete all hits expect the first and last from intermediate track objects.
412 :param add_mva_quality_indicator: Add the VXDQualityEstimatorMVA module to set the quality indicator
413 property for tracks from VXDTF2 standalone tracking
414 (ATTENTION: Standard triplet QI of VXDTF2 is replaced in this case
415 -> setting this option to 'True' will have some influence on the final track collection)
416 :param svd_standalone_mode: Which SVD standalone tracking is used.
417 Options are "VXDTF2", "SVDHough", "VXDTF2_and_SVDHough", and "SVDHough_and_VXDTF2".
418 Defaults to "VXDTF2"
419 """
420
421 if not is_svd_used(components):
422 return
423
424 if not input_reco_tracks:
425 # We do not have an input track store array. So lets just add vxdtf track finding
426 add_svd_standalone_tracking(path, components=["SVD"],
427 svd_standalone_mode=svd_standalone_mode,
428 reco_tracks=output_reco_tracks,
429 add_mva_quality_indicator=add_mva_quality_indicator)
430 return
431
432 if use_mc_truth:
433 # MC CKF needs MC matching information
434 path.add_module("MCRecoTracksMatcher", UsePXDHits=False, UseSVDHits=False,
435 UseCDCHits=is_cdc_used(components),
436 mcRecoTracksStoreArrayName="MCRecoTracks",
437 prRecoTracksStoreArrayName=input_reco_tracks)
438
439 if svd_ckf_mode == "SVD_before":
440 add_svd_standalone_tracking(path, components=["SVD"],
441 svd_standalone_mode=svd_standalone_mode,
442 reco_tracks=temporary_reco_tracks,
443 add_mva_quality_indicator=add_mva_quality_indicator)
444 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
445 use_mc_truth=use_mc_truth, direction="backward", **kwargs)
446 if add_both_directions:
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="forward", **kwargs)
449
450 elif svd_ckf_mode == "SVD_before_with_second_ckf":
451 add_svd_standalone_tracking(path, components=["SVD"],
452 svd_standalone_mode=svd_standalone_mode,
453 reco_tracks=temporary_reco_tracks,
454 add_mva_quality_indicator=add_mva_quality_indicator)
455 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
456 use_mc_truth=use_mc_truth, direction="backward", **kwargs)
457 if add_both_directions:
458 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
459 use_mc_truth=use_mc_truth, direction="forward", **kwargs)
460 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
461 use_mc_truth=use_mc_truth, direction="backward", **kwargs)
462 if add_both_directions:
463 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
464 use_mc_truth=use_mc_truth, direction="forward", **kwargs)
465
466 elif svd_ckf_mode == "only_ckf":
467 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
468 use_mc_truth=use_mc_truth, direction="backward", **kwargs)
469 if add_both_directions:
470 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
471 use_mc_truth=use_mc_truth, direction="forward", **kwargs)
472
473 elif svd_ckf_mode == "SVD_after":
474 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
475 use_mc_truth=use_mc_truth, direction="backward", **kwargs)
476 if add_both_directions:
477 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
478 use_mc_truth=use_mc_truth, direction="forward", **kwargs)
479
480 add_svd_standalone_tracking(path, components=["SVD"],
481 svd_standalone_mode=svd_standalone_mode,
482 reco_tracks=temporary_reco_tracks,
483 add_mva_quality_indicator=add_mva_quality_indicator)
484 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
485 use_mc_truth=use_mc_truth, direction="backward", **kwargs)
486 if add_both_directions:
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="forward", **kwargs)
489
490 elif svd_ckf_mode == "SVD_alone":
491 add_svd_standalone_tracking(path, components=["SVD"],
492 svd_standalone_mode=svd_standalone_mode,
493 reco_tracks=temporary_reco_tracks,
494 add_mva_quality_indicator=add_mva_quality_indicator)
495 path.add_module('VXDCDCTrackMerger',
496 CDCRecoTrackColName=input_reco_tracks,
497 VXDRecoTrackColName=temporary_reco_tracks)
498
499 elif svd_ckf_mode == "cosmics":
500 add_cosmics_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
501 use_mc_truth=use_mc_truth, direction="backward", **kwargs)
502 if add_both_directions:
503 add_cosmics_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
504 use_mc_truth=use_mc_truth, direction="forward", **kwargs)
505
506 else:
507 raise ValueError(f"Do not understand the svd_ckf_mode {svd_ckf_mode}")
508
509 if use_svd_to_cdc_ckf:
510 combined_svd_cdc_standalone_tracks = temporary_svd_cdc_reco_tracks
511 else:
512 combined_svd_cdc_standalone_tracks = output_reco_tracks
513
514 # Write out the combinations of tracks
515 path.add_module("RelatedTracksCombiner", VXDRecoTracksStoreArrayName=temporary_reco_tracks,
516 CDCRecoTracksStoreArrayName=input_reco_tracks,
517 recoTracksStoreArrayName=combined_svd_cdc_standalone_tracks)
518
519 if use_svd_to_cdc_ckf:
520 path.add_module("ToCDCCKF",
521 inputWireHits="CDCWireHitVector",
522 inputRecoTrackStoreArrayName=combined_svd_cdc_standalone_tracks,
523 relatedRecoTrackStoreArrayName="CKFCDCRecoTracks",
524 relationCheckForDirection="backward",
525 ignoreTracksWithCDChits=True,
526 outputRecoTrackStoreArrayName="CKFCDCRecoTracks",
527 outputRelationRecoTrackStoreArrayName=combined_svd_cdc_standalone_tracks,
528 writeOutDirection="backward",
529 stateBasicFilterParameters={"maximalHitDistance": 0.15},
530 pathFilter="arc_length",
531 maximalLayerJump=4)
532
533 path.add_module("CDCCKFTracksCombiner",
534 CDCRecoTracksStoreArrayName="CKFCDCRecoTracks",
535 VXDRecoTracksStoreArrayName=combined_svd_cdc_standalone_tracks,
536 recoTracksStoreArrayName=output_reco_tracks)
537
538 if prune_temporary_tracks:
539 for temp_reco_track in [combined_svd_cdc_standalone_tracks, "CKFCDCRecoTracks"]:
540 path.add_module('PruneRecoTracks', storeArrayName=temp_reco_track)
541
542
543def add_svd_standalone_tracking(path,
544 components=["SVD"],
545 svd_clusters="",
546 svd_standalone_mode="VXDTF2",
547 reco_tracks="SVDRecoTracks",
548 add_mva_quality_indicator=False,
549 suffix=""):
550 """
551 Convenience function to add the SVD standalone tracking
552
553 :param path: basf2 path
554 :param components: components to use, defaults to SVD
555 :param svd_clusters: Name of the SVDClusters StoreArray used for tracking
556 :param svd_standalone_mode: Which SVD standalone tracking is used.
557 Options are "VXDTF2", "SVDHough", "VXDTF2_and_SVDHough", and "SVDHough_and_VXDTF2".
558 Defaults to "VXDTF2"
559 :param reco_tracks: In case the only SVD standalone tracking is performed, these are the final RecoTracks,
560 otherwise it's an intermediate StoreaArray where the SVD tracks from the SVD standalone track finding are stored, before they are merged with CDC tracks and extended via the CKF tracking.
561 :param add_mva_quality_indicator: Add the VXDQualityEstimatorMVA module to set the quality indicator
562 property for tracks from VXDTF2 standalone tracking
563 (ATTENTION: Standard triplet QI of VXDTF2 is replaced in this case
564 -> setting this option to 'True' will have some influence on the final track collection)
565 :param suffix: all names of intermediate Storearrays will have the suffix appended. Useful in cases someone needs to
566 put several instances of track finding in one path.
567 """
568 if svd_standalone_mode == "VXDTF2":
569 add_vxd_track_finding_vxdtf2(path, components=components, svd_clusters=svd_clusters, reco_tracks=reco_tracks,
570 add_mva_quality_indicator=add_mva_quality_indicator, suffix=suffix)
571
572 elif svd_standalone_mode == "SVDHough":
573 add_svd_hough_tracking(path, reco_tracks=reco_tracks, suffix=suffix)
574
575 elif svd_standalone_mode == "VXDTF2_and_SVDHough":
576 add_vxd_track_finding_vxdtf2(path,
577 components=components,
578 svd_clusters=svd_clusters,
579 nameSPTCs="SPTrackCands"+"VXDTF2",
580 reco_tracks=reco_tracks+"VXDTF2",
581 add_mva_quality_indicator=add_mva_quality_indicator,
582 suffix=suffix)
583 add_svd_hough_tracking(path,
584 reco_tracks=reco_tracks+"Hough",
585 svd_space_point_track_candidates="SPTrackCands"+"Hough",
586 suffix=suffix)
587
588 path.add_module('RecoTrackStoreArrayCombiner',
589 Temp1RecoTracksStoreArrayName=reco_tracks+"VXDTF2",
590 Temp2RecoTracksStoreArrayName=reco_tracks+"Hough",
591 recoTracksStoreArrayName=reco_tracks)
592 path.add_module('PruneRecoTracks', storeArrayName=reco_tracks+"VXDTF2")
593 path.add_module('PruneRecoTracks', storeArrayName=reco_tracks+"Hough")
594
595 elif svd_standalone_mode == "SVDHough_and_VXDTF2":
596 add_svd_hough_tracking(path,
597 reco_tracks=reco_tracks+"Hough",
598 svd_space_point_track_candidates="SPTrackCands"+"Hough",
599 suffix=suffix)
600 add_vxd_track_finding_vxdtf2(path,
601 components=components,
602 svd_clusters=svd_clusters,
603 nameSPTCs="SPTrackCands"+"VXDTF2",
604 reco_tracks=reco_tracks+"VXDTF2",
605 add_mva_quality_indicator=add_mva_quality_indicator,
606 suffix=suffix)
607
608 path.add_module('RecoTrackStoreArrayCombiner',
609 Temp1RecoTracksStoreArrayName=reco_tracks+"Hough",
610 Temp2RecoTracksStoreArrayName=reco_tracks+"VXDTF2",
611 recoTracksStoreArrayName=reco_tracks)
612 path.add_module('PruneRecoTracks', storeArrayName=reco_tracks+"Hough")
613 path.add_module('PruneRecoTracks', storeArrayName=reco_tracks+"VXDTF2")
614
615 else:
616 raise ValueError(f"Do not understand the svd_standalone_mode {svd_standalone_mode}")
617
618
619def add_cdc_track_finding(path, output_reco_tracks="RecoTracks", with_ca=False,
620 use_second_hits=False, add_mva_quality_indicator=True,
621 reattach_hits=False):
622 """
623 Convenience function for adding all cdc track finder modules
624 to the path.
625
626 The result is a StoreArray with name @param reco_tracks full of RecoTracks (not TrackCands any more!).
627 Use the GenfitTrackCandidatesCreator Module to convert back.
628
629 :param path: basf2 path
630 :param output_reco_tracks: Name of the output RecoTracks. Defaults to RecoTracks.
631 :param use_second_hits: If true, the second hit information will be used in the CDC track finding.
632 :param add_mva_quality_indicator: Add the TFCDC_TrackQualityEstimator module to set the CDC quality
633 indicator property of the CDC ``output_reco_tracks``
634 :param cdc_quality_estimator_weightfile: Weightfile identifier for the TFCDC_TrackQualityEstimator
635 :param reattach_hits: if true, use the ReattachCDCWireHitsToRecoTracks module at the end of the CDC track finding
636 to read hits with bad ADC or TOT rejected by the TFCDC_WireHitPreparer module.
637 """
638 # add EventLevelTrackinginfo for logging errors
639 if 'RegisterEventLevelTrackingInfo' not in path:
640 path.add_module('RegisterEventLevelTrackingInfo')
641
642 # Init the geometry for cdc tracking and the hits and cut low ADC hits
643 path.add_module("TFCDC_WireHitPreparer",
644 wirePosition="aligned",
645 useSecondHits=use_second_hits,
646 flightTimeEstimation="outwards",
647 filter="mva",
648 filterParameters={'DBPayloadName': 'trackfindingcdc_WireHitBackgroundDetectorParameters'})
649
650 # Constructs clusters
651 path.add_module("TFCDC_ClusterPreparer",
652 ClusterFilter="all",
653 ClusterFilterParameters={})
654
655 # Find segments within the clusters
656 path.add_module("TFCDC_SegmentFinderFacetAutomaton",
657 SegmentRelationFilterParameters={'DBPayloadName': 'trackfindingcdc_RealisticSegmentRelationFilterParameters'})
658
659 # Find axial tracks
660 path.add_module("TFCDC_AxialTrackFinderLegendre")
661
662 # Improve the quality of the axial tracks
663 path.add_module("TFCDC_TrackQualityAsserter",
664 corrections=["B2B"])
665
666 # Find the stereo hits to those axial tracks
667 path.add_module('TFCDC_StereoHitFinder')
668
669 # Combine segments with axial tracks
670 path.add_module('TFCDC_SegmentTrackCombiner',
671 segmentTrackFilter="mva",
672 segmentTrackFilterParameters={'DBPayloadName': 'trackfindingcdc_SegmentTrackFilterParameters'},
673 trackFilter="mva",
674 trackFilterParameters={'DBPayloadName': 'trackfindingcdc_TrackFilterParameters'})
675
676 output_tracks = "CDCTrackVector"
677
678 if with_ca:
679 output_tracks = "CombinedCDCTrackVector"
680 path.add_module("TFCDC_TrackFinderSegmentPairAutomaton",
681 tracks="CDCTrackVector2")
682
683 # Overwrites the origin CDCTrackVector
684 path.add_module("TFCDC_TrackCombiner",
685 inputTracks="CDCTrackVector",
686 secondaryInputTracks="CDCTrackVector2",
687 tracks=output_tracks)
688
689 # Improve the quality of all tracks and output
690 path.add_module("TFCDC_TrackQualityAsserter",
691 inputTracks=output_tracks,
692 corrections=[
693 "LayerBreak",
694 "OneSuperlayer",
695 "Small",
696 ])
697
698 if with_ca:
699 # Add curlers in the axial inner most superlayer
700 path.add_module("TFCDC_TrackCreatorSingleSegments",
701 inputTracks=output_tracks,
702 MinimalHitsBySuperLayerId={0: 15})
703
704 if add_mva_quality_indicator:
705 # Add CDC-specific mva method to set the quality indicator for the CDC tracks
706 path.add_module(
707 "TFCDC_TrackQualityEstimator",
708 inputTracks=output_tracks,
709 filter='mva',
710 filterParameters={'DBPayloadName': 'trackfindingcdc_TrackQualityEstimatorParameters'},
711 deleteTracks=True,
712 resetTakenFlag=True
713 )
714
715 # Export CDCTracks to RecoTracks representation
716 path.add_module("TFCDC_TrackExporter",
717 inputTracks=output_tracks,
718 RecoTracksStoreArrayName="CDCRecoTracksBeforeReattaching" if reattach_hits else output_reco_tracks)
719
720 if reattach_hits:
721 # The ReattachCDCWireHitsToRecoTracks module (below) requires the SetupGenfitExtrapolation module
722 if 'SetupGenfitExtrapolation' not in path:
723 # Prepare Genfit extrapolation
724 path.add_module('SetupGenfitExtrapolation')
725
726 # Loop over low-ADC/TOT CDCWireHits and RecoTracks and reattach the hits to the tracks if they are close enough
727 path.add_module("ReattachCDCWireHitsToRecoTracks",
728 inputRecoTracksStoreArrayName="CDCRecoTracksBeforeReattaching",
729 outputRecoTracksStoreArrayName=output_reco_tracks)
730
731 # Correct time seed (only necessary for the CDC tracks)
732 path.add_module("IPTrackTimeEstimator",
733 useFittedInformation=False,
734 recoTracksStoreArrayName=output_reco_tracks)
735
736 # run fast t0 estimation from CDC hits only
737 path.add_module("CDCHitBasedT0Extraction")
738
739 # prepare mdst event level info
740 path.add_module("CDCTrackingEventLevelMdstInfoFillerFromHits")
741 path.add_module("CDCTrackingEventLevelMdstInfoFillerFromSegments")
742
743
744def add_eclcdc_track_finding(path, components, output_reco_tracks="RecoTracks", prune_temporary_tracks=True):
745 """
746 Convenience function for adding all track finder modules to the path that are based on ecl seeds.
747
748 The result is a StoreArray with name @param reco_tracks full of RecoTracks.
749 Use the GenfitTrackCandidatesCreator Module to convert back.
750
751 :param path: basf2 path
752 :param components: the list of geometry components in use or None for all components.
753 :param output_reco_tracks: Name of the output RecoTracks. Defaults to RecoTracks.
754 :param pruneTracks: Delete all hits expect the first and the last from the found tracks.
755 """
756 if not is_cdc_used(components) or not is_ecl_used(components):
757 return
758
759 ecl_cdc_reco_tracks = "ECLCDCRecoTracks"
760
761 if not is_svd_used(components):
762 ecl_cdc_reco_tracks = output_reco_tracks
763
764 # collections that will be pruned
765 temporary_reco_track_list = []
766
767 path.add_module("ToCDCFromEclCKF",
768 inputWireHits="CDCWireHitVector",
769 minimalEnRequirementCluster=0.3,
770 eclSeedRecoTrackStoreArrayName='EclSeedRecoTracks',
771 hitFindingDirection="backward",
772 outputRecoTrackStoreArrayName="CDCRecoTracksFromEcl",
773 outputRelationRecoTrackStoreArrayName="EclSeedRecoTracks",
774 writeOutDirection="forward",
775 stateBasicFilterParameters={"maximalHitDistance": 7.5, "maximalHitDistanceEclSeed": 75.0},
776 stateExtrapolationFilterParameters={"direction": "backward"},
777 pathFilter="arc_length_fromEcl",
778 inputECLshowersStoreArrayName="ECLShowers",
779 trackFindingDirection="backward",
780 setTakenFlag=False,
781 seedComponent="ECL"
782 )
783
784 path.add_module("ToCDCCKF",
785 inputWireHits="CDCWireHitVector",
786 inputRecoTrackStoreArrayName="CDCRecoTracksFromEcl",
787 relatedRecoTrackStoreArrayName=ecl_cdc_reco_tracks,
788 relationCheckForDirection="backward",
789 outputRecoTrackStoreArrayName=ecl_cdc_reco_tracks,
790 outputRelationRecoTrackStoreArrayName="CDCRecoTracksFromEcl",
791 writeOutDirection="backward",
792 stateBasicFilterParameters={"maximalHitDistance": 0.75},
793 stateExtrapolationFilterParameters={"direction": "forward"},
794 pathFilter="arc_length",
795 seedComponent="ECL"
796 )
797 # "EclSeedRecoTracks" don't have to be added to the list as these do not contain any hits
798 temporary_reco_track_list.append('CDCRecoTracksFromEcl')
799
800 # Do the following modules have to be added as these are executed already after
801 # the CDC standalone?
802 # If so: they also have to be included in the new SVD->CDC CKF (see add_svd_track_finding(..) above)
803
804 # Correct time seed (only necessary for the CDC tracks)
805 # path.add_module("IPTrackTimeEstimator",
806 # useFittedInformation=False,
807 # recoTracksStoreArrayName=ecl_cdc_reco_tracks)
808
809 # run fast t0 estimation from CDC hits only
810 # path.add_module("CDCHitBasedT0Extraction")
811
812 # prepare mdst event level info
813 # path.add_module("CDCTrackingEventLevelMdstInfoFiller")
814
815 if is_svd_used(components):
816 add_svd_track_finding(path, components=components, input_reco_tracks=ecl_cdc_reco_tracks,
817 output_reco_tracks=output_reco_tracks, use_mc_truth=False,
818 svd_ckf_mode="only_ckf", add_both_directions=False,
819 temporary_reco_tracks="ECLSVDRecoTracks", use_svd_to_cdc_ckf=False,
820 prune_temporary_tracks=prune_temporary_tracks)
821 temporary_reco_track_list.append(ecl_cdc_reco_tracks)
822 temporary_reco_track_list.append('ECLSVDRecoTracks')
823
824 if prune_temporary_tracks:
825 for temporary_reco_track_name in temporary_reco_track_list:
826 if temporary_reco_track_name != output_reco_tracks:
827 path.add_module('PruneRecoTracks', storeArrayName=temporary_reco_track_name)
828
829
830def add_cdc_cr_track_finding(path, output_reco_tracks="RecoTracks", trigger_point=(0, 0, 0), merge_tracks=True,
831 use_second_cdc_hits=False):
832 """
833 Convenience function for adding all cdc track finder modules currently dedicated for the CDC-TOP testbeam
834 to the path.
835
836 The result is a StoreArray with name @param reco_tracks full of RecoTracks (not TrackCands any more!).
837
838 Arguments
839 ---------
840 path: basf2.Path
841 The path to be filled
842 output_reco_tracks: str
843 Name of the output RecoTracks. Defaults to RecoTracks.
844 merge_tracks: bool
845 The upper and lower half of the tracks should be merged together in one track
846 use_second_hits: bool
847 If true, the second hit information will be used in the CDC track finding.
848 """
849
850 # Init the geometry for cdc tracking and the hits
851 path.add_module("TFCDC_WireHitPreparer",
852 useSecondHits=use_second_cdc_hits,
853 flightTimeEstimation="downwards",
854 filter="cuts_from_DB",
855 triggerPoint=trigger_point)
856
857 # Constructs clusters and reduce background hits
858 path.add_module("TFCDC_ClusterPreparer",
859 ClusterFilter="mva_bkg",
860 ClusterFilterParameters={'DBPayloadName': 'trackfindingcdc_ClusterFilterParameters'})
861
862 # Find segments within the clusters
863 path.add_module("TFCDC_SegmentFinderFacetAutomaton",
864 SegmentOrientation="downwards")
865
866 # Find axial tracks
867 path.add_module("TFCDC_AxialTrackFinderLegendre")
868
869 # Improve the quality of the axial tracks
870 path.add_module("TFCDC_TrackQualityAsserter",
871 corrections=["B2B"])
872
873 # Find the stereo hits to those axial tracks
874 path.add_module('TFCDC_StereoHitFinder')
875
876 # Combine segments with axial tracks
877 path.add_module('TFCDC_SegmentTrackCombiner',
878 segmentTrackFilter="mva",
879 segmentTrackFilterParameters={'DBPayloadName': 'trackfindingcdc_SegmentTrackFilterParameters'},
880 trackFilter="mva",
881 trackFilterParameters={'DBPayloadName': 'trackfindingcdc_TrackFilterParameters'})
882
883 # Improve the quality of all tracks and output
884 path.add_module("TFCDC_TrackQualityAsserter",
885 corrections=["LayerBreak", "OneSuperlayer", "Small"],
886 )
887
888 # Flip track orientation to always point downwards
889 path.add_module("TFCDC_TrackOrienter",
890 inputTracks="CDCTrackVector",
891 tracks="OrientedCDCTrackVector",
892 TrackOrientation="downwards",
893 )
894
895 output_tracks = "OrientedCDCTrackVector"
896
897 if merge_tracks:
898 # Merge tracks together if needed
899 path.add_module("TFCDC_TrackLinker",
900 inputTracks="OrientedCDCTrackVector",
901 tracks="MergedCDCTrackVector",
902 filter="phi",
903 )
904 output_tracks = "MergedCDCTrackVector"
905
906 # However, we also want to export the non merged tracks
907 # Correct time seed - assumes velocity near light speed
908 path.add_module("TFCDC_TrackFlightTimeAdjuster",
909 inputTracks="OrientedCDCTrackVector",
910 )
911
912 # Export CDCTracks to RecoTracks representation
913 path.add_module("TFCDC_TrackExporter",
914 inputTracks="OrientedCDCTrackVector",
915 RecoTracksStoreArrayName="NonMergedRecoTracks")
916
917 # Correct time seed - assumes velocity near light speed
918 path.add_module("TFCDC_TrackFlightTimeAdjuster",
919 inputTracks=output_tracks,
920 )
921
922 # Export CDCTracks to RecoTracks representation
923 path.add_module("TFCDC_TrackExporter",
924 inputTracks=output_tracks,
925 RecoTracksStoreArrayName=output_reco_tracks)
926
927 # run fast t0 estimation from CDC hits only
928 path.add_module("CDCHitBasedT0Extraction")
929
930
931def add_vxd_track_finding_vxdtf2(
932 path,
933 svd_clusters="",
934 reco_tracks="RecoTracks",
935 nameSPTCs='SPTrackCands',
936 components=None,
937 suffix="",
938 useTwoStepSelection=True,
939 PXDminSVDSPs=3,
940 sectormap_file=None,
941 custom_setup_name=None,
942 min_SPTC_quality=0.,
943 filter_overlapping=True,
944 add_mva_quality_indicator=False,
945):
946 """
947 Convenience function for adding all vxd track finder Version 2 modules
948 to the path.
949
950 The result is a StoreArray with name @param reco_tracks full of RecoTracks (not TrackCands any more!).
951 Use the GenfitTrackCandidatesCreator Module to convert back.
952
953 :param path: basf2 path
954 :param svd_clusters: SVDCluster collection name
955 :param reco_tracks: Name of the output RecoTracks, Defaults to RecoTracks.
956 :param nameSPTCs: Name of the SpacePointTrackCands StoreArray
957 :param components: List of the detector components to be used in the reconstruction. Defaults to None which means
958 all components.
959 :param suffix: all names of intermediate Storearrays will have the suffix appended. Useful in cases someone needs to
960 put several instances of track finding in one path.
961 :param useTwoStepSelection: if True Families will be defined during path creation and will be used to create only
962 the best candidate per family.
963 :param PXDminSVDSPs: When using PXD require at least this number of SVD SPs for the SPTCs
964 :param sectormap_file: if set to a finite value, a file will be used instead of the sectormap in the database.
965 :param custom_setup_name: Set a custom setup name for the tree in the sector map.
966 :param min_SPTC_quality: minimal qualityIndicator value to keeps SPTCs after the QualityEstimation.
967 0 means no cut. Default: 0
968 :param filter_overlapping: Whether to use SVDOverlapResolver, Default: True
969 :param add_mva_quality_indicator: Whether to use the MVA Quality Estimator module for VXDTF2 tracks to set the
970 quality_indicator property of the found ``reco_tracks``. Default: False.
971 """
972
975
976 # setting different for pxd and svd:
977 if is_pxd_used(components):
978 setup_name = "SVDPXDDefault"
979 db_sec_map_file = "VXDSectorMap_v000.root"
980 use_pxd = True
981 else:
982 setup_name = "SVDOnlyDefault"
983 db_sec_map_file = "SVDSectorMap_v000.root"
984 use_pxd = False
985
986
990
991 # setup the event level tracking info to log errors and stuff
992 nameTrackingInfoModule = "RegisterEventLevelTrackingInfo" + suffix
993 nameEventTrackingInfo = "EventLevelTrackingInfo" + suffix
994 if nameTrackingInfoModule not in path:
995 # Use modified name of module and created StoreObj as module might be added twice (PXDDataReduction)
996 registerEventlevelTrackingInfo = register_module('RegisterEventLevelTrackingInfo')
997 registerEventlevelTrackingInfo.set_name(nameTrackingInfoModule)
998 registerEventlevelTrackingInfo.param('EventLevelTrackingInfoName', nameEventTrackingInfo)
999 path.add_module(registerEventlevelTrackingInfo)
1000
1001 nameSPs = 'SpacePoints' + suffix
1002
1003 pxdSPCreatorName = 'PXDSpacePointCreator' + suffix
1004 if pxdSPCreatorName not in [e.name() for e in path.modules()]:
1005 if use_pxd:
1006 spCreatorPXD = register_module('PXDSpacePointCreator')
1007 spCreatorPXD.set_name(pxdSPCreatorName)
1008 spCreatorPXD.param('NameOfInstance', 'PXDSpacePoints')
1009 spCreatorPXD.param('SpacePoints', "PXD" + nameSPs)
1010 path.add_module(spCreatorPXD)
1011
1012 # SecMap Bootstrap
1013 secMapBootStrap = register_module('SectorMapBootstrap')
1014 secMapBootStrap.param('ReadSectorMap', sectormap_file is not None) # read from file
1015 secMapBootStrap.param('ReadSecMapFromDB', sectormap_file is None) # this will override ReadSectorMap
1016 secMapBootStrap.param('SectorMapsInputFile', sectormap_file or db_sec_map_file)
1017 secMapBootStrap.param('SetupToRead', custom_setup_name or setup_name)
1018 secMapBootStrap.param('WriteSectorMap', False)
1019 path.add_module(secMapBootStrap)
1020
1021
1025
1026 spacePointArrayNames = ["SVD" + nameSPs]
1027 if use_pxd:
1028 spacePointArrayNames += ["PXD" + nameSPs]
1029
1030 nameSegNet = 'SegmentNetwork' + suffix
1031
1032 segNetProducer = register_module('SegmentNetworkProducer')
1033 segNetProducer.param('NetworkOutputName', nameSegNet)
1034 segNetProducer.param('SpacePointsArrayNames', spacePointArrayNames)
1035 segNetProducer.param('sectorMapName', custom_setup_name or setup_name)
1036 segNetProducer.param('EventLevelTrackingInfoName', nameEventTrackingInfo)
1037 path.add_module(segNetProducer)
1038
1039
1043
1044 # append a suffix to the storearray name
1045 nameSPTCs += suffix
1046
1047 trackFinder = register_module('TrackFinderVXDCellOMat')
1048 trackFinder.param('NetworkName', nameSegNet)
1049 trackFinder.param('SpacePointTrackCandArrayName', nameSPTCs)
1050 trackFinder.param('printNetworks', False)
1051 trackFinder.param('setFamilies', useTwoStepSelection)
1052 trackFinder.param('selectBestPerFamily', useTwoStepSelection)
1053 trackFinder.param('xBestPerFamily', 30)
1054 trackFinder.param('EventLevelTrackingInfoName', nameEventTrackingInfo)
1055 path.add_module(trackFinder)
1056
1057 if useTwoStepSelection:
1058 subSetModule = register_module('AddVXDTrackCandidateSubSets')
1059 subSetModule.param('NameSpacePointTrackCands', nameSPTCs)
1060 path.add_module(subSetModule)
1061
1062
1066
1067 # When using PXD require at least PXDminSVDSPs SVD SPs for the SPTCs
1068 if use_pxd:
1069 pxdSVDCut = register_module('PXDSVDCut')
1070 pxdSVDCut.param('minSVDSPs', PXDminSVDSPs)
1071 pxdSVDCut.param('SpacePointTrackCandsStoreArrayName', nameSPTCs)
1072 path.add_module(pxdSVDCut)
1073
1074 if add_mva_quality_indicator:
1075 path.add_module(
1076 "VXDQualityEstimatorMVA",
1077 SpacePointTrackCandsStoreArrayName=nameSPTCs,
1078 )
1079 else:
1080 path.add_module(
1081 'QualityEstimatorVXD',
1082 EstimationMethod='tripletFit',
1083 SpacePointTrackCandsStoreArrayName=nameSPTCs,
1084 )
1085
1086 if min_SPTC_quality > 0.:
1087 qualityIndicatorCutter = register_module('VXDTrackCandidatesQualityIndicatorCutter')
1088 qualityIndicatorCutter.param('minRequiredQuality', min_SPTC_quality)
1089 qualityIndicatorCutter.param('NameSpacePointTrackCands', nameSPTCs)
1090 path.add_module(qualityIndicatorCutter)
1091
1092 # will discard track candidates (with low quality estimators) if the number of TC is above threshold
1093 maxCandidateSelection = register_module('BestVXDTrackCandidatesSelector')
1094 maxCandidateSelection.param('NameSpacePointTrackCands', nameSPTCs)
1095 maxCandidateSelection.param('NewNameSpacePointTrackCands', nameSPTCs)
1096 maxCandidateSelection.param('SubsetCreation', False)
1097 path.add_module(maxCandidateSelection)
1098
1099 # Properties
1100 vIPRemover = register_module('SPTCvirtualIPRemover')
1101 vIPRemover.param('tcArrayName', nameSPTCs)
1102 # want to remove virtualIP for any track length
1103 vIPRemover.param('maxTCLengthForVIPKeeping', 0)
1104 path.add_module(vIPRemover)
1105
1106
1110
1111 if filter_overlapping:
1112 overlapResolver = register_module('SVDOverlapResolver')
1113 overlapResolver.param('NameSpacePointTrackCands', nameSPTCs)
1114 overlapResolver.param('ResolveMethod', 'greedy') # other option is 'hopfield'
1115 overlapResolver.param('NameSVDClusters', svd_clusters)
1116 path.add_module(overlapResolver)
1117
1118
1122
1123 momSeedRetriever = register_module('SPTCmomentumSeedRetriever')
1124 momSeedRetriever.param('tcArrayName', nameSPTCs)
1125 path.add_module(momSeedRetriever)
1126
1127 converter = register_module('SPTC2RTConverter')
1128 converter.param('recoTracksStoreArrayName', reco_tracks)
1129 converter.param('spacePointsTCsStoreArrayName', nameSPTCs)
1130 converter.param('svdClustersName', svd_clusters)
1131 converter.param('svdHitsStoreArrayName', svd_clusters)
1132 path.add_module(converter)
1133
1134
1135def add_svd_hough_tracking(path,
1136 svd_space_points='SVDSpacePoints',
1137 svd_clusters='SVDClusters',
1138 reco_tracks='RecoTracks',
1139 svd_space_point_track_candidates='SPTrackCands',
1140 suffix=''):
1141 """
1142 Convenience function to add the SVDHoughTracking to the path.
1143 :param path: The path to add the SVDHoughTracking module to.
1144 :param svd_space_points: Name of the StoreArray containing the SVDSpacePoints
1145 :param svd_clusters: Name of the StoreArray containing the SVDClusters
1146 :param reco_tracks: Name of the StoreArray containing the RecoTracks
1147 :param svd_space_point_track_candidates: Name of the StoreArray containing the SpacePointTrackCandidates
1148 :param suffix: all names of intermediate StoreArrays will have the suffix appended. Useful in cases someone needs to
1149 put several instances of track finding in one path.
1150 """
1151
1152 path.add_module('SVDHoughTracking',
1153 SVDSpacePointStoreArrayName=svd_space_points + suffix,
1154 SVDClustersStoreArrayName=svd_clusters + suffix,
1155 finalOverlapResolverNameSVDClusters=svd_clusters + suffix,
1156 refinerOverlapResolverNameSVDClusters=svd_clusters + suffix,
1157 RecoTracksStoreArrayName=reco_tracks + suffix,
1158 SVDSpacePointTrackCandsStoreArrayName=svd_space_point_track_candidates + suffix,
1159 relationFilter='angleAndTime',
1160 twoHitUseNBestHits=4,
1161 threeHitUseNBestHits=3,
1162 fourHitUseNBestHits=3,
1163 fiveHitUseNBestHits=2,
1164 )
1165
1166
1167def is_svd_used(components):
1168 """Return true, if the SVD is present in the components list"""
1169 return components is None or 'SVD' in components
1170
1171
1172def is_pxd_used(components):
1173 """Return true, if the PXD is present in the components list"""
1174 return components is None or 'PXD' in components
1175
1176
1177def is_cdc_used(components):
1178 """Return true, if the CDC is present in the components list"""
1179 return components is None or 'CDC' in components
1180
1181
1182def is_ecl_used(components):
1183 """Return true, if the ECL is present in the components list"""
1184 return components is None or 'ECL' in components
1185