19 #ifndef ROOT_Math_GenVector_PtEtaPhiE4D
20 #define ROOT_Math_GenVector_PtEtaPhiE4D 1
51 template <
class ScalarType>
56 typedef ScalarType Scalar;
63 PtEtaPhiE4D() : fPt(0), fEta(0), fPhi(0), fE(0) { }
68 PtEtaPhiE4D(Scalar pt, Scalar eta, Scalar phi, Scalar e) :
69 fPt(pt), fEta(eta), fPhi(phi), fE(e) { Restrict(); }
75 template <
class CoordSystem >
76 explicit PtEtaPhiE4D(
const CoordSystem & c) :
77 fPt(c.Pt()), fEta(c.Eta()), fPhi(c.Phi()), fE(c.E()) { }
85 PtEtaPhiE4D(
const PtEtaPhiE4D & v) :
86 fPt(v.fPt), fEta(v.fEta), fPhi(v.fPhi), fE(v.fE) { }
91 PtEtaPhiE4D & operator = (
const PtEtaPhiE4D & v) {
103 void SetCoordinates(
const Scalar src[] )
104 { fPt=src[0]; fEta=src[1]; fPhi=src[2]; fE=src[3]; Restrict(); }
109 void GetCoordinates( Scalar dest[] )
const
110 { dest[0] = fPt; dest[1] = fEta; dest[2] = fPhi; dest[3] = fE; }
115 void SetCoordinates(Scalar pt, Scalar eta, Scalar phi, Scalar e)
116 { fPt=pt; fEta = eta; fPhi = phi; fE = e; Restrict(); }
122 GetCoordinates(Scalar& pt, Scalar & eta, Scalar & phi, Scalar& e)
const
123 { pt=fPt; eta=fEta; phi = fPhi; e = fE; }
129 Scalar Pt()
const {
return fPt; }
130 Scalar Eta()
const {
return fEta; }
131 Scalar Phi()
const {
return fPhi; }
132 Scalar E()
const {
return fE; }
134 Scalar Perp()
const {
return Pt(); }
135 Scalar Rho()
const {
return Pt(); }
136 Scalar T()
const {
return E(); }
140 Scalar Px()
const {
return fPt * cos(fPhi); }
141 Scalar X ()
const {
return Px(); }
142 Scalar Py()
const {
return fPt * sin(fPhi); }
143 Scalar Y ()
const {
return Py(); }
145 return fPt > 0 ? fPt * sinh(fEta) : fEta == 0 ? 0 : fEta > 0 ? fEta - etaMax<Scalar>() : fEta + etaMax<Scalar>();
147 Scalar Z ()
const {
return Pz(); }
153 return fPt > 0 ? fPt * cosh(fEta)
154 : fEta > etaMax<Scalar>() ? fEta - etaMax<Scalar>()
155 : fEta < -etaMax<Scalar>() ? -fEta - etaMax<Scalar>() : 0;
157 Scalar R()
const {
return P(); }
164 const Scalar p = P();
173 const Scalar p = P();
174 return fE * fE - p * p;
176 Scalar Mag2()
const {
return M2(); }
182 const Scalar mm = M2();
186 GenVector::Throw (
"PtEtaPhiE4D::M() - Tachyonic:\n"
187 " Pt and Eta give P such that P^2 > E^2, so the mass would be imaginary");
191 Scalar Mag()
const {
return M(); }
196 Scalar Pt2()
const {
return fPt*fPt;}
197 Scalar Perp2()
const {
return Pt2(); }
202 Scalar Mt2()
const { Scalar pz = Pz();
return fE*fE - pz*pz; }
208 const Scalar mm = Mt2();
212 GenVector::Throw (
"PtEtaPhiE4D::Mt() - Tachyonic:\n"
213 " Pt and Eta give Pz such that Pz^2 > E^2, so the mass would be imaginary");
225 return fE / cosh(fEta);
233 const Scalar et = Et();
238 inline static Scalar pi() {
return M_PI; }
239 inline void Restrict() {
240 if (fPhi <= -pi() || fPhi > pi()) fPhi = fPhi - floor(fPhi / (2 * pi()) + .5) * 2 * pi();
247 Scalar Theta()
const {
return (fPt > 0 ? Scalar(2) * atan(exp(-fEta)) : fEta >= 0 ? 0 : pi()); }
254 void SetPt( Scalar pt) {
260 void SetEta( Scalar eta) {
266 void SetPhi( Scalar phi) {
273 void SetE( Scalar e) {
280 void SetPxPyPzE(Scalar px, Scalar py, Scalar pz, Scalar e);
289 fPhi = ( fPhi > 0 ? fPhi - pi() : fPhi + pi() );
297 void Scale( Scalar a) {
309 template <
class CoordSystem >
310 PtEtaPhiE4D & operator = (
const CoordSystem & c) {
321 bool operator == (
const PtEtaPhiE4D & rhs)
const {
322 return fPt == rhs.fPt && fEta == rhs.fEta
323 && fPhi == rhs.fPhi && fE == rhs.fE;
325 bool operator != (
const PtEtaPhiE4D & rhs)
const {
return !(operator==(rhs));}
331 Scalar x()
const {
return X(); }
332 Scalar y()
const {
return Y(); }
333 Scalar z()
const {
return Z(); }
334 Scalar t()
const {
return E(); }
338 #if defined(__MAKECINT__) || defined(G__DICTIONARY)
342 void SetPx(Scalar px);
344 void SetPy(Scalar py);
346 void SetPz(Scalar pz);
370 #if defined(__MAKECINT__) || defined(G__DICTIONARY)
378 template <
class ScalarType>
379 inline void PtEtaPhiE4D<ScalarType>::SetPxPyPzE(Scalar px, Scalar py, Scalar pz, Scalar e) {
380 *
this = PxPyPzE4D<Scalar> (px, py, pz, e);
384 #if defined(__MAKECINT__) || defined(G__DICTIONARY)
388 template <
class ScalarType>
389 inline void PtEtaPhiE4D<ScalarType>::SetPx(Scalar px) {
390 GenVector_exception e(
"PtEtaPhiE4D::SetPx() is not supposed to be called");
392 PxPyPzE4D<Scalar> v(*
this); v.SetPx(px); *
this = PtEtaPhiE4D<Scalar>(v);
394 template <
class ScalarType>
395 inline void PtEtaPhiE4D<ScalarType>::SetPy(Scalar py) {
396 GenVector_exception e(
"PtEtaPhiE4D::SetPx() is not supposed to be called");
398 PxPyPzE4D<Scalar> v(*
this); v.SetPy(py); *
this = PtEtaPhiE4D<Scalar>(v);
400 template <
class ScalarType>
401 inline void PtEtaPhiE4D<ScalarType>::SetPz(Scalar pz) {
402 GenVector_exception e(
"PtEtaPhiE4D::SetPx() is not supposed to be called");
404 PxPyPzE4D<Scalar> v(*
this); v.SetPz(pz); *
this = PtEtaPhiE4D<Scalar>(v);
406 template <
class ScalarType>
407 inline void PtEtaPhiE4D<ScalarType>::SetM(Scalar m) {
408 GenVector_exception e(
"PtEtaPhiE4D::SetM() is not supposed to be called");
410 PtEtaPhiM4D<Scalar> v(*
this); v.SetM(m);
411 *
this = PtEtaPhiE4D<Scalar>(v);
414 #endif // endif __MAKE__CINT || G__DICTIONARY
423 #endif // ROOT_Math_GenVector_PtEtaPhiE4D