18 #ifndef ROOT_Math_GenVector_PtEtaPhiM4D
19 #define ROOT_Math_GenVector_PtEtaPhiM4D 1
51 template <
class ScalarType>
56 typedef ScalarType Scalar;
63 PtEtaPhiM4D() : fPt(0), fEta(0), fPhi(0), fM(0) { }
68 PtEtaPhiM4D(Scalar pt, Scalar eta, Scalar phi, Scalar mass) :
69 fPt(pt), fEta(eta), fPhi(phi), fM(mass) {
71 if (fM < 0) RestrictNegMass();
78 template <
class CoordSystem >
79 explicit PtEtaPhiM4D(
const CoordSystem & c) :
80 fPt(c.Pt()), fEta(c.Eta()), fPhi(c.Phi()), fM(c.M()) { RestrictPhi(); }
88 PtEtaPhiM4D(
const PtEtaPhiM4D & v) :
89 fPt(v.fPt), fEta(v.fEta), fPhi(v.fPhi), fM(v.fM) { }
94 PtEtaPhiM4D & operator = (
const PtEtaPhiM4D & v) {
106 void SetCoordinates(
const Scalar src[] ) {
107 fPt=src[0]; fEta=src[1]; fPhi=src[2]; fM=src[3];
109 if (fM <0) RestrictNegMass();
115 void GetCoordinates( Scalar dest[] )
const
116 { dest[0] = fPt; dest[1] = fEta; dest[2] = fPhi; dest[3] = fM; }
121 void SetCoordinates(Scalar pt, Scalar eta, Scalar phi, Scalar mass) {
122 fPt=pt; fEta = eta; fPhi = phi; fM = mass;
124 if (fM <0) RestrictNegMass();
131 GetCoordinates(Scalar& pt, Scalar & eta, Scalar & phi, Scalar& mass)
const
132 { pt=fPt; eta=fEta; phi = fPhi; mass = fM; }
138 Scalar Pt()
const {
return fPt; }
139 Scalar Eta()
const {
return fEta; }
140 Scalar Phi()
const {
return fPhi; }
145 Scalar M()
const {
return fM; }
146 Scalar Mag()
const {
return M(); }
148 Scalar Perp()
const {
return Pt(); }
149 Scalar Rho()
const {
return Pt(); }
153 Scalar Px()
const {
return fPt * cos(fPhi); }
154 Scalar X ()
const {
return Px(); }
155 Scalar Py()
const {
return fPt * sin(fPhi); }
156 Scalar Y ()
const {
return Py(); }
158 return fPt > 0 ? fPt * sinh(fEta) : fEta == 0 ? 0 : fEta > 0 ? fEta - etaMax<Scalar>() : fEta + etaMax<Scalar>();
160 Scalar Z ()
const {
return Pz(); }
166 return fPt > 0 ? fPt * cosh(fEta)
167 : fEta > etaMax<Scalar>() ? fEta - etaMax<Scalar>()
168 : fEta < -etaMax<Scalar>() ? -fEta - etaMax<Scalar>() : 0;
170 Scalar R()
const {
return P(); }
177 const Scalar p = P();
185 Scalar e2 = P2() + M2();
187 return e2 > 0 ? e2 : 0;
193 Scalar E()
const {
return sqrt(E2()); }
195 Scalar T()
const {
return E(); }
202 return ( fM >= 0 ) ? fM*fM : -fM*fM;
204 Scalar Mag2()
const {
return M2(); }
209 Scalar Pt2()
const {
return fPt*fPt;}
210 Scalar Perp2()
const {
return Pt2(); }
215 Scalar Mt2()
const {
return M2() + fPt*fPt; }
221 const Scalar mm = Mt2();
225 GenVector::Throw (
"PtEtaPhiM4D::Mt() - Tachyonic:\n"
226 " Pz^2 > E^2 so the transverse mass would be imaginary");
236 return 2. * E2() / (cosh(2 * fEta) + 1);
242 Scalar Et()
const {
return E() / cosh(fEta); }
245 inline static Scalar pi() {
return M_PI; }
246 inline void RestrictPhi() {
247 if (fPhi <= -pi() || fPhi > pi()) fPhi = fPhi - floor(fPhi / (2 * pi()) + .5) * 2 * pi();
251 inline void RestrictNegMass() {
253 if (P2() - fM * fM < 0) {
254 GenVector::Throw(
"PtEtaPhiM4D::unphysical value of mass, set to closest physical value");
265 Scalar Theta()
const {
return (fPt > 0 ? Scalar(2) * atan(exp(-fEta)) : fEta >= 0 ? 0 : pi()); }
272 void SetPt( Scalar pt) {
278 void SetEta( Scalar eta) {
284 void SetPhi( Scalar phi) {
291 void SetM( Scalar mass) {
293 if (fM <0) RestrictNegMass();
299 void SetPxPyPzE(Scalar px, Scalar py, Scalar pz, Scalar e);
310 fPhi = ( (fPhi > 0) ? fPhi - pi() : fPhi + pi() );
312 GenVector::Throw (
"PtEtaPhiM4D::Negate - cannot negate the energy - can negate only the spatial components");
318 void Scale( Scalar a) {
330 template <
class CoordSystem >
331 PtEtaPhiM4D & operator = (
const CoordSystem & c) {
342 bool operator == (
const PtEtaPhiM4D & rhs)
const {
343 return fPt == rhs.fPt && fEta == rhs.fEta
344 && fPhi == rhs.fPhi && fM == rhs.fM;
346 bool operator != (
const PtEtaPhiM4D & rhs)
const {
return !(operator==(rhs));}
352 Scalar x()
const {
return X(); }
353 Scalar y()
const {
return Y(); }
354 Scalar z()
const {
return Z(); }
355 Scalar t()
const {
return E(); }
358 #if defined(__MAKECINT__) || defined(G__DICTIONARY)
362 void SetPx(Scalar px);
364 void SetPy(Scalar py);
366 void SetPz(Scalar pz);
396 template <
class ScalarType>
397 inline void PtEtaPhiM4D<ScalarType>::SetPxPyPzE(Scalar px, Scalar py, Scalar pz, Scalar e) {
398 *
this = PxPyPzE4D<Scalar> (px, py, pz, e);
402 #if defined(__MAKECINT__) || defined(G__DICTIONARY)
406 template <
class ScalarType>
407 void PtEtaPhiM4D<ScalarType>::SetPx(Scalar px) {
408 GenVector_exception e(
"PtEtaPhiM4D::SetPx() is not supposed to be called");
410 PxPyPzE4D<Scalar> v(*
this); v.SetPx(px); *
this = PtEtaPhiM4D<Scalar>(v);
412 template <
class ScalarType>
413 void PtEtaPhiM4D<ScalarType>::SetPy(Scalar py) {
414 GenVector_exception e(
"PtEtaPhiM4D::SetPx() is not supposed to be called");
416 PxPyPzE4D<Scalar> v(*
this); v.SetPy(py); *
this = PtEtaPhiM4D<Scalar>(v);
418 template <
class ScalarType>
419 void PtEtaPhiM4D<ScalarType>::SetPz(Scalar pz) {
420 GenVector_exception e(
"PtEtaPhiM4D::SetPx() is not supposed to be called");
422 PxPyPzE4D<Scalar> v(*
this); v.SetPz(pz); *
this = PtEtaPhiM4D<Scalar>(v);
424 template <
class ScalarType>
425 void PtEtaPhiM4D<ScalarType>::SetE(Scalar energy) {
426 GenVector_exception e(
"PtEtaPhiM4D::SetE() is not supposed to be called");
428 PxPyPzE4D<Scalar> v(*
this); v.SetE(energy); *
this = PtEtaPhiM4D<Scalar>(v);
431 #endif // endif __MAKE__CINT || G__DICTIONARY
439 #endif // ROOT_Math_GenVector_PtEtaPhiM4D