thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.2.1
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 
21 namespace ThePEG {
22 
23 template <typename Value>
42 class Lorentz5Vector: public LorentzVector<Value> {
43 
44 public:
45 
47  using Value2 = decltype(sqr(std::declval<Value>()));
48 
49 public:
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 
58 public:
59 
65  Lorentz5Vector() : mm() {}
66 
70  Lorentz5Vector(Value m)
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 
91  Lorentz5Vector(const ThreeVector<Value> & p, Value e)
92  : LorentzVector<Value>(p, e) { rescaleMass(); }
93 
98  Lorentz5Vector(Value m, const ThreeVector<Value> & p)
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 
158  void rescaleEnergy() {
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 
265 private:
266 
268  Value mm;
269 
270 };
271 
273 template <typename OStream, typename T, typename UT>
274 void 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 
280 template <typename IStream, typename T, typename UT>
281 void 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 
291 template <typename ValueA, typename ValueB>
292 inline auto
293 operator*(const Lorentz5Vector<ValueA> & a, const Lorentz5Vector<ValueB> & b)
294 -> decltype(a.dot(b))
295 {
296  return a.dot(b);
297 }
298 
299 template <typename ValueA, typename ValueB>
300 inline auto
301 operator*(const LorentzVector<ValueA> & a, const Lorentz5Vector<ValueB> & b)
302 -> decltype(a.dot(b))
303 {
304  return a.dot(b);
305 }
306 
307 template <typename ValueA, typename ValueB>
308 inline auto
309 operator*(const Lorentz5Vector<ValueA> & a, const LorentzVector<ValueB> & b)
310 -> decltype(a.dot(b))
311 {
312  return a.dot(b);
313 }
314 
315 template <typename Value>
316 inline auto
317 operator*(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 */
A 4-component Lorentz vector.
Definition: LorentzVector.h:35
void setRho(Value newRho)
Set new radius.
Value m() const
Magnitude (signed) .
double massError() const
Return the relative inconsistency in the mass component.
auto dot(const LorentzVector< U > &a) const -> decltype(this->t() *a.t())
Dot product with metric .
Lorentz5Vector()
Constructor giving the null vector.
double energyError() const
Return the relative inconsistency in the energy component.
Value mm
The invariant mass/length member.
void ounitstream(OStream &os, const vector< T, Alloc > &v, UT &u)
Ouput a vector of objects with the specified unit.
Definition: Containers.h:275
LorentzVector< Value > & operator=(const LorentzVector< ValueB > &b)
Assignment operator.
Definition: LorentzVector.h:68
const SpinOneLorentzRotation & one() const
The spin-1 transformation.
A 3-component vector.
Definition: ThreeVector.h:34
The LorentzRotation class combine a SpinOneLorentzRotation and a spin SpinHalfLorentzRotation to prov...
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
double rhoError() const
Return the relative inconsistency in the spatial components.
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
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.
Lorentz5Vector(Value x, Value y, Value z, Value t=Value())
Constructor giving the components x, y, z, t.
Value2 tau2() const
Mass/invariant length component squared.
void iunitstream(IStream &is, vector< T, Alloc > &v, UT &u)
Input a vector of objects with the specified unit.
Definition: Containers.h:289
static bool pos()
Return true if the direction is positive.
Definition: Direction.h:113
Value dirPlus() const
Return the positive negative light-cone components (depending on the value of Direction<0>.
void rescaleRho()
Rescale spatial component, so that the invariant length/mass of the LorentzVector agrees with the cur...
Lorentz5Vector(const ThreeVector< Value > &p, Value t, Value tau)
Constructor giving a 3-Vector, a time component and an invariant length.
void setMass(Value a)
Set invariant length/mass.
Value plus() const
Returns the positive light-cone component .
double relativeError(FloatType x, FloatType y)
Returns (x - y)/(|x| + |y|).
Definition: Maths.h:80
Value mass() const
Mass/invariant length component.
Lorentz5Vector(Value m, const ThreeVector< Value > &p)
Constructor giving an invariant length and a 3-Vector component.
contains the LorentzVector class.
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
Lorentz5Vector(const Lorentz5Vector< U > &p)
Construct from value type U convertible to Value.
static bool neg()
Return true if the direction is negative (reversed).
Definition: Direction.h:120
decltype(sqr(std::declval< Length >())) Value2
Template argument typedef.
void rescaleMass()
Set the invariant length/mass member, so that it agrees with the invariant length/mass of the Lorentz...
Lorentz5Vector(const LorentzVector< Value > &p)
Copy from HepLorentzVector constructor.
void rescaleEnergy()
Rescale energy, so that the invariant length/mass of the LorentzVector agrees with the current one...
Value x() const
Component access.
The Lorentz5Vector inherits from the LorentzVector class.
Lorentz5Vector & transform(const LorentzRotation &r)
Perform a Lorentz transformation.
Value tau() const
Mass/invariant length component.
Lorentz5Vector(const LorentzVector< Value > &p, Value m)
Constructor giving a LorentzVector and an invariant length.
Lorentz5Vector & operator=(const LorentzVector< Value > &q)
Assignment.
Value dirMinus() const
Return the positive negative light-cone components (depending on the value of Direction<0>.
Value2 mass2() const
Mass/invariant length component squared.
void setTau(Value a)
Set invariant length/mass.
LorentzVector< Value > & transform(const SpinOneLorentzRotation &m)
Rotate the vector. Resets .
Lorentz5Vector(Value m)
Constructor giving the invariant length.
Value minus() const
Returns the negative light-cone component .
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