File indexing completed on 2024-09-27 07:03:37
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #ifndef LORENTZVECTOR_H
0035 #define LORENTZVECTOR_H
0036
0037
0038 #include "vector3.h"
0039 #include <vector>
0040
0041
0042 class lorentzVector
0043 {
0044 public:
0045
0046 lorentzVector();
0047 virtual ~lorentzVector();
0048
0049 lorentzVector(double x, double y, double z, double t);
0050
0051 void SetXYZT(double x, double y, double z, double t);
0052 void SetPxPyPzE(double px, double py, double pz, double e) { SetXYZT(px, py, pz, e); };
0053
0054 double GetPx() const { return fSpaceVec.GetVector()[0]; }
0055 double GetPy() const { return fSpaceVec.GetVector()[1]; }
0056 double GetPz() const { return fSpaceVec.GetVector()[2]; }
0057 double GetE() const { return fTime; }
0058 virtual void reflect(){fSpaceVec.SetVector(-1.0*fSpaceVec.X(),-1.0*fSpaceVec.Y(),-1.0*fSpaceVec.Z());};
0059
0060 lorentzVector& operator +=(const lorentzVector& vec)
0061 {
0062 fSpaceVec += vec.fSpaceVec;
0063 fTime += vec.fTime;
0064 return *this;
0065 }
0066 lorentzVector& operator -=(const lorentzVector& vec)
0067 {
0068 fSpaceVec -= vec.fSpaceVec;
0069 fTime -= vec.fTime;
0070 return *this;
0071 }
0072
0073 double M2() const { return fTime * fTime - fSpaceVec.Mag2(); }
0074 double M () const
0075 {
0076 const double mag2 = M2();
0077 return (mag2 < 0) ? -sqrt(-mag2) : sqrt(mag2);
0078 }
0079
0080 vector3 BoostVector() const
0081 { return vector3(fSpaceVec.X() / fTime, fSpaceVec.Y() / fTime, fSpaceVec.Z() / fTime); }
0082 void Boost(const vector3& beta)
0083 {
0084 const double beta2 = beta.Mag2();
0085 const double gamma = 1 / sqrt(1 - beta2);
0086 const double betaTimesMom = beta.X() * fSpaceVec.X() + beta.Y() * fSpaceVec.Y() + beta.Z() * fSpaceVec.Z();
0087 const double gamma2 = (beta2 > 0) ? (gamma - 1) / beta2 : 0;
0088 SetXYZT(fSpaceVec.X() + gamma2 * betaTimesMom * beta.X() + gamma * beta.X() * fTime,
0089 fSpaceVec.Y() + gamma2 * betaTimesMom * beta.Y() + gamma * beta.Y() * fTime,
0090 fSpaceVec.Z() + gamma2 * betaTimesMom * beta.Z() + gamma * beta.Z() * fTime,
0091 gamma * (fTime + betaTimesMom));
0092 }
0093
0094 friend std::ostream& operator << (std::ostream& out,
0095 const lorentzVector& vec)
0096 {
0097 out << "(" << vec.GetPx() << ", " << vec.GetPy() << ", " << vec.GetPz()
0098 << "; " << vec.GetE() << ")";
0099 return out;
0100 }
0101
0102 private:
0103
0104 vector3 fSpaceVec;
0105 double fTime;
0106
0107 };
0108
0109
0110 #endif