Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:30:08

0001 // @(#)root/physics:$Id$
0002 // Author: Pasha Murat , Peter Malzacher  12/02/99
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TLorentzVector
0013 #define ROOT_TLorentzVector
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TLorentzVector                                                       //
0019 //                                                                      //
0020 // Place holder for real lorentz vector class.                          //
0021 //                                                                      //
0022 //////////////////////////////////////////////////////////////////////////
0023 
0024 #include "TMath.h"
0025 #include "TVector3.h"
0026 #include "TRotation.h"
0027 #include "Math/Vector4D.h"
0028 
0029 class TLorentzRotation;
0030 
0031 class TLorentzVector : public TObject {
0032 
0033 private:
0034 
0035    TVector3 fP;  // 3 vector component
0036    Double_t fE;  // time or energy of (x,y,z,t) or (px,py,pz,e)
0037 
0038 public:
0039 
0040    typedef Double_t Scalar;   // to be able to use it with the ROOT::Math::VectorUtil functions
0041 
0042    enum { kX=0, kY=1, kZ=2, kT=3, kNUM_COORDINATES=4, kSIZE=kNUM_COORDINATES };
0043    // Safe indexing of the coordinates when using with matrices, arrays, etc.
0044 
0045    TLorentzVector();
0046 
0047    TLorentzVector(Double_t x, Double_t y, Double_t z, Double_t t);
0048    // Constructor giving the components x, y, z, t.
0049 
0050    TLorentzVector(const Double_t * carray);
0051    TLorentzVector(const Float_t * carray);
0052    // Constructor from an array, not checked!
0053 
0054    TLorentzVector(const TVector3 & vector3, Double_t t);
0055    // Constructor giving a 3-Vector and a time component.
0056 
0057    TLorentzVector(const TLorentzVector & lorentzvector) noexcept;
0058    // Copy constructor.
0059 
0060    ~TLorentzVector() override = default;
0061    // Destructor
0062 
0063    // inline operator TVector3 () const;
0064    // inline operator TVector3 & ();
0065    // Conversion (cast) to TVector3.
0066 
0067    inline Double_t X() const;
0068    inline Double_t Y() const;
0069    inline Double_t Z() const;
0070    inline Double_t T() const;
0071    // Get position and time.
0072 
0073    inline void SetX(Double_t a);
0074    inline void SetY(Double_t a);
0075    inline void SetZ(Double_t a);
0076    inline void SetT(Double_t a);
0077    // Set position and time.
0078 
0079    inline Double_t Px() const;
0080    inline Double_t Py() const;
0081    inline Double_t Pz() const;
0082    inline Double_t P()  const;
0083    inline Double_t E()  const;
0084    inline Double_t Energy() const;
0085    // Get momentum and energy.
0086 
0087    inline void SetPx(Double_t a);
0088    inline void SetPy(Double_t a);
0089    inline void SetPz(Double_t a);
0090    inline void SetE(Double_t a);
0091    // Set momentum and energy.
0092 
0093    inline TVector3 Vect() const ;
0094    // Get spatial component.
0095 
0096    inline void SetVect(const TVector3 & vect3);
0097    // Set spatial component.
0098 
0099    inline Double_t Theta() const;
0100    inline Double_t CosTheta() const;
0101    inline Double_t Phi() const; //returns phi from -pi to pi
0102    inline Double_t Rho() const;
0103    // Get spatial vector components in spherical coordinate system.
0104 
0105    inline void SetTheta(Double_t theta);
0106    inline void SetPhi(Double_t phi);
0107    inline void SetRho(Double_t rho);
0108    // Set spatial vector components in spherical coordinate system.
0109 
0110    inline void SetPxPyPzE(Double_t px, Double_t py, Double_t pz, Double_t e);
0111    inline void SetXYZT(Double_t  x, Double_t  y, Double_t  z, Double_t t);
0112    inline void SetXYZM(Double_t  x, Double_t  y, Double_t  z, Double_t m);
0113    inline void SetPtEtaPhiM(Double_t pt, Double_t eta, Double_t phi, Double_t m);
0114    inline void SetPtEtaPhiE(Double_t pt, Double_t eta, Double_t phi, Double_t e);
0115    // Setters to provide the functionality (but a more meanigful name) of
0116    // the previous version eg SetV4... PsetV4...
0117 
0118    inline void GetXYZT(Double_t *carray) const;
0119    inline void GetXYZT(Float_t *carray) const;
0120    // Getters into an arry
0121    // no checking!
0122 
0123    Double_t operator () (int i) const;
0124    inline Double_t operator [] (int i) const;
0125    // Get components by index.
0126 
0127    Double_t & operator () (int i);
0128    inline Double_t & operator [] (int i);
0129    // Set components by index.
0130 
0131    inline TLorentzVector & operator = (const TLorentzVector &) noexcept;
0132    // Assignment.
0133 
0134    inline TLorentzVector   operator +  (const TLorentzVector &) const;
0135    inline TLorentzVector & operator += (const TLorentzVector &);
0136    // Additions.
0137 
0138    inline TLorentzVector   operator -  (const TLorentzVector &) const;
0139    inline TLorentzVector & operator -= (const TLorentzVector &);
0140    // Subtractions.
0141 
0142    inline TLorentzVector operator - () const;
0143    // Unary minus.
0144 
0145    inline TLorentzVector operator * (Double_t a) const;
0146    inline TLorentzVector & operator *= (Double_t a);
0147    // Scaling with real numbers.
0148 
0149    inline Bool_t operator == (const TLorentzVector &) const;
0150    inline Bool_t operator != (const TLorentzVector &) const;
0151    // Comparisons.
0152 
0153    inline Double_t Perp2() const;
0154    // Transverse component of the spatial vector squared.
0155 
0156    inline Double_t Pt() const;
0157    inline Double_t Perp() const;
0158    // Transverse component of the spatial vector (R in cylindrical system).
0159 
0160    inline void SetPerp(Double_t);
0161    // Set the transverse component of the spatial vector.
0162 
0163    inline Double_t Perp2(const TVector3 & v) const;
0164    // Transverse component of the spatial vector w.r.t. given axis squared.
0165 
0166    inline Double_t Pt(const TVector3 & v) const;
0167    inline Double_t Perp(const TVector3 & v) const;
0168    // Transverse component of the spatial vector w.r.t. given axis.
0169 
0170    inline Double_t Et2() const;
0171    // Transverse energy squared.
0172 
0173    inline Double_t Et() const;
0174    // Transverse energy.
0175 
0176    inline Double_t Et2(const TVector3 &) const;
0177    // Transverse energy w.r.t. given axis squared.
0178 
0179    inline Double_t Et(const TVector3 &) const;
0180    // Transverse energy w.r.t. given axis.
0181 
0182    inline Double_t DeltaPhi(const TLorentzVector &) const;
0183    inline Double_t DeltaR(const TLorentzVector &, Bool_t useRapidity=kFALSE) const;
0184    inline Double_t DrEtaPhi(const TLorentzVector &) const;
0185    inline Double_t DrRapidityPhi(const TLorentzVector &) const;
0186    inline TVector2 EtaPhiVector();
0187 
0188    inline Double_t Angle(const TVector3 & v) const;
0189    // Angle wrt. another vector.
0190 
0191    inline Double_t Mag2() const;
0192    inline Double_t M2() const;
0193    // Invariant mass squared.
0194 
0195    inline Double_t Mag() const;
0196    inline Double_t M() const;
0197    // Invariant mass. If mag2() is negative then -sqrt(-mag2()) is returned.
0198 
0199    inline Double_t Mt2() const;
0200    // Transverse mass squared.
0201 
0202    inline Double_t Mt() const;
0203    // Transverse mass.
0204 
0205    inline Double_t Beta() const;
0206    inline Double_t Gamma() const;
0207 
0208    inline Double_t Dot(const TLorentzVector &) const;
0209    inline Double_t operator * (const TLorentzVector &) const;
0210    // Scalar product.
0211 
0212    inline void SetVectMag(const TVector3 & spatial, Double_t magnitude);
0213    inline void SetVectM(const TVector3 & spatial, Double_t mass);
0214    // Copy spatial coordinates, and set energy = sqrt(mass^2 + spatial^2)
0215 
0216    inline Double_t Plus() const;
0217    inline Double_t Minus() const;
0218    // Returns t +/- z.
0219    // Related to the positive/negative light-cone component,
0220    // which some define this way and others define as (t +/- z)/sqrt(2)
0221 
0222    inline TVector3 BoostVector() const ;
0223    // Returns the spatial components divided by the time component.
0224 
0225    void Boost(Double_t, Double_t, Double_t);
0226    inline void Boost(const TVector3 &);
0227    // Lorentz boost.
0228 
0229    Double_t Rapidity() const;
0230    // Returns the rapidity, i.e. 0.5*ln((E+pz)/(E-pz))
0231 
0232    inline Double_t Eta() const;
0233    inline Double_t PseudoRapidity() const;
0234    // Returns the pseudo-rapidity, i.e. -ln(tan(theta/2))
0235 
0236    inline void RotateX(Double_t angle);
0237    // Rotate the spatial component around the x-axis.
0238 
0239    inline void RotateY(Double_t angle);
0240    // Rotate the spatial component around the y-axis.
0241 
0242    inline void RotateZ(Double_t angle);
0243    // Rotate the spatial component around the z-axis.
0244 
0245    inline void RotateUz(const TVector3 & newUzVector);
0246    // Rotates the reference frame from Uz to newUz (unit vector).
0247 
0248    inline void Rotate(Double_t, const TVector3 &);
0249    // Rotate the spatial component around specified axis.
0250 
0251    inline TLorentzVector & operator *= (const TRotation &);
0252    inline TLorentzVector & Transform(const TRotation &);
0253    // Transformation with HepRotation.
0254 
0255    TLorentzVector & operator *= (const TLorentzRotation &);
0256    TLorentzVector & Transform(const TLorentzRotation &);
0257    // Transformation with HepLorenzRotation.
0258 
0259    operator ROOT::Math::PxPyPzEVector() const {
0260       return {Px(), Py(), Pz(), E()};
0261    }
0262 
0263    void        Print(Option_t *option="") const override;
0264 
0265    ClassDefOverride(TLorentzVector,4) // A four vector with (-,-,-,+) metric
0266 };
0267 
0268 
0269 //inline TLorentzVector operator * (const TLorentzVector &, Double_t a);
0270 // moved to TLorentzVector::operator * (Double_t a)
0271 inline TLorentzVector operator * (Double_t a, const TLorentzVector &);
0272 // Scaling LorentzVector with a real number
0273 
0274 
0275 inline Double_t TLorentzVector::X() const { return fP.X(); }
0276 inline Double_t TLorentzVector::Y() const { return fP.Y(); }
0277 inline Double_t TLorentzVector::Z() const { return fP.Z(); }
0278 inline Double_t TLorentzVector::T() const { return fE; }
0279 
0280 inline void TLorentzVector::SetX(Double_t a) { fP.SetX(a); }
0281 inline void TLorentzVector::SetY(Double_t a) { fP.SetY(a); }
0282 inline void TLorentzVector::SetZ(Double_t a) { fP.SetZ(a); }
0283 inline void TLorentzVector::SetT(Double_t a) { fE = a; }
0284 
0285 inline Double_t TLorentzVector::Px() const { return X(); }
0286 inline Double_t TLorentzVector::Py() const { return Y(); }
0287 inline Double_t TLorentzVector::Pz() const { return Z(); }
0288 inline Double_t TLorentzVector::P()  const { return fP.Mag(); }
0289 inline Double_t TLorentzVector::E()  const { return T(); }
0290 inline Double_t TLorentzVector::Energy()  const { return T(); }
0291 
0292 inline void TLorentzVector::SetPx(Double_t a) { SetX(a); }
0293 inline void TLorentzVector::SetPy(Double_t a) { SetY(a); }
0294 inline void TLorentzVector::SetPz(Double_t a) { SetZ(a); }
0295 inline void TLorentzVector::SetE(Double_t a)  { SetT(a); }
0296 
0297 inline TVector3 TLorentzVector::Vect() const { return fP; }
0298 
0299 inline void TLorentzVector::SetVect(const TVector3 &p) { fP = p; }
0300 
0301 inline Double_t TLorentzVector::Phi() const {
0302    return fP.Phi();
0303 }
0304 
0305 inline Double_t TLorentzVector::Theta() const {
0306    return fP.Theta();
0307 }
0308 
0309 inline Double_t TLorentzVector::CosTheta() const {
0310    return fP.CosTheta();
0311 }
0312 
0313 
0314 inline Double_t TLorentzVector::Rho() const {
0315    return fP.Mag();
0316 }
0317 
0318 inline void TLorentzVector::SetTheta(Double_t th) {
0319    fP.SetTheta(th);
0320 }
0321 
0322 inline void TLorentzVector::SetPhi(Double_t phi) {
0323    fP.SetPhi(phi);
0324 }
0325 
0326 inline void TLorentzVector::SetRho(Double_t rho) {
0327    fP.SetMag(rho);
0328 }
0329 
0330 inline void TLorentzVector::SetXYZT(Double_t  x, Double_t  y, Double_t  z, Double_t t) {
0331    fP.SetXYZ(x, y, z);
0332    SetT(t);
0333 }
0334 
0335 inline void TLorentzVector::SetPxPyPzE(Double_t px, Double_t py, Double_t pz, Double_t e) {
0336    SetXYZT(px, py, pz, e);
0337 }
0338 
0339 inline void TLorentzVector::SetXYZM(Double_t  x, Double_t  y, Double_t  z, Double_t m) {
0340    if ( m  >= 0 )
0341       SetXYZT( x, y, z, TMath::Sqrt(x*x+y*y+z*z+m*m) );
0342    else
0343       SetXYZT( x, y, z, TMath::Sqrt( TMath::Max((x*x+y*y+z*z-m*m), 0. ) ) );
0344 }
0345 
0346 inline void TLorentzVector::SetPtEtaPhiM(Double_t pt, Double_t eta, Double_t phi, Double_t m) {
0347    pt = TMath::Abs(pt);
0348    SetXYZM(pt*TMath::Cos(phi), pt*TMath::Sin(phi), pt*sinh(eta) ,m);
0349 }
0350 
0351 inline void TLorentzVector::SetPtEtaPhiE(Double_t pt, Double_t eta, Double_t phi, Double_t e) {
0352    pt = TMath::Abs(pt);
0353    SetXYZT(pt*TMath::Cos(phi), pt*TMath::Sin(phi), pt*sinh(eta) ,e);
0354 }
0355 
0356 inline void TLorentzVector::GetXYZT(Double_t *carray) const {
0357    fP.GetXYZ(carray);
0358    carray[3] = fE;
0359 }
0360 
0361 inline void TLorentzVector::GetXYZT(Float_t *carray) const{
0362    fP.GetXYZ(carray);
0363    carray[3] = fE;
0364 }
0365 
0366 inline Double_t & TLorentzVector::operator [] (int i)       { return (*this)(i); }
0367 inline Double_t   TLorentzVector::operator [] (int i) const { return (*this)(i); }
0368 
0369 inline TLorentzVector &TLorentzVector::operator = (const TLorentzVector & q) noexcept {
0370    fP = q.Vect();
0371    fE = q.T();
0372    return *this;
0373 }
0374 
0375 inline TLorentzVector TLorentzVector::operator + (const TLorentzVector & q) const {
0376    return TLorentzVector(fP+q.Vect(), fE+q.T());
0377 }
0378 
0379 inline TLorentzVector &TLorentzVector::operator += (const TLorentzVector & q) {
0380    fP += q.Vect();
0381    fE += q.T();
0382    return *this;
0383 }
0384 
0385 inline TLorentzVector TLorentzVector::operator - (const TLorentzVector & q) const {
0386    return TLorentzVector(fP-q.Vect(), fE-q.T());
0387 }
0388 
0389 inline TLorentzVector &TLorentzVector::operator -= (const TLorentzVector & q) {
0390    fP -= q.Vect();
0391    fE -= q.T();
0392    return *this;
0393 }
0394 
0395 inline TLorentzVector TLorentzVector::operator - () const {
0396    return TLorentzVector(-X(), -Y(), -Z(), -T());
0397 }
0398 
0399 inline TLorentzVector& TLorentzVector::operator *= (Double_t a) {
0400    fP *= a;
0401    fE *= a;
0402    return *this;
0403 }
0404 
0405 inline TLorentzVector TLorentzVector::operator * (Double_t a) const {
0406    return TLorentzVector(a*X(), a*Y(), a*Z(), a*T());
0407 }
0408 
0409 inline Bool_t TLorentzVector::operator == (const TLorentzVector & q) const {
0410    return (Vect() == q.Vect() && T() == q.T());
0411 }
0412 
0413 inline Bool_t TLorentzVector::operator != (const TLorentzVector & q) const {
0414    return (Vect() != q.Vect() || T() != q.T());
0415 }
0416 
0417 inline Double_t TLorentzVector::Perp2() const  { return fP.Perp2(); }
0418 
0419 inline Double_t TLorentzVector::Perp()  const  { return fP.Perp(); }
0420 
0421 inline Double_t TLorentzVector::Pt() const { return Perp(); }
0422 
0423 inline void TLorentzVector::SetPerp(Double_t r) {
0424    fP.SetPerp(r);
0425 }
0426 
0427 inline Double_t TLorentzVector::Perp2(const TVector3 &v) const {
0428    return fP.Perp2(v);
0429 }
0430 
0431 inline Double_t TLorentzVector::Perp(const TVector3 &v) const {
0432    return fP.Perp(v);
0433 }
0434 
0435 inline Double_t TLorentzVector::Pt(const TVector3 &v) const {
0436    return Perp(v);
0437 }
0438 
0439 inline Double_t TLorentzVector::Et2() const {
0440    Double_t pt2 = fP.Perp2();
0441    return pt2 == 0 ? 0 : E()*E() * pt2/(pt2+Z()*Z());
0442 }
0443 
0444 inline Double_t TLorentzVector::Et() const {
0445    Double_t etet = Et2();
0446    return E() < 0.0 ? -sqrt(etet) : sqrt(etet);
0447 }
0448 
0449 inline Double_t TLorentzVector::Et2(const TVector3 & v) const {
0450    Double_t pt2 = fP.Perp2(v);
0451    Double_t pv = fP.Dot(v.Unit());
0452    return pt2 == 0 ? 0 : E()*E() * pt2/(pt2+pv*pv);
0453 }
0454 
0455 inline Double_t TLorentzVector::Et(const TVector3 & v) const {
0456    Double_t etet = Et2(v);
0457    return E() < 0.0 ? -sqrt(etet) : sqrt(etet);
0458 }
0459 
0460 inline Double_t TLorentzVector::DeltaPhi(const TLorentzVector & v) const {
0461    return TVector2::Phi_mpi_pi(Phi()-v.Phi());
0462 }
0463 
0464 inline Double_t TLorentzVector::Eta() const {
0465    return PseudoRapidity();
0466 }
0467 
0468 inline Double_t TLorentzVector::DeltaR(const TLorentzVector & v, const Bool_t useRapidity) const {
0469   if(useRapidity){
0470      Double_t drap = Rapidity()-v.Rapidity();
0471      Double_t dphi = TVector2::Phi_mpi_pi(Phi()-v.Phi());
0472      return TMath::Sqrt( drap*drap+dphi*dphi );
0473   } else {
0474     Double_t deta = Eta()-v.Eta();
0475     Double_t dphi = TVector2::Phi_mpi_pi(Phi()-v.Phi());
0476     return TMath::Sqrt( deta*deta+dphi*dphi );
0477   }
0478 }
0479 
0480 inline Double_t TLorentzVector::DrEtaPhi(const TLorentzVector & v) const{
0481    return DeltaR(v);
0482 }
0483 
0484 inline Double_t TLorentzVector::DrRapidityPhi(const TLorentzVector & v) const{
0485    return DeltaR(v, kTRUE);
0486 }
0487 
0488 inline TVector2 TLorentzVector::EtaPhiVector() {
0489    return TVector2 (Eta(),Phi());
0490 }
0491 
0492 
0493 inline Double_t TLorentzVector::Angle(const TVector3 &v) const {
0494    return fP.Angle(v);
0495 }
0496 
0497 inline Double_t TLorentzVector::Mag2() const {
0498    return T()*T() - fP.Mag2();
0499 }
0500 
0501 inline Double_t TLorentzVector::Mag() const {
0502    Double_t mm = Mag2();
0503    return mm < 0.0 ? -TMath::Sqrt(-mm) : TMath::Sqrt(mm);
0504 }
0505 
0506 inline Double_t TLorentzVector::M2() const { return Mag2(); }
0507 inline Double_t TLorentzVector::M() const { return Mag(); }
0508 
0509 inline Double_t TLorentzVector::Mt2() const {
0510    return E()*E() - Z()*Z();
0511 }
0512 
0513 inline Double_t TLorentzVector::Mt() const {
0514    Double_t mm = Mt2();
0515    return mm < 0.0 ? -TMath::Sqrt(-mm) : TMath::Sqrt(mm);
0516 }
0517 
0518 inline Double_t TLorentzVector::Beta() const {
0519    return fP.Mag() / fE;
0520 }
0521 
0522 inline Double_t TLorentzVector::Gamma() const {
0523    Double_t b = Beta();
0524    return 1.0/TMath::Sqrt(1- b*b);
0525 }
0526 
0527 inline void TLorentzVector::SetVectMag(const TVector3 & spatial, Double_t magnitude) {
0528    SetXYZM(spatial.X(), spatial.Y(), spatial.Z(), magnitude);
0529 }
0530 
0531 inline void TLorentzVector::SetVectM(const TVector3 & spatial, Double_t mass) {
0532    SetVectMag(spatial, mass);
0533 }
0534 
0535 inline Double_t TLorentzVector::Dot(const TLorentzVector & q) const {
0536    return T()*q.T() - Z()*q.Z() - Y()*q.Y() - X()*q.X();
0537 }
0538 
0539 inline Double_t TLorentzVector::operator * (const TLorentzVector & q) const {
0540    return Dot(q);
0541 }
0542 
0543 //Member functions Plus() and Minus() return the positive and negative
0544 //light-cone components:
0545 //
0546 //  Double_t pcone = v.Plus();
0547 //  Double_t mcone = v.Minus();
0548 //
0549 //CAVEAT: The values returned are T{+,-}Z. It is known that some authors
0550 //find it easier to define these components as (T{+,-}Z)/sqrt(2). Thus
0551 //check what definition is used in the physics you're working in and adapt
0552 //your code accordingly.
0553 
0554 inline Double_t TLorentzVector::Plus() const {
0555    return T() + Z();
0556 }
0557 
0558 inline Double_t TLorentzVector::Minus() const {
0559    return T() - Z();
0560 }
0561 
0562 inline TVector3 TLorentzVector::BoostVector() const {
0563    return TVector3(X()/T(), Y()/T(), Z()/T());
0564 }
0565 
0566 inline void TLorentzVector::Boost(const TVector3 & b) {
0567    Boost(b.X(), b.Y(), b.Z());
0568 }
0569 
0570 inline Double_t TLorentzVector::PseudoRapidity() const {
0571    return fP.PseudoRapidity();
0572 }
0573 
0574 inline void TLorentzVector::RotateX(Double_t angle) {
0575    fP.RotateX(angle);
0576 }
0577 
0578 inline void TLorentzVector::RotateY(Double_t angle) {
0579    fP.RotateY(angle);
0580 }
0581 
0582 inline void TLorentzVector::RotateZ(Double_t angle) {
0583    fP.RotateZ(angle);
0584 }
0585 
0586 inline void TLorentzVector::RotateUz(const TVector3 &newUzVector) {
0587    fP.RotateUz(newUzVector);
0588 }
0589 
0590 inline void TLorentzVector::Rotate(Double_t a, const TVector3 &v) {
0591    fP.Rotate(a,v);
0592 }
0593 
0594 inline TLorentzVector &TLorentzVector::operator *= (const TRotation & m) {
0595    fP *= m;
0596    return *this;
0597 }
0598 
0599 inline TLorentzVector &TLorentzVector::Transform(const TRotation & m) {
0600    fP.Transform(m);
0601    return *this;
0602 }
0603 
0604 inline TLorentzVector operator * (Double_t a, const TLorentzVector & p) {
0605    return TLorentzVector(a*p.X(), a*p.Y(), a*p.Z(), a*p.T());
0606 }
0607 
0608 inline TLorentzVector::TLorentzVector()
0609                : fP(), fE(0.0) {}
0610 
0611 inline TLorentzVector::TLorentzVector(Double_t x, Double_t y, Double_t z, Double_t t)
0612                : fP(x,y,z), fE(t) {}
0613 
0614 inline TLorentzVector::TLorentzVector(const Double_t * x0)
0615                : fP(x0), fE(x0[3]) {}
0616 
0617 inline TLorentzVector::TLorentzVector(const Float_t * x0)
0618                : fP(x0), fE(x0[3]) {}
0619 
0620 inline TLorentzVector::TLorentzVector(const TVector3 & p, Double_t e)
0621                : fP(p), fE(e) {}
0622 
0623 inline TLorentzVector::TLorentzVector(const TLorentzVector & p) noexcept : TObject(p)
0624                , fP(p.Vect()), fE(p.T()) {}
0625 
0626 
0627 
0628 inline Double_t TLorentzVector::operator () (int i) const
0629 {
0630    //dereferencing operator const
0631    switch(i) {
0632       case kX:
0633      return fP.X();
0634       case kY:
0635          return fP.Y();
0636       case kZ:
0637          return fP.Z();
0638       case kT:
0639          return fE;
0640       default:
0641          Error("operator()()", "bad index (%d) returning 0",i);
0642    }
0643    return 0.;
0644 }
0645 
0646 inline Double_t & TLorentzVector::operator () (int i)
0647 {
0648    //dereferencing operator
0649    switch(i) {
0650       case kX:
0651          return fP.fX;
0652       case kY:
0653          return fP.fY;
0654       case kZ:
0655          return fP.fZ;
0656       case kT:
0657          return fE;
0658       default:
0659          Error("operator()()", "bad index (%d) returning &fE",i);
0660    }
0661    return fE;
0662 }
0663 
0664 #endif