ATLAS Offline Software
LegacyTopoMergerMap.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
2 
3 from collections import namedtuple, OrderedDict as odict
4 
5 from AthenaCommon.Logging import logging
6 log = logging.getLogger(__name__)
7 
8 MC = namedtuple('MC', "target_bit, topo_board, source_bit, signals")
9 
10 # the following mapping is hardcoded to match the hardwired legacy L1Topo
11 # merger board based on specifications from Stefan Haas
12 __mapping = [
13  MC(target_bit = 0, topo_board = 0, source_bit = 0, signals = ( "900INVM9999-AJ30s6-AJ20s6", None )),
14  MC(target_bit = 1, topo_board = 0, source_bit = 1, signals = ( "800INVM9999-AJ30s6-AJ20s6", None )),
15  MC(target_bit = 2, topo_board = 0, source_bit = 2, signals = ( "700INVM9999-AJ30s6-AJ20s6", "ZEE-EM20shi2" )),
16  MC(target_bit = 3, topo_board = 0, source_bit = 3, signals = ( "500INVM9999-AJ30s6-AJ20s6", None )),
17  MC(target_bit = 4, topo_board = 0, source_bit = 4, signals = ( "400INVM9999-AJ30s6-AJ20s6", "0DR03-EM7ab-CJ15ab" )),
18  MC(target_bit = 5, topo_board = 0, source_bit = 5, signals = ( "300INVM9999-AJ30s6-AJ20s6", "10MINDPHI-J20s2-XE30" )),
19  MC(target_bit = 6, topo_board = 0, source_bit = 6, signals = ( "200INVM9999-AJ30s6-AJ20s6", "10MINDPHI-J20s2-XE50" )),
20  MC(target_bit = 7, topo_board = 0, source_bit = 7, signals = ( "100INVM9999-AJ30s6-AJ20s6", "100RATIO-0MATCH-TAU30si2-EMall" )),
21  MC(target_bit = 8, topo_board = 0, source_bit = 8, signals = ( "0INVM9-EM7ab-EMab", "NOT-0MATCH-TAU30si1-EMall" )),
22  MC(target_bit = 9, topo_board = 0, source_bit = 9, signals = ( "HT150-J20s5pETA31", None )),
23  MC(target_bit = 10, topo_board = 0, source_bit = 10, signals = ( "HT190-J15s5pETA21", None )),
24  MC(target_bit = 11, topo_board = 0, source_bit = 11, signals = ( "1INVM5-EMs1-EMs6", None )),
25  MC(target_bit = 12, topo_board = 0, source_bit = 12, signals = ( "1INVM5-EM7s1-EMs6", "27DPHI32-EMs1-EMs6" )),
26  MC(target_bit = 13, topo_board = 0, source_bit = 13, signals = ( "1INVM5-EM12s1-EMs6", None )),
27  MC(target_bit = 14, topo_board = 0, source_bit = 14, signals = ( None, None )),
28  MC(target_bit = 15, topo_board = 0, source_bit = 15, signals = ( "400INVM9999-AJ30s6pETA31-AJ20s6p31ETA49", None )),
29  MC(target_bit = 16, topo_board = 0, source_bit = 16, signals = ( None, "DISAMB-30INVM-EM20his2-TAU12ab" )),
30  MC(target_bit = 17, topo_board = 0, source_bit = 17, signals = ( None, None )),
31  MC(target_bit = 18, topo_board = 0, source_bit = 18, signals = ( None, None )),
32  MC(target_bit = 19, topo_board = 0, source_bit = 19, signals = ( "1DISAMB-J25ab-0DR28-EM15his2-TAU12abi", None)),
33  MC(target_bit = 20, topo_board = 0, source_bit = 28, signals = ( None, "600INVM9999-J30s6-AJ20s6" )),
34  MC(target_bit = 21, topo_board = 0, source_bit = 29, signals = ( None, "500INVM9999-J30s6-AJ20s6" )),
35  MC(target_bit = 22, topo_board = 0, source_bit = 30, signals = ( None, "400INVM9999-J30s6-AJ20s6" )),
36  MC(target_bit = 23, topo_board = 0, source_bit = 31, signals = ( None, "200INVM9999-J30s6-AJ20s6" )),
37  MC(target_bit = 24, topo_board = 1, source_bit = 10, signals = ( None, None )),
38  MC(target_bit = 25, topo_board = 1, source_bit = 11, signals = ( None, "SC111-CJ15abpETA26" )),
39  MC(target_bit = 26, topo_board = 1, source_bit = 18, signals = ( None, "0DR28-TAU20abi-TAU12abi" )),
40  MC(target_bit = 27, topo_board = 1, source_bit = 19, signals = ( None, "1DISAMB-J25ab-0DR28-TAU20abi-TAU12abi" )),
41  MC(target_bit = 28, topo_board = 1, source_bit = 20, signals = ( None, "1DISAMB-TAU12abi-J25ab" )),
42  MC(target_bit = 29, topo_board = 1, source_bit = 21, signals = ( None, None )),
43  MC(target_bit = 30, topo_board = 1, source_bit = 28, signals = ( "0DETA20-J50s1-Js2", None )),
44  MC(target_bit = 31, topo_board = 1, source_bit = 29, signals = ( None, None )),
45 ]
46 
47 
48 def createMergerBoard(legacyBoard0, legacyBoard1):
49 
50  legacyOccupation = [[32*[None],32*[None]],[32*[None],32*[None]]]
51  for boardNumber, board in enumerate([legacyBoard0, legacyBoard1]):
52  for conn in board["connectors"][0]["algorithmGroups"]:
53  fpga = conn['fpga']
54  clock = conn['clock']
55  for topoAlgDef in conn['algorithms']:
56  lines = topoAlgDef.outputlines
57  if len(lines)==1:
58  legacyOccupation[boardNumber][clock][ 16*fpga + topoAlgDef.outputbits] = lines[0]
59  else:
60  for bit,line in enumerate(lines):
61  legacyOccupation[boardNumber][clock][ 16*fpga + bit + topoAlgDef.outputbits[0]] = line
62 
63  signals = [32*[None], 32*[None]]
64  for mc in __mapping:
65  for clock in [0,1]:
66  algFromMapping = mc.signals[clock]
67  if algFromMapping is None:
68  continue
69  signals[clock][mc.target_bit] = "R2TOPO_"+algFromMapping
70  algFromLegacyBoardDef = legacyOccupation[mc.topo_board][clock][mc.source_bit]
71  if algFromMapping != algFromLegacyBoardDef:
72  fpga = mc.source_bit // 16
73  bit = mc.source_bit % 16
74  msg = f"Legacy board mapping expects line {algFromMapping} on LegacyBoard{mc.topo_board}, fpga {fpga}, " +\
75  f"clock {clock}, bit {bit} but board defines {algFromLegacyBoardDef}"
76  log.error(msg)
77  raise RuntimeError("Mapping doesn't match LegacyBoard definition")
78 
79 
80  board = odict()
81  board["connectors"] = []
82  board["type"] = "merger"
83  board["connectors"].append({
84  "name" : "LegacyTopoMerged",
85  "format" : "simple",
86  "nbitsDefault" : 1,
87  "type" : "electrical",
88  "legacy" : False,
89  "signalGroups" : [
90  {
91  "clock" : 0,
92  "signals" : signals[0]
93  },
94  {
95  "clock" : 1,
96  "signals" : signals[1]
97  }
98  ]
99  })
100  return odict( [("LegacyTopoMerger", board)] )
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
MC
Definition: HepMCHelpers.h:19
python.L1.Config.LegacyTopoMergerMap.createMergerBoard
def createMergerBoard(legacyBoard0, legacyBoard1)
Definition: LegacyTopoMergerMap.py:48