Back to home page

EIC code displayed by LXR

 
 

    


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

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 UnplacedParaboloid class
0006 /// @file volumes/ParaboloidStruct.h
0007 /// @author Raman Sehgal
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 /// Struct encapsulating data members of the unplaced paraboloid
0018 template <typename T = double>
0019 struct ParaboloidStruct {
0020   T fRlo; ///< Radius of the circle at z = -dz
0021   T fRhi; ///< Radius of the circle at z = +dz
0022   T fDz;  ///< Half size in z
0023 
0024   // Values computed from parameters, to be cached
0025   T fDx;   ///< Half size of the bounding box in x
0026   T fDy;   ///< Half size of the bounding box in y
0027   T fA;    ///< Parameter a in the equation of paraboloid: z = a * (x^2 + y^2) + b
0028   T fInvA; ///< Inverted value of a
0029   T fA2;   ///< Parameter a squared
0030   T fB;    ///< Parameter b in the equation of paraboloid: z = a * (x^2 + y^2) + b
0031   T fB2;   ///< Parameter b squared
0032   T fInvB; ///< Inverted value of b
0033   T fK1;   ///< Cached value: 0.5 * (Rhi^2 - Rlo^2) / Dz
0034   T fK2;   ///< Cached value: 0.5 * (Rhi^2 + Rlo^2)
0035   T fRlo2; ///< Radius of the circle at z = -dz squared
0036   T fRhi2; ///< Radius of the circle at z = +dz squared
0037 
0038   /// Default constructor
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   /// Constructor
0047   /// @param rlo Radius of the circle at z = -dz
0048   /// @param rhi Radius of the circle at z = +dz
0049   /// @param dz Half size in z
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   /// Sets data members
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   /// Sets fDx and fDy
0076   VECCORE_ATT_HOST_DEVICE
0077   void ComputeBoundingBox()
0078   {
0079     fDx = Max(fRhi, fRlo);
0080     fDy = fDx;
0081   }
0082 
0083   /// Sets parameters of the paraboloid
0084   /// @param rlo Radius of the circle at z = -dz
0085   /// @param rhi Radius of the circle at z = +dz
0086   /// @param dz Half size in z
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   /// Sets the raduis of the circle at z = -dz
0103   /// @param val Value of the radius
0104   VECCORE_ATT_HOST_DEVICE
0105   void SetRlo(const T rlo) { SetRloAndRhiAndDz(rlo, fRhi, fDz); }
0106 
0107   /// Sets the raduis of the circle at z = +dz
0108   /// @param val Value of the radius
0109   VECCORE_ATT_HOST_DEVICE
0110   void SetRhi(const T rhi) { SetRloAndRhiAndDz(fRlo, rhi, fDz); }
0111 
0112   /// Sets the half size in z
0113   /// @param val Value of the half size in z
0114   VECCORE_ATT_HOST_DEVICE
0115   void SetDz(const T dz) { SetRloAndRhiAndDz(fRlo, fRhi, dz); }
0116 };
0117 } // namespace VECGEOM_IMPL_NAMESPACE
0118 } // namespace vecgeom
0119 
0120 #endif