ATLAS Offline Software
Loading...
Searching...
No Matches
menu_config_tests.StructuredChainNames Class Reference
Inheritance diagram for menu_config_tests.StructuredChainNames:
Collaboration diagram for menu_config_tests.StructuredChainNames:

Public Member Functions

 __init__ (self, trigger_level)
 run (self, config)

Public Attributes

 description = description
list failures = []

Protected Member Functions

 _name_matches_hlt_convention (self, name)
 _name_matches_l1_convention (self, name)
 _matches_shared_conventions (self, name)

Protected Attributes

 _trigger_level = trigger_level
list _allowed_prefixes = [trigger_level.value]
dict _signature_type_order

Static Protected Attributes

dict _SIGNATURE_TYPE_ORDER

Detailed Description

Verifies that chain names start with the expected prefix, and have their
parts in the correct order by type, as well as any trigger level specific
restrictions.

Definition at line 63 of file menu_config_tests.py.

Constructor & Destructor Documentation

◆ __init__()

menu_config_tests.StructuredChainNames.__init__ ( self,
trigger_level )

Definition at line 78 of file menu_config_tests.py.

78 def __init__(self, trigger_level):
79 super(StructuredChainNames, self).__init__(
80 description="Chain names are structured in the expected way")
81 self._trigger_level = trigger_level
82 self._allowed_prefixes = [trigger_level.value]
83 if trigger_level == TriggerLevel.HLT:
84 self._allowed_prefixes.append("EF")
85 self._signature_type_order = \
86 self._SIGNATURE_TYPE_ORDER[trigger_level]
87

Member Function Documentation

◆ _matches_shared_conventions()

menu_config_tests.StructuredChainNames._matches_shared_conventions ( self,
name )
protected
True if name starts with level prefix, and all signature
types are in the correct order, otherwise False.

Definition at line 120 of file menu_config_tests.py.

120 def _matches_shared_conventions(self, name):
121 '''
122 True if name starts with level prefix, and all signature
123 types are in the correct order, otherwise False.
124 '''
125 # The signature objects in each item should be ordered by type, in the
126 # order defined in _SIGNATURE_TYPE_ORDER.
127 signature_types = "|".join(self._signature_type_order)
128 sig_type_pattern = re.compile(
129 r"_\d*[egj]?({})\d+s?".format(signature_types))
130
131# this is commented because needs to be discussed (it will be removed/changed in next dev)
132 # re to find the signature that has the probe leg
133 #sig_probe_pattern = re.compile(r"_\d*?({})\d+s?[\D]*?_probe".format(signature_types))
134
135
136 def items_in_order(part):
137 #part = part.replace("leg","p") #if we leave the word leg, the findall(..) function will find a 'g'
138 indices = [self._signature_type_order.index(x) for x in
139 sig_type_pattern.findall(part)]
140
141# this is commented because needs to be discussed (it will be removed/changed in next dev)
142 # this finds the signatures with the probe leg
143 # matches = sig_type_pattern.findall(part)
144 # matches_probe = sig_probe_pattern.findall(part)
145 # if len(matches_probe):
146 # assert(len(matches_probe)==1)
147 # probe_leg = matches_probe[0]
148 # matches_after_probe = matches.copy()
149 # # force the probe leg to be the last one
150 # if probe_leg in matches_after_probe:
151 # # Remove the element
152 # matches_after_probe.remove(probe_leg)
153 # # Append it to the end
154 # matches_after_probe.append(probe_leg)
155 # indices_after_probe = [self._signature_type_order.index(x) for x in matches_after_probe]
156 # # copy the new indices
157 # #indices = indices_after_probe.copy()
158
159
160 rr = indices == sorted(indices)
161 if not rr:
162 log.error("[StructuredChainNames::items_in_order] %s NOT SORTED!", indices)
163
164 return rr
165
166 def are_signatures_in_order(name_parts):
167
168 to_check = ["".join(f"_{p}" for p in name_parts if "-" not in p)]
169
170 # Sections of topo item parts are checked for ordering independently.
171 topo_parts = [p for p in name_parts if "-" in p]
172 for topo in topo_parts:
173 to_check.extend(topo.split("-"))
174 res = all(items_in_order(part) for part in to_check)
175 if not res:
176 for part in to_check:
177 if not items_in_order(part):
178 log.error("[StructuredChainNames::are_signatures_in_order] %s not in order!", part)
179 return res
180
181 # Name must begin with the trigger level, and contain at least one item.
182 parts = name.split("_")
183
184 result= all((len(parts) > 1,
185 parts[0] in self._allowed_prefixes,
186 are_signatures_in_order(parts[1:])))
187 if not result:
188 log.error("[StructuredChainNames::_matches_shared_conventions] chain deosn't match convention: parts[0] = %s, value = %s, parts[1:] = %s, signature_types = %s",
189 parts[0], self._trigger_level.value, parts[1:], signature_types)
190
191 return result
192
193
Definition index.py:1

