ATLAS Offline Software
L1CaloFEXByteStreamConfig.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 #
4 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
5 from AthenaConfiguration.ComponentFactory import CompFactory
6 from libpyeformat_helper import SourceIdentifier, SubDetector
7 
8 def 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  # Note: this is currently unsupported!!!
16  tool.eEMContainerReadKey = "L1_eEMxRoI" if xTOBs else "L1_eEMRoI"
17  tool.eTAUContainerReadKey = "L1_eTauxRoI" if xTOBs else "L1_eTauRoI"
18  tool.eEMContainerWriteKey = ""
19  tool.eTAUContainerWriteKey = ""
20  else:
21  # read BS == write xAOD
22  tool.eEMContainerReadKey = ""
23  tool.eTAUContainerReadKey = ""
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 
87 def 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  tool.jJRoIContainerReadKey = "L1_jFexSRJetxRoI" if xTOBs else "L1_jFexSRJetRoI"
96  tool.jLJRoIContainerReadKey = "L1_jFexLRJetxRoI" if xTOBs else "L1_jFexLRJetRoI"
97  tool.jTauRoIContainerReadKey = "L1_jFexTauxRoI" if xTOBs else "L1_jFexTauRoI"
98  tool.jEMRoIContainerReadKey = "L1_jFexFwdElxRoI" if xTOBs else "L1_jFexFwdElRoI"
99  tool.jTERoIContainerReadKey = "L1_jFexSumETxRoI" if xTOBs else "L1_jFexSumETRoI"
100  tool.jXERoIContainerReadKey = "L1_jFexMETxRoI" if xTOBs else "L1_jFexMETRoI"
101 
102  tool.jJRoIContainerWriteKey =""
103  tool.jLJRoIContainerWriteKey =""
104  tool.jTauRoIContainerWriteKey=""
105  tool.jEMRoIContainerWriteKey =""
106  tool.jTERoIContainerWriteKey =""
107  tool.jXERoIContainerWriteKey =""
108  else:
109  # read BS == write xAOD
110  tool.jJRoIContainerReadKey =""
111  tool.jLJRoIContainerReadKey =""
112  tool.jTauRoIContainerReadKey =""
113  tool.jEMRoIContainerReadKey =""
114  tool.jTERoIContainerReadKey =""
115  tool.jXERoIContainerReadKey =""
116 
117  tool.jJRoIContainerWriteKey = "L1_jFexSRJetxRoI" if xTOBs else "L1_jFexSRJetRoI"
118  tool.jLJRoIContainerWriteKey = "L1_jFexLRJetxRoI" if xTOBs else "L1_jFexLRJetRoI"
119  tool.jTauRoIContainerWriteKey= "L1_jFexTauxRoI" if xTOBs else "L1_jFexTauRoI"
120  tool.jEMRoIContainerWriteKey = "L1_jFexFwdElxRoI" if xTOBs else "L1_jFexFwdElRoI"
121  tool.jTERoIContainerWriteKey = "L1_jFexSumETxRoI" if xTOBs else "L1_jFexSumETRoI"
122  tool.jXERoIContainerWriteKey = "L1_jFexMETxRoI" if xTOBs else "L1_jFexMETRoI"
123 
124  if flags.Output.HISTFileName != '' or flags.Trigger.doHLT:
125  if flags.Trigger.doHLT:
126  from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
127  monTool = GenericMonitoringTool(flags,'MonTool',HistPath = f'HLTFramework/L1BSConverters/{name}')
128  topDir = "EXPERT"
129  else:
130  # if used in offline reconstruction respect DQ convention (ATR-26371)
131  from AthenaMonitoring import AthMonitorCfgHelper
132  helper = AthMonitorCfgHelper(flags, 'HLTFramework')
133  monTool = helper.addGroup(None, f'{name}MonTool', f'/HLT/HLTFramework/L1BSConverters/{name}')
134  topDir = None
135  acc.merge(helper.result())
136 
137  monTool.defineHistogram('jfexDecoderErrorTitle,jfexDecoderErrorLocation;errors', path=topDir, type='TH2I',
138  title='jFEX TOB Decoder Errors;Type;Location',
139  xlabels=["UNKNOWN"],
140  ylabels=["UNKNOWN"],
141  opt=['kCanRebin'],merge="merge")
142  tool.MonTool = monTool
143 
144  acc.setPrivateTools(tool)
145  return acc
146 
147 
148 def gFexByteStreamToolCfg(flags, name, *, writeBS=False):
149  acc = ComponentAccumulator()
150  tool = CompFactory.gFexByteStreamTool(name)
151  gfex_roi_moduleids = [0x3000]
152  tool.ROBIDs = [int(SourceIdentifier(SubDetector.TDAQ_CALO_FEAT_EXTRACT_ROI, moduleid)) for moduleid in gfex_roi_moduleids]
153  if writeBS:
154  # write BS == read xAOD
155  tool.gFexRhoOutputContainerReadKey ="L1_gFexRhoRoI"
156  tool.gFexSRJetOutputContainerReadKey ="L1_gFexSRJetRoI"
157  tool.gFexLRJetOutputContainerReadKey ="L1_gFexLRJetRoI"
158  tool.gScalarEJwojOutputContainerReadKey ="L1_gScalarEJwoj"
159  tool.gMETComponentsJwojOutputContainerReadKey ="L1_gMETComponentsJwoj"
160  tool.gMHTComponentsJwojOutputContainerReadKey ="L1_gMHTComponentsJwoj"
161  tool.gMSTComponentsJwojOutputContainerReadKey ="L1_gMSTComponentsJwoj"
162  tool.gMETComponentsNoiseCutOutputContainerReadKey ="L1_gMETComponentsNoiseCut"
163  tool.gMETComponentsRmsOutputContainerReadKey ="L1_gMETComponentsRms"
164  tool.gScalarENoiseCutOutputContainerReadKey ="L1_gScalarENoiseCut"
165  tool.gScalarERmsOutputContainerReadKey ="L1_gScalarERms"
166 
167 
168  tool.gFexRhoOutputContainerWriteKey =""
169  tool.gFexSRJetOutputContainerWriteKey =""
170  tool.gFexLRJetOutputContainerWriteKey =""
171  tool.gScalarEJwojOutputContainerWriteKey =""
172  tool.gMETComponentsJwojOutputContainerWriteKey =""
173  tool.gMHTComponentsJwojOutputContainerWriteKey =""
174  tool.gMSTComponentsJwojOutputContainerWriteKey =""
175  tool.gMETComponentsNoiseCutOutputContainerWriteKey =""
176  tool.gMETComponentsRmsOutputContainerWriteKey =""
177  tool.gScalarENoiseCutOutputContainerWriteKey =""
178  tool.gScalarERmsOutputContainerWriteKey =""
179  else:
180  # read BS == write xAOD
181  tool.gFexRhoOutputContainerReadKey =""
182  tool.gFexSRJetOutputContainerReadKey =""
183  tool.gFexLRJetOutputContainerReadKey =""
184  tool.gScalarEJwojOutputContainerReadKey =""
185  tool.gMETComponentsJwojOutputContainerReadKey =""
186  tool.gMHTComponentsJwojOutputContainerReadKey =""
187  tool.gMSTComponentsJwojOutputContainerReadKey =""
188  tool.gMETComponentsNoiseCutOutputContainerReadKey =""
189  tool.gMETComponentsRmsOutputContainerReadKey =""
190  tool.gScalarENoiseCutOutputContainerReadKey =""
191  tool.gScalarERmsOutputContainerReadKey =""
192 
193 
194  tool.gFexRhoOutputContainerWriteKey ="L1_gFexRhoRoI"
195  tool.gFexSRJetOutputContainerWriteKey ="L1_gFexSRJetRoI"
196  tool.gFexLRJetOutputContainerWriteKey ="L1_gFexLRJetRoI"
197  tool.gScalarEJwojOutputContainerWriteKey ="L1_gScalarEJwoj"
198  tool.gMETComponentsJwojOutputContainerWriteKey ="L1_gMETComponentsJwoj"
199  tool.gMHTComponentsJwojOutputContainerWriteKey ="L1_gMHTComponentsJwoj"
200  tool.gMSTComponentsJwojOutputContainerWriteKey ="L1_gMSTComponentsJwoj"
201  tool.gMETComponentsNoiseCutOutputContainerWriteKey ="L1_gMETComponentsNoiseCut"
202  tool.gMETComponentsRmsOutputContainerWriteKey ="L1_gMETComponentsRms"
203  tool.gScalarENoiseCutOutputContainerWriteKey ="L1_gScalarENoiseCut"
204  tool.gScalarERmsOutputContainerWriteKey ="L1_gScalarERms"
205 
206 
207  if flags.Output.HISTFileName != '' or flags.Trigger.doHLT:
208  if flags.Trigger.doHLT:
209  from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
210  monTool = GenericMonitoringTool(flags,'MonTool',HistPath = f'HLTFramework/L1BSConverters/{name}')
211  topDir = "EXPERT"
212  else:
213  # if used in offline reconstruction respect DQ convention (ATR-26371)
214  from AthenaMonitoring import AthMonitorCfgHelper
215  helper = AthMonitorCfgHelper(flags, 'HLTFramework')
216  monTool = helper.addGroup(None, f'{name}MonTool', f'/HLT/HLTFramework/L1BSConverters/{name}')
217  topDir = None
218  acc.merge(helper.result())
219 
220  monTool.defineHistogram('gfexDecoderErrorTitle,gfexDecoderErrorLocation;errors', path=topDir, type='TH2I',
221  title='gFEX TOB Decoder Errors;Type;Location',
222  xlabels=["UNKNOWN"],
223  ylabels=["UNKNOWN"],
224  opt=['kCanRebin'],merge="merge")
225  tool.MonTool = monTool
226 
227 
228  acc.setPrivateTools(tool)
229  return acc
230 
231 
232 def jFexInputByteStreamToolCfg(flags, name, *, writeBS=False):
233  acc = ComponentAccumulator()
234  tool = CompFactory.jFexInputByteStreamTool(name)
235  jfex_roi_moduleids = [0x2000,0x2010,0x2020,0x2030,0x2040,0x2050]
236  tool.ROBIDs = [int(SourceIdentifier(SubDetector.TDAQ_CALO_FEAT_EXTRACT_DAQ, moduleid)) for moduleid in jfex_roi_moduleids]
237 
238  #will be needed in the future for jTower container, still not coded
239  if writeBS:
240  # write BS == read xAOD
241  tool.jTowersReadKey = "L1_jFexDataTowers"
242 
243  tool.jTowersWriteKey =""
244  else:
245  # read BS == write xAOD
246  tool.jTowersReadKey =""
247 
248  tool.jTowersWriteKey = "L1_jFexDataTowers"
249 
250  if flags.Output.HISTFileName != '' or flags.Trigger.doHLT:
251  if flags.Trigger.doHLT:
252  from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
253  monTool = GenericMonitoringTool(flags,'MonTool',HistPath = f'HLTFramework/L1BSConverters/{name}')
254  topDir = "EXPERT"
255  else:
256  # if used in offline reconstruction respect DQ convention (ATR-26371)
257  from AthenaMonitoring import AthMonitorCfgHelper
258  helper = AthMonitorCfgHelper(flags, 'HLTFramework')
259  monTool = helper.addGroup(None, f'{name}MonTool', f'/HLT/HLTFramework/L1BSConverters/{name}')
260  topDir = None
261  acc.merge(helper.result())
262 
263  monTool.defineHistogram('jfexDecoderErrorTitle,jfexDecoderErrorLocation;errors', path=topDir, type='TH2I',
264  title='jFEX InputData Decoder Errors;Type;Location',
265  xlabels=["UNKNOWN"],
266  ylabels=["UNKNOWN"],
267  opt=['kCanRebin'],merge="merge")
268  tool.MonTool = monTool
269 
270 
271  acc.setPrivateTools(tool)
272  return acc
273 
274 
275 def gFexInputByteStreamToolCfg(flags, name, *, writeBS=False):
276  acc = ComponentAccumulator()
277  tool = CompFactory.gFexInputByteStreamTool(name)
278  gfex_roi_moduleids = [0x3000]
279  tool.ROBIDs = [int(SourceIdentifier(SubDetector.TDAQ_CALO_FEAT_EXTRACT_DAQ, moduleid)) for moduleid in gfex_roi_moduleids]
280 
281  if writeBS:
282  # write BS == read xAOD
283  tool.gTowersReadKey = "L1_gFexDataTowers"
284 
285  tool.gTowersWriteKey =""
286  else:
287  # read BS == write xAOD
288  tool.gTowersReadKey =""
289 
290  tool.gTowersWriteKey = "L1_gFexDataTowers"
291 
292  if flags.Output.HISTFileName != '' or flags.Trigger.doHLT:
293  if flags.Trigger.doHLT:
294  from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
295  monTool = GenericMonitoringTool(flags,'MonTool',HistPath = f'HLTFramework/L1BSConverters/{name}')
296  topDir = "EXPERT"
297  else:
298  # if used in offline reconstruction respect DQ convention (ATR-26371)
299  from AthenaMonitoring import AthMonitorCfgHelper
300  helper = AthMonitorCfgHelper(flags, 'HLTFramework')
301  monTool = helper.addGroup(None, f'{name}MonTool', f'/HLT/HLTFramework/L1BSConverters/{name}')
302  topDir = None
303  acc.merge(helper.result())
304 
305  monTool.defineHistogram('gfexDecoderErrorTitle,gfexDecoderErrorLocation;errors', path=topDir, type='TH2I',
306  title='gFEX InputData Decoder Errors;Type;Location',
307  xlabels=["UNKNOWN"],
308  ylabels=["UNKNOWN"],
309  opt=['kCanRebin'],merge="merge")
310  tool.MonTool = monTool
311 
312  acc.setPrivateTools(tool)
313  return acc
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
GenericMonitoringTool
Definition: GenericMonitoringTool.h:53
L1CaloFEXByteStreamConfig.jFexInputByteStreamToolCfg
def jFexInputByteStreamToolCfg(flags, name, *writeBS=False)
Definition: L1CaloFEXByteStreamConfig.py:232
L1CaloFEXByteStreamConfig.gFexByteStreamToolCfg
def gFexByteStreamToolCfg(flags, name, *writeBS=False)
Definition: L1CaloFEXByteStreamConfig.py:148
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
L1CaloFEXByteStreamConfig.gFexInputByteStreamToolCfg
def gFexInputByteStreamToolCfg(flags, name, *writeBS=False)
Definition: L1CaloFEXByteStreamConfig.py:275
L1CaloFEXByteStreamConfig.jFexRoiByteStreamToolCfg
def jFexRoiByteStreamToolCfg(flags, name, *writeBS=False, xTOBs=False)
Definition: L1CaloFEXByteStreamConfig.py:87
L1CaloFEXByteStreamConfig.eFexByteStreamToolCfg
def eFexByteStreamToolCfg(flags, name, *writeBS=False, TOBs=True, xTOBs=False, multiSlice=False, decodeInputs=False)
Definition: L1CaloFEXByteStreamConfig.py:8