File indexing completed on 2025-01-30 10:26:17
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef VECGEOM_VOLUMES_PARABOLOIDSTRUCT_H_
0010 #define VECGEOM_VOLUMES_PARABOLOIDSTRUCT_H_
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 ParaboloidStruct {
0020 T fRlo;
0021 T fRhi;
0022 T fDz;
0023
0024
0025 T fDx;
0026 T fDy;
0027 T fA;
0028 T fInvA;
0029 T fA2;
0030 T fB;
0031 T fB2;
0032 T fInvB;
0033 T fK1;
0034 T fK2;
0035 T fRlo2;
0036 T fRhi2;
0037
0038
0039 VECCORE_ATT_HOST_DEVICE
0040 ParaboloidStruct()
0041 : fRlo(0.), fRhi(0.), fDz(0.), fA(0.), fInvA(0.), fB(0.), fInvB(0.), fK1(0.), fK2(0.), fRlo2(0.), fRhi2(0.)
0042 {
0043 CalculateCached();
0044 }
0045
0046
0047
0048
0049
0050 VECCORE_ATT_HOST_DEVICE
0051 ParaboloidStruct(const T rlo, const T rhi, const T dz)
0052 : fRlo(rlo), fRhi(rhi), fDz(dz), fA(0.), fInvA(0.), fB(0.), fInvB(0.), fK1(0.), fK2(0.), fRlo2(0.), fRhi2(0.)
0053 {
0054 CalculateCached();
0055 }
0056
0057
0058 VECCORE_ATT_HOST_DEVICE
0059 void CalculateCached()
0060 {
0061 fRlo2 = fRlo * fRlo;
0062 fRhi2 = fRhi * fRhi;
0063 T dd = 1. / (fRhi2 - fRlo2);
0064 fA = 2. * fDz * dd;
0065 fB = -fDz * (fRlo2 + fRhi2) * dd;
0066 fK1 = (fRhi2 - fRlo2) * 0.5 / fDz;
0067 fK2 = (fRhi2 + fRlo2) * 0.5;
0068 fInvA = 1 / fA;
0069 fInvB = 1 / fB;
0070 fA2 = fA * fA;
0071 fB2 = fB * fB;
0072 ComputeBoundingBox();
0073 }
0074
0075
0076 VECCORE_ATT_HOST_DEVICE
0077 void ComputeBoundingBox()
0078 {
0079 fDx = Max(fRhi, fRlo);
0080 fDy = fDx;
0081 }
0082
0083
0084
0085
0086
0087 VECCORE_ATT_HOST_DEVICE
0088 void SetRloAndRhiAndDz(const T rlo, const T rhi, const T dz)
0089 {
0090
0091 if ((rlo < 0) || (rhi < 0) || (dz <= 0)) {
0092
0093 printf("Error SetRloAndRhiAndDz: invalid dimensions. Check (rlo>=0) (rhi>=0) (dz>0)\n");
0094 return;
0095 }
0096 fRlo = rlo;
0097 fRhi = rhi;
0098 fDz = dz;
0099 CalculateCached();
0100 }
0101
0102
0103
0104 VECCORE_ATT_HOST_DEVICE
0105 void SetRlo(const T rlo) { SetRloAndRhiAndDz(rlo, fRhi, fDz); }
0106
0107
0108
0109 VECCORE_ATT_HOST_DEVICE
0110 void SetRhi(const T rhi) { SetRloAndRhiAndDz(fRlo, rhi, fDz); }
0111
0112
0113
0114 VECCORE_ATT_HOST_DEVICE
0115 void SetDz(const T dz) { SetRloAndRhiAndDz(fRlo, fRhi, dz); }
0116 };
0117 }
0118 }
0119
0120 #endif