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, kaon
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, kaon
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':
345 components=components,
346 enableDebugOutput=
True
356 add_postfilter_posttracking_reconstruction(
358 components=components,
359 addClusterExpertModules=addClusterExpertModules,
360 legacy_ecl_charged_pid=legacy_ecl_charged_pid,
361 run_klm_dnn=run_klm_dnn
372 path.add_module(
'StatisticsSummary').set_name(
'Sum_Postfilter_PostTracking')
375def add_cosmics_reconstruction(
379 skipGeometryAdding=False,
380 eventTimingExtraction=True,
381 addClusterExpertModules=True,
383 use_second_cdc_hits=False,
385 reconstruct_cdst=False,
387 legacy_ecl_charged_pid=False,
390 This function adds the standard reconstruction modules for cosmic data to a path.
391 Consists of tracking
and the functionality provided by :func:`add_posttracking_reconstruction()`,
392 plus the modules to calculate the software trigger cuts.
394 :param path: Add the modules to this path.
395 :param components: list of geometry components to include reconstruction
for,
or None for all components.
396 :param pruneTracks: Delete all hits
except the first
and last of the tracks after the dEdX modules.
397 :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module
and will add it,
398 if it
is not already present
in the path. In a setup
with multiple (conditional) paths however, it can
not
399 determine,
if the geometry
is already loaded. This flag can be used to just turn off the geometry adding at
400 all (but you will have to add it on your own then).
402 :param eventTimingExtraction: extract the event time
403 :param addClusterExpertModules: Add the cluster expert modules
in the KLM
and ECL. Turn this off to reduce
406 :param merge_tracks: The upper
and lower half of the tracks should be merged together
in one track
407 :param use_second_cdc_hits: If true, the second hit information will be used
in the CDC track finding.
409 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
411 :param reconstruct_cdst: run only the minimal reconstruction needed to produce the cdsts (raw+tracking+dE/dx)
412 :param posttracking: run reconstruction
for outer detectors.
413 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
414 MVA based charged particle ID (false).
418 basf2.declare_cosmics()
421 check_components(components)
424 add_prefilter_pretracking_reconstruction(path,
425 components=components)
428 add_cr_tracking_reconstruction(path,
429 components=components,
431 skip_geometry_adding=skipGeometryAdding,
432 event_time_extraction=eventTimingExtraction,
433 merge_tracks=merge_tracks,
434 use_second_cdc_hits=use_second_cdc_hits)
437 path.add_module(
'StatisticsSummary').set_name(
'Sum_Tracking')
441 add_special_vxd_modules(path, components=components)
442 add_dedx_modules(path, components=components, enableDebugOutput=
True)
443 add_prune_tracks(path, components=components)
447 add_posttracking_reconstruction(path,
448 components=components,
449 pruneTracks=pruneTracks,
450 addClusterExpertModules=addClusterExpertModules,
451 add_muid_hits=add_muid_hits,
453 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
456def add_mc_reconstruction(path, components=None, pruneTracks=True, addClusterExpertModules=True,
457 use_second_cdc_hits=False, add_muid_hits=False, legacy_ecl_charged_pid=False):
459 This function adds the standard reconstruction modules with MC tracking
462 @param components list of geometry components to include reconstruction
for,
or None for all components.
463 @param use_second_cdc_hits: If true, the second hit information will be used
in the CDC track finding.
464 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
465 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
466 MVA based charged particle ID (false).
473 add_prefilter_pretracking_reconstruction(path,
474 components=components)
477 add_mc_tracking_reconstruction(path,
478 components=components,
480 use_second_cdc_hits=use_second_cdc_hits)
483 path.add_module(
'StatisticsSummary').set_name(
'Sum_MC_Tracking')
486 add_posttracking_reconstruction(path,
487 components=components,
488 pruneTracks=pruneTracks,
489 add_muid_hits=add_muid_hits,
490 addClusterExpertModules=addClusterExpertModules,
491 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
494def add_prefilter_pretracking_reconstruction(path, components=None):
496 This function adds the standard reconstruction modules BEFORE tracking
499 :param path: The path to add the modules to.
500 :param components: list of geometry components to include reconstruction for,
or None for all components.
503 add_ecl_modules(path, components)
506 path.add_module(
'StatisticsSummary').set_name(
'Sum_Clustering')
509def add_prefilter_posttracking_reconstruction(path,
512 for_cdst_analysis=False,
513 add_eventt0_combiner_for_cdst=False):
515 This function adds to the path the standard reconstruction modules after prefilter tracking
516 whoose outputs are also needed in the filter.
518 :param path: The path to add the modules to.
519 :param components: list of geometry components to include reconstruction
for,
or None for all components.
520 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
521 :param for_cdst_analysis:
if True, EventT0Combiner
is not added to path.
522 This
is only needed by prepare_cdst_analysis().
523 :param add_eventt0_combiner_for_cdst:
if True, the EventT0Combiner module
is added to the path even
if
524 for_cdst_analysis
is False. This
is useful
for validation purposes
for avoiding to run the full
525 add_reconstruction(). Note that,
with the default settings (for_cdst_analysis=
False and
526 add_eventt0_combiner_for_cdst=
False), the EventT0Combiner module
is added to the path.
529 add_ext_module(path, components)
532 if not for_cdst_analysis
or add_eventt0_combiner_for_cdst:
533 path.add_module(
"EventT0Combiner")
534 add_ecl_finalizer_module(path, components)
535 add_ecl_mc_matcher_module(path, components)
536 add_klm_modules(path, components)
537 add_klm_mc_matcher_module(path, components)
538 add_muid_module(path, add_hits_to_reco_track=add_muid_hits, components=components)
539 add_ecl_track_cluster_modules(path, components)
540 add_ecl_cluster_properties_modules(path, components)
543def add_postfilter_posttracking_reconstruction(path,
545 addClusterExpertModules=True,
547 for_cdst_analysis=False,
548 legacy_ecl_charged_pid=False,
551 This function adds to the path the standard reconstruction modules whoose outputs are not needed
in the filter.
553 :param path: The path to add the modules to.
554 :param components: list of geometry components to include reconstruction
for,
or None for all components.
555 :param addClusterExpertModules: Add the cluster expert modules
in the KLM
and ECL. Turn this off to reduce
557 :param cosmics:
if True, steer TOP
for cosmic reconstruction.
558 :param for_cdst_analysis:
if True, the OnlineEventT0Creator module
is not added to the path.
559 This
is only needed by prepare_cdst_analysis().
560 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
561 MVA based charged particle ID (false). This flag
is automatically set to true on HLT
and ExpressReco.
562 :param run_klm_dnn: If
True, add the ``KLMMuonIDDNNExpert`` module to the path. This flag
is automatically set to
563 false on HLT
and ExpressReco.
566 add_dedx_modules(path, components, for_cdst_analysis=for_cdst_analysis)
567 add_top_modules(path, components, cosmics=cosmics)
568 add_arich_modules(path, components)
571 if not for_cdst_analysis:
572 path.add_module(
"OnlineEventT0Creator")
574 add_ecl_chargedpid_module(path, components, legacy_ecl_charged_pid)
575 add_pid_module(path, components, run_klm_dnn)
577 if addClusterExpertModules:
579 add_cluster_expert_modules(path, components)
581 add_ecl_track_brem_finder(path, components)
584def add_posttracking_reconstruction(path,
587 addClusterExpertModules=True,
590 for_cdst_analysis=False,
591 add_eventt0_combiner_for_cdst=False,
592 legacy_ecl_charged_pid=False):
594 This function adds the standard reconstruction modules after tracking
597 :param path: The path to add the modules to.
598 :param components: list of geometry components to include reconstruction for,
or None for all components.
599 :param pruneTracks: Delete all hits
except the first
and last after the post-tracking modules.
600 :param addClusterExpertModules: Add the cluster expert modules
in the KLM
and ECL. Turn this off to reduce
602 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
603 :param cosmics:
if True, steer TOP
for cosmic reconstruction.
604 :param for_cdst_analysis:
if True, the dEdx
and PruneTracks modules are
not added to the path,
as well
605 as all EventT0 related modules.
606 This
is only needed by prepare_cdst_analysis().
607 :param add_eventt0_combiner_for_cdst:
if True, the EventT0Combiner module
is added to the path even
if
608 for_cdst_analysis
is True. This
is useful
for validation purposes
for avoiding to run the full
609 add_reconstruction(). Note that,
with the default settings (for_cdst_analysis=
False and
610 add_eventt0_combiner_for_cdst=
False), the EventT0Combiner module
is added to the path.
611 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
612 MVA based charged particle ID (false).
615 add_prefilter_posttracking_reconstruction(path,
616 components=components,
617 add_muid_hits=add_muid_hits,
618 for_cdst_analysis=for_cdst_analysis,
619 add_eventt0_combiner_for_cdst=add_eventt0_combiner_for_cdst)
621 add_postfilter_posttracking_reconstruction(path,
622 components=components,
623 addClusterExpertModules=addClusterExpertModules,
625 for_cdst_analysis=for_cdst_analysis,
626 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
630 if not for_cdst_analysis:
632 add_prune_tracks(path, components)
634 path.add_module(
'StatisticsSummary').set_name(
'Sum_Posttracking_Reconstruction')
637def add_cdst_output(path,
639 filename='cdst.root',
640 additionalBranches=None,
641 dataDescription=None,
642 ignoreInputModulesCheck=False):
644 This function adds the `RootOutput` module to a path with the settings needed to produce a cDST output.
645 The actual cDST output content depends on the value of the parameter `mc`:
646 *
if `mc`
is `
False` (default setting), the cDST content
is raw + tracking dataobjects;
647 *
if `mc`
is `
True`, the cDST content
is digits + MCParticles + tracking dataobjects.
649 @param path Path to add modules to.
650 @param mc Define the type of cDST output content: `
False`
for raw + tracking dataobjects, `
True`
for digits +
651 MCParticles + tracking dataobjects.
652 @param filename Output file name.
653 @param additionalBranches Additional objects/arrays of event durability to save
654 @param dataDescription Additional key->value pairs to be added
as data description
655 fields to the output FileMetaData.
656 @param ignoreInputModulesCheck If
True, do
not enforce check on missing PXD modules
in the input path.
657 Needed when a conditional path
is passed
as input.
660 branches = list(CDST_TRACKING_OBJECTS)
661 persistentBranches = ['FileMetaData']
664 branches += ALWAYS_SAVE_OBJECTS + RAWDATA_OBJECTS
666 branches += list(DIGITS_OBJECTS) + [
668 'EventLevelTriggerTimeInfo',
669 'SoftwareTriggerResult',
671 persistentBranches += [
'BackgroundInfo']
673 if not ignoreInputModulesCheck
and "PXDClustersFromTracks" not in [module.name()
for module
in path.modules()]:
674 basf2.B2ERROR(
"PXDClustersFromTracks is required in CDST output but its module is not found in the input path!")
676 if dataDescription
is None:
678 dataDescription.setdefault(
"dataLevel",
"cdst")
680 if additionalBranches
is not None:
681 branches += additionalBranches
683 return path.add_module(
"RootOutput", outputFileName=filename, branchNames=branches,
684 branchNamesPersistent=persistentBranches, additionalDataDescription=dataDescription)
687def add_arich_modules(path, components=None):
689 Add the ARICH reconstruction to the path.
691 :param path: The path to add the modules to.
692 :param components: The components to use or None to use all standard components.
694 if components
is None or 'ARICH' in components:
695 path.add_module(
'ARICHFillHits')
696 path.add_module(
'ARICHReconstructor',
700def add_top_modules(path, components=None, cosmics=False):
702 Add the TOP reconstruction to the path.
704 :param path: The path to add the modules to.
705 :param components: The components to use or None to use all standard components.
706 :param cosmics:
if True, steer TOP
for cosmic reconstruction
708 if components
is None or 'TOP' in components:
709 path.add_module(
'TOPChannelMasker')
711 path.add_module(
'TOPCosmicT0Finder')
713 path.add_module(
'TOPBunchFinder')
714 path.add_module(
'TOPReconstructor')
717def add_cluster_expert_modules(path, components=None):
719 Add the KLMExpert and ClusterMatcher modules to the path.
721 :param path: The path to add the modules to.
722 :param components: The components to use
or None to use all standard components.
724 if components
is None or (
'KLM' in components
and 'ECL' in components):
725 path.add_module(
'KLMExpert')
726 path.add_module(
'ClusterMatcher')
729def add_pid_module(path, components=None, run_klm_dnn=True):
731 Add the PID modules to the path.
733 :param path: The path to add the modules to.
734 :param components: The components to use or None to use all standard components.
735 :param run_klm_dnn: If
True, add the ``KLMMuonIDDNNExpert`` module to the path.
736 This flag
is automatically set to false on HLT
and ExpressReco.
738 if components
is None or 'SVD' in components
or 'CDC' in components:
739 path.add_module(
'MdstPID')
740 if (components
is None or 'KLM' in components)
and run_klm_dnn:
741 path.add_module(
'KLMMuonIDDNNExpert')
744def add_klm_modules(path, components=None):
746 Add the KLM reconstruction modules to the path.
748 :param path: The path to add the modules to.
749 :param components: The components to use or None to use all standard components.
751 if components
is None or 'KLM' in components:
752 path.add_module(
'KLMReconstructor')
753 path.add_module(
'KLMClustersReconstructor')
756def add_klm_mc_matcher_module(path, components=None):
758 Add the KLM mc matcher module to the path.
760 :param path: The path to add the modules to.
761 :param components: The components to use or None to use all standard components.
763 if components
is None or 'KLM' in components:
764 path.add_module(
'MCMatcherKLMClusters')
767def add_muid_module(path, add_hits_to_reco_track=False, components=None):
769 Add the MuID module to the path.
771 :param path: The path to add the modules to.
772 :param add_hits_to_reco_track: Add the found KLM hits also to the RecoTrack. Make sure to refit the track afterwards.
773 :param components: The components to use or None to use all standard components.
776 if components
is None or (
'CDC' in components
and 'ECL' in components
and 'KLM' in components):
777 path.add_module(
'Muid',
778 addHitsToRecoTrack=add_hits_to_reco_track)
779 if components
is not None and 'CDC' in components:
780 if (
'ECL' not in components
and 'KLM' in components):
781 basf2.B2WARNING(
'You added KLM to the components list but not ECL: the module Muid, that is necessary '
782 'for correct muonID computation, will not be added to your reconstruction path. '
783 'Make sure that this is fine for your purposes, otherwise please include also ECL.')
784 if (
'ECL' in components
and 'KLM' not in components):
785 basf2.B2WARNING(
'You added ECL to the components list but not KLM: the module Muid, that is necessary '
786 'for correct ECLCluster-Track matching, will not be added to your reconstruction path. '
787 ' Make sure that this is fine for your purposes, otherwise please include also KLM.')
790def add_ecl_modules(path, components=None):
792 Add the ECL reconstruction modules to the path.
794 :param path: The path to add the modules to.
795 :param components: The components to use or None to use all standard components.
797 if components
is None or 'ECL' in components:
798 path.add_module(
'ECLWaveformFit')
799 path.add_module(
'ECLDigitCalibrator')
800 path.add_module(
'ECLEventT0')
801 path.add_module(
'ECLCRFinder')
802 path.add_module(
'ECLLocalMaximumFinder')
803 path.add_module(
'ECLSplitterN1')
804 path.add_module(
'ECLSplitterN2')
805 path.add_module(
'ECLShowerCorrector')
806 path.add_module(
'ECLShowerShape')
807 path.add_module(
'ECLClusterPSD')
808 path.add_module(
'ECLCovarianceMatrix')
812def add_ecl_finalizer_module(path, components=None):
814 Add the ECL finalizer module to the path.
816 :param path: The path to add the modules to.
817 :param components: The components to use or None to use all standard components.
820 if components
is None or 'ECL' in components:
821 path.add_module(
'ECLFinalizer')
824def add_ecl_track_cluster_modules(path, components=None):
826 Add the ECL track cluster matching module to the path.
828 :param path: The path to add the modules to.
829 :param components: The components to use or None to use all standard components.
831 if components
is None or (
'ECL' in components
and (
'PXD' in components
or 'SVD' in components
or 'CDC' in components)):
832 path.add_module(
'ECLTrackClusterMatching')
835def add_ecl_cluster_properties_modules(path, components=None):
837 Add the ECL cluster properties module to the path.
839 :param path: The path to add the modules to.
840 :param components: The components to use or None to use all standard components.
842 if components
is None or (
'ECL' in components
and (
'PXD' in components
or 'SVD' in components
or 'CDC' in components)):
843 path.add_module(
'ECLClusterProperties')
846def add_ecl_track_brem_finder(path, components=None):
848 Add the bremsstrahlung finding module to the path.
850 :param path: The path to add the modules to.
851 :param components: The components to use or None to use all standard components.
853 if components
is None or (
'ECL' in components
and (
'PXD' in components
or 'SVD' in components)):
854 path.add_module(
'ECLTrackBremFinder')
857def add_ecl_chargedpid_module(path, components=None, legacyMode=False):
859 Add the ECL charged PID module to the path.
861 :param path: The path to add the modules to.
862 :param components: The components to use or None to use all standard components.
863 :param legacyMode: Uses the simple E/p based charged PID instead of the MVA based charged PID.
864 This flag
is automatically set to true on HLT
and ExpressReco.
866 if components
is None or 'ECL' in components:
869 path.add_module(
'ECLChargedPID')
871 path.add_module(
'ECLFillCellIdMapping')
872 path.add_module(
'ECLChargedPIDMVA')
875def add_ecl_mc_matcher_module(path, components=None):
877 Add the ECL MC matcher module to the path.
879 :param path: The path to add the modules to.
880 :param components: The components to use or None to use all standard components.
882 if components
is None or 'ECL' in components:
883 path.add_module(
'MCMatcherECLClusters')
886def add_ext_module(path, components=None):
888 Add the extrapolation module to the path.
890 :param path: The path to add the modules to.
891 :param components: The components to use or None to use all standard components.
893 if components
is None or 'CDC' in components:
894 path.add_module(
'Ext')
897def add_dedx_modules(path, components=None, for_cdst_analysis=False, enableDebugOutput=False):
899 Add the dE/dX reconstruction modules to the path.
901 :param path: The path to add the modules to.
902 :param components: The components to use or None to use all standard components.
903 :param for_cdst_analysis:
if True, add only DedxPIDCreator module, otherwise add both
904 :param enableDebugOutput: enable/disable writing out debugging information to CDCDedxTracks
907 if components
is None or 'CDC' in components:
908 if for_cdst_analysis:
909 path.add_module(
'CDCDedxPIDCreator', enableDebugOutput=
True)
911 path.add_module(
'CDCDedxHitSaver')
912 path.add_module(
'CDCDedxPIDCreator', enableDebugOutput=enableDebugOutput)
915 if components
is None or 'SVD' in components:
916 if for_cdst_analysis:
917 path.add_module(
'VXDDedxPIDRemaker')
919 path.add_module(
'VXDDedxPID')
922def add_special_vxd_modules(path, components=None):
924 Add two modules that are not part of the standard reconstruction.
926 :param path: The path to add the modules to.
927 :param components: The components to use
or None to use all standard components.
930 if not components
or (
'PXD' in components):
931 path.add_module(
"PXDClustersFromTracks")
932 if not components
or (
'SVD' in components):
933 path.add_module(
"SVDShaperDigitsFromTracks")
936def prepare_cdst_analysis(path, components=None, mc=False, add_eventt0_combiner=False, legacy_ecl_charged_pid=False):
938 Adds to a (analysis) path all the modules needed to analyse a cDST file in the raw+tracking format
939 for collisions/cosmics data
or in the digits+tracking format
for MC data.
941 :param path: The path to add the modules to.
942 :param components: The components to use
or None to use all standard components.
943 :param mc: Are we running over MC data
or not? If so, do
not run the unpackers.
944 :param add_eventt0_combiner: If
True, it adds the EventT0Combiner module when the post-tracking
945 reconstruction
is run. This must NOT be used during the calibration, but it may be necessary
946 for validation purposes
or for the user analyses.
947 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
948 MVA based charged particle ID (false).
954 components=components)
956 check_components(components)
957 path.add_module(
'Gearbox')
958 path.add_module(
'Geometry')
961 add_prefilter_pretracking_reconstruction(path,
962 components=components)
965 if components
is None or 'SVD' in components:
966 add_svd_reconstruction(path)
967 if components
is None or 'PXD' in components:
968 add_pxd_reconstruction(path)
971 path.add_module(
'SetupGenfitExtrapolation',
972 energyLossBrems=
False,
976 add_posttracking_reconstruction(path,
977 components=components,
978 for_cdst_analysis=
True,
979 add_eventt0_combiner_for_cdst=add_eventt0_combiner,
980 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
983def prepare_user_cdst_analysis(path, components=None, mc=False):
985 Adds to a (analysis) path all the modules needed to analyse a cDST file in the raw+tracking format
986 for collisions/cosmics data
or in the digits+tracking format
for MC data.
987 Differently
from prepare_cdst_analysis(), this function add the EventT0Combiner module to the path,
988 which makes this function suitable
for all the users
and not only
for the calibration expertes.
989 Note that the EventT0Combiner module
is necessary
for applying the proper EventT0 correction to
992 :param path: The path to add the modules to.
993 :param components: The components to use
or None to use all standard components.
994 :param mc: Are we running over MC data
or not? If so, do
not run the unpackers.
996 prepare_cdst_analysis(path=path, components=components, mc=mc, add_eventt0_combiner=True)