Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:03

0001 #ifndef DataFormats_Math_PtEtaPhiMass_h
0002 #define DataFormats_Math_PtEtaPhiMass_h
0003 
0004 #include <cmath>
0005 inline float __attribute__((always_inline)) __attribute__((pure)) etaFromXYZ(float x, float y, float z) {
0006   float t(z / std::sqrt(x * x + y * y));
0007   return ::asinhf(t);
0008 }
0009 inline float __attribute__((always_inline)) __attribute__((pure)) etaFromRZ(float r, float z) {
0010   float t(z / r);
0011   return ::asinhf(t);
0012 }
0013 
0014 /// standard cms four-momentum Lorentz vector
0015 /// consistent with LeafCandidate representation
0016 class PtEtaPhiMass {
0017 private:
0018   float pt_, eta_, phi_, mass_;
0019 
0020 public:
0021   // default constructor (unitialized)
0022   PtEtaPhiMass() {}
0023 
0024   //positional constructor (still compatible with Root, c++03)
0025   constexpr PtEtaPhiMass(float ipt, float ieta, float iphi, float imass)
0026       : pt_(ipt), eta_(ieta), phi_(iphi), mass_(imass) {}
0027 
0028   /// transverse momentum
0029   constexpr float pt() const { return pt_; }
0030   /// momentum pseudorapidity
0031   constexpr float eta() const { return eta_; }
0032   /// momentum azimuthal angle
0033   constexpr float phi() const { return phi_; }
0034   /// mass
0035   constexpr float mass() const { return mass_; }
0036 };
0037 
0038 class RhoEtaPhi {
0039 private:
0040   float rho_, eta_, phi_;
0041 
0042 public:
0043   // default constructor (unitialized)
0044   RhoEtaPhi() {}
0045 
0046   //positional constructor (still compatible with Root, c++03)
0047   RhoEtaPhi(float irho, float ieta, float iphi) : rho_(irho), eta_(ieta), phi_(iphi) {}
0048 
0049   /// transverse momentum
0050   float rho() const { return rho_; }
0051   /// momentum pseudorapidity
0052   float eta() const { return eta_; }
0053   /// momentum azimuthal angle
0054   float phi() const { return phi_; }
0055 };
0056 
0057 #endif