2 from softwaretrigger
import constants
6 from geometry
import check_components
10 def add_online_dqm(path, run_type, dqm_environment, components, dqm_mode, create_hlt_unit_histograms=False):
12 Add DQM plots for a specific run type and dqm environment
16 from daqdqm.collisiondqm
import add_collision_dqm
17 from daqdqm.cosmicdqm
import add_cosmic_dqm
19 if run_type == constants.RunTypes.beam:
20 add_collision_dqm(path, components=components, dqm_environment=dqm_environment,
21 dqm_mode=dqm_mode, create_hlt_unit_histograms=create_hlt_unit_histograms)
22 elif run_type == constants.RunTypes.cosmic:
23 add_cosmic_dqm(path, components=components, dqm_environment=dqm_environment,
26 basf2.B2FATAL(
"Run type {} not supported.".format(run_type))
28 if dqm_mode
in [
"dont_care",
"all_events"]:
29 path.add_module(
'DelayDQM', title=dqm_environment, histogramDirectoryName=
'DAQ')
32 def add_hlt_dqm(path, run_type, components, dqm_mode, create_hlt_unit_histograms=False):
34 Add all the DQM modules for HLT to the path
39 dqm_environment=constants.Location.hlt.name,
40 components=components,
41 dqm_mode=dqm_mode.name,
42 create_hlt_unit_histograms=create_hlt_unit_histograms)
43 path.add_module(
'StatisticsSummary').set_name(
'Sum_HLT_DQM_'+dqm_mode.name)
46 def add_expressreco_dqm(path, run_type, components):
48 Add all the DQM modules for ExpressReco to the path
50 add_online_dqm(path, run_type=run_type, dqm_environment=constants.Location.expressreco.name, components=components,
51 dqm_mode=constants.DQMModes.dont_care.name)
54 def add_geometry_if_not_present(path):
56 Add the geometry and gearbox module if it was not already added to the path
58 if 'Gearbox' not in path:
59 path.add_module(
'Gearbox')
61 if 'Geometry' not in path:
62 path.add_module(
'Geometry', useDB=
True)
65 def add_store_only_metadata_path(path):
67 Helper function to create a path which deletes (prunes) everything from the data store except
68 things that are really needed, e.g. the event meta data and the results of the software trigger module.
70 After this path was processed, you can not use the data store content any more to do reconstruction (because
71 it is more or less empty), but can only output it to a (S)ROOT file.
73 path.add_module(
"PruneDataStore", matchEntries=constants.ALWAYS_SAVE_OBJECTS).set_name(
"KeepMetaData")
76 def add_store_only_rawdata_path(path, additonal_store_arrays_to_keep=None):
78 Helper function to create a path which deletes (prunes) everything from the data store except
79 raw objects from the detector and things that are really needed, e.g. the event meta data and the results of the
80 software trigger module.
82 After this path was processed, you can not use the data store content any more to do reconstruction (because
83 it is more or less empty), but can only output it to a (S)ROOT file.
85 entries_to_keep = constants.ALWAYS_SAVE_OBJECTS + constants.RAWDATA_OBJECTS
87 if additonal_store_arrays_to_keep:
88 entries_to_keep += additonal_store_arrays_to_keep
90 path.add_module(
"PruneDataStore", matchEntries=entries_to_keep).set_name(
"KeepRawData")
93 def add_filter_software_trigger(path,
94 store_array_debug_prescale=0,
95 use_random_numbers_for_prescale=True):
97 Add the SoftwareTrigger for the filter cuts to the given path.
99 Only the calculation of the cuts is implemented here - the cut logic has to be done
100 using the module return value.
102 :param path: The path to which the module should be added.
103 :param store_array_debug_prescale: When not 0, store each N events the content of the variables needed for the
104 cut calculations in the data store.
105 :param use_random_numbers_for_prescale: If True, the prescales are applied using randomly generated numbers,
106 otherwise are applied using an internal counter.
107 :return: the software trigger module
109 hlt_cut_module = path.add_module(
"SoftwareTrigger",
110 baseIdentifier=
"filter",
111 preScaleStoreDebugOutputToDataStore=store_array_debug_prescale,
112 useRandomNumbersForPreScale=use_random_numbers_for_prescale)
114 return hlt_cut_module
117 def add_skim_software_trigger(path, store_array_debug_prescale=0):
119 Add the SoftwareTrigger for the skimming (after the filtering) to the given path.
121 Only the calculation of the cuts is implemented here - the cut logic has to be done
123 :param path: The path to which the module should be added.
124 :param store_array_debug_prescale: When not 0, store each N events the content of the variables needed for the
125 cut calculations in the data store.
126 :return: the software trigger module
139 [[clusterReg == 1 and E > 0.03] or [clusterReg == 2 and E > 0.02] or [clusterReg == 3 and E > 0.03]] and \
140 [abs(clusterTiming) < formula(1.0 * clusterErrorTiming) or E > 0.1] and [clusterE1E9 > 0.3 or E > 0.1] ', path=path)
143 vertex.kFit(
'pi0:veryLooseFit', 0.0,
'mass', path=path)
144 D0_Cut =
'1.7 < M < 2.1'
145 D0_Ch = [
'K-:dstSkim pi+:dstSkim',
146 'K-:dstSkim pi+:dstSkim pi0:veryLooseFit',
147 'K-:dstSkim pi+:dstSkim pi-:dstSkim pi+:dstSkim',
148 'K_S0:dstSkim pi+:dstSkim pi-:dstSkim']
150 for chID, channel
in enumerate(D0_Ch):
154 Dst_Cut =
'useCMSFrame(p) > 2.2 and massDifference(0) < 0.16'
157 for chID, channel
in enumerate(D0_Ch):
160 Dst_List.append(
'D*+:ch' + str(chID))
164 path.add_module(
"SoftwareTrigger", baseIdentifier=
"skim",
165 preScaleStoreDebugOutputToDataStore=store_array_debug_prescale)
168 def add_filter_reconstruction(path, run_type, components, **kwargs):
170 Add everything needed to calculation a filter decision and if possible,
171 also do the HLT filtering. This is only possible for beam runs (in the moment).
173 Up to now, we add the full reconstruction, but this will change in the future.
175 Please note that this function adds the HLT decision, but does not branch
178 check_components(components)
180 if run_type == constants.RunTypes.beam:
183 skipGeometryAdding=
True,
185 add_trigger_calculation=
False,
186 components=components,
187 nCDCHitsMax=constants.DOOM_NCDCHITSMAX,
188 nSVDShaperDigitsMax=constants.DOOM_NSVDSHAPERDIGITSMAX,
189 event_abort=hlt_event_abort,
192 add_filter_software_trigger(path, store_array_debug_prescale=1)
193 path.add_module(
'StatisticsSummary').set_name(
'Sum_HLT_Filter_Calculation')
195 elif run_type == constants.RunTypes.cosmic:
197 components=components, **kwargs)
199 basf2.B2FATAL(f
"Run Type {run_type} not supported.")
202 def add_filter_module(path):
204 Add and return a skim module, which has a return value dependent
205 on the final HLT decision.
207 return path.add_module(
"TriggerSkim", triggerLines=[
"software_trigger_cut&all&total_result"])
210 def add_post_filter_reconstruction(path, run_type, components):
212 Add all modules which should run after the HLT decision is taken
213 and only on the accepted events.
214 Up to now, this only includes the skim part, but this will
215 change in the future.
217 check_components(components)
219 if run_type == constants.RunTypes.beam:
220 add_skim_software_trigger(path, store_array_debug_prescale=1)
221 path.add_module(
'StatisticsSummary').set_name(
'Sum_HLT_Skim_Calculation')
222 elif run_type == constants.RunTypes.cosmic:
225 basf2.B2FATAL(f
"Run Type {run_type} not supported.")
228 def hlt_event_abort(module, condition, error_flag):
230 Create a discard path suitable for HLT processing, i.e. set an error flag and
231 keep only the metadata.
234 p.add_module(
"EventErrorFlag", errorFlag=error_flag)
235 add_store_only_metadata_path(p)
236 module.if_value(condition, p, basf2.AfterConditionPath.CONTINUE)