18 #ifndef ROOT_Math_GenVector_PxPyPzM4D
19 #define ROOT_Math_GenVector_PxPyPzM4D 1
46 template <
class ScalarType =
double>
51 typedef ScalarType Scalar;
58 PxPyPzM4D() : fX(0.0), fY(0.0), fZ(0.0), fM(0.0) { }
64 PxPyPzM4D(Scalar px, Scalar py, Scalar pz, Scalar m) :
65 fX(px), fY(py), fZ(pz), fM(m) {
67 if (fM < 0) RestrictNegMass();
74 template <
class CoordSystem>
75 explicit PxPyPzM4D(
const CoordSystem & v) :
76 fX( v.X() ), fY( v.Y() ), fZ( v.Z() ), fM( v.M() )
84 PxPyPzM4D(
const PxPyPzM4D & v) :
85 fX(v.fX), fY(v.fY), fZ(v.fZ), fM(v.fM) { }
90 PxPyPzM4D & operator = (
const PxPyPzM4D & v) {
103 template <
class AnyCoordSystem>
104 PxPyPzM4D & operator = (
const AnyCoordSystem & v) {
115 void SetCoordinates(
const Scalar src[] ) {
116 fX=src[0]; fY=src[1]; fZ=src[2]; fM=src[3];
117 if (fM < 0) RestrictNegMass();
123 void GetCoordinates( Scalar dest[] )
const
124 { dest[0] = fX; dest[1] = fY; dest[2] = fZ; dest[3] = fM; }
129 void SetCoordinates(Scalar px, Scalar py, Scalar pz, Scalar m) {
130 fX=px; fY=py; fZ=pz; fM=m;
131 if (fM < 0) RestrictNegMass();
137 void GetCoordinates(Scalar& px, Scalar& py, Scalar& pz, Scalar& m)
const
138 { px=fX; py=fY; pz=fZ; m=fM;}
144 Scalar Px()
const {
return fX;}
145 Scalar Py()
const {
return fY;}
146 Scalar Pz()
const {
return fZ;}
147 Scalar M()
const {
return fM; }
149 Scalar X()
const {
return fX;}
150 Scalar Y()
const {
return fY;}
151 Scalar Z()
const {
return fZ;}
157 Scalar E()
const {
return sqrt(E2()); }
159 Scalar T()
const {
return E();}
164 Scalar P2()
const {
return fX*fX + fY*fY + fZ*fZ; }
169 Scalar P()
const {
return sqrt(P2()); }
170 Scalar R()
const {
return P(); }
177 return ( fM >= 0 ) ? fM*fM : -fM*fM;
179 Scalar Mag2()
const {
return M2(); }
181 Scalar Mag()
const {
return M(); }
187 Scalar e2 = P2() + M2();
189 return e2 > 0 ? e2 : 0;
195 Scalar Pt2()
const {
return fX*fX + fY*fY;}
196 Scalar Perp2()
const {
return Pt2();}
201 Scalar Pt()
const {
return sqrt(Perp2()); }
202 Scalar Perp()
const {
return Pt();}
203 Scalar Rho()
const {
return Pt();}
208 Scalar Mt2()
const {
return E2() - fZ*fZ; }
214 const Scalar mm = Mt2();
218 GenVector::Throw (
"PxPyPzM4D::Mt() - Tachyonic:\n"
219 " Pz^2 > E^2 so the transverse mass would be imaginary");
230 return pt2 == 0 ? 0 : E2() * pt2/( pt2 + fZ*fZ );
237 const Scalar etet = Et2();
244 Scalar Phi()
const {
return (fX == 0.0 && fY == 0.0) ? 0.0 : atan2(fY, fX); }
249 Scalar Theta()
const {
return (fX == 0.0 && fY == 0.0 && fZ == 0.0) ? 0 : atan2(Pt(), fZ); }
255 return Impl::Eta_FromRhoZ ( Pt(), fZ);
264 void SetPx( Scalar px) {
270 void SetPy( Scalar py) {
276 void SetPz( Scalar pz) {
282 void SetM( Scalar m) {
284 if (fM < 0) RestrictNegMass();
290 void SetPxPyPzE(Scalar px, Scalar py, Scalar pz, Scalar e);
303 GenVector::Throw (
"PxPyPzM4D::Negate - cannot negate the energy - can negate only the spatial components");
309 void Scale(
const Scalar & a) {
320 bool operator == (
const PxPyPzM4D & rhs)
const {
321 return fX == rhs.fX && fY == rhs.fY && fZ == rhs.fZ && fM == rhs.fM;
323 bool operator != (
const PxPyPzM4D & rhs)
const {
return !(operator==(rhs));}
330 Scalar x()
const {
return X(); }
331 Scalar y()
const {
return Y(); }
332 Scalar z()
const {
return Z(); }
333 Scalar t()
const {
return E(); }
337 #if defined(__MAKECINT__) || defined(G__DICTIONARY)
341 void SetPt(Scalar pt);
343 void SetEta(Scalar eta);
345 void SetPhi(Scalar phi);
355 inline void RestrictNegMass() {
356 if ( fM >=0 )
return;
357 if ( P2() - fM*fM < 0 ) {
358 GenVector::Throw(
"PxPyPzM4D::unphysical value of mass, set to closest physical value");
389 template <
class ScalarType>
390 inline void PxPyPzM4D<ScalarType>::SetPxPyPzE(Scalar px, Scalar py, Scalar pz, Scalar e) {
391 *
this = PxPyPzE4D<Scalar> (px, py, pz, e);
395 #if defined(__MAKECINT__) || defined(G__DICTIONARY)
401 template <
class ScalarType>
402 inline void PxPyPzM4D<ScalarType>::SetPt(ScalarType pt) {
403 GenVector_exception e(
"PxPyPzM4D::SetPt() is not supposed to be called");
405 PtEtaPhiE4D<ScalarType> v(*
this); v.SetPt(pt); *
this = PxPyPzM4D<ScalarType>(v);
407 template <
class ScalarType>
408 inline void PxPyPzM4D<ScalarType>::SetEta(ScalarType eta) {
409 GenVector_exception e(
"PxPyPzM4D::SetEta() is not supposed to be called");
411 PtEtaPhiE4D<ScalarType> v(*
this); v.SetEta(eta); *
this = PxPyPzM4D<ScalarType>(v);
413 template <
class ScalarType>
414 inline void PxPyPzM4D<ScalarType>::SetPhi(ScalarType phi) {
415 GenVector_exception e(
"PxPyPzM4D::SetPhi() is not supposed to be called");
417 PtEtaPhiE4D<ScalarType> v(*
this); v.SetPhi(phi); *
this = PxPyPzM4D<ScalarType>(v);
419 template <
class ScalarType>
420 inline void PxPyPzM4D<ScalarType>::SetE(ScalarType energy) {
421 GenVector_exception e(
"PxPyPzM4D::SetE() is not supposed to be called");
423 PxPyPzE4D<ScalarType> v(*
this); v.SetE(energy);
424 *
this = PxPyPzM4D<ScalarType>(v);
428 #endif // endif __MAKE__CINT || G__DICTIONARY
436 #endif // ROOT_Math_GenVector_PxPyPzM4D