HPS-MC
Parameter Class Reference

Representation of a single alignment parameter. More...

Public Member Functions

def __init__ (self, idn, name, half, trans_rot, direction, mp_layer_id)
 
def float (self, yes=True)
 Set whether this parameter is floating/active or not. More...
 
def module (self)
 Get the module number from the millepede layer number. More...
 
def layer (self)
 Get the human layer number. More...
 
def id (self)
 
def direction (self)
 
def individual (self)
 Get whether this Parameter represents a single sensor (True) or a structural component holding two or more sensors (False) More...
 
def translation (self)
 True if Parameter represents a translation. More...
 
def rotation (self)
 True if Parameter represents a rotation. More...
 
def top (self)
 Does this parameter represent a component on the top half (True) or bottom (False) More...
 
def bottom (self)
 True if Parameter is in bottom half, False if in top half. More...
 
def axial (self)
 Get whether this Parameter represents a single axial sensor (True) or something else (False) More...
 
def stereo (self)
 Get whether this Parameter represents a single stereo sensor (True) or something else (False) More...
 
def front (self)
 True if Parameter is single sensor in front half, False otherwise. More...
 
def back (self)
 True if Parameter is single sensor in back half, False otherwise. More...
 
def hole (self)
 True if Parameter is a single sensor in back half on the hole side, Flase otherwise. More...
 
def slot (self)
 True if Parameter is a single sensor in back half on the slot side, Flase otherwise. More...
 
def active (self)
 True if Parameter is active (i.e. More...
 
def from_map_file_line (line)
 
def from_idn (idn)
 Deduce the categorical flags from the ID number. More...
 
def parse_map_file (map_filepath)
 load the entire parameter set from a map file More...
 
def parse_pede_res (res_file, destination=None, skip_nonfloat=False)
 parse a pede results file More...
 
def pede_format (self)
 Print this parameter as it should appear in the pede steering file. More...
 
def compact_value (self)
 Print the value of this parameter as it should be inserted into the compact. More...
 
def __repr__ (self)
 Representation of this parameter. More...
 
def __str__ (self)
 Human printing of this parameter. More...
 

Static Public Attributes

 idn_str_pattern = re.compile('^[12][123][123][0-9][0-9]$')
 
 layer_number_pattern = re.compile('^.*_L([0-9]).*$')
 

Private Member Functions

def __from_res_file_line (self, line)
 Assumes line is for the same parameter as stored in self. More...
 

Private Attributes

 _id
 
 _name
 
 _half
 
 _trans_rot
 
 _direction
 
 _mp_layer_id
 
 _val
 
 _error
 
 _active
 

Detailed Description

Representation of a single alignment parameter.

This class also contains helpful functions for operating on sets of alignment parameters e.g. parsing the map file or pede res file

Attributes

id : int pede ID number as written in compact.xml, pede steering, and map files name : str human-readable name as written in map file half : int 1 is for top and 2 is for bottom trans_rot : int 1 is for translation and 2 is for rotation direction : int 1 is for 'u', 2 is for v, and 3 is for w mp_layer_id : int "layer" ID number in millepede (i.e. axial and stereo sensors are separated) val : float value of parameter (if loaded from res file) error : float error of parameter (if loaded from res file) active : bool true if parameter is floating, false otherwise

Definition at line 6 of file _parameter.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  idn,
  name,
  half,
  trans_rot,
  direction,
  mp_layer_id 
)

Definition at line 38 of file _parameter.py.

Member Function Documentation

◆ __from_res_file_line()

def __from_res_file_line (   self,
  line 
)
private

Assumes line is for the same parameter as stored in self.

   A line in the pede result file has either 3 or 5 columns.

   1. ID
   2. value
   3. activity (0.0 if floating, -1.0 if not)
   4. (if active) value
   5. (if active) error in value

   We ignore the first column and assume that we are only calling
   this function if the line has already been deduced to correspond
   to the parameter we represent.

Definition at line 205 of file _parameter.py.

◆ __repr__()

def __repr__ (   self)

Representation of this parameter.

Definition at line 284 of file _parameter.py.

◆ __str__()

def __str__ (   self)

Human printing of this parameter.

Definition at line 288 of file _parameter.py.

◆ active()

def active (   self)

True if Parameter is active (i.e.

floating) and False if not

Definition at line 143 of file _parameter.py.

◆ axial()

def axial (   self)

Get whether this Parameter represents a single axial sensor (True) or something else (False)

We have to check the name to see if 'axial' is in it.

Definition at line 111 of file _parameter.py.

◆ back()

def back (   self)

True if Parameter is single sensor in back half, False otherwise.

Definition at line 131 of file _parameter.py.

◆ bottom()

def bottom (   self)

True if Parameter is in bottom half, False if in top half.

Definition at line 107 of file _parameter.py.

◆ compact_value()

def compact_value (   self)

Print the value of this parameter as it should be inserted into the compact.

   **including** the operator (either + or -)

   This is where we handle whether the sign flips (translations) or doesn't (rotations)

