pyg4ometry.gdml.Defines¶
Classes¶
Holds an expression as a string and can use the expression parser |
|
Common bits for a define. Must have a name and a registry. Adding |
|
Base class for all scalars (Constants, Quantity, Variable and 'Expression') |
|
GDML constant define wrapper object |
|
GDML quantity define wrapper object |
|
GDML variable define wrapper object |
|
General expression, does not have an analogue in GDML |
|
GDML position define wrapper object |
|
GDML rotation define wrapper object |
|
GDML scale define wrapper object |
|
GDML matrix define wrapper object |
|
Auxiliary information container object |
Functions¶
|
Take a float, str, ScalarBase and return string expression. |
|
|
|
Helper functions that takes a string and returns an expression object or a string |
|
Take a list [x,y,z] and create a vector |
|
Take a list of lists [[rx,ry,rz],[x,y,z]] and create a transformation [Rotation,Position] |
|
|
|
Sin of a ScalarBase object, returns a Constant |
|
Cosine of a ScalarBase object, returns a Constant |
|
Tangent of a ScalarBase object, returns a Constant |
|
ArcSin of a ScalarBase object, returns a Constant |
|
ArcCos of a ScalarBase object, returns a Constant |
|
ArcTan of a ScalarBase object, returns a Constant |
|
Exponential of a ScalarBase object, returns a Constant |
|
Natural logarithm of a ScalarBase object, returns a Constant |
|
Base 10 logarithm of a ScalarBase object, returns a Constant |
|
Square root of a ScalarBase object, returns a Constant |
|
arg raised to power |
|
absolute value of arg |
|
absolute value of arg |
|
absolute value of arg |
|
Creates a GDML Matrix from an energy and a value vector |
Module Contents¶
- class pyg4ometry.gdml.Defines.BasicExpression(name, expressionString, registry)¶
Holds an expression as a string and can use the expression parser in the supplied registry to evaluate it. A registry is required.
- Parameters:
name (str) – Name of the expression object
expressionString (str) – Expression itself as a string e.g. “12.0” or “a + 3.0”
registry (pyg4ometry.geant4.Registry.Registry) – The registry object to give context for any variables used.
>>> r = pyg4ometry.geant4.Registry() >>> a = BasicExpression("a", "3.0", r) >>> float(a) >>> str(a)
- name¶
- expressionString¶
- parseTree = None¶
- registry¶
- eval()¶
- variables(allDependents=False)¶
- simp()¶
- __repr__()¶
- __float__()¶
- str()¶
- pyg4ometry.gdml.Defines.upgradeToStringExpression(reg, obj)¶
Take a float, str, ScalarBase and return string expression.
- Parameters:
reg (Registry) – Registry for lookup in define dictionary
obj (str,float,ScalarBase) – Object to upgrade
- Returns:
String expression
- Return type:
- pyg4ometry.gdml.Defines.evaluateToFloat(reg, obj)¶
- pyg4ometry.gdml.Defines.upgradeToExpression(reg, obj)¶
Helper functions that takes a string and returns an expression object or a string
- pyg4ometry.gdml.Defines.upgradeToVector(var, reg, type='position', unit='', addRegistry=False)¶
Take a list [x,y,z] and create a vector
- pyg4ometry.gdml.Defines.upgradeToTransformation(var, reg, addRegistry=False)¶
Take a list of lists [[rx,ry,rz],[x,y,z]] and create a transformation [Rotation,Position]
- pyg4ometry.gdml.Defines.operationReturnType(name, strExpr, v1, v2, type1, type2, reg)¶
- class pyg4ometry.gdml.Defines.DefineBase(name='', registry=None)¶
Common bits for a define. Must have a name and a registry. Adding to the registry can’t be done here as it must be done by the derived type.
- name¶
- registry¶
- setRegistry(registry)¶
- class pyg4ometry.gdml.Defines.ScalarBase(typeName, name='', registry=None)¶
Bases:
DefineBaseBase class for all scalars (Constants, Quantity, Variable and ‘Expression’)
- expression = None¶
- _typeName¶
- setExpression(expressionString)¶
Take a string and make it into the BasicExpression type for this object.
- Parameters:
expressionString (str) – Expression to store.
- setRegistry(registry)¶
- __repr__()¶
- __float__()¶
- __add__(other)¶
- __sub__(other)¶
- __rsub__(other)¶
- __mul__(other)¶
- __truediv__(other)¶
- __rtruediv__(other)¶
- __neg__()¶
- __abs__()¶
- __pow__(power)¶
- __radd__¶
- __rmul__¶
- pyg4ometry.gdml.Defines.sin(arg)¶
Sin of a ScalarBase object, returns a Constant
- Parameters:
arg (Constant, Quantity, Variable or Expression) – Argument of sin
- pyg4ometry.gdml.Defines.cos(arg)¶
Cosine of a ScalarBase object, returns a Constant
- Parameters:
arg (Constant, Quantity, Variable or Expression) – Argument of cos
- pyg4ometry.gdml.Defines.tan(arg)¶
Tangent of a ScalarBase object, returns a Constant
- Parameters:
arg (Constant, Quantity, Variable or Expression) – Argument of tan
- pyg4ometry.gdml.Defines.asin(arg)¶
ArcSin of a ScalarBase object, returns a Constant
- Parameters:
arg (Constant, Quantity, Variable or Expression) – Argument of asin
- pyg4ometry.gdml.Defines.acos(arg)¶
ArcCos of a ScalarBase object, returns a Constant
- Parameters:
arg (Constant, Quantity, Variable or Expression) – Argument of acos
- pyg4ometry.gdml.Defines.atan(arg)¶
ArcTan of a ScalarBase object, returns a Constant
- Parameters:
arg (Constant, Quantity, Variable or Expression) – Argument of tan
- pyg4ometry.gdml.Defines.exp(arg)¶
Exponential of a ScalarBase object, returns a Constant
- Parameters:
arg (Constant, Quantity, Variable or Expression) – Argument of exp
- pyg4ometry.gdml.Defines.log(arg)¶
Natural logarithm of a ScalarBase object, returns a Constant
- Parameters:
arg (Constant, Quantity, Variable or Expression) – Argument of log
- pyg4ometry.gdml.Defines.log10(arg)¶
Base 10 logarithm of a ScalarBase object, returns a Constant
- Parameters:
arg (Constant, Quantity, Variable or Expression) – Argument of log10
- pyg4ometry.gdml.Defines.sqrt(arg)¶
Square root of a ScalarBase object, returns a Constant
- Parameters:
arg (Constant, Quantity, Variable or Expression) – Argument of sin
- pyg4ometry.gdml.Defines.pow(arg, power)¶
arg raised to power
- Parameters:
arg (Constant, Quantity, Variable or Expression) – Argument of x**y
power (float) – y
- pyg4ometry.gdml.Defines.abs(arg)¶
absolute value of arg
- Parameters:
arg (Constant, Quantity, Variable or Expression) – Argument of abs(arg)
- pyg4ometry.gdml.Defines.min(arg1, arg2)¶
absolute value of arg
- Parameters:
arg (Constant, Quantity, Variable or Expression) – Argument of abs(arg)
- pyg4ometry.gdml.Defines.max(arg1, arg2)¶
absolute value of arg
- Parameters:
arg (Constant, Quantity, Variable or Expression) – Argument of abs(arg)
- class pyg4ometry.gdml.Defines.Constant(name, value, registry, addRegistry=True)¶
Bases:
ScalarBaseGDML constant define wrapper object
- Parameters:
- expression¶
- __eq__(other)¶
- __ne__(other)¶
- __lt__(other)¶
- __gt__(other)¶
- __le__(other)¶
- __ge__(other)¶
- class pyg4ometry.gdml.Defines.Quantity(name, value, unit, type, registry, addRegistry=True)¶
Bases:
ScalarBaseGDML quantity define wrapper object
- Parameters:
- unit¶
- type¶
- expression¶
- __repr__()¶
- class pyg4ometry.gdml.Defines.Variable(name, value, registry, addRegistry=True)¶
Bases:
ScalarBaseGDML variable define wrapper object
- Parameters:
- expression¶
- class pyg4ometry.gdml.Defines.Expression(name, value, registry, addRegistry=False)¶
Bases:
ScalarBaseGeneral expression, does not have an analogue in GDML
- Parameters:
- expression¶
- __int__()¶
- class pyg4ometry.gdml.Defines.VectorBase(typeName, name, registry)¶
- _typeName¶
- name¶
- registry¶
- x = None¶
- y = None¶
- z = None¶
- unit = None¶
- __repr__()¶
- __add__(other)¶
- __sub__(other)¶
- __mul__(other)¶
- __rmul__¶
- __truediv__(other)¶
- nonzero()¶
Evaluate vector
- Returns:
Check if the vector is trivial (all elements zero)
- Return type:
- __getitem__(key)¶
- setRegistry(registry)¶
- class pyg4ometry.gdml.Defines.Position(name, x, y, z, unit='mm', registry=None, addRegistry=True)¶
Bases:
VectorBaseGDML position define wrapper object
- Parameters:
- x¶
- y¶
- z¶
- class pyg4ometry.gdml.Defines.Rotation(name, rx, ry, rz, unit='rad', registry=None, addRegistry=True)¶
Bases:
VectorBaseGDML rotation define wrapper object
- Parameters:
- x¶
- y¶
- z¶
- class pyg4ometry.gdml.Defines.Scale(name, sx, sy, sz, unit=None, registry=None, addRegistry=True)¶
Bases:
VectorBaseGDML scale define wrapper object
- Parameters:
- x¶
- y¶
- z¶
- class pyg4ometry.gdml.Defines.Matrix(name, coldim, values, registry=None, addRegistry=True)¶
GDML matrix define wrapper object
- Parameters:
- name¶
- coldim¶
- registry¶
- values = []¶
- values_asarray¶
- eval()¶
Evaluate matrix
- Returns:
numerical evaluation of matrix
- Return type:
numpy.array
- __repr__()¶
- __getitem__(key)¶
- pyg4ometry.gdml.Defines.MatrixFromVectors(e, v, name, registry, eunit='eV', vunit='')¶
Creates a GDML Matrix from an energy and a value vector
- Parameters:
name (str) – of matrix of registry
e (list or numpy.array - shape (1,)) – energy list/vector in units of eunit
v (list or numpy.array - shape (1,)) – value list/vector in units of vunit
registry (Registry) – for storing define
eunit (str) – unit for the energy vector (default: eV)
vunit (str) – unit for the value vector (default: unitless)
- class pyg4ometry.gdml.Defines.Auxiliary(auxtype, auxvalue, registry=None, unit='', addRegistry=True)¶
Auxiliary information container object
- auxtype¶
- auxvalue¶
- auxunit¶
- subaux = []¶
- registry¶
- addSubAuxiliary(aux)¶
Add a sub-auxiliary inside the scope of the current auxiliary
- Parameters:
aux (object, gdml.Defines.Auxiliary) – auxiliary definition