3 from collections
import OrderedDict
as odict
4 from operator
import attrgetter
7 from AthenaCommon.Logging
import logging
8 log = logging.getLogger(__name__)
10 from .TopoAlgos
import DecisionAlgo, MultiplicityAlgo, SortingAlgo
13 SORT = (
'sortingAlgorithms')
14 DEC = (
'decisionAlgorithms')
15 MULT = (
'multiplicityAlgorithms')
21 TOPO = (1,
'TOPO',
'new topo',
'TopoAlgoDef')
22 MUCTPI = (2,
'MUTOPO',
'muctpi topo',
'TopoAlgoDefMuctpi')
23 LEGACY = (3,
'R2TOPO',
'legacy topo',
'TopoAlgoDefLegacy')
24 MULTI = (4,
'MULTTOPO',
'multiplicity topo',
'TopoAlgoDefMultiplicity')
28 self.
prefix = key +
'_' if key
else ''
37 return [ AlgCategory.TOPO, AlgCategory.MUCTPI, AlgCategory.MULTI, AlgCategory.LEGACY ]
41 if 'muctpi' in boardName.lower():
42 currentTopoCategory = AlgCategory.MUCTPI
43 elif 'topo' in boardName.lower():
44 if 'legacy' in boardName.lower():
45 currentTopoCategory = AlgCategory.LEGACY
47 currentTopoCategory = AlgCategory.TOPO
49 raise RuntimeError(
"Board %s is not a topo board" % boardName )
50 return currentTopoCategory
58 for cat
in AlgCategory:
60 if cat
in [AlgCategory.TOPO, AlgCategory.MUCTPI, AlgCategory.LEGACY]:
61 self.
topoAlgos[cat][AlgType.DEC] = odict()
62 self.
topoAlgos[cat][AlgType.SORT] = odict()
63 elif cat
in [AlgCategory.MULTI]:
64 self.
topoAlgos[cat][AlgType.MULT] = odict()
67 if type(category)
is not AlgCategory:
68 raise RuntimeError(
"No category is provided when adding topo algo %s to menu" % algo.name)
70 if isinstance(algo,DecisionAlgo):
72 elif isinstance(algo, SortingAlgo):
73 algType = AlgType.SORT
74 elif isinstance(algo, MultiplicityAlgo):
75 algType = AlgType.MULT
77 raise RuntimeError(
"Trying to add topo algorithm %s of unknown type %s to the menu" % (algo.name,
type(algo)))
79 if algType
not in self.
topoAlgos[category]:
80 self.
topoAlgos[category][algType] = odict()
82 if algo.name
in self.
topoAlgos[category][algType]:
83 raise RuntimeError(
"Trying to add topo algorithm %s a second time" % algo.name)
85 self.
topoAlgos[category][algType][algo.name] = algo
92 confObj[cat.key] = odict()
94 confObj[cat.key][typ.key] = odict()
96 confObj[cat.key][typ.key][alg.name] = alg.json()