thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.1.5
Lorentz5Vector.h
1 // -*- C++ -*-
2 //
3 // Lorentz5Vector.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2017 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 
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 template <typename T, typename U>
289 struct BinaryOpTraits;
290 
294 template <typename T>
295 struct BinaryOpTraits<Lorentz5Vector<T>, double> {
302 };
303 
307 template <typename U>
308 struct BinaryOpTraits<double, Lorentz5Vector<U> > {
312 };
313 
317 template <typename T, typename U>
318 struct BinaryOpTraits<Lorentz5Vector<T>, std::complex<U> > {
325 };
326 
330 template <typename T, typename U>
331 struct BinaryOpTraits<std::complex<T>, Lorentz5Vector<U> > {
335 };
336 
340 template <typename T, typename U>
344  typedef typename BinaryOpTraits<T,U>::MulT MulT;
345 };
346 
350 template <typename T, typename U>
354  typedef typename BinaryOpTraits<T,U>::MulT MulT;
355 };
356 
360 template <typename T, typename U>
364  typedef typename BinaryOpTraits<T,U>::MulT MulT;
365 };
366 
368 
369 template <typename ValueA, typename ValueB>
371 operator*(const Lorentz5Vector<ValueA> & a, const Lorentz5Vector<ValueB> & b) {
372  return a.dot(b);
373 }
374 
375 template <typename ValueA, typename ValueB>
377 operator*(const LorentzVector<ValueA> & a, const Lorentz5Vector<ValueB> & b) {
378  return a.dot(b);
379 }
380 
381 template <typename ValueA, typename ValueB>
383 operator*(const Lorentz5Vector<ValueA> & a, const LorentzVector<ValueB> & b) {
384  return a.dot(b);
385 }
386 
387 template <typename Value>
388 inline typename BinaryOpTraits<Value,Value>::MulT
389 operator*(const Lorentz5Vector<Value> & a, const Lorentz5Vector<Value> & b) {
390  return a.dot(b);
391 }
393 }
394 
395 #endif /* ThePEG_Particle_H */
A 4-component Lorentz vector.
Definition: LorentzVector.h:35
BinaryOpTraits< Value, U >::MulT dot(const LorentzVector< U > &a) const
Dot product with metric .
void setRho(Value newRho)
Set new radius.
Value m() const
Magnitude (signed) .
double massError() const
Return the relative inconsistency in the mass component.
Lorentz5Vector()
Constructor giving the null vector.
double energyError() const
Return the relative inconsistency in the energy component.
Value mm
The invariant mass/length member.
Lorentz5Vector< U > MulT
The type resulting from multiplication of the template type with itself.
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
Lorentz5Vector< std::complex< typename BinaryOpTraits< T, U >::MulT > > MulT
The type resulting from multiplication of the template type with itself.
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...
STL namespace.
double rhoError() const
Return the relative inconsistency in the spatial components.
BinaryOpTraits< T, U >::MulT MulT
The type resulting from multiplication of the template type with itself.
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.
BinaryOpTraits< T, U >::MulT MulT
The type resulting from multiplication of the template type with itself.
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< std::complex< typename BinaryOpTraits< T, U >::MulT > > MulT
The type resulting from multiplication of the template type with itself.
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:89
Value mass() const
Mass/invariant length component.
BinaryOpTraits< T, U >::MulT MulT
The type resulting from multiplication of the template type with itself.
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
Lorentz5Vector< T > DivT
The type resulting from division of one template type with another.
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.
Lorentz5Vector< T > MulT
The type resulting from multiplication of the template type with itself.
Value tau() const
Mass/invariant length component.
Lorentz5Vector(const LorentzVector< Value > &p, Value m)
Constructor giving a LorentzVector and an invariant length.
BinaryOpTraits< Value, Value >::MulT Value2
Template argument typedef.
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.
BinaryOpTraits should be specialized with typdefs called MulT and DivT which gives the type resulting...
Definition: PhysicalQty.h:244
void setTau(Value a)
Set invariant length/mass.
LorentzVector< Value > & transform(const SpinOneLorentzRotation &m)
Rotate the vector. Resets .
Lorentz5Vector< std::complex< typename BinaryOpTraits< T, U >::DivT > > DivT
The type resulting from division of one template type with another.
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