ATLAS Offline Software
Loading...
Searching...
No Matches
L1CaloFEXByteStreamConfig.py
Go to the documentation of this file.
2# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3#
4from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
5from AthenaConfiguration.ComponentFactory import CompFactory
6from libpyeformat_helper import SourceIdentifier, SubDetector
7
8def eFexByteStreamToolCfg(flags, name, *, writeBS=False, TOBs=True, xTOBs=False, multiSlice=False, decodeInputs=False):
9 acc = ComponentAccumulator()
10
11 tool = CompFactory.eFexByteStreamTool(name)
12
13 if writeBS:
14 # write BS == read xAOD
15 # Input RoI containers come from the TrigCompositeContainer passed by the
16 # Cnv at runtime, so no read-handle properties are needed here.
17 tool.eEMContainerWriteKey = ""
18 tool.eTAUContainerWriteKey = ""
19 efex_roi_moduleids = [0x1000,0x1100]
20 tool.ROBIDs = [int(SourceIdentifier(SubDetector.TDAQ_CALO_FEAT_EXTRACT_ROI, moduleid)) for moduleid in efex_roi_moduleids]
21
22 else:
23 # read BS == write xAOD
24 if TOBs or xTOBs or multiSlice:
25 efex_roi_moduleids = [0x1000,0x1100]
26 tool.ROBIDs = [int(SourceIdentifier(SubDetector.TDAQ_CALO_FEAT_EXTRACT_ROI, moduleid)) for moduleid in efex_roi_moduleids]
27 if TOBs:
28 tool.eEMContainerWriteKey = "L1_eEMRoI"
29 tool.eTAUContainerWriteKey = "L1_eTauRoI"
30 if xTOBs:
31 tool.eEMxContainerWriteKey = "L1_eEMxRoI"
32 tool.eTAUxContainerWriteKey = "L1_eTauxRoI"
33 if multiSlice:
34 tool.eEMSliceContainerWriteKey = "L1_eEMxRoIOutOfTime"
35 tool.eTAUSliceContainerWriteKey = "L1_eTauxRoIOutOfTime"
36 if decodeInputs:
37 efex_raw_ids = []
38 inputId = int(SourceIdentifier(SubDetector.TDAQ_CALO_FEAT_EXTRACT_DAQ, 0x1000))
39 for shelf in range(0,2):
40 for module in range(0,12):
41 efex_raw_ids += [inputId + shelf*0x100 + module*0x010 ]
42 tool.ROBIDs += efex_raw_ids
43 tool.eTowerContainerWriteKey = "L1_eFexDataTowers"
44
45 if flags.Output.HISTFileName != '' or flags.Trigger.doHLT:
46 if flags.Trigger.doHLT:
47 from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
48 monTool = GenericMonitoringTool(flags,'MonTool',HistPath = f'HLTFramework/L1BSConverters/{name}')
49 topDir = "EXPERT"
50 monTool.defineHistogram('efexDecoderErrorTitle,efexDecoderErrorLocation;errors', path=topDir, type='TH2I',
51 title='Decoder Errors;Title;Location',
52 xbins=1,xmin=0,xmax=1,
53 ybins=1,ymin=0,ymax=1,
54 opt=['kCanRebin'],merge="merge")
55 tool.MonTool = monTool
56 else:
57 # if used in offline reconstruction respect DQ convention (ATR-26371)
58 # use L1Calo's special MonitoringCfgHelper
59 from TrigT1CaloMonitoring.LVL1CaloMonitoringConfig import L1CaloMonitorCfgHelper
60 helper = L1CaloMonitorCfgHelper(flags,None,name)
61
62 # could consider getting rid of this first histogram, since all the info should be accessible in the second
63 # will make decision after gaining experience @ P1
64 helper.defineHistogram('efexDecoderErrorTitle,efexDecoderErrorLocation;h_efex_errors', type='TH2I',
65 path="Developer/ByteStreamDecoders",
66 fillGroup = f'{name}MonTool',
67 title='eFEX Decoder Errors;Title;Location',
68 xbins=1,xmin=0,xmax=1,
69 ybins=1,ymin=0,ymax=1,
70 opt=['kCanRebin','kAlwaysCreate'],merge="merge")
71 helper.defineHistogram('lbn,decoderError;h_efex_errors_vs_lbn', type='TH2I',
72 path="Expert/ByteStreamDecoders",
73 hanConfig={"algorithm":"Histogram_Empty","description":"Should be empty. Please report any errors to eFEX software experts."},
74 fillGroup = f'{name}MonTool',
75 title='eFEX Decoder Errors;LB;Error',
76 xbins=1,xmin=0,xmax=1,
77 ybins=1,ymin=0,ymax=1,
78 opt=['kAddBinsDynamically','kCanRebin','kAlwaysCreate'],merge="merge")
79 tool.MonTool = helper.fillGroups[f'{name}MonTool']
80 acc.merge(helper.result())
81
82
83 acc.setPrivateTools(tool)
84 return acc
85
86
87def jFexRoiByteStreamToolCfg(flags, name, *, writeBS=False, xTOBs=False):
88 acc = ComponentAccumulator()
89 tool = CompFactory.jFexRoiByteStreamTool(name)
90 tool.ConvertExtendedTOBs = xTOBs
91 jfex_roi_moduleids = [0x2000]
92 tool.ROBIDs = [int(SourceIdentifier(SubDetector.TDAQ_CALO_FEAT_EXTRACT_ROI, moduleid)) for moduleid in jfex_roi_moduleids]
93 if writeBS:
94 # write BS == read xAOD
95 # Input RoI containers come from the TrigCompositeContainer passed by the
96 # Cnv at runtime, so no read-handle properties are needed here.
97 tool.jJRoIContainerWriteKey =""
98 tool.jLJRoIContainerWriteKey =""
99 tool.jTauRoIContainerWriteKey=""
100 tool.jEMRoIContainerWriteKey =""
101 tool.jTERoIContainerWriteKey =""
102 tool.jXERoIContainerWriteKey =""
103 else:
104 # read BS == write xAOD
105 tool.jJRoIContainerWriteKey = "L1_jFexSRJetxRoI" if xTOBs else "L1_jFexSRJetRoI"
106 tool.jLJRoIContainerWriteKey = "L1_jFexLRJetxRoI" if xTOBs else "L1_jFexLRJetRoI"
107 tool.jTauRoIContainerWriteKey= "L1_jFexTauxRoI" if xTOBs else "L1_jFexTauRoI"
108 tool.jEMRoIContainerWriteKey = "L1_jFexFwdElxRoI" if xTOBs else "L1_jFexFwdElRoI"
109 tool.jTERoIContainerWriteKey = "L1_jFexSumETxRoI" if xTOBs else "L1_jFexSumETRoI"
110 tool.jXERoIContainerWriteKey = "L1_jFexMETxRoI" if xTOBs else "L1_jFexMETRoI"
111
112 if flags.Output.HISTFileName != '' or flags.Trigger.doHLT:
113 if flags.Trigger.doHLT:
114 from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
115 monTool = GenericMonitoringTool(flags,'MonTool',HistPath = f'HLTFramework/L1BSConverters/{name}')
116 topDir = "EXPERT"
117 else:
118 # if used in offline reconstruction respect DQ convention (ATR-26371)
119 from AthenaMonitoring import AthMonitorCfgHelper
120 helper = AthMonitorCfgHelper(flags, 'HLTFramework')
121 monTool = helper.addGroup(None, f'{name}MonTool', f'/HLT/HLTFramework/L1BSConverters/{name}')
122 topDir = None
123 acc.merge(helper.result())
124
125 monTool.defineHistogram('jfexDecoderErrorTitle,jfexDecoderErrorLocation;errors', path=topDir, type='TH2I',
126 title='jFEX TOB Decoder Errors;Type;Location',
127 xlabels=["UNKNOWN"],
128 ylabels=["UNKNOWN"],
129 opt=['kCanRebin'],merge="merge")
130 tool.MonTool = monTool
131
132 acc.setPrivateTools(tool)
133 return acc
134
135
136def gFexByteStreamToolCfg(flags, name, *, writeBS=False, multiSlice=False, TOBs=True):
137 acc = ComponentAccumulator()
138 tool = CompFactory.gFexByteStreamTool(name)
139 gfex_roi_moduleids = [0x3000]
140 tool.ROBIDs = [int(SourceIdentifier(SubDetector.TDAQ_CALO_FEAT_EXTRACT_ROI, moduleid)) for moduleid in gfex_roi_moduleids]
141 if writeBS:
142 # write BS == read xAOD; encoder consumes RoIs from the TrigCompositeContainer
143 # pushed in by L1TriggerResultByteStreamCnv, so no per-container ReadHandleKeys
144 # are needed and the WriteHandleKeys are forced empty.
145 tool.gFexRhoOutputContainerWriteKey =""
146 tool.gFexSRJetOutputContainerWriteKey =""
147 tool.gFexLRJetOutputContainerWriteKey =""
148 tool.gScalarEJwojOutputContainerWriteKey =""
149 tool.gEspressoOutputContainerWriteKey =""
150 tool.gRistrettoOutputContainerWriteKey =""
151 tool.gMETComponentsJwojOutputContainerWriteKey =""
152 tool.gMHTComponentsJwojOutputContainerWriteKey =""
153 tool.gMSTComponentsJwojOutputContainerWriteKey =""
154 tool.gMETComponentsNoiseCutOutputContainerWriteKey =""
155 tool.gMETComponentsRmsOutputContainerWriteKey =""
156 tool.gScalarENoiseCutOutputContainerWriteKey =""
157 tool.gScalarERmsOutputContainerWriteKey =""
158 else:
159 # read BS == write xAOD
160 # When TOBs=False, standard L1A containers are disabled (empty write keys).
161 # They are already provided by the HLT result deserialiser.
162 # Only gEspresso, gRistretto and multi-slice (OutOfTime) containers are decoded.
163 tool.gFexRhoOutputContainerWriteKey ="L1_gFexRhoRoI" if TOBs else ""
164 tool.gFexSRJetOutputContainerWriteKey ="L1_gFexSRJetRoI" if TOBs else ""
165 tool.gFexLRJetOutputContainerWriteKey ="L1_gFexLRJetRoI" if TOBs else ""
166 tool.gScalarEJwojOutputContainerWriteKey ="L1_gScalarEJwoj" if TOBs else ""
167 tool.gEspressoOutputContainerWriteKey ="L1_gEspresso"
168 tool.gRistrettoOutputContainerWriteKey ="L1_gRistretto"
169 tool.gMETComponentsJwojOutputContainerWriteKey ="L1_gMETComponentsJwoj" if TOBs else ""
170 tool.gMHTComponentsJwojOutputContainerWriteKey ="L1_gMHTComponentsJwoj" if TOBs else ""
171 tool.gMSTComponentsJwojOutputContainerWriteKey ="L1_gMSTComponentsJwoj" if TOBs else ""
172 tool.gMETComponentsNoiseCutOutputContainerWriteKey ="L1_gMETComponentsNoiseCut" if TOBs else ""
173 tool.gMETComponentsRmsOutputContainerWriteKey ="L1_gMETComponentsRms" if TOBs else ""
174 tool.gScalarENoiseCutOutputContainerWriteKey ="L1_gScalarENoiseCut" if TOBs else ""
175 tool.gScalarERmsOutputContainerWriteKey ="L1_gScalarERms" if TOBs else ""
176
177 # Multi-slice containers (out-of-time TOBs from slices 1,2)
178 if multiSlice:
179 # Jet TOBs
180 tool.gFexRhoSliceContainerWriteKey ="L1_gFexRhoRoIOutOfTime"
181 tool.gFexSRJetSliceContainerWriteKey ="L1_gFexSRJetRoIOutOfTime"
182 tool.gFexLRJetSliceContainerWriteKey ="L1_gFexLRJetRoIOutOfTime"
183 # Global TOBs - JwoJ
184 tool.gScalarEJwojSliceContainerWriteKey ="L1_gScalarEJwojOutOfTime"
185 tool.gMETComponentsJwojSliceContainerWriteKey ="L1_gMETComponentsJwojOutOfTime"
186 tool.gMHTComponentsJwojSliceContainerWriteKey ="L1_gMHTComponentsJwojOutOfTime"
187 tool.gMSTComponentsJwojSliceContainerWriteKey ="L1_gMSTComponentsJwojOutOfTime"
188 # Global TOBs - gEspresso
189 tool.gEspressoSliceContainerWriteKey ="L1_gEspressoOutOfTime"
190 # Global TOBs - gRistretto
191 tool.gRistrettoSliceContainerWriteKey ="L1_gRistrettoOutOfTime"
192 # Global TOBs - NoiseCut
193 tool.gMETComponentsNoiseCutSliceContainerWriteKey="L1_gMETComponentsNoiseCutOutOfTime"
194 tool.gScalarENoiseCutSliceContainerWriteKey ="L1_gScalarENoiseCutOutOfTime"
195 # Global TOBs - Rms
196 tool.gMETComponentsRmsSliceContainerWriteKey ="L1_gMETComponentsRmsOutOfTime"
197 tool.gScalarERmsSliceContainerWriteKey ="L1_gScalarERmsOutOfTime"
198 # Note: Slice number decoration keys are automatically derived from the
199 # parent WriteHandleKeys above with decoration name "sliceNumber"
200
201
202 if flags.Output.HISTFileName != '' or flags.Trigger.doHLT:
203 if flags.Trigger.doHLT:
204 from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
205 monTool = GenericMonitoringTool(flags,'MonTool',HistPath = f'HLTFramework/L1BSConverters/{name}')
206 topDir = "EXPERT"
207 else:
208 # if used in offline reconstruction respect DQ convention (ATR-26371)
209 from AthenaMonitoring import AthMonitorCfgHelper
210 helper = AthMonitorCfgHelper(flags, 'HLTFramework')
211 monTool = helper.addGroup(None, f'{name}MonTool', f'/HLT/HLTFramework/L1BSConverters/{name}')
212 topDir = None
213 acc.merge(helper.result())
214
215 monTool.defineHistogram('gfexDecoderErrorTitle,gfexDecoderErrorLocation;errors', path=topDir, type='TH2I',
216 title='gFEX TOB Decoder Errors;Type;Location',
217 xlabels=["UNKNOWN"],
218 ylabels=["UNKNOWN"],
219 opt=['kCanRebin'],merge="merge")
220 tool.MonTool = monTool
221
222
223 acc.setPrivateTools(tool)
224 return acc
225
226
227def jFexInputByteStreamToolCfg(flags, name, *, writeBS=False):
228 acc = ComponentAccumulator()
229 tool = CompFactory.jFexInputByteStreamTool(name)
230 jfex_roi_moduleids = [0x2000,0x2010,0x2020,0x2030,0x2040,0x2050]
231 tool.ROBIDs = [int(SourceIdentifier(SubDetector.TDAQ_CALO_FEAT_EXTRACT_DAQ, moduleid)) for moduleid in jfex_roi_moduleids]
232
233 #will be needed in the future for jTower container, still not coded
234 if writeBS:
235 # write BS == read xAOD
236 tool.jTowersReadKey = "L1_jFexDataTowers"
237
238 tool.jTowersWriteKey =""
239 else:
240 # read BS == write xAOD
241 tool.jTowersReadKey =""
242
243 tool.jTowersWriteKey = "L1_jFexDataTowers"
244
245 if flags.Output.HISTFileName != '' or flags.Trigger.doHLT:
246 if flags.Trigger.doHLT:
247 from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
248 monTool = GenericMonitoringTool(flags,'MonTool',HistPath = f'HLTFramework/L1BSConverters/{name}')
249 topDir = "EXPERT"
250 else:
251 # if used in offline reconstruction respect DQ convention (ATR-26371)
252 from AthenaMonitoring import AthMonitorCfgHelper
253 helper = AthMonitorCfgHelper(flags, 'HLTFramework')
254 monTool = helper.addGroup(None, f'{name}MonTool', f'/HLT/HLTFramework/L1BSConverters/{name}')
255 topDir = None
256 acc.merge(helper.result())
257
258 monTool.defineHistogram('jfexDecoderErrorTitle,jfexDecoderErrorLocation;errors', path=topDir, type='TH2I',
259 title='jFEX InputData Decoder Errors;Type;Location',
260 xlabels=["UNKNOWN"],
261 ylabels=["UNKNOWN"],
262 opt=['kCanRebin'],merge="merge")
263 tool.MonTool = monTool
264
265
266 acc.setPrivateTools(tool)
267 return acc
268
269
270def gFexInputByteStreamToolCfg(flags, name, *, writeBS=False):
271 acc = ComponentAccumulator()
272 tool = CompFactory.gFexInputByteStreamTool(name)
273 gfex_roi_moduleids = [0x3000]
274 tool.ROBIDs = [int(SourceIdentifier(SubDetector.TDAQ_CALO_FEAT_EXTRACT_DAQ, moduleid)) for moduleid in gfex_roi_moduleids]
275
276 if writeBS:
277 # write BS == read xAOD
278 tool.gTowersReadKey = "L1_gFexDataTowers"
279
280 tool.gTowersWriteKey =""
281 else:
282 # read BS == write xAOD
283 tool.gTowersReadKey =""
284
285 tool.gTowersWriteKey = "L1_gFexDataTowers"
286
287 if flags.Output.HISTFileName != '' or flags.Trigger.doHLT:
288 if flags.Trigger.doHLT:
289 from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
290 monTool = GenericMonitoringTool(flags,'MonTool',HistPath = f'HLTFramework/L1BSConverters/{name}')
291 topDir = "EXPERT"
292 else:
293 # if used in offline reconstruction respect DQ convention (ATR-26371)
294 from AthenaMonitoring import AthMonitorCfgHelper
295 helper = AthMonitorCfgHelper(flags, 'HLTFramework')
296 monTool = helper.addGroup(None, f'{name}MonTool', f'/HLT/HLTFramework/L1BSConverters/{name}')
297 topDir = None
298 acc.merge(helper.result())
299
300 monTool.defineHistogram('gfexDecoderErrorTitle,gfexDecoderErrorLocation;errors', path=topDir, type='TH2I',
301 title='gFEX InputData Decoder Errors;Type;Location',
302 xlabels=["UNKNOWN"],
303 ylabels=["UNKNOWN"],
304 opt=['kCanRebin'],merge="merge")
305 tool.MonTool = monTool
306
307 acc.setPrivateTools(tool)
308 return acc
gFexByteStreamToolCfg(flags, name, *, writeBS=False, multiSlice=False, TOBs=True)
eFexByteStreamToolCfg(flags, name, *, writeBS=False, TOBs=True, xTOBs=False, multiSlice=False, decodeInputs=False)
jFexRoiByteStreamToolCfg(flags, name, *, writeBS=False, xTOBs=False)
jFexInputByteStreamToolCfg(flags, name, *, writeBS=False)
gFexInputByteStreamToolCfg(flags, name, *, writeBS=False)