Definition at line 269 of file _parameter.py.

◆ direction()

def direction (   self)

Definition at line 84 of file _parameter.py.

◆ float()

def float (   self,
  yes = True 
)

Set whether this parameter is floating/active or not.

Definition at line 50 of file _parameter.py.

◆ from_idn()

def from_idn (   idn)

Deduce the categorical flags from the ID number.

   Each ID number is five digis.
   In regex terms...

   [12][12][123][0-9][0-9]
    |             |- last two digis are sensor ID number
    |        |------ direction 1==u, 2==v, 3==w
    |    |---------- transformation 1==translation, 2==rotation
    |--------------- detector half 1==top, 2==bottom

   So we just need to break it down by modulo and integer
   division /OR/ do some str conversion nonsense in python.

Definition at line 155 of file _parameter.py.

◆ from_map_file_line()

def from_map_file_line (   line)
parse a line from the map file

we assume that the constructor's arguments are in the same
order as a line in the sensor map file

Definition at line 147 of file _parameter.py.

◆ front()

def front (   self)

True if Parameter is single sensor in front half, False otherwise.

Definition at line 127 of file _parameter.py.

◆ hole()

def hole (   self)

True if Parameter is a single sensor in back half on the hole side, Flase otherwise.

Definition at line 135 of file _parameter.py.

◆ id()

def id (   self)

Definition at line 81 of file _parameter.py.

◆ individual()

def individual (   self)

Get whether this Parameter represents a single sensor (True) or a structural component holding two or more sensors (False)

Definition at line 87 of file _parameter.py.

◆ layer()

def layer (   self)

Get the human layer number.

    Since, for the 2016 parameter mapping, a typo led to a dis-association between
    the module number deduced from the ID number and the layer number, we have
    to extract the layer number from the name of the parameter name as it appears
    in the mapping. We look for '_L<digit>' and extract <digit> as the layer number.

Definition at line 66 of file _parameter.py.

◆ module()

def module (   self)

Get the module number from the millepede layer number.

    We group sensors in pairs to form modules and the layer number
    for millepede counts up from the furthest upstream sensor. Thus,
    we do integer-division by two to get the module number.

Definition at line 54 of file _parameter.py.

◆ parse_map_file()

def parse_map_file (   map_filepath)

load the entire parameter set from a map file

   Returns
   -------
   dict
       map from ID number to a Parameter

Definition at line 187 of file _parameter.py.

◆ parse_pede_res()

def parse_pede_res (   res_file,
  destination = None,
  skip_nonfloat = False 
)

parse a pede results file

   Parse the results file into a dictionary. If no destination dictionary
   is provided, a new dictionary is created with the ID numbers as keys
   and Parameter instances as values. Since this mapping is created without
   the sensor mapping, the rest of the Parameter attributes are assigned
   non-sensical values.

   Parameters
   ----------
   res_file : str
       path to results file we are going to parse
   destination : dict, optional
       if provided, load the values from the file into parameters in this dict
   skip_nonfloat : bool, optional
       skip non-floating parameters

Definition at line 228 of file _parameter.py.

◆ pede_format()

def pede_format (   self)

Print this parameter as it should appear in the pede steering file.

Definition at line 265 of file _parameter.py.

◆ rotation()

def rotation (   self)

True if Parameter represents a rotation.

Definition at line 97 of file _parameter.py.

◆ slot()

def slot (   self)

True if Parameter is a single sensor in back half on the slot side, Flase otherwise.

Definition at line 139 of file _parameter.py.

◆ stereo()

def stereo (   self)

Get whether this Parameter represents a single stereo sensor (True) or something else (False)

We have to check the name to see if 'stereo' is in it.

Definition at line 119 of file _parameter.py.

◆ top()

def top (   self)

Does this parameter represent a component on the top half (True) or bottom (False)

Definition at line 101 of file _parameter.py.

◆ translation()

def translation (   self)

True if Parameter represents a translation.

Definition at line 93 of file _parameter.py.

Member Data Documentation

◆ _active

_active
private

Definition at line 48 of file _parameter.py.

◆ _direction

_direction
private

Definition at line 43 of file _parameter.py.

◆ _error

_error
private

Definition at line 47 of file _parameter.py.

◆ _half

_half
private

Definition at line 41 of file _parameter.py.

◆ _id

_id
private

Definition at line 39 of file _parameter.py.

◆ _mp_layer_id

_mp_layer_id
private

Definition at line 44 of file _parameter.py.

◆ _name

_name
private

Definition at line 40 of file _parameter.py.

◆ _trans_rot

_trans_rot
private

Definition at line 42 of file _parameter.py.

◆ _val

_val
private

Definition at line 46 of file _parameter.py.

◆ idn_str_pattern

idn_str_pattern = re.compile('^[12][123][123][0-9][0-9]$')
static

Definition at line 35 of file _parameter.py.

◆ layer_number_pattern

layer_number_pattern = re.compile('^.*_L([0-9]).*$')
static

Definition at line 36 of file _parameter.py.


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