Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // This file is part of VecGeom and is distributed under the
0002 // conditions in the file LICENSE.txt in the top directory.
0003 // For the full list of authors see CONTRIBUTORS.txt and `git log`.
0004 
0005 /// Declaration of a struct with data members for the Trd class
0006 /// @file volumes/TrdStruct.h
0007 /// @author Mihaela Gheata
0008 
0009 #ifndef VECGEOM_VOLUMES_TRDSTRUCT_H_
0010 #define VECGEOM_VOLUMES_TRDSTRUCT_H_
0011 #include "VecGeom/base/Global.h"
0012 
0013 namespace vecgeom {
0014 
0015 inline namespace VECGEOM_IMPL_NAMESPACE {
0016 
0017 /// Struct encapsulating data members of the unplaced Trd
0018 template <typename T = double>
0019 struct TrdStruct {
0020   T fDX1; ///< Half-length along x at the surface positioned at -dz
0021   T fDX2; ///< Half-length along x at the surface positioned at +dz
0022   T fDY1; ///< Half-length along y at the surface positioned at -dz
0023   T fDY2; ///< Half-length along y at the surface positioned at +dz
0024   T fDZ;  ///< Half-length along z axis
0025 
0026   // cached values
0027   T fX2minusX1;    ///< Difference between half-legths along x at +dz and -dz
0028   T fY2minusY1;    ///< Difference between half-legths along y at +dz and -dz
0029   T fHalfX1plusX2; ///< Half-length along x at z = 0
0030   T fHalfY1plusY2; ///< Half-length along y at z = 0
0031   T fCalfX;        ///< Absolute value of cosine of inclination angle along x
0032   T fCalfY;        ///< Absolute value of cosine of inclination angle along y
0033   T fSecxz;        ///< Reciprocal of fCalfX
0034   T fSecyz;        ///< Reciprocal of fCalfY
0035   T fToleranceX;   ///< Corrected tolerance for Inside checks on X
0036   T fToleranceY;   ///< Corrected tolerance for Inside checks on Y
0037 
0038   T fFx; ///< Tangent of inclination angle along x
0039   T fFy; ///< Tangent of inclination angle along y
0040 
0041   /// Default constructor, it just allocates memory
0042   VECCORE_ATT_HOST_DEVICE
0043   TrdStruct() {}
0044 
0045   /// Constructor
0046   /// @param x1 Half-length along x at the surface positioned at -dz
0047   /// @param x2 Half-length along x at the surface positioned at +dz
0048   /// @param y Half-length along y axis
0049   /// @param z Half-length along z axis
0050   VECCORE_ATT_HOST_DEVICE
0051   TrdStruct(const T x1, const T x2, const T y, const T z)
0052       : fDX1(x1), fDX2(x2), fDY1(y), fDY2(y), fDZ(z), fX2minusX1(0), fY2minusY1(0), fHalfX1plusX2(0), fHalfY1plusY2(0),
0053         fCalfX(0), fCalfY(0), fFx(0), fFy(0)
0054   {
0055     CalculateCached();
0056   }
0057 
0058   /// Constructor
0059   /// @param x1 Half-length along x at the surface positioned at -dz
0060   /// @param x2 Half-length along x at the surface positioned at +dz
0061   /// @param y1 Half-length along y at the surface positioned at -dz
0062   /// @param y2 Half-length along y at the surface positioned at +dz
0063   /// @param z Half-length along z axis
0064   VECCORE_ATT_HOST_DEVICE
0065   TrdStruct(const T x1, const T x2, const T y1, const T y2, const T z)
0066       : fDX1(x1), fDX2(x2), fDY1(y1), fDY2(y2), fDZ(z), fX2minusX1(0), fY2minusY1(0), fHalfX1plusX2(0),
0067         fHalfY1plusY2(0), fCalfX(0), fCalfY(0), fFx(0), fFy(0)
0068   {
0069     CalculateCached();
0070   }
0071 
0072   /// Constructor
0073   /// @param x Half-length along x axis
0074   /// @param y Half-length along y axis
0075   /// @param z Half-length along z axis
0076   VECCORE_ATT_HOST_DEVICE
0077   TrdStruct(const T x, const T y, const T z)
0078       : fDX1(x), fDX2(x), fDY1(y), fDY2(y), fDZ(z), fX2minusX1(0), fY2minusY1(0), fHalfX1plusX2(0), fHalfY1plusY2(0),
0079         fCalfX(0), fCalfY(0), fFx(0), fFy(0)
0080   {
0081     CalculateCached();
0082   }
0083 
0084   /// Set all data members
0085   /// @param x1 Half-length along x at the surface positioned at -dz
0086   /// @param x2 Half-length along x at the surface positioned at +dz
0087   /// @param y1 Half-length along y at the surface positioned at -dz
0088   /// @param y2 Half-length along y at the surface positioned at +dz
0089   /// @param z Half-length along z axis
0090   VECCORE_ATT_HOST_DEVICE
0091   void SetAllParameters(T x1, T x2, T y1, T y2, T z)
0092   {
0093     fDX1 = x1;
0094     fDX2 = x2;
0095     fDY1 = y1;
0096     fDY2 = y2;
0097     fDZ  = z;
0098     CalculateCached();
0099   }
0100 
0101   /// Calculate cached values
0102   VECCORE_ATT_HOST_DEVICE
0103   void CalculateCached()
0104   {
0105     fX2minusX1    = fDX2 - fDX1;
0106     fY2minusY1    = fDY2 - fDY1;
0107     fHalfX1plusX2 = 0.5 * (fDX1 + fDX2);
0108     fHalfY1plusY2 = 0.5 * (fDY1 + fDY2);
0109 
0110     fFx    = 0.5 * (fDX1 - fDX2) / fDZ;
0111     fFy    = 0.5 * (fDY1 - fDY2) / fDZ;
0112     fSecxz = sqrt(1 + fFx * fFx);
0113     fSecyz = sqrt(1 + fFy * fFy);
0114 
0115     fCalfX      = 1. / Sqrt(1.0 + fFx * fFx);
0116     fCalfY      = 1. / Sqrt(1.0 + fFy * fFy);
0117     fToleranceX = kTolerance * Sqrt(fX2minusX1 * fX2minusX1 + 4 * fDZ * fDZ);
0118     fToleranceY = kTolerance * Sqrt(fX2minusX1 * fX2minusX1 + 4 * fDZ * fDZ);
0119   }
0120 };
0121 } // namespace VECGEOM_IMPL_NAMESPACE
0122 } // namespace vecgeom
0123 
0124 #endif