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',
48 'SVDShaperDigitsFromTracks',
49 'PXDClustersFromTracks',
69def default_event_abort(module, condition, error_flag):
70 """Default event abort outside of HLT: Ignore the error flag and just stop
71 processing by giving an empty path"""
73 module.if_value(condition, p, basf2.AfterConditionPath.END)
76def add_reconstruction(path, components=None, pruneTracks=True, add_trigger_calculation=True, skipGeometryAdding=False,
77 trackFitHypotheses=None, addClusterExpertModules=True,
78 use_second_cdc_hits=False, add_muid_hits=False, reconstruct_cdst=None,
79 event_abort=default_event_abort, use_random_numbers_for_hlt_prescale=True,
80 pxd_filtering_offline=False,
81 create_intercepts_for_pxd_ckf=False,
82 append_full_grid_cdc_eventt0=True,
83 legacy_ecl_charged_pid=False, emulate_HLT=False,
84 skip_full_grid_cdc_eventt0_if_svd_time_present=True):
86 This function adds the standard reconstruction modules to a path.
87 Consists of clustering, tracking and the PID modules essentially
in this structure:
89 | :func:`add_reconstruction()`
90 | ├── :func:`add_prefilter_reconstruction()`
91 | │ ├── :func:`add_prefilter_pretracking_reconstruction()` : Clustering
92 | │ ├── ``add_prefilter_tracking_reconstruction()`` : Tracking essential
for HLT filter calculation
93 | │ └── :func:`add_prefilter_posttracking_reconstruction()` : PID
and clustering essential
for HLT
94 | └── :func:`add_postfilter_reconstruction()`
95 | ├── ``add_postfilter_tracking_reconstruction()`` : Rest of the tracking
96 | └── :func:`add_postfilter_posttracking_reconstruction()` : Rest of PID
and clustering
98 plus the modules to calculate the software trigger cuts.
100 :param path: Add the modules to this path.
101 :param components: list of geometry components to include reconstruction
for,
or None for all components.
102 :param pruneTracks: Delete all hits
except the first
and last of the tracks after the V0Finder modules.
103 :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module
and will add it,
104 if it
is not already present
in the path. In a setup
with multiple (conditional) paths however, it can
not
105 determine,
if the geometry
is already loaded. This flag can be used to just turn off the geometry adding at
106 all (but you will have to add it on your own then).
107 :param trackFitHypotheses: Change the additional fitted track fit hypotheses. If no argument
is given,
108 the fitted hypotheses are pion, muon
and proton, i.e. [211, 321, 2212].
109 :param addClusterExpertModules: Add the cluster expert modules
in the KLM
and ECL. Turn this off to reduce
111 :param use_second_cdc_hits: If true, the second hit information will be used
in the CDC track finding.
112 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
113 :param add_trigger_calculation: add the software trigger modules
for monitoring (do
not make any cut)
114 :param reconstruct_cdst:
None for mdst,
'rawFormat' to reconstruct cdsts
in rawFormat,
'fullFormat' for the
115 full (old) format. This parameter
is needed when reconstructing cdsts, otherwise the
116 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,
117 the condition and the error_flag to be set
if these events are kept. If run on HLT this will
not abort the event
118 but just remove all data
except for the event information.
119 :param use_random_numbers_for_hlt_prescale: If
True, the HLT filter prescales are applied using randomly
120 generated numbers, otherwise are applied using an internal counter.
121 :param pxd_filtering_offline: If
True, PXD data reduction (ROI filtering)
is applied during the track reconstruction.
122 The reconstructed SVD/CDC tracks are used to define the ROIs
and reject all PXD clusters outside of these.
123 :param create_intercepts_for_pxd_ckf: If
True, the PXDROIFinder
is added to the path to create PXDIntercepts to be used
124 for hit filtering when creating the CKF relations. This independent of the offline PXD digit filtering which
is
125 steered by
'pxd_filtering_offline'. This can be applied
for both data
and MC.
126 :param append_full_grid_cdc_eventt0: If
True, the module FullGridChi2TrackTimeExtractor
is added to the path
127 and provides the CDC temporary EventT0.
128 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
129 MVA based charged particle ID (false).
130 :param emulate_HLT:
if True, it runs the reconstruction
as it
is run on HLT (e.g. without PXD).
131 If you want to use this flag on raw data, you should also exclude the following branches
from RootInput: ROIs, ROIpayload
132 :param skip_full_grid_cdc_eventt0_if_svd_time_present:
if true,
and if also append_full_grid_cdc_eventt0
is true, the
133 FullGridChi2TrackTimeExtractor
is only executed
in the events where no SVD-based EventT0
is found. If false, but
134 append_full_grid_cdc_eventt0
is true, FullGridChi2TrackTimeExtractor will be executed
in each event regardless of
135 SVD EventT0 being present. Has no effect
if append_full_grid_cdc_eventt0
is false. Default: true
143 if reconstruct_cdst ==
'rawFormat':
144 append_full_grid_cdc_eventt0 =
True
147 components = DEFAULT_HLT_COMPONENTS
150 add_prefilter_reconstruction(path,
151 components=components,
152 add_modules_for_trigger_calculation=add_trigger_calculation,
153 skipGeometryAdding=skipGeometryAdding,
154 trackFitHypotheses=trackFitHypotheses,
155 use_second_cdc_hits=use_second_cdc_hits,
156 add_muid_hits=add_muid_hits,
157 reconstruct_cdst=reconstruct_cdst,
158 event_abort=event_abort,
159 pxd_filtering_offline=pxd_filtering_offline,
160 create_intercepts_for_pxd_ckf=create_intercepts_for_pxd_ckf,
161 append_full_grid_cdc_eventt0=append_full_grid_cdc_eventt0,
162 skip_full_grid_cdc_eventt0_if_svd_time_present=skip_full_grid_cdc_eventt0_if_svd_time_present)
165 if add_trigger_calculation
and (
not components
or (
"CDC" in components
and "ECL" in components
and "KLM" in components)):
166 add_filter_software_trigger(path,
167 use_random_numbers_for_prescale=use_random_numbers_for_hlt_prescale)
170 add_postfilter_reconstruction(path,
171 components=components,
172 pruneTracks=pruneTracks,
173 addClusterExpertModules=addClusterExpertModules,
174 reconstruct_cdst=reconstruct_cdst,
175 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
178 if add_trigger_calculation
and (
not components
or (
"CDC" in components
and "ECL" in components
and "KLM" in components)):
179 add_skim_software_trigger(path)
182def add_prefilter_reconstruction(path,
184 add_modules_for_trigger_calculation=True,
185 skipGeometryAdding=False,
186 trackFitHypotheses=None,
187 use_second_cdc_hits=False,
189 reconstruct_cdst=None,
190 event_abort=default_event_abort,
191 pxd_filtering_offline=False,
192 create_intercepts_for_pxd_ckf=False,
193 append_full_grid_cdc_eventt0=True,
194 skip_full_grid_cdc_eventt0_if_svd_time_present=True):
196 This function adds only the reconstruction modules required to calculate HLT filter decision to a path.
197 Consists of essential tracking and the functionality provided by :func:`add_prefilter_posttracking_reconstruction()`.
199 :param path: Add the modules to this path.
200 :param components: list of geometry components to include reconstruction
for,
or None for all components.
201 :param add_modules_for_trigger_calculation: add the modules necessary
for computing the software trigger decision
202 during later stages (do
not make any cut), relevant only when reconstruct_cdst
is not None.
203 :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module
and will add it,
204 if it
is not already present
in the path. In a setup
with multiple (conditional) paths however, it can
not
205 determine,
if the geometry
is already loaded. This flag can be used to just turn off the geometry adding at
206 all (but you will have to add it on your own then).
207 :param trackFitHypotheses: Change the additional fitted track fit hypotheses. If no argument
is given,
208 the fitted hypotheses are pion, muon
and proton, i.e. [211, 321, 2212].
209 :param use_second_cdc_hits: If true, the second hit information will be used
in the CDC track finding.
210 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
211 :param reconstruct_cdst:
None for mdst,
'rawFormat' to reconstruct cdsts
in rawFormat,
'fullFormat' for the
212 full (old) format. This parameter
is needed when reconstructing cdsts, otherwise the
213 required PXD objects won
't be added.
214 :param event_abort: A function to abort event processing at the given point. Should take three arguments: a module,
215 the condition and the error_flag to be set
if these events are kept. If run on HLT this will
not abort the event
216 but just remove all data
except for the event information.
217 :param pxd_filtering_offline: If
True, PXD data reduction (ROI filtering)
is applied during the track reconstruction.
218 The reconstructed SVD/CDC tracks are used to define the ROIs
and reject all PXD clusters outside of these.
219 :param create_intercepts_for_pxd_ckf: If
True, the PXDROIFinder
is added to the path to create PXDIntercepts to be used
220 for hit filtering when creating the CKF relations. This independent of the offline PXD digit filtering which
is
221 steered by
'pxd_filtering_offline'. This can be applied
for both data
and MC.
222 :param append_full_grid_cdc_eventt0: If
True, the module FullGridChi2TrackTimeExtractor
is added to the path
223 and provides the CDC temporary EventT0.
224 :param skip_full_grid_cdc_eventt0_if_svd_time_present:
if true,
and if also append_full_grid_cdc_eventt0
is true, the
225 FullGridChi2TrackTimeExtractor
is only executed
in the events where no SVD-based EventT0
is found. If false, but
226 append_full_grid_cdc_eventt0
is true, FullGridChi2TrackTimeExtractor will be executed
in each event regardless of
227 SVD EventT0 being present. Has no effect
if append_full_grid_cdc_eventt0
is false. Default: true
231 from ROOT
import Belle2
234 check_components(components)
237 doom = path.add_module(
"EventsOfDoomBuster")
238 event_abort(doom,
">=1", Belle2.EventMetaData.c_ReconstructionAbort)
239 path.add_module(
'StatisticsSummary').set_name(
'Sum_EventsofDoomBuster')
242 add_prefilter_pretracking_reconstruction(path, components=components)
245 add_prefilter_tracking_reconstruction(
247 components=components,
248 mcTrackFinding=
False,
249 skipGeometryAdding=skipGeometryAdding,
250 trackFitHypotheses=trackFitHypotheses,
251 use_second_cdc_hits=use_second_cdc_hits,
252 pxd_filtering_offline=pxd_filtering_offline,
253 create_intercepts_for_pxd_ckf=create_intercepts_for_pxd_ckf,
254 append_full_grid_cdc_eventt0=append_full_grid_cdc_eventt0,
255 skip_full_grid_cdc_eventt0_if_svd_time_present=skip_full_grid_cdc_eventt0_if_svd_time_present)
258 path.add_module(
'StatisticsSummary').set_name(
'Sum_Prefilter_Tracking')
262 add_special_vxd_modules(path, components=components)
263 if reconstruct_cdst ==
'rawFormat' and not add_modules_for_trigger_calculation:
267 add_prefilter_posttracking_reconstruction(path,
268 components=components,
269 add_muid_hits=add_muid_hits)
272 path.add_module(
'StatisticsSummary').set_name(
'Sum_Prefilter_PostTracking')
275def add_postfilter_reconstruction(path,
278 addClusterExpertModules=True,
279 reconstruct_cdst=None,
280 legacy_ecl_charged_pid=False):
282 This function adds the reconstruction modules not required to calculate HLT filter decision to a path.
284 :param path: Add the modules to this path.
285 :param components: list of geometry components to include reconstruction
for,
or None for all components.
286 :param pruneTracks: Delete all hits expect the first
and the last
from the found tracks.
287 :param addClusterExpertModules: Add the cluster expert modules
in the KLM
and ECL. Turn this off to
288 reduce execution time.
289 :param reconstruct_cdst:
None for mdst,
'rawFormat' to reconstruct cdsts
in rawFormat,
'fullFormat' for the
290 full (old) format. This parameter
is needed when reconstructing cdsts, otherwise the
291 required PXD objects won
't be added.
292 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true)
or
293 MVA based charged particle ID (false).
297 add_postfilter_tracking_reconstruction(path, components=components, pruneTracks=
False)
299 path.add_module(
'StatisticsSummary').set_name(
'Sum_Postfilter_Tracking')
302 if reconstruct_cdst ==
'rawFormat':
303 add_dedx_modules(path, components=components)
305 add_prune_tracks(path, components)
309 add_postfilter_posttracking_reconstruction(path,
310 components=components,
311 addClusterExpertModules=addClusterExpertModules,
312 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
315 add_prune_tracks(path, components)
318 path.add_module(
'StatisticsSummary').set_name(
'Sum_Postfilter_PostTracking')
321def add_cosmics_reconstruction(
325 skipGeometryAdding=False,
326 eventTimingExtraction=True,
327 addClusterExpertModules=True,
329 use_second_cdc_hits=False,
331 reconstruct_cdst=False,
333 legacy_ecl_charged_pid=False,
336 This function adds the standard reconstruction modules for cosmic data to a path.
337 Consists of tracking
and the functionality provided by :func:`add_posttracking_reconstruction()`,
338 plus the modules to calculate the software trigger cuts.
340 :param path: Add the modules to this path.
341 :param components: list of geometry components to include reconstruction
for,
or None for all components.
342 :param pruneTracks: Delete all hits
except the first
and last of the tracks after the dEdX modules.
343 :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module
and will add it,
344 if it
is not already present
in the path. In a setup
with multiple (conditional) paths however, it can
not
345 determine,
if the geometry
is already loaded. This flag can be used to just turn off the geometry adding at
346 all (but you will have to add it on your own then).
348 :param eventTimingExtraction: extract the event time
349 :param addClusterExpertModules: Add the cluster expert modules
in the KLM
and ECL. Turn this off to reduce
352 :param merge_tracks: The upper
and lower half of the tracks should be merged together
in one track
353 :param use_second_cdc_hits: If true, the second hit information will be used
in the CDC track finding.
355 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
357 :param reconstruct_cdst: run only the minimal reconstruction needed to produce the cdsts (raw+tracking+dE/dx)
358 :param posttracking: run reconstruction
for outer detectors.
359 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
360 MVA based charged particle ID (false).
364 basf2.declare_cosmics()
367 check_components(components)
370 add_prefilter_pretracking_reconstruction(path,
371 components=components)
374 add_cr_tracking_reconstruction(path,
375 components=components,
377 skip_geometry_adding=skipGeometryAdding,
378 event_time_extraction=eventTimingExtraction,
379 merge_tracks=merge_tracks,
380 use_second_cdc_hits=use_second_cdc_hits)
383 path.add_module(
'StatisticsSummary').set_name(
'Sum_Tracking')
387 add_special_vxd_modules(path, components=components)
388 add_dedx_modules(path, components=components)
389 add_prune_tracks(path, components=components)
393 add_posttracking_reconstruction(path,
394 components=components,
395 pruneTracks=pruneTracks,
396 addClusterExpertModules=addClusterExpertModules,
397 add_muid_hits=add_muid_hits,
399 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
402def add_mc_reconstruction(path, components=None, pruneTracks=True, addClusterExpertModules=True,
403 use_second_cdc_hits=False, add_muid_hits=False, legacy_ecl_charged_pid=False):
405 This function adds the standard reconstruction modules with MC tracking
408 @param components list of geometry components to include reconstruction
for,
or None for all components.
409 @param use_second_cdc_hits: If true, the second hit information will be used
in the CDC track finding.
410 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
411 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
412 MVA based charged particle ID (false).
419 add_prefilter_pretracking_reconstruction(path,
420 components=components)
423 add_mc_tracking_reconstruction(path,
424 components=components,
426 use_second_cdc_hits=use_second_cdc_hits)
429 path.add_module(
'StatisticsSummary').set_name(
'Sum_MC_Tracking')
432 add_posttracking_reconstruction(path,
433 components=components,
434 pruneTracks=pruneTracks,
435 add_muid_hits=add_muid_hits,
436 addClusterExpertModules=addClusterExpertModules,
437 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
440def add_prefilter_pretracking_reconstruction(path, components=None):
442 This function adds the standard reconstruction modules BEFORE tracking
445 :param path: The path to add the modules to.
446 :param components: list of geometry components to include reconstruction for,
or None for all components.
449 add_ecl_modules(path, components)
452 path.add_module(
'StatisticsSummary').set_name(
'Sum_Clustering')
455def add_prefilter_posttracking_reconstruction(path,
458 for_cdst_analysis=False,
459 add_eventt0_combiner_for_cdst=False):
461 This function adds to the path the standard reconstruction modules after prefilter tracking
462 whoose outputs are also needed in the filter.
464 :param path: The path to add the modules to.
465 :param components: list of geometry components to include reconstruction
for,
or None for all components.
466 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
467 :param for_cdst_analysis:
if True, EventT0Combiner
is not added to path.
468 This
is only needed by prepare_cdst_analysis().
469 :param add_eventt0_combiner_for_cdst:
if True, the EventT0Combiner module
is added to the path even
if
470 for_cdst_analysis
is False. This
is useful
for validation purposes
for avoiding to run the full
471 add_reconstruction(). Note that,
with the default settings (for_cdst_analysis=
False and
472 add_eventt0_combiner_for_cdst=
False), the EventT0Combiner module
is added to the path.
475 add_ext_module(path, components)
478 if not for_cdst_analysis
or add_eventt0_combiner_for_cdst:
479 path.add_module(
"EventT0Combiner")
480 add_ecl_finalizer_module(path, components)
481 add_ecl_mc_matcher_module(path, components)
482 add_klm_modules(path, components)
483 add_klm_mc_matcher_module(path, components)
484 add_muid_module(path, add_hits_to_reco_track=add_muid_hits, components=components)
485 add_ecl_track_cluster_modules(path, components)
486 add_ecl_cluster_properties_modules(path, components)
489def add_postfilter_posttracking_reconstruction(path,
491 addClusterExpertModules=True,
493 for_cdst_analysis=False,
494 legacy_ecl_charged_pid=False):
496 This function adds to the path the standard reconstruction modules whoose outputs are not needed
in the filter.
498 :param path: The path to add the modules to.
499 :param components: list of geometry components to include reconstruction
for,
or None for all components.
500 :param addClusterExpertModules: Add the cluster expert modules
in the KLM
and ECL. Turn this off to reduce
502 :param cosmics:
if True, steer TOP
for cosmic reconstruction.
503 :param for_cdst_analysis:
if True, the OnlineEventT0Creator module
is not added to the path.
504 This
is only needed by prepare_cdst_analysis().
505 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
506 MVA based charged particle ID (false).
510 if not for_cdst_analysis:
511 add_dedx_modules(path, components)
513 add_top_modules(path, components, cosmics=cosmics)
514 add_arich_modules(path, components)
517 if not for_cdst_analysis:
518 path.add_module(
"OnlineEventT0Creator")
520 add_ecl_chargedpid_module(path, components, legacy_ecl_charged_pid)
521 add_pid_module(path, components)
523 if addClusterExpertModules:
525 add_cluster_expert_modules(path, components)
527 add_ecl_track_brem_finder(path, components)
530def add_posttracking_reconstruction(path,
533 addClusterExpertModules=True,
536 for_cdst_analysis=False,
537 add_eventt0_combiner_for_cdst=False,
538 legacy_ecl_charged_pid=False):
540 This function adds the standard reconstruction modules after tracking
543 :param path: The path to add the modules to.
544 :param components: list of geometry components to include reconstruction for,
or None for all components.
545 :param pruneTracks: Delete all hits
except the first
and last after the post-tracking modules.
546 :param addClusterExpertModules: Add the cluster expert modules
in the KLM
and ECL. Turn this off to reduce
548 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
549 :param cosmics:
if True, steer TOP
for cosmic reconstruction.
550 :param for_cdst_analysis:
if True, the dEdx
and PruneTracks modules are
not added to the path,
as well
551 as all EventT0 related modules.
552 This
is only needed by prepare_cdst_analysis().
553 :param add_eventt0_combiner_for_cdst:
if True, the EventT0Combiner module
is added to the path even
if
554 for_cdst_analysis
is True. This
is useful
for validation purposes
for avoiding to run the full
555 add_reconstruction(). Note that,
with the default settings (for_cdst_analysis=
False and
556 add_eventt0_combiner_for_cdst=
False), the EventT0Combiner module
is added to the path.
557 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
558 MVA based charged particle ID (false).
561 add_prefilter_posttracking_reconstruction(path,
562 components=components,
563 add_muid_hits=add_muid_hits,
564 for_cdst_analysis=for_cdst_analysis,
565 add_eventt0_combiner_for_cdst=add_eventt0_combiner_for_cdst)
567 add_postfilter_posttracking_reconstruction(path,
568 components=components,
569 addClusterExpertModules=addClusterExpertModules,
571 for_cdst_analysis=for_cdst_analysis,
572 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
576 if not for_cdst_analysis:
578 add_prune_tracks(path, components)
580 path.add_module(
'StatisticsSummary').set_name(
'Sum_Posttracking_Reconstruction')
583def add_cdst_output(path,
585 filename='cdst.root',
586 additionalBranches=None,
587 dataDescription=None,
588 ignoreInputModulesCheck=False):
590 This function adds the `RootOutput` module to a path with the settings needed to produce a cDST output.
591 The actual cDST output content depends on the value of the parameter `mc`:
592 *
if `mc`
is `
False` (default setting), the cDST content
is raw + tracking dataobjects;
593 *
if `mc`
is `
True`, the cDST content
is digits + MCParticles + tracking dataobjects.
595 @param path Path to add modules to.
596 @param mc Define the type of cDST output content: `
False`
for raw + tracking dataobjects, `
True`
for digits +
597 MCParticles + tracking dataobjects.
598 @param filename Output file name.
599 @param additionalBranches Additional objects/arrays of event durability to save
600 @param dataDescription Additional key->value pairs to be added
as data description
601 fields to the output FileMetaData.
602 @param ignoreInputModulesCheck If
True, do
not enforce check on missing PXD modules
in the input path.
603 Needed when a conditional path
is passed
as input.
606 branches = list(CDST_TRACKING_OBJECTS)
607 persistentBranches = ['FileMetaData']
610 branches += ALWAYS_SAVE_OBJECTS + RAWDATA_OBJECTS
612 branches += list(DIGITS_OBJECTS) + [
614 'EventLevelTriggerTimeInfo',
615 'SoftwareTriggerResult',
617 persistentBranches += [
'BackgroundInfo']
619 if not ignoreInputModulesCheck
and "PXDClustersFromTracks" not in [module.name()
for module
in path.modules()]:
620 basf2.B2ERROR(
"PXDClustersFromTracks is required in CDST output but its module is not found in the input path!")
622 if dataDescription
is None:
624 dataDescription.setdefault(
"dataLevel",
"cdst")
626 if additionalBranches
is not None:
627 branches += additionalBranches
629 return path.add_module(
"RootOutput", outputFileName=filename, branchNames=branches,
630 branchNamesPersistent=persistentBranches, additionalDataDescription=dataDescription)
633def add_arich_modules(path, components=None):
635 Add the ARICH reconstruction to the path.
637 :param path: The path to add the modules to.
638 :param components: The components to use or None to use all standard components.
640 if components
is None or 'ARICH' in components:
641 path.add_module(
'ARICHFillHits')
642 path.add_module(
'ARICHReconstructor',
646def add_top_modules(path, components=None, cosmics=False):
648 Add the TOP reconstruction to the path.
650 :param path: The path to add the modules to.
651 :param components: The components to use or None to use all standard components.
652 :param cosmics:
if True, steer TOP
for cosmic reconstruction
654 if components
is None or 'TOP' in components:
655 path.add_module(
'TOPChannelMasker')
657 path.add_module(
'TOPCosmicT0Finder')
659 path.add_module(
'TOPBunchFinder')
660 path.add_module(
'TOPReconstructor')
663def add_cluster_expert_modules(path, components=None):
665 Add the KLMExpert and ClusterMatcher modules to the path.
667 :param path: The path to add the modules to.
668 :param components: The components to use
or None to use all standard components.
670 if components
is None or (
'KLM' in components
and 'ECL' in components):
671 path.add_module(
'KLMExpert')
672 path.add_module(
'ClusterMatcher')
675def add_pid_module(path, components=None):
677 Add the PID modules to the path.
679 :param path: The path to add the modules to.
680 :param components: The components to use or None to use all standard components.
682 if components
is None or 'SVD' in components
or 'CDC' in components:
683 path.add_module(
'MdstPID')
684 if components
is None:
685 path.add_module(
'KLMMuonIDDNNExpert')
688def add_klm_modules(path, components=None):
690 Add the KLM reconstruction modules to the path.
692 :param path: The path to add the modules to.
693 :param components: The components to use or None to use all standard components.
695 if components
is None or 'KLM' in components:
696 path.add_module(
'KLMReconstructor')
697 path.add_module(
'KLMClustersReconstructor')
700def add_klm_mc_matcher_module(path, components=None):
702 Add the KLM mc matcher module 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.
707 if components
is None or 'KLM' in components:
708 path.add_module(
'MCMatcherKLMClusters')
711def add_muid_module(path, add_hits_to_reco_track=False, components=None):
713 Add the MuID module to the path.
715 :param path: The path to add the modules to.
716 :param add_hits_to_reco_track: Add the found KLM hits also to the RecoTrack. Make sure to refit the track afterwards.
717 :param components: The components to use or None to use all standard components.
720 if components
is None or (
'CDC' in components
and 'ECL' in components
and 'KLM' in components):
721 path.add_module(
'Muid',
722 addHitsToRecoTrack=add_hits_to_reco_track)
723 if components
is not None and 'CDC' in components:
724 if (
'ECL' not in components
and 'KLM' in components):
725 basf2.B2WARNING(
'You added KLM to the components list but not ECL: the module Muid, that is necessary '
726 'for correct muonID computation, will not be added to your reconstruction path. '
727 'Make sure that this is fine for your purposes, otherwise please include also ECL.')
728 if (
'ECL' in components
and 'KLM' not in components):
729 basf2.B2WARNING(
'You added ECL to the components list but not KLM: the module Muid, that is necessary '
730 'for correct ECLCluster-Track matching, will not be added to your reconstruction path. '
731 ' Make sure that this is fine for your purposes, otherwise please include also KLM.')
734def add_ecl_modules(path, components=None):
736 Add the ECL reconstruction modules to the path.
738 :param path: The path to add the modules to.
739 :param components: The components to use or None to use all standard components.
741 if components
is None or 'ECL' in components:
742 path.add_module(
'ECLWaveformFit')
743 path.add_module(
'ECLDigitCalibrator')
744 path.add_module(
'ECLEventT0')
745 path.add_module(
'ECLCRFinder')
746 path.add_module(
'ECLLocalMaximumFinder')
747 path.add_module(
'ECLSplitterN1')
748 path.add_module(
'ECLSplitterN2')
749 path.add_module(
'ECLShowerCorrector')
750 path.add_module(
'ECLShowerShape')
751 path.add_module(
'ECLClusterPSD')
752 path.add_module(
'ECLCovarianceMatrix')
756def add_ecl_finalizer_module(path, components=None):
758 Add the ECL finalizer 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.
764 if components
is None or 'ECL' in components:
765 path.add_module(
'ECLFinalizer')
768def add_ecl_track_cluster_modules(path, components=None):
770 Add the ECL track cluster matching module to the path.
772 :param path: The path to add the modules to.
773 :param components: The components to use or None to use all standard components.
775 if components
is None or (
'ECL' in components
and (
'PXD' in components
or 'SVD' in components
or 'CDC' in components)):
776 path.add_module(
'ECLTrackClusterMatching')
779def add_ecl_cluster_properties_modules(path, components=None):
781 Add the ECL cluster properties module to the path.
783 :param path: The path to add the modules to.
784 :param components: The components to use or None to use all standard components.
786 if components
is None or (
'ECL' in components
and (
'PXD' in components
or 'SVD' in components
or 'CDC' in components)):
787 path.add_module(
'ECLClusterProperties')
790def add_ecl_track_brem_finder(path, components=None):
792 Add the bremsstrahlung finding module 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
and (
'PXD' in components
or 'SVD' in components)):
798 path.add_module(
'ECLTrackBremFinder')
801def add_ecl_chargedpid_module(path, components=None, legacyMode=False):
803 Add the ECL charged PID module to the path.
805 :param path: The path to add the modules to.
806 :param components: The components to use or None to use all standard components.
807 :param legacyMode: Uses the simple E/p based charged PID instead of the MVA based charged PID.
809 if components
is None or 'ECL' in components:
812 path.add_module(
'ECLChargedPID')
814 path.add_module(
'ECLFillCellIdMapping')
815 path.add_module(
'ECLChargedPIDMVA')
818def add_ecl_mc_matcher_module(path, components=None):
820 Add the ECL MC matcher 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:
826 path.add_module(
'MCMatcherECLClusters')
829def add_ext_module(path, components=None):
831 Add the extrapolation 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 'CDC' in components:
837 path.add_module(
'Ext')
840def add_dedx_modules(path, components=None):
842 Add the dE/dX reconstruction modules 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.
848 if components
is None or 'CDC' in components:
849 path.add_module(
'CDCDedxPID')
852 if components
is None or 'SVD' in components:
853 path.add_module(
'VXDDedxPID')
856def add_special_vxd_modules(path, components=None):
858 Add two modules that are not part of the standard reconstruction.
860 :param path: The path to add the modules to.
861 :param components: The components to use
or None to use all standard components.
864 if not components
or (
'PXD' in components):
865 path.add_module(
"PXDClustersFromTracks")
866 if not components
or (
'SVD' in components):
867 path.add_module(
"SVDShaperDigitsFromTracks")
870def prepare_cdst_analysis(path, components=None, mc=False, add_eventt0_combiner=False, legacy_ecl_charged_pid=False):
872 Adds to a (analysis) path all the modules needed to analyse a cDST file in the raw+tracking format
873 for collisions/cosmics data
or in the digits+tracking format
for MC data.
875 :param path: The path to add the modules to.
876 :param components: The components to use
or None to use all standard components.
877 :param mc: Are we running over MC data
or not? If so, do
not run the unpackers.
878 :param add_eventt0_combiner: If
True, it adds the EventT0Combiner module when the post-tracking
879 reconstruction
is run. This must NOT be used during the calibration, but it may be necessary
880 for validation purposes
or for the user analyses.
881 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
882 MVA based charged particle ID (false).
888 components=components)
890 check_components(components)
891 path.add_module(
'Gearbox')
892 path.add_module(
'Geometry')
895 add_prefilter_pretracking_reconstruction(path,
896 components=components)
899 if components
is None or 'SVD' in components:
900 add_svd_reconstruction(path)
901 if components
is None or 'PXD' in components:
902 add_pxd_reconstruction(path)
905 path.add_module(
'SetupGenfitExtrapolation',
906 energyLossBrems=
False,
910 add_posttracking_reconstruction(path,
911 components=components,
912 for_cdst_analysis=
True,
913 add_eventt0_combiner_for_cdst=add_eventt0_combiner,
914 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
917def prepare_user_cdst_analysis(path, components=None, mc=False):
919 Adds to a (analysis) path all the modules needed to analyse a cDST file in the raw+tracking format
920 for collisions/cosmics data
or in the digits+tracking format
for MC data.
921 Differently
from prepare_cdst_analysis(), this function add the EventT0Combiner module to the path,
922 which makes this function suitable
for all the users
and not only
for the calibration expertes.
923 Note that the EventT0Combiner module
is necessary
for applying the proper EventT0 correction to
926 :param path: The path to add the modules to.
927 :param components: The components to use
or None to use all standard components.
928 :param mc: Are we running over MC data
or not? If so, do
not run the unpackers.
930 prepare_cdst_analysis(path=path, components=components, mc=mc, add_eventt0_combiner=True)