#ifndef ROOT_Math_GenVector_PtEtaPhiE4D
#define ROOT_Math_GenVector_PtEtaPhiE4D 1
#include "Math/GenVector/etaMax.h"
#include "Math/GenVector/GenVector_exception.h"
#include <cmath>
#ifdef TRACE_CE
#include <iostream>
#endif
namespace ROOT {
namespace Math {
template <class ScalarType>
class PtEtaPhiE4D {
public :
typedef ScalarType Scalar;
PtEtaPhiE4D() : fPt(0), fEta(0), fPhi(0), fE(0) { }
PtEtaPhiE4D(Scalar pt, Scalar eta, Scalar phi, Scalar e) :
fPt(pt), fEta(eta), fPhi(phi), fE(e) { Restrict(); }
template <class CoordSystem >
explicit PtEtaPhiE4D(const CoordSystem & c) :
fPt(c.Pt()), fEta(c.Eta()), fPhi(c.Phi()), fE(c.E()) { }
void SetCoordinates( const Scalar src[] )
{ fPt=src[0]; fEta=src[1]; fPhi=src[2]; fE=src[3]; Restrict(); }
void GetCoordinates( Scalar dest[] ) const
{ dest[0] = fPt; dest[1] = fEta; dest[2] = fPhi; dest[3] = fE; }
void SetCoordinates(Scalar pt, Scalar eta, Scalar phi, Scalar e)
{ fPt=pt; fEta = eta; fPhi = phi; fE = e; Restrict(); }
void
GetCoordinates(Scalar& pt, Scalar & eta, Scalar & phi, Scalar& e) const
{ pt=fPt; eta=fEta; phi = fPhi; e = fE; }
Scalar Pt() const { return fPt; }
Scalar Eta() const { return fEta; }
Scalar Phi() const { return fPhi; }
Scalar E() const { return fE; }
Scalar Perp()const { return Pt(); }
Scalar Rho() const { return Pt(); }
Scalar T() const { return E(); }
Scalar Px() const { return fPt*cos(fPhi);}
Scalar X () const { return Px(); }
Scalar Py() const { return fPt*sin(fPhi);}
Scalar Y () const { return Py(); }
Scalar Pz() const {
return fPt > 0 ? fPt*std::sinh(fEta) :
fEta == 0 ? 0 :
fEta > 0 ? fEta - etaMax<Scalar>() :
fEta + etaMax<Scalar>() ;
}
Scalar Z () const { return Pz(); }
Scalar P() const {
return fPt > 0 ? fPt*std::cosh(fEta) :
fEta > etaMax<Scalar>() ? fEta - etaMax<Scalar>() :
fEta < -etaMax<Scalar>() ? -fEta - etaMax<Scalar>() :
0 ;
}
Scalar R() const { return P(); }
Scalar P2() const { Scalar p = P(); return p*p; }
Scalar M2() const { Scalar p = P(); return fE*fE - p*p; }
Scalar Mag2() const { return M2(); }
Scalar M() const {
Scalar mm = M2();
if (mm >= 0) {
return std::sqrt(mm);
} else {
GenVector_exception e ("PtEtaPhiE4D::M() - Tachyonic:\n"
" Pt and Eta give P such that P^2 > E^2, so the mass would be imaginary");
Throw(e);
return -std::sqrt(-mm);
}
}
Scalar Mag() const { return M(); }
Scalar Pt2() const { return fPt*fPt;}
Scalar Perp2() const { return Pt2(); }
Scalar Mt2() const { Scalar pz = Pz(); return fE*fE - pz*pz; }
Scalar Mt() const {
Scalar mm = Mt2();
if (mm >= 0) {
return std::sqrt(mm);
} else {
GenVector_exception e ("PtEtaPhiE4D::Mt() - Tachyonic:\n"
" Pt and Eta give Pz such that Pz^2 > E^2, so the mass would be imaginary");
Throw(e);
return -std::sqrt(-mm);
}
}
Scalar Et() const {
return fE / std::cosh(fEta);
}
Scalar Et2() const { Scalar et = Et(); return et*et; }
private:
inline static double pi() { return 3.14159265358979323; }
inline void Restrict() {
if ( fPhi <= -pi() || fPhi > pi() )
fPhi = fPhi - std::floor( fPhi/(2*pi()) +.5 ) * 2*pi();
return;
}
public:
Scalar Theta() const {
if (fPt > 0) return 2* std::atan( exp( - fEta ) );
if (fEta >= 0) return 0;
return pi();
}
void SetPt( Scalar pt) {
fPt = pt;
}
void SetEta( Scalar eta) {
fEta = eta;
}
void SetPhi( Scalar phi) {
fPhi = phi;
Restrict();
}
void SetE( Scalar e) {
fE = e;
}
void Negate( ) { fPhi = - fPhi; fEta = - fEta; fE = - fE; }
void Scale( Scalar a) {
if (a < 0) {
Negate(); a = -a;
}
fPt *= a;
fE *= a;
}
template <class CoordSystem >
PtEtaPhiE4D & operator = (const CoordSystem & c) {
fPt = c.Pt();
fEta = c.Eta();
fPhi = c.Phi();
fE = c.E();
return *this;
}
bool operator == (const PtEtaPhiE4D & rhs) const {
return fPt == rhs.fPt && fEta == rhs.fEta
&& fPhi == rhs.fPhi && fE == rhs.fE;
}
bool operator != (const PtEtaPhiE4D & rhs) const {return !(operator==(rhs));}
Scalar x() const { return X(); }
Scalar y() const { return Y(); }
Scalar z() const { return Z(); }
Scalar t() const { return E(); }
#if defined(__MAKECINT__) || defined(G__DICTIONARY)
void SetPx(Scalar px);
void SetPy(Scalar py);
void SetPz(Scalar pz);
void SetM(Scalar m);
#endif
private:
ScalarType fPt;
ScalarType fEta;
ScalarType fPhi;
ScalarType fE;
};
}
}
#if defined(__MAKECINT__) || defined(G__DICTIONARY)
#include "Math/GenVector/PxPyPzE4D.h"
#include "Math/GenVector/PtEtaPhiM4D.h"
namespace ROOT {
namespace Math {
template <class ScalarType>
void PtEtaPhiE4D<ScalarType>::SetPx(Scalar px) {
GenVector_exception e("PtEtaPhiE4D::SetPx() is not supposed to be called");
Throw(e);
PxPyPzE4D<Scalar> v(*this); v.SetPx(px); *this = PtEtaPhiE4D<Scalar>(v);
}
template <class ScalarType>
void PtEtaPhiE4D<ScalarType>::SetPy(Scalar py) {
GenVector_exception e("PtEtaPhiE4D::SetPx() is not supposed to be called");
Throw(e);
PxPyPzE4D<Scalar> v(*this); v.SetPy(py); *this = PtEtaPhiE4D<Scalar>(v);
}
template <class ScalarType>
void PtEtaPhiE4D<ScalarType>::SetPz(Scalar pz) {
GenVector_exception e("PtEtaPhiE4D::SetPx() is not supposed to be called");
Throw(e);
PxPyPzE4D<Scalar> v(*this); v.SetPz(pz); *this = PtEtaPhiE4D<Scalar>(v);
}
template <class ScalarType>
void PtEtaPhiE4D<ScalarType>::SetM(Scalar m) {
GenVector_exception e("PtEtaPhiE4D::SetM() is not supposed to be called");
Throw(e);
PtEtaPhiM4D<Scalar> v(*this); v.SetM(m);
*this = PtEtaPhiE4D<Scalar>(v);
}
}
}
#endif // endif __MAKE__CINT || G__DICTIONARY
#endif // ROOT_Math_GenVector_PtEtaPhiE4D
ROOT page - Class index - Class Hierarchy - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.