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 Types

typedef HLT::TypeInformation::for_each_type_c< typenameEDMLIST::map, my_functor, my_result<>, my_arg< HLT::TypeInformation::get_cont, CONTAINER > >::type result

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
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.

Member Typedef Documentation

◆ result

Definition at line 90 of file EDM_MasterSearch.h.

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._signature_type_order = \
83 self._SIGNATURE_TYPE_ORDER[trigger_level]
84

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 117 of file menu_config_tests.py.

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

◆ _name_matches_hlt_convention()

menu_config_tests.StructuredChainNames._name_matches_hlt_convention ( self,
name )
protected

Definition at line 95 of file menu_config_tests.py.

95 def _name_matches_hlt_convention(self, name):
96 return "_L1" in name and self._matches_shared_conventions(name)
97

◆ _name_matches_l1_convention()

menu_config_tests.StructuredChainNames._name_matches_l1_convention ( self,
name )
protected

Definition at line 98 of file menu_config_tests.py.

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

◆ run()

menu_config_tests.StructuredChainNames.run ( self,
config )

Reimplemented from menu_config_tests.MenuVerification.

Definition at line 85 of file menu_config_tests.py.

85 def run(self, config):
86 if self._trigger_level == TriggerLevel.HLT:
87 names = config["chains"].keys()
88 self.failures = [n for n in names
89 if not self._name_matches_hlt_convention(n)]
90 elif self._trigger_level == TriggerLevel.L1:
91 names = [item["name"] for item in config["items"].values()]
92 self.failures = [n for n in names
93 if not self._name_matches_l1_convention(n)]
94
Definition run.py:1

Member Data Documentation

◆ _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 82 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: