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,
355 enableDebugOutput=
True
365 add_postfilter_posttracking_reconstruction(
367 components=components,
368 addClusterExpertModules=addClusterExpertModules,
369 legacy_ecl_charged_pid=legacy_ecl_charged_pid,
370 run_klm_dnn=run_klm_dnn
381 path.add_module(
'StatisticsSummary').set_name(
'Sum_Postfilter_PostTracking')
384def add_cosmics_reconstruction(
388 skipGeometryAdding=False,
389 eventTimingExtraction=True,
390 addClusterExpertModules=True,
392 use_second_cdc_hits=False,
394 reconstruct_cdst=False,
396 legacy_ecl_charged_pid=False,
399 This function adds the standard reconstruction modules for cosmic data to a path.
400 Consists of tracking and the functionality provided by :func:`add_posttracking_reconstruction()`,
401 plus the modules to calculate the software trigger cuts.
403 :param path: Add the modules to this path.
404 :param components: list of geometry components to include reconstruction for, or None for all components.
405 :param pruneTracks: Delete all hits except the first and last of the tracks after the dEdX modules.
406 :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module and will add it,
407 if it is not already present in the path. In a setup with multiple (conditional) paths however, it can not
408 determine, if the geometry is already loaded. This flag can be used to just turn off the geometry adding at
409 all (but you will have to add it on your own then).
411 :param eventTimingExtraction: extract the event time
412 :param addClusterExpertModules: Add the cluster expert modules in the KLM and ECL. Turn this off to reduce
415 :param merge_tracks: The upper and lower half of the tracks should be merged together in one track
416 :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
418 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
420 :param reconstruct_cdst: run only the minimal reconstruction needed to produce the cdsts (raw+tracking+dE/dx)
421 :param posttracking: run reconstruction for outer detectors.
422 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
423 MVA based charged particle ID (false).
427 basf2.declare_cosmics()
430 check_components(components)
433 add_prefilter_pretracking_reconstruction(path,
434 components=components)
437 add_cr_tracking_reconstruction(path,
438 components=components,
440 skip_geometry_adding=skipGeometryAdding,
441 event_time_extraction=eventTimingExtraction,
442 merge_tracks=merge_tracks,
443 use_second_cdc_hits=use_second_cdc_hits)
446 path.add_module(
'StatisticsSummary').set_name(
'Sum_Tracking')
450 add_special_vxd_modules(path, components=components)
451 add_dedx_modules(path, components=components, enableDebugOutput=
True)
452 add_prune_tracks(path, components=components)
456 add_posttracking_reconstruction(path,
457 components=components,
458 pruneTracks=pruneTracks,
459 addClusterExpertModules=addClusterExpertModules,
460 add_muid_hits=add_muid_hits,
462 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
465def add_mc_reconstruction(path, components=None, pruneTracks=True, addClusterExpertModules=True,
466 use_second_cdc_hits=False, add_muid_hits=False, legacy_ecl_charged_pid=False):
468 This function adds the standard reconstruction modules with MC tracking
471 @param components list of geometry components to include reconstruction for, or None for all components.
472 @param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
473 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
474 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
475 MVA based charged particle ID (false).
482 add_prefilter_pretracking_reconstruction(path,
483 components=components)
486 add_mc_tracking_reconstruction(path,
487 components=components,
489 use_second_cdc_hits=use_second_cdc_hits)
492 path.add_module(
'StatisticsSummary').set_name(
'Sum_MC_Tracking')
495 add_posttracking_reconstruction(path,
496 components=components,
497 pruneTracks=pruneTracks,
498 add_muid_hits=add_muid_hits,
499 addClusterExpertModules=addClusterExpertModules,
500 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
503def add_prefilter_pretracking_reconstruction(path, components=None):
505 This function adds the standard reconstruction modules BEFORE tracking
508 :param path: The path to add the modules to.
509 :param components: list of geometry components to include reconstruction for, or None for all components.
512 add_ecl_modules(path, components)
515 path.add_module(
'StatisticsSummary').set_name(
'Sum_Clustering')
518def add_prefilter_posttracking_reconstruction(path,
521 for_cdst_analysis=False,
522 add_eventt0_combiner_for_cdst=False):
524 This function adds to the path the standard reconstruction modules after prefilter tracking
525 whoose outputs are also needed in the filter.
527 :param path: The path to add the modules to.
528 :param components: list of geometry components to include reconstruction for, or None for all components.
529 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
530 :param for_cdst_analysis: if True, EventT0Combiner is not added to path.
531 This is only needed by prepare_cdst_analysis().
532 :param add_eventt0_combiner_for_cdst: if True, the EventT0Combiner module is added to the path even if
533 for_cdst_analysis is False. This is useful for validation purposes for avoiding to run the full
534 add_reconstruction(). Note that, with the default settings (for_cdst_analysis=False and
535 add_eventt0_combiner_for_cdst=False), the EventT0Combiner module is added to the path.
538 add_ext_module(path, components)
541 if not for_cdst_analysis
or add_eventt0_combiner_for_cdst:
542 path.add_module(
"EventT0Combiner")
543 add_ecl_finalizer_module(path, components)
544 add_ecl_mc_matcher_module(path, components)
545 add_klm_modules(path, components)
546 add_klm_mc_matcher_module(path, components)
547 add_muid_module(path, add_hits_to_reco_track=add_muid_hits, components=components)
548 add_ecl_track_cluster_modules(path, components)
549 add_ecl_cluster_properties_modules(path, components)
552def add_postfilter_posttracking_reconstruction(path,
554 addClusterExpertModules=True,
556 for_cdst_analysis=False,
557 legacy_ecl_charged_pid=False,
560 This function adds to the path the standard reconstruction modules whoose outputs are not needed in the filter.
562 :param path: The path to add the modules to.
563 :param components: list of geometry components to include reconstruction for, or None for all components.
564 :param addClusterExpertModules: Add the cluster expert modules in the KLM and ECL. Turn this off to reduce
566 :param cosmics: if True, steer TOP for cosmic reconstruction.
567 :param for_cdst_analysis: if True, the OnlineEventT0Creator module is not added to the path.
568 This is only needed by prepare_cdst_analysis().
569 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
570 MVA based charged particle ID (false). This flag is automatically set to true on HLT and ExpressReco.
571 :param run_klm_dnn: If True, add the ``KLMMuonIDDNNExpert`` module to the path. This flag is automatically set to
572 false on HLT and ExpressReco.
575 add_dedx_modules(path, components, for_cdst_analysis=for_cdst_analysis)
576 add_top_modules(path, components, cosmics=cosmics)
577 add_arich_modules(path, components)
580 if not for_cdst_analysis:
581 path.add_module(
"OnlineEventT0Creator")
583 add_ecl_chargedpid_module(path, components, legacy_ecl_charged_pid)
584 add_pid_module(path, components, run_klm_dnn)
586 if addClusterExpertModules:
588 add_cluster_expert_modules(path, components)
590 add_ecl_track_brem_finder(path, components)
593def add_posttracking_reconstruction(path,
596 addClusterExpertModules=True,
599 for_cdst_analysis=False,
600 add_eventt0_combiner_for_cdst=False,
601 legacy_ecl_charged_pid=False):
603 This function adds the standard reconstruction modules after tracking
606 :param path: The path to add the modules to.
607 :param components: list of geometry components to include reconstruction for, or None for all components.
608 :param pruneTracks: Delete all hits except the first and last after the post-tracking modules.
609 :param addClusterExpertModules: Add the cluster expert modules in the KLM and ECL. Turn this off to reduce
611 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
612 :param cosmics: if True, steer TOP for cosmic reconstruction.
613 :param for_cdst_analysis: if True, the dEdx and PruneTracks modules are not added to the path, as well
614 as all EventT0 related modules.
615 This is only needed by prepare_cdst_analysis().
616 :param add_eventt0_combiner_for_cdst: if True, the EventT0Combiner module is added to the path even if
617 for_cdst_analysis is True. This is useful for validation purposes for avoiding to run the full
618 add_reconstruction(). Note that, with the default settings (for_cdst_analysis=False and
619 add_eventt0_combiner_for_cdst=False), the EventT0Combiner module is added to the path.
620 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
621 MVA based charged particle ID (false).
624 add_prefilter_posttracking_reconstruction(path,
625 components=components,
626 add_muid_hits=add_muid_hits,
627 for_cdst_analysis=for_cdst_analysis,
628 add_eventt0_combiner_for_cdst=add_eventt0_combiner_for_cdst)
630 add_postfilter_posttracking_reconstruction(path,
631 components=components,
632 addClusterExpertModules=addClusterExpertModules,
634 for_cdst_analysis=for_cdst_analysis,
635 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
639 if not for_cdst_analysis:
641 add_prune_tracks(path, components)
643 path.add_module(
'StatisticsSummary').set_name(
'Sum_Posttracking_Reconstruction')
646def add_cdst_output(path,
648 filename='cdst.root',
649 additionalBranches=None,
650 dataDescription=None,
651 ignoreInputModulesCheck=False):
653 This function adds the `RootOutput` module to a path with the settings needed to produce a cDST output.
654 The actual cDST output content depends on the value of the parameter `mc`:
655 * if `mc` is `False` (default setting), the cDST content is raw + tracking dataobjects;
656 * if `mc` is `True`, the cDST content is digits + MCParticles + tracking dataobjects.
658 @param path Path to add modules to.
659 @param mc Define the type of cDST output content: `False` for raw + tracking dataobjects, `True` for digits +
660 MCParticles + tracking dataobjects.
661 @param filename Output file name.
662 @param additionalBranches Additional objects/arrays of event durability to save
663 @param dataDescription Additional key->value pairs to be added as data description
664 fields to the output FileMetaData.
665 @param ignoreInputModulesCheck If True, do not enforce check on missing PXD modules in the input path.
666 Needed when a conditional path is passed as input.
669 branches = list(CDST_TRACKING_OBJECTS)
670 persistentBranches = [
'FileMetaData']
673 branches += ALWAYS_SAVE_OBJECTS + RAWDATA_OBJECTS
675 branches += list(DIGITS_OBJECTS) + [
677 'EventLevelTriggerTimeInfo',
678 'SoftwareTriggerResult',
680 persistentBranches += [
'BackgroundInfo']
682 if not ignoreInputModulesCheck
and "PXDClustersFromTracks" not in [module.name()
for module
in path.modules()]:
683 basf2.B2ERROR(
"PXDClustersFromTracks is required in CDST output but its module is not found in the input path!")
685 if dataDescription
is None:
687 dataDescription.setdefault(
"dataLevel",
"cdst")
689 if additionalBranches
is not None:
690 branches += additionalBranches
692 return path.add_module(
"RootOutput", outputFileName=filename, branchNames=branches,
693 branchNamesPersistent=persistentBranches, additionalDataDescription=dataDescription)
696def add_arich_modules(path, components=None):
698 Add the ARICH reconstruction to the path.
700 :param path: The path to add the modules to.
701 :param components: The components to use or None to use all standard components.
703 if components
is None or 'ARICH' in components:
704 path.add_module(
'ARICHFillHits')
705 path.add_module(
'ARICHReconstructor',
709def add_top_modules(path, components=None, cosmics=False):
711 Add the TOP reconstruction to the path.
713 :param path: The path to add the modules to.
714 :param components: The components to use or None to use all standard components.
715 :param cosmics: if True, steer TOP for cosmic reconstruction
717 if components
is None or 'TOP' in components:
718 path.add_module(
'TOPChannelMasker')
720 path.add_module(
'TOPCosmicT0Finder')
722 path.add_module(
'TOPBunchFinder')
723 path.add_module(
'TOPReconstructor')
726def add_cluster_expert_modules(path, components=None):
728 Add the KLMExpert and ClusterMatcher modules to the path.
730 :param path: The path to add the modules to.
731 :param components: The components to use or None to use all standard components.
733 if components
is None or (
'KLM' in components
and 'ECL' in components):
734 path.add_module(
'KLMExpert')
735 path.add_module(
'ClusterMatcher')
738def add_pid_module(path, components=None, run_klm_dnn=True):
740 Add the PID modules to the path.
742 :param path: The path to add the modules to.
743 :param components: The components to use or None to use all standard components.
744 :param run_klm_dnn: If True, add the ``KLMMuonIDDNNExpert`` module to the path.
745 This flag is automatically set to false on HLT and ExpressReco.
747 if components
is None or 'SVD' in components
or 'CDC' in components:
748 path.add_module(
'MdstPID')
749 if (components
is None or 'KLM' in components)
and run_klm_dnn:
750 path.add_module(
'KLMMuonIDDNNExpert')
753def add_klm_modules(path, components=None):
755 Add the KLM reconstruction modules to the path.
757 :param path: The path to add the modules to.
758 :param components: The components to use or None to use all standard components.
760 if components
is None or 'KLM' in components:
761 path.add_module(
'KLMReconstructor')
762 path.add_module(
'KLMClustersReconstructor')
763 path.add_module(
'KLMClusterAna')
766def add_klm_mc_matcher_module(path, components=None):
768 Add the KLM mc matcher module to the path.
770 :param path: The path to add the modules to.
771 :param components: The components to use or None to use all standard components.
773 if components
is None or 'KLM' in components:
774 path.add_module(
'MCMatcherKLMClusters')
777def add_muid_module(path, add_hits_to_reco_track=False, components=None):
779 Add the MuID module to the path.
781 :param path: The path to add the modules to.
782 :param add_hits_to_reco_track: Add the found KLM hits also to the RecoTrack. Make sure to refit the track afterwards.
783 :param components: The components to use or None to use all standard components.
786 if components
is None or (
'CDC' in components
and 'ECL' in components
and 'KLM' in components):
787 path.add_module(
'Muid',
788 addHitsToRecoTrack=add_hits_to_reco_track)
789 if components
is not None and 'CDC' in components:
790 if (
'ECL' not in components
and 'KLM' in components):
791 basf2.B2WARNING(
'You added KLM to the components list but not ECL: the module Muid, that is necessary '
792 'for correct muonID computation, will not be added to your reconstruction path. '
793 'Make sure that this is fine for your purposes, otherwise please include also ECL.')
794 if (
'ECL' in components
and 'KLM' not in components):
795 basf2.B2WARNING(
'You added ECL to the components list but not KLM: the module Muid, that is necessary '
796 'for correct ECLCluster-Track matching, will not be added to your reconstruction path. '
797 ' Make sure that this is fine for your purposes, otherwise please include also KLM.')
800def add_ecl_modules(path, components=None):
802 Add the ECL reconstruction modules to the path.
804 :param path: The path to add the modules to.
805 :param components: The components to use or None to use all standard components.
807 if components
is None or 'ECL' in components:
808 path.add_module(
'ECLWaveformFit')
809 path.add_module(
'ECLDigitCalibrator')
810 path.add_module(
'ECLEventT0')
811 path.add_module(
'ECLCRFinder')
812 path.add_module(
'ECLLocalMaximumFinder')
813 path.add_module(
'ECLSplitterN1')
814 path.add_module(
'ECLSplitterN2')
815 path.add_module(
'ECLShowerCorrector')
816 path.add_module(
'ECLShowerShape')
817 path.add_module(
'ECLClusterPSD')
818 path.add_module(
'ECLCovarianceMatrix')
822def add_ecl_finalizer_module(path, components=None):
824 Add the ECL finalizer module to the path.
826 :param path: The path to add the modules to.
827 :param components: The components to use or None to use all standard components.
830 if components
is None or 'ECL' in components:
831 path.add_module(
'ECLFinalizer')
834def add_ecl_track_cluster_modules(path, components=None):
836 Add the ECL track cluster matching module to the path.
838 :param path: The path to add the modules to.
839 :param components: The components to use or None to use all standard components.
841 if components
is None or (
'ECL' in components
and (
'PXD' in components
or 'SVD' in components
or 'CDC' in components)):
842 path.add_module(
'ECLTrackClusterMatching')
845def add_ecl_cluster_properties_modules(path, components=None):
847 Add the ECL cluster properties module to the path.
849 :param path: The path to add the modules to.
850 :param components: The components to use or None to use all standard components.
852 if components
is None or (
'ECL' in components
and (
'PXD' in components
or 'SVD' in components
or 'CDC' in components)):
853 path.add_module(
'ECLClusterProperties')
856def add_ecl_track_brem_finder(path, components=None):
858 Add the bremsstrahlung finding module to the path.
860 :param path: The path to add the modules to.
861 :param components: The components to use or None to use all standard components.
863 if components
is None or (
'ECL' in components
and (
'PXD' in components
or 'SVD' in components)):
864 path.add_module(
'ECLTrackBremFinder')
867def add_ecl_chargedpid_module(path, components=None, legacyMode=False):
869 Add the ECL charged PID module to the path.
871 :param path: The path to add the modules to.
872 :param components: The components to use or None to use all standard components.
873 :param legacyMode: Uses the simple E/p based charged PID instead of the MVA based charged PID.
874 This flag is automatically set to true on HLT and ExpressReco.
876 if components
is None or 'ECL' in components:
879 path.add_module(
'ECLChargedPID')
881 path.add_module(
'ECLFillCellIdMapping')
882 path.add_module(
'ECLChargedPIDMVA')
885def add_ecl_mc_matcher_module(path, components=None):
887 Add the ECL MC matcher module to the path.
889 :param path: The path to add the modules to.
890 :param components: The components to use or None to use all standard components.
892 if components
is None or 'ECL' in components:
893 path.add_module(
'MCMatcherECLClusters')
896def add_ext_module(path, components=None):
898 Add the extrapolation module to the path.
900 :param path: The path to add the modules to.
901 :param components: The components to use or None to use all standard components.
903 if components
is None or 'CDC' in components:
904 path.add_module(
'Ext')
907def add_dedx_modules(path, components=None, for_cdst_analysis=False, enableDebugOutput=False):
909 Add the dE/dX reconstruction modules to the path.
911 :param path: The path to add the modules to.
912 :param components: The components to use or None to use all standard components.
913 :param for_cdst_analysis: if True, add only DedxPIDCreator module, otherwise add both
914 :param enableDebugOutput: enable/disable writing out debugging information to CDCDedxTracks
917 if components
is None or 'CDC' in components:
918 if for_cdst_analysis:
919 path.add_module(
'CDCDedxPIDCreator', enableDebugOutput=
True)
921 path.add_module(
'CDCDedxHitSaver')
922 path.add_module(
'CDCDedxPIDCreator', enableDebugOutput=enableDebugOutput)
925 if components
is None or 'SVD' in components:
926 if for_cdst_analysis:
927 path.add_module(
'VXDDedxPIDRemaker')
929 path.add_module(
'VXDDedxPID')
932def add_special_vxd_modules(path, components=None):
934 Add two modules that are not part of the standard reconstruction.
936 :param path: The path to add the modules to.
937 :param components: The components to use or None to use all standard components.
940 if not components
or (
'PXD' in components):
941 path.add_module(
"PXDClustersFromTracks")
942 if not components
or (
'SVD' in components):
943 path.add_module(
"SVDShaperDigitsFromTracks")
946def prepare_cdst_analysis(path, components=None, mc=False, add_eventt0_combiner=False, legacy_ecl_charged_pid=False):
948 Adds to a (analysis) path all the modules needed to analyse a cDST file in the raw+tracking format
949 for collisions/cosmics data or in the digits+tracking format for MC data.
951 :param path: The path to add the modules to.
952 :param components: The components to use or None to use all standard components.
953 :param mc: Are we running over MC data or not? If so, do not run the unpackers.
954 :param add_eventt0_combiner: If True, it adds the EventT0Combiner module when the post-tracking
955 reconstruction is run. This must NOT be used during the calibration, but it may be necessary
956 for validation purposes or for the user analyses.
957 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
958 MVA based charged particle ID (false).
964 components=components)
966 check_components(components)
967 path.add_module(
'Gearbox')
968 path.add_module(
'Geometry')
971 add_prefilter_pretracking_reconstruction(path,
972 components=components)
975 if components
is None or 'SVD' in components:
976 add_svd_reconstruction(path)
977 if components
is None or 'PXD' in components:
978 add_pxd_reconstruction(path)
981 path.add_module(
'SetupGenfitExtrapolation',
982 energyLossBrems=
False,
986 add_posttracking_reconstruction(path,
987 components=components,
988 for_cdst_analysis=
True,
989 add_eventt0_combiner_for_cdst=add_eventt0_combiner,
990 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
993def prepare_user_cdst_analysis(path, components=None, mc=False):
995 Adds to a (analysis) path all the modules needed to analyse a cDST file in the raw+tracking format
996 for collisions/cosmics data or in the digits+tracking format for MC data.
997 Differently from prepare_cdst_analysis(), this function add the EventT0Combiner module to the path,
998 which makes this function suitable for all the users and not only for the calibration expertes.
999 Note that the EventT0Combiner module is necessary for applying the proper EventT0 correction to
1002 :param path: The path to add the modules to.
1003 :param components: The components to use or None to use all standard components.
1004 :param mc: Are we running over MC data or not? If so, do not run the unpackers.
1006 prepare_cdst_analysis(path=path, components=components, mc=mc, add_eventt0_combiner=
True)