ThePEG  1.8.0
Lorentz5Vector.h
1 // -*- C++ -*-
2 //
3 // Lorentz5Vector.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2011 Leif Lonnblad
5 //
6 // ThePEG is licenced under version 2 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  typedef typename BinaryOpTraits<Value,Value>::MulT Value2;
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>
341 struct BinaryOpTraits<Lorentz5Vector<T>, Lorentz5Vector<U> > {
344  typedef typename BinaryOpTraits<T,U>::MulT MulT;
345 };
346 
350 template <typename T, typename U>
351 struct BinaryOpTraits<LorentzVector<T>, Lorentz5Vector<U> > {
354  typedef typename BinaryOpTraits<T,U>::MulT MulT;
355 };
356 
360 template <typename T, typename U>
361 struct BinaryOpTraits<Lorentz5Vector<T>, LorentzVector<U> > {
364  typedef typename BinaryOpTraits<T,U>::MulT MulT;
365 };
366 
368 
369 template <typename ValueA, typename ValueB>
370 inline typename BinaryOpTraits<ValueA,ValueB>::MulT
371 operator*(const Lorentz5Vector<ValueA> & a, const Lorentz5Vector<ValueB> & b) {
372  return a.dot(b);
373 }
374 
375 template <typename ValueA, typename ValueB>
376 inline typename BinaryOpTraits<ValueA,ValueB>::MulT
377 operator*(const LorentzVector<ValueA> & a, const Lorentz5Vector<ValueB> & b) {
378  return a.dot(b);
379 }
380 
381 template <typename ValueA, typename ValueB>
382 inline typename BinaryOpTraits<ValueA,ValueB>::MulT
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 */