lloca.utils.rand_transforms
Random Lorentz transformations.
Functions
|
Determine whether the transformation is a boost or a rotation, based on the spacetime axes that are involved. |
|
Create a general pure boost, i.e. a symmetric Lorentz transformation. |
|
Create general Lorentz transformations as rotation * boost. |
|
Create rotation matrices embedded in Lorentz transformations. |
|
|
|
Create xy-plane rotation matrices embedded in the Lorentz group. |
|
Create Lorentz transformations consisting of a boost along the z-axis and a rotation around the z-axis. |
|
|
|
Sample rapidity from a clipped gaussian distribution. |
|
Recursively build transformation matrices based on given lists of axes and angles. |
- lloca.utils.rand_transforms.get_trafo_type(axis)[source]
Determine whether the transformation is a boost or a rotation, based on the spacetime axes that are involved.
- Parameters:
axis (torch.Tensor) – Axis of the transformation, should be of shape (2, …)
- Returns:
trafo_type – A boolean tensor indicating whether the transformation is a boost (1) or a rotation (0).
- Return type:
torch.Tensor
- lloca.utils.rand_transforms.rand_boost(shape, std_eta=0.1, n_max_std_eta=3.0, device='cpu', dtype=torch.float32, generator=None)[source]
Create a general pure boost, i.e. a symmetric Lorentz transformation.
- Parameters:
shape (torch.Size) – Shape of the transformation matrices
std_eta (float) – Standard deviation of rapidity
n_max_std_eta (float) – Allowed number of standard deviations; used to sample from a truncated Gaussian
device (str)
dtype (torch.dtype)
generator (torch.Generator)
- Returns:
final_trafo – The resulting Lorentz transformation matrices of shape (…, 4, 4).
- Return type:
torch.tensor
- lloca.utils.rand_transforms.rand_lorentz(shape, std_eta=0.1, n_max_std_eta=3.0, device='cpu', dtype=torch.float32, generator=None)[source]
Create general Lorentz transformations as rotation * boost. Any Lorentz transformation can be expressed in this way, see polar decomposition of the Lorentz group.
- Parameters:
shape (torch.Size) – Shape of the transformation matrices
std_eta (float) – Standard deviation of rapidity
n_max_std_eta (float) – Allowed number of standard deviations; used to sample from a truncated Gaussian
device (str)
dtype (torch.dtype)
generator (torch.Generator)
- Returns:
final_trafo – The resulting Lorentz transformation matrices of shape (…, 4, 4).
- Return type:
torch.tensor
- lloca.utils.rand_transforms.rand_rotation(shape, device='cpu', dtype=torch.float32, generator=None)[source]
Create rotation matrices embedded in Lorentz transformations. The rotations are sampled uniformly using quaternions, see https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation.
- Parameters:
shape (torch.Size) – Shape of the transformation matrices
device (str)
dtype (torch.dtype)
generator (torch.Generator)
- Returns:
final_trafo – The resulting Lorentz transformation matrices of shape (…, 4, 4).
- Return type:
torch.tensor
- lloca.utils.rand_transforms.rand_xyrotation(shape, device='cpu', dtype=torch.float32, generator=None)[source]
Create xy-plane rotation matrices embedded in the Lorentz group.
- Parameters:
shape (torch.Size) – Shape of the transformation matrices
device (str)
dtype (torch.dtype)
generator (torch.Generator)
- Returns:
final_trafo – The resulting Lorentz transformation matrices of shape (…, 4, 4).
- Return type:
torch.tensor
- lloca.utils.rand_transforms.rand_ztransform(shape, std_eta=0.1, n_max_std_eta=3.0, device='cpu', dtype=torch.float32, generator=None)[source]
Create Lorentz transformations consisting of a boost along the z-axis and a rotation around the z-axis. This transformation is common in LHC physics.
- Parameters:
shape (torch.Size) – Shape of the transformation matrices
std_eta (float) – Standard deviation of rapidity
n_max_std_eta (float) – Allowed number of standard deviations; used to sample from a truncated Gaussian
device (str)
dtype (torch.dtype)
generator (torch.Generator)
- Returns:
final_trafo – The resulting Lorentz transformation matrices of shape (…, 4, 4).
- Return type:
torch.tensor
- lloca.utils.rand_transforms.sample_rapidity(shape, std_eta=0.1, n_max_std_eta=3.0, device='cpu', dtype=torch.float32, generator=None)[source]
Sample rapidity from a clipped gaussian distribution.
- Parameters:
shape (torch.Size) – Shape of the output tensor
std_eta (float) – Standard deviation of the rapidity
n_max_std_eta (float) – Maximum number of standard deviations for truncation
device (str)
dtype (torch.dtype)
generator (torch.Generator)
- lloca.utils.rand_transforms.transform(axes, angles, use_float64=True)[source]
Recursively build transformation matrices based on given lists of axes and angles. This function is very flexible, but transformations built in this way suffer from numerical inaccuracies when many transformations are chained together.
- Parameters:
axes (list[int]) – List of axes along which the transformations are performed. Each element is a tensor of shape (2, …).
angles (list[torch.Tensor]) – List of angles used for the transformations. Each element is a tensor of shape (…,).
use_float64 (bool, optional) – Whether to use float64 for calculations, by default True
- Returns:
final_trafo – Final transformation matrix of shape (…, 4, 4).
- Return type:
torch.Tensor