Belle II Software  release-05-01-25
reconstruction.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 from basf2 import *
5 
6 from ROOT import Belle2
7 
8 from geometry import check_components
9 
10 from svd import add_svd_reconstruction
11 from pxd import add_pxd_reconstruction
12 
13 from rawdata import add_unpackers
14 
15 from softwaretrigger.constants import ALWAYS_SAVE_OBJECTS, RAWDATA_OBJECTS
16 
17 from tracking import (
18  add_mc_tracking_reconstruction,
19  add_tracking_reconstruction,
20  add_cr_tracking_reconstruction,
21  add_mc_track_finding,
22  add_track_finding,
23  add_prune_tracks,
24 )
25 
26 from softwaretrigger.path_utils import (
27  add_filter_software_trigger,
28  add_skim_software_trigger
29 )
30 
31 import mdst
32 
33 
34 def default_event_abort(module, condition, error_flag):
35  """Default event abort outside of HLT: Ignore the error flag and just stop
36  processing by giving an empty path"""
37  p = Path()
38  module.if_value(condition, p, AfterConditionPath.END)
39 
40 
41 def add_reconstruction(path, components=None, pruneTracks=True, add_trigger_calculation=True, skipGeometryAdding=False,
42  trackFitHypotheses=None, addClusterExpertModules=True, use_second_cdc_hits=False,
43  add_muid_hits=False, reconstruct_cdst=None, nCDCHitsMax=6000, nSVDShaperDigitsMax=70000,
44  event_abort=default_event_abort, use_random_numbers_for_hlt_prescale=True):
45  """
46  This function adds the standard reconstruction modules to a path.
47  Consists of tracking and the functionality provided by :func:`add_posttracking_reconstruction()`,
48  plus the modules to calculate the software trigger cuts.
49 
50  :param path: Add the modules to this path.
51  :param components: list of geometry components to include reconstruction for, or None for all components.
52  :param pruneTracks: Delete all hits except the first and last of the tracks after the dEdX modules.
53  :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module and will add it,
54  if it is not already present in the path. In a setup with multiple (conditional) paths however, it can not
55  determine, if the geometry is already loaded. This flag can be used to just turn off the geometry adding at
56  all (but you will have to add it on your own then).
57  :param trackFitHypotheses: Change the additional fitted track fit hypotheses. If no argument is given,
58  the fitted hypotheses are pion, muon and proton, i.e. [211, 321, 2212].
59  :param addClusterExpertModules: Add the cluster expert modules in the KLM and ECL. Turn this off to reduce
60  execution time.
61  :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
62  :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
63  :param add_trigger_calculation: add the software trigger modules for monitoring (do not make any cut)
64  :param reconstruct_cdst: None for mdst, 'rawFormat' to reconstruct cdsts in rawFormat, 'fullFormat' for the
65  full (old) format. This parameter is needed when reconstructing cdsts, otherwise the
66  required PXD objects won't be added.
67  :param nCDCHitsMax: the max number of CDC hits for an event to be reconstructed.
68  :param nSVDShaperDigitsMax: the max number of SVD shaper digits for an event to be reconstructed.
69  :param event_abort: A function to abort event processing at the given point. Should take three arguments: a module,
70  the condition and the error_flag to be set if these events are kept. If run on HLT this will not abort the event
71  but just remove all data except for the event information.
72  :param use_random_numbers_for_hlt_prescale: If True, the HLT filter prescales are applied using randomly
73  generated numbers, otherwise are applied using an internal counter.
74  """
75 
76  # Check components.
77  check_components(components)
78 
79  # Do not even attempt at reconstructing events w/ abnormally large occupancy.
80  doom = path.add_module("EventsOfDoomBuster", nCDCHitsMax=nCDCHitsMax, nSVDShaperDigitsMax=nSVDShaperDigitsMax)
81  event_abort(doom, ">=1", Belle2.EventMetaData.c_ReconstructionAbort)
82  path.add_module('StatisticsSummary').set_name('Sum_EventsofDoomBuster')
83 
84  # Add modules that have to be run BEFORE track reconstruction
85  add_pretracking_reconstruction(path,
86  components=components)
87 
88  # Add tracking reconstruction modules
89  add_tracking_reconstruction(path,
90  components=components,
91  pruneTracks=False,
92  mcTrackFinding=False,
93  skipGeometryAdding=skipGeometryAdding,
94  trackFitHypotheses=trackFitHypotheses,
95  use_second_cdc_hits=use_second_cdc_hits)
96 
97  # Statistics summary
98  path.add_module('StatisticsSummary').set_name('Sum_Tracking')
99 
100  #
101  # RAW CDST CASE
102  #
103  # If you are reconstructing a raw cdsts, add only the dE/dx calculation, PXDClustersFromTrack, SVDShaperDigitsFromTracks,
104  # and pruning. Full post-tracking recon won't be run unless add_trigger_calculation is set to True.
105  if reconstruct_cdst == 'rawFormat':
106  # if PXD or SVD are included, you will need there two modules which are not part of the standard reconstruction
107  if not components or ('PXD' in components):
108  path.add_module("PXDClustersFromTracks")
109  if not components or ('SVD' in components):
110  path.add_module("SVDShaperDigitsFromTracks")
111 
112  # if you need to calculate the triggerResult, then you will need the full post-tracking recostruction
113  if add_trigger_calculation and (not components or ("CDC" in components and "ECL" in components and "KLM" in components)):
114  add_posttracking_reconstruction(path,
115  components=components,
116  pruneTracks=pruneTracks,
117  add_muid_hits=add_muid_hits,
118  addClusterExpertModules=addClusterExpertModules)
119  add_filter_software_trigger(path,
120  use_random_numbers_for_prescale=use_random_numbers_for_hlt_prescale)
121  add_skim_software_trigger(path)
122  # if you don't need the softwareTrigger result, then you can add only these two modules of the post-tracking reconstruction
123  else:
124  add_dedx_modules(path)
125  add_prune_tracks(path, components=components)
126 
127  #
128  # FULL (aka old) CDST CASE
129  #
130  # if you are reconstructing a full cdst you need full post-tracking and the extra PXD and SVD modules
131  elif reconstruct_cdst == 'fullFormat':
132  # if PXD or SVD are included, you will need there two modules which are not part of the standard reconstruction
133  if not components or ('PXD' in components):
134  path.add_module("PXDClustersFromTracks")
135  if not components or ('SVD' in components):
136  path.add_module("SVDShaperDigitsFromTracks")
137 
138  # Add further reconstruction modules, This part is the same for mdst and full cdsts
139  add_posttracking_reconstruction(path,
140  components=components,
141  pruneTracks=pruneTracks,
142  add_muid_hits=add_muid_hits,
143  addClusterExpertModules=addClusterExpertModules)
144  # Add the modules calculating the software trigger cuts (but not performing them)
145  if add_trigger_calculation and (not components or ("CDC" in components and "ECL" in components and "KLM" in components)):
146  add_filter_software_trigger(path,
147  use_random_numbers_for_prescale=use_random_numbers_for_hlt_prescale)
148  add_skim_software_trigger(path)
149 
150  #
151  # ANYTING ELSE CASE
152  #
153  # if you are not reconstucting cdsts just run the post-trackign stuff
154  else:
155  add_posttracking_reconstruction(path,
156  components=components,
157  pruneTracks=pruneTracks,
158  add_muid_hits=add_muid_hits,
159  addClusterExpertModules=addClusterExpertModules)
160  # Add the modules calculating the software trigger cuts (but not performing them)
161  if add_trigger_calculation and (not components or ("CDC" in components and "ECL" in components and "KLM" in components)):
162  add_filter_software_trigger(path,
163  use_random_numbers_for_prescale=use_random_numbers_for_hlt_prescale)
164  add_skim_software_trigger(path)
165 
166 
167 def add_cosmics_reconstruction(
168  path,
169  components=None,
170  pruneTracks=True,
171  skipGeometryAdding=False,
172  eventTimingExtraction=True,
173  addClusterExpertModules=True,
174  merge_tracks=True,
175  top_in_counter=False,
176  data_taking_period='early_phase3',
177  use_second_cdc_hits=False,
178  add_muid_hits=False,
179  reconstruct_cdst=False):
180  """
181  This function adds the standard reconstruction modules for cosmic data to a path.
182  Consists of tracking and the functionality provided by :func:`add_posttracking_reconstruction()`,
183  plus the modules to calculate the software trigger cuts.
184 
185  :param path: Add the modules to this path.
186  :param data_taking_period: The cosmics generation will be added using the
187  parameters, that where used in this period of data taking. The periods can be found in cdc/cr/__init__.py.
188 
189  :param components: list of geometry components to include reconstruction for, or None for all components.
190  :param pruneTracks: Delete all hits except the first and last of the tracks after the dEdX modules.
191  :param skipGeometryAdding: Advances flag: The tracking modules need the geometry module and will add it,
192  if it is not already present in the path. In a setup with multiple (conditional) paths however, it can not
193  determine, if the geometry is already loaded. This flag can be used to just turn off the geometry adding at
194  all (but you will have to add it on your own then).
195 
196  :param eventTimingExtraction: extract the event time
197  :param addClusterExpertModules: Add the cluster expert modules in the KLM and ECL. Turn this off to reduce
198  execution time.
199 
200  :param merge_tracks: The upper and lower half of the tracks should be merged together in one track
201  :param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
202 
203  :param top_in_counter: time of propagation from the hit point to the PMT in the trigger counter is subtracted
204  (assuming PMT is put at -z of the counter).
205 
206  :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
207 
208  :param reconstruct_cdst: run only the minimal reconstruction needed to produce the cdsts (raw+tracking+dE/dx)
209  """
210 
211  # Check components.
212  check_components(components)
213 
214  # Add modules that have to be run before track reconstruction
215  add_pretracking_reconstruction(path,
216  components=components)
217 
218  # Add cdc tracking reconstruction modules
219  add_cr_tracking_reconstruction(path,
220  components=components,
221  prune_tracks=False,
222  skip_geometry_adding=skipGeometryAdding,
223  event_time_extraction=eventTimingExtraction,
224  merge_tracks=merge_tracks,
225  data_taking_period=data_taking_period,
226  top_in_counter=top_in_counter,
227  use_second_cdc_hits=use_second_cdc_hits)
228 
229  # Statistics summary
230  path.add_module('StatisticsSummary').set_name('Sum_Tracking')
231 
232  if reconstruct_cdst:
233  # if PXD or SVD are included, you will need there two modules which are not part of the standard reconstruction
234  if not components or ('PXD' in components):
235  path.add_module("PXDClustersFromTracks")
236  if not components or ('SVD' in components):
237  path.add_module("SVDShaperDigitsFromTracks")
238  # And add only the dE/dx calculation and prune the tracks
239  add_dedx_modules(path)
240  add_prune_tracks(path, components=components)
241 
242  else:
243  # Add further reconstruction modules
244  add_posttracking_reconstruction(path,
245  components=components,
246  pruneTracks=pruneTracks,
247  addClusterExpertModules=addClusterExpertModules,
248  add_muid_hits=add_muid_hits,
249  cosmics=True)
250 
251 
252 def add_mc_reconstruction(path, components=None, pruneTracks=True, addClusterExpertModules=True,
253  use_second_cdc_hits=False, add_muid_hits=False):
254  """
255  This function adds the standard reconstruction modules with MC tracking
256  to a path.
257 
258  @param components list of geometry components to include reconstruction for, or None for all components.
259  @param use_second_cdc_hits: If true, the second hit information will be used in the CDC track finding.
260  :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
261  """
262 
263  # Add modules that have to be run before track reconstruction
264  add_pretracking_reconstruction(path,
265  components=components)
266 
267  # tracking
268  add_mc_tracking_reconstruction(path,
269  components=components,
270  pruneTracks=False,
271  use_second_cdc_hits=use_second_cdc_hits)
272 
273  # Statistics summary
274  path.add_module('StatisticsSummary').set_name('Sum_Tracking')
275 
276  # add further reconstruction modules
277  add_posttracking_reconstruction(path,
278  components=components,
279  pruneTracks=pruneTracks,
280  add_muid_hits=add_muid_hits,
281  addClusterExpertModules=addClusterExpertModules)
282 
283 
284 def add_pretracking_reconstruction(path, components=None):
285  """
286  This function adds the standard reconstruction modules BEFORE tracking
287  to a path.
288 
289  :param path: The path to add the modules to.
290  :param components: list of geometry components to include reconstruction for, or None for all components.
291  """
292 
293  add_ecl_modules(path, components)
294 
295  # Statistics summary
296  path.add_module('StatisticsSummary').set_name('Sum_Clustering')
297 
298 
299 def add_posttracking_reconstruction(path, components=None, pruneTracks=True, addClusterExpertModules=True,
300  add_muid_hits=False, cosmics=False):
301  """
302  This function adds the standard reconstruction modules after tracking
303  to a path.
304 
305  :param path: The path to add the modules to.
306  :param components: list of geometry components to include reconstruction for, or None for all components.
307  :param pruneTracks: Delete all hits except the first and last after the post-tracking modules.
308  :param addClusterExpertModules: Add the cluster expert modules in the KLM and ECL. Turn this off to reduce
309  execution time.
310  :param add_muid_hits: Add the found KLM hits to the RecoTrack. Make sure to refit the track afterwards.
311  :param cosmics: if True, steer TOP for cosmic reconstruction
312  """
313 
314  add_dedx_modules(path, components)
315  add_ext_module(path, components)
316  add_top_modules(path, components, cosmics=cosmics)
317  add_arich_modules(path, components)
318 
319  path.add_module("EventT0Combiner")
320 
321  add_ecl_finalizer_module(path, components)
322 
323  add_ecl_mc_matcher_module(path, components)
324 
325  add_klm_modules(path, components)
326 
327  add_klm_mc_matcher_module(path, components)
328 
329  add_muid_module(path, add_hits_to_reco_track=add_muid_hits, components=components)
330  add_ecl_track_cluster_modules(path, components)
331  add_ecl_cluster_properties_modules(path, components)
332  add_ecl_chargedpid_module(path, components)
333  add_pid_module(path, components)
334 
335  if addClusterExpertModules:
336  # FIXME: Disabled for HLT until execution time bug is fixed
337  add_cluster_expert_modules(path, components)
338 
339  add_ecl_track_brem_finder(path, components)
340 
341  # Prune tracks as soon as the post-tracking steps are complete
342  if pruneTracks:
343  add_prune_tracks(path, components)
344 
345  path.add_module('StatisticsSummary').set_name('Sum_Posttracking_Reconstruction')
346 
347 
348 def add_mdst_output(
349  path,
350  mc=True,
351  filename='mdst.root',
352  additionalBranches=[],
353  dataDescription=None,
354 ):
355  """
356  This function adds the MDST output modules to a path, saving only objects defined as part of the MDST data format.
357 
358  @param path Path to add modules to
359  @param mc Save Monte Carlo quantities? (MCParticles and corresponding relations)
360  @param filename Output file name.
361  @param additionalBranches Additional objects/arrays of event durability to save
362  @param dataDescription Additional key->value pairs to be added as data description
363  fields to the output FileMetaData
364  """
365 
366  return mdst.add_mdst_output(path, mc, filename, additionalBranches, dataDescription)
367 
368 
369 def add_cdst_output(
370  path,
371  mc=True,
372  filename='cdst.root',
373  additionalBranches=[],
374  dataDescription=None,
375  rawFormat=False,
376  ignoreInputModulesCheck=False
377 ):
378  """
379  This function adds the `RootOutput` module to a path with the settings needed to produce a cDST output.
380 
381  @param path Path to add modules to.
382  @param mc Save Monte Carlo quantities? (MCParticles and corresponding relations)
383  @param filename Output file name.
384  @param additionalBranches Additional objects/arrays of event durability to save
385  @param dataDescription Additional key->value pairs to be added as data description
386  fields to the output FileMetaData
387  @param rawFormat saves the cdsts in the raw+tracking format.
388  @param ignoreInputModulesCheck If True, do not enforce check on missing PXD modules in the input path.
389  Needed when a conditional path is passed as input.
390  """
391 
392  branches = [
393  'Tracks',
394  'V0s',
395  'TrackFitResults',
396  'EventLevelTrackingInfo',
397  'PIDLikelihoods',
398  'TracksToPIDLikelihoods',
399  'ECLClusters',
400  'ECLClustersToTracksNamedBremsstrahlung',
401  'EventLevelClusteringInfo',
402  'TracksToECLClusters',
403  'KLMClusters',
404  'KlIds',
405  'KLMClustersToKlIds',
406  'TRGSummary',
407  'SoftwareTriggerResult',
408  'RecoTracks',
409  'EventT0',
410  'PXDClustersFromTracks',
411  'SVDEventInfo',
412  'SVDShaperDigits',
413  'SVDRecoDigits',
414  'SVDClusters',
415  'CDCDedxTracks',
416  'TOPDigits',
417  'ExtHits',
418  'TOPLikelihoods',
419  'TOPRecBunch',
420  'TOPTimeZeros',
421  'TOPAsicMask',
422  'ECLDigits',
423  'ECLCalDigits',
424  'TRGECLClusters',
425  'TRGECLUnpackerStores',
426  'TRGECLUnpackerEvtStores',
427  'TRGGRLUnpackerStore',
428  'CDCTriggerSegmentHits',
429  'CDCTrigger2DFinderTracks',
430  'CDCTrigger2DFinderClones',
431  'CDCTriggerNNInputSegmentHits',
432  'CDCTriggerNNInput2DFinderTracks',
433  'CDCTriggerNeuroTracks',
434  'CDCTriggerNeuroTracksInput',
435  'CDCTriggerNNInputFinderTracks',
436  'CDCTriggerNNInputBits',
437  'CDCTriggerNNOutputBits',
438  'TRGGDLUnpackerStores',
439  'TRGTOPUnpackerStores',
440  'RecoHitInformations',
441  'RecoHitInformationsToBKLMHit2ds',
442  'TracksToARICHLikelihoods',
443  'TracksToExtHits',
444  'ARICHDigits',
445  'ARICHInfo',
446  'ARICHTracks',
447  'ARICHLikelihoods',
448  'ARICHTracksToExtHits',
449  'SoftwareTriggerVariables',
450  'KLMDigits',
451  'KLMMuidLikelihoods',
452  'TracksToKLMMuidLikelihoods',
453  'BKLMHit1ds',
454  'BKLMHit1dsToKLMDigits',
455  'BKLMHit2ds',
456  'BKLMHit2dsToBKLMHit1ds',
457  'EKLMAlignmentHits',
458  'EKLMHit2ds',
459  'EKLMHit2dsToKLMDigits',
460  'TracksToBKLMHit2ds',
461  'TracksToEKLMHit2ds',
462  'SVDShaperDigitsFromTracks',
463  'TRGGDLUnpackerStores',
464  'VXDDedxTracks',
465  'VXDDedxLikelihoods',
466  ]
467 
468  if rawFormat:
469  branches = ALWAYS_SAVE_OBJECTS + RAWDATA_OBJECTS + [
470  'RecoTracks',
471  'Tracks',
472  'V0s',
473  'TrackFitResults',
474  'EventT0',
475  'TRGECLClusters',
476  'CDCDedxTracks',
477  'SVDShaperDigitsFromTracks',
478  'PXDClustersFromTracks',
479  'VXDDedxTracks',
480  'CDCDedxLikelihoods',
481  'VXDDedxLikelihoods'
482  ]
483 
484  if not ignoreInputModulesCheck and "PXDClustersFromTracks" not in [module.name() for module in path.modules()]:
485  basf2.B2ERROR("PXDClustersFromTracks is required in CDST output but its module is not found in the input path!")
486 
487  if dataDescription is None:
488  dataDescription = {}
489  dataDescription.setdefault("dataLevel", "cdst")
490 
491  persistentBranches = ['FileMetaData']
492  if mc:
493  branches += ['MCParticles', 'TracksToMCParticles',
494  'ECLClustersToMCParticles', 'KLMClustersToMCParticles']
495  persistentBranches += ['BackgroundInfo']
496  branches += additionalBranches
497 
498  return path.add_module("RootOutput", outputFileName=filename, branchNames=branches,
499  branchNamesPersistent=persistentBranches, additionalDataDescription=dataDescription)
500 
501 
502 def add_arich_modules(path, components=None):
503  """
504  Add the ARICH reconstruction to the path.
505 
506  :param path: The path to add the modules to.
507  :param components: The components to use or None to use all standard components.
508  """
509  if components is None or 'ARICH' in components:
510  arich_fillHits = register_module('ARICHFillHits')
511  path.add_module(arich_fillHits)
512  arich_rec = register_module('ARICHReconstructor')
513  # enabled for ARICH DQM plots
514  arich_rec.param('storePhotons', 1)
515  path.add_module(arich_rec)
516 
517 
518 def add_top_modules(path, components=None, cosmics=False):
519  """
520  Add the TOP reconstruction to the path.
521 
522  :param path: The path to add the modules to.
523  :param components: The components to use or None to use all standard components.
524  :param cosmics: if True, steer TOP for cosmic reconstruction
525  """
526  # TOP reconstruction
527  if components is None or 'TOP' in components:
528  top_cm = register_module('TOPChannelMasker')
529  path.add_module(top_cm)
530  if cosmics:
531  top_finder = register_module('TOPCosmicT0Finder')
532  path.add_module(top_finder)
533  else:
534  top_finder = register_module('TOPBunchFinder')
535  path.add_module(top_finder)
536  top_rec = register_module('TOPReconstructor')
537  path.add_module(top_rec)
538 
539 
540 def add_cluster_expert_modules(path, components=None):
541  """
542  Add the KLMExpert and ClusterMatcher modules to the path.
543 
544  :param path: The path to add the modules to.
545  :param components: The components to use or None to use all standard components.
546  """
547  # KLMExpert (needed for KlId) ClusterMatcher (needed for Cluster)
548  if components is None or ('KLM' in components and 'ECL' in components):
549  klm_expert = register_module('KLMExpert')
550  path.add_module(klm_expert)
551  cluster_matcher = register_module('ClusterMatcher')
552  path.add_module(cluster_matcher)
553 
554 
555 def add_pid_module(path, components=None):
556  """
557  Add the PID modules to the path.
558 
559  :param path: The path to add the modules to.
560  :param components: The components to use or None to use all standard components.
561  """
562  # charged particle PID
563  if components is None or 'SVD' in components or 'CDC' in components:
564  mdstPID = register_module('MdstPID')
565  path.add_module(mdstPID)
566 
567 
568 def add_klm_modules(path, components=None):
569  """
570  Add the KLM reconstruction modules to the path.
571 
572  :param path: The path to add the modules to.
573  :param components: The components to use or None to use all standard components.
574  """
575  if components is None or 'KLM' in components:
576  klm_rec = register_module('KLMReconstructor')
577  path.add_module(klm_rec)
578  klm_clusters_rec = register_module('KLMClustersReconstructor')
579  path.add_module(klm_clusters_rec)
580 
581 
582 def add_klm_mc_matcher_module(path, components=None):
583  """
584  Add the KLM mc matcher module to the path.
585 
586  :param path: The path to add the modules to.
587  :param components: The components to use or None to use all standard components.
588  """
589  # MC matching
590  if components is None or 'KLM' in components:
591  klm_mc = register_module('MCMatcherKLMClusters')
592  path.add_module(klm_mc)
593 
594 
595 def add_muid_module(path, add_hits_to_reco_track=False, components=None):
596  """
597  Add the MuID module to the path.
598 
599  :param path: The path to add the modules to.
600  :param add_hits_to_reco_track: Add the found KLM hits also to the RecoTrack. Make sure to refit the track afterwards.
601  :param components: The components to use or None to use all standard components.
602  """
603  # Muid is needed for muonID computation and ECLCluster-Track matching.
604  if components is None or ('CDC' in components and 'ECL' in components and 'KLM' in components):
605  muid = register_module('Muid', addHitsToRecoTrack=add_hits_to_reco_track)
606  path.add_module(muid)
607  if components is not None and 'CDC' in components:
608  if ('ECL' not in components and 'KLM' in components):
609  B2WARNING('You added KLM to the components list but not ECL: the module Muid, that is necessary '
610  'for correct muonID computation, will not be added to your reconstruction path. '
611  'Make sure that this is fine for your purposes, otherwise please include also ECL.')
612  if ('ECL' in components and 'KLM' not in components):
613  B2WARNING('You added ECL to the components list but not KLM: the module Muid, that is necessary '
614  'for correct ECLCluster-Track matching, will not be added to your reconstruction path. '
615  ' Make sure that this is fine for your purposes, otherwise please include also KLM.')
616 
617 
618 def add_ecl_modules(path, components=None):
619  """
620  Add the ECL reconstruction modules to the path.
621 
622  :param path: The path to add the modules to.
623  :param components: The components to use or None to use all standard components.
624  """
625  # ECL calibration and reconstruction
626  if components is None or 'ECL' in components:
627 
628  # ECL offline waveform fitting
629  ecl_waveform_fit = register_module('ECLWaveformFit')
630  path.add_module(ecl_waveform_fit)
631 
632  # ECL digit calibration
633  ecl_digit_calibration = register_module('ECLDigitCalibrator')
634  path.add_module(ecl_digit_calibration)
635 
636  # ECL T0 extraction
637  path.add_module('ECLEventT0')
638 
639  # ECL connected region finder
640  ecl_crfinder = register_module('ECLCRFinder')
641  path.add_module(ecl_crfinder)
642 
643  # ECL local maximum finder
644  ecl_lmfinder = register_module('ECLLocalMaximumFinder')
645  path.add_module(ecl_lmfinder)
646 
647  # ECL splitter N1
648  ecl_splitterN1 = register_module('ECLSplitterN1')
649  path.add_module(ecl_splitterN1)
650 
651  # ECL splitter N2
652  ecl_splitterN2 = register_module('ECLSplitterN2')
653  path.add_module(ecl_splitterN2)
654 
655  # ECL Shower Correction
656  ecl_showercorrection = register_module('ECLShowerCorrector')
657  path.add_module(ecl_showercorrection)
658 
659  # ECL Shower Calibration
660  ecl_showercalibration = register_module('ECLShowerCalibrator')
661  path.add_module(ecl_showercalibration)
662 
663  # ECL Shower Shape
664  ecl_showershape = register_module('ECLShowerShape')
665  path.add_module(ecl_showershape)
666 
667  # ECL Pulse Shape Discrimination
668  ecl_clusterPSD = register_module('ECLClusterPSD')
669  path.add_module(ecl_clusterPSD)
670 
671  # ECL covariance matrix
672  ecl_covariance = register_module('ECLCovarianceMatrix')
673  path.add_module(ecl_covariance)
674 
675  # ECL finalize -> must run after eventT0Combiner
676 
677 
678 def add_ecl_finalizer_module(path, components=None):
679  """
680  Add the ECL finalizer module to the path.
681 
682  :param path: The path to add the modules to.
683  :param components: The components to use or None to use all standard components.
684  """
685 
686  if components is None or 'ECL' in components:
687  # ECL finalize
688  ecl_finalize = register_module('ECLFinalizer')
689  path.add_module(ecl_finalize)
690 
691 
692 def add_ecl_track_cluster_modules(path, components=None):
693  """
694  Add the ECL track cluster matching module to the path.
695 
696  :param path: The path to add the modules to.
697  :param components: The components to use or None to use all standard components.
698  """
699  if components is None or ('ECL' in components and ('PXD' in components or 'SVD' in components or 'CDC' in components)):
700  path.add_module('ECLTrackClusterMatching')
701 
702 
703 def add_ecl_cluster_properties_modules(path, components=None):
704  """
705  Add the ECL cluster properties module to the path.
706 
707  :param path: The path to add the modules to.
708  :param components: The components to use or None to use all standard components.
709  """
710  if components is None or ('ECL' in components and ('PXD' in components or 'SVD' in components or 'CDC' in components)):
711  path.add_module('ECLClusterProperties')
712 
713 
714 def add_ecl_track_brem_finder(path, components=None):
715  """
716  Add the bremsstrahlung finding module to the path.
717 
718  :param path: The path to add the modules to.
719  :param components: The components to use or None to use all standard components.
720  """
721  if components is None or ('ECL' in components and ('PXD' in components or 'SVD' in components)):
722  brem_finder = register_module('ECLTrackBremFinder')
723  path.add_module(brem_finder)
724 
725 
726 def add_ecl_chargedpid_module(path, components=None):
727  """
728  Add the ECL charged PID module to the path.
729 
730  :param path: The path to add the modules to.
731  :param components: The components to use or None to use all standard components.
732  """
733  if components is None or 'ECL' in components:
734  # charged PID
735  charged_id = register_module('ECLChargedPID')
736  path.add_module(charged_id)
737 
738 
739 def add_ecl_mc_matcher_module(path, components=None):
740  """
741  Add the ECL MC matcher module to the path.
742 
743  :param path: The path to add the modules to.
744  :param components: The components to use or None to use all standard components.
745  """
746  if components is None or 'ECL' in components:
747  # MC matching
748  ecl_mc = register_module('MCMatcherECLClusters')
749  path.add_module(ecl_mc)
750 
751 
752 def add_ext_module(path, components=None):
753  """
754  Add the extrapolation module to the path.
755 
756  :param path: The path to add the modules to.
757  :param components: The components to use or None to use all standard components.
758  """
759  if components is None or 'CDC' in components:
760  ext = register_module('Ext')
761  path.add_module(ext)
762 
763 
764 def add_dedx_modules(path, components=None):
765  """
766  Add the dEdX reconstruction modules to the path
767  and prune the tracks afterwards if wanted.
768 
769  :param path: The path to add the modules to.
770  :param components: The components to use or None to use all standard components.
771  """
772  # CDC dE/dx PID
773  if components is None or 'CDC' in components:
774  CDCdEdxPID = register_module('CDCDedxPID')
775  path.add_module(CDCdEdxPID)
776 
777  # VXD dE/dx PID
778  # only run this if the SVD is enabled - PXD is disabled by default
779  if components is None or 'SVD' in components:
780  VXDdEdxPID = register_module('VXDDedxPID')
781  path.add_module(VXDdEdxPID)
782 
783 
784 def prepare_cdst_analysis(path, components=None):
785  """
786  Adds to a (analysis) path all the modules needed to
787  analyse a cdsts file in the raw+tracking format.
788 
789  :param path: The path to add the modules to.
790  :param components: The components to use or None to use all standard components.
791  """
792  # unpackers
793  add_unpackers(path, components=components)
794 
795  # this is currently just calls add_ecl_modules
796  add_pretracking_reconstruction(path, components=components)
797 
798  # needed to retrieve the PXD and SVD clusters out of the raws
799  if components is None or 'SVD' in components:
800  add_svd_reconstruction(path)
801  if components is None or 'PXD' in components:
802  add_pxd_reconstruction(path)
803 
804  # check, this one may not be needed...
805  path.add_module('SetupGenfitExtrapolation', energyLossBrems=False, noiseBrems=False)
806 
807  # from here on mostly a replica of add_posttracking_reconstruction without dE/dx, prunetracks and eventT0 modules
808  add_ext_module(path, components)
809  add_top_modules(path, components)
810  add_arich_modules(path, components)
811  add_ecl_finalizer_module(path, components)
812  add_ecl_mc_matcher_module(path, components)
813  add_klm_modules(path, components)
814  add_klm_mc_matcher_module(path, components)
815  add_muid_module(path, components=components)
816  add_ecl_track_cluster_modules(path, components)
817  add_ecl_cluster_properties_modules(path, components)
818  add_ecl_chargedpid_module(path, components)
819  add_pid_module(path, components)
820  add_cluster_expert_modules(path, components)
821  add_ecl_track_brem_finder(path, components)
mdst.add_mdst_output
def add_mdst_output(path, mc=True, filename='mdst.root', additionalBranches=[], dataDescription=None)
Definition: mdst.py:8
softwaretrigger.constants
Definition: constants.py:1
softwaretrigger.path_utils
Definition: path_utils.py:1