13os.environ[
'OMP_THREAD_LIMIT'] =
"1"
17from geometry
import check_components, is_detector_present, are_detectors_present, is_any_detector_present
19from svd
import add_svd_reconstruction
20from pxd
import add_pxd_reconstruction
25 add_prefilter_tracking_reconstruction,
26 add_postfilter_tracking_reconstruction,
27 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, svd_standalone_mode="VXDTF2",
79 add_muid_hits=False, reconstruct_cdst=None,
80 use_random_numbers_for_hlt_prescale=True,
81 pxd_filtering_offline=False,
82 create_intercepts_for_pxd_ckf=False,
83 append_full_grid_cdc_eventt0=True,
84 legacy_ecl_charged_pid=False, emulate_HLT=False,
85 skip_full_grid_cdc_eventt0_if_svd_time_present=True,
86 switch_off_slow_modules_for_online=False,
87 use_cat_finder=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 svd_standalone_mode: Which SVD standalone tracking is used.
118 Options are "VXDTF2", "SVDHough", "VXDTF2_and_SVDHough", and "SVDHough_and_VXDTF2".
120 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
121 :param add_trigger_calculation: add the software trigger modules for monitoring (do not make any cut)
122 :param reconstruct_cdst: None for mdst, 'rawFormat' to reconstruct cdsts in rawFormat, 'fullFormat' for the
123 full (old) format. This parameter is needed when reconstructing cdsts, otherwise the
124 required PXD objects won't be added.
125 :param event_abort: A function to abort event processing at the given point. Should take three arguments: a module,
126 the condition and the error_flag to be set if these events are kept. If run on HLT this will not abort the event
127 but just remove all data except for the event information.
128 :param use_random_numbers_for_hlt_prescale: If True, the HLT filter prescales are applied using randomly
129 generated numbers, otherwise are applied using an internal counter.
130 :param pxd_filtering_offline: If True, PXD data reduction (ROI filtering) is applied during the track reconstruction.
131 The reconstructed SVD/CDC tracks are used to define the ROIs and reject all PXD clusters outside of these.
132 :param create_intercepts_for_pxd_ckf: If True, the PXDROIFinder is added to the path to create PXDIntercepts to be used
133 for hit filtering when creating the CKF relations. This independent of the offline PXD digit filtering which is
134 steered by 'pxd_filtering_offline'. This can be applied for both data and MC.
135 :param append_full_grid_cdc_eventt0: If True, the module FullGridChi2TrackTimeExtractor is added to the path
136 and provides the CDC temporary EventT0.
137 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
138 MVA based charged particle ID (false).
139 :param emulate_HLT: if True, it runs the reconstruction as it is run on HLT (e.g. without PXD).
140 If you want to use this flag on raw data, you should also exclude the following branches from RootInput: ROIs, ROIpayload
141 :param skip_full_grid_cdc_eventt0_if_svd_time_present: if true, and if also append_full_grid_cdc_eventt0 is true, the
142 FullGridChi2TrackTimeExtractor is only executed in the events where no SVD-based EventT0 is found. If false, but
143 append_full_grid_cdc_eventt0 is true, FullGridChi2TrackTimeExtractor will be executed in each event regardless of
144 SVD EventT0 being present. Has no effect if append_full_grid_cdc_eventt0 is false. Default: true
145 :param switch_off_slow_modules_for_online: if true, it switches off some modules in the reconstruction chain by overriding
146 other flags (e.g.: this flag overrides ``append_full_grid_cdc_eventt0``. On HLT and ExpressReco, this flag is set
147 to true in order to speed up the reconstruction.
148 :param use_cat_finder: if True, it runs the CDC AI Track Finder (CATFinder) as CDC track finding algorithm
149 instead of the default one.
157 if reconstruct_cdst ==
'rawFormat':
158 append_full_grid_cdc_eventt0 =
True
161 components = DEFAULT_HLT_COMPONENTS
164 if switch_off_slow_modules_for_online:
165 append_full_grid_cdc_eventt0 =
False
166 legacy_ecl_charged_pid =
True
169 add_prefilter_module(path, event_abort=default_event_abort)
172 add_prefilter_reconstruction(path,
173 components=components,
174 add_modules_for_trigger_calculation=add_trigger_calculation,
175 skipGeometryAdding=skipGeometryAdding,
176 trackFitHypotheses=trackFitHypotheses,
177 with_cdc_cellular_automaton=with_cdc_cellular_automaton,
178 use_second_cdc_hits=use_second_cdc_hits,
179 svd_standalone_mode=svd_standalone_mode,
180 add_muid_hits=add_muid_hits,
181 reconstruct_cdst=reconstruct_cdst,
182 pxd_filtering_offline=pxd_filtering_offline,
183 create_intercepts_for_pxd_ckf=create_intercepts_for_pxd_ckf,
184 append_full_grid_cdc_eventt0=append_full_grid_cdc_eventt0,
185 skip_full_grid_cdc_eventt0_if_svd_time_present=skip_full_grid_cdc_eventt0_if_svd_time_present,
186 switch_off_slow_modules_for_online=switch_off_slow_modules_for_online,
187 use_cat_finder=use_cat_finder)
190 if add_trigger_calculation
and are_detectors_present([
"CDC",
"ECL",
"KLM"], components):
191 add_filter_software_trigger(path,
192 use_random_numbers_for_prescale=use_random_numbers_for_hlt_prescale)
195 add_postfilter_reconstruction(path,
196 components=components,
197 pruneTracks=pruneTracks,
198 trackFitHypotheses=trackFitHypotheses,
199 addClusterExpertModules=addClusterExpertModules,
200 reconstruct_cdst=reconstruct_cdst,
201 legacy_ecl_charged_pid=legacy_ecl_charged_pid,
202 switch_off_slow_modules_for_online=switch_off_slow_modules_for_online)
205 if add_trigger_calculation
and are_detectors_present([
"CDC",
"ECL",
"KLM"], components):
206 add_skim_software_trigger(path)
209def add_prefilter_reconstruction(path,
211 add_modules_for_trigger_calculation=True,
212 skipGeometryAdding=False,
213 trackFitHypotheses=None,
214 with_cdc_cellular_automaton=False,
215 use_second_cdc_hits=False,
216 svd_standalone_mode="VXDTF2",
218 reconstruct_cdst=None,
219 pxd_filtering_offline=False,
220 create_intercepts_for_pxd_ckf=False,
221 append_full_grid_cdc_eventt0=True,
222 skip_full_grid_cdc_eventt0_if_svd_time_present=True,
223 switch_off_slow_modules_for_online=False,
224 use_cat_finder=False):
226 This function adds only the reconstruction modules required to calculate HLT filter decision to a path.
227 Consists of essential tracking and the functionality provided by :func:`add_prefilter_posttracking_reconstruction()`.
229 :param path: Add the modules to this path.
230 :param components: list of geometry components to include reconstruction for, or None for all components.
231 :param add_modules_for_trigger_calculation: add the modules necessary for computing the software trigger decision
232 during later stages (do not make any cut), relevant only when reconstruct_cdst is not None.
233 :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module and will add it,
234 if it is not already present in the path. In a setup with multiple (conditional) paths however, it can not
235 determine, if the geometry is already loaded. This flag can be used to just turn off the geometry adding at
236 all (but you will have to add it on your own then).
237 :param trackFitHypotheses: Change the additional fitted track fit hypotheses. If no argument is given,
238 the fitted hypotheses are pion, kaon and proton, i.e. [211, 321, 2212].
239 :param with_cdc_cellular_automaton: If true, in the CDC track finding the cellular automaton algorithm will be used too,
240 after the global algorithm (Legendre).
241 :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
242 :param svd_standalone_mode: Which SVD standalone tracking is used.
243 Options are "VXDTF2", "SVDHough", "VXDTF2_and_SVDHough", and "SVDHough_and_VXDTF2".
245 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
246 :param reconstruct_cdst: None for mdst, 'rawFormat' to reconstruct cdsts in rawFormat, 'fullFormat' for the
247 full (old) format. This parameter is needed when reconstructing cdsts, otherwise the
248 required PXD objects won't be added.
249 :param pxd_filtering_offline: If True, PXD data reduction (ROI filtering) is applied during the track reconstruction.
250 The reconstructed SVD/CDC tracks are used to define the ROIs and reject all PXD clusters outside of these.
251 :param create_intercepts_for_pxd_ckf: If True, the PXDROIFinder is added to the path to create PXDIntercepts to be used
252 for hit filtering when creating the CKF relations. This independent of the offline PXD digit filtering which is
253 steered by 'pxd_filtering_offline'. This can be applied for both data and MC.
254 :param append_full_grid_cdc_eventt0: If True, the module FullGridChi2TrackTimeExtractor is added to the path
255 and provides the CDC temporary EventT0.
256 :param skip_full_grid_cdc_eventt0_if_svd_time_present: if true, and if also append_full_grid_cdc_eventt0 is true, the
257 FullGridChi2TrackTimeExtractor is only executed in the events where no SVD-based EventT0 is found. If false, but
258 append_full_grid_cdc_eventt0 is true, FullGridChi2TrackTimeExtractor will be executed in each event regardless of
259 SVD EventT0 being present. Has no effect if append_full_grid_cdc_eventt0 is false. Default: true
260 :param switch_off_slow_modules_for_online: if true, it switches off some modules in the reconstruction chain by overriding
261 other flags (e.g.: this flag overrides ``append_full_grid_cdc_eventt0``. On HLT and ExpressReco, this flag is set
262 to true in order to speed up the reconstruction.
263 :param use_cat_finder: if True, it runs the CDC AI Track Finder (CATFinder) as CDC track finding algorithm
264 instead of the default one.
268 if switch_off_slow_modules_for_online:
269 append_full_grid_cdc_eventt0 =
False
272 from ROOT
import Belle2
275 check_components(components)
278 add_prefilter_pretracking_reconstruction(path, components=components)
281 add_prefilter_tracking_reconstruction(
283 components=components,
284 mcTrackFinding=
False,
285 skipGeometryAdding=skipGeometryAdding,
286 trackFitHypotheses=trackFitHypotheses,
287 with_cdc_cellular_automaton=with_cdc_cellular_automaton,
288 use_second_cdc_hits=use_second_cdc_hits,
289 svd_standalone_mode=svd_standalone_mode,
290 pxd_filtering_offline=pxd_filtering_offline,
291 create_intercepts_for_pxd_ckf=create_intercepts_for_pxd_ckf,
292 append_full_grid_cdc_eventt0=append_full_grid_cdc_eventt0,
293 skip_full_grid_cdc_eventt0_if_svd_time_present=skip_full_grid_cdc_eventt0_if_svd_time_present,
294 use_cat_finder=use_cat_finder)
297 path.add_module(
'StatisticsSummary').set_name(
'Sum_Prefilter_Tracking')
301 add_special_vxd_modules(path, components=components)
302 if reconstruct_cdst ==
'rawFormat' and not add_modules_for_trigger_calculation:
306 add_prefilter_posttracking_reconstruction(path,
307 components=components,
308 add_muid_hits=add_muid_hits)
311 path.add_module(
'StatisticsSummary').set_name(
'Sum_Prefilter_PostTracking')
314def add_postfilter_reconstruction(path,
317 trackFitHypotheses=None,
318 addClusterExpertModules=True,
319 reconstruct_cdst=None,
320 legacy_ecl_charged_pid=False,
321 switch_off_slow_modules_for_online=False):
323 This function adds the reconstruction modules not required to calculate HLT filter decision to a path.
325 :param path: Add the modules to this path.
326 :param components: list of geometry components to include reconstruction for, or None for all components.
327 :param pruneTracks: Delete all hits expect the first and the last from the found tracks.
328 :param trackFitHypotheses: Change the additional fitted track fit hypotheses. If no argument is given,
329 the fitted hypotheses are pion, kaon and proton, i.e. [211, 321, 2212].
330 :param addClusterExpertModules: Add the cluster expert modules in the KLM and ECL. Turn this off to
331 reduce execution time.
332 :param reconstruct_cdst: None for mdst, 'rawFormat' to reconstruct cdsts in rawFormat, 'fullFormat' for the
333 full (old) format. This parameter is needed when reconstructing cdsts, otherwise the
334 required PXD objects won't be added.
335 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
336 MVA based charged particle ID (false).
337 :param switch_off_slow_modules_for_online: if true, it switches off some modules in the reconstruction chain by overriding
338 other flags (e.g.: this flag overrides ``append_full_grid_cdc_eventt0``. On HLT and ExpressReco, this flag is set
339 to true in order to speed up the reconstruction.
343 flip_recoTrack =
True
346 if switch_off_slow_modules_for_online:
347 legacy_ecl_charged_pid =
True
348 flip_recoTrack =
False
353 add_postfilter_tracking_reconstruction(
355 components=components,
357 trackFitHypotheses=trackFitHypotheses,
358 flip_recoTrack=flip_recoTrack,
359 kink_finding=kink_finding
362 path.add_module(
'StatisticsSummary').set_name(
'Sum_Postfilter_Tracking')
365 if reconstruct_cdst ==
'rawFormat':
368 components=components
378 add_postfilter_posttracking_reconstruction(
380 components=components,
381 addClusterExpertModules=addClusterExpertModules,
382 legacy_ecl_charged_pid=legacy_ecl_charged_pid,
383 run_klm_dnn=run_klm_dnn
394 path.add_module(
'StatisticsSummary').set_name(
'Sum_Postfilter_PostTracking')
397def add_cosmics_reconstruction(
401 skipGeometryAdding=False,
402 eventTimingExtraction=True,
403 addClusterExpertModules=True,
405 use_second_cdc_hits=False,
407 reconstruct_cdst=False,
409 legacy_ecl_charged_pid=False,
412 This function adds the standard reconstruction modules for cosmic data to a path.
413 Consists of tracking and the functionality provided by :func:`add_posttracking_reconstruction()`,
414 plus the modules to calculate the software trigger cuts.
416 :param path: Add the modules to this path.
417 :param components: list of geometry components to include reconstruction for, or None for all components.
418 :param pruneTracks: Delete all hits except the first and last of the tracks after the dEdX modules.
419 :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module and will add it,
420 if it is not already present in the path. In a setup with multiple (conditional) paths however, it can not
421 determine, if the geometry is already loaded. This flag can be used to just turn off the geometry adding at
422 all (but you will have to add it on your own then).
424 :param eventTimingExtraction: extract the event time
425 :param addClusterExpertModules: Add the cluster expert modules in the KLM and ECL. Turn this off to reduce
428 :param merge_tracks: The upper and lower half of the tracks should be merged together in one track
429 :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
431 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
433 :param reconstruct_cdst: run only the minimal reconstruction needed to produce the cdsts (raw+tracking+dE/dx)
434 :param posttracking: run reconstruction for outer detectors.
435 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
436 MVA based charged particle ID (false).
440 basf2.declare_cosmics()
443 check_components(components)
446 add_prefilter_pretracking_reconstruction(path,
447 components=components)
450 add_cr_tracking_reconstruction(path,
451 components=components,
453 skip_geometry_adding=skipGeometryAdding,
454 event_time_extraction=eventTimingExtraction,
455 merge_tracks=merge_tracks,
456 use_second_cdc_hits=use_second_cdc_hits)
459 path.add_module(
'StatisticsSummary').set_name(
'Sum_Tracking')
463 add_special_vxd_modules(path, components=components)
464 add_dedx_modules(path, components=components)
465 add_prune_tracks(path, components=components)
469 add_posttracking_reconstruction(path,
470 components=components,
471 pruneTracks=pruneTracks,
472 addClusterExpertModules=addClusterExpertModules,
473 add_muid_hits=add_muid_hits,
475 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
478def add_prefilter_pretracking_reconstruction(path, components=None):
480 This function adds the standard reconstruction modules BEFORE tracking
483 :param path: The path to add the modules to.
484 :param components: list of geometry components to include reconstruction for, or None for all components.
487 add_ecl_modules(path, components)
490 path.add_module(
'StatisticsSummary').set_name(
'Sum_Clustering')
493def add_prefilter_posttracking_reconstruction(path,
496 for_cdst_analysis=False,
497 add_eventt0_combiner_for_cdst=False):
499 This function adds to the path the standard reconstruction modules after prefilter tracking
500 whoose outputs are also needed in the filter.
502 :param path: The path to add the modules to.
503 :param components: list of geometry components to include reconstruction for, or None for all components.
504 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
505 :param for_cdst_analysis: if True, EventT0Combiner is not added to path.
506 This is only needed by prepare_cdst_analysis().
507 :param add_eventt0_combiner_for_cdst: if True, the EventT0Combiner module is added to the path even if
508 for_cdst_analysis is False. This is useful for validation purposes for avoiding to run the full
509 add_reconstruction(). Note that, with the default settings (for_cdst_analysis=False and
510 add_eventt0_combiner_for_cdst=False), the EventT0Combiner module is added to the path.
513 add_ext_module(path, components)
516 if not for_cdst_analysis
or add_eventt0_combiner_for_cdst:
517 path.add_module(
"EventT0Combiner")
518 add_ecl_finalizer_module(path, components)
519 add_ecl_mc_matcher_module(path, components)
520 add_klm_modules(path, components)
521 add_klm_mc_matcher_module(path, components)
522 add_muid_module(path, add_hits_to_reco_track=add_muid_hits, components=components)
523 add_ecl_track_cluster_modules(path, components)
524 add_ecl_cluster_properties_modules(path, components)
527def add_postfilter_posttracking_reconstruction(path,
529 addClusterExpertModules=True,
531 for_cdst_analysis=False,
532 legacy_ecl_charged_pid=False,
535 This function adds to the path the standard reconstruction modules whoose outputs are not needed in the filter.
537 :param path: The path to add the modules to.
538 :param components: list of geometry components to include reconstruction for, or None for all components.
539 :param addClusterExpertModules: Add the cluster expert modules in the KLM and ECL. Turn this off to reduce
541 :param cosmics: if True, steer TOP for cosmic reconstruction.
542 :param for_cdst_analysis: if True, the OnlineEventT0Creator module is not added to the path.
543 This is only needed by prepare_cdst_analysis().
544 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
545 MVA based charged particle ID (false). This flag is automatically set to true on HLT and ExpressReco.
546 :param run_klm_dnn: If True, add the ``KLMMuonIDDNNExpert`` module to the path. This flag is automatically set to
547 false on HLT and ExpressReco.
550 add_dedx_modules(path, components, for_cdst_analysis=for_cdst_analysis)
551 add_top_modules(path, components, cosmics=cosmics)
552 add_arich_modules(path, components)
555 if not for_cdst_analysis:
556 path.add_module(
"OnlineEventT0Creator")
558 add_ecl_chargedpid_module(path, components, legacy_ecl_charged_pid)
559 add_pid_module(path, components, run_klm_dnn)
561 if addClusterExpertModules:
563 add_cluster_expert_modules(path, components)
565 add_ecl_track_brem_finder(path, components)
568def add_posttracking_reconstruction(path,
571 addClusterExpertModules=True,
574 for_cdst_analysis=False,
575 add_eventt0_combiner_for_cdst=False,
576 legacy_ecl_charged_pid=False):
578 This function adds the standard reconstruction modules after tracking
581 :param path: The path to add the modules to.
582 :param components: list of geometry components to include reconstruction for, or None for all components.
583 :param pruneTracks: Delete all hits except the first and last after the post-tracking modules.
584 :param addClusterExpertModules: Add the cluster expert modules in the KLM and ECL. Turn this off to reduce
586 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
587 :param cosmics: if True, steer TOP for cosmic reconstruction.
588 :param for_cdst_analysis: if True, the dEdx and PruneTracks modules are not added to the path, as well
589 as all EventT0 related modules.
590 This is only needed by prepare_cdst_analysis().
591 :param add_eventt0_combiner_for_cdst: if True, the EventT0Combiner module is added to the path even if
592 for_cdst_analysis is True. This is useful for validation purposes for avoiding to run the full
593 add_reconstruction(). Note that, with the default settings (for_cdst_analysis=False and
594 add_eventt0_combiner_for_cdst=False), the EventT0Combiner module is added to the path.
595 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
596 MVA based charged particle ID (false).
599 add_prefilter_posttracking_reconstruction(path,
600 components=components,
601 add_muid_hits=add_muid_hits,
602 for_cdst_analysis=for_cdst_analysis,
603 add_eventt0_combiner_for_cdst=add_eventt0_combiner_for_cdst)
605 add_postfilter_posttracking_reconstruction(path,
606 components=components,
607 addClusterExpertModules=addClusterExpertModules,
609 for_cdst_analysis=for_cdst_analysis,
610 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
614 if not for_cdst_analysis:
616 add_prune_tracks(path, components)
618 path.add_module(
'StatisticsSummary').set_name(
'Sum_Posttracking_Reconstruction')
621def add_cdst_output(path,
623 filename='cdst.root',
624 additionalBranches=None,
625 dataDescription=None,
626 ignoreInputModulesCheck=False):
628 This function adds the `RootOutput` module to a path with the settings needed to produce a cDST output.
629 The actual cDST output content depends on the value of the parameter `mc`:
630 * if `mc` is `False`, the cDST content is raw + tracking dataobjects;
631 * if `mc` is `True` (default setting), the cDST content is digits + MCParticles + tracking dataobjects.
633 @param path Path to add modules to.
634 @param mc Define the type of cDST output content: `False` for raw + tracking dataobjects, `True` for digits +
635 MCParticles + tracking dataobjects.
636 @param filename Output file name.
637 @param additionalBranches Additional objects/arrays of event durability to save
638 @param dataDescription Additional key->value pairs to be added as data description
639 fields to the output FileMetaData.
640 @param ignoreInputModulesCheck If True, do not enforce check on missing PXD modules in the input path.
641 Needed when a conditional path is passed as input.
644 branches = list(CDST_TRACKING_OBJECTS)
645 persistentBranches = [
'FileMetaData']
648 branches += ALWAYS_SAVE_OBJECTS + RAWDATA_OBJECTS
650 branches += list(DIGITS_OBJECTS) + [
652 'EventLevelTriggerTimeInfo',
653 'SoftwareTriggerResult',
655 persistentBranches += [
'BackgroundInfo']
657 if not ignoreInputModulesCheck
and "PXDClustersFromTracks" not in [module.name()
for module
in path.modules()]:
658 basf2.B2ERROR(
"PXDClustersFromTracks is required in CDST output but its module is not found in the input path!")
660 if dataDescription
is None:
662 dataDescription.setdefault(
"dataLevel",
"cdst")
664 if additionalBranches
is not None:
665 branches += additionalBranches
667 return path.add_module(
"RootOutput", outputFileName=filename, branchNames=branches,
668 branchNamesPersistent=persistentBranches, additionalDataDescription=dataDescription)
671def add_arich_modules(path, components=None):
673 Add the ARICH reconstruction to the path.
675 :param path: The path to add the modules to.
676 :param components: The components to use or None to use all standard components.
678 if is_detector_present(
"ARICH", components):
679 path.add_module(
'ARICHFillHits')
680 path.add_module(
'ARICHReconstructor',
684def add_top_modules(path, components=None, cosmics=False):
686 Add the TOP reconstruction to the path.
688 :param path: The path to add the modules to.
689 :param components: The components to use or None to use all standard components.
690 :param cosmics: if True, steer TOP for cosmic reconstruction
692 if is_detector_present(
"TOP", components):
693 path.add_module(
'TOPChannelMasker')
695 path.add_module(
'TOPCosmicT0Finder')
697 path.add_module(
'TOPBunchFinder')
698 path.add_module(
'TOPReconstructor')
701def add_cluster_expert_modules(path, components=None):
703 Add the ClusterMatcher module to the path.
705 :param path: The path to add the modules to.
706 :param components: The components to use or None to use all standard components.
708 if are_detectors_present([
"KLM",
"ECL"], components):
709 path.add_module(
'ClusterMatcher')
712def add_pid_module(path, components=None, run_klm_dnn=True):
714 Add the PID modules to the path.
716 :param path: The path to add the modules to.
717 :param components: The components to use or None to use all standard components.
718 :param run_klm_dnn: If True, add the ``KLMMuonIDDNNExpert`` module to the path.
719 This flag is automatically set to false on HLT and ExpressReco.
721 if is_any_detector_present([
"SVD",
"CDC"], components):
722 path.add_module(
'MdstPID')
723 if is_detector_present(
"KLM", components)
and run_klm_dnn:
724 path.add_module(
'KLMMuonIDDNNExpert')
727def add_klm_modules(path, components=None):
729 Add the KLM reconstruction modules to the path.
731 :param path: The path to add the modules to.
732 :param components: The components to use or None to use all standard components.
734 if is_detector_present(
"KLM", components):
735 path.add_module(
'KLMReconstructor')
736 path.add_module(
'KLMClustersReconstructor')
737 path.add_module(
'KLMClusterAna')
740def add_klm_mc_matcher_module(path, components=None):
742 Add the KLM mc matcher module to the path.
744 :param path: The path to add the modules to.
745 :param components: The components to use or None to use all standard components.
747 if is_detector_present(
"KLM", components):
748 path.add_module(
'MCMatcherKLMClusters')
751def add_muid_module(path, add_hits_to_reco_track=False, components=None):
753 Add the MuID module to the path.
755 :param path: The path to add the modules to.
756 :param add_hits_to_reco_track: Add the found KLM hits also to the RecoTrack. Make sure to refit the track afterwards.
757 :param components: The components to use or None to use all standard components.
760 if are_detectors_present([
"CDC",
"ECL",
"KLM"], components):
761 path.add_module(
'Muid',
762 addHitsToRecoTrack=add_hits_to_reco_track)
763 if is_detector_present(
"CDC", components):
764 if not is_detector_present(
"ECL", components)
and is_detector_present(
"KLM", components):
765 basf2.B2WARNING(
'You added KLM to the components list but not ECL: the module Muid, that is necessary '
766 'for correct muonID computation, will not be added to your reconstruction path. '
767 'Make sure that this is fine for your purposes, otherwise please include also ECL.')
768 if is_detector_present(
"ECL", components)
and not is_detector_present(
"KLM", components):
769 basf2.B2WARNING(
'You added ECL to the components list but not KLM: the module Muid, that is necessary '
770 'for correct ECLCluster-Track matching, will not be added to your reconstruction path. '
771 ' Make sure that this is fine for your purposes, otherwise please include also KLM.')
774def add_ecl_modules(path, components=None):
776 Add the ECL reconstruction modules to the path.
778 :param path: The path to add the modules to.
779 :param components: The components to use or None to use all standard components.
781 if is_detector_present(
"ECL", components):
782 path.add_module(
'ECLWaveformFit')
783 path.add_module(
'ECLDigitCalibrator')
784 path.add_module(
'ECLEventT0')
785 path.add_module(
'ECLCRFinder')
786 path.add_module(
'ECLLocalMaximumFinder')
787 path.add_module(
'ECLSplitterN1')
788 path.add_module(
'ECLSplitterN2')
789 path.add_module(
'ECLShowerCorrector')
790 path.add_module(
'ECLShowerShape')
791 path.add_module(
'ECLClusterPSD')
792 path.add_module(
'ECLCovarianceMatrix')
796def add_ecl_finalizer_module(path, components=None):
798 Add the ECL finalizer module to the path.
800 :param path: The path to add the modules to.
801 :param components: The components to use or None to use all standard components.
804 if is_detector_present(
"ECL", components):
805 path.add_module(
'ECLFinalizer')
808def add_ecl_track_cluster_modules(path, components=None):
810 Add the ECL track cluster matching module to the path.
812 :param path: The path to add the modules to.
813 :param components: The components to use or None to use all standard components.
815 if is_detector_present(
"ECL", components)
and is_any_detector_present([
"PXD",
"SVD",
"CDC"], components):
816 path.add_module(
'ECLTrackClusterMatching')
819def add_ecl_cluster_properties_modules(path, components=None):
821 Add the ECL cluster properties 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.
826 if is_detector_present(
"ECL", components)
and is_any_detector_present([
"PXD",
"SVD",
"CDC"], components):
827 path.add_module(
'ECLClusterProperties')
830def add_ecl_track_brem_finder(path, components=None):
832 Add the bremsstrahlung finding module to the path.
834 :param path: The path to add the modules to.
835 :param components: The components to use or None to use all standard components.
837 if is_detector_present(
"ECL", components)
and is_any_detector_present([
"PXD",
"SVD"], components):
838 path.add_module(
'ECLTrackBremFinder')
841def add_ecl_chargedpid_module(path, components=None, legacyMode=False):
843 Add the ECL charged PID module to the path.
845 :param path: The path to add the modules to.
846 :param components: The components to use or None to use all standard components.
847 :param legacyMode: Uses the simple E/p based charged PID instead of the MVA based charged PID.
848 This flag is automatically set to true on HLT and ExpressReco.
850 if is_detector_present(
"ECL", components):
853 path.add_module(
'ECLChargedPID')
855 path.add_module(
'ECLFillCellIdMapping')
856 path.add_module(
'ECLChargedPIDMVA')
859def add_ecl_mc_matcher_module(path, components=None):
861 Add the ECL MC matcher module to the path.
863 :param path: The path to add the modules to.
864 :param components: The components to use or None to use all standard components.
866 if is_detector_present(
"ECL", components):
867 path.add_module(
'MCMatcherECLClusters')
870def add_ext_module(path, components=None):
872 Add the extrapolation module to the path.
874 :param path: The path to add the modules to.
875 :param components: The components to use or None to use all standard components.
877 if is_detector_present(
"CDC", components):
878 path.add_module(
'Ext')
881def add_dedx_modules(path, components=None, for_cdst_analysis=False):
883 Add the dE/dX reconstruction modules to the path.
885 :param path: The path to add the modules to.
886 :param components: The components to use or None to use all standard components.
887 :param for_cdst_analysis: if True, add only DedxPIDCreator module, otherwise add both
890 if is_detector_present(
"CDC", components):
891 if for_cdst_analysis:
892 path.add_module(
'CDCDedxPIDCreator')
894 path.add_module(
'CDCDedxHitSaver')
895 path.add_module(
'CDCDedxPIDCreator')
898 if is_detector_present(
"SVD", components):
899 if for_cdst_analysis:
900 path.add_module(
'VXDDedxPIDRemaker')
902 path.add_module(
'VXDDedxPID')
905def add_special_vxd_modules(path, components=None):
907 Add two modules that are not part of the standard reconstruction.
909 :param path: The path to add the modules to.
910 :param components: The components to use or None to use all standard components.
913 if is_detector_present(
"PXD", components):
914 path.add_module(
"PXDClustersFromTracks")
915 if is_detector_present(
"SVD", components):
916 path.add_module(
"SVDShaperDigitsFromTracks")
919def prepare_cdst_analysis(path, components=None, mc=False, add_eventt0_combiner=False, legacy_ecl_charged_pid=False):
921 Adds to a (analysis) path all the modules needed to analyse a cDST file in the raw+tracking format
922 for collisions/cosmics data or in the digits+tracking format for MC data.
924 :param path: The path to add the modules to.
925 :param components: The components to use or None to use all standard components.
926 :param mc: Are we running over MC data or not? If so, do not run the unpackers.
927 :param add_eventt0_combiner: If True, it adds the EventT0Combiner module when the post-tracking
928 reconstruction is run. This must NOT be used during the calibration, but it may be necessary
929 for validation purposes or for the user analyses.
930 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true) or
931 MVA based charged particle ID (false).
936 from rawdata
import add_unpackers
938 components=components)
940 check_components(components)
941 path.add_module(
'Gearbox')
942 path.add_module(
'Geometry')
945 add_prefilter_pretracking_reconstruction(path,
946 components=components)
949 if is_detector_present(
"SVD", components):
950 add_svd_reconstruction(path)
951 if is_detector_present(
"PXD", components):
952 add_pxd_reconstruction(path)
955 path.add_module(
'SetupGenfitExtrapolation',
956 energyLossBrems=
False,
960 add_posttracking_reconstruction(path,
961 components=components,
962 for_cdst_analysis=
True,
963 add_eventt0_combiner_for_cdst=add_eventt0_combiner,
964 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
967def prepare_user_cdst_analysis(path, components=None, mc=False):
969 Adds to a (analysis) path all the modules needed to analyse a cDST file in the raw+tracking format
970 for collisions/cosmics data or in the digits+tracking format for MC data.
971 Differently from prepare_cdst_analysis(), this function add the EventT0Combiner module to the path,
972 which makes this function suitable for all the users and not only for the calibration expertes.
973 Note that the EventT0Combiner module is necessary for applying the proper EventT0 correction to
976 :param path: The path to add the modules to.
977 :param components: The components to use or None to use all standard components.
978 :param mc: Are we running over MC data or not? If so, do not run the unpackers.
980 prepare_cdst_analysis(path=path, components=components, mc=mc, add_eventt0_combiner=
True)