File indexing completed on 2025-01-18 10:14:08
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef VECGEOM_VOLUMES_PARALLELEPIPEDSTRUCT_H_
0010 #define VECGEOM_VOLUMES_PARALLELEPIPEDSTRUCT_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 ParallelepipedStruct {
0020 Vector3D<T> fDimensions;
0021 T fAlpha;
0022 T fTheta;
0023 T fPhi;
0024 T fCtx;
0025 T fCty;
0026 T fAreas[3];
0027 Vector3D<T> fNormals[3];
0028
0029
0030 T fTanAlpha;
0031 T fTanThetaSinPhi;
0032 T fTanThetaCosPhi;
0033 T fCosTheta;
0034
0035
0036
0037
0038
0039
0040 VECCORE_ATT_HOST_DEVICE
0041 ParallelepipedStruct(Vector3D<T> const &dim, const T alpha, const T theta, const T phi)
0042 : fDimensions(dim), fAlpha(0), fTheta(0), fPhi(0), fCtx(0), fCty(0), fTanAlpha(0), fTanThetaSinPhi(0),
0043 fTanThetaCosPhi(0)
0044 {
0045 SetAlpha(alpha);
0046 SetThetaAndPhi(theta, phi);
0047 }
0048
0049
0050
0051
0052
0053
0054
0055
0056 VECCORE_ATT_HOST_DEVICE
0057 ParallelepipedStruct(const T dx, const T dy, const T dz, const T alpha, const T theta, const T phi)
0058 : fDimensions(dx, dy, dz), fAlpha(0), fTheta(0), fPhi(0), fCtx(0), fCty(0), fTanAlpha(0), fTanThetaSinPhi(0),
0059 fTanThetaCosPhi(0)
0060 {
0061 SetAlpha(alpha);
0062 SetThetaAndPhi(theta, phi);
0063 }
0064
0065
0066
0067 VECCORE_ATT_HOST_DEVICE
0068 void SetAlpha(const T alpha)
0069 {
0070 fAlpha = alpha;
0071 fTanAlpha = vecCore::math::Tan(alpha);
0072 ComputeNormals();
0073 }
0074
0075
0076
0077 VECCORE_ATT_HOST_DEVICE
0078 void SetTheta(const T theta) { SetThetaAndPhi(theta, fPhi); }
0079
0080
0081
0082 VECCORE_ATT_HOST_DEVICE
0083 void SetPhi(const T phi) { SetThetaAndPhi(fTheta, phi); }
0084
0085
0086
0087
0088 VECCORE_ATT_HOST_DEVICE
0089 void SetThetaAndPhi(const T theta, const T phi)
0090 {
0091 fTheta = theta;
0092 fPhi = phi;
0093 fTanThetaCosPhi = vecCore::math::Tan(fTheta) * vecCore::math::Cos(fPhi);
0094 fTanThetaSinPhi = vecCore::math::Tan(fTheta) * vecCore::math::Sin(fPhi);
0095 fCosTheta = vecCore::math::Cos(fTheta);
0096 ComputeNormals();
0097 }
0098
0099
0100 VECCORE_ATT_HOST_DEVICE
0101 void ComputeNormals()
0102 {
0103 Vector3D<T> vx(1., 0., 0.);
0104 Vector3D<T> vy(fTanAlpha, 1., 0.);
0105 Vector3D<T> vz(fTanThetaCosPhi, fTanThetaSinPhi, 1.);
0106 fNormals[0] = vy.Cross(vz);
0107 fNormals[1] = vz.Cross(vx);
0108 fNormals[2].Set(0., 0., 1.);
0109 fAreas[0] = 4. * fDimensions.y() * fDimensions.z() * fNormals[0].Mag();
0110 fAreas[1] = 4. * fDimensions.z() * fDimensions.x() * fNormals[1].Mag();
0111 fAreas[2] = 4. * fDimensions.x() * fDimensions.y();
0112 fNormals[0].Normalize();
0113 fNormals[1].Normalize();
0114 fCtx = vecCore::math::Abs(fNormals[0].x());
0115 fCty = vecCore::math::Abs(fNormals[1].y());
0116 }
0117 };
0118 }
0119 }
0120
0121 #endif