Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-13 08:34:52

0001 /// @file UnplacedGenericPolycone.h
0002 /// @author Raman Sehgal (raman.sehgal@cern.ch)
0003 
0004 #ifndef VECGEOM_VOLUMES_UNPLACEDGENERICPOLYCONE_H_
0005 #define VECGEOM_VOLUMES_UNPLACEDGENERICPOLYCONE_H_
0006 
0007 #include "VecGeom/base/Cuda.h"
0008 #include "VecGeom/base/Global.h"
0009 #include "VecGeom/base/AlignedBase.h"
0010 #include "VecGeom/base/Vector3D.h"
0011 #include "VecGeom/volumes/UnplacedVolume.h"
0012 #include "VecGeom/volumes/GenericPolyconeStruct.h"
0013 #include "VecGeom/volumes/kernel/GenericPolyconeImplementation.h"
0014 #include "VecGeom/volumes/UnplacedVolumeImplHelper.h"
0015 #include "VecGeom/volumes/ReducedPolycone.h"
0016 
0017 namespace vecgeom {
0018 
0019 VECGEOM_DEVICE_FORWARD_DECLARE(class UnplacedGenericPolycone;);
0020 VECGEOM_DEVICE_DECLARE_CONV(class, UnplacedGenericPolycone);
0021 
0022 inline namespace VECGEOM_IMPL_NAMESPACE {
0023 
0024 class UnplacedGenericPolycone : public UnplacedVolumeImplHelper<GenericPolyconeImplementation>, public AlignedBase {
0025 
0026 private:
0027   GenericPolyconeStruct<Precision> fGenericPolycone;
0028 
0029   // Original Polycone Parameters
0030   Precision fSPhi;
0031   Precision fDPhi;
0032   int fNumRZ;
0033   Vector<Precision> fR;
0034   Vector<Precision> fZ;
0035 
0036   // Used for Extent
0037   Vector3D<Precision> fAMin;
0038   Vector3D<Precision> fAMax;
0039 
0040 public:
0041   /*
0042    * All the required GenericPolycone Constructor
0043    *
0044    */
0045   VECCORE_ATT_HOST_DEVICE
0046   UnplacedGenericPolycone();
0047 
0048   VECCORE_ATT_HOST_DEVICE
0049   UnplacedGenericPolycone(Precision phiStart,  // initial phi starting angle
0050                           Precision phiTotal,  // total phi angle
0051                           int numRZ,           // number corners in r,z space (must be an even number)
0052                           Precision const *r,  // r coordinate of these corners
0053                           Precision const *z); // z coordinate of these corners
0054 
0055   VECCORE_ATT_HOST_DEVICE
0056   VECGEOM_FORCE_INLINE
0057   virtual ESolidType GetType() const override { return ESolidType::genericpolycone; }
0058 
0059   VECCORE_ATT_HOST_DEVICE
0060   GenericPolyconeStruct<Precision> const &GetStruct() const { return fGenericPolycone; }
0061 
0062   /*
0063    * Required Getters and Setters
0064    *
0065    */
0066 
0067   VECCORE_ATT_HOST_DEVICE
0068   VECGEOM_FORCE_INLINE
0069   Precision GetSPhi() const { return fSPhi; }
0070 
0071   VECCORE_ATT_HOST_DEVICE
0072   VECGEOM_FORCE_INLINE
0073   Precision GetDPhi() const { return fDPhi; }
0074 
0075   VECCORE_ATT_HOST_DEVICE
0076   VECGEOM_FORCE_INLINE
0077   int GetNumRz() const { return fNumRZ; }
0078 
0079   VECCORE_ATT_HOST_DEVICE
0080   VECGEOM_FORCE_INLINE
0081   Vector<Precision> GetR() const { return fR; }
0082 
0083   VECCORE_ATT_HOST_DEVICE
0084   VECGEOM_FORCE_INLINE
0085   Vector<Precision> GetZ() const { return fZ; }
0086 
0087   VECCORE_ATT_HOST_DEVICE
0088   void Extent(Vector3D<Precision> &, Vector3D<Precision> &) const override;
0089 
0090   VECCORE_ATT_HOST_DEVICE
0091   bool Normal(Vector3D<Precision> const &point, Vector3D<Precision> &norm) const override;
0092 
0093   Precision Capacity() const override { return fGenericPolycone.fCubicVolume; }
0094 
0095   // Using the Generic implementation from UnplacedVolume
0096   Precision SurfaceArea() const override { return EstimateSurfaceArea(); }
0097 
0098   Vector3D<Precision> SamplePointOnSurface() const override;
0099 
0100   std::string GetEntityType() const { return "GenericPolycone"; }
0101 
0102 public:
0103   virtual int MemorySize() const final { return sizeof(*this); }
0104 
0105   VECCORE_ATT_HOST_DEVICE
0106   virtual void Print() const override;
0107 
0108   virtual void Print(std::ostream &os) const override;
0109 
0110 #ifdef VECGEOM_CUDA_INTERFACE
0111   virtual size_t DeviceSizeOf() const override { return DevicePtr<cuda::UnplacedGenericPolycone>::SizeOf(); }
0112   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override;
0113   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override;
0114 #endif
0115 
0116 #ifndef VECCORE_CUDA
0117   // this is the function called from the VolumeFactory
0118   // this may be specific to the shape
0119   static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0120                                VPlacedVolume *const placement = NULL);
0121 
0122   VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume, Transformation3D const *const transformation,
0123                                    VPlacedVolume *const placement) const override;
0124 #else
0125   VECCORE_ATT_DEVICE
0126   static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0127                                const int id, const int copy_no, const int child_id,
0128                                VPlacedVolume *const placement = NULL);
0129   VECCORE_ATT_DEVICE VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
0130                                                       Transformation3D const *const transformation, const int id,
0131                                                       const int copy_no, const int child_id,
0132                                                       VPlacedVolume *const placement) const override;
0133 
0134 #endif
0135 };
0136 
0137 using GenericUnplacedGenericPolycone = UnplacedGenericPolycone;
0138 } // namespace VECGEOM_IMPL_NAMESPACE
0139 } // namespace vecgeom
0140 
0141 #endif