◆ _name_matches_hlt_convention()

menu_config_tests.StructuredChainNames._name_matches_hlt_convention ( self,
name )
protected

Definition at line 98 of file menu_config_tests.py.

98 def _name_matches_hlt_convention(self, name):
99 return "_L1" in name and self._matches_shared_conventions(name)
100

◆ _name_matches_l1_convention()

menu_config_tests.StructuredChainNames._name_matches_l1_convention ( self,
name )
protected

Definition at line 101 of file menu_config_tests.py.

101 def _name_matches_l1_convention(self, name):
102 def FEX_items_in_order(name):
103 '''
104 Where multiple FEX algorithms are used for the same item type,
105 they should be in alphabetical order.
106 '''
107 fex_pattern = r"\d*([egj])({})[A-Z]*\d+s?".format(
108 "|".join(self._signature_type_order))
109 fex_items = re.findall(fex_pattern, name)
110
111 for item_type in self._signature_type_order:
112 fexes_of_type = [fex for fex, match_type in fex_items
113 if match_type == item_type]
114 if not fexes_of_type == sorted(fexes_of_type):
115 return False
116 return True
117
118 return self._matches_shared_conventions(name) and FEX_items_in_order(name)
119

◆ run()

menu_config_tests.StructuredChainNames.run ( self,
config )

Reimplemented from menu_config_tests.MenuVerification.

Definition at line 88 of file menu_config_tests.py.

88 def run(self, config):
89 if self._trigger_level == TriggerLevel.HLT:
90 names = config["chains"].keys()
91 self.failures = [n for n in names
92 if not self._name_matches_hlt_convention(n)]
93 elif self._trigger_level == TriggerLevel.L1:
94 names = [item["name"] for item in config["items"].values()]
95 self.failures = [n for n in names
96 if not self._name_matches_l1_convention(n)]
97
int run(int argc, char *argv[])

Member Data Documentation

◆ _allowed_prefixes

list menu_config_tests.StructuredChainNames._allowed_prefixes = [trigger_level.value]
protected

Definition at line 82 of file menu_config_tests.py.

◆ _SIGNATURE_TYPE_ORDER

dict menu_config_tests.StructuredChainNames._SIGNATURE_TYPE_ORDER
staticprotected
Initial value:
= {
TriggerLevel.HLT: getListOfSignatureStrings(),
# TODO: import list of signatures items from L1 code
TriggerLevel.L1: [
"EM", "MU", "TAU", "J", "XE", "HT"
],
}

Definition at line 70 of file menu_config_tests.py.

◆ _signature_type_order

dict menu_config_tests.StructuredChainNames._signature_type_order
protected
Initial value:
= \
self._SIGNATURE_TYPE_ORDER[trigger_level]

Definition at line 85 of file menu_config_tests.py.

◆ _trigger_level

menu_config_tests.StructuredChainNames._trigger_level = trigger_level
protected

Definition at line 81 of file menu_config_tests.py.

◆ description

menu_config_tests.MenuVerification.description = description
inherited

Definition at line 29 of file menu_config_tests.py.

◆ failures

list menu_config_tests.MenuVerification.failures = []
inherited

Definition at line 30 of file menu_config_tests.py.


The documentation for this class was generated from the following file: