3 from operator
import attrgetter
6 from AthenaCommon.Logging
import logging
7 log = logging.getLogger(__name__)
9 from .TopoAlgos
import DecisionAlgo, MultiplicityAlgo, SortingAlgo
12 SORT = (
'sortingAlgorithms')
13 DEC = (
'decisionAlgorithms')
14 MULT = (
'multiplicityAlgorithms')
20 TOPO = (1,
'TOPO',
'new topo',
'TopoAlgoDef')
21 MUCTPI = (2,
'MUTOPO',
'muctpi topo',
'TopoAlgoDefMuctpi')
22 LEGACY = (3,
'R2TOPO',
'legacy topo',
'TopoAlgoDefLegacy')
23 MULTI = (4,
'MULTTOPO',
'multiplicity topo',
'TopoAlgoDefMultiplicity')
27 self.
prefix = key +
'_' if key
else ''
36 return [ AlgCategory.TOPO, AlgCategory.MUCTPI, AlgCategory.MULTI, AlgCategory.LEGACY ]
40 if 'muctpi' in boardName.lower():
41 currentTopoCategory = AlgCategory.MUCTPI
42 elif 'topo' in boardName.lower():
43 if 'legacy' in boardName.lower():
44 currentTopoCategory = AlgCategory.LEGACY
46 currentTopoCategory = AlgCategory.TOPO
48 raise RuntimeError(
"Board %s is not a topo board" % boardName )
49 return currentTopoCategory
57 for cat
in AlgCategory:
59 if cat
in [AlgCategory.TOPO, AlgCategory.MUCTPI, AlgCategory.LEGACY]:
62 elif cat
in [AlgCategory.MULTI]:
66 if type(category)
is not AlgCategory:
67 raise RuntimeError(
"No category is provided when adding topo algo %s to menu" % algo.name)
69 if isinstance(algo,DecisionAlgo):
71 elif isinstance(algo, SortingAlgo):
72 algType = AlgType.SORT
73 elif isinstance(algo, MultiplicityAlgo):
74 algType = AlgType.MULT
76 raise RuntimeError(
"Trying to add topo algorithm %s of unknown type %s to the menu" % (algo.name,
type(algo)))
78 if algType
not in self.
topoAlgos[category]:
81 if algo.name
in self.
topoAlgos[category][algType]:
82 raise RuntimeError(
"Trying to add topo algorithm %s a second time" % algo.name)
84 self.
topoAlgos[category][algType][algo.name] = algo
93 confObj[cat.key][typ.key] = {}
95 confObj[cat.key][typ.key][alg.name] = alg.json()