Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:15

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 /// @brief This file contains the declaration of the UnplacedParaboloid class
0006 /// @file volumes/UnplacedParaboloid.h
0007 /// @author Marilena Bandieramonte
0008 
0009 #ifndef VECGEOM_VOLUMES_UNPLACEDPARABOLOID_H_
0010 #define VECGEOM_VOLUMES_UNPLACEDPARABOLOID_H_
0011 
0012 #include "VecGeom/base/Cuda.h"
0013 #include "VecGeom/base/Global.h"
0014 #include "VecGeom/base/AlignedBase.h"
0015 #include "VecGeom/base/Vector3D.h"
0016 #include "VecGeom/volumes/UnplacedVolume.h"
0017 #include "VecGeom/volumes/ParaboloidStruct.h" // the pure Paraboloid struct
0018 #include "VecGeom/volumes/kernel/ParaboloidImplementation.h"
0019 #include "VecGeom/volumes/UnplacedVolumeImplHelper.h"
0020 
0021 namespace vecgeom {
0022 
0023 VECGEOM_DEVICE_FORWARD_DECLARE(class UnplacedParaboloid;);
0024 VECGEOM_DEVICE_DECLARE_CONV(class, UnplacedParaboloid);
0025 
0026 inline namespace VECGEOM_IMPL_NAMESPACE {
0027 
0028 /// Class for paraboloid shape primitive
0029 ///
0030 /// A paraboloid is the solid bounded by the following surfaces:
0031 /// - 2 planes parallel with XY cutting the Z axis at z = -dz and z = +dz
0032 /// - the surface of revolution of a parabola described by: z = a * (x^2 + y^2) + b
0033 ///
0034 /// The parameters a and b are automatically computed from:
0035 /// - rlo - radius of the circle of intersection between the
0036 /// parabolic surface and the plane z = -dz
0037 /// - rhi - the radius of the circle of intersection between the
0038 /// parabolic surface and the plane z = +dz
0039 /// - dz = a * rhi^2 + b and  -dz = a * rlo^2 + b, where rhi > rlo, both >= 0
0040 /// - a = 2 * dz * dd and b = -dz * (rlo^2 + rhi^2) * dd, where dd = 1 / (rhi^2 - rlo^2)
0041 ///
0042 class UnplacedParaboloid : public SIMDUnplacedVolumeImplHelper<ParaboloidImplementation>, public AlignedBase {
0043 
0044 private:
0045   ParaboloidStruct<Precision> fParaboloid; ///< The paraboloid structure
0046 
0047   Precision fCubicVolume; ///< Cached value of the volume
0048   Precision fSurfaceArea; ///< Cached value of the surface area
0049 
0050 public:
0051   /// Default constructor
0052   VECCORE_ATT_HOST_DEVICE
0053   UnplacedParaboloid();
0054 
0055   /// Constructor
0056   /// @param rlo Radius of the circle at z = -dz
0057   /// @param rhi Radius of the circle at z = +dz
0058   /// @param dz Half size in z
0059   VECCORE_ATT_HOST_DEVICE
0060   UnplacedParaboloid(const Precision rlo, const Precision rhi, const Precision dz);
0061 
0062   /// Getter for the structure storing the paraboloid data
0063   VECCORE_ATT_HOST_DEVICE
0064   ParaboloidStruct<Precision> const &GetStruct() const { return fParaboloid; }
0065 
0066   /// Getter for the raduis of the circle at z = -dz
0067   VECCORE_ATT_HOST_DEVICE
0068   VECGEOM_FORCE_INLINE
0069   Precision GetRlo() const { return fParaboloid.fRlo; }
0070 
0071   /// Getter for the raduis of the circle at z = +dz
0072   VECCORE_ATT_HOST_DEVICE
0073   VECGEOM_FORCE_INLINE
0074   Precision GetRhi() const { return fParaboloid.fRhi; }
0075 
0076   /// Getter for the half size in z
0077   VECCORE_ATT_HOST_DEVICE
0078   VECGEOM_FORCE_INLINE
0079   Precision GetDz() const { return fParaboloid.fDz; }
0080 
0081   /// Returns the parameter a of the paraboloid surface
0082   VECCORE_ATT_HOST_DEVICE
0083   VECGEOM_FORCE_INLINE
0084   Precision GetA() const { return fParaboloid.fA; }
0085 
0086   /// Returns the parameter b of the paraboloid surface
0087   VECCORE_ATT_HOST_DEVICE
0088   VECGEOM_FORCE_INLINE
0089   Precision GetB() const { return fParaboloid.fB; }
0090 
0091   /// Sets the raduis of the circle at z = -dz
0092   /// @param val Value of the radius
0093   VECCORE_ATT_HOST_DEVICE
0094   // VECGEOM_FORCE_INLINE
0095   void SetRlo(Precision val)
0096   {
0097     fParaboloid.SetRlo(val);
0098     CalcCapacity();
0099     CalcSurfaceArea();
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 SetRhi(Precision val)
0106   {
0107     fParaboloid.SetRhi(val);
0108     CalcCapacity();
0109     CalcSurfaceArea();
0110   }
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(Precision val)
0116   {
0117     fParaboloid.SetDz(val);
0118     CalcCapacity();
0119     CalcSurfaceArea();
0120   }
0121 
0122   /// Sets all parameters of the paraboloid
0123   /// @param rlo Radius of the circle at z = -dz
0124   /// @param rhi Radius of the circle at z = +dz
0125   /// @param dz Half size in z
0126   VECCORE_ATT_HOST_DEVICE
0127   void SetRloAndRhiAndDz(Precision rlo, Precision rhi, Precision dz)
0128   {
0129     fParaboloid.SetRloAndRhiAndDz(rlo, rhi, dz);
0130     CalcCapacity();
0131     CalcSurfaceArea();
0132   }
0133 
0134   VECCORE_ATT_HOST_DEVICE
0135   void Extent(Vector3D<Precision> &, Vector3D<Precision> &) const override;
0136 
0137   /// Calculate the volume
0138   VECCORE_ATT_HOST_DEVICE
0139   void CalcCapacity();
0140 
0141   /// Calculate the surface area
0142   VECCORE_ATT_HOST_DEVICE
0143   void CalcSurfaceArea();
0144 
0145   Precision Capacity() const override { return fCubicVolume; }
0146 
0147   Precision SurfaceArea() const override { return fSurfaceArea; }
0148 
0149   virtual Vector3D<Precision> SamplePointOnSurface() const override;
0150 
0151   VECCORE_ATT_HOST_DEVICE
0152   virtual bool Normal(Vector3D<Precision> const &p, Vector3D<Precision> &normal) const override
0153   {
0154     bool valid = false;
0155     normal     = ParaboloidImplementation::NormalKernel(fParaboloid, p, valid);
0156     return valid;
0157   }
0158 
0159   /// Get the solid type as string
0160   /// @return Name of the solid type
0161   std::string GetEntityType() const;
0162 
0163   /// Get list of the paraboloid parameters as an array. Not implemented !!!
0164   VECCORE_ATT_HOST_DEVICE
0165   void GetParametersList(int aNumber, Precision *aArray) const;
0166 
0167   VECCORE_ATT_HOST_DEVICE
0168   UnplacedParaboloid *Clone() const;
0169 
0170   std::ostream &StreamInfo(std::ostream &os) const;
0171 
0172 public:
0173   virtual int MemorySize() const final { return sizeof(*this); }
0174 
0175   VECCORE_ATT_HOST_DEVICE
0176   virtual void Print() const override;
0177 
0178   virtual void Print(std::ostream &os) const override;
0179 
0180 #ifndef VECCORE_CUDA
0181   virtual SolidMesh *CreateMesh3D(Transformation3D const &trans, size_t nSegments) const override;
0182 #endif
0183 
0184 #ifdef VECGEOM_CUDA_INTERFACE
0185   virtual size_t DeviceSizeOf() const override { return DevicePtr<cuda::UnplacedParaboloid>::SizeOf(); }
0186   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override;
0187   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override;
0188 #endif
0189 
0190   /// Templated factory for creating a placed volume
0191 #ifndef VECCORE_CUDA
0192   template <TranslationCode trans_code, RotationCode rot_code>
0193   static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0194                                VPlacedVolume *const placement = NULL);
0195 
0196   VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume, Transformation3D const *const transformation,
0197                                    const TranslationCode trans_code, const RotationCode rot_code,
0198                                    VPlacedVolume *const placement) const override;
0199 #else
0200   template <TranslationCode trans_code, RotationCode rot_code>
0201   VECCORE_ATT_DEVICE
0202   static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0203                                const int id, const int copy_no, const int child_id,
0204                                VPlacedVolume *const placement = NULL);
0205   VECCORE_ATT_DEVICE VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
0206                                                       Transformation3D const *const transformation,
0207                                                       const TranslationCode trans_code, const RotationCode rot_code,
0208                                                       const int id, const int copy_no, const int child_id,
0209                                                       VPlacedVolume *const placement) const override;
0210 
0211 #endif
0212 };
0213 } // namespace VECGEOM_IMPL_NAMESPACE
0214 } // namespace vecgeom
0215 
0216 #endif