Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/VecGeom/volumes/UnplacedEllipticalCone.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 UnplacedVolumeImplHelper<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   VECCORE_ATT_HOST_DEVICE
0066   VECGEOM_FORCE_INLINE
0067   virtual ESolidType GetType() const override { return ESolidType::ellipticalcone; }
0068 
0069   /// Getter for the structure storing elliptical cone data.
0070   VECCORE_ATT_HOST_DEVICE
0071   EllipticalConeStruct<Precision> const &GetStruct() const { return fEllipticalCone; }
0072 
0073   /// Getter for the parameter that specifies inclination of the conical surface in x
0074   VECCORE_ATT_HOST_DEVICE
0075   VECGEOM_FORCE_INLINE
0076   Precision GetSemiAxisX() const { return fEllipticalCone.fDx; }
0077 
0078   /// Getter for that parameter that specifies inclination of the conical surface in y
0079   VECCORE_ATT_HOST_DEVICE
0080   VECGEOM_FORCE_INLINE
0081   Precision GetSemiAxisY() const { return fEllipticalCone.fDy; }
0082 
0083   /// Getter for the height
0084   VECCORE_ATT_HOST_DEVICE
0085   VECGEOM_FORCE_INLINE
0086   Precision GetZMax() const { return fEllipticalCone.fDz; }
0087 
0088   /// Getter for the cut in z
0089   VECCORE_ATT_HOST_DEVICE
0090   VECGEOM_FORCE_INLINE
0091   Precision GetZTopCut() const { return fEllipticalCone.fZCut; }
0092 
0093   /// Setter for the elliptical cone parameters
0094   /// @param a Inclination of the conical surface in x
0095   /// @param b Inclination of the conical surface in y
0096   /// @param h Height
0097   /// @param zcut cut in z
0098   VECCORE_ATT_HOST_DEVICE
0099   VECGEOM_FORCE_INLINE
0100   void SetParameters(Precision a, Precision b, Precision h, Precision zcut)
0101   {
0102     fEllipticalCone.fDx   = a;
0103     fEllipticalCone.fDy   = b;
0104     fEllipticalCone.fDz   = h;
0105     fEllipticalCone.fZCut = zcut;
0106     CheckParameters();
0107   };
0108 
0109   VECCORE_ATT_HOST_DEVICE
0110   void Extent(Vector3D<Precision> &, Vector3D<Precision> &) const override;
0111 
0112   Precision Capacity() const override { return fEllipticalCone.fCubicVolume; }
0113 
0114   Precision SurfaceArea() const override { return fEllipticalCone.fSurfaceArea; }
0115 
0116   Vector3D<Precision> SamplePointOnSurface() const override;
0117 
0118   VECCORE_ATT_HOST_DEVICE
0119   virtual bool Normal(Vector3D<Precision> const &p, Vector3D<Precision> &normal) const override
0120   {
0121     bool valid;
0122     normal = EllipticalConeImplementation::NormalKernel(fEllipticalCone, p, valid);
0123     return valid;
0124   }
0125 
0126   /// Get the solid type as string.
0127   /// @return Name of the solid type
0128   std::string GetEntityType() const { return "EllipticalCone"; }
0129 
0130   std::ostream &StreamInfo(std::ostream &os) const;
0131 
0132 public:
0133   virtual int MemorySize() const final { return sizeof(*this); }
0134 
0135   VECCORE_ATT_HOST_DEVICE
0136   virtual void Print() const override;
0137 
0138   virtual void Print(std::ostream &os) const override;
0139 
0140 #ifndef VECCORE_CUDA
0141   virtual SolidMesh *CreateMesh3D(Transformation3D const &trans, size_t nSegments) const override;
0142 #endif
0143 
0144 #ifdef VECGEOM_CUDA_INTERFACE
0145   virtual size_t DeviceSizeOf() const override { return DevicePtr<cuda::UnplacedEllipticalCone>::SizeOf(); }
0146   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override;
0147   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override;
0148 #endif
0149 
0150 #ifndef VECCORE_CUDA
0151   /// Templated factory for creating a placed volume
0152   static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0153                                VPlacedVolume *const placement = NULL);
0154 
0155   VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume, Transformation3D const *const transformation,
0156                                    VPlacedVolume *const placement) const override;
0157 #else
0158   VECCORE_ATT_DEVICE static VPlacedVolume *Create(LogicalVolume const *const logical_volume,
0159                                                   Transformation3D const *const transformation, const int id,
0160                                                   const int copy_no, const int child_id,
0161                                                   VPlacedVolume *const placement = NULL);
0162   VECCORE_ATT_DEVICE VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
0163                                                       Transformation3D const *const transformation, const int id,
0164                                                       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