File indexing completed on 2025-01-18 10:10:11
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef ROOT_Math_GenVector_PxPyPzE4D
0019 #define ROOT_Math_GenVector_PxPyPzE4D 1
0020
0021 #include "Math/GenVector/eta.h"
0022
0023 #include "Math/GenVector/GenVector_exception.h"
0024
0025
0026 #include <cmath>
0027
0028 namespace ROOT {
0029
0030 namespace Math {
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043 template <class ScalarType = double>
0044 class PxPyPzE4D {
0045
0046 public :
0047
0048 typedef ScalarType Scalar;
0049 static constexpr unsigned int Dimension = 4U;
0050
0051
0052
0053
0054
0055
0056 PxPyPzE4D() : fX(0.0), fY(0.0), fZ(0.0), fT(0.0) { }
0057
0058
0059
0060
0061
0062 PxPyPzE4D(Scalar px, Scalar py, Scalar pz, Scalar e) :
0063 fX(px), fY(py), fZ(pz), fT(e) { }
0064
0065
0066
0067
0068
0069
0070 template <class CoordSystem>
0071 explicit constexpr PxPyPzE4D(const CoordSystem & v) :
0072 fX( v.x() ), fY( v.y() ), fZ( v.z() ), fT( v.t() ) { }
0073
0074
0075
0076
0077
0078
0079 PxPyPzE4D(const PxPyPzE4D & v) :
0080 fX(v.fX), fY(v.fY), fZ(v.fZ), fT(v.fT) { }
0081
0082
0083
0084
0085 PxPyPzE4D & operator = (const PxPyPzE4D & v) {
0086 fX = v.fX;
0087 fY = v.fY;
0088 fZ = v.fZ;
0089 fT = v.fT;
0090 return *this;
0091 }
0092
0093
0094
0095
0096 void SetCoordinates( const Scalar src[] )
0097 { fX=src[0]; fY=src[1]; fZ=src[2]; fT=src[3]; }
0098
0099
0100
0101
0102 void GetCoordinates( Scalar dest[] ) const
0103 { dest[0] = fX; dest[1] = fY; dest[2] = fZ; dest[3] = fT; }
0104
0105
0106
0107
0108 void SetCoordinates(Scalar px, Scalar py, Scalar pz, Scalar e)
0109 { fX=px; fY=py; fZ=pz; fT=e;}
0110
0111
0112
0113
0114 void GetCoordinates(Scalar& px, Scalar& py, Scalar& pz, Scalar& e) const
0115 { px=fX; py=fY; pz=fZ; e=fT;}
0116
0117
0118
0119
0120
0121 Scalar Px() const { return fX;}
0122 Scalar Py() const { return fY;}
0123 Scalar Pz() const { return fZ;}
0124 Scalar E() const { return fT;}
0125
0126 Scalar X() const { return fX;}
0127 Scalar Y() const { return fY;}
0128 Scalar Z() const { return fZ;}
0129 Scalar T() const { return fT;}
0130
0131
0132
0133
0134
0135
0136 Scalar P2() const { return fX*fX + fY*fY + fZ*fZ; }
0137
0138
0139
0140
0141 Scalar P() const { using std::sqrt; return sqrt(P2()); }
0142 Scalar R() const { return P(); }
0143
0144
0145
0146
0147 Scalar M2() const { return fT*fT - fX*fX - fY*fY - fZ*fZ;}
0148 Scalar Mag2() const { return M2(); }
0149
0150
0151
0152
0153 Scalar M() const
0154 {
0155 const Scalar mm = M2();
0156 if (mm >= 0) {
0157 using std::sqrt;
0158 return sqrt(mm);
0159 } else {
0160 GenVector::Throw ("PxPyPzE4D::M() - Tachyonic:\n"
0161 " P^2 > E^2 so the mass would be imaginary");
0162 using std::sqrt;
0163 return -sqrt(-mm);
0164 }
0165 }
0166 Scalar Mag() const { return M(); }
0167
0168
0169
0170
0171 Scalar Pt2() const { return fX*fX + fY*fY;}
0172 Scalar Perp2() const { return Pt2();}
0173
0174
0175
0176
0177 Scalar Pt() const { using std::sqrt; return sqrt(Perp2()); }
0178 Scalar Perp() const { return Pt();}
0179 Scalar Rho() const { return Pt();}
0180
0181
0182
0183
0184 Scalar Mt2() const { return fT*fT - fZ*fZ; }
0185
0186
0187
0188
0189 Scalar Mt() const {
0190 const Scalar mm = Mt2();
0191 if (mm >= 0) {
0192 using std::sqrt;
0193 return sqrt(mm);
0194 } else {
0195 GenVector::Throw ("PxPyPzE4D::Mt() - Tachyonic:\n"
0196 " Pz^2 > E^2 so the transverse mass would be imaginary");
0197 using std::sqrt;
0198 return -sqrt(-mm);
0199 }
0200 }
0201
0202
0203
0204
0205 Scalar Et2() const {
0206
0207 Scalar pt2 = Pt2();
0208 return pt2 == 0 ? 0 : fT*fT * pt2/( pt2 + fZ*fZ );
0209 }
0210
0211
0212
0213
0214 Scalar Et() const {
0215 const Scalar etet = Et2();
0216 using std::sqrt;
0217 return fT < 0.0 ? -sqrt(etet) : sqrt(etet);
0218 }
0219
0220
0221
0222
0223 Scalar Phi() const { using std::atan2; return (fX == 0.0 && fY == 0.0) ? 0 : atan2(fY, fX); }
0224
0225
0226
0227
0228 Scalar Theta() const { using std::atan2; return (fX == 0.0 && fY == 0.0 && fZ == 0.0) ? 0 : atan2(Pt(), fZ); }
0229
0230
0231
0232
0233 Scalar Eta() const {
0234 return Impl::Eta_FromRhoZ ( Pt(), fZ);
0235 }
0236
0237
0238
0239
0240
0241
0242
0243 void SetPx( Scalar px) {
0244 fX = px;
0245 }
0246
0247
0248
0249 void SetPy( Scalar py) {
0250 fY = py;
0251 }
0252
0253
0254
0255 void SetPz( Scalar pz) {
0256 fZ = pz;
0257 }
0258
0259
0260
0261 void SetE( Scalar e) {
0262 fT = e;
0263 }
0264
0265
0266
0267
0268 void SetPxPyPzE(Scalar px, Scalar py, Scalar pz, Scalar e) {
0269 fX=px;
0270 fY=py;
0271 fZ=pz;
0272 fT=e;
0273 }
0274
0275
0276
0277
0278
0279
0280
0281
0282 void Negate( ) { fX = -fX; fY = -fY; fZ = -fZ; fT = -fT;}
0283
0284
0285
0286
0287 void Scale( const Scalar & a) {
0288 fX *= a;
0289 fY *= a;
0290 fZ *= a;
0291 fT *= a;
0292 }
0293
0294
0295
0296
0297
0298 template <class AnyCoordSystem>
0299 PxPyPzE4D & operator = (const AnyCoordSystem & v) {
0300 fX = v.x();
0301 fY = v.y();
0302 fZ = v.z();
0303 fT = v.t();
0304 return *this;
0305 }
0306
0307
0308
0309
0310 bool operator == (const PxPyPzE4D & rhs) const {
0311 return fX == rhs.fX && fY == rhs.fY && fZ == rhs.fZ && fT == rhs.fT;
0312 }
0313 bool operator != (const PxPyPzE4D & rhs) const {return !(operator==(rhs));}
0314
0315
0316
0317
0318
0319
0320 Scalar x() const { return fX; }
0321 Scalar y() const { return fY; }
0322 Scalar z() const { return fZ; }
0323 Scalar t() const { return fT; }
0324
0325
0326
0327 #if defined(__MAKECINT__) || defined(G__DICTIONARY)
0328
0329
0330
0331 void SetPt(Scalar pt);
0332
0333 void SetEta(Scalar eta);
0334
0335 void SetPhi(Scalar phi);
0336
0337 void SetM(Scalar m);
0338
0339 #endif
0340
0341 private:
0342
0343
0344
0345
0346
0347 ScalarType fX;
0348 ScalarType fY;
0349 ScalarType fZ;
0350 ScalarType fT;
0351
0352 };
0353
0354 }
0355 }
0356
0357
0358
0359 #if defined(__MAKECINT__) || defined(G__DICTIONARY)
0360
0361
0362 #include "Math/GenVector/PtEtaPhiE4D.h"
0363 #include "Math/GenVector/PtEtaPhiM4D.h"
0364
0365 namespace ROOT {
0366
0367 namespace Math {
0368
0369
0370
0371
0372
0373 template <class ScalarType>
0374 void PxPyPzE4D<ScalarType>::SetPt(Scalar pt) {
0375 GenVector_exception e("PxPyPzE4D::SetPt() is not supposed to be called");
0376 throw e;
0377 PtEtaPhiE4D<Scalar> v(*this); v.SetPt(pt); *this = PxPyPzE4D<Scalar>(v);
0378 }
0379 template <class ScalarType>
0380 void PxPyPzE4D<ScalarType>::SetEta(Scalar eta) {
0381 GenVector_exception e("PxPyPzE4D::SetEta() is not supposed to be called");
0382 throw e;
0383 PtEtaPhiE4D<Scalar> v(*this); v.SetEta(eta); *this = PxPyPzE4D<Scalar>(v);
0384 }
0385 template <class ScalarType>
0386 void PxPyPzE4D<ScalarType>::SetPhi(Scalar phi) {
0387 GenVector_exception e("PxPyPzE4D::SetPhi() is not supposed to be called");
0388 throw e;
0389 PtEtaPhiE4D<Scalar> v(*this); v.SetPhi(phi); *this = PxPyPzE4D<Scalar>(v);
0390 }
0391
0392 template <class ScalarType>
0393 void PxPyPzE4D<ScalarType>::SetM(Scalar m) {
0394 GenVector_exception e("PxPyPzE4D::SetM() is not supposed to be called");
0395 throw e;
0396 PtEtaPhiM4D<Scalar> v(*this); v.SetM(m);
0397 *this = PxPyPzE4D<Scalar>(v);
0398 }
0399
0400
0401 }
0402
0403 }
0404
0405 #endif
0406
0407
0408 #endif