1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
// This file is part of VecGeom and is distributed under the
// conditions in the file LICENSE.txt in the top directory.
// For the full list of authors see CONTRIBUTORS.txt and `git log`.
/// Declaration of a struct with data members for the UnplacedParallelepiped class
/// @file volumes/ParallelepipedStruct.h
/// @author First version created by Mihaela Gheata
#ifndef VECGEOM_VOLUMES_PARALLELEPIPEDSTRUCT_H_
#define VECGEOM_VOLUMES_PARALLELEPIPEDSTRUCT_H_
#include "VecGeom/base/Global.h"
namespace vecgeom {
inline namespace VECGEOM_IMPL_NAMESPACE {
/// Struct encapsulating data members of the unplaced parallelepiped
template <typename T = double>
struct ParallelepipedStruct {
Vector3D<T> fDimensions; ///< Dimensions dx, dy, dx
T fAlpha; ///< Angle dx versus dy
T fTheta; ///< Theta angle of parallelepiped axis
T fPhi; ///< Phi angle of parallelepiped axis
T fCtx; ///< Scale factor for safety distances in X
T fCty; ///< Scale factor for safety distances in Y
T fAreas[3]; ///< Facet areas
Vector3D<T> fNormals[3]; ///< Precomputed normals
// Precomputed values computed from parameters
T fTanAlpha; ///< Tangent of alpha angle
T fTanThetaSinPhi; ///< tan(theta)*sin(phi)
T fTanThetaCosPhi; ///< tan(theta)*cos(phi)
T fCosTheta; ///< cos(theta)
/// Constructor from a vector of dimensions and three angles
/// @param dim 3D vector with dx, dy, dz
/// @param alpha Angle between y-axis and the line joining centres of the faces at +/- dy
/// @param theta Polar angle
/// @param phi Azimuthal angle
VECCORE_ATT_HOST_DEVICE
ParallelepipedStruct(Vector3D<T> const &dim, const T alpha, const T theta, const T phi)
: fDimensions(dim), fAlpha(0), fTheta(0), fPhi(0), fCtx(0), fCty(0), fTanAlpha(0), fTanThetaSinPhi(0),
fTanThetaCosPhi(0)
{
SetAlpha(alpha);
SetThetaAndPhi(theta, phi);
}
/// Constructor from three dimensions and three angles
/// @param dx Half length in x
/// @param dy Half length in y
/// @param dz Half length in z
/// @param alpha Angle between y-axis and the line joining centres of the faces at +/- dy
/// @param theta Polar angle
/// @param phi Azimuthal angle
VECCORE_ATT_HOST_DEVICE
ParallelepipedStruct(const T dx, const T dy, const T dz, const T alpha, const T theta, const T phi)
: fDimensions(dx, dy, dz), fAlpha(0), fTheta(0), fPhi(0), fCtx(0), fCty(0), fTanAlpha(0), fTanThetaSinPhi(0),
fTanThetaCosPhi(0)
{
SetAlpha(alpha);
SetThetaAndPhi(theta, phi);
}
/// Setter for alpha angle
/// @param alpha angle between Y and the axis of symmetry of the base
VECCORE_ATT_HOST_DEVICE
void SetAlpha(const T alpha)
{
fAlpha = alpha;
fTanAlpha = vecCore::math::Tan(alpha);
ComputeNormals();
}
/// Setter for theta angle
/// @param theta Polar angle
VECCORE_ATT_HOST_DEVICE
void SetTheta(const T theta) { SetThetaAndPhi(theta, fPhi); }
/// Setter for phi angle
/// @param phi Azimuthal angle
VECCORE_ATT_HOST_DEVICE
void SetPhi(const T phi) { SetThetaAndPhi(fTheta, phi); }
/// Setter for theta and phi
/// @param theta Polar angle
/// @param phi Azimuthal angle
VECCORE_ATT_HOST_DEVICE
void SetThetaAndPhi(const T theta, const T phi)
{
fTheta = theta;
fPhi = phi;
fTanThetaCosPhi = vecCore::math::Tan(fTheta) * vecCore::math::Cos(fPhi);
fTanThetaSinPhi = vecCore::math::Tan(fTheta) * vecCore::math::Sin(fPhi);
fCosTheta = vecCore::math::Cos(fTheta);
ComputeNormals();
}
/// Compute auxiliary data members: normals, areas, scale factors
VECCORE_ATT_HOST_DEVICE
void ComputeNormals()
{
Vector3D<T> vx(1., 0., 0.);
Vector3D<T> vy(fTanAlpha, 1., 0.);
Vector3D<T> vz(fTanThetaCosPhi, fTanThetaSinPhi, 1.);
fNormals[0] = vy.Cross(vz);
fNormals[1] = vz.Cross(vx);
fNormals[2].Set(0., 0., 1.);
fAreas[0] = 4. * fDimensions.y() * fDimensions.z() * fNormals[0].Mag();
fAreas[1] = 4. * fDimensions.z() * fDimensions.x() * fNormals[1].Mag();
fAreas[2] = 4. * fDimensions.x() * fDimensions.y();
fNormals[0].Normalize();
fNormals[1].Normalize();
fCtx = vecCore::math::Abs(fNormals[0].x());
fCty = vecCore::math::Abs(fNormals[1].y());
}
};
} // namespace VECGEOM_IMPL_NAMESPACE
} // namespace vecgeom
#endif
|