183 if 'MuCTPi' in connDefName
or 'Legacy' in connDefName:
186 boardName = connDefName + fpgaName
189 allowedInputs[
'Topo1Opt0'] = [
'MU',
'eEM',
'eTAU',
'gJ',
'gLJ',
'ZeroBiasA']
190 allowedInputs[
'Topo1Opt1'] = [
'MU',
'eEM',
'eTAU',
'gJ',
'gLJ', ]
191 allowedInputs[
'Topo1Opt2'] = [
'MU',
'eTAU',
'cTAU',
'j',
'cXE',
'gXE',
'gTE',
'gMHT',
'gESPRESSO',
'LArSaturation',
'ZeroBiasB']
192 allowedInputs[
'Topo1Opt3'] = [
'MU',
'eTAU',
'cTAU',
'j',
'cXE',
'gXE',
'gTE',
'gMHT',
'gESPRESSO',
'gRISTRETTO',
'LArSaturation',
'ZeroBiasB']
193 allowedInputs[
'Topo2El0'] = [
'MU',
'eTAU',
'j', ]
194 allowedInputs[
'Topo2El1'] = [
'eEM',
'j', ]
195 allowedInputs[
'Topo3El0'] = [
'eEM',
'eTAU',
'j', ]
196 allowedInputs[
'Topo3El1'] = [
'MU',
'eEM',
'eTAU',
'g', ]
198 if boardName
not in allowedInputs.keys():
199 raise RuntimeError(
"Connector name %s not found" % boardName)
201 if 'Mult_' in algo.name:
202 if not (any(x
in algo.threshold
for x
in allowedInputs[boardName])):
203 raise RuntimeError(
"Algorithm %s in board %s with threshold %s not allowed" % (algo.name, boardName, algo.threshold))
205 if 'Mult_' not in algo.name:
206 for algoInput
in algo.inputs:
207 if not (any(x
in algoInput
for x
in allowedInputs[boardName])):
208 raise RuntimeError(
"Algorithm %s in board %s with input %s not allowed" % (algo.name, boardName, algoInput))
211 fullName = boardName + connName
214 allowedInputs[
'Ctpin7EM1'] = 8 * [
'EM']
215 allowedInputs[
'Ctpin7EM2'] = 8 * [
'EM']
216 allowedInputs[
'Ctpin7TAU1'] = 8 * [
'HA']
217 allowedInputs[
'Ctpin7TAU2'] = 8 * [
'HA']
219 allowedInputs[
'Ctpin8JET1'] = 10 * [
'J']
220 allowedInputs[
'Ctpin8JET2'] = 15 * [
'J']
221 allowedInputs[
'Ctpin8EN1'] = 8 * [
'TE'] + 8 * [
'XE'] + 8 * [
'XS']
222 allowedInputs[
'Ctpin8EN2'] = 8 * [
'TE'] + 8 * [
'XE']
224 invalidThresholds =
False
225 for ithr, thr
in enumerate(thresholds):
227 allowedThr = allowedInputs[fullName][ithr]
228 if thr[:len(allowedThr)] != allowedThr:
229 log.error(f
"Threshold {thr} does not match expected type {allowedThr} at position {ithr} in connector {fullName}")
230 invalidThresholds =
True
232 log.error(f
"Too many thresholds ({len(thresholds)}) provided for connector {fullName}, which only supports {len(allowedInputs[fullName])} thresholds")
233 invalidThresholds =
True
234 if invalidThresholds:
235 raise RuntimeError(
"Incorrect specification of legacy L1Calo thresholds")
259 from collections
import namedtuple
260 ctpInput = namedtuple(
'ctpInput',
"name, conn, nbit")
265 ctpInputBitSets = dict()
266 ctpInputNameSets = dict()
267 ctpUnusedInputBitSets = dict()
268 ctpUnusedInputNameSets = dict()
269 for item
in self.
items:
270 ctpOutputs.append(item.name)
271 for thrName
in item.thresholdNames():
272 if thrName[:3] ==
'ZB_':
273 thrName = thrName[3:]
274 if thrName
not in thrNames:
275 thrNames.append(thrName)
276 thrNames_notFound = []
277 for thrName
in thrNames:
278 thrName_found =
False
280 if conn.ctype != CType.ELEC:
281 for tl
in conn.triggerLines:
282 if thrName == tl.name:
283 ctpInputs.append(ctpInput(name=thrName, conn=conn.name, nbit=tl.nbits))
286 for fpga
in conn.triggerLines:
287 for clock
in conn.triggerLines[fpga]:
288 for tl
in conn.triggerLines[fpga][clock]:
289 if thrName == tl.name:
290 ctpInputs.append(ctpInput(name=thrName, conn=conn.name, nbit=tl.nbits))
292 if not thrName_found:
293 thrNames_notFound.append(thrName)
296 if conn.ctype != CType.ELEC:
297 for tl
in conn.triggerLines:
299 if thrName[:3] ==
'ZB_':
300 thrName = thrName[3:]
302 for ctpIn
in ctpInputs:
303 if thrName == ctpIn.name:
306 ctpUnusedInputs.append(ctpInput(name=thrName, conn=conn.name, nbit=tl.nbits))
308 for fpga
in conn.triggerLines:
309 for clock
in conn.triggerLines[fpga]:
310 for tl
in conn.triggerLines[fpga][clock]:
312 if thrName[:3] ==
'ZB_':
313 thrName = thrName[3:]
315 for ctpIn
in ctpInputs:
316 if thrName == ctpIn.name:
319 ctpUnusedInputs.append(ctpInput(name=thrName, conn=conn.name, nbit=tl.nbits))
321 if len(thrNames_notFound) > 0:
322 log.error(
"Thresholds [%s] are not found",
",".join(thrNames_notFound))
323 log.error(
"Input thresholds are [%s]",
",".join([input.name
for input
in ctpInputs]))
324 raise RuntimeError(
"Not all input thresholds found!")
326 for ctpIn
in ctpInputs:
329 if thrName[:2]
in [
'EM',
'HA',
'XE',
'TE',
'XS']:
330 thrset =
'legacyCalo'
331 elif thrName[:1] ==
'J':
332 thrset =
'legacyCalo'
333 elif thrName[:2] ==
'MU':
335 elif thrName[:3]
in [
'MBT',
'AFP',
'BCM',
'CAL',
'NIM',
'ZDC',
'BPT',
'LUC',
'BMA']:
337 elif thrName[:6] ==
'R2TOPO':
338 thrset =
'legacyTopo'
339 elif thrName[:1]
in [
'e',
'j',
'c',
'g']:
341 elif thrName[:4] ==
'TOPO':
342 if 'Topo2' in ctpIn.conn:
344 elif 'Topo3' in ctpIn.conn:
347 if thrset
not in ctpInputBitSets:
348 ctpInputBitSets[thrset] = 0
349 ctpInputNameSets[thrset] = []
350 if thrName
not in ctpInputNameSets[thrset]:
351 ctpInputNameSets[thrset].append(thrName)
352 ctpInputBitSets[thrset] += ctpIn.nbit
354 for ctpIn
in ctpUnusedInputs:
357 if thrName[:2]
in [
'EM',
'HA',
'XE',
'TE',
'XS']:
358 thrset =
'legacyCalo'
359 elif thrName[:1] ==
'J':
360 thrset =
'legacyCalo'
361 elif thrName[:2] ==
'MU':
363 elif thrName[:3]
in [
'MBT',
'AFP',
'BCM',
'CAL',
'NIM',
'ZDC',
'BPT',
'LUC']:
365 elif thrName[:6] ==
'R2TOPO':
366 thrset =
'legacyTopo'
367 elif thrName[:1]
in [
'e',
'j',
'c',
'g']:
369 elif thrName[:4] ==
'TOPO':
370 if 'Topo2' in ctpIn.conn:
372 elif 'Topo3' in ctpIn.conn:
375 if thrset
not in ctpUnusedInputBitSets:
376 ctpUnusedInputBitSets[thrset] = 0
377 ctpUnusedInputNameSets[thrset] = []
378 if thrName
not in ctpUnusedInputNameSets[thrset]:
379 ctpUnusedInputNameSets[thrset].append(thrName)
380 ctpUnusedInputBitSets[thrset] += ctpIn.nbit
383 log.info(
"Check total number of CTP input and output bits:")
384 log.info(
"Number of output bits: %i", len(ctpOutputs))
385 for thrset
in ctpInputBitSets:
386 log.info(
"Used inputs in %s: %i thresholds and %i bits", thrset, len(ctpInputNameSets[thrset]), ctpInputBitSets[thrset])
387 if thrset
is not None:
388 log.debug(
"Threshold set %s: %s", thrset,
",".join(ctpInputNameSets[thrset]))
390 log.warning(
"Unrecognised CTP input bits: %s",
",".join(ctpInputNameSets[thrset]))
391 totalInputs += ctpInputBitSets[thrset]
392 log.info(
"Number of used inputs bits: %i", totalInputs)
393 totalUnusedInputs = 0
394 for thrset
in ctpUnusedInputBitSets:
395 log.debug(
"Unused thresholds in %s: %i thresholds and %i bits", thrset, len(ctpUnusedInputNameSets[thrset]), ctpUnusedInputBitSets[thrset])
396 if thrset
is not None:
397 log.debug(
"Unused threshold set %s: %s", thrset,
",".join(ctpUnusedInputNameSets[thrset]))
399 log.debug(
"Unrecognised CTP input bits: %s",
",".join(ctpUnusedInputNameSets[thrset]))
400 totalUnusedInputs += ctpUnusedInputBitSets[thrset]
401 log.debug(
"Number of un-used inputs bits: %i", totalUnusedInputs)
404 if (totalInputs > Limits.MaxTrigItems
or len(ctpOutputs) > Limits.MaxTrigItems):
405 if 'AllCTPIn' in self.
menuInfo.menuBaseName:
406 log.warning(f
"Input or output bits limit of {Limits.MaxTrigItems} exceeded in the dummy CTP menu -- OK")
408 raise RuntimeError(
"Both the numbers of inputs and outputs need to be not greater than %i in a physics menu!" % Limits.MaxTrigItems)
425 connected_boards = []
426 for layout, connectors
in self.
ctp.inputConnectors.items():
427 for _, contents
in connectors.items():
428 if layout ==
'ctpin':
430 connected_boards += [board
for board
in contents.values()
if board]
432 connected_boards.append(contents)
434 for conn_name
in connected_boards:
436 if conn.ctype != CType.ELEC:
437 for tl
in conn.triggerLines:
439 if thrName[:3] ==
'ZB_':
440 thrName = thrName[3:]
441 all_ctpin.append(thrName)
443 for fpga
in conn.triggerLines:
444 for clock
in conn.triggerLines[fpga]:
445 for tl
in conn.triggerLines[fpga][clock]:
447 if thrName[:3] ==
'ZB_':
448 thrName = thrName[3:]
449 all_ctpin.append(thrName)
451 for item
in self.
items:
452 for thrName
in item.thresholdNames():
453 if thrName[:3] ==
'ZB_':
454 thrName = thrName[3:]
455 if thrName
not in all_ctpin:
457 f
'checkItemsHaveInputs: Threshold {thrName} used by {item.name} is not on a board connected to CTP')