YAP
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LorentzTransformation.h
Go to the documentation of this file.
1 /* YAP - Yet another PWA toolkit
2  Copyright 2015, Technische Universitaet Muenchen,
3  Authors: Daniel Greenwald, Johannes Rauch
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
20 
21 #ifndef yap_LorentzTransformation_h
22 #define yap_LorentzTransformation_h
23 
24 #include "Matrix.h"
25 #include "FourVector.h"
26 #include "ThreeVector.h"
27 
28 #include <algorithm>
29 
30 namespace yap {
31 
34 template <typename T>
35 const FourMatrix<T> lorentzTransformation(const ThreeMatrix<T>& R)
36 {
37  FourMatrix<T> L = unitMatrix<T, 4>();
38  for (unsigned i = 0; i < R.size(); ++i)
39  std::copy(R[i].begin(), R[i].end(), L[i + 1].begin() + 1);
40  return L;
41 }
42 
45 template <typename T>
46 const FourMatrix<T> lorentzTransformation(const FourVector<T>& V)
47 {
48  auto gamma = V[0] / abs(V); // E / m
49  auto b = FourVector<T>((gamma + 1), gamma * vect(V) / V[0]) / sqrt(gamma + 1); // vect(V)/V[0] = beta
50 
51  return diagonalMatrix<T, 4>({ -1, 1, 1, 1}) + outer(b, b);
52 }
53 
56 template <typename T>
57 constexpr FourMatrix<T> lorentzTransformation(const ThreeVector<T>& V)
58 { return lorentzTransformation<T>(FourVector<T>(T(1), V)); }
59 
62 template <typename T>
63 constexpr FourMatrix<T> lorentzTransformation(const std::vector<FourVector<T> >& fourVecs)
64 { return lorentzTransformation(std::accumulate(fourVecs.begin(), fourVecs.end(), FourVector<T>({0, 0, 0, 0}))); }
65 
69 template <typename T>
70 constexpr FourMatrix<T> lorentzTransformation(const ThreeMatrix<T>& R, const FourVector<T>& V)
71 { return lorentzTransformation<T>(V) * lorentzTransformation<T>(R); }
72 
76 template <typename T>
77 constexpr FourMatrix<T> lorentzTransformation(const ThreeMatrix<T>& R, const ThreeVector<T>& V)
78 { return lorentzTransformation<T>(V) * lorentzTransformation<T>(R); }
79 
83 template <typename T>
84 constexpr FourMatrix<T> lorentzTransformation(const FourVector<T>& V, const ThreeMatrix<T> R)
85 { return lorentzTransformation<T>(R) * lorentzTransformation<T>(V); }
86 
90 template <typename T>
91 constexpr FourMatrix<T> lorentzTransformation(const ThreeVector<T>& V, const ThreeMatrix<T>& R)
92 { return lorentzTransformation<T>(R) * lorentzTransformation<T>(V); }
93 
94 }
95 #endif
Four-Vector handling.
Definition: FourVector.h:41
constexpr ThreeVector< T > vect(const FourVector< T > &V) noexcept
Definition: FourVector.h:68
constexpr T abs(const Vector< T, N > &A)
Definition: Vector.h:371
const SquareMatrix< T, N > outer(const Vector< T, N > &A, const Vector< T, N > &B)
outer product
Definition: Vector.h:405
const FourMatrix< T > lorentzTransformation(const ThreeMatrix< T > &R)
Definition: LorentzTransformation.h:35