#ifndef ROOT_Math_GenVector_PtEtaPhiM4D
#define ROOT_Math_GenVector_PtEtaPhiM4D 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 PtEtaPhiM4D {
public :
typedef ScalarType Scalar;
PtEtaPhiM4D() : fPt(0), fEta(0), fPhi(0), fM(0) { }
PtEtaPhiM4D(Scalar pt, Scalar eta, Scalar phi, Scalar mass) :
fPt(pt), fEta(eta), fPhi(phi), fM(mass) { Restrict(); }
template <class CoordSystem >
explicit PtEtaPhiM4D(const CoordSystem & c) :
fPt(c.Pt()), fEta(c.Eta()), fPhi(c.Phi()), fM(c.M()) { Restrict(); }
void SetCoordinates( const Scalar src[] )
{ fPt=src[0]; fEta=src[1]; fPhi=src[2]; fM=src[3]; Restrict(); }
void GetCoordinates( Scalar dest[] ) const
{ dest[0] = fPt; dest[1] = fEta; dest[2] = fPhi; dest[3] = fM; }
void SetCoordinates(Scalar pt, Scalar eta, Scalar phi, Scalar mass)
{ fPt=pt; fEta = eta; fPhi = phi; fM = mass; Restrict(); }
void
GetCoordinates(Scalar& pt, Scalar & eta, Scalar & phi, Scalar& mass) const
{ pt=fPt; eta=fEta; phi = fPhi; mass = fM; }
Scalar Pt() const { return fPt; }
Scalar Eta() const { return fEta; }
Scalar Phi() const { return fPhi; }
Scalar M() const { return fM; }
Scalar Mag() const { return M(); }
Scalar Perp()const { return Pt(); }
Scalar Rho() const { return Pt(); }
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 E() const {
Scalar e = std::sqrt(fM*fM + P()*P());
return fM>=0? e : -e;
}
Scalar T() const { return E(); }
Scalar M2() const { return fM*fM; }
Scalar Mag2() const { return M2(); }
Scalar Pt2() const { return fPt*fPt;}
Scalar Perp2() const { return Pt2(); }
Scalar Mt2() const { return fM*fM + fPt*fPt; }
Scalar Mt() const {
Scalar mt2 = Mt2();
return fM >= 0 ? std::sqrt(mt2) : -std::sqrt(mt2);
}
Scalar Et2() const { return fM*fM/std::cosh(fEta) + fPt*fPt; }
Scalar Et() const {
return E() / std::cosh(fEta);
}
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 SetM( Scalar mass) {
fM = mass;
}
void Negate( ) { fPhi = - fPhi; fEta = - fEta; fM = - fM; }
void Scale( Scalar a) {
if (a < 0) {
Negate(); a = -a;
}
fPt *= a;
fM *= a;
}
template <class CoordSystem >
PtEtaPhiM4D & operator = (const CoordSystem & c) {
fPt = c.Pt();
fEta = c.Eta();
fPhi = c.Phi();
fM = c.M();
return *this;
}
bool operator == (const PtEtaPhiM4D & rhs) const {
return fPt == rhs.fPt && fEta == rhs.fEta
&& fPhi == rhs.fPhi && fM == rhs.fM;
}
bool operator != (const PtEtaPhiM4D & 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 SetE(Scalar t);
#endif
private:
ScalarType fPt;
ScalarType fEta;
ScalarType fPhi;
ScalarType fM;
};
}
}
#if defined(__MAKECINT__) || defined(G__DICTIONARY)
#include "Math/GenVector/PxPyPzE4D.h"
namespace ROOT {
namespace Math {
template <class ScalarType>
void PtEtaPhiM4D<ScalarType>::SetPx(Scalar px) {
GenVector_exception e("PtEtaPhiM4D::SetPx() is not supposed to be called");
Throw(e);
PxPyPzE4D<Scalar> v(*this); v.SetPx(px); *this = PtEtaPhiM4D<Scalar>(v);
}
template <class ScalarType>
void PtEtaPhiM4D<ScalarType>::SetPy(Scalar py) {
GenVector_exception e("PtEtaPhiM4D::SetPx() is not supposed to be called");
Throw(e);
PxPyPzE4D<Scalar> v(*this); v.SetPy(py); *this = PtEtaPhiM4D<Scalar>(v);
}
template <class ScalarType>
void PtEtaPhiM4D<ScalarType>::SetPz(Scalar pz) {
GenVector_exception e("PtEtaPhiM4D::SetPx() is not supposed to be called");
Throw(e);
PxPyPzE4D<Scalar> v(*this); v.SetPz(pz); *this = PtEtaPhiM4D<Scalar>(v);
}
template <class ScalarType>
void PtEtaPhiM4D<ScalarType>::SetE(Scalar t) {
GenVector_exception e("PtEtaPhiM4D::SetE() is not supposed to be called");
Throw(e);
PxPyPzE4D<Scalar> v(*this); v.SetE(t); *this = PtEtaPhiM4D<Scalar>(v);
}
}
}
#endif // endif __MAKE__CINT || G__DICTIONARY
#endif // ROOT_Math_GenVector_PtEtaPhiM4D
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.