HPS-MC
Pattern Class Reference

Pattern that can match one or more paramters. More...

Public Member Functions

def __init__ (self, pattern, *first=True)
 
def match (self, p)
 
def __eq__ (self, p)
 
def __repr__ (self)
 

Static Public Attributes

int NUM_MODULES = 7
 
dictionary binary_keywords
 
list unary_keywords
 
dictionary aliases
 

Private Member Functions

def __validate_id (i)
 Make sure input is a valid ID number, otherwise return NotImplemented. More...
 
def __validate_module (m)
 Make sure input is a valid module number, otherwise return NotImplemented. More...
 
def __validate_layer (layer)
 Make sure input is a valid layer number, otherwise return NotImplemented. More...
 
def _add_check (self, c)
 add a check into our list of checks, making sure it is the correct format More...
 

Private Attributes

 _checks
 
 _og_str
 

Detailed Description

Pattern that can match one or more paramters.

This is an internal class and should not be used outside of this module

A single "pattern" is a str that is one of the unary keywords OR has a binary keyword followed by an "=" character followed by one of that keywords values. All whitespace in a pattern is removed so spaces can be added for easier readability.

Syntax

Each pattern is made up of one or more operations where each operation is separated by an ampersand "&" to reflect that a Pattern takes the logical-and of the operations listed.

'op1 & op2 & op3 ...'

Each operation can be one of three things.

  1. An ID number.
  2. A unary operation.
  3. A binary operation.

ID numbers are the 5-digit millepede ID number for that parameter which encodes all of the location information within it. It specifies a single millepede parameter.

Unary operations are special keywords that correspond to different logical grouping of parameters. Some unary operations correspond to functions returning True/False of the Parameter class while others are simple shortenings of common Pattern strings (a.k.a. "aliases").

Binary operations are a string formatted like "kw = val" where a single equal sign is used. kw is a keyword corresponding to select functions from the Parameter class while val is a keyword corresponding to specific options for each kw.

Definition at line 6 of file _pattern.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  pattern,
first = True 
)

Definition at line 146 of file _pattern.py.

Member Function Documentation

◆ __eq__()

def __eq__ (   self,
  p 
)

Definition at line 187 of file _pattern.py.

◆ __repr__()

def __repr__ (   self)

Definition at line 190 of file _pattern.py.

◆ __validate_id()

def __validate_id (   i)
private

Make sure input is a valid ID number, otherwise return NotImplemented.

    A valid ID number is a 5-digit integer matching the Parameter.idn_str_pattern
    regular expression.

Definition at line 45 of file _pattern.py.

◆ __validate_layer()

def __validate_layer (   layer)
private

Make sure input is a valid layer number, otherwise return NotImplemented.

    A valid layer number is an index counting axial/stereo pairs from 1 at
    the front of the detector up to NUM_MODULES

Definition at line 70 of file _pattern.py.

◆ __validate_module()

def __validate_module (   m)
private

Make sure input is a valid module number, otherwise return NotImplemented.

    A valid module number is an index counting from 0 at the front of the detector
    up to NUM_MODULES-1

Definition at line 56 of file _pattern.py.

◆ _add_check()

def _add_check (   self,
  c 
)
private

add a check into our list of checks, making sure it is the correct format

Definition at line 117 of file _pattern.py.

◆ match()

def match (   self,
  p 
)

Definition at line 177 of file _pattern.py.

Member Data Documentation

◆ _checks

_checks
private

Definition at line 148 of file _pattern.py.

◆ _og_str

_og_str
private

Definition at line 149 of file _pattern.py.

◆ aliases

dictionary aliases
static
Initial value:
= {
'bot': 'bottom',
'trans': 'translation',
'rot': 'rotation',
'tu': 'direction=u & translation',
'rw': 'direction=w & rotation'
}

Definition at line 109 of file _pattern.py.

◆ binary_keywords

dictionary binary_keywords
static
Initial value:
= {
'id': __validate_id,
'module': __validate_module,
'layer': __validate_layer,
'direction': {'u': 1, 'v': 2, 'w': 3}
}

Definition at line 87 of file _pattern.py.

◆ NUM_MODULES

int NUM_MODULES = 7
static

Definition at line 43 of file _pattern.py.

◆ unary_keywords

list unary_keywords
static
Initial value:
= [
'top',
'bottom',
'translation',
'rotation',
'individual',
'axial',
'stereo',
'front',
'back',
'hole',
'slot'
]

Definition at line 93 of file _pattern.py.


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