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):
87 This function adds the standard reconstruction modules to a path.
88 Consists of clustering, tracking and the PID modules essentially
in this structure:
90 | :func:`add_reconstruction()`
91 | ├── :func:`add_prefilter_reconstruction()`
92 | │ ├── :func:`add_prefilter_pretracking_reconstruction()` : Clustering
93 | │ ├── ``add_prefilter_tracking_reconstruction()`` : Tracking essential
for HLT filter calculation
94 | │ └── :func:`add_prefilter_posttracking_reconstruction()` : PID
and clustering essential
for HLT
95 | └── :func:`add_postfilter_reconstruction()`
96 | ├── ``add_postfilter_tracking_reconstruction()`` : Rest of the tracking
97 | └── :func:`add_postfilter_posttracking_reconstruction()` : Rest of PID
and clustering
99 plus the modules to calculate the software trigger cuts.
101 :param path: Add the modules to this path.
102 :param components: list of geometry components to include reconstruction
for,
or None for all components.
103 :param pruneTracks: Delete all hits
except the first
and last of the tracks after the V0Finder modules.
104 :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module
and will add it,
105 if it
is not already present
in the path. In a setup
with multiple (conditional) paths however, it can
not
106 determine,
if the geometry
is already loaded. This flag can be used to just turn off the geometry adding at
107 all (but you will have to add it on your own then).
108 :param trackFitHypotheses: Change the additional fitted track fit hypotheses. If no argument
is given,
109 the fitted hypotheses are pion, muon
and proton, i.e. [211, 321, 2212].
110 :param addClusterExpertModules: Add the cluster expert modules
in the KLM
and ECL. Turn this off to reduce
112 :param use_second_cdc_hits: If true, the second hit information will be used
in the CDC track finding.
113 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
114 :param add_trigger_calculation: add the software trigger modules
for monitoring (do
not make any cut)
115 :param reconstruct_cdst:
None for mdst,
'rawFormat' to reconstruct cdsts
in rawFormat,
'fullFormat' for the
116 full (old) format. This parameter
is needed when reconstructing cdsts, otherwise the
117 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,
118 the condition and the error_flag to be set
if these events are kept. If run on HLT this will
not abort the event
119 but just remove all data
except for the event information.
120 :param use_random_numbers_for_hlt_prescale: If
True, the HLT filter prescales are applied using randomly
121 generated numbers, otherwise are applied using an internal counter.
122 :param pxd_filtering_offline: If
True, PXD data reduction (ROI filtering)
is applied during the track reconstruction.
123 The reconstructed SVD/CDC tracks are used to define the ROIs
and reject all PXD clusters outside of these.
124 :param create_intercepts_for_pxd_ckf: If
True, the PXDROIFinder
is added to the path to create PXDIntercepts to be used
125 for hit filtering when creating the CKF relations. This independent of the offline PXD digit filtering which
is
126 steered by
'pxd_filtering_offline'. This can be applied
for both data
and MC.
127 :param append_full_grid_cdc_eventt0: If
True, the module FullGridChi2TrackTimeExtractor
is added to the path
128 and provides the CDC temporary EventT0.
129 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
130 MVA based charged particle ID (false).
131 :param emulate_HLT:
if True, it runs the reconstruction
as it
is run on HLT (e.g. without PXD).
132 If you want to use this flag on raw data, you should also exclude the following branches
from RootInput: ROIs, ROIpayload
133 :param skip_full_grid_cdc_eventt0_if_svd_time_present:
if true,
and if also append_full_grid_cdc_eventt0
is true, the
134 FullGridChi2TrackTimeExtractor
is only executed
in the events where no SVD-based EventT0
is found. If false, but
135 append_full_grid_cdc_eventt0
is true, FullGridChi2TrackTimeExtractor will be executed
in each event regardless of
136 SVD EventT0 being present. Has no effect
if append_full_grid_cdc_eventt0
is false. Default: true
144 if reconstruct_cdst ==
'rawFormat':
145 append_full_grid_cdc_eventt0 =
True
148 components = DEFAULT_HLT_COMPONENTS
151 add_prefilter_reconstruction(path,
152 components=components,
153 add_modules_for_trigger_calculation=add_trigger_calculation,
154 skipGeometryAdding=skipGeometryAdding,
155 trackFitHypotheses=trackFitHypotheses,
156 use_second_cdc_hits=use_second_cdc_hits,
157 add_muid_hits=add_muid_hits,
158 reconstruct_cdst=reconstruct_cdst,
159 event_abort=event_abort,
160 pxd_filtering_offline=pxd_filtering_offline,
161 create_intercepts_for_pxd_ckf=create_intercepts_for_pxd_ckf,
162 append_full_grid_cdc_eventt0=append_full_grid_cdc_eventt0,
163 skip_full_grid_cdc_eventt0_if_svd_time_present=skip_full_grid_cdc_eventt0_if_svd_time_present)
166 if add_trigger_calculation
and (
not components
or (
"CDC" in components
and "ECL" in components
and "KLM" in components)):
167 add_filter_software_trigger(path,
168 use_random_numbers_for_prescale=use_random_numbers_for_hlt_prescale)
171 add_postfilter_reconstruction(path,
172 components=components,
173 pruneTracks=pruneTracks,
174 addClusterExpertModules=addClusterExpertModules,
175 reconstruct_cdst=reconstruct_cdst,
176 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
179 if add_trigger_calculation
and (
not components
or (
"CDC" in components
and "ECL" in components
and "KLM" in components)):
180 add_skim_software_trigger(path)
183def add_prefilter_reconstruction(path,
185 add_modules_for_trigger_calculation=True,
186 skipGeometryAdding=False,
187 trackFitHypotheses=None,
188 use_second_cdc_hits=False,
190 reconstruct_cdst=None,
191 event_abort=default_event_abort,
192 pxd_filtering_offline=False,
193 create_intercepts_for_pxd_ckf=False,
194 append_full_grid_cdc_eventt0=True,
195 skip_full_grid_cdc_eventt0_if_svd_time_present=True):
197 This function adds only the reconstruction modules required to calculate HLT filter decision to a path.
198 Consists of essential tracking and the functionality provided by :func:`add_prefilter_posttracking_reconstruction()`.
200 :param path: Add the modules to this path.
201 :param components: list of geometry components to include reconstruction
for,
or None for all components.
202 :param add_modules_for_trigger_calculation: add the modules necessary
for computing the software trigger decision
203 during later stages (do
not make any cut), relevant only when reconstruct_cdst
is not None.
204 :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module
and will add it,
205 if it
is not already present
in the path. In a setup
with multiple (conditional) paths however, it can
not
206 determine,
if the geometry
is already loaded. This flag can be used to just turn off the geometry adding at
207 all (but you will have to add it on your own then).
208 :param trackFitHypotheses: Change the additional fitted track fit hypotheses. If no argument
is given,
209 the fitted hypotheses are pion, muon
and proton, i.e. [211, 321, 2212].
210 :param use_second_cdc_hits: If true, the second hit information will be used
in the CDC track finding.
211 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
212 :param reconstruct_cdst:
None for mdst,
'rawFormat' to reconstruct cdsts
in rawFormat,
'fullFormat' for the
213 full (old) format. This parameter
is needed when reconstructing cdsts, otherwise the
214 required PXD objects won
't be added.
215 :param event_abort: A function to abort event processing at the given point. Should take three arguments: a module,
216 the condition and the error_flag to be set
if these events are kept. If run on HLT this will
not abort the event
217 but just remove all data
except for the event information.
218 :param pxd_filtering_offline: If
True, PXD data reduction (ROI filtering)
is applied during the track reconstruction.
219 The reconstructed SVD/CDC tracks are used to define the ROIs
and reject all PXD clusters outside of these.
220 :param create_intercepts_for_pxd_ckf: If
True, the PXDROIFinder
is added to the path to create PXDIntercepts to be used
221 for hit filtering when creating the CKF relations. This independent of the offline PXD digit filtering which
is
222 steered by
'pxd_filtering_offline'. This can be applied
for both data
and MC.
223 :param append_full_grid_cdc_eventt0: If
True, the module FullGridChi2TrackTimeExtractor
is added to the path
224 and provides the CDC temporary EventT0.
225 :param skip_full_grid_cdc_eventt0_if_svd_time_present:
if true,
and if also append_full_grid_cdc_eventt0
is true, the
226 FullGridChi2TrackTimeExtractor
is only executed
in the events where no SVD-based EventT0
is found. If false, but
227 append_full_grid_cdc_eventt0
is true, FullGridChi2TrackTimeExtractor will be executed
in each event regardless of
228 SVD EventT0 being present. Has no effect
if append_full_grid_cdc_eventt0
is false. Default: true
232 from ROOT
import Belle2
235 check_components(components)
238 doom = path.add_module(
"EventsOfDoomBuster")
239 event_abort(doom,
">=1", Belle2.EventMetaData.c_ReconstructionAbort)
240 path.add_module(
'StatisticsSummary').set_name(
'Sum_EventsofDoomBuster')
243 add_prefilter_pretracking_reconstruction(path, components=components)
246 add_prefilter_tracking_reconstruction(
248 components=components,
249 mcTrackFinding=
False,
250 skipGeometryAdding=skipGeometryAdding,
251 trackFitHypotheses=trackFitHypotheses,
252 use_second_cdc_hits=use_second_cdc_hits,
253 pxd_filtering_offline=pxd_filtering_offline,
254 create_intercepts_for_pxd_ckf=create_intercepts_for_pxd_ckf,
255 append_full_grid_cdc_eventt0=append_full_grid_cdc_eventt0,
256 skip_full_grid_cdc_eventt0_if_svd_time_present=skip_full_grid_cdc_eventt0_if_svd_time_present)
259 path.add_module(
'StatisticsSummary').set_name(
'Sum_Prefilter_Tracking')
263 add_special_vxd_modules(path, components=components)
264 if reconstruct_cdst ==
'rawFormat' and not add_modules_for_trigger_calculation:
268 add_prefilter_posttracking_reconstruction(path,
269 components=components,
270 add_muid_hits=add_muid_hits)
273 path.add_module(
'StatisticsSummary').set_name(
'Sum_Prefilter_PostTracking')
276def add_postfilter_reconstruction(path,
279 addClusterExpertModules=True,
280 reconstruct_cdst=None,
281 legacy_ecl_charged_pid=False):
283 This function adds the reconstruction modules not required to calculate HLT filter decision to a path.
285 :param path: Add the modules to this path.
286 :param components: list of geometry components to include reconstruction
for,
or None for all components.
287 :param pruneTracks: Delete all hits expect the first
and the last
from the found tracks.
288 :param addClusterExpertModules: Add the cluster expert modules
in the KLM
and ECL. Turn this off to
289 reduce execution time.
290 :param reconstruct_cdst:
None for mdst,
'rawFormat' to reconstruct cdsts
in rawFormat,
'fullFormat' for the
291 full (old) format. This parameter
is needed when reconstructing cdsts, otherwise the
292 required PXD objects won
't be added.
293 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID in the ECL (true)
or
294 MVA based charged particle ID (false).
298 add_postfilter_tracking_reconstruction(path, components=components, pruneTracks=
False)
300 path.add_module(
'StatisticsSummary').set_name(
'Sum_Postfilter_Tracking')
303 if reconstruct_cdst ==
'rawFormat':
304 add_dedx_modules(path, components=components, enableDebugOutput=
True)
306 add_prune_tracks(path, components)
310 add_postfilter_posttracking_reconstruction(path,
311 components=components,
312 addClusterExpertModules=addClusterExpertModules,
313 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
316 add_prune_tracks(path, components)
319 path.add_module(
'StatisticsSummary').set_name(
'Sum_Postfilter_PostTracking')
322def add_cosmics_reconstruction(
326 skipGeometryAdding=False,
327 eventTimingExtraction=True,
328 addClusterExpertModules=True,
330 use_second_cdc_hits=False,
332 reconstruct_cdst=False,
334 legacy_ecl_charged_pid=False,
337 This function adds the standard reconstruction modules for cosmic data to a path.
338 Consists of tracking
and the functionality provided by :func:`add_posttracking_reconstruction()`,
339 plus the modules to calculate the software trigger cuts.
341 :param path: Add the modules to this path.
342 :param components: list of geometry components to include reconstruction
for,
or None for all components.
343 :param pruneTracks: Delete all hits
except the first
and last of the tracks after the dEdX modules.
344 :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module
and will add it,
345 if it
is not already present
in the path. In a setup
with multiple (conditional) paths however, it can
not
346 determine,
if the geometry
is already loaded. This flag can be used to just turn off the geometry adding at
347 all (but you will have to add it on your own then).
349 :param eventTimingExtraction: extract the event time
350 :param addClusterExpertModules: Add the cluster expert modules
in the KLM
and ECL. Turn this off to reduce
353 :param merge_tracks: The upper
and lower half of the tracks should be merged together
in one track
354 :param use_second_cdc_hits: If true, the second hit information will be used
in the CDC track finding.
356 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
358 :param reconstruct_cdst: run only the minimal reconstruction needed to produce the cdsts (raw+tracking+dE/dx)
359 :param posttracking: run reconstruction
for outer detectors.
360 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
361 MVA based charged particle ID (false).
365 basf2.declare_cosmics()
368 check_components(components)
371 add_prefilter_pretracking_reconstruction(path,
372 components=components)
375 add_cr_tracking_reconstruction(path,
376 components=components,
378 skip_geometry_adding=skipGeometryAdding,
379 event_time_extraction=eventTimingExtraction,
380 merge_tracks=merge_tracks,
381 use_second_cdc_hits=use_second_cdc_hits)
384 path.add_module(
'StatisticsSummary').set_name(
'Sum_Tracking')
388 add_special_vxd_modules(path, components=components)
389 add_dedx_modules(path, components=components, enableDebugOutput=
True)
390 add_prune_tracks(path, components=components)
394 add_posttracking_reconstruction(path,
395 components=components,
396 pruneTracks=pruneTracks,
397 addClusterExpertModules=addClusterExpertModules,
398 add_muid_hits=add_muid_hits,
400 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
403def add_mc_reconstruction(path, components=None, pruneTracks=True, addClusterExpertModules=True,
404 use_second_cdc_hits=False, add_muid_hits=False, legacy_ecl_charged_pid=False):
406 This function adds the standard reconstruction modules with MC tracking
409 @param components list of geometry components to include reconstruction
for,
or None for all components.
410 @param use_second_cdc_hits: If true, the second hit information will be used
in the CDC track finding.
411 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
412 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
413 MVA based charged particle ID (false).
420 add_prefilter_pretracking_reconstruction(path,
421 components=components)
424 add_mc_tracking_reconstruction(path,
425 components=components,
427 use_second_cdc_hits=use_second_cdc_hits)
430 path.add_module(
'StatisticsSummary').set_name(
'Sum_MC_Tracking')
433 add_posttracking_reconstruction(path,
434 components=components,
435 pruneTracks=pruneTracks,
436 add_muid_hits=add_muid_hits,
437 addClusterExpertModules=addClusterExpertModules,
438 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
441def add_prefilter_pretracking_reconstruction(path, components=None):
443 This function adds the standard reconstruction modules BEFORE tracking
446 :param path: The path to add the modules to.
447 :param components: list of geometry components to include reconstruction for,
or None for all components.
450 add_ecl_modules(path, components)
453 path.add_module(
'StatisticsSummary').set_name(
'Sum_Clustering')
456def add_prefilter_posttracking_reconstruction(path,
459 for_cdst_analysis=False,
460 add_eventt0_combiner_for_cdst=False):
462 This function adds to the path the standard reconstruction modules after prefilter tracking
463 whoose outputs are also needed in the filter.
465 :param path: The path to add the modules to.
466 :param components: list of geometry components to include reconstruction
for,
or None for all components.
467 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
468 :param for_cdst_analysis:
if True, EventT0Combiner
is not added to path.
469 This
is only needed by prepare_cdst_analysis().
470 :param add_eventt0_combiner_for_cdst:
if True, the EventT0Combiner module
is added to the path even
if
471 for_cdst_analysis
is False. This
is useful
for validation purposes
for avoiding to run the full
472 add_reconstruction(). Note that,
with the default settings (for_cdst_analysis=
False and
473 add_eventt0_combiner_for_cdst=
False), the EventT0Combiner module
is added to the path.
476 add_ext_module(path, components)
479 if not for_cdst_analysis
or add_eventt0_combiner_for_cdst:
480 path.add_module(
"EventT0Combiner")
481 add_ecl_finalizer_module(path, components)
482 add_ecl_mc_matcher_module(path, components)
483 add_klm_modules(path, components)
484 add_klm_mc_matcher_module(path, components)
485 add_muid_module(path, add_hits_to_reco_track=add_muid_hits, components=components)
486 add_ecl_track_cluster_modules(path, components)
487 add_ecl_cluster_properties_modules(path, components)
490def add_postfilter_posttracking_reconstruction(path,
492 addClusterExpertModules=True,
494 for_cdst_analysis=False,
495 legacy_ecl_charged_pid=False):
497 This function adds to the path the standard reconstruction modules whoose outputs are not needed
in the filter.
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.
501 :param addClusterExpertModules: Add the cluster expert modules
in the KLM
and ECL. Turn this off to reduce
503 :param cosmics:
if True, steer TOP
for cosmic reconstruction.
504 :param for_cdst_analysis:
if True, the OnlineEventT0Creator module
is not added to the path.
505 This
is only needed by prepare_cdst_analysis().
506 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
507 MVA based charged particle ID (false).
510 add_dedx_modules(path, components, for_cdst_analysis=for_cdst_analysis)
511 add_top_modules(path, components, cosmics=cosmics)
512 add_arich_modules(path, components)
515 if not for_cdst_analysis:
516 path.add_module(
"OnlineEventT0Creator")
518 add_ecl_chargedpid_module(path, components, legacy_ecl_charged_pid)
519 add_pid_module(path, components)
521 if addClusterExpertModules:
523 add_cluster_expert_modules(path, components)
525 add_ecl_track_brem_finder(path, components)
528def add_posttracking_reconstruction(path,
531 addClusterExpertModules=True,
534 for_cdst_analysis=False,
535 add_eventt0_combiner_for_cdst=False,
536 legacy_ecl_charged_pid=False):
538 This function adds the standard reconstruction modules after tracking
541 :param path: The path to add the modules to.
542 :param components: list of geometry components to include reconstruction for,
or None for all components.
543 :param pruneTracks: Delete all hits
except the first
and last after the post-tracking modules.
544 :param addClusterExpertModules: Add the cluster expert modules
in the KLM
and ECL. Turn this off to reduce
546 :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
547 :param cosmics:
if True, steer TOP
for cosmic reconstruction.
548 :param for_cdst_analysis:
if True, the dEdx
and PruneTracks modules are
not added to the path,
as well
549 as all EventT0 related modules.
550 This
is only needed by prepare_cdst_analysis().
551 :param add_eventt0_combiner_for_cdst:
if True, the EventT0Combiner module
is added to the path even
if
552 for_cdst_analysis
is True. This
is useful
for validation purposes
for avoiding to run the full
553 add_reconstruction(). Note that,
with the default settings (for_cdst_analysis=
False and
554 add_eventt0_combiner_for_cdst=
False), the EventT0Combiner module
is added to the path.
555 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
556 MVA based charged particle ID (false).
559 add_prefilter_posttracking_reconstruction(path,
560 components=components,
561 add_muid_hits=add_muid_hits,
562 for_cdst_analysis=for_cdst_analysis,
563 add_eventt0_combiner_for_cdst=add_eventt0_combiner_for_cdst)
565 add_postfilter_posttracking_reconstruction(path,
566 components=components,
567 addClusterExpertModules=addClusterExpertModules,
569 for_cdst_analysis=for_cdst_analysis,
570 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
574 if not for_cdst_analysis:
576 add_prune_tracks(path, components)
578 path.add_module(
'StatisticsSummary').set_name(
'Sum_Posttracking_Reconstruction')
581def add_cdst_output(path,
583 filename='cdst.root',
584 additionalBranches=None,
585 dataDescription=None,
586 ignoreInputModulesCheck=False):
588 This function adds the `RootOutput` module to a path with the settings needed to produce a cDST output.
589 The actual cDST output content depends on the value of the parameter `mc`:
590 *
if `mc`
is `
False` (default setting), the cDST content
is raw + tracking dataobjects;
591 *
if `mc`
is `
True`, the cDST content
is digits + MCParticles + tracking dataobjects.
593 @param path Path to add modules to.
594 @param mc Define the type of cDST output content: `
False`
for raw + tracking dataobjects, `
True`
for digits +
595 MCParticles + tracking dataobjects.
596 @param filename Output file name.
597 @param additionalBranches Additional objects/arrays of event durability to save
598 @param dataDescription Additional key->value pairs to be added
as data description
599 fields to the output FileMetaData.
600 @param ignoreInputModulesCheck If
True, do
not enforce check on missing PXD modules
in the input path.
601 Needed when a conditional path
is passed
as input.
604 branches = list(CDST_TRACKING_OBJECTS)
605 persistentBranches = ['FileMetaData']
608 branches += ALWAYS_SAVE_OBJECTS + RAWDATA_OBJECTS
610 branches += list(DIGITS_OBJECTS) + [
612 'EventLevelTriggerTimeInfo',
613 'SoftwareTriggerResult',
615 persistentBranches += [
'BackgroundInfo']
617 if not ignoreInputModulesCheck
and "PXDClustersFromTracks" not in [module.name()
for module
in path.modules()]:
618 basf2.B2ERROR(
"PXDClustersFromTracks is required in CDST output but its module is not found in the input path!")
620 if dataDescription
is None:
622 dataDescription.setdefault(
"dataLevel",
"cdst")
624 if additionalBranches
is not None:
625 branches += additionalBranches
627 return path.add_module(
"RootOutput", outputFileName=filename, branchNames=branches,
628 branchNamesPersistent=persistentBranches, additionalDataDescription=dataDescription)
631def add_arich_modules(path, components=None):
633 Add the ARICH reconstruction to the path.
635 :param path: The path to add the modules to.
636 :param components: The components to use or None to use all standard components.
638 if components
is None or 'ARICH' in components:
639 path.add_module(
'ARICHFillHits')
640 path.add_module(
'ARICHReconstructor',
644def add_top_modules(path, components=None, cosmics=False):
646 Add the TOP reconstruction to the path.
648 :param path: The path to add the modules to.
649 :param components: The components to use or None to use all standard components.
650 :param cosmics:
if True, steer TOP
for cosmic reconstruction
652 if components
is None or 'TOP' in components:
653 path.add_module(
'TOPChannelMasker')
655 path.add_module(
'TOPCosmicT0Finder')
657 path.add_module(
'TOPBunchFinder')
658 path.add_module(
'TOPReconstructor')
661def add_cluster_expert_modules(path, components=None):
663 Add the KLMExpert and ClusterMatcher modules to the path.
665 :param path: The path to add the modules to.
666 :param components: The components to use
or None to use all standard components.
668 if components
is None or (
'KLM' in components
and 'ECL' in components):
669 path.add_module(
'KLMExpert')
670 path.add_module(
'ClusterMatcher')
673def add_pid_module(path, components=None):
675 Add the PID modules to the path.
677 :param path: The path to add the modules to.
678 :param components: The components to use or None to use all standard components.
680 if components
is None or 'SVD' in components
or 'CDC' in components:
681 path.add_module(
'MdstPID')
682 if components
is None:
683 path.add_module(
'KLMMuonIDDNNExpert')
686def add_klm_modules(path, components=None):
688 Add the KLM reconstruction modules to the path.
690 :param path: The path to add the modules to.
691 :param components: The components to use or None to use all standard components.
693 if components
is None or 'KLM' in components:
694 path.add_module(
'KLMReconstructor')
695 path.add_module(
'KLMClustersReconstructor')
698def add_klm_mc_matcher_module(path, components=None):
700 Add the KLM mc matcher module to the path.
702 :param path: The path to add the modules to.
703 :param components: The components to use or None to use all standard components.
705 if components
is None or 'KLM' in components:
706 path.add_module(
'MCMatcherKLMClusters')
709def add_muid_module(path, add_hits_to_reco_track=False, components=None):
711 Add the MuID module to the path.
713 :param path: The path to add the modules to.
714 :param add_hits_to_reco_track: Add the found KLM hits also to the RecoTrack. Make sure to refit the track afterwards.
715 :param components: The components to use or None to use all standard components.
718 if components
is None or (
'CDC' in components
and 'ECL' in components
and 'KLM' in components):
719 path.add_module(
'Muid',
720 addHitsToRecoTrack=add_hits_to_reco_track)
721 if components
is not None and 'CDC' in components:
722 if (
'ECL' not in components
and 'KLM' in components):
723 basf2.B2WARNING(
'You added KLM to the components list but not ECL: the module Muid, that is necessary '
724 'for correct muonID computation, will not be added to your reconstruction path. '
725 'Make sure that this is fine for your purposes, otherwise please include also ECL.')
726 if (
'ECL' in components
and 'KLM' not in components):
727 basf2.B2WARNING(
'You added ECL to the components list but not KLM: the module Muid, that is necessary '
728 'for correct ECLCluster-Track matching, will not be added to your reconstruction path. '
729 ' Make sure that this is fine for your purposes, otherwise please include also KLM.')
732def add_ecl_modules(path, components=None):
734 Add the ECL reconstruction modules to the path.
736 :param path: The path to add the modules to.
737 :param components: The components to use or None to use all standard components.
739 if components
is None or 'ECL' in components:
740 path.add_module(
'ECLWaveformFit')
741 path.add_module(
'ECLDigitCalibrator')
742 path.add_module(
'ECLEventT0')
743 path.add_module(
'ECLCRFinder')
744 path.add_module(
'ECLLocalMaximumFinder')
745 path.add_module(
'ECLSplitterN1')
746 path.add_module(
'ECLSplitterN2')
747 path.add_module(
'ECLShowerCorrector')
748 path.add_module(
'ECLShowerCalibrator')
749 path.add_module(
'ECLShowerShape')
750 path.add_module(
'ECLClusterPSD')
751 path.add_module(
'ECLCovarianceMatrix')
755def add_ecl_finalizer_module(path, components=None):
757 Add the ECL finalizer module to the path.
759 :param path: The path to add the modules to.
760 :param components: The components to use or None to use all standard components.
763 if components
is None or 'ECL' in components:
764 path.add_module(
'ECLFinalizer')
767def add_ecl_track_cluster_modules(path, components=None):
769 Add the ECL track cluster matching module to the path.
771 :param path: The path to add the modules to.
772 :param components: The components to use or None to use all standard components.
774 if components
is None or (
'ECL' in components
and (
'PXD' in components
or 'SVD' in components
or 'CDC' in components)):
775 path.add_module(
'ECLTrackClusterMatching')
778def add_ecl_cluster_properties_modules(path, components=None):
780 Add the ECL cluster properties module to the path.
782 :param path: The path to add the modules to.
783 :param components: The components to use or None to use all standard components.
785 if components
is None or (
'ECL' in components
and (
'PXD' in components
or 'SVD' in components
or 'CDC' in components)):
786 path.add_module(
'ECLClusterProperties')
789def add_ecl_track_brem_finder(path, components=None):
791 Add the bremsstrahlung finding module to the path.
793 :param path: The path to add the modules to.
794 :param components: The components to use or None to use all standard components.
796 if components
is None or (
'ECL' in components
and (
'PXD' in components
or 'SVD' in components)):
797 path.add_module(
'ECLTrackBremFinder')
800def add_ecl_chargedpid_module(path, components=None, legacyMode=False):
802 Add the ECL charged PID module to the path.
804 :param path: The path to add the modules to.
805 :param components: The components to use or None to use all standard components.
806 :param legacyMode: Uses the simple E/p based charged PID instead of the MVA based charged PID.
808 if components
is None or 'ECL' in components:
811 path.add_module(
'ECLChargedPID')
813 path.add_module(
'ECLFillCellIdMapping')
814 path.add_module(
'ECLChargedPIDMVA')
817def add_ecl_mc_matcher_module(path, components=None):
819 Add the ECL MC matcher module to the path.
821 :param path: The path to add the modules to.
822 :param components: The components to use or None to use all standard components.
824 if components
is None or 'ECL' in components:
825 path.add_module(
'MCMatcherECLClusters')
828def add_ext_module(path, components=None):
830 Add the extrapolation module to the path.
832 :param path: The path to add the modules to.
833 :param components: The components to use or None to use all standard components.
835 if components
is None or 'CDC' in components:
836 path.add_module(
'Ext')
839def add_dedx_modules(path, components=None, for_cdst_analysis=False, enableDebugOutput=False):
841 Add the dE/dX reconstruction modules to the path.
843 :param path: The path to add the modules to.
844 :param components: The components to use or None to use all standard components.
845 :param for_cdst_analysis:
if True, add only DedxPIDCreator module, otherwise add both
846 :param enableDebugOutput: enable/disable writing out debugging information to CDCDedxTracks
849 if components
is None or 'CDC' in components:
850 if for_cdst_analysis:
851 path.add_module(
'CDCDedxPIDCreator', enableDebugOutput=
True)
853 path.add_module(
'CDCDedxHitSaver')
854 path.add_module(
'CDCDedxPIDCreator', enableDebugOutput=enableDebugOutput)
857 if components
is None or 'SVD' in components:
858 if for_cdst_analysis:
859 path.add_module(
'VXDDedxPIDRemaker')
861 path.add_module(
'VXDDedxPID')
864def add_special_vxd_modules(path, components=None):
866 Add two modules that are not part of the standard reconstruction.
868 :param path: The path to add the modules to.
869 :param components: The components to use
or None to use all standard components.
872 if not components
or (
'PXD' in components):
873 path.add_module(
"PXDClustersFromTracks")
874 if not components
or (
'SVD' in components):
875 path.add_module(
"SVDShaperDigitsFromTracks")
878def prepare_cdst_analysis(path, components=None, mc=False, add_eventt0_combiner=False, legacy_ecl_charged_pid=False):
880 Adds to a (analysis) path all the modules needed to analyse a cDST file in the raw+tracking format
881 for collisions/cosmics data
or in the digits+tracking format
for MC data.
883 :param path: The path to add the modules to.
884 :param components: The components to use
or None to use all standard components.
885 :param mc: Are we running over MC data
or not? If so, do
not run the unpackers.
886 :param add_eventt0_combiner: If
True, it adds the EventT0Combiner module when the post-tracking
887 reconstruction
is run. This must NOT be used during the calibration, but it may be necessary
888 for validation purposes
or for the user analyses.
889 :param legacy_ecl_charged_pid: Bool denoting whether to use the legacy EoP based charged particleID
in the ECL (true)
or
890 MVA based charged particle ID (false).
896 components=components)
898 check_components(components)
899 path.add_module(
'Gearbox')
900 path.add_module(
'Geometry')
903 add_prefilter_pretracking_reconstruction(path,
904 components=components)
907 if components
is None or 'SVD' in components:
908 add_svd_reconstruction(path)
909 if components
is None or 'PXD' in components:
910 add_pxd_reconstruction(path)
913 path.add_module(
'SetupGenfitExtrapolation',
914 energyLossBrems=
False,
918 add_posttracking_reconstruction(path,
919 components=components,
920 for_cdst_analysis=
True,
921 add_eventt0_combiner_for_cdst=add_eventt0_combiner,
922 legacy_ecl_charged_pid=legacy_ecl_charged_pid)
925def prepare_user_cdst_analysis(path, components=None, mc=False):
927 Adds to a (analysis) path all the modules needed to analyse a cDST file in the raw+tracking format
928 for collisions/cosmics data
or in the digits+tracking format
for MC data.
929 Differently
from prepare_cdst_analysis(), this function add the EventT0Combiner module to the path,
930 which makes this function suitable
for all the users
and not only
for the calibration expertes.
931 Note that the EventT0Combiner module
is necessary
for applying the proper EventT0 correction to
934 :param path: The path to add the modules to.
935 :param components: The components to use
or None to use all standard components.
936 :param mc: Are we running over MC data
or not? If so, do
not run the unpackers.
938 prepare_cdst_analysis(path=path, components=components, mc=mc, add_eventt0_combiner=True)