HPS-MC
 
Loading...
Searching...
No Matches
Parameter Class Reference

Representation of a single alignment parameter. More...

Public Member Functions

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

Static Public Attributes

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

Protected Attributes

 _id
 
 _name
 
 _half
 
 _trans_rot
 
 _direction
 
 _mp_layer_id
 
 _val
 
 _error
 
 _active
 

Private Member Functions

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

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

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

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

__repr__ (   self)

Representation of this parameter.

Definition at line 284 of file _parameter.py.

◆ __str__()

__str__ (   self)

Human printing of this parameter.

Definition at line 288 of file _parameter.py.

◆ active()

active (   self)

True if Parameter is active (i.e.

floating) and False if not

Definition at line 143 of file _parameter.py.

◆ axial()

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

back (   self)

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

Definition at line 131 of file _parameter.py.

◆ bottom()

bottom (   self)

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

Definition at line 107 of file _parameter.py.

◆ compact_value()

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

direction (   self)

Definition at line 84 of file _parameter.py.

◆ float()

float (   self,
  yes = True 
)

Set whether this parameter is floating/active or not.

Definition at line 50 of file _parameter.py.

◆ from_idn()

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

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

front (   self)

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

Definition at line 127 of file _parameter.py.

◆ hole()

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

id (   self)

Definition at line 81 of file _parameter.py.

◆ individual()

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

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

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

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

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

pede_format (   self)

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

Definition at line 265 of file _parameter.py.

◆ rotation()

rotation (   self)

True if Parameter represents a rotation.

Definition at line 97 of file _parameter.py.

◆ slot()

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

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

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

translation (   self)

True if Parameter represents a translation.

Definition at line 93 of file _parameter.py.

Member Data Documentation

◆ _active

_active
protected

Definition at line 48 of file _parameter.py.

◆ _direction

_direction
protected

Definition at line 43 of file _parameter.py.

◆ _error

_error
protected

Definition at line 47 of file _parameter.py.

◆ _half

_half
protected

Definition at line 41 of file _parameter.py.

◆ _id

_id
protected

Definition at line 39 of file _parameter.py.

◆ _mp_layer_id

_mp_layer_id
protected

Definition at line 44 of file _parameter.py.

◆ _name

_name
protected

Definition at line 40 of file _parameter.py.

◆ _trans_rot

_trans_rot
protected

Definition at line 42 of file _parameter.py.

◆ _val

_val
protected

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: