Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-28 01:32:16

0001 #ifndef DataFormats_Math_CMS_Units_h
0002 #define DataFormats_Math_CMS_Units_h
0003 
0004 // This file provides units represented with user-defined literals to more easily attach units to numerical values.
0005 // The CMS convention is that centimeter = 1 and GeV = 1
0006 
0007 #include "DataFormats/Math/interface/angle_units.h"
0008 
0009 namespace cms_units {
0010 
0011   using angle_units::piRadians;  // Needed by files the include this file
0012 
0013   namespace operators {
0014 
0015     // The following are needed by files that include this header
0016     // Since "using namespace" is prohibited in header files, each
0017     // name is individually imported with a "using" statement.
0018     using angle_units::operators::operator""_deg;
0019     using angle_units::operators::operator""_pi;
0020     using angle_units::operators::operator""_rad;
0021     using angle_units::operators::almostEqual;
0022     using angle_units::operators::convertDegToRad;
0023     using angle_units::operators::convertRadToDeg;
0024 
0025     // Length
0026     constexpr double operator"" _mm(long double length) { return length * 0.1; }
0027     constexpr double operator"" _cm(long double length) { return length * 1.; }
0028     constexpr double operator"" _m(long double length) { return length * 100.; }
0029     constexpr double operator"" _cm3(long double length) { return length * 1._cm * 1._cm * 1._cm; }
0030     constexpr double operator"" _m3(long double length) { return length * 1._m * 1._m * 1._m; }
0031     constexpr double operator"" _mm(unsigned long long int length) { return length * 0.1; }
0032     constexpr double operator"" _cm(unsigned long long int length) { return length * 1; }
0033 
0034     // Energy
0035     constexpr double operator"" _GeV(long double energy) { return energy * 1.; }
0036     constexpr double operator"" _eV(long double energy) { return energy * 1.e-9_GeV; }
0037     constexpr double operator"" _MeV(long double energy) { return energy * 1.e-3_GeV; }
0038     constexpr double operator"" _TeV(long double energy) { return energy * 1.e3_GeV; }
0039 
0040     // Add these conversion functions to this namespace for convenience
0041     using angle_units::operators::convertCm2ToMm2;
0042     using angle_units::operators::convertCmToMm;
0043     using angle_units::operators::convertGeVToKeV;
0044     using angle_units::operators::convertGeVToMeV;
0045     using angle_units::operators::convertMeVToGeV;
0046     using angle_units::operators::convertMm3ToM3;
0047     using angle_units::operators::convertMmToCm;
0048 
0049   }  // namespace operators
0050 }  // namespace cms_units
0051 
0052 #endif