Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
menu_config_tests.StructuredChainNames Class Reference
Inheritance diagram for menu_config_tests.StructuredChainNames:
Collaboration diagram for menu_config_tests.StructuredChainNames:

Public Member Functions

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

Public Attributes

 failures
 
 description
 

Private Member Functions

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

Private Attributes

 _trigger_level
 
 _signature_type_order
 

Static Private Attributes

 _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__()

def menu_config_tests.StructuredChainNames.__init__ (   self,
  trigger_level 
)

Reimplemented from menu_config_tests.MenuVerification.

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()

def menu_config_tests.StructuredChainNames._matches_shared_conventions (   self,
  name 
)
private
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 

◆ _name_matches_hlt_convention()

def menu_config_tests.StructuredChainNames._name_matches_hlt_convention (   self,
  name 
)
private

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()

def menu_config_tests.StructuredChainNames._name_matches_l1_convention (   self,
  name 
)
private

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()

def 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 

Member Data Documentation

◆ _SIGNATURE_TYPE_ORDER

menu_config_tests.StructuredChainNames._SIGNATURE_TYPE_ORDER
staticprivate

Definition at line 70 of file menu_config_tests.py.

◆ _signature_type_order

menu_config_tests.StructuredChainNames._signature_type_order
private

Definition at line 82 of file menu_config_tests.py.

◆ _trigger_level

menu_config_tests.StructuredChainNames._trigger_level
private

Definition at line 81 of file menu_config_tests.py.

◆ description

menu_config_tests.MenuVerification.description
inherited

Definition at line 29 of file menu_config_tests.py.

◆ failures

menu_config_tests.StructuredChainNames.failures

Definition at line 88 of file menu_config_tests.py.


The documentation for this class was generated from the following file:
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename R::value_type > sorted(const R &r, PROJ proj={})
Helper function to create a sorted vector from an unsorted range.
vtune_athena.format
format
Definition: vtune_athena.py:14
index
Definition: index.py:1
run
int run(int argc, char *argv[])
Definition: ttree2hdf5.cxx:28
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:805
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
Cut::all
@ all
Definition: SUSYToolsAlg.cxx:67