ATLAS Offline Software
Loading...
Searching...
No Matches
Trigger
TriggerCommon
TriggerMenuMT
python
L1
Base
TopoAlgorithms.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3
from
operator
import
attrgetter
4
from
enum
import
Enum
5
6
from
AthenaCommon.Logging
import
logging
7
log = logging.getLogger(__name__)
8
9
from
.TopoAlgos
import
DecisionAlgo, MultiplicityAlgo, SortingAlgo
10
11
class
AlgType
(Enum):
12
SORT = (
'sortingAlgorithms'
)
13
DEC = (
'decisionAlgorithms'
)
14
MULT = (
'multiplicityAlgorithms'
)
15
16
def
__init__
(self, key):
17
self.
key
= key
18
19
class
AlgCategory
(Enum):
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'
)
24
25
def
__init__
(self, _, key, desc, defFile ):
26
self.
key
= key
27
self.
prefix
= key +
'_'
if
key
else
''
28
self.
desc
= desc
29
self.
defFile
= defFile
30
31
def
__str__
(self):
32
return
self.
desc
33
34
@staticmethod
35
def
getAllCategories
():
36
return
[ AlgCategory.TOPO, AlgCategory.MUCTPI, AlgCategory.MULTI, AlgCategory.LEGACY ]
37
38
@staticmethod
39
def
getCategoryFromBoardName
(boardName):
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
45
else
:
46
currentTopoCategory = AlgCategory.TOPO
47
else
:
48
raise
RuntimeError(
"Board %s is not a topo board"
% boardName )
49
return
currentTopoCategory
50
51
52
class
MenuTopoAlgorithmsCollection
(
object
):
53
54
def
__init__
(self):
55
# all algos that are in menu (new and legacy)
56
self.
topoAlgos
= {}
57
for
cat
in
AlgCategory:
58
self.
topoAlgos
[cat] = {}
59
if
cat
in
[AlgCategory.TOPO, AlgCategory.MUCTPI, AlgCategory.LEGACY]:
60
self.
topoAlgos
[cat][AlgType.DEC] = {}
61
self.
topoAlgos
[cat][AlgType.SORT] = {}
62
elif
cat
in
[AlgCategory.MULTI]:
63
self.
topoAlgos
[cat][AlgType.MULT] = {}
64
65
def
addAlgo
(self, algo, category):
66
if
type
(category)
is
not
AlgCategory:
67
raise
RuntimeError(
"No category is provided when adding topo algo %s to menu"
% algo.name)
68
69
if
isinstance(algo,DecisionAlgo):
70
algType = AlgType.DEC
71
elif
isinstance(algo, SortingAlgo):
72
algType = AlgType.SORT
73
elif
isinstance(algo, MultiplicityAlgo):
74
algType = AlgType.MULT
75
else
:
76
raise
RuntimeError(
"Trying to add topo algorithm %s of unknown type %s to the menu"
% (algo.name,
type
(algo)))
77
78
if
algType
not
in
self.
topoAlgos
[category]:
79
self.
topoAlgos
[category][algType] = {}
80
81
if
algo.name
in
self.
topoAlgos
[category][algType]:
82
raise
RuntimeError(
"Trying to add topo algorithm %s a second time"
% algo.name)
83
84
self.
topoAlgos
[category][algType][algo.name] = algo
85
86
87
def
json
(self):
88
89
confObj = {}
90
for
cat
in
self.
topoAlgos
:
91
confObj[cat.key] = {}
92
for
typ
in
self.
topoAlgos
[cat]:
93
confObj[cat.key][typ.key] = {}
94
for
alg
in
sorted(self.
topoAlgos
[cat][typ].values(), key=attrgetter(
'name'
)):
95
confObj[cat.key][typ.key][alg.name] = alg.json()
96
97
return
confObj
json
nlohmann::json json
Definition
HistogramDef.cxx:9
python.L1.Base.TopoAlgorithms.AlgCategory
Definition
TopoAlgorithms.py:19
python.L1.Base.TopoAlgorithms.AlgCategory.desc
desc
Definition
TopoAlgorithms.py:28
python.L1.Base.TopoAlgorithms.AlgCategory.getAllCategories
getAllCategories()
Definition
TopoAlgorithms.py:35
python.L1.Base.TopoAlgorithms.AlgCategory.getCategoryFromBoardName
getCategoryFromBoardName(boardName)
Definition
TopoAlgorithms.py:39
python.L1.Base.TopoAlgorithms.AlgCategory.__str__
__str__(self)
Definition
TopoAlgorithms.py:31
python.L1.Base.TopoAlgorithms.AlgCategory.defFile
defFile
Definition
TopoAlgorithms.py:29
python.L1.Base.TopoAlgorithms.AlgCategory.prefix
str prefix
Definition
TopoAlgorithms.py:27
python.L1.Base.TopoAlgorithms.AlgCategory.__init__
__init__(self, _, key, desc, defFile)
Definition
TopoAlgorithms.py:25
python.L1.Base.TopoAlgorithms.AlgCategory.key
key
Definition
TopoAlgorithms.py:26
python.L1.Base.TopoAlgorithms.AlgType
Definition
TopoAlgorithms.py:11
python.L1.Base.TopoAlgorithms.AlgType.key
key
Definition
TopoAlgorithms.py:17
python.L1.Base.TopoAlgorithms.AlgType.__init__
__init__(self, key)
Definition
TopoAlgorithms.py:16
python.L1.Base.TopoAlgorithms.MenuTopoAlgorithmsCollection
Definition
TopoAlgorithms.py:52
python.L1.Base.TopoAlgorithms.MenuTopoAlgorithmsCollection.topoAlgos
dict topoAlgos
Definition
TopoAlgorithms.py:56
python.L1.Base.TopoAlgorithms.MenuTopoAlgorithmsCollection.__init__
__init__(self)
Definition
TopoAlgorithms.py:54
python.L1.Base.TopoAlgorithms.MenuTopoAlgorithmsCollection.addAlgo
addAlgo(self, algo, category)
Definition
TopoAlgorithms.py:65
type
object
Generated on
for ATLAS Offline Software by
1.14.0