00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef ThePEG_Lorentz5Vector_H
00010 #define ThePEG_Lorentz5Vector_H
00011
00012
00013
00014 #include "LorentzVector.h"
00015 #include "Lorentz5Vector.fh"
00016 #include "ThePEG/Utilities/Maths.h"
00017 #include "ThePEG/Utilities/Direction.h"
00018 #include "ThePEG/Utilities/UnitIO.h"
00019 #include "LorentzRotation.h"
00020
00021 namespace ThePEG {
00022
00023 template <typename Value>
00042 class Lorentz5Vector: public LorentzVector<Value> {
00043
00044 public:
00045
00047 typedef typename BinaryOpTraits<Value,Value>::MulT Value2;
00048
00049 public:
00051
00052 Value x() const { return LorentzVector<Value>::x(); }
00053 Value y() const { return LorentzVector<Value>::y(); }
00054 Value z() const { return LorentzVector<Value>::z(); }
00055 Value t() const { return LorentzVector<Value>::t(); }
00057
00058 public:
00059
00065 Lorentz5Vector() : mm() {}
00066
00070 Lorentz5Vector(Value m)
00071 : LorentzVector<Value>(Value(), Value(), Value(), m), mm(m) {}
00072
00077 Lorentz5Vector(Value x, Value y, Value z, Value t = Value())
00078 : LorentzVector<Value>(x, y, z, t) { rescaleMass(); }
00079
00084 Lorentz5Vector(Value x, Value y, Value z, Value t, Value tau)
00085 : LorentzVector<Value>(x, y, z, t), mm(tau) {}
00086
00091 Lorentz5Vector(const ThreeVector<Value> & p, Value e)
00092 : LorentzVector<Value>(p, e) { rescaleMass(); }
00093
00098 Lorentz5Vector(Value m, const ThreeVector<Value> & p)
00099 : LorentzVector<Value>(p, sqrt(p.mag2() + m*m)), mm(m) {}
00100
00105 Lorentz5Vector(const ThreeVector<Value> & p, Value t, Value tau)
00106 : LorentzVector<Value>(p, t), mm(tau) {}
00107
00112 Lorentz5Vector(const LorentzVector<Value> & p, Value m)
00113 : LorentzVector<Value>(p), mm(m) {}
00114
00119 Lorentz5Vector(const LorentzVector<Value> & p)
00120 : LorentzVector<Value>(p) { rescaleMass(); }
00122
00128 void setTau(Value a) { mm = a; }
00129
00133 void setMass(Value a) { mm = a; }
00134
00139 Lorentz5Vector & operator=(const LorentzVector<Value> & q) {
00140 LorentzVector<Value>::operator=(q);
00141 return *this;
00142 }
00144
00151 void rescaleEnergy() {
00152 LorentzVector<Value>::setT(sqrt(LorentzVector<Value>::vect().mag2() + mass2()));
00153 }
00154
00159 void rescaleRho() {
00160 LorentzVector<Value>::setRho(sqrt(t()*t() - mass2()));
00161 }
00162
00167 void rescaleMass() {
00168 mm = LorentzVector<Value>::m();
00169 }
00171
00177 double massError() const {
00178 return sqrt(abs(Math::relativeError(mass2(),
00179 LorentzVector<Value>::m2())));
00180 }
00181
00185 double energyError() const {
00186 return sqrt(abs(Math::relativeError(t()*t(), mass2()
00187 + LorentzVector<Value>::vect().mag2())));
00188 }
00189
00193 double rhoError() const {
00194 return sqrt(abs(Math::relativeError(LorentzVector<Value>::vect().mag2(),
00195 t()*t() - mass2())));
00196 }
00198
00205 Value2 mass2() const { return mm > Value() ? mm*mm: -mm*mm; }
00206
00211 Value2 tau2() const { return mass2(); }
00212
00217 Value mass() const { return mm; }
00218
00219
00224 Value tau() const { return mass(); }
00225
00230 Value dirPlus() const {
00231 return Direction<0>::pos() ?
00232 LorentzVector<Value>::plus()
00233 :
00234 LorentzVector<Value>::minus();
00235 }
00236
00241 Value dirMinus() const {
00242 return Direction<0>::neg() ?
00243 LorentzVector<Value>::plus()
00244 :
00245 LorentzVector<Value>::minus();
00246 }
00248
00252 Lorentz5Vector & transform(const LorentzRotation & r)
00253 {
00254 LorentzVector<Value>::transform(r.one());
00255 return *this;
00256 }
00257
00258 private:
00259
00261 Value mm;
00262
00263 };
00264
00266 template <typename OStream, typename T, typename UT>
00267 void ounitstream(OStream & os, const Lorentz5Vector<T> & p, UT & u) {
00268 os << ounit(p.x(), u) << ounit(p.y(), u) << ounit(p.z(), u)
00269 << ounit(p.e(), u) << ounit(p.mass(), u);
00270 }
00271
00273 template <typename IStream, typename T, typename UT>
00274 void iunitstream(IStream & is, Lorentz5Vector<T> & p, UT & u) {
00275 T x, y, z, e, mass;
00276 is >> iunit(x, u) >> iunit(y, u) >> iunit(z, u) >> iunit(e, u)
00277 >> iunit(mass, u);
00278 p = Lorentz5Vector<T>(x, y, z, e, mass);
00279 }
00280
00281 template <typename T, typename U>
00282 struct BinaryOpTraits;
00283
00287 template <typename T>
00288 struct BinaryOpTraits<Lorentz5Vector<T>, double> {
00291 typedef Lorentz5Vector<T> MulT;
00294 typedef Lorentz5Vector<T> DivT;
00295 };
00296
00300 template <typename U>
00301 struct BinaryOpTraits<double, Lorentz5Vector<U> > {
00304 typedef Lorentz5Vector<U> MulT;
00305 };
00306
00310 template <typename T, typename U>
00311 struct BinaryOpTraits<Lorentz5Vector<T>, std::complex<U> > {
00314 typedef Lorentz5Vector<std::complex<typename BinaryOpTraits<T,U>::MulT> > MulT;
00317 typedef Lorentz5Vector<std::complex<typename BinaryOpTraits<T,U>::DivT> > DivT;
00318 };
00319
00323 template <typename T, typename U>
00324 struct BinaryOpTraits<std::complex<T>, Lorentz5Vector<U> > {
00327 typedef Lorentz5Vector<std::complex<typename BinaryOpTraits<T,U>::MulT> > MulT;
00328 };
00329
00333 template <typename T, typename U>
00334 struct BinaryOpTraits<Lorentz5Vector<T>, Lorentz5Vector<U> > {
00337 typedef typename BinaryOpTraits<T,U>::MulT MulT;
00338 };
00339
00343 template <typename T, typename U>
00344 struct BinaryOpTraits<LorentzVector<T>, Lorentz5Vector<U> > {
00347 typedef typename BinaryOpTraits<T,U>::MulT MulT;
00348 };
00349
00353 template <typename T, typename U>
00354 struct BinaryOpTraits<Lorentz5Vector<T>, LorentzVector<U> > {
00357 typedef typename BinaryOpTraits<T,U>::MulT MulT;
00358 };
00359
00361
00362 template <typename ValueA, typename ValueB>
00363 inline typename BinaryOpTraits<ValueA,ValueB>::MulT
00364 operator*(const Lorentz5Vector<ValueA> & a, const Lorentz5Vector<ValueB> & b) {
00365 return a.dot(b);
00366 }
00367
00368 template <typename ValueA, typename ValueB>
00369 inline typename BinaryOpTraits<ValueA,ValueB>::MulT
00370 operator*(const LorentzVector<ValueA> & a, const Lorentz5Vector<ValueB> & b) {
00371 return a.dot(b);
00372 }
00373
00374 template <typename ValueA, typename ValueB>
00375 inline typename BinaryOpTraits<ValueA,ValueB>::MulT
00376 operator*(const Lorentz5Vector<ValueA> & a, const LorentzVector<ValueB> & b) {
00377 return a.dot(b);
00378 }
00379
00380 template <typename Value>
00381 inline typename BinaryOpTraits<Value,Value>::MulT
00382 operator*(const Lorentz5Vector<Value> & a, const Lorentz5Vector<Value> & b) {
00383 return a.dot(b);
00384 }
00386 }
00387
00388 #endif