Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-05 09:37:07

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 the unplaced elliptical tube shape
0006 /// @file volumes/UnplacedEllipticalTube.h
0007 /// @author Raman Sehgal, Evgueni Tcherniaev
0008 
0009 #ifndef VECGEOM_VOLUMES_UNPLACEDELLIPTICALTUBE_H_
0010 #define VECGEOM_VOLUMES_UNPLACEDELLIPTICALTUBE_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/EllipticalTubeStruct.h" // the pure EllipticalTube struct
0018 #include "VecGeom/volumes/kernel/EllipticalTubeImplementation.h"
0019 #include "VecGeom/volumes/UnplacedVolumeImplHelper.h"
0020 
0021 namespace vecgeom {
0022 
0023 VECGEOM_DEVICE_FORWARD_DECLARE(class UnplacedEllipticalTube;);
0024 VECGEOM_DEVICE_DECLARE_CONV(class, UnplacedEllipticalTube);
0025 
0026 inline namespace VECGEOM_IMPL_NAMESPACE {
0027 
0028 /// Class for elliptical tube shape primitive
0029 ///
0030 /// Elliptical tube is a whole cylinder with elliptic cross section.
0031 /// The shape is centered at the origin, its half length is equal to dz.
0032 /// The equation of the ellipse in cross section is:
0033 ///
0034 /// (x/dx)^2 + (y/dy)^2 = 1
0035 ///
0036 class UnplacedEllipticalTube : public UnplacedVolumeImplHelper<EllipticalTubeImplementation>, public AlignedBase {
0037 
0038 private:
0039   EllipticalTubeStruct<Precision> fEllipticalTube;
0040 
0041   /// Check correctness of the parameters and set the data members
0042   VECCORE_ATT_HOST_DEVICE
0043   void CheckParameters();
0044 
0045 public:
0046   /// Constructor
0047   /// @param dx Length of x semi-axis
0048   /// @param dy Length of y semi-axis
0049   /// @param dz Half length in z
0050   VECCORE_ATT_HOST_DEVICE
0051   UnplacedEllipticalTube(Precision dx, Precision dy, Precision dz);
0052 
0053   VECCORE_ATT_HOST_DEVICE
0054   VECGEOM_FORCE_INLINE
0055   virtual ESolidType GetType() const override { return ESolidType::ellipticaltube; }
0056 
0057   /// Getter for the structure storing elliptical cone data
0058   VECCORE_ATT_HOST_DEVICE
0059   EllipticalTubeStruct<Precision> const &GetStruct() const { return fEllipticalTube; }
0060 
0061   /// Getter for x semi-axis
0062   VECCORE_ATT_HOST_DEVICE
0063   VECGEOM_FORCE_INLINE
0064   Precision GetDx() const { return fEllipticalTube.fDx; }
0065 
0066   /// Getter for y semi-axis
0067   VECCORE_ATT_HOST_DEVICE
0068   VECGEOM_FORCE_INLINE
0069   Precision GetDy() const { return fEllipticalTube.fDy; }
0070 
0071   /// Getter for the half length in z
0072   VECCORE_ATT_HOST_DEVICE
0073   VECGEOM_FORCE_INLINE
0074   Precision GetDz() const { return fEllipticalTube.fDz; }
0075 
0076   /// Setter for the elliptical tube parameters
0077   /// @param dx Length of x semi-axis
0078   /// @param dy Length of y semi-axis
0079   /// @param dz Half length in z
0080   VECCORE_ATT_HOST_DEVICE
0081   VECGEOM_FORCE_INLINE
0082   void SetParameters(Precision dx, Precision dy, Precision dz)
0083   {
0084     fEllipticalTube.fDx = dx;
0085     fEllipticalTube.fDy = dy;
0086     fEllipticalTube.fDz = dz;
0087     CheckParameters();
0088   };
0089 
0090   /// Set x semi-axis
0091   VECCORE_ATT_HOST_DEVICE
0092   VECGEOM_FORCE_INLINE
0093   void SetDx(Precision dx)
0094   {
0095     fEllipticalTube.fDx = dx;
0096     CheckParameters();
0097   };
0098 
0099   /// Set y semi-axis
0100   VECCORE_ATT_HOST_DEVICE
0101   VECGEOM_FORCE_INLINE
0102   void SetDy(Precision dy)
0103   {
0104     fEllipticalTube.fDy = dy;
0105     CheckParameters();
0106   };
0107 
0108   /// Set half length in z
0109   VECCORE_ATT_HOST_DEVICE
0110   VECGEOM_FORCE_INLINE
0111   void SetDz(Precision dz)
0112   {
0113     fEllipticalTube.fDz = dz;
0114     CheckParameters();
0115   };
0116 
0117   VECCORE_ATT_HOST_DEVICE
0118   void Extent(Vector3D<Precision> &, Vector3D<Precision> &) const override;
0119 
0120   Precision Capacity() const override { return fEllipticalTube.fCubicVolume; }
0121 
0122   Precision SurfaceArea() const override { return fEllipticalTube.fSurfaceArea; }
0123 
0124   Vector3D<Precision> SamplePointOnSurface() const override;
0125 
0126   VECCORE_ATT_HOST_DEVICE
0127   virtual bool Normal(Vector3D<Precision> const &p, Vector3D<Precision> &normal) const override
0128   {
0129     bool valid;
0130     normal = EllipticalTubeImplementation::NormalKernel(fEllipticalTube, p, valid);
0131     return valid;
0132   }
0133 
0134   /// Get the solid type as string
0135   /// @return Name of the solid type
0136   std::string GetEntityType() const { return "EllipticalTube"; }
0137 
0138   std::ostream &StreamInfo(std::ostream &os) const;
0139 
0140 public:
0141   virtual int MemorySize() const final { return sizeof(*this); }
0142 
0143   VECCORE_ATT_HOST_DEVICE
0144   virtual void Print() const override;
0145 
0146   virtual void Print(std::ostream &os) const override;
0147 
0148 #ifndef VECCORE_CUDA
0149   virtual SolidMesh *CreateMesh3D(Transformation3D const &trans, size_t nSegments) const override;
0150 #endif
0151 
0152 #ifdef VECGEOM_CUDA_INTERFACE
0153   virtual size_t DeviceSizeOf() const override { return DevicePtr<cuda::UnplacedEllipticalTube>::SizeOf(); }
0154   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override;
0155   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override;
0156 #endif
0157 
0158   /// Templated factory for creating a placed volume
0159 #ifndef VECCORE_CUDA
0160   static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0161                                VPlacedVolume *const placement = NULL);
0162 
0163   VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume, Transformation3D const *const transformation,
0164                                    VPlacedVolume *const placement) const override;
0165 #else
0166   VECCORE_ATT_DEVICE
0167   static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0168                                const int id, const int copy_no, const int child_id,
0169                                VPlacedVolume *const placement = NULL);
0170   VECCORE_ATT_DEVICE VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
0171                                                       Transformation3D const *const transformation, const int id,
0172                                                       const int copy_no, const int child_id,
0173                                                       VPlacedVolume *const placement) const override;
0174 
0175 #endif
0176 };
0177 } // namespace VECGEOM_IMPL_NAMESPACE
0178 } // namespace vecgeom
0179 
0180 #endif