Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:26:01

0001 #ifndef VECGEOM_MATH_H
0002 #define VECGEOM_MATH_H
0003 
0004 #include <cmath>
0005 #include <limits>
0006 #include "VecCore/Limits.h"
0007 
0008 namespace vecgeom {
0009 inline namespace VECGEOM_IMPL_NAMESPACE {
0010 
0011 #ifdef __CUDA_ARCH__
0012 #define VECGEOM_CONST static __constant__ const
0013 #else
0014 #define VECGEOM_CONST static constexpr
0015 #endif
0016 
0017 #ifdef VECGEOM_FLOAT_PRECISION
0018 using Precision                        = float;
0019 VECGEOM_CONST Precision kTolerance     = 1e-3;
0020 VECGEOM_CONST Precision kPushTolerance = 1e-3;
0021 VECGEOM_CONST Precision kSqrtTolerance = 3.1622777e-2;
0022 VECGEOM_CONST Precision kAngTolerance  = 1e-2;
0023 VECGEOM_CONST Precision kConeTolerance = 1e-3;
0024 VECGEOM_CONST Precision kFarAway       = 1e5;
0025 #else
0026 using Precision                        = double;
0027 VECGEOM_CONST Precision kTolerance     = 1e-9;
0028 VECGEOM_CONST Precision kPushTolerance = 1e-6;
0029 VECGEOM_CONST Precision kSqrtTolerance = 3.1622777e-5;
0030 VECGEOM_CONST Precision kAngTolerance  = 1e-9;
0031 VECGEOM_CONST Precision kConeTolerance = 1e-7;
0032 VECGEOM_CONST Precision kFarAway       = 1e10;
0033 #endif
0034 
0035 using namespace vecCore::math;
0036 
0037 VECGEOM_CONST Precision kAvogadro = 6.02214085774e23;
0038 VECGEOM_CONST Precision kEpsilon  = std::numeric_limits<Precision>::epsilon();
0039 // VECGEOM_CONST Precision kInfinity         = std::numeric_limits<Precision>::infinity();
0040 // a special constant to indicate a "miss" length
0041 VECGEOM_CONST Precision kInfLength         = vecCore::NumericLimits<Precision>::Max();
0042 VECGEOM_CONST Precision kMaximum           = vecCore::NumericLimits<Precision>::Max();
0043 VECGEOM_CONST Precision kMinimum           = vecCore::NumericLimits<Precision>::Min();
0044 VECGEOM_CONST Precision kPi                = 3.14159265358979323846;
0045 VECGEOM_CONST Precision kHalfPi            = 0.5 * kPi;
0046 VECGEOM_CONST Precision kTwoPi             = 2. * kPi;
0047 VECGEOM_CONST Precision kTwoPiInv          = 1. / kTwoPi;
0048 VECGEOM_CONST Precision kDegToRad          = kPi / 180.;
0049 VECGEOM_CONST Precision kRadToDeg          = 180. / kPi;
0050 VECGEOM_CONST Precision kRadTolerance      = 1e-9;
0051 VECGEOM_CONST Precision kTiny              = 1e-30;
0052 VECGEOM_CONST Precision kHalfTolerance     = 0.5 * kTolerance;
0053 VECGEOM_CONST Precision kToleranceSquared  = kTolerance * kTolerance;
0054 
0055 template <typename T>
0056 struct Tiny {
0057   static constexpr T kValue = 1.e-30;
0058 };
0059 
0060 template <template <typename, typename> class ImplementationType, typename T, typename Q>
0061 struct Tiny<ImplementationType<T, Q>> {
0062   static constexpr typename ImplementationType<T, Q>::value_type kValue = 1.e-30;
0063 };
0064 } // namespace VECGEOM_IMPL_NAMESPACE
0065 } // namespace vecgeom
0066 
0067 #endif