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 use_second_cdc_hits=False, add_muid_hits=False, reconstruct_cdst=None,
80 event_abort=default_event_abort, 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):
88 This function adds the standard reconstruction modules to a path.
89 Consists of clustering, tracking and the PID modules essentially
in this structure:
91 | :func:`add_reconstruction()`
92 | ├── :func:`add_prefilter_reconstruction()`
93 | │ ├── :func:`add_prefilter_pretracking_reconstruction()` : Clustering
94 | │ ├── ``add_prefilter_tracking_reconstruction()`` : Tracking essential
for HLT filter calculation
95 | │ └── :func:`add_prefilter_posttracking_reconstruction()` : PID
and clustering essential
for HLT
96 | └── :func:`add_postfilter_reconstruction()`
97 | ├── ``add_postfilter_tracking_reconstruction()`` : Rest of the tracking
98 | └── :func:`add_postfilter_posttracking_reconstruction()` : Rest of PID
and clustering
100 plus the modules to calculate the software trigger cuts.
102 :param path: Add the modules to this path.
103 :param components: list of geometry components to include reconstruction
for,
or None for all components.
104 :param pruneTracks: Delete all hits
except the first
and last of the tracks after the V0Finder modules.
105 :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module
and will add it,
106 if it
is not already present
in the path. In a setup
with multiple (conditional) paths however, it can
not
107 determine,
if the geometry
is already loaded. This flag can be used to just turn off the geometry adding at
108 all (but you will have to add it on your own then).
109 :param trackFitHypotheses: Change the additional fitted track fit hypotheses. If no argument
is given,
110 the fitted hypotheses are pion, muon
and proton, i.e. [211, 321, 2212].
111 :param addClusterExpertModules: Add the cluster expert modules
in the KLM
and ECL. Turn this off to reduce
113 :param use_second_cdc_hits: If true, the second hit information will be used
in the CDC track finding.
114 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
115 :param add_trigger_calculation: add the software trigger modules
for monitoring (do
not make any cut)
116 :param reconstruct_cdst:
None for mdst,
'rawFormat' to reconstruct cdsts
in rawFormat,
'fullFormat' for the
117 full (old) format. This parameter
is needed when reconstructing cdsts, otherwise the
118 required PXD objects won
't be added. :param event_abort: A function to abort event processing at the given point. Should take three arguments: a module,
119 the condition and the error_flag to be set
if these events are kept. If run on HLT this will
not abort the event
120 but just remove all data
except for the event information.
121 :param use_random_numbers_for_hlt_prescale: If
True, the HLT filter prescales are applied using randomly
122 generated numbers, otherwise are applied using an internal counter.
123 :param pxd_filtering_offline: If
True, PXD data reduction (ROI filtering)
is applied during the track reconstruction.
124 The reconstructed SVD/CDC tracks are used to define the ROIs
and reject all PXD clusters outside of these.
125 :param create_intercepts_for_pxd_ckf: If
True, the PXDROIFinder
is added to the path to create PXDIntercepts to be used
126 for hit filtering when creating the CKF relations. This independent of the offline PXD digit filtering which
is
127 steered by
'pxd_filtering_offline'. This can be applied
for both data
and MC.
128 :param append_full_grid_cdc_eventt0: If
True, the module FullGridChi2TrackTimeExtractor
is added to the path
129 and provides the CDC temporary EventT0.
130 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
131 MVA based charged particle ID (false).
132 :param emulate_HLT:
if True, it runs the reconstruction
as it
is run on HLT (e.g. without PXD).
133 If you want to use this flag on raw data, you should also exclude the following branches
from RootInput: ROIs, ROIpayload
134 :param skip_full_grid_cdc_eventt0_if_svd_time_present:
if true,
and if also append_full_grid_cdc_eventt0
is true, the
135 FullGridChi2TrackTimeExtractor
is only executed
in the events where no SVD-based EventT0
is found. If false, but
136 append_full_grid_cdc_eventt0
is true, FullGridChi2TrackTimeExtractor will be executed
in each event regardless of
137 SVD EventT0 being present. Has no effect
if append_full_grid_cdc_eventt0
is false. Default: true
138 :param switch_off_slow_modules_for_online:
if true, it switches off some modules
in the reconstruction chain by overriding
139 other flags (e.g.: this flag overrides ``append_full_grid_cdc_eventt0``. On HLT
and ExpressReco, this flag
is set
140 to true
in order to speed up the reconstruction.
148 if reconstruct_cdst ==
'rawFormat':
149 append_full_grid_cdc_eventt0 =
True
152 components = DEFAULT_HLT_COMPONENTS
155 if switch_off_slow_modules_for_online:
156 append_full_grid_cdc_eventt0 =
False
157 legacy_ecl_charged_pid =
True
160 add_prefilter_reconstruction(path,
161 components=components,
162 add_modules_for_trigger_calculation=add_trigger_calculation,
163 skipGeometryAdding=skipGeometryAdding,
164 trackFitHypotheses=trackFitHypotheses,
165 use_second_cdc_hits=use_second_cdc_hits,
166 add_muid_hits=add_muid_hits,
167 reconstruct_cdst=reconstruct_cdst,
168 event_abort=event_abort,
169 pxd_filtering_offline=pxd_filtering_offline,
170 create_intercepts_for_pxd_ckf=create_intercepts_for_pxd_ckf,
171 append_full_grid_cdc_eventt0=append_full_grid_cdc_eventt0,
172 skip_full_grid_cdc_eventt0_if_svd_time_present=skip_full_grid_cdc_eventt0_if_svd_time_present,
173 switch_off_slow_modules_for_online=switch_off_slow_modules_for_online)
176 if add_trigger_calculation
and (
not components
or (
"CDC" in components
and "ECL" in components
and "KLM" in components)):
177 add_filter_software_trigger(path,
178 use_random_numbers_for_prescale=use_random_numbers_for_hlt_prescale)
181 add_postfilter_reconstruction(path,
182 components=components,
183 pruneTracks=pruneTracks,
184 addClusterExpertModules=addClusterExpertModules,
185 reconstruct_cdst=reconstruct_cdst,
186 legacy_ecl_charged_pid=legacy_ecl_charged_pid,
187 switch_off_slow_modules_for_online=switch_off_slow_modules_for_online)
190 if add_trigger_calculation
and (
not components
or (
"CDC" in components
and "ECL" in components
and "KLM" in components)):
191 add_skim_software_trigger(path)
194def add_prefilter_reconstruction(path,
196 add_modules_for_trigger_calculation=True,
197 skipGeometryAdding=False,
198 trackFitHypotheses=None,
199 use_second_cdc_hits=False,
201 reconstruct_cdst=None,
202 event_abort=default_event_abort,
203 pxd_filtering_offline=False,
204 create_intercepts_for_pxd_ckf=False,
205 append_full_grid_cdc_eventt0=True,
206 skip_full_grid_cdc_eventt0_if_svd_time_present=True,
207 switch_off_slow_modules_for_online=False):
209 This function adds only the reconstruction modules required to calculate HLT filter decision to a path.
210 Consists of essential tracking and the functionality provided by :func:`add_prefilter_posttracking_reconstruction()`.
212 :param path: Add the modules to this path.
213 :param components: list of geometry components to include reconstruction
for,
or None for all components.
214 :param add_modules_for_trigger_calculation: add the modules necessary
for computing the software trigger decision
215 during later stages (do
not make any cut), relevant only when reconstruct_cdst
is not None.
216 :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module
and will add it,
217 if it
is not already present
in the path. In a setup
with multiple (conditional) paths however, it can
not
218 determine,
if the geometry
is already loaded. This flag can be used to just turn off the geometry adding at
219 all (but you will have to add it on your own then).
220 :param trackFitHypotheses: Change the additional fitted track fit hypotheses. If no argument
is given,
221 the fitted hypotheses are pion, muon
and proton, i.e. [211, 321, 2212].
222 :param use_second_cdc_hits: If true, the second hit information will be used
in the CDC track finding.
223 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
224 :param reconstruct_cdst:
None for mdst,
'rawFormat' to reconstruct cdsts
in rawFormat,
'fullFormat' for the
225 full (old) format. This parameter
is needed when reconstructing cdsts, otherwise the
226 required PXD objects won
't be added.
227 :param event_abort: A function to abort event processing at the given point. Should take three arguments: a module,
228 the condition and the error_flag to be set
if these events are kept. If run on HLT this will
not abort the event
229 but just remove all data
except for the event information.
230 :param pxd_filtering_offline: If
True, PXD data reduction (ROI filtering)
is applied during the track reconstruction.
231 The reconstructed SVD/CDC tracks are used to define the ROIs
and reject all PXD clusters outside of these.
232 :param create_intercepts_for_pxd_ckf: If
True, the PXDROIFinder
is added to the path to create PXDIntercepts to be used
233 for hit filtering when creating the CKF relations. This independent of the offline PXD digit filtering which
is
234 steered by
'pxd_filtering_offline'. This can be applied
for both data
and MC.
235 :param append_full_grid_cdc_eventt0: If
True, the module FullGridChi2TrackTimeExtractor
is added to the path
236 and provides the CDC temporary EventT0.
237 :param skip_full_grid_cdc_eventt0_if_svd_time_present:
if true,
and if also append_full_grid_cdc_eventt0
is true, the
238 FullGridChi2TrackTimeExtractor
is only executed
in the events where no SVD-based EventT0
is found. If false, but
239 append_full_grid_cdc_eventt0
is true, FullGridChi2TrackTimeExtractor will be executed
in each event regardless of
240 SVD EventT0 being present. Has no effect
if append_full_grid_cdc_eventt0
is false. Default: true
241 :param switch_off_slow_modules_for_online:
if true, it switches off some modules
in the reconstruction chain by overriding
242 other flags (e.g.: this flag overrides ``append_full_grid_cdc_eventt0``. On HLT
and ExpressReco, this flag
is set
243 to true
in order to speed up the reconstruction.
247 if switch_off_slow_modules_for_online:
248 append_full_grid_cdc_eventt0 =
False
251 from ROOT
import Belle2
254 check_components(components)
257 doom = path.add_module(
"EventsOfDoomBuster")
258 event_abort(doom,
">=1", Belle2.EventMetaData.c_ReconstructionAbort)
259 path.add_module(
'StatisticsSummary').set_name(
'Sum_EventsofDoomBuster')
262 add_prefilter_pretracking_reconstruction(path, components=components)
265 add_prefilter_tracking_reconstruction(
267 components=components,
268 mcTrackFinding=
False,
269 skipGeometryAdding=skipGeometryAdding,
270 trackFitHypotheses=trackFitHypotheses,
271 use_second_cdc_hits=use_second_cdc_hits,
272 pxd_filtering_offline=pxd_filtering_offline,
273 create_intercepts_for_pxd_ckf=create_intercepts_for_pxd_ckf,
274 append_full_grid_cdc_eventt0=append_full_grid_cdc_eventt0,
275 skip_full_grid_cdc_eventt0_if_svd_time_present=skip_full_grid_cdc_eventt0_if_svd_time_present)
278 path.add_module(
'StatisticsSummary').set_name(
'Sum_Prefilter_Tracking')
282 add_special_vxd_modules(path, components=components)
283 if reconstruct_cdst ==
'rawFormat' and not add_modules_for_trigger_calculation:
287 add_prefilter_posttracking_reconstruction(path,
288 components=components,
289 add_muid_hits=add_muid_hits)
292 path.add_module(
'StatisticsSummary').set_name(
'Sum_Prefilter_PostTracking')
295def add_postfilter_reconstruction(path,
298 addClusterExpertModules=True,
299 reconstruct_cdst=None,
300 legacy_ecl_charged_pid=False,
301 switch_off_slow_modules_for_online=False):
303 This function adds the reconstruction modules not required to calculate HLT filter decision to a path.
305 :param path: Add the modules to this path.
306 :param components: list of geometry components to include reconstruction
for,
or None for all components.
307 :param pruneTracks: Delete all hits expect the first
and the last
from the found tracks.
308 :param addClusterExpertModules: Add the cluster expert modules
in the KLM
and ECL. Turn this off to
309 reduce execution time.
310 :param reconstruct_cdst:
None for mdst,
'rawFormat' to reconstruct cdsts
in rawFormat,
'fullFormat' for the
311 full (old) format. This parameter
is needed when reconstructing cdsts, otherwise the
312 required PXD objects won
't be added.
313 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true)
or
314 MVA based charged particle ID (false).
315 :param switch_off_slow_modules_for_online:
if true, it switches off some modules
in the reconstruction chain by overriding
316 other flags (e.g.: this flag overrides ``append_full_grid_cdc_eventt0``. On HLT
and ExpressReco, this flag
is set
317 to true
in order to speed up the reconstruction.
321 flip_recoTrack =
True
324 if switch_off_slow_modules_for_online:
325 legacy_ecl_charged_pid =
True
326 flip_recoTrack =
False
331 add_postfilter_tracking_reconstruction(
333 components=components,
335 flip_recoTrack=flip_recoTrack,
336 kink_finding=kink_finding
339 path.add_module(
'StatisticsSummary').set_name(
'Sum_Postfilter_Tracking')
342 if reconstruct_cdst ==
'rawFormat':
343 add_dedx_modules(path, components=components)
345 add_prune_tracks(path, components)
349 add_postfilter_posttracking_reconstruction(
351 components=components,
352 addClusterExpertModules=addClusterExpertModules,
353 legacy_ecl_charged_pid=legacy_ecl_charged_pid,
354 run_klm_dnn=run_klm_dnn
365 path.add_module(
'StatisticsSummary').set_name(
'Sum_Postfilter_PostTracking')
368def add_cosmics_reconstruction(
372 skipGeometryAdding=False,
373 eventTimingExtraction=True,
374 addClusterExpertModules=True,
376 use_second_cdc_hits=False,
378 reconstruct_cdst=False,
380 legacy_ecl_charged_pid=False,
383 This function adds the standard reconstruction modules for cosmic data to a path.
384 Consists of tracking
and the functionality provided by :func:`add_posttracking_reconstruction()`,
385 plus the modules to calculate the software trigger cuts.
387 :param path: Add the modules to this path.
388 :param components: list of geometry components to include reconstruction
for,
or None for all components.
389 :param pruneTracks: Delete all hits
except the first
and last of the tracks after the dEdX modules.
390 :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module
and will add it,
391 if it
is not already present
in the path. In a setup
with multiple (conditional) paths however, it can
not
392 determine,
if the geometry
is already loaded. This flag can be used to just turn off the geometry adding at
393 all (but you will have to add it on your own then).
395 :param eventTimingExtraction: extract the event time
396 :param addClusterExpertModules: Add the cluster expert modules
in the KLM
and ECL. Turn this off to reduce
399 :param merge_tracks: The upper
and lower half of the tracks should be merged together
in one track
400 :param use_second_cdc_hits: If true, the second hit information will be used
in the CDC track finding.
402 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
404 :param reconstruct_cdst: run only the minimal reconstruction needed to produce the cdsts (raw+tracking+dE/dx)
405 :param posttracking: run reconstruction
for outer detectors.
406 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
407 MVA based charged particle ID (false).
411 basf2.declare_cosmics()
414 check_components(components)
417 add_prefilter_pretracking_reconstruction(path,
418 components=components)
421 add_cr_tracking_reconstruction(path,
422 components=components,
424 skip_geometry_adding=skipGeometryAdding,
425 event_time_extraction=eventTimingExtraction,
426 merge_tracks=merge_tracks,
427 use_second_cdc_hits=use_second_cdc_hits)
430 path.add_module(
'StatisticsSummary').set_name(
'Sum_Tracking')
434 add_special_vxd_modules(path, components=components)
435 add_dedx_modules(path, components=components)
436 add_prune_tracks(path, components=components)
440 add_posttracking_reconstruction(path,
441 components=components,
442 pruneTracks=pruneTracks,
443 addClusterExpertModules=addClusterExpertModules,
444 add_muid_hits=add_muid_hits,
446 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
449def add_mc_reconstruction(path, components=None, pruneTracks=True, addClusterExpertModules=True,
450 use_second_cdc_hits=False, add_muid_hits=False, legacy_ecl_charged_pid=False):
452 This function adds the standard reconstruction modules with MC tracking
455 @param components list of geometry components to include reconstruction
for,
or None for all components.
456 @param use_second_cdc_hits: If true, the second hit information will be used
in the CDC track finding.
457 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
458 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
459 MVA based charged particle ID (false).
466 add_prefilter_pretracking_reconstruction(path,
467 components=components)
470 add_mc_tracking_reconstruction(path,
471 components=components,
473 use_second_cdc_hits=use_second_cdc_hits)
476 path.add_module(
'StatisticsSummary').set_name(
'Sum_MC_Tracking')
479 add_posttracking_reconstruction(path,
480 components=components,
481 pruneTracks=pruneTracks,
482 add_muid_hits=add_muid_hits,
483 addClusterExpertModules=addClusterExpertModules,
484 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
487def add_prefilter_pretracking_reconstruction(path, components=None):
489 This function adds the standard reconstruction modules BEFORE tracking
492 :param path: The path to add the modules to.
493 :param components: list of geometry components to include reconstruction for,
or None for all components.
496 add_ecl_modules(path, components)
499 path.add_module(
'StatisticsSummary').set_name(
'Sum_Clustering')
502def add_prefilter_posttracking_reconstruction(path,
505 for_cdst_analysis=False,
506 add_eventt0_combiner_for_cdst=False):
508 This function adds to the path the standard reconstruction modules after prefilter tracking
509 whoose outputs are also needed in the filter.
511 :param path: The path to add the modules to.
512 :param components: list of geometry components to include reconstruction
for,
or None for all components.
513 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
514 :param for_cdst_analysis:
if True, EventT0Combiner
is not added to path.
515 This
is only needed by prepare_cdst_analysis().
516 :param add_eventt0_combiner_for_cdst:
if True, the EventT0Combiner module
is added to the path even
if
517 for_cdst_analysis
is False. This
is useful
for validation purposes
for avoiding to run the full
518 add_reconstruction(). Note that,
with the default settings (for_cdst_analysis=
False and
519 add_eventt0_combiner_for_cdst=
False), the EventT0Combiner module
is added to the path.
522 add_ext_module(path, components)
525 if not for_cdst_analysis
or add_eventt0_combiner_for_cdst:
526 path.add_module(
"EventT0Combiner")
527 add_ecl_finalizer_module(path, components)
528 add_ecl_mc_matcher_module(path, components)
529 add_klm_modules(path, components)
530 add_klm_mc_matcher_module(path, components)
531 add_muid_module(path, add_hits_to_reco_track=add_muid_hits, components=components)
532 add_ecl_track_cluster_modules(path, components)
533 add_ecl_cluster_properties_modules(path, components)
536def add_postfilter_posttracking_reconstruction(path,
538 addClusterExpertModules=True,
540 for_cdst_analysis=False,
541 legacy_ecl_charged_pid=False,
544 This function adds to the path the standard reconstruction modules whoose outputs are not needed
in the filter.
546 :param path: The path to add the modules to.
547 :param components: list of geometry components to include reconstruction
for,
or None for all components.
548 :param addClusterExpertModules: Add the cluster expert modules
in the KLM
and ECL. Turn this off to reduce
550 :param cosmics:
if True, steer TOP
for cosmic reconstruction.
551 :param for_cdst_analysis:
if True, the OnlineEventT0Creator module
is not added to the path.
552 This
is only needed by prepare_cdst_analysis().
553 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
554 MVA based charged particle ID (false). This flag
is automatically set to true on HLT
and ExpressReco.
555 :param run_klm_dnn: If
True, add the ``KLMMuonIDDNNExpert`` module to the path. This flag
is automatically set to
556 false on HLT
and ExpressReco.
559 add_dedx_modules(path, components, for_cdst_analysis=for_cdst_analysis)
560 add_top_modules(path, components, cosmics=cosmics)
561 add_arich_modules(path, components)
564 if not for_cdst_analysis:
565 path.add_module(
"OnlineEventT0Creator")
567 add_ecl_chargedpid_module(path, components, legacy_ecl_charged_pid)
568 add_pid_module(path, components, run_klm_dnn)
570 if addClusterExpertModules:
572 add_cluster_expert_modules(path, components)
574 add_ecl_track_brem_finder(path, components)
577def add_posttracking_reconstruction(path,
580 addClusterExpertModules=True,
583 for_cdst_analysis=False,
584 add_eventt0_combiner_for_cdst=False,
585 legacy_ecl_charged_pid=False):
587 This function adds the standard reconstruction modules after tracking
590 :param path: The path to add the modules to.
591 :param components: list of geometry components to include reconstruction for,
or None for all components.
592 :param pruneTracks: Delete all hits
except the first
and last after the post-tracking modules.
593 :param addClusterExpertModules: Add the cluster expert modules
in the KLM
and ECL. Turn this off to reduce
595 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
596 :param cosmics:
if True, steer TOP
for cosmic reconstruction.
597 :param for_cdst_analysis:
if True, the dEdx
and PruneTracks modules are
not added to the path,
as well
598 as all EventT0 related modules.
599 This
is only needed by prepare_cdst_analysis().
600 :param add_eventt0_combiner_for_cdst:
if True, the EventT0Combiner module
is added to the path even
if
601 for_cdst_analysis
is True. This
is useful
for validation purposes
for avoiding to run the full
602 add_reconstruction(). Note that,
with the default settings (for_cdst_analysis=
False and
603 add_eventt0_combiner_for_cdst=
False), the EventT0Combiner module
is added to the path.
604 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
605 MVA based charged particle ID (false).
608 add_prefilter_posttracking_reconstruction(path,
609 components=components,
610 add_muid_hits=add_muid_hits,
611 for_cdst_analysis=for_cdst_analysis,
612 add_eventt0_combiner_for_cdst=add_eventt0_combiner_for_cdst)
614 add_postfilter_posttracking_reconstruction(path,
615 components=components,
616 addClusterExpertModules=addClusterExpertModules,
618 for_cdst_analysis=for_cdst_analysis,
619 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
623 if not for_cdst_analysis:
625 add_prune_tracks(path, components)
627 path.add_module(
'StatisticsSummary').set_name(
'Sum_Posttracking_Reconstruction')
630def add_cdst_output(path,
632 filename='cdst.root',
633 additionalBranches=None,
634 dataDescription=None,
635 ignoreInputModulesCheck=False):
637 This function adds the `RootOutput` module to a path with the settings needed to produce a cDST output.
638 The actual cDST output content depends on the value of the parameter `mc`:
639 *
if `mc`
is `
False` (default setting), the cDST content
is raw + tracking dataobjects;
640 *
if `mc`
is `
True`, the cDST content
is digits + MCParticles + tracking dataobjects.
642 @param path Path to add modules to.
643 @param mc Define the type of cDST output content: `
False`
for raw + tracking dataobjects, `
True`
for digits +
644 MCParticles + tracking dataobjects.
645 @param filename Output file name.
646 @param additionalBranches Additional objects/arrays of event durability to save
647 @param dataDescription Additional key->value pairs to be added
as data description
648 fields to the output FileMetaData.
649 @param ignoreInputModulesCheck If
True, do
not enforce check on missing PXD modules
in the input path.
650 Needed when a conditional path
is passed
as input.
653 branches = list(CDST_TRACKING_OBJECTS)
654 persistentBranches = ['FileMetaData']
657 branches += ALWAYS_SAVE_OBJECTS + RAWDATA_OBJECTS
659 branches += list(DIGITS_OBJECTS) + [
661 'EventLevelTriggerTimeInfo',
662 'SoftwareTriggerResult',
664 persistentBranches += [
'BackgroundInfo']
666 if not ignoreInputModulesCheck
and "PXDClustersFromTracks" not in [module.name()
for module
in path.modules()]:
667 basf2.B2ERROR(
"PXDClustersFromTracks is required in CDST output but its module is not found in the input path!")
669 if dataDescription
is None:
671 dataDescription.setdefault(
"dataLevel",
"cdst")
673 if additionalBranches
is not None:
674 branches += additionalBranches
676 return path.add_module(
"RootOutput", outputFileName=filename, branchNames=branches,
677 branchNamesPersistent=persistentBranches, additionalDataDescription=dataDescription)
680def add_arich_modules(path, components=None):
682 Add the ARICH reconstruction to the path.
684 :param path: The path to add the modules to.
685 :param components: The components to use or None to use all standard components.
687 if components
is None or 'ARICH' in components:
688 path.add_module(
'ARICHFillHits')
689 path.add_module(
'ARICHReconstructor',
693def add_top_modules(path, components=None, cosmics=False):
695 Add the TOP 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.
699 :param cosmics:
if True, steer TOP
for cosmic reconstruction
701 if components
is None or 'TOP' in components:
702 path.add_module(
'TOPChannelMasker')
704 path.add_module(
'TOPCosmicT0Finder')
706 path.add_module(
'TOPBunchFinder')
707 path.add_module(
'TOPReconstructor')
710def add_cluster_expert_modules(path, components=None):
712 Add the KLMExpert and ClusterMatcher modules to the path.
714 :param path: The path to add the modules to.
715 :param components: The components to use
or None to use all standard components.
717 if components
is None or (
'KLM' in components
and 'ECL' in components):
718 path.add_module(
'KLMExpert')
719 path.add_module(
'ClusterMatcher')
722def add_pid_module(path, components=None, run_klm_dnn=True):
724 Add the PID modules to the path.
726 :param path: The path to add the modules to.
727 :param components: The components to use or None to use all standard components.
728 :param run_klm_dnn: If
True, add the ``KLMMuonIDDNNExpert`` module to the path.
729 This flag
is automatically set to false on HLT
and ExpressReco.
731 if components
is None or 'SVD' in components
or 'CDC' in components:
732 path.add_module(
'MdstPID')
733 if (components
is None or 'KLM' in components)
and run_klm_dnn:
734 path.add_module(
'KLMMuonIDDNNExpert')
737def add_klm_modules(path, components=None):
739 Add the KLM reconstruction modules to the path.
741 :param path: The path to add the modules to.
742 :param components: The components to use or None to use all standard components.
744 if components
is None or 'KLM' in components:
745 path.add_module(
'KLMReconstructor')
746 path.add_module(
'KLMClustersReconstructor')
749def add_klm_mc_matcher_module(path, components=None):
751 Add the KLM mc matcher module to the path.
753 :param path: The path to add the modules to.
754 :param components: The components to use or None to use all standard components.
756 if components
is None or 'KLM' in components:
757 path.add_module(
'MCMatcherKLMClusters')
760def add_muid_module(path, add_hits_to_reco_track=False, components=None):
762 Add the MuID module to the path.
764 :param path: The path to add the modules to.
765 :param add_hits_to_reco_track: Add the found KLM hits also to the RecoTrack. Make sure to refit the track afterwards.
766 :param components: The components to use or None to use all standard components.
769 if components
is None or (
'CDC' in components
and 'ECL' in components
and 'KLM' in components):
770 path.add_module(
'Muid',
771 addHitsToRecoTrack=add_hits_to_reco_track)
772 if components
is not None and 'CDC' in components:
773 if (
'ECL' not in components
and 'KLM' in components):
774 basf2.B2WARNING(
'You added KLM to the components list but not ECL: the module Muid, that is necessary '
775 'for correct muonID computation, will not be added to your reconstruction path. '
776 'Make sure that this is fine for your purposes, otherwise please include also ECL.')
777 if (
'ECL' in components
and 'KLM' not in components):
778 basf2.B2WARNING(
'You added ECL to the components list but not KLM: the module Muid, that is necessary '
779 'for correct ECLCluster-Track matching, will not be added to your reconstruction path. '
780 ' Make sure that this is fine for your purposes, otherwise please include also KLM.')
783def add_ecl_modules(path, components=None):
785 Add the ECL reconstruction modules to the path.
787 :param path: The path to add the modules to.
788 :param components: The components to use or None to use all standard components.
790 if components
is None or 'ECL' in components:
791 path.add_module(
'ECLWaveformFit')
792 path.add_module(
'ECLDigitCalibrator')
793 path.add_module(
'ECLEventT0')
794 path.add_module(
'ECLCRFinder')
795 path.add_module(
'ECLLocalMaximumFinder')
796 path.add_module(
'ECLSplitterN1')
797 path.add_module(
'ECLSplitterN2')
798 path.add_module(
'ECLShowerCorrector')
799 path.add_module(
'ECLShowerCalibrator')
800 path.add_module(
'ECLShowerShape')
801 path.add_module(
'ECLClusterPSD')
802 path.add_module(
'ECLCovarianceMatrix')
806def add_ecl_finalizer_module(path, components=None):
808 Add the ECL finalizer module to the path.
810 :param path: The path to add the modules to.
811 :param components: The components to use or None to use all standard components.
814 if components
is None or 'ECL' in components:
815 path.add_module(
'ECLFinalizer')
818def add_ecl_track_cluster_modules(path, components=None):
820 Add the ECL track cluster matching module to the path.
822 :param path: The path to add the modules to.
823 :param components: The components to use or None to use all standard components.
825 if components
is None or (
'ECL' in components
and (
'PXD' in components
or 'SVD' in components
or 'CDC' in components)):
826 path.add_module(
'ECLTrackClusterMatching')
829def add_ecl_cluster_properties_modules(path, components=None):
831 Add the ECL cluster properties module to the path.
833 :param path: The path to add the modules to.
834 :param components: The components to use or None to use all standard components.
836 if components
is None or (
'ECL' in components
and (
'PXD' in components
or 'SVD' in components
or 'CDC' in components)):
837 path.add_module(
'ECLClusterProperties')
840def add_ecl_track_brem_finder(path, components=None):
842 Add the bremsstrahlung finding module to the path.
844 :param path: The path to add the modules to.
845 :param components: The components to use or None to use all standard components.
847 if components
is None or (
'ECL' in components
and (
'PXD' in components
or 'SVD' in components)):
848 path.add_module(
'ECLTrackBremFinder')
851def add_ecl_chargedpid_module(path, components=None, legacyMode=False):
853 Add the ECL charged PID module to the path.
855 :param path: The path to add the modules to.
856 :param components: The components to use or None to use all standard components.
857 :param legacyMode: Uses the simple E/p based charged PID instead of the MVA based charged PID.
858 This flag
is automatically set to true on HLT
and ExpressReco.
860 if components
is None or 'ECL' in components:
863 path.add_module(
'ECLChargedPID')
865 path.add_module(
'ECLFillCellIdMapping')
866 path.add_module(
'ECLChargedPIDMVA')
869def add_ecl_mc_matcher_module(path, components=None):
871 Add the ECL MC matcher module to the path.
873 :param path: The path to add the modules to.
874 :param components: The components to use or None to use all standard components.
876 if components
is None or 'ECL' in components:
877 path.add_module(
'MCMatcherECLClusters')
880def add_ext_module(path, components=None):
882 Add the extrapolation module to the path.
884 :param path: The path to add the modules to.
885 :param components: The components to use or None to use all standard components.
887 if components
is None or 'CDC' in components:
888 path.add_module(
'Ext')
891def add_dedx_modules(path, components=None, for_cdst_analysis=False):
893 Add the dE/dX reconstruction modules to the path.
895 :param path: The path to add the modules to.
896 :param components: The components to use or None to use all standard components.
897 :param for_cdst_analysis:
if True, add only DedxPIDCreator module, otherwise add both
898 :param enableDebugOutput: enable/disable writing out debugging information to CDCDedxTracks
901 if components
is None or 'CDC' in components:
902 if for_cdst_analysis:
903 path.add_module(
'CDCDedxPIDCreator')
905 path.add_module(
'CDCDedxHitSaver')
906 path.add_module(
'CDCDedxPIDCreator')
909 if components
is None or 'SVD' in components:
910 if for_cdst_analysis:
911 path.add_module(
'VXDDedxPIDRemaker')
913 path.add_module(
'VXDDedxPID')
916def add_special_vxd_modules(path, components=None):
918 Add two modules that are not part of the standard reconstruction.
920 :param path: The path to add the modules to.
921 :param components: The components to use
or None to use all standard components.
924 if not components
or (
'PXD' in components):
925 path.add_module(
"PXDClustersFromTracks")
926 if not components
or (
'SVD' in components):
927 path.add_module(
"SVDShaperDigitsFromTracks")
930def prepare_cdst_analysis(path, components=None, mc=False, add_eventt0_combiner=False, legacy_ecl_charged_pid=False):
932 Adds to a (analysis) path all the modules needed to analyse a cDST file in the raw+tracking format
933 for collisions/cosmics data
or in the digits+tracking format
for MC data.
935 :param path: The path to add the modules to.
936 :param components: The components to use
or None to use all standard components.
937 :param mc: Are we running over MC data
or not? If so, do
not run the unpackers.
938 :param add_eventt0_combiner: If
True, it adds the EventT0Combiner module when the post-tracking
939 reconstruction
is run. This must NOT be used during the calibration, but it may be necessary
940 for validation purposes
or for the user analyses.
941 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
942 MVA based charged particle ID (false).
948 components=components)
950 check_components(components)
951 path.add_module(
'Gearbox')
952 path.add_module(
'Geometry')
955 add_prefilter_pretracking_reconstruction(path,
956 components=components)
959 if components
is None or 'SVD' in components:
960 add_svd_reconstruction(path)
961 if components
is None or 'PXD' in components:
962 add_pxd_reconstruction(path)
965 path.add_module(
'SetupGenfitExtrapolation',
966 energyLossBrems=
False,
970 add_posttracking_reconstruction(path,
971 components=components,
972 for_cdst_analysis=
True,
973 add_eventt0_combiner_for_cdst=add_eventt0_combiner,
974 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
977def prepare_user_cdst_analysis(path, components=None, mc=False):
979 Adds to a (analysis) path all the modules needed to analyse a cDST file in the raw+tracking format
980 for collisions/cosmics data
or in the digits+tracking format
for MC data.
981 Differently
from prepare_cdst_analysis(), this function add the EventT0Combiner module to the path,
982 which makes this function suitable
for all the users
and not only
for the calibration expertes.
983 Note that the EventT0Combiner module
is necessary
for applying the proper EventT0 correction to
986 :param path: The path to add the modules to.
987 :param components: The components to use
or None to use all standard components.
988 :param mc: Are we running over MC data
or not? If so, do
not run the unpackers.
990 prepare_cdst_analysis(path=path, components=components, mc=mc, add_eventt0_combiner=True)