13os.environ[
'OMP_THREAD_LIMIT'] =
"1"
17from geometry
import check_components
19from svd
import add_svd_reconstruction
20from pxd
import add_pxd_reconstruction
22from rawdata
import add_unpackers
27 add_mc_tracking_reconstruction,
28 add_prefilter_tracking_reconstruction,
29 add_postfilter_tracking_reconstruction,
30 add_cr_tracking_reconstruction,
35 add_filter_software_trigger,
36 add_skim_software_trigger
40CDST_TRACKING_OBJECTS = (
41 'EventLevelTrackingInfo',
49 'SVDShaperDigitsFromTracks',
50 'PXDClustersFromTracks',
70def default_event_abort(module, condition, error_flag):
71 """Default event abort outside of HLT: Ignore the error flag and just stop
72 processing by giving an empty path"""
74 module.if_value(condition, p, basf2.AfterConditionPath.END)
77def add_reconstruction(path, components=None, pruneTracks=True, add_trigger_calculation=True, skipGeometryAdding=False,
78 trackFitHypotheses=None, addClusterExpertModules=True,
79 with_cdc_cellular_automaton=False,
80 use_second_cdc_hits=False, add_muid_hits=False, reconstruct_cdst=None,
81 event_abort=default_event_abort, use_random_numbers_for_hlt_prescale=True,
82 pxd_filtering_offline=False,
83 create_intercepts_for_pxd_ckf=False,
84 append_full_grid_cdc_eventt0=True,
85 legacy_ecl_charged_pid=False, emulate_HLT=False,
86 skip_full_grid_cdc_eventt0_if_svd_time_present=True,
87 switch_off_slow_modules_for_online=False):
89 This function adds the standard reconstruction modules to a path.
90 Consists of clustering, tracking and the PID modules essentially in this structure:
92 | :func:`add_reconstruction()`
93 | ├── :func:`add_prefilter_reconstruction()`
94 | │ ├── :func:`add_prefilter_pretracking_reconstruction()` : Clustering
95 | │ ├── ``add_prefilter_tracking_reconstruction()`` : Tracking essential for HLT filter calculation
96 | │ └── :func:`add_prefilter_posttracking_reconstruction()` : PID and clustering essential for HLT
97 | └── :func:`add_postfilter_reconstruction()`
98 | ├── ``add_postfilter_tracking_reconstruction()`` : Rest of the tracking
99 | └── :func:`add_postfilter_posttracking_reconstruction()` : Rest of PID and clustering
101 plus the modules to calculate the software trigger cuts.
103 :param path: Add the modules to this path.
104 :param components: list of geometry components to include reconstruction for, or None for all components.
105 :param pruneTracks: Delete all hits except the first and last of the tracks after the V0Finder modules.
106 :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module and will add it,
107 if it is not already present in the path. In a setup with multiple (conditional) paths however, it can not
108 determine, if the geometry is already loaded. This flag can be used to just turn off the geometry adding at
109 all (but you will have to add it on your own then).
110 :param trackFitHypotheses: Change the additional fitted track fit hypotheses. If no argument is given,
111 the fitted hypotheses are pion, kaon and proton, i.e. [211, 321, 2212].
112 :param addClusterExpertModules: Add the cluster expert modules in the KLM and ECL. Turn this off to reduce
114 :param with_cdc_cellular_automaton: If true, in the CDC track finding the cellular automaton algorithm will be used too,
115 after the global algorithm (Legendre).
116 :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
117 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
118 :param add_trigger_calculation: add the software trigger modules for monitoring (do not make any cut)
119 :param reconstruct_cdst: None for mdst, 'rawFormat' to reconstruct cdsts in rawFormat, 'fullFormat' for the
120 full (old) format. This parameter is needed when reconstructing cdsts, otherwise the
121 required PXD objects won't be added.
122 :param event_abort: A function to abort event processing at the given point. Should take three arguments: a module,
123 the condition and the error_flag to be set if these events are kept. If run on HLT this will not abort the event
124 but just remove all data except for the event information.
125 :param use_random_numbers_for_hlt_prescale: If True, the HLT filter prescales are applied using randomly
126 generated numbers, otherwise are applied using an internal counter.
127 :param pxd_filtering_offline: If True, PXD data reduction (ROI filtering) is applied during the track reconstruction.
128 The reconstructed SVD/CDC tracks are used to define the ROIs and reject all PXD clusters outside of these.
129 :param create_intercepts_for_pxd_ckf: If True, the PXDROIFinder is added to the path to create PXDIntercepts to be used
130 for hit filtering when creating the CKF relations. This independent of the offline PXD digit filtering which is
131 steered by 'pxd_filtering_offline'. This can be applied for both data and MC.
132 :param append_full_grid_cdc_eventt0: If True, the module FullGridChi2TrackTimeExtractor is added to the path
133 and provides the CDC temporary EventT0.
134 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
135 MVA based charged particle ID (false).
136 :param emulate_HLT: if True, it runs the reconstruction as it is run on HLT (e.g. without PXD).
137 If you want to use this flag on raw data, you should also exclude the following branches from RootInput: ROIs, ROIpayload
138 :param skip_full_grid_cdc_eventt0_if_svd_time_present: if true, and if also append_full_grid_cdc_eventt0 is true, the
139 FullGridChi2TrackTimeExtractor is only executed in the events where no SVD-based EventT0 is found. If false, but
140 append_full_grid_cdc_eventt0 is true, FullGridChi2TrackTimeExtractor will be executed in each event regardless of
141 SVD EventT0 being present. Has no effect if append_full_grid_cdc_eventt0 is false. Default: true
142 :param switch_off_slow_modules_for_online: if true, it switches off some modules in the reconstruction chain by overriding
143 other flags (e.g.: this flag overrides ``append_full_grid_cdc_eventt0``. On HLT and ExpressReco, this flag is set
144 to true in order to speed up the reconstruction.
152 if reconstruct_cdst ==
'rawFormat':
153 append_full_grid_cdc_eventt0 =
True
156 components = DEFAULT_HLT_COMPONENTS
159 if switch_off_slow_modules_for_online:
160 append_full_grid_cdc_eventt0 =
False
161 legacy_ecl_charged_pid =
True
164 add_prefilter_reconstruction(path,
165 components=components,
166 add_modules_for_trigger_calculation=add_trigger_calculation,
167 skipGeometryAdding=skipGeometryAdding,
168 trackFitHypotheses=trackFitHypotheses,
169 with_cdc_cellular_automaton=with_cdc_cellular_automaton,
170 use_second_cdc_hits=use_second_cdc_hits,
171 add_muid_hits=add_muid_hits,
172 reconstruct_cdst=reconstruct_cdst,
173 event_abort=event_abort,
174 pxd_filtering_offline=pxd_filtering_offline,
175 create_intercepts_for_pxd_ckf=create_intercepts_for_pxd_ckf,
176 append_full_grid_cdc_eventt0=append_full_grid_cdc_eventt0,
177 skip_full_grid_cdc_eventt0_if_svd_time_present=skip_full_grid_cdc_eventt0_if_svd_time_present,
178 switch_off_slow_modules_for_online=switch_off_slow_modules_for_online)
181 if add_trigger_calculation
and (
not components
or (
"CDC" in components
and "ECL" in components
and "KLM" in components)):
182 add_filter_software_trigger(path,
183 use_random_numbers_for_prescale=use_random_numbers_for_hlt_prescale)
186 add_postfilter_reconstruction(path,
187 components=components,
188 pruneTracks=pruneTracks,
189 addClusterExpertModules=addClusterExpertModules,
190 reconstruct_cdst=reconstruct_cdst,
191 legacy_ecl_charged_pid=legacy_ecl_charged_pid,
192 switch_off_slow_modules_for_online=switch_off_slow_modules_for_online)
195 if add_trigger_calculation
and (
not components
or (
"CDC" in components
and "ECL" in components
and "KLM" in components)):
196 add_skim_software_trigger(path)
199def add_prefilter_reconstruction(path,
201 add_modules_for_trigger_calculation=True,
202 skipGeometryAdding=False,
203 trackFitHypotheses=None,
204 with_cdc_cellular_automaton=False,
205 use_second_cdc_hits=False,
207 reconstruct_cdst=None,
208 event_abort=default_event_abort,
209 pxd_filtering_offline=False,
210 create_intercepts_for_pxd_ckf=False,
211 append_full_grid_cdc_eventt0=True,
212 skip_full_grid_cdc_eventt0_if_svd_time_present=True,
213 switch_off_slow_modules_for_online=False):
215 This function adds only the reconstruction modules required to calculate HLT filter decision to a path.
216 Consists of essential tracking and the functionality provided by :func:`add_prefilter_posttracking_reconstruction()`.
218 :param path: Add the modules to this path.
219 :param components: list of geometry components to include reconstruction for, or None for all components.
220 :param add_modules_for_trigger_calculation: add the modules necessary for computing the software trigger decision
221 during later stages (do not make any cut), relevant only when reconstruct_cdst is not None.
222 :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module and will add it,
223 if it is not already present in the path. In a setup with multiple (conditional) paths however, it can not
224 determine, if the geometry is already loaded. This flag can be used to just turn off the geometry adding at
225 all (but you will have to add it on your own then).
226 :param trackFitHypotheses: Change the additional fitted track fit hypotheses. If no argument is given,
227 the fitted hypotheses are pion, kaon and proton, i.e. [211, 321, 2212].
228 :param with_cdc_cellular_automaton: If true, in the CDC track finding the cellular automaton algorithm will be used too,
229 after the global algorithm (Legendre).
230 :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
231 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
232 :param reconstruct_cdst: None for mdst, 'rawFormat' to reconstruct cdsts in rawFormat, 'fullFormat' for the
233 full (old) format. This parameter is needed when reconstructing cdsts, otherwise the
234 required PXD objects won't be added.
235 :param event_abort: A function to abort event processing at the given point. Should take three arguments: a module,
236 the condition and the error_flag to be set if these events are kept. If run on HLT this will not abort the event
237 but just remove all data except for the event information.
238 :param pxd_filtering_offline: If True, PXD data reduction (ROI filtering) is applied during the track reconstruction.
239 The reconstructed SVD/CDC tracks are used to define the ROIs and reject all PXD clusters outside of these.
240 :param create_intercepts_for_pxd_ckf: If True, the PXDROIFinder is added to the path to create PXDIntercepts to be used
241 for hit filtering when creating the CKF relations. This independent of the offline PXD digit filtering which is
242 steered by 'pxd_filtering_offline'. This can be applied for both data and MC.
243 :param append_full_grid_cdc_eventt0: If True, the module FullGridChi2TrackTimeExtractor is added to the path
244 and provides the CDC temporary EventT0.
245 :param skip_full_grid_cdc_eventt0_if_svd_time_present: if true, and if also append_full_grid_cdc_eventt0 is true, the
246 FullGridChi2TrackTimeExtractor is only executed in the events where no SVD-based EventT0 is found. If false, but
247 append_full_grid_cdc_eventt0 is true, FullGridChi2TrackTimeExtractor will be executed in each event regardless of
248 SVD EventT0 being present. Has no effect if append_full_grid_cdc_eventt0 is false. Default: true
249 :param switch_off_slow_modules_for_online: if true, it switches off some modules in the reconstruction chain by overriding
250 other flags (e.g.: this flag overrides ``append_full_grid_cdc_eventt0``. On HLT and ExpressReco, this flag is set
251 to true in order to speed up the reconstruction.
255 if switch_off_slow_modules_for_online:
256 append_full_grid_cdc_eventt0 =
False
259 from ROOT
import Belle2
262 check_components(components)
265 doom = path.add_module(
"EventsOfDoomBuster")
266 event_abort(doom,
">=1", Belle2.EventMetaData.c_ReconstructionAbort)
267 path.add_module(
'StatisticsSummary').set_name(
'Sum_EventsofDoomBuster')
270 add_prefilter_pretracking_reconstruction(path, components=components)
273 add_prefilter_tracking_reconstruction(
275 components=components,
276 mcTrackFinding=
False,
277 skipGeometryAdding=skipGeometryAdding,
278 trackFitHypotheses=trackFitHypotheses,
279 with_cdc_cellular_automaton=with_cdc_cellular_automaton,
280 use_second_cdc_hits=use_second_cdc_hits,
281 pxd_filtering_offline=pxd_filtering_offline,
282 create_intercepts_for_pxd_ckf=create_intercepts_for_pxd_ckf,
283 append_full_grid_cdc_eventt0=append_full_grid_cdc_eventt0,
284 skip_full_grid_cdc_eventt0_if_svd_time_present=skip_full_grid_cdc_eventt0_if_svd_time_present)
287 path.add_module(
'StatisticsSummary').set_name(
'Sum_Prefilter_Tracking')
291 add_special_vxd_modules(path, components=components)
292 if reconstruct_cdst ==
'rawFormat' and not add_modules_for_trigger_calculation:
296 add_prefilter_posttracking_reconstruction(path,
297 components=components,
298 add_muid_hits=add_muid_hits)
301 path.add_module(
'StatisticsSummary').set_name(
'Sum_Prefilter_PostTracking')
304def add_postfilter_reconstruction(path,
307 addClusterExpertModules=True,
308 reconstruct_cdst=None,
309 legacy_ecl_charged_pid=False,
310 switch_off_slow_modules_for_online=False):
312 This function adds the reconstruction modules not required to calculate HLT filter decision to a path.
314 :param path: Add the modules to this path.
315 :param components: list of geometry components to include reconstruction for, or None for all components.
316 :param pruneTracks: Delete all hits expect the first and the last from the found tracks.
317 :param addClusterExpertModules: Add the cluster expert modules in the KLM and ECL. Turn this off to
318 reduce execution time.
319 :param reconstruct_cdst: None for mdst, 'rawFormat' to reconstruct cdsts in rawFormat, 'fullFormat' for the
320 full (old) format. This parameter is needed when reconstructing cdsts, otherwise the
321 required PXD objects won't be added.
322 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
323 MVA based charged particle ID (false).
324 :param switch_off_slow_modules_for_online: if true, it switches off some modules in the reconstruction chain by overriding
325 other flags (e.g.: this flag overrides ``append_full_grid_cdc_eventt0``. On HLT and ExpressReco, this flag is set
326 to true in order to speed up the reconstruction.
330 flip_recoTrack =
True
333 if switch_off_slow_modules_for_online:
334 legacy_ecl_charged_pid =
True
335 flip_recoTrack =
False
340 add_postfilter_tracking_reconstruction(
342 components=components,
344 flip_recoTrack=flip_recoTrack,
345 kink_finding=kink_finding
348 path.add_module(
'StatisticsSummary').set_name(
'Sum_Postfilter_Tracking')
351 if reconstruct_cdst ==
'rawFormat':
354 components=components
364 add_postfilter_posttracking_reconstruction(
366 components=components,
367 addClusterExpertModules=addClusterExpertModules,
368 legacy_ecl_charged_pid=legacy_ecl_charged_pid,
369 run_klm_dnn=run_klm_dnn
380 path.add_module(
'StatisticsSummary').set_name(
'Sum_Postfilter_PostTracking')
383def add_cosmics_reconstruction(
387 skipGeometryAdding=False,
388 eventTimingExtraction=True,
389 addClusterExpertModules=True,
391 use_second_cdc_hits=False,
393 reconstruct_cdst=False,
395 legacy_ecl_charged_pid=False,
398 This function adds the standard reconstruction modules for cosmic data to a path.
399 Consists of tracking and the functionality provided by :func:`add_posttracking_reconstruction()`,
400 plus the modules to calculate the software trigger cuts.
402 :param path: Add the modules to this path.
403 :param components: list of geometry components to include reconstruction for, or None for all components.
404 :param pruneTracks: Delete all hits except the first and last of the tracks after the dEdX modules.
405 :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module and will add it,
406 if it is not already present in the path. In a setup with multiple (conditional) paths however, it can not
407 determine, if the geometry is already loaded. This flag can be used to just turn off the geometry adding at
408 all (but you will have to add it on your own then).
410 :param eventTimingExtraction: extract the event time
411 :param addClusterExpertModules: Add the cluster expert modules in the KLM and ECL. Turn this off to reduce
414 :param merge_tracks: The upper and lower half of the tracks should be merged together in one track
415 :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
417 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
419 :param reconstruct_cdst: run only the minimal reconstruction needed to produce the cdsts (raw+tracking+dE/dx)
420 :param posttracking: run reconstruction for outer detectors.
421 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
422 MVA based charged particle ID (false).
426 basf2.declare_cosmics()
429 check_components(components)
432 add_prefilter_pretracking_reconstruction(path,
433 components=components)
436 add_cr_tracking_reconstruction(path,
437 components=components,
439 skip_geometry_adding=skipGeometryAdding,
440 event_time_extraction=eventTimingExtraction,
441 merge_tracks=merge_tracks,
442 use_second_cdc_hits=use_second_cdc_hits)
445 path.add_module(
'StatisticsSummary').set_name(
'Sum_Tracking')
449 add_special_vxd_modules(path, components=components)
450 add_dedx_modules(path, components=components)
451 add_prune_tracks(path, components=components)
455 add_posttracking_reconstruction(path,
456 components=components,
457 pruneTracks=pruneTracks,
458 addClusterExpertModules=addClusterExpertModules,
459 add_muid_hits=add_muid_hits,
461 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
464def add_mc_reconstruction(path, components=None, pruneTracks=True, addClusterExpertModules=True,
465 use_second_cdc_hits=False, add_muid_hits=False, legacy_ecl_charged_pid=False):
467 This function adds the standard reconstruction modules with MC tracking
470 @param components list of geometry components to include reconstruction for, or None for all components.
471 @param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
472 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
473 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
474 MVA based charged particle ID (false).
481 add_prefilter_pretracking_reconstruction(path,
482 components=components)
485 add_mc_tracking_reconstruction(path,
486 components=components,
488 use_second_cdc_hits=use_second_cdc_hits)
491 path.add_module(
'StatisticsSummary').set_name(
'Sum_MC_Tracking')
494 add_posttracking_reconstruction(path,
495 components=components,
496 pruneTracks=pruneTracks,
497 add_muid_hits=add_muid_hits,
498 addClusterExpertModules=addClusterExpertModules,
499 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
502def add_prefilter_pretracking_reconstruction(path, components=None):
504 This function adds the standard reconstruction modules BEFORE tracking
507 :param path: The path to add the modules to.
508 :param components: list of geometry components to include reconstruction for, or None for all components.
511 add_ecl_modules(path, components)
514 path.add_module(
'StatisticsSummary').set_name(
'Sum_Clustering')
517def add_prefilter_posttracking_reconstruction(path,
520 for_cdst_analysis=False,
521 add_eventt0_combiner_for_cdst=False):
523 This function adds to the path the standard reconstruction modules after prefilter tracking
524 whoose outputs are also needed in the filter.
526 :param path: The path to add the modules to.
527 :param components: list of geometry components to include reconstruction for, or None for all components.
528 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
529 :param for_cdst_analysis: if True, EventT0Combiner is not added to path.
530 This is only needed by prepare_cdst_analysis().
531 :param add_eventt0_combiner_for_cdst: if True, the EventT0Combiner module is added to the path even if
532 for_cdst_analysis is False. This is useful for validation purposes for avoiding to run the full
533 add_reconstruction(). Note that, with the default settings (for_cdst_analysis=False and
534 add_eventt0_combiner_for_cdst=False), the EventT0Combiner module is added to the path.
537 add_ext_module(path, components)
540 if not for_cdst_analysis
or add_eventt0_combiner_for_cdst:
541 path.add_module(
"EventT0Combiner")
542 add_ecl_finalizer_module(path, components)
543 add_ecl_mc_matcher_module(path, components)
544 add_klm_modules(path, components)
545 add_klm_mc_matcher_module(path, components)
546 add_muid_module(path, add_hits_to_reco_track=add_muid_hits, components=components)
547 add_ecl_track_cluster_modules(path, components)
548 add_ecl_cluster_properties_modules(path, components)
551def add_postfilter_posttracking_reconstruction(path,
553 addClusterExpertModules=True,
555 for_cdst_analysis=False,
556 legacy_ecl_charged_pid=False,
559 This function adds to the path the standard reconstruction modules whoose outputs are not needed in the filter.
561 :param path: The path to add the modules to.
562 :param components: list of geometry components to include reconstruction for, or None for all components.
563 :param addClusterExpertModules: Add the cluster expert modules in the KLM and ECL. Turn this off to reduce
565 :param cosmics: if True, steer TOP for cosmic reconstruction.
566 :param for_cdst_analysis: if True, the OnlineEventT0Creator module is not added to the path.
567 This is only needed by prepare_cdst_analysis().
568 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
569 MVA based charged particle ID (false). This flag is automatically set to true on HLT and ExpressReco.
570 :param run_klm_dnn: If True, add the ``KLMMuonIDDNNExpert`` module to the path. This flag is automatically set to
571 false on HLT and ExpressReco.
574 add_dedx_modules(path, components, for_cdst_analysis=for_cdst_analysis)
575 add_top_modules(path, components, cosmics=cosmics)
576 add_arich_modules(path, components)
579 if not for_cdst_analysis:
580 path.add_module(
"OnlineEventT0Creator")
582 add_ecl_chargedpid_module(path, components, legacy_ecl_charged_pid)
583 add_pid_module(path, components, run_klm_dnn)
585 if addClusterExpertModules:
587 add_cluster_expert_modules(path, components)
589 add_ecl_track_brem_finder(path, components)
592def add_posttracking_reconstruction(path,
595 addClusterExpertModules=True,
598 for_cdst_analysis=False,
599 add_eventt0_combiner_for_cdst=False,
600 legacy_ecl_charged_pid=False):
602 This function adds the standard reconstruction modules after tracking
605 :param path: The path to add the modules to.
606 :param components: list of geometry components to include reconstruction for, or None for all components.
607 :param pruneTracks: Delete all hits except the first and last after the post-tracking modules.
608 :param addClusterExpertModules: Add the cluster expert modules in the KLM and ECL. Turn this off to reduce
610 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
611 :param cosmics: if True, steer TOP for cosmic reconstruction.
612 :param for_cdst_analysis: if True, the dEdx and PruneTracks modules are not added to the path, as well
613 as all EventT0 related modules.
614 This is only needed by prepare_cdst_analysis().
615 :param add_eventt0_combiner_for_cdst: if True, the EventT0Combiner module is added to the path even if
616 for_cdst_analysis is True. This is useful for validation purposes for avoiding to run the full
617 add_reconstruction(). Note that, with the default settings (for_cdst_analysis=False and
618 add_eventt0_combiner_for_cdst=False), the EventT0Combiner module is added to the path.
619 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
620 MVA based charged particle ID (false).
623 add_prefilter_posttracking_reconstruction(path,
624 components=components,
625 add_muid_hits=add_muid_hits,
626 for_cdst_analysis=for_cdst_analysis,
627 add_eventt0_combiner_for_cdst=add_eventt0_combiner_for_cdst)
629 add_postfilter_posttracking_reconstruction(path,
630 components=components,
631 addClusterExpertModules=addClusterExpertModules,
633 for_cdst_analysis=for_cdst_analysis,
634 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
638 if not for_cdst_analysis:
640 add_prune_tracks(path, components)
642 path.add_module(
'StatisticsSummary').set_name(
'Sum_Posttracking_Reconstruction')
645def add_cdst_output(path,
647 filename='cdst.root',
648 additionalBranches=None,
649 dataDescription=None,
650 ignoreInputModulesCheck=False):
652 This function adds the `RootOutput` module to a path with the settings needed to produce a cDST output.
653 The actual cDST output content depends on the value of the parameter `mc`:
654 * if `mc` is `False` (default setting), the cDST content is raw + tracking dataobjects;
655 * if `mc` is `True`, the cDST content is digits + MCParticles + tracking dataobjects.
657 @param path Path to add modules to.
658 @param mc Define the type of cDST output content: `False` for raw + tracking dataobjects, `True` for digits +
659 MCParticles + tracking dataobjects.
660 @param filename Output file name.
661 @param additionalBranches Additional objects/arrays of event durability to save
662 @param dataDescription Additional key->value pairs to be added as data description
663 fields to the output FileMetaData.
664 @param ignoreInputModulesCheck If True, do not enforce check on missing PXD modules in the input path.
665 Needed when a conditional path is passed as input.
668 branches = list(CDST_TRACKING_OBJECTS)
669 persistentBranches = [
'FileMetaData']
672 branches += ALWAYS_SAVE_OBJECTS + RAWDATA_OBJECTS
674 branches += list(DIGITS_OBJECTS) + [
676 'EventLevelTriggerTimeInfo',
677 'SoftwareTriggerResult',
679 persistentBranches += [
'BackgroundInfo']
681 if not ignoreInputModulesCheck
and "PXDClustersFromTracks" not in [module.name()
for module
in path.modules()]:
682 basf2.B2ERROR(
"PXDClustersFromTracks is required in CDST output but its module is not found in the input path!")
684 if dataDescription
is None:
686 dataDescription.setdefault(
"dataLevel",
"cdst")
688 if additionalBranches
is not None:
689 branches += additionalBranches
691 return path.add_module(
"RootOutput", outputFileName=filename, branchNames=branches,
692 branchNamesPersistent=persistentBranches, additionalDataDescription=dataDescription)
695def add_arich_modules(path, components=None):
697 Add the ARICH reconstruction to the path.
699 :param path: The path to add the modules to.
700 :param components: The components to use or None to use all standard components.
702 if components
is None or 'ARICH' in components:
703 path.add_module(
'ARICHFillHits')
704 path.add_module(
'ARICHReconstructor',
708def add_top_modules(path, components=None, cosmics=False):
710 Add the TOP reconstruction to the path.
712 :param path: The path to add the modules to.
713 :param components: The components to use or None to use all standard components.
714 :param cosmics: if True, steer TOP for cosmic reconstruction
716 if components
is None or 'TOP' in components:
717 path.add_module(
'TOPChannelMasker')
719 path.add_module(
'TOPCosmicT0Finder')
721 path.add_module(
'TOPBunchFinder')
722 path.add_module(
'TOPReconstructor')
725def add_cluster_expert_modules(path, components=None):
727 Add the KLMExpert and ClusterMatcher modules to the path.
729 :param path: The path to add the modules to.
730 :param components: The components to use or None to use all standard components.
732 if components
is None or (
'KLM' in components
and 'ECL' in components):
733 path.add_module(
'KLMExpert')
734 path.add_module(
'ClusterMatcher')
737def add_pid_module(path, components=None, run_klm_dnn=True):
739 Add the PID modules to the path.
741 :param path: The path to add the modules to.
742 :param components: The components to use or None to use all standard components.
743 :param run_klm_dnn: If True, add the ``KLMMuonIDDNNExpert`` module to the path.
744 This flag is automatically set to false on HLT and ExpressReco.
746 if components
is None or 'SVD' in components
or 'CDC' in components:
747 path.add_module(
'MdstPID')
748 if (components
is None or 'KLM' in components)
and run_klm_dnn:
749 path.add_module(
'KLMMuonIDDNNExpert')
752def add_klm_modules(path, components=None):
754 Add the KLM reconstruction modules to the path.
756 :param path: The path to add the modules to.
757 :param components: The components to use or None to use all standard components.
759 if components
is None or 'KLM' in components:
760 path.add_module(
'KLMReconstructor')
761 path.add_module(
'KLMClustersReconstructor')
762 path.add_module(
'KLMClusterAna')
765def add_klm_mc_matcher_module(path, components=None):
767 Add the KLM mc matcher module to the path.
769 :param path: The path to add the modules to.
770 :param components: The components to use or None to use all standard components.
772 if components
is None or 'KLM' in components:
773 path.add_module(
'MCMatcherKLMClusters')
776def add_muid_module(path, add_hits_to_reco_track=False, components=None):
778 Add the MuID module to the path.
780 :param path: The path to add the modules to.
781 :param add_hits_to_reco_track: Add the found KLM hits also to the RecoTrack. Make sure to refit the track afterwards.
782 :param components: The components to use or None to use all standard components.
785 if components
is None or (
'CDC' in components
and 'ECL' in components
and 'KLM' in components):
786 path.add_module(
'Muid',
787 addHitsToRecoTrack=add_hits_to_reco_track)
788 if components
is not None and 'CDC' in components:
789 if (
'ECL' not in components
and 'KLM' in components):
790 basf2.B2WARNING(
'You added KLM to the components list but not ECL: the module Muid, that is necessary '
791 'for correct muonID computation, will not be added to your reconstruction path. '
792 'Make sure that this is fine for your purposes, otherwise please include also ECL.')
793 if (
'ECL' in components
and 'KLM' not in components):
794 basf2.B2WARNING(
'You added ECL to the components list but not KLM: the module Muid, that is necessary '
795 'for correct ECLCluster-Track matching, will not be added to your reconstruction path. '
796 ' Make sure that this is fine for your purposes, otherwise please include also KLM.')
799def add_ecl_modules(path, components=None):
801 Add the ECL reconstruction modules to the path.
803 :param path: The path to add the modules to.
804 :param components: The components to use or None to use all standard components.
806 if components
is None or 'ECL' in components:
807 path.add_module(
'ECLWaveformFit')
808 path.add_module(
'ECLDigitCalibrator')
809 path.add_module(
'ECLEventT0')
810 path.add_module(
'ECLCRFinder')
811 path.add_module(
'ECLLocalMaximumFinder')
812 path.add_module(
'ECLSplitterN1')
813 path.add_module(
'ECLSplitterN2')
814 path.add_module(
'ECLShowerCorrector')
815 path.add_module(
'ECLShowerShape')
816 path.add_module(
'ECLClusterPSD')
817 path.add_module(
'ECLCovarianceMatrix')
821def add_ecl_finalizer_module(path, components=None):
823 Add the ECL finalizer module to the path.
825 :param path: The path to add the modules to.
826 :param components: The components to use or None to use all standard components.
829 if components
is None or 'ECL' in components:
830 path.add_module(
'ECLFinalizer')
833def add_ecl_track_cluster_modules(path, components=None):
835 Add the ECL track cluster matching module to the path.
837 :param path: The path to add the modules to.
838 :param components: The components to use or None to use all standard components.
840 if components
is None or (
'ECL' in components
and (
'PXD' in components
or 'SVD' in components
or 'CDC' in components)):
841 path.add_module(
'ECLTrackClusterMatching')
844def add_ecl_cluster_properties_modules(path, components=None):
846 Add the ECL cluster properties module to the path.
848 :param path: The path to add the modules to.
849 :param components: The components to use or None to use all standard components.
851 if components
is None or (
'ECL' in components
and (
'PXD' in components
or 'SVD' in components
or 'CDC' in components)):
852 path.add_module(
'ECLClusterProperties')
855def add_ecl_track_brem_finder(path, components=None):
857 Add the bremsstrahlung finding module to the path.
859 :param path: The path to add the modules to.
860 :param components: The components to use or None to use all standard components.
862 if components
is None or (
'ECL' in components
and (
'PXD' in components
or 'SVD' in components)):
863 path.add_module(
'ECLTrackBremFinder')
866def add_ecl_chargedpid_module(path, components=None, legacyMode=False):
868 Add the ECL charged PID module to the path.
870 :param path: The path to add the modules to.
871 :param components: The components to use or None to use all standard components.
872 :param legacyMode: Uses the simple E/p based charged PID instead of the MVA based charged PID.
873 This flag is automatically set to true on HLT and ExpressReco.
875 if components
is None or 'ECL' in components:
878 path.add_module(
'ECLChargedPID')
880 path.add_module(
'ECLFillCellIdMapping')
881 path.add_module(
'ECLChargedPIDMVA')
884def add_ecl_mc_matcher_module(path, components=None):
886 Add the ECL MC matcher module to the path.
888 :param path: The path to add the modules to.
889 :param components: The components to use or None to use all standard components.
891 if components
is None or 'ECL' in components:
892 path.add_module(
'MCMatcherECLClusters')
895def add_ext_module(path, components=None):
897 Add the extrapolation module to the path.
899 :param path: The path to add the modules to.
900 :param components: The components to use or None to use all standard components.
902 if components
is None or 'CDC' in components:
903 path.add_module(
'Ext')
906def add_dedx_modules(path, components=None, for_cdst_analysis=False):
908 Add the dE/dX reconstruction modules to the path.
910 :param path: The path to add the modules to.
911 :param components: The components to use or None to use all standard components.
912 :param for_cdst_analysis: if True, add only DedxPIDCreator module, otherwise add both
913 :param enableDebugOutput: enable/disable writing out debugging information to CDCDedxTracks
916 if components
is None or 'CDC' in components:
917 if for_cdst_analysis:
918 path.add_module(
'CDCDedxPIDCreator')
920 path.add_module(
'CDCDedxHitSaver')
921 path.add_module(
'CDCDedxPIDCreator')
924 if components
is None or 'SVD' in components:
925 if for_cdst_analysis:
926 path.add_module(
'VXDDedxPIDRemaker')
928 path.add_module(
'VXDDedxPID')
931def add_special_vxd_modules(path, components=None):
933 Add two modules that are not part of the standard reconstruction.
935 :param path: The path to add the modules to.
936 :param components: The components to use or None to use all standard components.
939 if not components
or (
'PXD' in components):
940 path.add_module(
"PXDClustersFromTracks")
941 if not components
or (
'SVD' in components):
942 path.add_module(
"SVDShaperDigitsFromTracks")
945def prepare_cdst_analysis(path, components=None, mc=False, add_eventt0_combiner=False, legacy_ecl_charged_pid=False):
947 Adds to a (analysis) path all the modules needed to analyse a cDST file in the raw+tracking format
948 for collisions/cosmics data or in the digits+tracking format for MC data.
950 :param path: The path to add the modules to.
951 :param components: The components to use or None to use all standard components.
952 :param mc: Are we running over MC data or not? If so, do not run the unpackers.
953 :param add_eventt0_combiner: If True, it adds the EventT0Combiner module when the post-tracking
954 reconstruction is run. This must NOT be used during the calibration, but it may be necessary
955 for validation purposes or for the user analyses.
956 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
957 MVA based charged particle ID (false).
963 components=components)
965 check_components(components)
966 path.add_module(
'Gearbox')
967 path.add_module(
'Geometry')
970 add_prefilter_pretracking_reconstruction(path,
971 components=components)
974 if components
is None or 'SVD' in components:
975 add_svd_reconstruction(path)
976 if components
is None or 'PXD' in components:
977 add_pxd_reconstruction(path)
980 path.add_module(
'SetupGenfitExtrapolation',
981 energyLossBrems=
False,
985 add_posttracking_reconstruction(path,
986 components=components,
987 for_cdst_analysis=
True,
988 add_eventt0_combiner_for_cdst=add_eventt0_combiner,
989 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
992def prepare_user_cdst_analysis(path, components=None, mc=False):
994 Adds to a (analysis) path all the modules needed to analyse a cDST file in the raw+tracking format
995 for collisions/cosmics data or in the digits+tracking format for MC data.
996 Differently from prepare_cdst_analysis(), this function add the EventT0Combiner module to the path,
997 which makes this function suitable for all the users and not only for the calibration expertes.
998 Note that the EventT0Combiner module is necessary for applying the proper EventT0 correction to
1001 :param path: The path to add the modules to.
1002 :param components: The components to use or None to use all standard components.
1003 :param mc: Are we running over MC data or not? If so, do not run the unpackers.
1005 prepare_cdst_analysis(path=path, components=components, mc=mc, add_eventt0_combiner=
True)