ATLAS Offline Software
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 61 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 77 of file menu_config_tests.py.

77  def __init__(self, trigger_level):
78  super(StructuredChainNames, self).__init__(
79  description="Chain names are structured in the expected way")
80  self._trigger_level = trigger_level
81  self._signature_type_order = \
82  self._SIGNATURE_TYPE_ORDER[trigger_level]
83 

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

116  def _matches_shared_conventions(self, name):
117  '''
118  True if name starts with level prefix, and all signature
119  types are in the correct order, otherwise False.
120  '''
121  # The signature objects in each item should be ordered by type, in the
122  # order defined in _SIGNATURE_TYPE_ORDER.
123  signature_types = "|".join(self._signature_type_order)
124  sig_type_pattern = re.compile(
125  r"_\d*[egj]?({})\d+s?".format(signature_types))
126  def items_in_order(part):
127  #part = part.replace("leg","p") #if we leave the word leg, the findall(..) function will find a 'g'
128  indices = [self._signature_type_order.index(x) for x in
129  sig_type_pattern.findall(part)]
130  rr = indices == sorted(indices)
131  if not rr:
132  log.error("[StructuredChainNames::items_in_order] %s NOT SORTED!", indices)
133 
134  return rr
135 
136  def are_signatures_in_order(name_parts):
137  to_check = ["_".join(p for p in name_parts if "-" not in p)]
138  # Sections of topo item parts are checked for ordering independently.
139  topo_parts = [p for p in name_parts if "-" in p]
140  for topo in topo_parts:
141  to_check.extend(topo.split("-"))
142  res = all(items_in_order(part) for part in to_check)
143  if not res:
144  for part in to_check:
145  if not items_in_order(part):
146  log.error("[StructuredChainNames::are_signatures_in_order] %s not in order!", part)
147  return res
148 
149  # Name must begin with the trigger level, and contain at least one item.
150  parts = name.split("_")
151 
152  result= all((len(parts) > 1,
153  parts[0] == self._trigger_level.value,
154  are_signatures_in_order(parts[1:])))
155  if not result:
156  log.error("[StructuredChainNames::_matches_shared_conventions] chain deosn't match convention: parts[0] = %s, value = %s, parts[1:] = %s, signature_types = %s",
157  parts[0], self._trigger_level.value, parts[1:], signature_types)
158  return result
159 
160 

◆ _name_matches_hlt_convention()

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

Definition at line 94 of file menu_config_tests.py.

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

◆ _name_matches_l1_convention()

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

Definition at line 97 of file menu_config_tests.py.

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

◆ run()

def menu_config_tests.StructuredChainNames.run (   self,
  config 
)

Reimplemented from menu_config_tests.MenuVerification.

Definition at line 84 of file menu_config_tests.py.

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

Member Data Documentation

◆ _SIGNATURE_TYPE_ORDER

menu_config_tests.StructuredChainNames._SIGNATURE_TYPE_ORDER
staticprivate

Definition at line 68 of file menu_config_tests.py.

◆ _signature_type_order

menu_config_tests.StructuredChainNames._signature_type_order
private

Definition at line 81 of file menu_config_tests.py.

◆ _trigger_level

menu_config_tests.StructuredChainNames._trigger_level
private

Definition at line 80 of file menu_config_tests.py.

◆ description

menu_config_tests.MenuVerification.description
inherited

Definition at line 27 of file menu_config_tests.py.

◆ failures

menu_config_tests.StructuredChainNames.failures

Definition at line 87 of file menu_config_tests.py.


The documentation for this class was generated from the following file:
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:797
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
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
Cut::all
@ all
Definition: SUSYToolsAlg.cxx:64
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790