#ifndef ROOT_Math_GenVector_PxPyPzE4D
#define ROOT_Math_GenVector_PxPyPzE4D 1
#ifndef ROOT_Math_GenVector_eta
#include "Math/GenVector/eta.h"
#endif
#ifndef ROOT_Math_GenVector_GenVector_exception
#include "Math/GenVector/GenVector_exception.h"
#endif
#include <cmath>
namespace ROOT {
namespace Math {
template <class ScalarType = double>
class PxPyPzE4D {
public :
typedef ScalarType Scalar;
PxPyPzE4D() : fX(0), fY(0), fZ(0), fT(0) { }
PxPyPzE4D(Scalar px, Scalar py, Scalar pz, Scalar e) :
fX(px), fY(py), fZ(pz), fT(e) { }
template <class CoordSystem>
explicit PxPyPzE4D(const CoordSystem & v) :
fX( v.x() ), fY( v.y() ), fZ( v.z() ), fT( v.t() ) { }
PxPyPzE4D(const PxPyPzE4D & v) :
fX(v.fX), fY(v.fY), fZ(v.fZ), fT(v.fT) { }
PxPyPzE4D & operator = (const PxPyPzE4D & v) {
fX = v.fX;
fY = v.fY;
fZ = v.fZ;
fT = v.fT;
return *this;
}
void SetCoordinates( const Scalar src[] )
{ fX=src[0]; fY=src[1]; fZ=src[2]; fT=src[3]; }
void GetCoordinates( Scalar dest[] ) const
{ dest[0] = fX; dest[1] = fY; dest[2] = fZ; dest[3] = fT; }
void SetCoordinates(Scalar px, Scalar py, Scalar pz, Scalar e)
{ fX=px; fY=py; fZ=pz; fT=e;}
void GetCoordinates(Scalar& px, Scalar& py, Scalar& pz, Scalar& e) const
{ px=fX; py=fY; pz=fZ; e=fT;}
Scalar Px() const { return fX;}
Scalar Py() const { return fY;}
Scalar Pz() const { return fZ;}
Scalar E() const { return fT;}
Scalar X() const { return fX;}
Scalar Y() const { return fY;}
Scalar Z() const { return fZ;}
Scalar T() const { return fT;}
Scalar P2() const { return fX*fX + fY*fY + fZ*fZ; }
Scalar P() const { return std::sqrt(P2()); }
Scalar R() const { return P(); }
Scalar M2() const { return fT*fT - fX*fX - fY*fY - fZ*fZ;}
Scalar Mag2() const { return M2(); }
Scalar M() const {
Scalar mm = M2();
if (mm >= 0) {
return std::sqrt(mm);
} else {
GenVector::Throw ("PxPyPzE4D::M() - Tachyonic:\n"
" P^2 > E^2 so the mass would be imaginary");
return -std::sqrt(-mm);
}
}
Scalar Mag() const { return M(); }
Scalar Pt2() const { return fX*fX + fY*fY;}
Scalar Perp2() const { return Pt2();}
Scalar Pt() const { return std::sqrt(Perp2());}
Scalar Perp() const { return Pt();}
Scalar Rho() const { return Pt();}
Scalar Mt2() const { return fT*fT - fZ*fZ; }
Scalar Mt() const {
Scalar mm = Mt2();
if (mm >= 0) {
return std::sqrt(mm);
} else {
GenVector::Throw ("PxPyPzE4D::Mt() - Tachyonic:\n"
" Pz^2 > E^2 so the transverse mass would be imaginary");
return -std::sqrt(-mm);
}
}
Scalar Et2() const {
Scalar pt2 = Pt2();
return pt2 == 0 ? 0 : fT*fT * pt2/( pt2 + fZ*fZ );
}
Scalar Et() const {
Scalar etet = Et2();
return fT < 0.0 ? -std::sqrt(etet) : std::sqrt(etet);
}
Scalar Phi() const {
return (fX == 0.0 && fY == 0.0) ? 0 : std::atan2(fY,fX);
}
Scalar Theta() const {
return (fX == 0.0 && fY == 0.0 && fZ == 0.0) ? 0 : std::atan2(Pt(),fZ);
}
Scalar Eta() const {
return Impl::Eta_FromRhoZ ( Pt(), fZ);
}
void SetPx( Scalar px) {
fX = px;
}
void SetPy( Scalar py) {
fY = py;
}
void SetPz( Scalar pz) {
fZ = pz;
}
void SetE( Scalar e) {
fT = e;
}
void SetPxPyPzE(Scalar px, Scalar py, Scalar pz, Scalar e) {
fX=px;
fY=py;
fZ=pz;
fT=e;
}
void Negate( ) { fX = -fX; fY = -fY; fZ = -fZ; fT = -fT;}
void Scale( const Scalar & a) {
fX *= a;
fY *= a;
fZ *= a;
fT *= a;
}
template <class AnyCoordSystem>
PxPyPzE4D & operator = (const AnyCoordSystem & v) {
fX = v.x();
fY = v.y();
fZ = v.z();
fT = v.t();
return *this;
}
bool operator == (const PxPyPzE4D & rhs) const {
return fX == rhs.fX && fY == rhs.fY && fZ == rhs.fZ && fT == rhs.fT;
}
bool operator != (const PxPyPzE4D & rhs) const {return !(operator==(rhs));}
Scalar x() const { return fX; }
Scalar y() const { return fY; }
Scalar z() const { return fZ; }
Scalar t() const { return fT; }
#if defined(__MAKECINT__) || defined(G__DICTIONARY)
void SetPt(Scalar pt);
void SetEta(Scalar eta);
void SetPhi(Scalar phi);
void SetM(Scalar m);
#endif
private:
ScalarType fX;
ScalarType fY;
ScalarType fZ;
ScalarType fT;
};
}
}
#if defined(__MAKECINT__) || defined(G__DICTIONARY)
#ifndef ROOT_Math_GenVector_PtEtaPhiE4D
#include "Math/GenVector/PtEtaPhiE4D.h"
#endif
#ifndef ROOT_Math_GenVector_PtEtaPhiM4D
#include "Math/GenVector/PtEtaPhiM4D.h"
#endif
namespace ROOT {
namespace Math {
template <class ScalarType>
void PxPyPzE4D<ScalarType>::SetPt(Scalar pt) {
GenVector_exception e("PxPyPzE4D::SetPt() is not supposed to be called");
throw e;
PtEtaPhiE4D<Scalar> v(*this); v.SetPt(pt); *this = PxPyPzE4D<Scalar>(v);
}
template <class ScalarType>
void PxPyPzE4D<ScalarType>::SetEta(Scalar eta) {
GenVector_exception e("PxPyPzE4D::SetEta() is not supposed to be called");
throw e;
PtEtaPhiE4D<Scalar> v(*this); v.SetEta(eta); *this = PxPyPzE4D<Scalar>(v);
}
template <class ScalarType>
void PxPyPzE4D<ScalarType>::SetPhi(Scalar phi) {
GenVector_exception e("PxPyPzE4D::SetPhi() is not supposed to be called");
throw e;
PtEtaPhiE4D<Scalar> v(*this); v.SetPhi(phi); *this = PxPyPzE4D<Scalar>(v);
}
template <class ScalarType>
void PxPyPzE4D<ScalarType>::SetM(Scalar m) {
GenVector_exception e("PxPyPzE4D::SetM() is not supposed to be called");
throw e;
PtEtaPhiM4D<Scalar> v(*this); v.SetM(m);
*this = PxPyPzE4D<Scalar>(v);
}
}
}
#endif // endif __MAKE__CINT || G__DICTIONARY
#endif // ROOT_Math_GenVector_PxPyPzE4D