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 cone shape
0006 /// @file volumes/UnplacedEllipticalCone.h
0007 /// @author Raman Sehgal, Evgueni Tcherniaev
0008 
0009 #ifndef VECGEOM_VOLUMES_UNPLACEDELLIPTICALCONE_H_
0010 #define VECGEOM_VOLUMES_UNPLACEDELLIPTICALCONE_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/EllipticalConeStruct.h" // the pure EllipticalCone struct
0018 #include "VecGeom/volumes/kernel/EllipticalConeImplementation.h"
0019 #include "VecGeom/volumes/UnplacedVolumeImplHelper.h"
0020 
0021 namespace vecgeom {
0022 
0023 VECGEOM_DEVICE_FORWARD_DECLARE(class UnplacedEllipticalCone;);
0024 VECGEOM_DEVICE_DECLARE_CONV(class, UnplacedEllipticalCone);
0025 
0026 inline namespace VECGEOM_IMPL_NAMESPACE {
0027 
0028 /// Class for elliptical cone shape primitive.
0029 ///
0030 /// Elliptical cone is a full cone with elliptical base which can be cut in z.
0031 /// The shape is centered at the origin: one base is at z=-zcut, another at z=zcut.
0032 /// If there is no cut then the base is at z=-h the apex is at z=h.
0033 /// Lateral surface of an elliptical cone is defined by the equation:
0034 ///
0035 /// (x / a)^2 + (y / b)^2 = (h - z)^2
0036 ///
0037 /// - a - undimensioned value, it specifies the inclination of the surface in x
0038 /// - b - undimensioned value, it specifies the inclination of the surface in y
0039 /// - h - height, z-coordinate where the uncut surface hits z axis
0040 ///
0041 /// The semi-major axes at the z=0 plane are equal to a*h and b*h
0042 ///
0043 class UnplacedEllipticalCone : public SIMDUnplacedVolumeImplHelper<EllipticalConeImplementation>, public AlignedBase {
0044 
0045 private:
0046   EllipticalConeStruct<Precision> fEllipticalCone; ///< Structure holding the data for Elliptical Cone
0047 
0048 private:
0049   /// Check correctness of the parameters and set the data members
0050   VECCORE_ATT_HOST_DEVICE
0051   void CheckParameters();
0052 
0053   /// Generates random point on the lateral surface of the elliptical cone
0054   Vector3D<Precision> SamplePointOnLateralSurface() const;
0055 
0056 public:
0057   /// Constructor
0058   /// @param a Inclination of the conical surface in x
0059   /// @param b Inclination of the conical surface in y
0060   /// @param h Height
0061   /// @param zcut cut in z
0062   VECCORE_ATT_HOST_DEVICE
0063   UnplacedEllipticalCone(Precision a, Precision b, Precision h, Precision zcut);
0064 
0065   /// Getter for the structure storing elliptical cone data.
0066   VECCORE_ATT_HOST_DEVICE
0067   EllipticalConeStruct<Precision> const &GetStruct() const { return fEllipticalCone; }
0068 
0069   /// Getter for the parameter that specifies inclination of the conical surface in x
0070   VECCORE_ATT_HOST_DEVICE
0071   VECGEOM_FORCE_INLINE
0072   Precision GetSemiAxisX() const { return fEllipticalCone.fDx; }
0073 
0074   /// Getter for that parameter that specifies inclination of the conical surface in y
0075   VECCORE_ATT_HOST_DEVICE
0076   VECGEOM_FORCE_INLINE
0077   Precision GetSemiAxisY() const { return fEllipticalCone.fDy; }
0078 
0079   /// Getter for the height
0080   VECCORE_ATT_HOST_DEVICE
0081   VECGEOM_FORCE_INLINE
0082   Precision GetZMax() const { return fEllipticalCone.fDz; }
0083 
0084   /// Getter for the cut in z
0085   VECCORE_ATT_HOST_DEVICE
0086   VECGEOM_FORCE_INLINE
0087   Precision GetZTopCut() const { return fEllipticalCone.fZCut; }
0088 
0089   /// Setter for the elliptical cone parameters
0090   /// @param a Inclination of the conical surface in x
0091   /// @param b Inclination of the conical surface in y
0092   /// @param h Height
0093   /// @param zcut cut in z
0094   VECCORE_ATT_HOST_DEVICE
0095   VECGEOM_FORCE_INLINE
0096   void SetParameters(Precision a, Precision b, Precision h, Precision zcut)
0097   {
0098     fEllipticalCone.fDx   = a;
0099     fEllipticalCone.fDy   = b;
0100     fEllipticalCone.fDz   = h;
0101     fEllipticalCone.fZCut = zcut;
0102     CheckParameters();
0103   };
0104 
0105   VECCORE_ATT_HOST_DEVICE
0106   void Extent(Vector3D<Precision> &, Vector3D<Precision> &) const override;
0107 
0108   Precision Capacity() const override { return fEllipticalCone.fCubicVolume; }
0109 
0110   Precision SurfaceArea() const override { return fEllipticalCone.fSurfaceArea; }
0111 
0112   Vector3D<Precision> SamplePointOnSurface() const override;
0113 
0114   VECCORE_ATT_HOST_DEVICE
0115   virtual bool Normal(Vector3D<Precision> const &p, Vector3D<Precision> &normal) const override
0116   {
0117     bool valid;
0118     normal = EllipticalConeImplementation::NormalKernel(fEllipticalCone, p, valid);
0119     return valid;
0120   }
0121 
0122   /// Get the solid type as string.
0123   /// @return Name of the solid type
0124   std::string GetEntityType() const { return "EllipticalCone"; }
0125 
0126   std::ostream &StreamInfo(std::ostream &os) const;
0127 
0128 public:
0129   virtual int MemorySize() const final { return sizeof(*this); }
0130 
0131   VECCORE_ATT_HOST_DEVICE
0132   virtual void Print() const override;
0133 
0134   virtual void Print(std::ostream &os) const override;
0135 
0136 #ifndef VECCORE_CUDA
0137   virtual SolidMesh *CreateMesh3D(Transformation3D const &trans, size_t nSegments) const override;
0138 #endif
0139 
0140 #ifdef VECGEOM_CUDA_INTERFACE
0141   virtual size_t DeviceSizeOf() const override { return DevicePtr<cuda::UnplacedEllipticalCone>::SizeOf(); }
0142   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override;
0143   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override;
0144 #endif
0145 
0146 #ifndef VECCORE_CUDA
0147   /// Templated factory for creating a placed volume
0148   template <TranslationCode trans_code, RotationCode rot_code>
0149   static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0150                                VPlacedVolume *const placement = NULL);
0151 
0152   VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume, Transformation3D const *const transformation,
0153                                    const TranslationCode trans_code, const RotationCode rot_code,
0154                                    VPlacedVolume *const placement) const override;
0155 #else
0156   template <TranslationCode trans_code, RotationCode rot_code>
0157   VECCORE_ATT_DEVICE
0158   static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0159                                const int id, const int copy_no, const int child_id,
0160                                VPlacedVolume *const placement = NULL);
0161   VECCORE_ATT_DEVICE VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
0162                                                       Transformation3D const *const transformation,
0163                                                       const TranslationCode trans_code, const RotationCode rot_code,
0164                                                       const int id, const int copy_no, const int child_id,
0165                                                       VPlacedVolume *const placement) const override;
0166 
0167 #endif
0168 };
0169 } // namespace VECGEOM_IMPL_NAMESPACE
0170 } // namespace vecgeom
0171 
0172 #endif