Back to home page

EIC code displayed by LXR

 
 

    


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

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 SIMDUnplacedVolumeImplHelper<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   /// Getter for the structure storing elliptical cone data
0054   VECCORE_ATT_HOST_DEVICE
0055   EllipticalTubeStruct<Precision> const &GetStruct() const { return fEllipticalTube; }
0056 
0057   /// Getter for x semi-axis
0058   VECCORE_ATT_HOST_DEVICE
0059   VECGEOM_FORCE_INLINE
0060   Precision GetDx() const { return fEllipticalTube.fDx; }
0061 
0062   /// Getter for y semi-axis
0063   VECCORE_ATT_HOST_DEVICE
0064   VECGEOM_FORCE_INLINE
0065   Precision GetDy() const { return fEllipticalTube.fDy; }
0066 
0067   /// Getter for the half length in z
0068   VECCORE_ATT_HOST_DEVICE
0069   VECGEOM_FORCE_INLINE
0070   Precision GetDz() const { return fEllipticalTube.fDz; }
0071 
0072   /// Setter for the elliptical tube parameters
0073   /// @param dx Length of x semi-axis
0074   /// @param dy Length of y semi-axis
0075   /// @param dz Half length in z
0076   VECCORE_ATT_HOST_DEVICE
0077   VECGEOM_FORCE_INLINE
0078   void SetParameters(Precision dx, Precision dy, Precision dz)
0079   {
0080     fEllipticalTube.fDx = dx;
0081     fEllipticalTube.fDy = dy;
0082     fEllipticalTube.fDz = dz;
0083     CheckParameters();
0084   };
0085 
0086   /// Set x semi-axis
0087   VECCORE_ATT_HOST_DEVICE
0088   VECGEOM_FORCE_INLINE
0089   void SetDx(Precision dx)
0090   {
0091     fEllipticalTube.fDx = dx;
0092     CheckParameters();
0093   };
0094 
0095   /// Set y semi-axis
0096   VECCORE_ATT_HOST_DEVICE
0097   VECGEOM_FORCE_INLINE
0098   void SetDy(Precision dy)
0099   {
0100     fEllipticalTube.fDy = dy;
0101     CheckParameters();
0102   };
0103 
0104   /// Set half length in z
0105   VECCORE_ATT_HOST_DEVICE
0106   VECGEOM_FORCE_INLINE
0107   void SetDz(Precision dz)
0108   {
0109     fEllipticalTube.fDz = dz;
0110     CheckParameters();
0111   };
0112 
0113   VECCORE_ATT_HOST_DEVICE
0114   void Extent(Vector3D<Precision> &, Vector3D<Precision> &) const override;
0115 
0116   Precision Capacity() const override { return fEllipticalTube.fCubicVolume; }
0117 
0118   Precision SurfaceArea() const override { return fEllipticalTube.fSurfaceArea; }
0119 
0120   Vector3D<Precision> SamplePointOnSurface() const override;
0121 
0122   VECCORE_ATT_HOST_DEVICE
0123   virtual bool Normal(Vector3D<Precision> const &p, Vector3D<Precision> &normal) const override
0124   {
0125     bool valid;
0126     normal = EllipticalTubeImplementation::NormalKernel(fEllipticalTube, p, valid);
0127     return valid;
0128   }
0129 
0130   /// Get the solid type as string
0131   /// @return Name of the solid type
0132   std::string GetEntityType() const { return "EllipticalTube"; }
0133 
0134   std::ostream &StreamInfo(std::ostream &os) const;
0135 
0136 public:
0137   virtual int MemorySize() const final { return sizeof(*this); }
0138 
0139   VECCORE_ATT_HOST_DEVICE
0140   virtual void Print() const override;
0141 
0142   virtual void Print(std::ostream &os) const override;
0143 
0144 #ifndef VECCORE_CUDA
0145   virtual SolidMesh *CreateMesh3D(Transformation3D const &trans, size_t nSegments) const override;
0146 #endif
0147 
0148 #ifdef VECGEOM_CUDA_INTERFACE
0149   virtual size_t DeviceSizeOf() const override { return DevicePtr<cuda::UnplacedEllipticalTube>::SizeOf(); }
0150   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override;
0151   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override;
0152 #endif
0153 
0154   /// Templated factory for creating a placed volume
0155 #ifndef VECCORE_CUDA
0156   template <TranslationCode trans_code, RotationCode rot_code>
0157   static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0158                                VPlacedVolume *const placement = NULL);
0159 
0160   VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume, Transformation3D const *const transformation,
0161                                    const TranslationCode trans_code, const RotationCode rot_code,
0162                                    VPlacedVolume *const placement) const override;
0163 #else
0164   template <TranslationCode trans_code, RotationCode rot_code>
0165   VECCORE_ATT_DEVICE
0166   static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0167                                const int id, const int copy_no, const int child_id,
0168                                VPlacedVolume *const placement = NULL);
0169   VECCORE_ATT_DEVICE VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
0170                                                       Transformation3D const *const transformation,
0171                                                       const TranslationCode trans_code, const RotationCode rot_code,
0172                                                       const int id, 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