# Project CMSSW displayed by LXR

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

```0001 #ifndef DataFormats_Math_Angle_Units_h
0002 #define DataFormats_Math_Angle_Units_h
0003
0004 #include <cmath>
0005
0006 namespace angle_units {
0007
0010
0011   namespace operators {
0012
0013     // Angle
0014     constexpr double operator"" _pi(long double x) { return double(x) * M_PI; }
0015     constexpr double operator"" _pi(unsigned long long int x) { return double(x) * M_PI; }
0016     constexpr double operator"" _deg(long double deg) { return deg / degPerRad; }
0017     constexpr double operator"" _deg(unsigned long long int deg) { return deg / degPerRad; }
0019
0020     template <class NumType>
0022     {
0024     }
0025
0026     template <class NumType>
0028     {
0030     }
0031
0032     template <class NumType>
0033     typename std::enable_if<!std::numeric_limits<NumType>::is_integer, bool>::type almostEqual(NumType x,
0034                                                                                                NumType y,
0035                                                                                                int ulp) {
0036       return std::fabs(x - y) <= std::numeric_limits<NumType>::epsilon() * std::fabs(x + y) * ulp ||
0037              std::fabs(x - y) < std::numeric_limits<NumType>::min();
0038     }
0039
0040     // Unit conversion functions. They are not related to angles, but it is convenient to define them here
0041     // to avoid code duplication.
0042
0043     template <class NumType>
0044     inline constexpr NumType convertMmToCm(NumType millimeters)  // Millimeters -> centimeters
0045     {
0046       return (millimeters / 10.);
0047     }
0048
0049     template <class NumType>
0050     inline constexpr NumType convertCmToMm(NumType centimeters)  // Centimeters -> Milliimeters
0051     {
0052       return (centimeters * 10.);
0053     }
0054
0055     template <class NumType>
0056     inline constexpr NumType convertCm2ToMm2(NumType centimeters)  // Centimeters^2 -> Milliimeters^2
0057     {
0058       return (centimeters * 100.);
0059     }
0060
0061     template <class NumType>
0062     inline constexpr NumType convertMm3ToM3(NumType mm3)  // Cubic millimeters -> cubic meters
0063     {
0064       return (mm3 / 1.e9);
0065     }
0066
0067     template <class NumType>
0068     inline constexpr NumType convertMeVToGeV(NumType mev)  // MeV -> GeV
0069     {
0070       return (mev * 0.001);
0071     }
0072
0073     template <class NumType>
0074     inline constexpr NumType convertGeVToMeV(NumType gev)  // GeV -> MeV
0075     {
0076       return (gev * 1000.);
0077     }
0078
0079     template <class NumType>
0080     inline constexpr NumType convertGeVToKeV(NumType gev)  // GeV -> keV
0081     {
0082       return (gev * 1.e6);
0083     }
0084
0085   }  // namespace operators
0086 }  // namespace angle_units
0087
0088 #endif```