Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-17 09:33:19

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 UnplacedVolumeImplHelper<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   VECCORE_ATT_HOST_DEVICE
0063   VECGEOM_FORCE_INLINE
0064   virtual ESolidType GetType() const override { return ESolidType::paraboloid; }
0065 
0066   /// Getter for the structure storing the paraboloid data
0067   VECCORE_ATT_HOST_DEVICE
0068   ParaboloidStruct<Precision> const &GetStruct() const { return fParaboloid; }
0069 
0070   /// Getter for the raduis of the circle at z = -dz
0071   VECCORE_ATT_HOST_DEVICE
0072   VECGEOM_FORCE_INLINE
0073   Precision GetRlo() const { return fParaboloid.fRlo; }
0074 
0075   /// Getter for the raduis of the circle at z = +dz
0076   VECCORE_ATT_HOST_DEVICE
0077   VECGEOM_FORCE_INLINE
0078   Precision GetRhi() const { return fParaboloid.fRhi; }
0079 
0080   /// Getter for the half size in z
0081   VECCORE_ATT_HOST_DEVICE
0082   VECGEOM_FORCE_INLINE
0083   Precision GetDz() const { return fParaboloid.fDz; }
0084 
0085   /// Returns the parameter a of the paraboloid surface
0086   VECCORE_ATT_HOST_DEVICE
0087   VECGEOM_FORCE_INLINE
0088   Precision GetA() const { return fParaboloid.fA; }
0089 
0090   /// Returns the parameter b of the paraboloid surface
0091   VECCORE_ATT_HOST_DEVICE
0092   VECGEOM_FORCE_INLINE
0093   Precision GetB() const { return fParaboloid.fB; }
0094 
0095   /// Sets the raduis of the circle at z = -dz
0096   /// @param val Value of the radius
0097   VECCORE_ATT_HOST_DEVICE
0098   // VECGEOM_FORCE_INLINE
0099   void SetRlo(Precision val)
0100   {
0101     fParaboloid.SetRlo(val);
0102     CalcCapacity();
0103     CalcSurfaceArea();
0104   }
0105 
0106   /// Sets the raduis of the circle at z = +dz
0107   /// @param val Value of the radius
0108   VECCORE_ATT_HOST_DEVICE
0109   void SetRhi(Precision val)
0110   {
0111     fParaboloid.SetRhi(val);
0112     CalcCapacity();
0113     CalcSurfaceArea();
0114   }
0115 
0116   /// Sets the half size in z
0117   /// @param val Value of the half size in z
0118   VECCORE_ATT_HOST_DEVICE
0119   void SetDz(Precision val)
0120   {
0121     fParaboloid.SetDz(val);
0122     CalcCapacity();
0123     CalcSurfaceArea();
0124   }
0125 
0126   /// Sets all parameters of the paraboloid
0127   /// @param rlo Radius of the circle at z = -dz
0128   /// @param rhi Radius of the circle at z = +dz
0129   /// @param dz Half size in z
0130   VECCORE_ATT_HOST_DEVICE
0131   void SetRloAndRhiAndDz(Precision rlo, Precision rhi, Precision dz)
0132   {
0133     fParaboloid.SetRloAndRhiAndDz(rlo, rhi, dz);
0134     CalcCapacity();
0135     CalcSurfaceArea();
0136   }
0137 
0138   VECCORE_ATT_HOST_DEVICE
0139   void Extent(Vector3D<Precision> &, Vector3D<Precision> &) const override;
0140 
0141   /// Calculate the volume
0142   VECCORE_ATT_HOST_DEVICE
0143   void CalcCapacity();
0144 
0145   /// Calculate the surface area
0146   VECCORE_ATT_HOST_DEVICE
0147   void CalcSurfaceArea();
0148 
0149   Precision Capacity() const override { return fCubicVolume; }
0150 
0151   Precision SurfaceArea() const override { return fSurfaceArea; }
0152 
0153   virtual Vector3D<Precision> SamplePointOnSurface() const override;
0154 
0155   VECCORE_ATT_HOST_DEVICE
0156   virtual bool Normal(Vector3D<Precision> const &p, Vector3D<Precision> &normal) const override
0157   {
0158     bool valid = false;
0159     normal     = ParaboloidImplementation::NormalKernel(fParaboloid, p, valid);
0160     return valid;
0161   }
0162 
0163   /// Get the solid type as string
0164   /// @return Name of the solid type
0165   std::string GetEntityType() const;
0166 
0167   /// Get list of the paraboloid parameters as an array. Not implemented !!!
0168   VECCORE_ATT_HOST_DEVICE
0169   void GetParametersList(int aNumber, Precision *aArray) const;
0170 
0171   VECCORE_ATT_HOST_DEVICE
0172   UnplacedParaboloid *Clone() const;
0173 
0174   std::ostream &StreamInfo(std::ostream &os) const;
0175 
0176 public:
0177   virtual int MemorySize() const final { return sizeof(*this); }
0178 
0179   VECCORE_ATT_HOST_DEVICE
0180   virtual void Print() const override;
0181 
0182   virtual void Print(std::ostream &os) const override;
0183 
0184 #ifndef VECCORE_CUDA
0185   virtual SolidMesh *CreateMesh3D(Transformation3D const &trans, size_t nSegments) const override;
0186 #endif
0187 
0188 #ifdef VECGEOM_CUDA_INTERFACE
0189   virtual size_t DeviceSizeOf() const override { return DevicePtr<cuda::UnplacedParaboloid>::SizeOf(); }
0190   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override;
0191   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override;
0192 #endif
0193 
0194   /// Templated factory for creating a placed volume
0195 #ifndef VECCORE_CUDA
0196   static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0197                                VPlacedVolume *const placement = NULL);
0198 
0199   VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume, Transformation3D const *const transformation,
0200                                    VPlacedVolume *const placement) const override;
0201 #else
0202   VECCORE_ATT_DEVICE
0203   static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0204                                const int id, const int copy_no, const int child_id,
0205                                VPlacedVolume *const placement = NULL);
0206   VECCORE_ATT_DEVICE VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
0207                                                       Transformation3D const *const transformation, const int id,
0208                                                       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