13os.environ[
'OMP_THREAD_LIMIT'] =
"1"
17from geometry
import check_components
19from svd
import add_svd_reconstruction
20from pxd
import add_pxd_reconstruction
25 add_mc_tracking_reconstruction,
26 add_prefilter_tracking_reconstruction,
27 add_postfilter_tracking_reconstruction,
28 add_cr_tracking_reconstruction,
33 add_filter_software_trigger,
34 add_skim_software_trigger
38CDST_TRACKING_OBJECTS = (
39 'EventLevelTrackingInfo',
47 'SVDShaperDigitsFromTracks',
48 'PXDClustersFromTracks',
68def default_event_abort(module, condition, error_flag):
69 """Default event abort outside of HLT: Ignore the error flag and just stop
70 processing by giving an empty path"""
72 module.if_value(condition, p, basf2.AfterConditionPath.END)
75def add_reconstruction(path, components=None, pruneTracks=True, add_trigger_calculation=True, skipGeometryAdding=False,
76 trackFitHypotheses=None, addClusterExpertModules=True,
77 with_cdc_cellular_automaton=False,
78 use_second_cdc_hits=False, add_muid_hits=False, reconstruct_cdst=None,
79 event_abort=default_event_abort, use_random_numbers_for_hlt_prescale=True,
80 pxd_filtering_offline=False,
81 create_intercepts_for_pxd_ckf=False,
82 append_full_grid_cdc_eventt0=True,
83 legacy_ecl_charged_pid=False, emulate_HLT=False,
84 skip_full_grid_cdc_eventt0_if_svd_time_present=True,
85 switch_off_slow_modules_for_online=False):
87 This function adds the standard reconstruction modules to a path.
88 Consists of clustering, tracking and the PID modules essentially in this structure:
90 | :func:`add_reconstruction()`
91 | ├── :func:`add_prefilter_reconstruction()`
92 | │ ├── :func:`add_prefilter_pretracking_reconstruction()` : Clustering
93 | │ ├── ``add_prefilter_tracking_reconstruction()`` : Tracking essential for HLT filter calculation
94 | │ └── :func:`add_prefilter_posttracking_reconstruction()` : PID and clustering essential for HLT
95 | └── :func:`add_postfilter_reconstruction()`
96 | ├── ``add_postfilter_tracking_reconstruction()`` : Rest of the tracking
97 | └── :func:`add_postfilter_posttracking_reconstruction()` : Rest of PID and clustering
99 plus the modules to calculate the software trigger cuts.
101 :param path: Add the modules to this path.
102 :param components: list of geometry components to include reconstruction for, or None for all components.
103 :param pruneTracks: Delete all hits except the first and last of the tracks after the V0Finder modules.
104 :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module and will add it,
105 if it is not already present in the path. In a setup with multiple (conditional) paths however, it can not
106 determine, if the geometry is already loaded. This flag can be used to just turn off the geometry adding at
107 all (but you will have to add it on your own then).
108 :param trackFitHypotheses: Change the additional fitted track fit hypotheses. If no argument is given,
109 the fitted hypotheses are pion, kaon and proton, i.e. [211, 321, 2212].
110 :param addClusterExpertModules: Add the cluster expert modules in the KLM and ECL. Turn this off to reduce
112 :param with_cdc_cellular_automaton: If true, in the CDC track finding the cellular automaton algorithm will be used too,
113 after the global algorithm (Legendre).
114 :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
115 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
116 :param add_trigger_calculation: add the software trigger modules for monitoring (do not make any cut)
117 :param reconstruct_cdst: None for mdst, 'rawFormat' to reconstruct cdsts in rawFormat, 'fullFormat' for the
118 full (old) format. This parameter is needed when reconstructing cdsts, otherwise the
119 required PXD objects won't be added.
120 :param event_abort: A function to abort event processing at the given point. Should take three arguments: a module,
121 the condition and the error_flag to be set if these events are kept. If run on HLT this will not abort the event
122 but just remove all data except for the event information.
123 :param use_random_numbers_for_hlt_prescale: If True, the HLT filter prescales are applied using randomly
124 generated numbers, otherwise are applied using an internal counter.
125 :param pxd_filtering_offline: If True, PXD data reduction (ROI filtering) is applied during the track reconstruction.
126 The reconstructed SVD/CDC tracks are used to define the ROIs and reject all PXD clusters outside of these.
127 :param create_intercepts_for_pxd_ckf: If True, the PXDROIFinder is added to the path to create PXDIntercepts to be used
128 for hit filtering when creating the CKF relations. This independent of the offline PXD digit filtering which is
129 steered by 'pxd_filtering_offline'. This can be applied for both data and MC.
130 :param append_full_grid_cdc_eventt0: If True, the module FullGridChi2TrackTimeExtractor is added to the path
131 and provides the CDC temporary EventT0.
132 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
133 MVA based charged particle ID (false).
134 :param emulate_HLT: if True, it runs the reconstruction as it is run on HLT (e.g. without PXD).
135 If you want to use this flag on raw data, you should also exclude the following branches from RootInput: ROIs, ROIpayload
136 :param skip_full_grid_cdc_eventt0_if_svd_time_present: if true, and if also append_full_grid_cdc_eventt0 is true, the
137 FullGridChi2TrackTimeExtractor is only executed in the events where no SVD-based EventT0 is found. If false, but
138 append_full_grid_cdc_eventt0 is true, FullGridChi2TrackTimeExtractor will be executed in each event regardless of
139 SVD EventT0 being present. Has no effect if append_full_grid_cdc_eventt0 is false. Default: true
140 :param switch_off_slow_modules_for_online: if true, it switches off some modules in the reconstruction chain by overriding
141 other flags (e.g.: this flag overrides ``append_full_grid_cdc_eventt0``. On HLT and ExpressReco, this flag is set
142 to true in order to speed up the reconstruction.
150 if reconstruct_cdst ==
'rawFormat':
151 append_full_grid_cdc_eventt0 =
True
154 components = DEFAULT_HLT_COMPONENTS
157 if switch_off_slow_modules_for_online:
158 append_full_grid_cdc_eventt0 =
False
159 legacy_ecl_charged_pid =
True
162 add_prefilter_reconstruction(path,
163 components=components,
164 add_modules_for_trigger_calculation=add_trigger_calculation,
165 skipGeometryAdding=skipGeometryAdding,
166 trackFitHypotheses=trackFitHypotheses,
167 with_cdc_cellular_automaton=with_cdc_cellular_automaton,
168 use_second_cdc_hits=use_second_cdc_hits,
169 add_muid_hits=add_muid_hits,
170 reconstruct_cdst=reconstruct_cdst,
171 event_abort=event_abort,
172 pxd_filtering_offline=pxd_filtering_offline,
173 create_intercepts_for_pxd_ckf=create_intercepts_for_pxd_ckf,
174 append_full_grid_cdc_eventt0=append_full_grid_cdc_eventt0,
175 skip_full_grid_cdc_eventt0_if_svd_time_present=skip_full_grid_cdc_eventt0_if_svd_time_present,
176 switch_off_slow_modules_for_online=switch_off_slow_modules_for_online)
179 if add_trigger_calculation
and (
not components
or (
"CDC" in components
and "ECL" in components
and "KLM" in components)):
180 add_filter_software_trigger(path,
181 use_random_numbers_for_prescale=use_random_numbers_for_hlt_prescale)
184 add_postfilter_reconstruction(path,
185 components=components,
186 pruneTracks=pruneTracks,
187 addClusterExpertModules=addClusterExpertModules,
188 reconstruct_cdst=reconstruct_cdst,
189 legacy_ecl_charged_pid=legacy_ecl_charged_pid,
190 switch_off_slow_modules_for_online=switch_off_slow_modules_for_online)
193 if add_trigger_calculation
and (
not components
or (
"CDC" in components
and "ECL" in components
and "KLM" in components)):
194 add_skim_software_trigger(path)
197def add_prefilter_reconstruction(path,
199 add_modules_for_trigger_calculation=True,
200 skipGeometryAdding=False,
201 trackFitHypotheses=None,
202 with_cdc_cellular_automaton=False,
203 use_second_cdc_hits=False,
205 reconstruct_cdst=None,
206 event_abort=default_event_abort,
207 pxd_filtering_offline=False,
208 create_intercepts_for_pxd_ckf=False,
209 append_full_grid_cdc_eventt0=True,
210 skip_full_grid_cdc_eventt0_if_svd_time_present=True,
211 switch_off_slow_modules_for_online=False):
213 This function adds only the reconstruction modules required to calculate HLT filter decision to a path.
214 Consists of essential tracking and the functionality provided by :func:`add_prefilter_posttracking_reconstruction()`.
216 :param path: Add the modules to this path.
217 :param components: list of geometry components to include reconstruction for, or None for all components.
218 :param add_modules_for_trigger_calculation: add the modules necessary for computing the software trigger decision
219 during later stages (do not make any cut), relevant only when reconstruct_cdst is not None.
220 :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module and will add it,
221 if it is not already present in the path. In a setup with multiple (conditional) paths however, it can not
222 determine, if the geometry is already loaded. This flag can be used to just turn off the geometry adding at
223 all (but you will have to add it on your own then).
224 :param trackFitHypotheses: Change the additional fitted track fit hypotheses. If no argument is given,
225 the fitted hypotheses are pion, kaon and proton, i.e. [211, 321, 2212].
226 :param with_cdc_cellular_automaton: If true, in the CDC track finding the cellular automaton algorithm will be used too,
227 after the global algorithm (Legendre).
228 :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
229 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
230 :param reconstruct_cdst: None for mdst, 'rawFormat' to reconstruct cdsts in rawFormat, 'fullFormat' for the
231 full (old) format. This parameter is needed when reconstructing cdsts, otherwise the
232 required PXD objects won't be added.
233 :param event_abort: A function to abort event processing at the given point. Should take three arguments: a module,
234 the condition and the error_flag to be set if these events are kept. If run on HLT this will not abort the event
235 but just remove all data except for the event information.
236 :param pxd_filtering_offline: If True, PXD data reduction (ROI filtering) is applied during the track reconstruction.
237 The reconstructed SVD/CDC tracks are used to define the ROIs and reject all PXD clusters outside of these.
238 :param create_intercepts_for_pxd_ckf: If True, the PXDROIFinder is added to the path to create PXDIntercepts to be used
239 for hit filtering when creating the CKF relations. This independent of the offline PXD digit filtering which is
240 steered by 'pxd_filtering_offline'. This can be applied for both data and MC.
241 :param append_full_grid_cdc_eventt0: If True, the module FullGridChi2TrackTimeExtractor is added to the path
242 and provides the CDC temporary EventT0.
243 :param skip_full_grid_cdc_eventt0_if_svd_time_present: if true, and if also append_full_grid_cdc_eventt0 is true, the
244 FullGridChi2TrackTimeExtractor is only executed in the events where no SVD-based EventT0 is found. If false, but
245 append_full_grid_cdc_eventt0 is true, FullGridChi2TrackTimeExtractor will be executed in each event regardless of
246 SVD EventT0 being present. Has no effect if append_full_grid_cdc_eventt0 is false. Default: true
247 :param switch_off_slow_modules_for_online: if true, it switches off some modules in the reconstruction chain by overriding
248 other flags (e.g.: this flag overrides ``append_full_grid_cdc_eventt0``. On HLT and ExpressReco, this flag is set
249 to true in order to speed up the reconstruction.
253 if switch_off_slow_modules_for_online:
254 append_full_grid_cdc_eventt0 =
False
257 from ROOT
import Belle2
260 check_components(components)
263 doom = path.add_module(
"EventsOfDoomBuster")
264 event_abort(doom,
">=1", Belle2.EventMetaData.c_ReconstructionAbort)
265 path.add_module(
'StatisticsSummary').set_name(
'Sum_EventsofDoomBuster')
268 add_prefilter_pretracking_reconstruction(path, components=components)
271 add_prefilter_tracking_reconstruction(
273 components=components,
274 mcTrackFinding=
False,
275 skipGeometryAdding=skipGeometryAdding,
276 trackFitHypotheses=trackFitHypotheses,
277 with_cdc_cellular_automaton=with_cdc_cellular_automaton,
278 use_second_cdc_hits=use_second_cdc_hits,
279 pxd_filtering_offline=pxd_filtering_offline,
280 create_intercepts_for_pxd_ckf=create_intercepts_for_pxd_ckf,
281 append_full_grid_cdc_eventt0=append_full_grid_cdc_eventt0,
282 skip_full_grid_cdc_eventt0_if_svd_time_present=skip_full_grid_cdc_eventt0_if_svd_time_present)
285 path.add_module(
'StatisticsSummary').set_name(
'Sum_Prefilter_Tracking')
289 add_special_vxd_modules(path, components=components)
290 if reconstruct_cdst ==
'rawFormat' and not add_modules_for_trigger_calculation:
294 add_prefilter_posttracking_reconstruction(path,
295 components=components,
296 add_muid_hits=add_muid_hits)
299 path.add_module(
'StatisticsSummary').set_name(
'Sum_Prefilter_PostTracking')
302def add_postfilter_reconstruction(path,
305 addClusterExpertModules=True,
306 reconstruct_cdst=None,
307 legacy_ecl_charged_pid=False,
308 switch_off_slow_modules_for_online=False):
310 This function adds the reconstruction modules not required to calculate HLT filter decision to a path.
312 :param path: Add the modules to this path.
313 :param components: list of geometry components to include reconstruction for, or None for all components.
314 :param pruneTracks: Delete all hits expect the first and the last from the found tracks.
315 :param addClusterExpertModules: Add the cluster expert modules in the KLM and ECL. Turn this off to
316 reduce execution time.
317 :param reconstruct_cdst: None for mdst, 'rawFormat' to reconstruct cdsts in rawFormat, 'fullFormat' for the
318 full (old) format. This parameter is needed when reconstructing cdsts, otherwise the
319 required PXD objects won't be added.
320 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
321 MVA based charged particle ID (false).
322 :param switch_off_slow_modules_for_online: if true, it switches off some modules in the reconstruction chain by overriding
323 other flags (e.g.: this flag overrides ``append_full_grid_cdc_eventt0``. On HLT and ExpressReco, this flag is set
324 to true in order to speed up the reconstruction.
328 flip_recoTrack =
True
331 if switch_off_slow_modules_for_online:
332 legacy_ecl_charged_pid =
True
333 flip_recoTrack =
False
338 add_postfilter_tracking_reconstruction(
340 components=components,
342 flip_recoTrack=flip_recoTrack,
343 kink_finding=kink_finding
346 path.add_module(
'StatisticsSummary').set_name(
'Sum_Postfilter_Tracking')
349 if reconstruct_cdst ==
'rawFormat':
352 components=components
362 add_postfilter_posttracking_reconstruction(
364 components=components,
365 addClusterExpertModules=addClusterExpertModules,
366 legacy_ecl_charged_pid=legacy_ecl_charged_pid,
367 run_klm_dnn=run_klm_dnn
378 path.add_module(
'StatisticsSummary').set_name(
'Sum_Postfilter_PostTracking')
381def add_cosmics_reconstruction(
385 skipGeometryAdding=False,
386 eventTimingExtraction=True,
387 addClusterExpertModules=True,
389 use_second_cdc_hits=False,
391 reconstruct_cdst=False,
393 legacy_ecl_charged_pid=False,
396 This function adds the standard reconstruction modules for cosmic data to a path.
397 Consists of tracking and the functionality provided by :func:`add_posttracking_reconstruction()`,
398 plus the modules to calculate the software trigger cuts.
400 :param path: Add the modules to this path.
401 :param components: list of geometry components to include reconstruction for, or None for all components.
402 :param pruneTracks: Delete all hits except the first and last of the tracks after the dEdX modules.
403 :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module and will add it,
404 if it is not already present in the path. In a setup with multiple (conditional) paths however, it can not
405 determine, if the geometry is already loaded. This flag can be used to just turn off the geometry adding at
406 all (but you will have to add it on your own then).
408 :param eventTimingExtraction: extract the event time
409 :param addClusterExpertModules: Add the cluster expert modules in the KLM and ECL. Turn this off to reduce
412 :param merge_tracks: The upper and lower half of the tracks should be merged together in one track
413 :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
415 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
417 :param reconstruct_cdst: run only the minimal reconstruction needed to produce the cdsts (raw+tracking+dE/dx)
418 :param posttracking: run reconstruction for outer detectors.
419 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
420 MVA based charged particle ID (false).
424 basf2.declare_cosmics()
427 check_components(components)
430 add_prefilter_pretracking_reconstruction(path,
431 components=components)
434 add_cr_tracking_reconstruction(path,
435 components=components,
437 skip_geometry_adding=skipGeometryAdding,
438 event_time_extraction=eventTimingExtraction,
439 merge_tracks=merge_tracks,
440 use_second_cdc_hits=use_second_cdc_hits)
443 path.add_module(
'StatisticsSummary').set_name(
'Sum_Tracking')
447 add_special_vxd_modules(path, components=components)
448 add_dedx_modules(path, components=components)
449 add_prune_tracks(path, components=components)
453 add_posttracking_reconstruction(path,
454 components=components,
455 pruneTracks=pruneTracks,
456 addClusterExpertModules=addClusterExpertModules,
457 add_muid_hits=add_muid_hits,
459 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
462def add_mc_reconstruction(path, components=None, pruneTracks=True, addClusterExpertModules=True,
463 use_second_cdc_hits=False, add_muid_hits=False, legacy_ecl_charged_pid=False):
465 This function adds the standard reconstruction modules with MC tracking
468 @param components list of geometry components to include reconstruction for, or None for all components.
469 @param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
470 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
471 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
472 MVA based charged particle ID (false).
479 add_prefilter_pretracking_reconstruction(path,
480 components=components)
483 add_mc_tracking_reconstruction(path,
484 components=components,
486 use_second_cdc_hits=use_second_cdc_hits)
489 path.add_module(
'StatisticsSummary').set_name(
'Sum_MC_Tracking')
492 add_posttracking_reconstruction(path,
493 components=components,
494 pruneTracks=pruneTracks,
495 add_muid_hits=add_muid_hits,
496 addClusterExpertModules=addClusterExpertModules,
497 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
500def add_prefilter_pretracking_reconstruction(path, components=None):
502 This function adds the standard reconstruction modules BEFORE tracking
505 :param path: The path to add the modules to.
506 :param components: list of geometry components to include reconstruction for, or None for all components.
509 add_ecl_modules(path, components)
512 path.add_module(
'StatisticsSummary').set_name(
'Sum_Clustering')
515def add_prefilter_posttracking_reconstruction(path,
518 for_cdst_analysis=False,
519 add_eventt0_combiner_for_cdst=False):
521 This function adds to the path the standard reconstruction modules after prefilter tracking
522 whoose outputs are also needed in the filter.
524 :param path: The path to add the modules to.
525 :param components: list of geometry components to include reconstruction for, or None for all components.
526 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
527 :param for_cdst_analysis: if True, EventT0Combiner is not added to path.
528 This is only needed by prepare_cdst_analysis().
529 :param add_eventt0_combiner_for_cdst: if True, the EventT0Combiner module is added to the path even if
530 for_cdst_analysis is False. This is useful for validation purposes for avoiding to run the full
531 add_reconstruction(). Note that, with the default settings (for_cdst_analysis=False and
532 add_eventt0_combiner_for_cdst=False), the EventT0Combiner module is added to the path.
535 add_ext_module(path, components)
538 if not for_cdst_analysis
or add_eventt0_combiner_for_cdst:
539 path.add_module(
"EventT0Combiner")
540 add_ecl_finalizer_module(path, components)
541 add_ecl_mc_matcher_module(path, components)
542 add_klm_modules(path, components)
543 add_klm_mc_matcher_module(path, components)
544 add_muid_module(path, add_hits_to_reco_track=add_muid_hits, components=components)
545 add_ecl_track_cluster_modules(path, components)
546 add_ecl_cluster_properties_modules(path, components)
549def add_postfilter_posttracking_reconstruction(path,
551 addClusterExpertModules=True,
553 for_cdst_analysis=False,
554 legacy_ecl_charged_pid=False,
557 This function adds to the path the standard reconstruction modules whoose outputs are not needed in the filter.
559 :param path: The path to add the modules to.
560 :param components: list of geometry components to include reconstruction for, or None for all components.
561 :param addClusterExpertModules: Add the cluster expert modules in the KLM and ECL. Turn this off to reduce
563 :param cosmics: if True, steer TOP for cosmic reconstruction.
564 :param for_cdst_analysis: if True, the OnlineEventT0Creator module is not added to the path.
565 This is only needed by prepare_cdst_analysis().
566 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
567 MVA based charged particle ID (false). This flag is automatically set to true on HLT and ExpressReco.
568 :param run_klm_dnn: If True, add the ``KLMMuonIDDNNExpert`` module to the path. This flag is automatically set to
569 false on HLT and ExpressReco.
572 add_dedx_modules(path, components, for_cdst_analysis=for_cdst_analysis)
573 add_top_modules(path, components, cosmics=cosmics)
574 add_arich_modules(path, components)
577 if not for_cdst_analysis:
578 path.add_module(
"OnlineEventT0Creator")
580 add_ecl_chargedpid_module(path, components, legacy_ecl_charged_pid)
581 add_pid_module(path, components, run_klm_dnn)
583 if addClusterExpertModules:
585 add_cluster_expert_modules(path, components)
587 add_ecl_track_brem_finder(path, components)
590def add_posttracking_reconstruction(path,
593 addClusterExpertModules=True,
596 for_cdst_analysis=False,
597 add_eventt0_combiner_for_cdst=False,
598 legacy_ecl_charged_pid=False):
600 This function adds the standard reconstruction modules after tracking
603 :param path: The path to add the modules to.
604 :param components: list of geometry components to include reconstruction for, or None for all components.
605 :param pruneTracks: Delete all hits except the first and last after the post-tracking modules.
606 :param addClusterExpertModules: Add the cluster expert modules in the KLM and ECL. Turn this off to reduce
608 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
609 :param cosmics: if True, steer TOP for cosmic reconstruction.
610 :param for_cdst_analysis: if True, the dEdx and PruneTracks modules are not added to the path, as well
611 as all EventT0 related modules.
612 This is only needed by prepare_cdst_analysis().
613 :param add_eventt0_combiner_for_cdst: if True, the EventT0Combiner module is added to the path even if
614 for_cdst_analysis is True. This is useful for validation purposes for avoiding to run the full
615 add_reconstruction(). Note that, with the default settings (for_cdst_analysis=False and
616 add_eventt0_combiner_for_cdst=False), the EventT0Combiner module is added to the path.
617 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
618 MVA based charged particle ID (false).
621 add_prefilter_posttracking_reconstruction(path,
622 components=components,
623 add_muid_hits=add_muid_hits,
624 for_cdst_analysis=for_cdst_analysis,
625 add_eventt0_combiner_for_cdst=add_eventt0_combiner_for_cdst)
627 add_postfilter_posttracking_reconstruction(path,
628 components=components,
629 addClusterExpertModules=addClusterExpertModules,
631 for_cdst_analysis=for_cdst_analysis,
632 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
636 if not for_cdst_analysis:
638 add_prune_tracks(path, components)
640 path.add_module(
'StatisticsSummary').set_name(
'Sum_Posttracking_Reconstruction')
643def add_cdst_output(path,
645 filename='cdst.root',
646 additionalBranches=None,
647 dataDescription=None,
648 ignoreInputModulesCheck=False):
650 This function adds the `RootOutput` module to a path with the settings needed to produce a cDST output.
651 The actual cDST output content depends on the value of the parameter `mc`:
652 * if `mc` is `False`, the cDST content is raw + tracking dataobjects;
653 * if `mc` is `True` (default setting), the cDST content is digits + MCParticles + tracking dataobjects.
655 @param path Path to add modules to.
656 @param mc Define the type of cDST output content: `False` for raw + tracking dataobjects, `True` for digits +
657 MCParticles + tracking dataobjects.
658 @param filename Output file name.
659 @param additionalBranches Additional objects/arrays of event durability to save
660 @param dataDescription Additional key->value pairs to be added as data description
661 fields to the output FileMetaData.
662 @param ignoreInputModulesCheck If True, do not enforce check on missing PXD modules in the input path.
663 Needed when a conditional path is passed as input.
666 branches = list(CDST_TRACKING_OBJECTS)
667 persistentBranches = [
'FileMetaData']
670 branches += ALWAYS_SAVE_OBJECTS + RAWDATA_OBJECTS
672 branches += list(DIGITS_OBJECTS) + [
674 'EventLevelTriggerTimeInfo',
675 'SoftwareTriggerResult',
677 persistentBranches += [
'BackgroundInfo']
679 if not ignoreInputModulesCheck
and "PXDClustersFromTracks" not in [module.name()
for module
in path.modules()]:
680 basf2.B2ERROR(
"PXDClustersFromTracks is required in CDST output but its module is not found in the input path!")
682 if dataDescription
is None:
684 dataDescription.setdefault(
"dataLevel",
"cdst")
686 if additionalBranches
is not None:
687 branches += additionalBranches
689 return path.add_module(
"RootOutput", outputFileName=filename, branchNames=branches,
690 branchNamesPersistent=persistentBranches, additionalDataDescription=dataDescription)
693def add_arich_modules(path, components=None):
695 Add the ARICH reconstruction to the path.
697 :param path: The path to add the modules to.
698 :param components: The components to use or None to use all standard components.
700 if components
is None or 'ARICH' in components:
701 path.add_module(
'ARICHFillHits')
702 path.add_module(
'ARICHReconstructor',
706def add_top_modules(path, components=None, cosmics=False):
708 Add the TOP reconstruction to the path.
710 :param path: The path to add the modules to.
711 :param components: The components to use or None to use all standard components.
712 :param cosmics: if True, steer TOP for cosmic reconstruction
714 if components
is None or 'TOP' in components:
715 path.add_module(
'TOPChannelMasker')
717 path.add_module(
'TOPCosmicT0Finder')
719 path.add_module(
'TOPBunchFinder')
720 path.add_module(
'TOPReconstructor')
723def add_cluster_expert_modules(path, components=None):
725 Add the KLMExpert and ClusterMatcher modules to the path.
727 :param path: The path to add the modules to.
728 :param components: The components to use or None to use all standard components.
730 if components
is None or (
'KLM' in components
and 'ECL' in components):
731 path.add_module(
'KLMExpert')
732 path.add_module(
'ClusterMatcher')
735def add_pid_module(path, components=None, run_klm_dnn=True):
737 Add the PID modules to the path.
739 :param path: The path to add the modules to.
740 :param components: The components to use or None to use all standard components.
741 :param run_klm_dnn: If True, add the ``KLMMuonIDDNNExpert`` module to the path.
742 This flag is automatically set to false on HLT and ExpressReco.
744 if components
is None or 'SVD' in components
or 'CDC' in components:
745 path.add_module(
'MdstPID')
746 if (components
is None or 'KLM' in components)
and run_klm_dnn:
747 path.add_module(
'KLMMuonIDDNNExpert')
750def add_klm_modules(path, components=None):
752 Add the KLM reconstruction modules to the path.
754 :param path: The path to add the modules to.
755 :param components: The components to use or None to use all standard components.
757 if components
is None or 'KLM' in components:
758 path.add_module(
'KLMReconstructor')
759 path.add_module(
'KLMClustersReconstructor')
760 path.add_module(
'KLMClusterAna')
763def add_klm_mc_matcher_module(path, components=None):
765 Add the KLM mc matcher module to the path.
767 :param path: The path to add the modules to.
768 :param components: The components to use or None to use all standard components.
770 if components
is None or 'KLM' in components:
771 path.add_module(
'MCMatcherKLMClusters')
774def add_muid_module(path, add_hits_to_reco_track=False, components=None):
776 Add the MuID module to the path.
778 :param path: The path to add the modules to.
779 :param add_hits_to_reco_track: Add the found KLM hits also to the RecoTrack. Make sure to refit the track afterwards.
780 :param components: The components to use or None to use all standard components.
783 if components
is None or (
'CDC' in components
and 'ECL' in components
and 'KLM' in components):
784 path.add_module(
'Muid',
785 addHitsToRecoTrack=add_hits_to_reco_track)
786 if components
is not None and 'CDC' in components:
787 if (
'ECL' not in components
and 'KLM' in components):
788 basf2.B2WARNING(
'You added KLM to the components list but not ECL: the module Muid, that is necessary '
789 'for correct muonID computation, will not be added to your reconstruction path. '
790 'Make sure that this is fine for your purposes, otherwise please include also ECL.')
791 if (
'ECL' in components
and 'KLM' not in components):
792 basf2.B2WARNING(
'You added ECL to the components list but not KLM: the module Muid, that is necessary '
793 'for correct ECLCluster-Track matching, will not be added to your reconstruction path. '
794 ' Make sure that this is fine for your purposes, otherwise please include also KLM.')
797def add_ecl_modules(path, components=None):
799 Add the ECL reconstruction modules to the path.
801 :param path: The path to add the modules to.
802 :param components: The components to use or None to use all standard components.
804 if components
is None or 'ECL' in components:
805 path.add_module(
'ECLWaveformFit')
806 path.add_module(
'ECLDigitCalibrator')
807 path.add_module(
'ECLEventT0')
808 path.add_module(
'ECLCRFinder')
809 path.add_module(
'ECLLocalMaximumFinder')
810 path.add_module(
'ECLSplitterN1')
811 path.add_module(
'ECLSplitterN2')
812 path.add_module(
'ECLShowerCorrector')
813 path.add_module(
'ECLShowerShape')
814 path.add_module(
'ECLClusterPSD')
815 path.add_module(
'ECLCovarianceMatrix')
819def add_ecl_finalizer_module(path, components=None):
821 Add the ECL finalizer module to the path.
823 :param path: The path to add the modules to.
824 :param components: The components to use or None to use all standard components.
827 if components
is None or 'ECL' in components:
828 path.add_module(
'ECLFinalizer')
831def add_ecl_track_cluster_modules(path, components=None):
833 Add the ECL track cluster matching module to the path.
835 :param path: The path to add the modules to.
836 :param components: The components to use or None to use all standard components.
838 if components
is None or (
'ECL' in components
and (
'PXD' in components
or 'SVD' in components
or 'CDC' in components)):
839 path.add_module(
'ECLTrackClusterMatching')
842def add_ecl_cluster_properties_modules(path, components=None):
844 Add the ECL cluster properties module to the path.
846 :param path: The path to add the modules to.
847 :param components: The components to use or None to use all standard components.
849 if components
is None or (
'ECL' in components
and (
'PXD' in components
or 'SVD' in components
or 'CDC' in components)):
850 path.add_module(
'ECLClusterProperties')
853def add_ecl_track_brem_finder(path, components=None):
855 Add the bremsstrahlung finding module to the path.
857 :param path: The path to add the modules to.
858 :param components: The components to use or None to use all standard components.
860 if components
is None or (
'ECL' in components
and (
'PXD' in components
or 'SVD' in components)):
861 path.add_module(
'ECLTrackBremFinder')
864def add_ecl_chargedpid_module(path, components=None, legacyMode=False):
866 Add the ECL charged PID module to the path.
868 :param path: The path to add the modules to.
869 :param components: The components to use or None to use all standard components.
870 :param legacyMode: Uses the simple E/p based charged PID instead of the MVA based charged PID.
871 This flag is automatically set to true on HLT and ExpressReco.
873 if components
is None or 'ECL' in components:
876 path.add_module(
'ECLChargedPID')
878 path.add_module(
'ECLFillCellIdMapping')
879 path.add_module(
'ECLChargedPIDMVA')
882def add_ecl_mc_matcher_module(path, components=None):
884 Add the ECL MC matcher module to the path.
886 :param path: The path to add the modules to.
887 :param components: The components to use or None to use all standard components.
889 if components
is None or 'ECL' in components:
890 path.add_module(
'MCMatcherECLClusters')
893def add_ext_module(path, components=None):
895 Add the extrapolation module to the path.
897 :param path: The path to add the modules to.
898 :param components: The components to use or None to use all standard components.
900 if components
is None or 'CDC' in components:
901 path.add_module(
'Ext')
904def add_dedx_modules(path, components=None, for_cdst_analysis=False):
906 Add the dE/dX reconstruction modules to the path.
908 :param path: The path to add the modules to.
909 :param components: The components to use or None to use all standard components.
910 :param for_cdst_analysis: if True, add only DedxPIDCreator module, otherwise add both
913 if components
is None or 'CDC' in components:
914 if for_cdst_analysis:
915 path.add_module(
'CDCDedxPIDCreator')
917 path.add_module(
'CDCDedxHitSaver')
918 path.add_module(
'CDCDedxPIDCreator')
921 if components
is None or 'SVD' in components:
922 if for_cdst_analysis:
923 path.add_module(
'VXDDedxPIDRemaker')
925 path.add_module(
'VXDDedxPID')
928def add_special_vxd_modules(path, components=None):
930 Add two modules that are not part of the standard reconstruction.
932 :param path: The path to add the modules to.
933 :param components: The components to use or None to use all standard components.
936 if not components
or (
'PXD' in components):
937 path.add_module(
"PXDClustersFromTracks")
938 if not components
or (
'SVD' in components):
939 path.add_module(
"SVDShaperDigitsFromTracks")
942def prepare_cdst_analysis(path, components=None, mc=False, add_eventt0_combiner=False, legacy_ecl_charged_pid=False):
944 Adds to a (analysis) path all the modules needed to analyse a cDST file in the raw+tracking format
945 for collisions/cosmics data or in the digits+tracking format for MC data.
947 :param path: The path to add the modules to.
948 :param components: The components to use or None to use all standard components.
949 :param mc: Are we running over MC data or not? If so, do not run the unpackers.
950 :param add_eventt0_combiner: If True, it adds the EventT0Combiner module when the post-tracking
951 reconstruction is run. This must NOT be used during the calibration, but it may be necessary
952 for validation purposes or for the user analyses.
953 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
954 MVA based charged particle ID (false).
959 from rawdata
import add_unpackers
961 components=components)
963 check_components(components)
964 path.add_module(
'Gearbox')
965 path.add_module(
'Geometry')
968 add_prefilter_pretracking_reconstruction(path,
969 components=components)
972 if components
is None or 'SVD' in components:
973 add_svd_reconstruction(path)
974 if components
is None or 'PXD' in components:
975 add_pxd_reconstruction(path)
978 path.add_module(
'SetupGenfitExtrapolation',
979 energyLossBrems=
False,
983 add_posttracking_reconstruction(path,
984 components=components,
985 for_cdst_analysis=
True,
986 add_eventt0_combiner_for_cdst=add_eventt0_combiner,
987 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
990def prepare_user_cdst_analysis(path, components=None, mc=False):
992 Adds to a (analysis) path all the modules needed to analyse a cDST file in the raw+tracking format
993 for collisions/cosmics data or in the digits+tracking format for MC data.
994 Differently from prepare_cdst_analysis(), this function add the EventT0Combiner module to the path,
995 which makes this function suitable for all the users and not only for the calibration expertes.
996 Note that the EventT0Combiner module is necessary for applying the proper EventT0 correction to
999 :param path: The path to add the modules to.
1000 :param components: The components to use or None to use all standard components.
1001 :param mc: Are we running over MC data or not? If so, do not run the unpackers.
1003 prepare_cdst_analysis(path=path, components=components, mc=mc, add_eventt0_combiner=
True)