5 from AthenaCommon.Logging
import logging
7 from .TopoAlgorithms
import AlgCategory
9 log = logging.getLogger(__name__)
13 ELEC = (2,
'electrical')
25 elif label ==
'electrical':
27 elif label ==
'optical':
30 raise NotImplementedError(
"Connector of type %s does't exist" % label)
34 MULT = (1,
'multiplicity')
35 TOPO = (2,
'topological')
36 SIMPLE = (3,
'simple')
42 if label ==
'multiplicity':
44 elif label ==
'topological':
46 elif label ==
'simple':
49 raise NotImplementedError
67 name, cformat, ctype, legacy, boardName = map(connDef.__getitem__,[
"name",
"format",
"type",
"legacy",
"board"])
70 raise RuntimeError(
"Connector %s has already been defined" % name)
72 log.debug(
"Adding connector %s, format %s, legacy set to %s, and connType %s", name, cformat, legacy, ctype)
73 if CType.from_str(ctype)
is CType.ELEC:
75 elif CType.from_str(ctype)
is CType.CTPIN:
84 confObj[conn.name] = conn.json()
91 __slots__ = [
'name',
'cformat',
'ctype',
'legacy',
'boardName',
'triggerLines',
'emptyTriggerLines']
94 @param name name of the connector
95 @param cformat can be 'topological' or 'multiplicity'
96 @param ctype can be 'ctpin', 'electrical', or 'optical'
98 name, cformat, ctype, legacy, boardName = map(connDef.__getitem__,[
"name",
"format",
"type",
"legacy",
"board"])
123 confObj[
"legacy"] = self.
legacy
124 confObj[
"triggerlines"] = [tl.json()
for tl
in self.
triggerLines]
129 __slots__ = [
'name',
'legacy',
'triggerLines',
'emptyTriggerLines']
132 @param name name of the connector
133 @param legacy is 'true' for legacy L1Calo connectors
135 super(CtpinConnector,self).
__init__(connDef = connDef)
139 for thrName
in connDef[
"thresholds"]:
140 nbits = connDef[
"nbitsDefault"]
141 if type(thrName)==tuple:
142 (thrName, nbits) = thrName
153 __slots__ = [
'name',
'cformat',
'ctype',
'legacy',
'triggerLines',
'emptyTriggerLines']
154 def __init__(self, name, cformat, ctype, legacy, connDef):
156 @param name name of the connector
157 @param cformat can be 'topological' or 'multiplicity'
158 @param ctype can be 'ctpin', 'electrical', or 'optical'
160 super(OpticalConnector,self).
__init__(connDef = connDef)
166 for thrName
in connDef[
"thresholds"]:
167 nbits = connDef[
"nbitsDefault"]
168 if type(thrName)==tuple:
169 (thrName, nbits) = thrName
179 raise RuntimeError(
"Property 'format' of connector %s is '%s' but must be either 'multiplicity' or 'topological', however 'topological' is not yet implemented" % (name,connDef[
"format"]))
183 def __init__(self, name, cformat, legacy, connDef):
185 @param name name of the connector
186 @param cformat can be 'topological' or 'simple'
188 super(ElectricalConnector,self).
__init__(connDef = connDef)
195 currentTopoCategory = AlgCategory.getCategoryFromBoardName(self.
boardName)
196 for thrG
in connDef[
"algorithmGroups"]:
197 fpga,clock = map(thrG.__getitem__,[
"fpga",
"clock"])
198 for topo
in thrG[
"algorithms"]:
199 bit = topo.outputbits[0]
if isinstance(topo.outputbits, tuple)
else topo.outputbits
200 for (i, tl)
in enumerate(topo.outputlines):
202 tlname = currentTopoCategory.prefix + tl
204 flatindex = 32*fpga + 2*startbit + clock
205 self.
addTriggerLine(
TriggerLine( name = tlname, startbit = startbit, flatindex = flatindex, nbits = 1, fpga = fpga, clock = clock ), fpga, clock )
206 elif self.
cformat == CFormat.SIMPLE:
207 for sigG
in connDef[
"signalGroups"]:
208 clock = sigG[
"clock"]
210 for signal
in sigG[
"signals"]:
211 nbits = connDef[
"nbitsDefault"]
212 if type(signal)==tuple:
213 (signal,nbits) = signal
218 flatindex = 2*startbit + clock
219 tl =
TriggerLine( name = signal, startbit = startbit, flatindex = flatindex, nbits = nbits, fpga =
None, clock = clock)
223 raise RuntimeError(
"Property 'format' of connector %s is '%s' but must be either 'simple' or 'topological'" % (name,connDef[
"format"]))
231 return [x.name
for x
in thr]
237 confObj[
"legacy"] = self.
legacy
238 confObj[
"triggerlines"] = {}
239 if self.
cformat == CFormat.TOPO:
243 _triggerLines += [tl.json()
for tl
in self.
triggerLines[fpga][clock]]
244 confObj[
"triggerlines"] = _triggerLines
245 elif self.
cformat == CFormat.SIMPLE:
248 _triggerLines += [tl.json()
for tl
in self.
triggerLines[0][clock]]
249 confObj[
"triggerlines"] = _triggerLines
254 def __init__(self, name, startbit, nbits, flatindex=None, fpga=None, clock=None):
264 confObj[
"name"] = self.
name
268 confObj[
"nbits"] = self.
nbits
269 if self.
fpga is not None:
270 confObj[
"fpga"] = self.
fpga
271 if self.
clock is not None:
272 confObj[
"clock"] = self.
clock