#include <fourvector.h>
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
The overloaded operators are built according to Andrew Koenig recommendations where the compound assignment operators is used as a base for their non-compound counterparts. This means that the operator + is implemented in terms of +=. The operator+ returns a copy of its result. + and friends are non-members, while the compound assignment counterparts, changing the left argument, are a member of the FourVector class.
Definition at line 33 of file fourvector.h.
Public Types | |
| using | iterator = std::array< double, 4 >::iterator |
| iterates over the components More... | |
| using | const_iterator = std::array< double, 4 >::const_iterator |
| iterates over the components More... | |
Public Member Functions | |
| FourVector () | |
| default constructor nulls the fourvector components More... | |
| FourVector (double y0, double y1, double y2, double y3) | |
| copy constructor More... | |
| FourVector (double y0, ThreeVector vec) | |
| construct from time-like component and a ThreeVector. More... | |
| double & | operator[] (std::size_t i) |
access the component at offset i. More... | |
| double | operator[] (std::size_t i) const |
| const overload of the [] operator More... | |
| double | x0 () const |
| void | set_x0 (double t) |
| double | x1 () const |
| void | set_x1 (double x) |
| double | x2 () const |
| void | set_x2 (double y) |
| double | x3 () const |
| void | set_x3 (double z) |
| ThreeVector | threevec () const |
| void | reset () |
| Set all the 4-vector components to 0. More... | |
| ThreeVector | velocity () const |
| Get the velocity (3-vector divided by zero component). More... | |
| double | Dot (const FourVector &a) const |
| calculate the scalar product with another four-vector More... | |
| double | sqr () const |
| calculate the square of the vector (which is a scalar) More... | |
| double | abs () const |
| calculate the lorentz invariant absolute value More... | |
| double | sqr3 () const |
| calculate the square of the spatial three-vector More... | |
| double | abs3 () const |
| calculate the absolute value of the spatial three-vector More... | |
| double | tau () const |
| calculate the proper time from the given four vector More... | |
| double | eta () const |
| calculate the space-time rapidity from the given four vector More... | |
| FourVector | lorentz_boost (const ThreeVector &v) const |
| Returns the FourVector boosted with velocity v. More... | |
| bool | operator== (const FourVector &a) const |
| Check if all four vector components are almost equal (accuracy \(10^{-4}\)). More... | |
| bool | operator!= (const FourVector &a) const |
| checks inequality (logical complement to FourVector::operator==(const FourVector&) const) More... | |
| bool | operator< (const FourVector &a) const |
| checks if \(x^\mu < a^\mu\) for all \(\mu\) (all four vector components are below comparison vector) More... | |
| bool | operator> (const FourVector &a) const |
| checks if \(x^\mu > a^\mu\) for all \(\mu\) (all four vector components are above comparison vector) More... | |
| bool | operator<= (const FourVector &a) const |
| logical complement to FourVector::operator>(const FourVector&) const More... | |
| bool | operator>= (const FourVector &a) const |
| logical complement to FourVector::operator<(const FourVector&) const More... | |
| FourVector | operator+= (const FourVector &a) |
| adds \(a_\mu: x_\mu^\prime = x_\mu + a_\mu\) More... | |
| FourVector | operator-= (const FourVector &a) |
| subtracts \(a_\mu: x_\mu^\prime = x_\mu - a_\mu\) More... | |
| FourVector | operator*= (const double &a) |
| multiplies by \(a: x_\mu^\prime = a \cdot x_\mu\) More... | |
| FourVector | operator/= (const double &a) |
| divides by \(a: x_\mu^\prime = \frac{1}{a} \cdot x_\mu\) More... | |
| iterator | begin () |
| iterator | end () |
| const_iterator | begin () const |
| const_iterator | end () const |
| const_iterator | cbegin () const |
| const_iterator | cend () const |
Private Attributes | |
| std::array< double, 4 > | x_ |
| internal storage of this vector's components More... | |
| using smash::FourVector::iterator = std::array<double, 4>::iterator |
iterates over the components
Definition at line 281 of file fourvector.h.
| using smash::FourVector::const_iterator = std::array<double, 4>::const_iterator |
iterates over the components
Definition at line 283 of file fourvector.h.
|
inline |
default constructor nulls the fourvector components
Definition at line 36 of file fourvector.h.
|
inline |
copy constructor
| [in] | y0 | The time component to be copied |
| [in] | y1 | The x component to be copied |
| [in] | y2 | The y component to be copied |
| [in] | y3 | the z component to be copied |
Definition at line 46 of file fourvector.h.
|
inline |
construct from time-like component and a ThreeVector.
| [in] | y0 | The time component to be used |
| [in] | vec | A ThreeVector (x,y,z) to be used |
Definition at line 55 of file fourvector.h.
|
inline |
access the component at offset i.
This operator results in the same as using the x0()...x3() functions
| [in] | i | the index of the component to access (has to be 0,1,2 or 3) |
Definition at line 65 of file fourvector.h.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 329 of file fourvector.h.
|
inline |
|
inline |
Get the velocity (3-vector divided by zero component).
Should only be used with momentum 4-vectors (not with space-time ones).
Definition at line 333 of file fourvector.h.
|
inline |
calculate the scalar product with another four-vector
| [in] | a | the FourVector to dot product with *this |
Definition at line 456 of file fourvector.h.
|
inline |
|
inline |
calculate the lorentz invariant absolute value
Note that this will fail for space-like vectors.
Definition at line 464 of file fourvector.h.
|
inline |
calculate the square of the spatial three-vector
Definition at line 474 of file fourvector.h.
|
inline |
calculate the absolute value of the spatial three-vector
Definition at line 476 of file fourvector.h.
|
inline |
calculate the proper time from the given four vector
Definition at line 478 of file fourvector.h.
|
inline |
calculate the space-time rapidity from the given four vector
Definition at line 482 of file fourvector.h.
| FourVector smash::FourVector::lorentz_boost | ( | const ThreeVector & | v | ) | const |
Returns the FourVector boosted with velocity v.
The current FourVector is not changed.
| [in] | v | ( \(\mathbf{v}\) in the explanation below) is a ThreeVector representing the boost velocity |
Notation:
The gamma factor is \(\gamma = 1/\sqrt{1-\mathbf{v}^2}\).
The time-like component of a Lorentz-boosted FourVector \(x^\mu = (x_0, x_1, x_2, x_3) = (x_0, \mathbf{r})\) with velocity \(\mathbf{v}\) is
\begin{eqnarray*} x^\prime_0 = \gamma \cdot (x_0 - \mathbf{r}\cdot\mathbf{v})\;, \end{eqnarray*}
and the space-like components i = 1, 2, 3 are:
\begin{eqnarray*} x^\prime_i &=& x_i + v_i \cdot \Bigl(\frac{\gamma - 1}{\mathbf{v}^2} \cdot \mathbf{r}\cdot\mathbf{v} - \gamma \cdot x_0\Bigr)\\ &=& x_i + v_i \cdot \Bigl(\frac{\gamma^2}{\gamma + 1} \cdot \mathbf{r}\cdot\mathbf{v} - \gamma \cdot x_0\Bigr)\\ &=& x_i - v_i \cdot \frac{\gamma}{\gamma + 1} \cdot \bigl[\gamma\,(x_0 - \mathbf{r}\cdot\mathbf{v})+x_0\bigr]\\ &=& x_i - v_i \cdot \frac{\gamma}{\gamma + 1} \cdot (x^\prime_0 + x^{\vphantom{\prime}}_0) \end{eqnarray*}
Note: This function is equivalent to -velocity Boost from ROOT
Definition at line 17 of file fourvector.cc.
| bool smash::FourVector::operator== | ( | const FourVector & | a | ) | const |
Check if all four vector components are almost equal (accuracy \(10^{-4}\)).
| [in] | a | The FourVector to compare to |
Definition at line 30 of file fourvector.cc.
|
inline |
checks inequality (logical complement to FourVector::operator==(const FourVector&) const)
| [in] | a | The FourVector to compare to |
Definition at line 336 of file fourvector.h.
|
inline |
checks if \(x^\mu < a^\mu\) for all \(\mu\) (all four vector components are below comparison vector)
| [in] | a | The FourVector to compare to |
Definition at line 340 of file fourvector.h.
|
inline |
checks if \(x^\mu > a^\mu\) for all \(\mu\) (all four vector components are above comparison vector)
| [in] | a | The FourVector to compare to |
Definition at line 346 of file fourvector.h.
|
inline |
logical complement to FourVector::operator>(const FourVector&) const
| [in] | a | The FourVector to compare to |
Definition at line 351 of file fourvector.h.
|
inline |
logical complement to FourVector::operator<(const FourVector&) const
| [in] | a | The FourVector to compare to |
Definition at line 356 of file fourvector.h.
|
inline |
adds \(a_\mu: x_\mu^\prime = x_\mu + a_\mu\)
| [in] | a | The FourVector to add |
Definition at line 360 of file fourvector.h.
|
inline |
subtracts \(a_\mu: x_\mu^\prime = x_\mu - a_\mu\)
| [in] | a | The FourVector to subtract |
Definition at line 381 of file fourvector.h.
|
inline |
multiplies by \(a: x_\mu^\prime = a \cdot x_\mu\)
| [in] | a | The value with which to multiply |
Definition at line 402 of file fourvector.h.
|
inline |
divides by \(a: x_\mu^\prime = \frac{1}{a} \cdot x_\mu\)
| [in] | a | The value by which to divide |
Definition at line 434 of file fourvector.h.
|
inline |
The iterator implements the randomIterator concept. Thus, you can simply write begin() + 1 to get an iterator that points to the 1st component.
Definition at line 291 of file fourvector.h.
|
inline |
|
inline |
|
inline |
Definition at line 299 of file fourvector.h.
|
inline |
|
inline |
|
private |
internal storage of this vector's components
Definition at line 308 of file fourvector.h.