CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CMSUnits.h
Go to the documentation of this file.
1 #ifndef DataFormats_Math_CMS_Units_h
2 #define DataFormats_Math_CMS_Units_h
3 
4 // This file provides units represented with user-defined literals to more easily attach units to numerical values.
5 // The CMS convention is that centimeter = 1 and GeV = 1
6 
8 
9 namespace cms_units {
10 
11  using angle_units::piRadians; // Needed by files the include this file
12 
13  namespace operators {
14 
15  // The following are needed by files that include this header
16  // Since "using namespace" is prohibited in header files, each
17  // name is individually imported with a "using" statement.
24 
25  // Length
26  constexpr double operator"" _mm(long double length) { return length * 0.1; }
27  constexpr double operator"" _cm(long double length) { return length * 1.; }
28  constexpr double operator"" _m(long double length) { return length * 100.; }
29  constexpr double operator"" _cm3(long double length) { return length * 1._cm * 1._cm * 1._cm; }
30  constexpr double operator"" _m3(long double length) { return length * 1._m * 1._m * 1._m; }
31  constexpr double operator"" _mm(unsigned long long int length) { return length * 0.1; }
32  constexpr double operator"" _cm(unsigned long long int length) { return length * 1; }
33 
34  } // namespace operators
35 } // namespace cms_units
36 
37 #endif
constexpr double convertDegToRad(NumType degrees)
Definition: angle_units.h:27
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
std::enable_if<!std::numeric_limits< NumType >::is_integer, bool >::type almostEqual(NumType x, NumType y, int ulp)
Definition: angle_units.h:33
constexpr double piRadians(M_PI)