ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TriggerCommon
TriggerMenuMT
python
HLT
Config
ChainConfigurationBase.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3
4
from
AthenaCommon.Logging
import
logging
5
log = logging.getLogger(__name__)
6
7
import
abc
8
import
inspect
9
import
functools
10
from
TriggerMenuMT.HLT.Config.MenuComponents
import
Chain, ChainStep
11
from
DecisionHandling.DecisionHandlingConfig
import
ComboHypoCfg
12
from
HLTSeeding.HLTSeedingConfig
import
mapThresholdToL1DecisionCollection
13
14
15
#----------------------------------------------------------------
16
# Base class to configure chain
17
#----------------------------------------------------------------
18
class
ChainConfigurationBase
(metaclass=abc.ABCMeta):
19
20
def
__init__
(self, chainDict):
21
22
# Consider using translation from dict["chainName"] to dict.chainName (less typing),
23
# though need to be able to access list of dictionaries as value of chainPart as well
24
# dict = type("dict", (object,), dict)
25
26
self.
dict
= {}
27
self.
dict
.update(chainDict)
28
29
self.
chainName
= self.
dict
[
'chainName'
]
30
self.
chainL1Item
= self.
dict
[
'L1item'
]
31
32
# check dictionary contains only one chain part
33
if
len( self.
dict
[
'chainParts'
] ) != 1:
34
raise
RuntimeError(
"Passed chain dictionary with %i chainParts to ChainConfigurationBase, but this constructor only supports chains with a single part"
% len( self.
dict
[
'chainParts'
] ) )
35
36
self.
chainPart
= self.
dict
[
'chainParts'
][0]
37
self.
L1Threshold
= self.
chainPart
[
'L1threshold'
]
# now threshold is always there
38
self.
mult
= int(self.
chainPart
[
'multiplicity'
])
39
self.
chainPartName
= self.
chainPart
[
'chainPartName'
]
40
self.
chainPartNameNoMult
=
''
41
self.
chainPartNameNoMultwL1
=
''
42
43
self.
chainPartNameNoMult
= self.
chainPartName
[1:]
if
self.
mult
> 1
else
self.
chainPartName
44
self.
chainPartNameNoMultwL1
+=
"_"
+self.
chainL1Item
45
46
def
getStep
(self, flags, stepName, sequenceCfgArray, comboHypoCfg=ComboHypoCfg, comboTools=[], **stepArgs):
47
log.debug(
"Configuring step %s with %d chainParts"
, stepName, len(self.
dict
[
'chainParts'
]))
48
49
# do not generate Menu Sequences, just store the functions that can do that
50
seqArray = [functools.partial(gen, flags, **stepArgs)
for
gen
in
sequenceCfgArray]
51
52
if
(len(seqArray)>0):
53
# Bind flags to comboHypo generator if needed
54
if
'flags'
in
inspect.signature(comboHypoCfg).parameters:
55
comboHypoCfg = functools.partial(comboHypoCfg, flags)
56
else
:
57
comboHypoCfg = functools.partial(comboHypoCfg)
58
return
ChainStep(stepName, seqArray,
59
[self.
dict
], comboHypoCfg = comboHypoCfg, comboToolConfs = comboTools)
60
61
# if not returned any step
62
raise
RuntimeError(
"[getStep] No sequences generated for step %s!"
, stepName)
63
64
def
getEmptyStep
(self, stepName):
65
log.debug(
'Configuring empty step %s'
, stepName)
66
return
ChainStep(stepName, chainDicts=[self.
dict
], isEmpty=
True
)
67
68
def
buildChain
(self, chainSteps):
69
70
alignmentGroups = []
71
if
isinstance(self.
chainPart
, dict):
72
alignmentGroups = [self.
chainPart
[
'alignmentGroup'
]]
73
elif
isinstance(self.
chainPart
, list):
74
75
alignmentGroups = [cp[
'alignmentGroup'
]
for
cp
in
self.
chainPart
]
76
testAlignGrps = list(
set
(alignmentGroups))
77
if
not(len(testAlignGrps) == 1
and
testAlignGrps[0] ==
'JetMET'
):
78
log.error(
"ChainConfigurationBase.buildChain(): number of chainParts does not correspond chainSteps"
)
79
log.error(
'ChainConfigurationBase.buildChain() chainPart: %s'
,self.
chainPart
)
80
log.error(
"ChainConfigurationBase.buildChain() alignmentGroups: %s"
, alignmentGroups)
81
log.error(
"ChainConfigurationBase.buildChain() chainName: %s"
, self.
chainName
)
82
log.error(
"ChainConfigurationBase.buildChain() chainSteps: %s"
, chainSteps)
83
else
:
84
alignmentGroups = testAlignGrps
85
86
else
:
87
log.error(
"ChainConfigurationBase.buildChain(): chainPart is not a list or dict, not sure what to do here! %s "
, self.
chainPart
)
88
89
L1decision = mapThresholdToL1DecisionCollection(self.
L1Threshold
)
90
myChain = Chain(name = self.
chainName
,
91
ChainSteps = chainSteps,
92
L1decisions = [L1decision],
93
nSteps = [len(chainSteps)],
# not true for combined chains
94
alignmentGroups = alignmentGroups
95
)
96
97
return
myChain
98
99
@abc.abstractmethod
100
def
assembleChainImpl
(self, flags):
101
return
102
103
def
assembleChain
(self, flags):
104
return
self.assembleChainImpl(flags)
ChainConfigurationBase.ChainConfigurationBase
Definition
ChainConfigurationBase.py:18
ChainConfigurationBase.ChainConfigurationBase.L1Threshold
dict L1Threshold
Definition
ChainConfigurationBase.py:37
ChainConfigurationBase.ChainConfigurationBase.chainPartNameNoMultwL1
str chainPartNameNoMultwL1
Definition
ChainConfigurationBase.py:41
ChainConfigurationBase.ChainConfigurationBase.assembleChain
assembleChain(self, flags)
Definition
ChainConfigurationBase.py:103
ChainConfigurationBase.ChainConfigurationBase.chainPart
dict chainPart
Definition
ChainConfigurationBase.py:36
ChainConfigurationBase.ChainConfigurationBase.getEmptyStep
getEmptyStep(self, stepName)
Definition
ChainConfigurationBase.py:64
ChainConfigurationBase.ChainConfigurationBase.assembleChainImpl
assembleChainImpl(self, flags)
Definition
ChainConfigurationBase.py:100
ChainConfigurationBase.ChainConfigurationBase.chainPartNameNoMult
str chainPartNameNoMult
Definition
ChainConfigurationBase.py:40
ChainConfigurationBase.ChainConfigurationBase.buildChain
buildChain(self, chainSteps)
Definition
ChainConfigurationBase.py:68
ChainConfigurationBase.ChainConfigurationBase.mult
mult
Definition
ChainConfigurationBase.py:38
ChainConfigurationBase.ChainConfigurationBase.getStep
getStep(self, flags, stepName, sequenceCfgArray, comboHypoCfg=ComboHypoCfg, comboTools=[], **stepArgs)
Definition
ChainConfigurationBase.py:46
ChainConfigurationBase.ChainConfigurationBase.chainL1Item
dict chainL1Item
Definition
ChainConfigurationBase.py:30
ChainConfigurationBase.ChainConfigurationBase.dict
dict dict
Definition
ChainConfigurationBase.py:26
ChainConfigurationBase.ChainConfigurationBase.__init__
__init__(self, chainDict)
Definition
ChainConfigurationBase.py:20
ChainConfigurationBase.ChainConfigurationBase.chainName
dict chainName
Definition
ChainConfigurationBase.py:29
ChainConfigurationBase.ChainConfigurationBase.chainPartName
dict chainPartName
Definition
ChainConfigurationBase.py:39
set
STL class.
Generated on
for ATLAS Offline Software by
1.17.0