Celeritas  0.5.0-56+6b053cd
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
celeritas::FourVector Struct Reference

The momentum-energy four-vector (Lorentz vector). More...

#include <FourVector.hh>

Public Types

using Energy = units::MevEnergy
 
using Momentum = units::MevMomentum
 
using Mass = units::MevMass
 

Public Member Functions

CELER_FUNCTION FourVectoroperator+= (FourVector const &v)
 In-place addition.
 

Static Public Member Functions

template<class PTV >
static CELER_FUNCTION FourVector from_particle (PTV const &particle, Real3 const &direction)
 Construct from a particle and direction.
 
static CELER_FUNCTION FourVector from_mass_momentum (Mass m, Momentum p, Real3 const &direction)
 Construct from rest mass, momentum, direction. More...
 

Public Attributes

Real3 mom {0, 0, 0}
 Particle momentum.
 
real_type energy {0}
 Particle total energy ( \(\sqrt{p^2 + m^2}\))
 

Detailed Description

The momentum-energy four-vector (Lorentz vector).

The units of this class are implicit: momentum is MevMomentum and energy is MevEnergy.

Member Function Documentation

◆ from_mass_momentum()

CELER_FUNCTION FourVector celeritas::FourVector::from_mass_momentum ( Mass  m,
Momentum  p,
Real3 const &  direction 
)
inlinestatic

Construct from rest mass, momentum, direction.

Note that this could be improved by using std::hypot which yields more accurate answers if the magnitudes of the momentum and mass are very different. However, differences in the implementation of that function can lead to differences across platforms, compilers, and architectures, so for now we use a naive sqrt+ipow.


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