File indexing completed on 2025-01-18 10:14:07
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef VOLUMES_HYPESTRUCT_H_
0009 #define VOLUMES_HYPESTRUCT_H_
0010
0011 #include "VecGeom/base/Global.h"
0012
0013 namespace vecgeom {
0014
0015 inline namespace VECGEOM_IMPL_NAMESPACE {
0016
0017
0018 template <typename T = double>
0019 struct HypeStruct {
0020 T fRmin;
0021 T fRmax;
0022 T fStIn;
0023 T fStOut;
0024 T fDz;
0025
0026
0027 Precision fTIn;
0028 Precision fTOut;
0029 Precision fTIn2;
0030 Precision fTOut2;
0031 Precision fTIn2Inv;
0032 Precision fTOut2Inv;
0033 Precision fRmin2;
0034 Precision fRmax2;
0035 Precision fDz2;
0036
0037 Precision fEndInnerRadius2;
0038 Precision fEndOuterRadius2;
0039 Precision fEndInnerRadius;
0040 Precision fEndOuterRadius;
0041
0042 Precision fInSqSide;
0043
0044
0045 Precision fCubicVolume, fSurfaceArea;
0046 Precision zToleranceLevel;
0047 Precision innerRadToleranceLevel, outerRadToleranceLevel;
0048
0049 VECCORE_ATT_HOST_DEVICE
0050 HypeStruct() : fRmin(0.), fRmax(0.), fStIn(0.), fStOut(0.), fDz(0.) {}
0051
0052 VECCORE_ATT_HOST_DEVICE
0053 HypeStruct(const Precision rMin, const Precision rMax, const Precision stIn, const Precision stOut,
0054 const Precision dz)
0055 : fRmin(rMin), fRmax(rMax), fStIn(stIn), fStOut(stOut), fDz(dz)
0056 {
0057 CalculateCached();
0058 }
0059
0060 VECCORE_ATT_HOST_DEVICE
0061 void CalculateCached()
0062 {
0063
0064 fTIn = vecCore::math::Tan(fStIn);
0065 fTOut = vecCore::math::Tan(fStOut);
0066 fTIn2 = fTIn * fTIn;
0067 fTOut2 = fTOut * fTOut;
0068
0069 fTIn2Inv = 1. / fTIn2;
0070 fTOut2Inv = 1. / fTOut2;
0071
0072 fRmin2 = fRmin * fRmin;
0073 fRmax2 = fRmax * fRmax;
0074 fDz2 = fDz * fDz;
0075
0076 fEndInnerRadius2 = fTIn2 * fDz2 + fRmin2;
0077 fEndOuterRadius2 = fTOut2 * fDz2 + fRmax2;
0078 fEndInnerRadius = vecCore::math::Sqrt(fEndInnerRadius2);
0079 fEndOuterRadius = vecCore::math::Sqrt(fEndOuterRadius2);
0080 fInSqSide = vecCore::math::Sqrt(2.) * fRmin;
0081 zToleranceLevel = kTolerance * fDz;
0082 innerRadToleranceLevel = kTolerance * fEndInnerRadius;
0083 outerRadToleranceLevel = kTolerance * fEndOuterRadius;
0084 CalcCapacity();
0085 CalcSurfaceArea();
0086
0087 }
0088
0089 VECCORE_ATT_HOST_DEVICE
0090 bool InnerSurfaceExists() const { return (fRmin > 0.) || (fStIn != 0.); }
0091
0092 VECCORE_ATT_HOST_DEVICE
0093 void CalcCapacity() { fCubicVolume = Volume(true) - Volume(false); }
0094
0095 VECCORE_ATT_HOST_DEVICE
0096 Precision Volume(bool outer)
0097 {
0098 if (outer)
0099 return 2 * kPi * fDz * ((fRmax) * (fRmax) + (fDz2 * fTOut2 / 3.));
0100 else
0101 return 2 * kPi * fDz * ((fRmin) * (fRmin) + (fDz2 * fTIn2 / 3.));
0102 }
0103
0104 VECCORE_ATT_HOST_DEVICE
0105 void CalcSurfaceArea() { fSurfaceArea = Area(true) + Area(false) + AreaEndCaps(); }
0106
0107 VECCORE_ATT_HOST_DEVICE
0108 Precision Area(bool outer)
0109 {
0110 Precision fT = 0., fR = 0.;
0111 if (outer) {
0112 fT = fTOut;
0113 fR = fRmax;
0114 } else {
0115 fT = fTIn;
0116 fR = fRmin;
0117 }
0118
0119 Precision ar = 0.;
0120
0121 if (fT == 0)
0122 ar = 4 * kPi * fR * fDz;
0123 else {
0124 Precision p = fT * std::sqrt(fT * fT);
0125 Precision q = p * fDz * std::sqrt(fR * fR + (std::pow(fT, 2.) + std::pow(fT, 4.)) * std::pow(fDz, 2.));
0126 Precision r = fR * fR * std::asinh(p * fDz / fR);
0127 ar = ((q + r) / (2 * p)) * 4 * kPi;
0128 }
0129 return ar;
0130 }
0131
0132 VECCORE_ATT_HOST_DEVICE
0133 Precision AreaEndCaps() { return 2 * kPi * (fEndOuterRadius2 - fEndInnerRadius2); }
0134
0135 VECCORE_ATT_HOST_DEVICE
0136 void SetParameters(const Precision rMin, const Precision rMax, const Precision stIn, const Precision stOut,
0137 const Precision dz)
0138 {
0139 fRmin = rMin;
0140 fStIn = stIn;
0141 fRmax = rMax;
0142 fStOut = stOut;
0143 fDz = dz;
0144 CalculateCached();
0145 }
0146 };
0147 }
0148 }
0149 #endif