thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
Lorentz5Vector.h
1// -*- C++ -*-
2//
3// Lorentz5Vector.h is a part of ThePEG - Toolkit for HEP Event Generation
4// Copyright (C) 1999-2019 Leif Lonnblad
5//
6// ThePEG is licenced under version 3 of the GPL, see COPYING for details.
7// Please respect the MCnet academic guidelines, see GUIDELINES for details.
8//
9#ifndef ThePEG_Lorentz5Vector_H
10#define ThePEG_Lorentz5Vector_H
11
12// This is the declaration of the Lorentz5vector class.
13
14#include "LorentzVector.h"
15#include "Lorentz5Vector.fh"
16#include "ThePEG/Utilities/Maths.h"
17#include "ThePEG/Utilities/Direction.h"
18#include "ThePEG/Utilities/UnitIO.h"
19#include "LorentzRotation.h"
20
21namespace ThePEG {
22
23template <typename Value>
42class Lorentz5Vector: public LorentzVector<Value> {
43
44public:
45
47 using Value2 = decltype(sqr(std::declval<Value>()));
48
49public:
51
52 Value x() const { return LorentzVector<Value>::x(); }
53 Value y() const { return LorentzVector<Value>::y(); }
54 Value z() const { return LorentzVector<Value>::z(); }
55 Value t() const { return LorentzVector<Value>::t(); }
57
58public:
59
66
71 : LorentzVector<Value>(Value(), Value(), Value(), m), mm(m) {}
72
77 Lorentz5Vector(Value x, Value y, Value z, Value t = Value())
78 : LorentzVector<Value>(x, y, z, t) { rescaleMass(); }
79
84 Lorentz5Vector(Value x, Value y, Value z, Value t, Value tau)
85 : LorentzVector<Value>(x, y, z, t), mm(tau) {}
86
92 : LorentzVector<Value>(p, e) { rescaleMass(); }
93
99 : LorentzVector<Value>(p, sqrt(p.mag2() + m*m)), mm(m) {}
100
105 Lorentz5Vector(const ThreeVector<Value> & p, Value t, Value tau)
106 : LorentzVector<Value>(p, t), mm(tau) {}
107
113 : LorentzVector<Value>(p), mm(m) {}
114
120 : LorentzVector<Value>(p) { rescaleMass(); }
121
125 template<class U>
127 : LorentzVector<Value>(p), mm(p.m) {}
129
135 void setTau(Value a) { mm = a; }
136
140 void setMass(Value a) { mm = a; }
141
148 return *this;
149 }
151
160 }
161
166 void rescaleRho() {
167 LorentzVector<Value>::setRho(sqrt(t()*t() - mass2()));
168 }
169
174 void rescaleMass() {
176 }
178
184 double massError() const {
185 return sqrt(abs(Math::relativeError(mass2(),
187 }
188
192 double energyError() const {
193 return sqrt(abs(Math::relativeError(t()*t(), mass2()
194 + LorentzVector<Value>::vect().mag2())));
195 }
196
200 double rhoError() const {
201 return sqrt(abs(Math::relativeError(LorentzVector<Value>::vect().mag2(),
202 t()*t() - mass2())));
203 }
205
212 Value2 mass2() const { return mm > Value() ? mm*mm: -mm*mm; }
213
218 Value2 tau2() const { return mass2(); }
219
224 Value mass() const { return mm; }
225
226
231 Value tau() const { return mass(); }
232
237 Value dirPlus() const {
238 return Direction<0>::pos() ?
240 :
242 }
243
248 Value dirMinus() const {
249 return Direction<0>::neg() ?
251 :
253 }
255
260 {
262 return *this;
263 }
264
265private:
266
268 Value mm;
269
270};
271
273template <typename OStream, typename T, typename UT>
274void ounitstream(OStream & os, const Lorentz5Vector<T> & p, UT & u) {
275 os << ounit(p.x(), u) << ounit(p.y(), u) << ounit(p.z(), u)
276 << ounit(p.e(), u) << ounit(p.mass(), u);
277}
278
280template <typename IStream, typename T, typename UT>
281void iunitstream(IStream & is, Lorentz5Vector<T> & p, UT & u) {
282 T x, y, z, e, mass;
283 is >> iunit(x, u) >> iunit(y, u) >> iunit(z, u) >> iunit(e, u)
284 >> iunit(mass, u);
285 p = Lorentz5Vector<T>(x, y, z, e, mass);
286}
287
288
290
291template <typename ValueA, typename ValueB>
292inline auto
293operator*(const Lorentz5Vector<ValueA> & a, const Lorentz5Vector<ValueB> & b)
294-> decltype(a.dot(b))
295{
296 return a.dot(b);
297}
298
299template <typename ValueA, typename ValueB>
300inline auto
301operator*(const LorentzVector<ValueA> & a, const Lorentz5Vector<ValueB> & b)
302-> decltype(a.dot(b))
303{
304 return a.dot(b);
305}
306
307template <typename ValueA, typename ValueB>
308inline auto
309operator*(const Lorentz5Vector<ValueA> & a, const LorentzVector<ValueB> & b)
310-> decltype(a.dot(b))
311{
312 return a.dot(b);
313}
314
315template <typename Value>
316inline auto
317operator*(const Lorentz5Vector<Value> & a, const Lorentz5Vector<Value> & b)
318-> decltype(a.dot(b))
319{
320 return a.dot(b);
321}
323}
324
325#endif /* ThePEG_Particle_H */
contains the LorentzVector class.
static bool neg()
Return true if the direction is negative (reversed).
Definition: Direction.h:120
static bool pos()
Return true if the direction is positive.
Definition: Direction.h:113
The Lorentz5Vector inherits from the LorentzVector class.
Value2 mass2() const
Mass/invariant length component squared.
Lorentz5Vector(Value x, Value y, Value z, Value t=Value())
Constructor giving the components x, y, z, t.
double rhoError() const
Return the relative inconsistency in the spatial components.
void setMass(Value a)
Set invariant length/mass.
void rescaleRho()
Rescale spatial component, so that the invariant length/mass of the LorentzVector agrees with the cur...
Lorentz5Vector(Value m)
Constructor giving the invariant length.
Value x() const
Component access.
double energyError() const
Return the relative inconsistency in the energy component.
Value2 tau2() const
Mass/invariant length component squared.
Value mm
The invariant mass/length member.
Lorentz5Vector & transform(const LorentzRotation &r)
Perform a Lorentz transformation.
Value dirMinus() const
Return the positive negative light-cone components (depending on the value of Direction<0>.
Value mass() const
Mass/invariant length component.
Lorentz5Vector & operator=(const LorentzVector< Value > &q)
Assignment.
Lorentz5Vector(const LorentzVector< Value > &p, Value m)
Constructor giving a LorentzVector and an invariant length.
Value tau() const
Mass/invariant length component.
void rescaleEnergy()
Rescale energy, so that the invariant length/mass of the LorentzVector agrees with the current one.
Lorentz5Vector(const Lorentz5Vector< U > &p)
Construct from value type U convertible to Value.
void rescaleMass()
Set the invariant length/mass member, so that it agrees with the invariant length/mass of the Lorentz...
decltype(sqr(std::declval< Value >())) Value2
Template argument typedef.
Value dirPlus() const
Return the positive negative light-cone components (depending on the value of Direction<0>.
Lorentz5Vector(const LorentzVector< Value > &p)
Copy from HepLorentzVector constructor.
Lorentz5Vector(const ThreeVector< Value > &p, Value t, Value tau)
Constructor giving a 3-Vector, a time component and an invariant length.
Lorentz5Vector()
Constructor giving the null vector.
double massError() const
Return the relative inconsistency in the mass component.
Lorentz5Vector(Value m, const ThreeVector< Value > &p)
Constructor giving an invariant length and a 3-Vector component.
Lorentz5Vector(const ThreeVector< Value > &p, Value e)
Constructor giving a 3-Vector and a time component.
Lorentz5Vector(Value x, Value y, Value z, Value t, Value tau)
Constructor giving the components x, y, z, t and invariant length.
void setTau(Value a)
Set invariant length/mass.
The LorentzRotation class combine a SpinOneLorentzRotation and a spin SpinHalfLorentzRotation to prov...
const SpinOneLorentzRotation & one() const
The spin-1 transformation.
A 4-component Lorentz vector.
Definition: LorentzVector.h:44
Value m() const
Magnitude (signed) .
LorentzVector< Value > & operator=(const LorentzVector< ValueB > &b)
Assignment operator.
Definition: LorentzVector.h:68
Value plus() const
Returns the positive light-cone component .
Value minus() const
Returns the negative light-cone component .
LorentzVector< Value > & transform(const SpinOneLorentzRotation &m)
Rotate the vector. Resets .
void setRho(Value newRho)
Set new radius.
A 3-component vector.
Definition: ThreeVector.h:35
double relativeError(FloatType x, FloatType y)
Returns (x - y)/(|x| + |y|).
Definition: Maths.h:80
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
IUnit< T, UT > iunit(T &t, const UT &ut)
Helper function creating a IUnit object given an object and a unit.
Definition: UnitIO.h:91
void iunitstream(IStream &is, vector< T, Alloc > &v, UT &u)
Input a vector of objects with the specified unit.
Definition: Containers.h:289
void ounitstream(OStream &os, const vector< T, Alloc > &v, UT &u)
Ouput a vector of objects with the specified unit.
Definition: Containers.h:275
constexpr auto sqr(const T &x) -> decltype(x *x)
The square function should really have been included in the standard C++ library.
Definition: ThePEG.h:117
OUnit< T, UT > ounit(const T &t, const UT &ut)
Helper function creating a OUnit object given an object and a unit.
Definition: UnitIO.h:84