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 fucntion 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 Alternativly 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 adjecent 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(path, fit_tracks=True, reco_tracks="RecoTracks", trackFitHypotheses=None):
284 """
285 This function adds the mva based selections and the flipping of the recoTracks
286
287 :param path: The path to add the tracking reconstruction modules to
288 :param fit_tracks: fit the flipped recotracks or not
289 :param reco_tracks: Name of the StoreArray where the reco tracks should be flipped
290 :param trackFitHypotheses: Which pdg hypothesis to fit. Defaults to [211, 321, 2212].
291 """
292
293 path.add_module("FlipQuality", recoTracksStoreArrayName=reco_tracks,
294 identifier='TRKTrackFlipAndRefit_MVA1_weightfile',
295 indexOfFlippingMVA=1).set_name("FlipQuality_1stMVA")
296
297 reco_tracks_flipped = "RecoTracks_flipped"
298 path.add_module("RecoTracksReverter", inputStoreArrayName=reco_tracks,
299 outputStoreArrayName=reco_tracks_flipped)
300 if fit_tracks:
301 path.add_module("DAFRecoFitter", recoTracksStoreArrayName=reco_tracks_flipped).set_name("Combined_DAFRecoFitter_flipped")
302 path.add_module("IPTrackTimeEstimator",
303 recoTracksStoreArrayName=reco_tracks_flipped, useFittedInformation=False)
304 path.add_module("TrackCreator", trackColName="Tracks_flipped",
305 trackFitResultColName="TrackFitResults_flipped",
306 recoTrackColName=reco_tracks_flipped,
307 pdgCodes=[
308 211,
309 321,
310 2212] if not trackFitHypotheses else trackFitHypotheses).set_name("TrackCreator_flipped")
311 path.add_module("FlipQuality", recoTracksStoreArrayName=reco_tracks,
312 identifier='TRKTrackFlipAndRefit_MVA2_weightfile',
313 indexOfFlippingMVA=2).set_name("FlipQuality_2ndMVA")
314 path.add_module("FlippedRecoTracksMerger",
315 inputStoreArrayName=reco_tracks,
316 inputStoreArrayNameFlipped=reco_tracks_flipped)
317
318
319def add_pxd_track_finding(path, components, input_reco_tracks, output_reco_tracks, use_mc_truth=False,
320 add_both_directions=False, temporary_reco_tracks="PXDRecoTracks", **kwargs):
321 """Add the pxd track finding to the path"""
322 if not is_pxd_used(components):
323 return
324
325 if use_mc_truth:
326 # MC CKF needs MC matching information
327 path.add_module("MCRecoTracksMatcher", UsePXDHits=False,
328 UseSVDHits=is_svd_used(components), UseCDCHits=is_cdc_used(components),
329 mcRecoTracksStoreArrayName="MCRecoTracks",
330 prRecoTracksStoreArrayName=input_reco_tracks)
331
332 add_pxd_ckf(path, svd_cdc_reco_tracks=input_reco_tracks, pxd_reco_tracks=temporary_reco_tracks,
333 direction="backward", use_mc_truth=use_mc_truth, **kwargs)
334
335 if add_both_directions:
336 add_pxd_ckf(path, svd_cdc_reco_tracks=input_reco_tracks, pxd_reco_tracks=temporary_reco_tracks,
337 direction="forward", use_mc_truth=use_mc_truth, **kwargs)
338
339 path.add_module("RelatedTracksCombiner", CDCRecoTracksStoreArrayName=input_reco_tracks,
340 VXDRecoTracksStoreArrayName=temporary_reco_tracks, recoTracksStoreArrayName=output_reco_tracks)
341
342
343def add_pxd_cr_track_finding(path, components, input_reco_tracks, output_reco_tracks, use_mc_truth=False,
344 add_both_directions=False, temporary_reco_tracks="PXDRecoTracks", **kwargs):
345 """Add the pxd track finding to the path"""
346 if not is_pxd_used(components):
347 return
348
349 if use_mc_truth:
350 # MC CKF needs MC matching information
351 path.add_module("MCRecoTracksMatcher", UsePXDHits=False,
352 UseSVDHits=is_svd_used(components), UseCDCHits=is_cdc_used(components),
353 mcRecoTracksStoreArrayName="MCRecoTracks",
354 prRecoTracksStoreArrayName=input_reco_tracks)
355
356 add_cosmics_pxd_ckf(path, svd_cdc_reco_tracks=input_reco_tracks, pxd_reco_tracks=temporary_reco_tracks,
357 direction="backward", use_mc_truth=use_mc_truth, **kwargs)
358
359 if add_both_directions:
360 add_cosmics_pxd_ckf(path, svd_cdc_reco_tracks=input_reco_tracks, pxd_reco_tracks=temporary_reco_tracks,
361 direction="forward", use_mc_truth=use_mc_truth, **kwargs)
362
363 path.add_module("RelatedTracksCombiner", CDCRecoTracksStoreArrayName=input_reco_tracks,
364 VXDRecoTracksStoreArrayName=temporary_reco_tracks, recoTracksStoreArrayName=output_reco_tracks)
365
366
367def add_svd_track_finding(
368 path,
369 components,
370 input_reco_tracks,
371 output_reco_tracks,
372 svd_ckf_mode="SVD_after",
373 use_mc_truth=False,
374 add_both_directions=True,
375 temporary_reco_tracks="SVDRecoTracks",
376 temporary_svd_cdc_reco_tracks="SVDPlusCDCStandaloneRecoTracks",
377 use_svd_to_cdc_ckf=True,
378 prune_temporary_tracks=True,
379 add_mva_quality_indicator=False,
380 svd_standalone_mode="VXDTF2",
381 **kwargs,
382):
383 """
384 Add SVD track finding to the path.
385
386 :param path: The path to add the tracking reconstruction modules to
387 :param components: The list of geometry components in use or None for all components.
388 :param input_reco_tracks: Name of the StoreArray with the input reco tracks (usually from CDC) that are used in the
389 CKF track finding and are merged with the newly found SVD tracks into the ``output_reco_tracks``.
390 :param output_reco_tracks: Name of the StoreArray where the reco tracks outputted by the SVD track finding should be
391 stored.
392 :param svd_ckf_mode: String designating the mode of the CDC-to-SVD CKF, that is how it is combined with the SVD
393 standalone track finding. One of "SVD_after", "SVD_before", "SVD_before_with_second_ckf",
394 "only_ckf", "SVD_alone", "cosmics".
395 :param use_mc_truth: Add mc matching and use the MC information in the CKF (but not in the VXDTF2)
396 :param add_both_directions: Whether to add the CKF with both forward and backward extrapolation directions instead
397 of just one.
398 :param temporary_reco_tracks: Intermediate store array where the SVD tracks from the SVD standalone track finding
399 are stored, before they are merged with CDC tracks and extended via the CKF tracking.
400 :param temporary_svd_cdc_reco_tracks: Intermediate store array where the combination of ``temporary_reco_tracks``
401 (from SVD) and ``input_reco_tracks`` (from CDC standalone) is stored, before the CKF is applied.
402 It is only used if ``use_svd_to_cdc_ckf`` is true. Otherwise, the combination is stored directly in
403 ``output_reco_tracks``.
404 :param use_svd_to_cdc_ckf: Whether to enable the CKF extrapolation from the SVD into the CDC.
405 That CKF application is not affected by ``svd_ckf_mode``.
406 :param prune_temporary_tracks: Delete all hits expect the first and last from intermediate track objects.
407 :param add_mva_quality_indicator: Add the VXDQualityEstimatorMVA module to set the quality indicator
408 property for tracks from VXDTF2 standalone tracking
409 (ATTENTION: Standard triplet QI of VXDTF2 is replaced in this case
410 -> setting this option to 'True' will have some influence on the final track collection)
411 :param svd_standalone_mode: Which SVD standalone tracking is used.
412 Options are "VXDTF2", "SVDHough", "VXDTF2_and_SVDHough", and "SVDHough_and_VXDTF2".
413 Defaults to "VXDTF2"
414 """
415
416 if not is_svd_used(components):
417 return
418
419 if not input_reco_tracks:
420 # We do not have an input track store array. So lets just add vxdtf track finding
421 add_svd_standalone_tracking(path, components=["SVD"],
422 svd_standalone_mode=svd_standalone_mode,
423 reco_tracks=output_reco_tracks,
424 add_mva_quality_indicator=add_mva_quality_indicator)
425 return
426
427 if use_mc_truth:
428 # MC CKF needs MC matching information
429 path.add_module("MCRecoTracksMatcher", UsePXDHits=False, UseSVDHits=False,
430 UseCDCHits=is_cdc_used(components),
431 mcRecoTracksStoreArrayName="MCRecoTracks",
432 prRecoTracksStoreArrayName=input_reco_tracks)
433
434 if svd_ckf_mode == "SVD_before":
435 add_svd_standalone_tracking(path, components=["SVD"],
436 svd_standalone_mode=svd_standalone_mode,
437 reco_tracks=temporary_reco_tracks,
438 add_mva_quality_indicator=add_mva_quality_indicator)
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="backward", **kwargs)
441 if add_both_directions:
442 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
443 use_mc_truth=use_mc_truth, direction="forward", **kwargs)
444
445 elif svd_ckf_mode == "SVD_before_with_second_ckf":
446 add_svd_standalone_tracking(path, components=["SVD"],
447 svd_standalone_mode=svd_standalone_mode,
448 reco_tracks=temporary_reco_tracks,
449 add_mva_quality_indicator=add_mva_quality_indicator)
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="backward", **kwargs)
452 if add_both_directions:
453 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
454 use_mc_truth=use_mc_truth, direction="forward", **kwargs)
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="backward", **kwargs)
457 if add_both_directions:
458 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
459 use_mc_truth=use_mc_truth, direction="forward", **kwargs)
460
461 elif svd_ckf_mode == "only_ckf":
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="backward", **kwargs)
464 if add_both_directions:
465 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
466 use_mc_truth=use_mc_truth, direction="forward", **kwargs)
467
468 elif svd_ckf_mode == "SVD_after":
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="backward", **kwargs)
471 if add_both_directions:
472 add_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
473 use_mc_truth=use_mc_truth, direction="forward", **kwargs)
474
475 add_svd_standalone_tracking(path, components=["SVD"],
476 svd_standalone_mode=svd_standalone_mode,
477 reco_tracks=temporary_reco_tracks,
478 add_mva_quality_indicator=add_mva_quality_indicator)
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="backward", **kwargs)
481 if add_both_directions:
482 add_ckf_based_merger(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
483 use_mc_truth=use_mc_truth, direction="forward", **kwargs)
484
485 elif svd_ckf_mode == "SVD_alone":
486 add_svd_standalone_tracking(path, components=["SVD"],
487 svd_standalone_mode=svd_standalone_mode,
488 reco_tracks=temporary_reco_tracks,
489 add_mva_quality_indicator=add_mva_quality_indicator)
490 path.add_module('VXDCDCTrackMerger',
491 CDCRecoTrackColName=input_reco_tracks,
492 VXDRecoTrackColName=temporary_reco_tracks)
493
494 elif svd_ckf_mode == "cosmics":
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="backward", **kwargs)
497 if add_both_directions:
498 add_cosmics_svd_ckf(path, cdc_reco_tracks=input_reco_tracks, svd_reco_tracks=temporary_reco_tracks,
499 use_mc_truth=use_mc_truth, direction="forward", **kwargs)
500
501 else:
502 raise ValueError(f"Do not understand the svd_ckf_mode {svd_ckf_mode}")
503
504 if use_svd_to_cdc_ckf:
505 combined_svd_cdc_standalone_tracks = temporary_svd_cdc_reco_tracks
506 else:
507 combined_svd_cdc_standalone_tracks = output_reco_tracks
508
509 # Write out the combinations of tracks
510 path.add_module("RelatedTracksCombiner", VXDRecoTracksStoreArrayName=temporary_reco_tracks,
511 CDCRecoTracksStoreArrayName=input_reco_tracks,
512 recoTracksStoreArrayName=combined_svd_cdc_standalone_tracks)
513
514 if use_svd_to_cdc_ckf:
515 path.add_module("ToCDCCKF",
516 inputWireHits="CDCWireHitVector",
517 inputRecoTrackStoreArrayName=combined_svd_cdc_standalone_tracks,
518 relatedRecoTrackStoreArrayName="CKFCDCRecoTracks",
519 relationCheckForDirection="backward",
520 ignoreTracksWithCDChits=True,
521 outputRecoTrackStoreArrayName="CKFCDCRecoTracks",
522 outputRelationRecoTrackStoreArrayName=combined_svd_cdc_standalone_tracks,
523 writeOutDirection="backward",
524 stateBasicFilterParameters={"maximalHitDistance": 0.15},
525 pathFilter="arc_length",
526 maximalLayerJump=4)
527
528 path.add_module("CDCCKFTracksCombiner",
529 CDCRecoTracksStoreArrayName="CKFCDCRecoTracks",
530 VXDRecoTracksStoreArrayName=combined_svd_cdc_standalone_tracks,
531 recoTracksStoreArrayName=output_reco_tracks)
532
533 if prune_temporary_tracks:
534 for temp_reco_track in [combined_svd_cdc_standalone_tracks, "CKFCDCRecoTracks"]:
535 path.add_module('PruneRecoTracks', storeArrayName=temp_reco_track)
536
537
538def add_svd_standalone_tracking(path,
539 components=["SVD"],
540 svd_clusters="",
541 svd_standalone_mode="VXDTF2",
542 reco_tracks="SVDRecoTracks",
543 add_mva_quality_indicator=False,
544 suffix=""):
545 """
546 Convenience function to add the SVD standalone tracking
547
548 :param path: basf2 path
549 :param components: components to use, defaults to SVD
550 :param svd_clusters: Name of the SVDClusters StoreArray used for tracking
551 :param svd_standalone_mode: Which SVD standalone tracking is used.
552 Options are "VXDTF2", "SVDHough", "VXDTF2_and_SVDHough", and "SVDHough_and_VXDTF2".
553 Defaults to "VXDTF2"
554 :param reco_tracks: In case the only SVD standalone tracking is performed, these are the final RecoTracks,
555 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.
556 :param add_mva_quality_indicator: Add the VXDQualityEstimatorMVA module to set the quality indicator
557 property for tracks from VXDTF2 standalone tracking
558 (ATTENTION: Standard triplet QI of VXDTF2 is replaced in this case
559 -> setting this option to 'True' will have some influence on the final track collection)
560 :param suffix: all names of intermediate Storearrays will have the suffix appended. Useful in cases someone needs to
561 put several instances of track finding in one path.
562 """
563 if svd_standalone_mode == "VXDTF2":
564 add_vxd_track_finding_vxdtf2(path, components=components, svd_clusters=svd_clusters, reco_tracks=reco_tracks,
565 add_mva_quality_indicator=add_mva_quality_indicator, suffix=suffix)
566
567 elif svd_standalone_mode == "SVDHough":
568 add_svd_hough_tracking(path, reco_tracks=reco_tracks, suffix=suffix)
569
570 elif svd_standalone_mode == "VXDTF2_and_SVDHough":
571 add_vxd_track_finding_vxdtf2(path,
572 components=components,
573 svd_clusters=svd_clusters,
574 nameSPTCs="SPTrackCands"+"VXDTF2",
575 reco_tracks=reco_tracks+"VXDTF2",
576 add_mva_quality_indicator=add_mva_quality_indicator,
577 suffix=suffix)
578 add_svd_hough_tracking(path,
579 reco_tracks=reco_tracks+"Hough",
580 svd_space_point_track_candidates="SPTrackCands"+"Hough",
581 suffix=suffix)
582
583 path.add_module('RecoTrackStoreArrayCombiner',
584 Temp1RecoTracksStoreArrayName=reco_tracks+"VXDTF2",
585 Temp2RecoTracksStoreArrayName=reco_tracks+"Hough",
586 recoTracksStoreArrayName=reco_tracks)
587 path.add_module('PruneRecoTracks', storeArrayName=reco_tracks+"VXDTF2")
588 path.add_module('PruneRecoTracks', storeArrayName=reco_tracks+"Hough")
589
590 elif svd_standalone_mode == "SVDHough_and_VXDTF2":
591 add_svd_hough_tracking(path,
592 reco_tracks=reco_tracks+"Hough",
593 svd_space_point_track_candidates="SPTrackCands"+"Hough",
594 suffix=suffix)
595 add_vxd_track_finding_vxdtf2(path,
596 components=components,
597 svd_clusters=svd_clusters,
598 nameSPTCs="SPTrackCands"+"VXDTF2",
599 reco_tracks=reco_tracks+"VXDTF2",
600 add_mva_quality_indicator=add_mva_quality_indicator,
601 suffix=suffix)
602
603 path.add_module('RecoTrackStoreArrayCombiner',
604 Temp1RecoTracksStoreArrayName=reco_tracks+"Hough",
605 Temp2RecoTracksStoreArrayName=reco_tracks+"VXDTF2",
606 recoTracksStoreArrayName=reco_tracks)
607 path.add_module('PruneRecoTracks', storeArrayName=reco_tracks+"Hough")
608 path.add_module('PruneRecoTracks', storeArrayName=reco_tracks+"VXDTF2")
609
610 else:
611 raise ValueError(f"Do not understand the svd_standalone_mode {svd_standalone_mode}")
612
613
614def add_cdc_track_finding(path, output_reco_tracks="RecoTracks", with_ca=False,
615 use_second_hits=False, add_mva_quality_indicator=True,
616 reattach_hits=False):
617 """
618 Convenience function for adding all cdc track finder modules
619 to the path.
620
621 The result is a StoreArray with name @param reco_tracks full of RecoTracks (not TrackCands any more!).
622 Use the GenfitTrackCandidatesCreator Module to convert back.
623
624 :param path: basf2 path
625 :param output_reco_tracks: Name of the output RecoTracks. Defaults to RecoTracks.
626 :param use_second_hits: If true, the second hit information will be used in the CDC track finding.
627 :param add_mva_quality_indicator: Add the TFCDC_TrackQualityEstimator module to set the CDC quality
628 indicator property of the CDC ``output_reco_tracks``
629 :param cdc_quality_estimator_weightfile: Weightfile identifier for the TFCDC_TrackQualityEstimator
630 :param reattach_hits: if true, use the ReattachCDCWireHitsToRecoTracks module at the end of the CDC track finding
631 to readd hits with bad ADC or TOT rejected by the TFCDC_WireHitPreparer module.
632 """
633 # add EventLevelTrackinginfo for logging errors
634 if 'RegisterEventLevelTrackingInfo' not in path:
635 path.add_module('RegisterEventLevelTrackingInfo')
636
637 # Init the geometry for cdc tracking and the hits and cut low ADC hits
638 path.add_module("TFCDC_WireHitPreparer",
639 wirePosition="aligned",
640 useSecondHits=use_second_hits,
641 flightTimeEstimation="outwards",
642 filter="mva",
643 filterParameters={'DBPayloadName': 'trackfindingcdc_WireHitBackgroundDetectorParameters'})
644
645 # Constructs clusters
646 path.add_module("TFCDC_ClusterPreparer",
647 ClusterFilter="all",
648 ClusterFilterParameters={})
649
650 # Find segments within the clusters
651 path.add_module("TFCDC_SegmentFinderFacetAutomaton",
652 SegmentRelationFilterParameters={'DBPayloadName': 'trackfindingcdc_RealisticSegmentRelationFilterParameters'})
653
654 # Find axial tracks
655 path.add_module("TFCDC_AxialTrackFinderLegendre")
656
657 # Improve the quality of the axial tracks
658 path.add_module("TFCDC_TrackQualityAsserter",
659 corrections=["B2B"])
660
661 # Find the stereo hits to those axial tracks
662 path.add_module('TFCDC_StereoHitFinder')
663
664 # Combine segments with axial tracks
665 path.add_module('TFCDC_SegmentTrackCombiner',
666 segmentTrackFilter="mva",
667 segmentTrackFilterParameters={'DBPayloadName': 'trackfindingcdc_SegmentTrackFilterParameters'},
668 trackFilter="mva",
669 trackFilterParameters={'DBPayloadName': 'trackfindingcdc_TrackFilterParameters'})
670
671 output_tracks = "CDCTrackVector"
672
673 if with_ca:
674 output_tracks = "CombinedCDCTrackVector"
675 path.add_module("TFCDC_TrackFinderSegmentPairAutomaton",
676 tracks="CDCTrackVector2")
677
678 # Overwrites the origin CDCTrackVector
679 path.add_module("TFCDC_TrackCombiner",
680 inputTracks="CDCTrackVector",
681 secondaryInputTracks="CDCTrackVector2",
682 tracks=output_tracks)
683
684 # Improve the quality of all tracks and output
685 path.add_module("TFCDC_TrackQualityAsserter",
686 inputTracks=output_tracks,
687 corrections=[
688 "LayerBreak",
689 "OneSuperlayer",
690 "Small",
691 ])
692
693 if with_ca:
694 # Add curlers in the axial inner most superlayer
695 path.add_module("TFCDC_TrackCreatorSingleSegments",
696 inputTracks=output_tracks,
697 MinimalHitsBySuperLayerId={0: 15})
698
699 if add_mva_quality_indicator:
700 # Add CDC-specific mva method to set the quality indicator for the CDC tracks
701 path.add_module(
702 "TFCDC_TrackQualityEstimator",
703 inputTracks=output_tracks,
704 filter='mva',
705 filterParameters={'DBPayloadName': 'trackfindingcdc_TrackQualityEstimatorParameters'},
706 deleteTracks=True,
707 resetTakenFlag=True
708 )
709
710 # Export CDCTracks to RecoTracks representation
711 path.add_module("TFCDC_TrackExporter",
712 inputTracks=output_tracks,
713 RecoTracksStoreArrayName="CDCRecoTracksBeforeReattaching" if reattach_hits else output_reco_tracks)
714
715 if reattach_hits:
716 # The ReattachCDCWireHitsToRecoTracks module (below) requires the SetupGenfitExtrapolation module
717 if 'SetupGenfitExtrapolation' not in path:
718 # Prepare Genfit extrapolation
719 path.add_module('SetupGenfitExtrapolation')
720
721 # Loop over low-ADC/TOT CDCWireHits and RecoTracks and reattach the hits to the tracks if they are close enough
722 path.add_module("ReattachCDCWireHitsToRecoTracks",
723 inputRecoTracksStoreArrayName="CDCRecoTracksBeforeReattaching",
724 outputRecoTracksStoreArrayName=output_reco_tracks)
725
726 # Correct time seed (only necessary for the CDC tracks)
727 path.add_module("IPTrackTimeEstimator",
728 useFittedInformation=False,
729 recoTracksStoreArrayName=output_reco_tracks)
730
731 # run fast t0 estimation from CDC hits only
732 path.add_module("CDCHitBasedT0Extraction")
733
734 # prepare mdst event level info
735 path.add_module("CDCTrackingEventLevelMdstInfoFillerFromHits")
736 path.add_module("CDCTrackingEventLevelMdstInfoFillerFromSegments")
737
738
739def add_eclcdc_track_finding(path, components, output_reco_tracks="RecoTracks", prune_temporary_tracks=True):
740 """
741 Convenience function for adding all track finder modules to the path that are based on ecl seeds.
742
743 The result is a StoreArray with name @param reco_tracks full of RecoTracks.
744 Use the GenfitTrackCandidatesCreator Module to convert back.
745
746 :param path: basf2 path
747 :param components: the list of geometry components in use or None for all components.
748 :param output_reco_tracks: Name of the output RecoTracks. Defaults to RecoTracks.
749 :param pruneTracks: Delete all hits expect the first and the last from the found tracks.
750 """
751 if not is_cdc_used(components) or not is_ecl_used(components):
752 return
753
754 ecl_cdc_reco_tracks = "ECLCDCRecoTracks"
755
756 if not is_svd_used(components):
757 ecl_cdc_reco_tracks = output_reco_tracks
758
759 # collections that will be pruned
760 temporary_reco_track_list = []
761
762 path.add_module("ToCDCFromEclCKF",
763 inputWireHits="CDCWireHitVector",
764 minimalEnRequirementCluster=0.3,
765 eclSeedRecoTrackStoreArrayName='EclSeedRecoTracks',
766 hitFindingDirection="backward",
767 outputRecoTrackStoreArrayName="CDCRecoTracksFromEcl",
768 outputRelationRecoTrackStoreArrayName="EclSeedRecoTracks",
769 writeOutDirection="forward",
770 stateBasicFilterParameters={"maximalHitDistance": 7.5, "maximalHitDistanceEclSeed": 75.0},
771 stateExtrapolationFilterParameters={"direction": "backward"},
772 pathFilter="arc_length_fromEcl",
773 inputECLshowersStoreArrayName="ECLShowers",
774 trackFindingDirection="backward",
775 setTakenFlag=False,
776 seedComponent="ECL"
777 )
778
779 path.add_module("ToCDCCKF",
780 inputWireHits="CDCWireHitVector",
781 inputRecoTrackStoreArrayName="CDCRecoTracksFromEcl",
782 relatedRecoTrackStoreArrayName=ecl_cdc_reco_tracks,
783 relationCheckForDirection="backward",
784 outputRecoTrackStoreArrayName=ecl_cdc_reco_tracks,
785 outputRelationRecoTrackStoreArrayName="CDCRecoTracksFromEcl",
786 writeOutDirection="backward",
787 stateBasicFilterParameters={"maximalHitDistance": 0.75},
788 stateExtrapolationFilterParameters={"direction": "forward"},
789 pathFilter="arc_length",
790 seedComponent="ECL"
791 )
792 # "EclSeedRecoTracks" don't have to be added to the list as these do not contain any hits
793 temporary_reco_track_list.append('CDCRecoTracksFromEcl')
794
795 # Do the following modules have to be added as these are executed already after
796 # the CDC standalone?
797 # If so: they also have to be included in the new SVD->CDC CKF (see add_svd_track_finding(..) above)
798
799 # Correct time seed (only necessary for the CDC tracks)
800 # path.add_module("IPTrackTimeEstimator",
801 # useFittedInformation=False,
802 # recoTracksStoreArrayName=ecl_cdc_reco_tracks)
803
804 # run fast t0 estimation from CDC hits only
805 # path.add_module("CDCHitBasedT0Extraction")
806
807 # prepare mdst event level info
808 # path.add_module("CDCTrackingEventLevelMdstInfoFiller")
809
810 if is_svd_used(components):
811 add_svd_track_finding(path, components=components, input_reco_tracks=ecl_cdc_reco_tracks,
812 output_reco_tracks=output_reco_tracks, use_mc_truth=False,
813 svd_ckf_mode="only_ckf", add_both_directions=False,
814 temporary_reco_tracks="ECLSVDRecoTracks", use_svd_to_cdc_ckf=False,
815 prune_temporary_tracks=prune_temporary_tracks)
816 temporary_reco_track_list.append(ecl_cdc_reco_tracks)
817 temporary_reco_track_list.append('ECLSVDRecoTracks')
818
819 if prune_temporary_tracks:
820 for temporary_reco_track_name in temporary_reco_track_list:
821 if temporary_reco_track_name != output_reco_tracks:
822 path.add_module('PruneRecoTracks', storeArrayName=temporary_reco_track_name)
823
824
825def add_cdc_cr_track_finding(path, output_reco_tracks="RecoTracks", trigger_point=(0, 0, 0), merge_tracks=True,
826 use_second_cdc_hits=False):
827 """
828 Convenience function for adding all cdc track finder modules currently dedicated for the CDC-TOP testbeam
829 to the path.
830
831 The result is a StoreArray with name @param reco_tracks full of RecoTracks (not TrackCands any more!).
832
833 Arguments
834 ---------
835 path: basf2.Path
836 The path to be filled
837 output_reco_tracks: str
838 Name of the output RecoTracks. Defaults to RecoTracks.
839 merge_tracks: bool
840 The upper and lower half of the tracks should be merged together in one track
841 use_second_hits: bool
842 If true, the second hit information will be used in the CDC track finding.
843 """
844
845 # Init the geometry for cdc tracking and the hits
846 path.add_module("TFCDC_WireHitPreparer",
847 useSecondHits=use_second_cdc_hits,
848 flightTimeEstimation="downwards",
849 filter="cuts_from_DB",
850 triggerPoint=trigger_point)
851
852 # Constructs clusters and reduce background hits
853 path.add_module("TFCDC_ClusterPreparer",
854 ClusterFilter="mva_bkg",
855 ClusterFilterParameters={'DBPayloadName': 'trackfindingcdc_ClusterFilterParameters'})
856
857 # Find segments within the clusters
858 path.add_module("TFCDC_SegmentFinderFacetAutomaton",
859 SegmentOrientation="downwards")
860
861 # Find axial tracks
862 path.add_module("TFCDC_AxialTrackFinderLegendre")
863
864 # Improve the quality of the axial tracks
865 path.add_module("TFCDC_TrackQualityAsserter",
866 corrections=["B2B"])
867
868 # Find the stereo hits to those axial tracks
869 path.add_module('TFCDC_StereoHitFinder')
870
871 # Combine segments with axial tracks
872 path.add_module('TFCDC_SegmentTrackCombiner',
873 segmentTrackFilter="mva",
874 segmentTrackFilterParameters={'DBPayloadName': 'trackfindingcdc_SegmentTrackFilterParameters'},
875 trackFilter="mva",
876 trackFilterParameters={'DBPayloadName': 'trackfindingcdc_TrackFilterParameters'})
877
878 # Improve the quality of all tracks and output
879 path.add_module("TFCDC_TrackQualityAsserter",
880 corrections=["LayerBreak", "OneSuperlayer", "Small"],
881 )
882
883 # Flip track orientation to always point downwards
884 path.add_module("TFCDC_TrackOrienter",
885 inputTracks="CDCTrackVector",
886 tracks="OrientedCDCTrackVector",
887 TrackOrientation="downwards",
888 )
889
890 output_tracks = "OrientedCDCTrackVector"
891
892 if merge_tracks:
893 # Merge tracks together if needed
894 path.add_module("TFCDC_TrackLinker",
895 inputTracks="OrientedCDCTrackVector",
896 tracks="MergedCDCTrackVector",
897 filter="phi",
898 )
899 output_tracks = "MergedCDCTrackVector"
900
901 # However, we also want to export the non merged tracks
902 # Correct time seed - assumes velocity near light speed
903 path.add_module("TFCDC_TrackFlightTimeAdjuster",
904 inputTracks="OrientedCDCTrackVector",
905 )
906
907 # Export CDCTracks to RecoTracks representation
908 path.add_module("TFCDC_TrackExporter",
909 inputTracks="OrientedCDCTrackVector",
910 RecoTracksStoreArrayName="NonMergedRecoTracks")
911
912 # Correct time seed - assumes velocity near light speed
913 path.add_module("TFCDC_TrackFlightTimeAdjuster",
914 inputTracks=output_tracks,
915 )
916
917 # Export CDCTracks to RecoTracks representation
918 path.add_module("TFCDC_TrackExporter",
919 inputTracks=output_tracks,
920 RecoTracksStoreArrayName=output_reco_tracks)
921
922 # run fast t0 estimation from CDC hits only
923 path.add_module("CDCHitBasedT0Extraction")
924
925
926def add_vxd_track_finding_vxdtf2(
927 path,
928 svd_clusters="",
929 reco_tracks="RecoTracks",
930 nameSPTCs='SPTrackCands',
931 components=None,
932 suffix="",
933 useTwoStepSelection=True,
934 PXDminSVDSPs=3,
935 sectormap_file=None,
936 custom_setup_name=None,
937 min_SPTC_quality=0.,
938 filter_overlapping=True,
939 add_mva_quality_indicator=False,
940):
941 """
942 Convenience function for adding all vxd track finder Version 2 modules
943 to the path.
944
945 The result is a StoreArray with name @param reco_tracks full of RecoTracks (not TrackCands any more!).
946 Use the GenfitTrackCandidatesCreator Module to convert back.
947
948 :param path: basf2 path
949 :param svd_clusters: SVDCluster collection name
950 :param reco_tracks: Name of the output RecoTracks, Defaults to RecoTracks.
951 :param nameSPTCs: Name of the SpacePointTrackCands StoreArray
952 :param components: List of the detector components to be used in the reconstruction. Defaults to None which means
953 all components.
954 :param suffix: all names of intermediate Storearrays will have the suffix appended. Useful in cases someone needs to
955 put several instances of track finding in one path.
956 :param useTwoStepSelection: if True Families will be defined during path creation and will be used to create only
957 the best candidate per family.
958 :param PXDminSVDSPs: When using PXD require at least this number of SVD SPs for the SPTCs
959 :param sectormap_file: if set to a finite value, a file will be used instead of the sectormap in the database.
960 :param custom_setup_name: Set a custom setup name for the tree in the sector map.
961 :param min_SPTC_quality: minimal qualityIndicator value to keeps SPTCs after the QualityEstimation.
962 0 means no cut. Default: 0
963 :param filter_overlapping: Whether to use SVDOverlapResolver, Default: True
964 :param add_mva_quality_indicator: Whether to use the MVA Quality Estimator module for VXDTF2 tracks to set the
965 quality_indicator property of the found ``reco_tracks``. Default: False.
966 """
967
970
971 # setting different for pxd and svd:
972 if is_pxd_used(components):
973 setup_name = "SVDPXDDefault"
974 db_sec_map_file = "VXDSectorMap_v000.root"
975 use_pxd = True
976 else:
977 setup_name = "SVDOnlyDefault"
978 db_sec_map_file = "SVDSectorMap_v000.root"
979 use_pxd = False
980
981
985
986 # setup the event level tracking info to log errors and stuff
987 nameTrackingInfoModule = "RegisterEventLevelTrackingInfo" + suffix
988 nameEventTrackingInfo = "EventLevelTrackingInfo" + suffix
989 if nameTrackingInfoModule not in path:
990 # Use modified name of module and created StoreObj as module might be added twice (PXDDataReduction)
991 registerEventlevelTrackingInfo = register_module('RegisterEventLevelTrackingInfo')
992 registerEventlevelTrackingInfo.set_name(nameTrackingInfoModule)
993 registerEventlevelTrackingInfo.param('EventLevelTrackingInfoName', nameEventTrackingInfo)
994 path.add_module(registerEventlevelTrackingInfo)
995
996 nameSPs = 'SpacePoints' + suffix
997
998 pxdSPCreatorName = 'PXDSpacePointCreator' + suffix
999 if pxdSPCreatorName not in [e.name() for e in path.modules()]:
1000 if use_pxd:
1001 spCreatorPXD = register_module('PXDSpacePointCreator')
1002 spCreatorPXD.set_name(pxdSPCreatorName)
1003 spCreatorPXD.param('NameOfInstance', 'PXDSpacePoints')
1004 spCreatorPXD.param('SpacePoints', "PXD" + nameSPs)
1005 path.add_module(spCreatorPXD)
1006
1007 # SecMap Bootstrap
1008 secMapBootStrap = register_module('SectorMapBootstrap')
1009 secMapBootStrap.param('ReadSectorMap', sectormap_file is not None) # read from file
1010 secMapBootStrap.param('ReadSecMapFromDB', sectormap_file is None) # this will override ReadSectorMap
1011 secMapBootStrap.param('SectorMapsInputFile', sectormap_file or db_sec_map_file)
1012 secMapBootStrap.param('SetupToRead', custom_setup_name or setup_name)
1013 secMapBootStrap.param('WriteSectorMap', False)
1014 path.add_module(secMapBootStrap)
1015
1016
1020
1021 spacePointArrayNames = ["SVD" + nameSPs]
1022 if use_pxd:
1023 spacePointArrayNames += ["PXD" + nameSPs]
1024
1025 nameSegNet = 'SegmentNetwork' + suffix
1026
1027 segNetProducer = register_module('SegmentNetworkProducer')
1028 segNetProducer.param('NetworkOutputName', nameSegNet)
1029 segNetProducer.param('SpacePointsArrayNames', spacePointArrayNames)
1030 segNetProducer.param('sectorMapName', custom_setup_name or setup_name)
1031 segNetProducer.param('EventLevelTrackingInfoName', nameEventTrackingInfo)
1032 path.add_module(segNetProducer)
1033
1034
1038
1039 # append a suffix to the storearray name
1040 nameSPTCs += suffix
1041
1042 trackFinder = register_module('TrackFinderVXDCellOMat')
1043 trackFinder.param('NetworkName', nameSegNet)
1044 trackFinder.param('SpacePointTrackCandArrayName', nameSPTCs)
1045 trackFinder.param('printNetworks', False)
1046 trackFinder.param('setFamilies', useTwoStepSelection)
1047 trackFinder.param('selectBestPerFamily', useTwoStepSelection)
1048 trackFinder.param('xBestPerFamily', 30)
1049 trackFinder.param('EventLevelTrackingInfoName', nameEventTrackingInfo)
1050 path.add_module(trackFinder)
1051
1052 if useTwoStepSelection:
1053 subSetModule = register_module('AddVXDTrackCandidateSubSets')
1054 subSetModule.param('NameSpacePointTrackCands', nameSPTCs)
1055 path.add_module(subSetModule)
1056
1057
1061
1062 # When using PXD require at least PXDminSVDSPs SVD SPs for the SPTCs
1063 if use_pxd:
1064 pxdSVDCut = register_module('PXDSVDCut')
1065 pxdSVDCut.param('minSVDSPs', PXDminSVDSPs)
1066 pxdSVDCut.param('SpacePointTrackCandsStoreArrayName', nameSPTCs)
1067 path.add_module(pxdSVDCut)
1068
1069 if add_mva_quality_indicator:
1070 path.add_module(
1071 "VXDQualityEstimatorMVA",
1072 SpacePointTrackCandsStoreArrayName=nameSPTCs,
1073 )
1074 else:
1075 path.add_module(
1076 'QualityEstimatorVXD',
1077 EstimationMethod='tripletFit',
1078 SpacePointTrackCandsStoreArrayName=nameSPTCs,
1079 )
1080
1081 if min_SPTC_quality > 0.:
1082 qualityIndicatorCutter = register_module('VXDTrackCandidatesQualityIndicatorCutter')
1083 qualityIndicatorCutter.param('minRequiredQuality', min_SPTC_quality)
1084 qualityIndicatorCutter.param('NameSpacePointTrackCands', nameSPTCs)
1085 path.add_module(qualityIndicatorCutter)
1086
1087 # will discard track candidates (with low quality estimators) if the number of TC is above threshold
1088 maxCandidateSelection = register_module('BestVXDTrackCandidatesSelector')
1089 maxCandidateSelection.param('NameSpacePointTrackCands', nameSPTCs)
1090 maxCandidateSelection.param('NewNameSpacePointTrackCands', nameSPTCs)
1091 maxCandidateSelection.param('SubsetCreation', False)
1092 path.add_module(maxCandidateSelection)
1093
1094 # Properties
1095 vIPRemover = register_module('SPTCvirtualIPRemover')
1096 vIPRemover.param('tcArrayName', nameSPTCs)
1097 # want to remove virtualIP for any track length
1098 vIPRemover.param('maxTCLengthForVIPKeeping', 0)
1099 path.add_module(vIPRemover)
1100
1101
1105
1106 if filter_overlapping:
1107 overlapResolver = register_module('SVDOverlapResolver')
1108 overlapResolver.param('NameSpacePointTrackCands', nameSPTCs)
1109 overlapResolver.param('ResolveMethod', 'greedy') # other option is 'hopfield'
1110 overlapResolver.param('NameSVDClusters', svd_clusters)
1111 path.add_module(overlapResolver)
1112
1113
1117
1118 momSeedRetriever = register_module('SPTCmomentumSeedRetriever')
1119 momSeedRetriever.param('tcArrayName', nameSPTCs)
1120 path.add_module(momSeedRetriever)
1121
1122 converter = register_module('SPTC2RTConverter')
1123 converter.param('recoTracksStoreArrayName', reco_tracks)
1124 converter.param('spacePointsTCsStoreArrayName', nameSPTCs)
1125 converter.param('svdClustersName', svd_clusters)
1126 converter.param('svdHitsStoreArrayName', svd_clusters)
1127 path.add_module(converter)
1128
1129
1130def add_svd_hough_tracking(path,
1131 svd_space_points='SVDSpacePoints',
1132 svd_clusters='SVDClusters',
1133 reco_tracks='RecoTracks',
1134 svd_space_point_track_candidates='SPTrackCands',
1135 suffix=''):
1136 """
1137 Convenience function to add the SVDHoughTracking to the path.
1138 :param path: The path to add the SVDHoughTracking module to.
1139 :param svd_space_points: Name of the StoreArray containing the SVDSpacePoints
1140 :param svd_clusters: Name of the StoreArray containing the SVDClusters
1141 :param reco_tracks: Name of the StoreArray containing the RecoTracks
1142 :param svd_space_point_track_candidates: Name of the StoreArray containing the SpacePointTrackCandidates
1143 :param suffix: all names of intermediate StoreArrays will have the suffix appended. Useful in cases someone needs to
1144 put several instances of track finding in one path.
1145 """
1146
1147 path.add_module('SVDHoughTracking',
1148 SVDSpacePointStoreArrayName=svd_space_points + suffix,
1149 SVDClustersStoreArrayName=svd_clusters + suffix,
1150 finalOverlapResolverNameSVDClusters=svd_clusters + suffix,
1151 refinerOverlapResolverNameSVDClusters=svd_clusters + suffix,
1152 RecoTracksStoreArrayName=reco_tracks + suffix,
1153 SVDSpacePointTrackCandsStoreArrayName=svd_space_point_track_candidates + suffix,
1154 relationFilter='angleAndTime',
1155 twoHitUseNBestHits=4,
1156 threeHitUseNBestHits=3,
1157 fourHitUseNBestHits=3,
1158 fiveHitUseNBestHits=2,
1159 )
1160
1161
1162def is_svd_used(components):
1163 """Return true, if the SVD is present in the components list"""
1164 return components is None or 'SVD' in components
1165
1166
1167def is_pxd_used(components):
1168 """Return true, if the PXD is present in the components list"""
1169 return components is None or 'PXD' in components
1170
1171
1172def is_cdc_used(components):
1173 """Return true, if the CDC is present in the components list"""
1174 return components is None or 'CDC' in components
1175
1176
1177def is_ecl_used(components):
1178 """Return true, if the ECL is present in the components list"""
1179 return components is None or 'ECL' in components
1180