209 def checkCountCTPInputsOutput(self):
210 from collections
import namedtuple
211 ctpInput = namedtuple(
'ctpInput',
"name, conn, nbit")
216 ctpInputBitSets = dict()
217 ctpInputNameSets = dict()
218 ctpUnusedInputBitSets = dict()
219 ctpUnusedInputNameSets = dict()
220 for item
in self.items:
221 ctpOutputs.append(item.name)
222 for thrName
in item.thresholdNames():
223 if thrName[:3]==
'ZB_':
224 thrName = thrName[3:]
225 if thrName
not in thrNames:
226 thrNames.append(thrName)
227 thrNames_notFound = []
228 for thrName
in thrNames:
229 thrName_found =
False
230 for conn
in self.connectors:
231 if conn.ctype != CType.ELEC:
232 for tl
in conn.triggerLines:
233 if thrName == tl.name:
234 ctpInputs.append(ctpInput(name=thrName,conn=conn.name,nbit=tl.nbits))
237 for fpga
in conn.triggerLines:
238 for clock
in conn.triggerLines[fpga]:
239 for tl
in conn.triggerLines[fpga][clock]:
240 if thrName == tl.name:
241 ctpInputs.append(ctpInput(name=thrName,conn=conn.name,nbit=tl.nbits))
243 if not thrName_found:
244 thrNames_notFound.append(thrName)
246 for conn
in self.connectors:
247 if conn.ctype != CType.ELEC:
248 for tl
in conn.triggerLines:
250 if thrName[:3]==
'ZB_':
251 thrName = thrName[3:]
253 for ctpIn
in ctpInputs:
254 if thrName == ctpIn.name:
257 ctpUnusedInputs.append(ctpInput(name=thrName,conn=conn.name,nbit=tl.nbits))
259 for fpga
in conn.triggerLines:
260 for clock
in conn.triggerLines[fpga]:
261 for tl
in conn.triggerLines[fpga][clock]:
263 if thrName[:3]==
'ZB_':
264 thrName = thrName[3:]
266 for ctpIn
in ctpInputs:
267 if thrName == ctpIn.name:
270 ctpUnusedInputs.append(ctpInput(name=thrName,conn=conn.name,nbit=tl.nbits))
272 if len(thrNames_notFound)>0:
273 log.error(
"Thresholds [%s] are not found",
",".
join(thrNames_notFound))
274 log.error(
"Input thresholds are [%s]",
",".
join([ input.name
for input
in ctpInputs]))
275 raise RuntimeError(
"Not all input thresholds found!")
277 for ctpIn
in ctpInputs:
280 if thrName[:2]
in [
'EM',
'HA',
'XE',
'TE',
'XS']:
281 thrset =
'legacyCalo'
282 elif thrName[:1]==
'J':
283 thrset =
'legacyCalo'
284 elif thrName[:2]==
'MU':
286 elif thrName[:3]
in [
'MBT',
'AFP',
'BCM',
'CAL',
'NIM',
'ZDC',
'BPT',
'LUC',
'BMA']:
288 elif thrName[:6]==
'R2TOPO':
289 thrset =
'legacyTopo'
290 elif thrName[:1]
in [
'e',
'j',
'c',
'g']:
292 elif thrName[:4]==
'TOPO':
293 if 'Topo2' in ctpIn.conn:
295 elif 'Topo3' in ctpIn.conn:
298 if thrset
not in ctpInputBitSets:
299 ctpInputBitSets[thrset] = 0
300 ctpInputNameSets[thrset] = []
301 if thrName
not in ctpInputNameSets[thrset]:
302 ctpInputNameSets[thrset].
append(thrName)
303 ctpInputBitSets[thrset] += ctpIn.nbit
305 for ctpIn
in ctpUnusedInputs:
308 if thrName[:2]
in [
'EM',
'HA',
'XE',
'TE',
'XS']:
309 thrset =
'legacyCalo'
310 elif thrName[:1]==
'J':
311 thrset =
'legacyCalo'
312 elif thrName[:2]==
'MU':
314 elif thrName[:3]
in [
'MBT',
'AFP',
'BCM',
'CAL',
'NIM',
'ZDC',
'BPT',
'LUC']:
316 elif thrName[:6]==
'R2TOPO':
317 thrset =
'legacyTopo'
318 elif thrName[:1]
in [
'e',
'j',
'c',
'g']:
320 elif thrName[:4]==
'TOPO':
321 if 'Topo2' in ctpIn.conn:
323 elif 'Topo3' in ctpIn.conn:
326 if thrset
not in ctpUnusedInputBitSets:
327 ctpUnusedInputBitSets[thrset] = 0
328 ctpUnusedInputNameSets[thrset] = []
329 if thrName
not in ctpUnusedInputNameSets[thrset]:
330 ctpUnusedInputNameSets[thrset].
append(thrName)
331 ctpUnusedInputBitSets[thrset] += ctpIn.nbit
334 log.info(
"Check total number of CTP input and output bits:")
335 log.info(
"Number of output bits: %i", len(ctpOutputs) )
336 for thrset
in ctpInputBitSets:
337 log.info(
"Used inputs in %s: %i thresholds and %i bits", thrset, len(ctpInputNameSets[thrset]), ctpInputBitSets[thrset] )
338 if thrset
is not None:
339 log.debug(
"Threshold set %s: %s", thrset,
",".
join(ctpInputNameSets[thrset]) )
341 log.info(
"Unrecognised CTP input bits: %s",
",".
join(ctpInputNameSets[thrset]) )
342 totalInputs += ctpInputBitSets[thrset]
343 log.info(
"Number of used inputs bits: %i" , totalInputs )
344 totalUnusedInputs = 0
345 for thrset
in ctpUnusedInputBitSets:
346 log.debug(
"Unused thresholds in %s: %i thresholds and %i bits", thrset, len(ctpUnusedInputNameSets[thrset]), ctpUnusedInputBitSets[thrset] )
347 if thrset
is not None:
348 log.debug(
"Unused threshold set %s: %s", thrset,
",".
join(ctpUnusedInputNameSets[thrset]) )
350 log.debug(
"Unrecognised CTP input bits: %s",
",".
join(ctpUnusedInputNameSets[thrset]) )
351 totalUnusedInputs += ctpUnusedInputBitSets[thrset]
352 log.debug(
"Number of un-used inputs bits: %i" , totalUnusedInputs )
355 if ( totalInputs > Limits.MaxTrigItems
or len(ctpOutputs) > Limits.MaxTrigItems):
356 if 'AllCTPIn' in self.menuName:
357 log.warning(f
"Input or output bits limit of {Limits.MaxTrigItems} exceeded in the dummy CTP menu -- OK")
359 raise RuntimeError(
"Both the numbers of inputs and outputs need to be not greater than %i in a physics menu!" % Limits.MaxTrigItems)