Belle II Software  release-06-01-15
__init__.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 import basf2 as b2
13 
14 # Many scripts import these functions from `tracking`, so leave these imports here
15 from tracking.path_utils import ( # noqa
16  add_cdc_cr_track_finding,
17  add_cdc_track_finding,
18  add_cr_track_fit_and_track_creator,
19  add_eclcdc_track_finding,
20  add_geometry_modules,
21  add_hit_preparation_modules,
22  add_mc_matcher,
23  add_prune_tracks,
24  add_pxd_cr_track_finding,
25  add_pxd_track_finding,
26  add_svd_track_finding,
27  add_track_fit_and_track_creator,
28  add_prefilter_track_fit_and_track_creator,
29  add_postfilter_track_fit,
30  add_vxd_track_finding_vxdtf2,
31  is_cdc_used,
32  is_ecl_used,
33  is_pxd_used,
34  is_svd_used,
35  use_local_sectormap,
36 )
37 
38 
39 def add_tracking_reconstruction(path, components=None, pruneTracks=False, skipGeometryAdding=False,
40  mcTrackFinding=False, trackFitHypotheses=None,
41  reco_tracks="RecoTracks", prune_temporary_tracks=True, fit_tracks=True,
42  use_second_cdc_hits=False, skipHitPreparerAdding=False,
43  use_svd_to_cdc_ckf=True, use_ecl_to_cdc_ckf=False,
44  add_cdcTrack_QI=True, add_vxdTrack_QI=False, add_recoTrack_QI=False):
45  """
46  This function adds the **standard tracking reconstruction** modules
47  to a path:
48 
49  #. first we find tracks using the CDC hits only, see :ref:`CDC Track Finding<tracking_trackFindingCDC>`
50  #. CDC tracks are extrapolated to SVD and SVD hits are attached, see :ref:`CDC to SVD CKF<tracking_cdc2svd_ckf>`
51  #. remaining SVD hits are used to find SVD tracks, see :ref:`SVD Track Finding<tracking_trackFindingSVD>`
52  #. SVD tracks are extrapolated to CDC to attach CDC hits, see :ref:`SVD to CDC CKF<tracking_svd2cdc_ckf>`
53  #. SVD and CDC tracks are merged and fitted, see :ref:`Track Fitting<tracking_trackFitting>`
54  #. merged SVD+CDC tracks are extrapolated to PXD to attach PXD hits, see :ref:`SVD to PXD CKF<tracking_svd2pxd_ckf>`
55 
56  .. note::
57 
58  PXD hits are not available on HLT. At the end of the tracking chain on HLT we have the\
59  :ref:`PXD Region Of Interest Finding<tracking_pxdDataReduction>`, that consists of extrapolating\
60  the tracks on the PXD sensors and defining regions in which we expect to find the hit.\
61  Only fired pixels inside these regions reach Event Builder 2.
62 
63  #. after all the tracks from the IP are found, we look for special classes of tracks,\
64  in particular we search for displaced vertices to reconstruct K-short, Lambda and\
65  photon-conversions, see :ref:`V0 Finding<tracking_v0Finding>`
66 
67  .. note::
68 
69  this last step is not run on HLT
70 
71 
72  :param path: the path to add the tracking reconstruction modules to
73  :param components: the list of geometry components in use or None for all components.
74  :param pruneTracks: if true, delete all hits except the first and the last in the found tracks.
75  :param skipGeometryAdding: (advanced flag) the tracking modules need the geometry module and will add it,
76  if it is not already present in the path. In a setup with multiple (conditional) paths however, it can not
77  determine, if the geometry is already loaded. This flag can be used o just turn off the geometry adding at
78  all (but you will have to add it on your own then).
79  :param skipHitPreparerAdding: (advanced flag) if true, do not add the hit preparation (esp. VXD cluster creation
80  modules. This is useful if they have been added before already.
81  :param mcTrackFinding: if true, use the MC track finders instead of the realistic ones.
82  :param reco_tracks: name of the StoreArray where the reco tracks should be stored
83  :param prune_temporary_tracks: if false, store all information of the single CDC and VXD tracks before merging.
84  If true, prune them.
85  :param fit_tracks: if false, the final track find and the TrackCreator module will no be executed
86  :param use_second_cdc_hits: if true, the second hit information will be used in the CDC track finding.
87  :param trackFitHypotheses: which pdg hypothesis to fit. Defaults to [211, 321, 2212].
88  :param use_svd_to_cdc_ckf: if true, add SVD to CDC CKF module.
89  :param use_ecl_to_cdc_ckf: if true, add ECL to CDC CKF module.
90  :param add_cdcTrack_QI: if true, add the MVA track quality estimation
91  to the path that sets the quality indicator property of the found CDC standalone tracks
92  :param add_vxdTrack_QI: if true, add the MVA track quality estimation
93  to the path that sets the quality indicator property of the found VXDTF2 tracks
94  (ATTENTION: Standard triplet QI of VXDTF2 is replaced in this case
95  -> setting this option to 'True' will have some influence on the final track collection)
96  :param add_recoTrack_QI: if true, add the MVA track quality estimation
97  to the path that sets the quality indicator property of all found reco tracks
98  (Both other QIs needed as input.)
99  """
100 
101  add_prefilter_tracking_reconstruction(
102  path,
103  components=components,
104  skipGeometryAdding=skipGeometryAdding,
105  mcTrackFinding=mcTrackFinding,
106  trackFitHypotheses=trackFitHypotheses,
107  reco_tracks=reco_tracks,
108  prune_temporary_tracks=prune_temporary_tracks,
109  fit_tracks=fit_tracks,
110  use_second_cdc_hits=use_second_cdc_hits,
111  skipHitPreparerAdding=skipHitPreparerAdding,
112  use_svd_to_cdc_ckf=use_svd_to_cdc_ckf,
113  use_ecl_to_cdc_ckf=use_ecl_to_cdc_ckf,
114  add_cdcTrack_QI=add_cdcTrack_QI,
115  add_vxdTrack_QI=add_vxdTrack_QI,
116  add_recoTrack_QI=add_recoTrack_QI)
117 
118  add_postfilter_tracking_reconstruction(path,
119  components=components,
120  pruneTracks=pruneTracks,
121  fit_tracks=fit_tracks,
122  reco_tracks=reco_tracks,
123  prune_temporary_tracks=prune_temporary_tracks)
124 
125 
126 def add_prefilter_tracking_reconstruction(path, components=None, skipGeometryAdding=False,
127  mcTrackFinding=False, trackFitHypotheses=None,
128  reco_tracks="RecoTracks", prune_temporary_tracks=True, fit_tracks=True,
129  use_second_cdc_hits=False, skipHitPreparerAdding=False,
130  use_svd_to_cdc_ckf=True, use_ecl_to_cdc_ckf=False,
131  add_cdcTrack_QI=True, add_vxdTrack_QI=False, add_recoTrack_QI=False):
132  """
133  This function adds the tracking reconstruction modules required to calculate HLT filter decision
134  to a path.
135 
136  :param path: The path to add the tracking reconstruction modules to
137  :param components: the list of geometry components in use or None for all components.
138  :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module and will add it,
139  if it is not already present in the path. In a setup with multiple (conditional) paths however, it can not
140  determine, if the geometry is already loaded. This flag can be used o just turn off the geometry adding at
141  all (but you will have to add it on your own then).
142  :param skipHitPreparerAdding: Advanced flag: do not add the hit preparation (esp. VXD cluster creation
143  modules. This is useful if they have been added before already.
144  :param mcTrackFinding: Use the MC track finders instead of the realistic ones.
145  :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
146  :param prune_temporary_tracks: If false, store all information of the single CDC and VXD tracks before merging.
147  If true, prune them.
148  :param fit_tracks: If false, the final track find and the TrackCreator module will no be executed
149  :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
150  :param trackFitHypotheses: Which pdg hypothesis to fit. Defaults to [211, 321, 2212].
151  :param use_svd_to_cdc_ckf: if true, add SVD to CDC CKF module.
152  :param use_ecl_to_cdc_ckf: if true, add ECL to CDC CKF module.
153  :param add_cdcTrack_QI: If true, add the MVA track quality estimation
154  to the path that sets the quality indicator property of the found CDC standalone tracks
155  :param add_vxdTrack_QI: If true, add the MVA track quality estimation
156  to the path that sets the quality indicator property of the found VXDTF2 tracks
157  (ATTENTION: Standard triplet QI of VXDTF2 is replaced in this case
158  -> setting this option to 'True' will have some influence on the final track collection)
159  :param add_recoTrack_QI: If true, add the MVA track quality estimation
160  to the path that sets the quality indicator property of all found reco tracks
161  (Both other QIs needed as input.)
162  """
163 
164  if not is_svd_used(components) and not is_cdc_used(components):
165  return
166 
167  if (add_cdcTrack_QI or add_vxdTrack_QI or add_recoTrack_QI) and not fit_tracks:
168  b2.B2ERROR("MVA track qualiy indicator requires `fit_tracks` to be enabled. Turning all off.")
169  add_cdcTrack_QI = False
170  add_vxdTrack_QI = False
171  add_recoTrack_QI = False
172 
173  if add_recoTrack_QI and (not add_cdcTrack_QI or not add_vxdTrack_QI):
174  b2.B2ERROR("RecoTrack qualiy indicator requires CDC and VXD QI as input. Turning it all of.")
175  add_cdcTrack_QI = False
176  add_vxdTrack_QI = False
177  add_recoTrack_QI = False
178 
179  if not skipGeometryAdding:
180  add_geometry_modules(path, components=components)
181 
182  if not skipHitPreparerAdding:
183  add_hit_preparation_modules(path, components=components)
184 
185  # Material effects for all track extrapolations
186  if 'SetupGenfitExtrapolation' not in path:
187  path.add_module('SetupGenfitExtrapolation',
188  energyLossBrems=False, noiseBrems=False)
189 
190  if mcTrackFinding:
191  add_mc_track_finding(path, components=components, reco_tracks=reco_tracks,
192  use_second_cdc_hits=use_second_cdc_hits)
193  else:
194  add_track_finding(path, components=components, reco_tracks=reco_tracks,
195  prune_temporary_tracks=prune_temporary_tracks,
196  use_second_cdc_hits=use_second_cdc_hits,
197  use_svd_to_cdc_ckf=use_svd_to_cdc_ckf,
198  use_ecl_to_cdc_ckf=use_ecl_to_cdc_ckf,
199  add_cdcTrack_QI=add_cdcTrack_QI, add_vxdTrack_QI=add_vxdTrack_QI)
200 
201  # Only run the track time extraction on the full reconstruction chain for now. Later, we may
202  # consider to do the CDC-hit based method already during the fast reconstruction stage
203  add_time_extraction(path, components=components)
204 
205  add_mc_matcher(path, components=components, reco_tracks=reco_tracks,
206  use_second_cdc_hits=use_second_cdc_hits)
207 
208  if fit_tracks:
209  add_prefilter_track_fit_and_track_creator(path,
210  trackFitHypotheses=trackFitHypotheses,
211  reco_tracks=reco_tracks,
212  add_mva_quality_indicator=add_recoTrack_QI)
213 
214 
215 def add_postfilter_tracking_reconstruction(path, components=None, pruneTracks=False, fit_tracks=True, reco_tracks="RecoTracks",
216  prune_temporary_tracks=True):
217  """
218  This function adds the tracking reconstruction modules not required to calculate HLT filter
219  decision to a path.
220 
221  :param path: The path to add the tracking reconstruction modules to
222  :param components: the list of geometry components in use or None for all components.
223  :param pruneTracks: Delete all hits except the first and the last in the found tracks.
224  :param fit_tracks: If false, the V0 module module will no be executed
225  :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
226  :param prune_temporary_tracks: If false, store all information of the single CDC and VXD tracks before merging.
227  If true, prune them.
228  """
229 
230  if fit_tracks:
231  add_postfilter_track_fit(path, components=components, pruneTracks=pruneTracks, reco_tracks=reco_tracks)
232 
233  if prune_temporary_tracks or pruneTracks:
234  path.add_module("PruneRecoHits")
235 
236 
237 def add_time_extraction(path, components=None):
238  """
239  Add time extraction components via tracking
240  """
241 
242  if is_cdc_used(components):
243  path.add_module("FullGridChi2TrackTimeExtractor")
244 
245 
246 def add_cr_tracking_reconstruction(path, components=None, prune_tracks=False,
247  skip_geometry_adding=False, event_time_extraction=True,
248  merge_tracks=True, use_second_cdc_hits=False):
249  """
250  This function adds the reconstruction modules for cr tracking to a path.
251 
252  :param path: The path to which to add the tracking reconstruction modules
253 
254  :param components: the list of geometry components in use or None for all components.
255  :param prune_tracks: Delete all hits except the first and the last in the found tracks.
256 
257  :param skip_geometry_adding: Advanced flag: The tracking modules need the geometry module and will add it,
258  if it is not already present in the path. In a setup with multiple (conditional) paths however, it cannot
259  determine if the geometry is already loaded. This flag can be used to just turn off the geometry adding
260  (but you will have to add it on your own).
261  :param event_time_extraction: extract the event time
262  :param merge_tracks: The upper and lower half of the tracks should be merged together in one track
263  :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
264 
265  """
266 
267  # make sure CDC is used
268  if not is_cdc_used(components):
269  return
270 
271  if not skip_geometry_adding:
272  add_geometry_modules(path, components)
273 
274  add_hit_preparation_modules(path, components=components)
275 
276  # Material effects for all track extrapolations
277  if 'SetupGenfitExtrapolation' not in path:
278  path.add_module('SetupGenfitExtrapolation',
279  energyLossBrems=False, noiseBrems=False)
280 
281  # track finding
282  add_cr_track_finding(path, reco_tracks="RecoTracks", components=components,
283  merge_tracks=merge_tracks, use_second_cdc_hits=use_second_cdc_hits)
284 
285  # track fitting
286  # if tracks were merged, use the unmerged collection for time extraction
287  add_cr_track_fit_and_track_creator(path, components=components, prune_tracks=prune_tracks,
288  event_timing_extraction=event_time_extraction)
289 
290  if merge_tracks:
291  # Do also fit the not merged tracks
292  add_cr_track_fit_and_track_creator(path, components=components, prune_tracks=prune_tracks,
293  event_timing_extraction=False,
294  reco_tracks="NonMergedRecoTracks", tracks="NonMergedTracks")
295 
296 
297 def add_mc_tracking_reconstruction(path, components=None, pruneTracks=False, use_second_cdc_hits=False):
298  """
299  This function adds the standard reconstruction modules for MC tracking
300  to a path.
301 
302  :param path: The path to add the tracking reconstruction modules to
303  :param components: the list of geometry components in use or None for all components.
304  :param pruneTracks: Delete all hits expect the first and the last from the found tracks.
305  :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
306  """
307  add_tracking_reconstruction(path,
308  components=components,
309  pruneTracks=pruneTracks,
310  mcTrackFinding=True,
311  use_second_cdc_hits=use_second_cdc_hits)
312 
313 
314 def add_track_finding(path, components=None, reco_tracks="RecoTracks",
315  prune_temporary_tracks=True, use_second_cdc_hits=False,
316  use_mc_truth=False, svd_ckf_mode="VXDTF2_after", add_both_directions=True,
317  use_svd_to_cdc_ckf=True, use_ecl_to_cdc_ckf=False,
318  add_cdcTrack_QI=True, add_vxdTrack_QI=False):
319  """
320  Add the CKF to the path with all the track finding related to and needed for it.
321  :param path: The path to add the tracking reconstruction modules to
322  :param reco_tracks: The store array name where to output all tracks
323  :param use_mc_truth: Use the truth information in the CKF modules
324  :param svd_ckf_mode: how to apply the CKF (with VXDTF2 or without). Defaults to "VXDTF2_after".
325  :param add_both_directions: Curlers may be found in the wrong orientation by the CDC track finder, so try to
326  extrapolate also in the other direction.
327  :param use_second_cdc_hits: whether to use the secondary CDC hit during CDC track finding or not
328  :param components: the list of geometry components in use or None for all components.
329  :param prune_temporary_tracks: If false, store all information of the single CDC and VXD tracks before merging.
330  If true, prune them.
331  :param use_svd_to_cdc_ckf: if true, add SVD to CDC CKF module.
332  :param use_ecl_to_cdc_ckf: if true, add ECL to CDC CKF module.
333  :param add_cdcTrack_QI: If true, add the MVA track quality estimation
334  to the path that sets the quality indicator property of the found CDC standalone tracks
335  :param add_vxdTrack_QI: If true, add the MVA track quality estimation
336  to the path that sets the quality indicator property of the found VXDTF2 tracks
337  (ATTENTION: Standard triplet QI of VXDTF2 is replaced in this case
338  -> setting this option to 'True' will have some influence on the final track collection)
339  """
340  if not is_svd_used(components) and not is_cdc_used(components):
341  return
342 
343  if use_ecl_to_cdc_ckf and not is_cdc_used(components):
344  b2.B2WARNING("ECL CKF cannot be used without CDC. Turning it off.")
345  use_ecl_to_cdc_ckf = False
346 
347  if use_ecl_to_cdc_ckf and not is_ecl_used(components):
348  b2.B2ERROR("ECL CKF cannot be used without ECL. Turning it off.")
349  use_ecl_to_cdc_ckf = False
350 
351  # register EventTrackingInfo
352  if 'RegisterEventLevelTrackingInfo' not in path:
353  path.add_module('RegisterEventLevelTrackingInfo')
354 
355  # output tracks
356  cdc_reco_tracks = "CDCRecoTracks"
357  svd_cdc_reco_tracks = "SVDCDCRecoTracks"
358  ecl_reco_tracks = "ECLRecoTracks"
359  combined_ecl_reco_tracks = "combinedECLRecoTracks"
360 
361  # temporary collections
362  svd_reco_tracks = "SVDRecoTracks"
363  pxd_reco_tracks = "PXDRecoTracks"
364 
365  # collections that will be pruned
366  temporary_reco_track_list = []
367 
368  # the name of the most recent track collection
369  latest_reco_tracks = None
370 
371  if not is_pxd_used(components):
372  if use_ecl_to_cdc_ckf and is_cdc_used(components):
373  combined_ecl_reco_tracks = reco_tracks
374  elif (not use_ecl_to_cdc_ckf) and is_svd_used(components):
375  svd_cdc_reco_tracks = reco_tracks
376  elif (not use_ecl_to_cdc_ckf) and (not is_svd_used(components)) and is_cdc_used(components):
377  cdc_reco_tracks = reco_tracks
378 
379  if is_cdc_used(components):
380  add_cdc_track_finding(path, use_second_hits=use_second_cdc_hits, output_reco_tracks=cdc_reco_tracks,
381  add_mva_quality_indicator=add_cdcTrack_QI)
382  temporary_reco_track_list.append(cdc_reco_tracks)
383  latest_reco_tracks = cdc_reco_tracks
384 
385  if is_svd_used(components):
386  add_svd_track_finding(path, components=components, input_reco_tracks=latest_reco_tracks,
387  output_reco_tracks=svd_cdc_reco_tracks, use_mc_truth=use_mc_truth,
388  temporary_reco_tracks=svd_reco_tracks,
389  svd_ckf_mode=svd_ckf_mode, add_both_directions=add_both_directions,
390  use_svd_to_cdc_ckf=use_svd_to_cdc_ckf, prune_temporary_tracks=prune_temporary_tracks,
391  add_mva_quality_indicator=add_vxdTrack_QI)
392  temporary_reco_track_list.append(svd_reco_tracks)
393  temporary_reco_track_list.append(svd_cdc_reco_tracks)
394  latest_reco_tracks = svd_cdc_reco_tracks
395 
396  if use_ecl_to_cdc_ckf and is_cdc_used(components):
397  add_eclcdc_track_finding(path, components=components, output_reco_tracks=ecl_reco_tracks,
398  prune_temporary_tracks=prune_temporary_tracks)
399 
400  # TODO: add another merging step? (SVD track found by vxdtf2, and CDC track found by ECL CKF)?
401 
402  path.add_module("RecoTrackStoreArrayCombiner",
403  Temp1RecoTracksStoreArrayName=latest_reco_tracks,
404  Temp2RecoTracksStoreArrayName=ecl_reco_tracks,
405  recoTracksStoreArrayName=combined_ecl_reco_tracks)
406  temporary_reco_track_list.append(ecl_reco_tracks)
407  temporary_reco_track_list.append(combined_ecl_reco_tracks)
408  latest_reco_tracks = combined_ecl_reco_tracks
409 
410  if is_pxd_used(components):
411  add_pxd_track_finding(path, components=components, input_reco_tracks=latest_reco_tracks,
412  use_mc_truth=use_mc_truth, output_reco_tracks=reco_tracks,
413  temporary_reco_tracks=pxd_reco_tracks,
414  add_both_directions=add_both_directions)
415  temporary_reco_track_list.append(pxd_reco_tracks)
416 
417  if prune_temporary_tracks:
418  for temporary_reco_track_name in temporary_reco_track_list:
419  if temporary_reco_track_name != reco_tracks:
420  path.add_module('PruneRecoTracks', storeArrayName=temporary_reco_track_name)
421 
422 
423 def add_cr_track_finding(path, reco_tracks="RecoTracks", components=None,
424  merge_tracks=True, use_second_cdc_hits=False):
425 
426  # register EventTrackingInfo
427  if 'RegisterEventLevelTrackingInfo' not in path:
428  path.add_module('RegisterEventLevelTrackingInfo')
429 
430  if not is_cdc_used(components):
431  b2.B2FATAL("CDC must be in components")
432 
433  reco_tracks_from_track_finding = reco_tracks
434  if merge_tracks:
435  reco_tracks_from_track_finding = "NonMergedRecoTracks"
436 
437  cdc_reco_tracks = "CDCRecoTracks"
438  if not is_pxd_used(components) and not is_svd_used(components):
439  cdc_reco_tracks = reco_tracks_from_track_finding
440 
441  svd_cdc_reco_tracks = "SVDCDCRecoTracks"
442  if not is_pxd_used(components):
443  svd_cdc_reco_tracks = reco_tracks_from_track_finding
444 
445  full_reco_tracks = reco_tracks_from_track_finding
446 
447  # CDC track finding with default settings
448  add_cdc_cr_track_finding(path, merge_tracks=False, use_second_cdc_hits=use_second_cdc_hits,
449  output_reco_tracks=cdc_reco_tracks)
450 
451  latest_reco_tracks = cdc_reco_tracks
452 
453  if is_svd_used(components):
454  add_svd_track_finding(path, components=components, input_reco_tracks=latest_reco_tracks,
455  output_reco_tracks=svd_cdc_reco_tracks,
456  svd_ckf_mode="cosmics", add_both_directions=True)
457  latest_reco_tracks = svd_cdc_reco_tracks
458 
459  if is_pxd_used(components):
460  add_pxd_cr_track_finding(path, components=components, input_reco_tracks=latest_reco_tracks,
461  output_reco_tracks=full_reco_tracks, add_both_directions=True,
462  filter_cut=0.01)
463 
464  if merge_tracks:
465  # merge the tracks together
466  path.add_module("CosmicsTrackMerger", inputRecoTracks=reco_tracks_from_track_finding,
467  outputRecoTracks=reco_tracks)
468 
469 
470 def add_mc_track_finding(path, components=None, reco_tracks="RecoTracks", use_second_cdc_hits=False):
471  """
472  Add the MC based TrackFinder to the path.
473 
474  :param path: The path to add the tracking reconstruction modules to
475  :param components: the list of geometry components in use or None for all components.
476  :param reco_tracks: Name of the StoreArray where the reco tracks should be stored
477  :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
478  """
479  if is_cdc_used(components) or is_pxd_used(components) or is_svd_used(components):
480  # find MCTracks in CDC, SVD and PXD (or a subset of it)
481  path.add_module('TrackFinderMCTruthRecoTracks',
482  RecoTracksStoreArrayName=reco_tracks,
483  UseSecondCDCHits=use_second_cdc_hits,
484  UsePXDHits=is_pxd_used(components),
485  UseSVDHits=is_svd_used(components),
486  UseCDCHits=is_cdc_used(components))
487 
488 
489 def add_tracking_for_PXDDataReduction_simulation(path, components, svd_cluster='__ROIsvdClusters'):
490  """
491  This function adds the standard reconstruction modules for tracking to be used for the simulation of PXD data
492  reduction to a path.
493 
494  :param path: The path to add the tracking reconstruction modules to
495  :param components: the list of geometry components in use or None for all components, always exclude the PXD.
496  """
497 
498  if not is_svd_used(components):
499  return
500 
501  # Material effects
502  if 'SetupGenfitExtrapolation' not in path:
503  material_effects = b2.register_module('SetupGenfitExtrapolation')
504  material_effects.set_name(
505  'SetupGenfitExtrapolationForPXDDataReduction')
506  path.add_module(material_effects)
507 
508  # SET StoreArray names
509  svd_reco_tracks = "__ROIsvdRecoTracks"
510 
511  # SVD ONLY TRACK FINDING
512  add_vxd_track_finding_vxdtf2(path, components=['SVD'], reco_tracks=svd_reco_tracks, suffix="__ROI",
513  svd_clusters=svd_cluster)
514 
515  # TRACK FITTING
516  dafRecoFitter = b2.register_module("DAFRecoFitter")
517  dafRecoFitter.set_name("SVD-only DAFRecoFitter")
518  dafRecoFitter.param('recoTracksStoreArrayName', svd_reco_tracks)
519  dafRecoFitter.param('svdHitsStoreArrayName', svd_cluster)
520  path.add_module(dafRecoFitter)
521 
522 
523 def add_vxd_standalone_cosmics_finder(
524  path,
525  reco_tracks="RecoTracks",
526  pxd_spacepoints_name="PXDSpacePoints",
527  svd_spacepoints_name="SVDSpacePoints",
528  quality_cut=0.0001,
529  min_sps=3,
530  max_rejected_sps=5):
531  """
532  Convenience function for adding VXD standalone cosmics track finding for B = 0 Tesla
533  to the path.
534 
535  The result is a StoreArray with name @param reco_tracks containing one or zero reco tracks per event.
536  This track candidates have an arbitrary but large momentum seed in the direction of the fitted line.
537  The position and momentum seed is obtained using a principal component analysis method.
538 
539  :param path: basf2 path
540  :param reco_tracks: Name of the output RecoTracks; defaults to RecoTracks.
541  :param spacepoints_name: name of store array containing the spacepoints; defaults to SpacePoints
542  :param quality_cut: Cut on the chi squared value of the line fit; candidates with values above the cut will be
543  rejected; defaults to 0.0001
544  :param min_sps: Minimal number of SpacePoints required to build a track candidate; defaults to 3;
545  :param max_rejected_sps: Maximal number of retries to refit a track after the worst spacepoint was removed;
546  defaults to 5;
547  """
548 
549  # register EventTrackingInfo
550  if 'RegisterEventLevelTrackingInfo' not in path:
551  path.add_module('RegisterEventLevelTrackingInfo')
552 
553  sp_creator_pxd = b2.register_module('PXDSpacePointCreator')
554  sp_creator_pxd.param('SpacePoints', pxd_spacepoints_name)
555  path.add_module(sp_creator_pxd)
556 
557  # SVDSpacePointCreator is applied in funtion add_svd_reconstruction
558 
559  track_finder = b2.register_module('TrackFinderVXDCosmicsStandalone')
560  track_finder.param('SpacePointTrackCandArrayName', "")
561  track_finder.param('SpacePoints', [pxd_spacepoints_name, svd_spacepoints_name])
562  track_finder.param('QualityCut', quality_cut)
563  track_finder.param('MinSPs', min_sps)
564  track_finder.param('MaxRejectedSPs', max_rejected_sps)
565  path.add_module(track_finder)
566 
567  converter = b2.register_module('SPTC2RTConverter')
568  converter.param('recoTracksStoreArrayName', reco_tracks)
569  path.add_module(converter)