File indexing completed on 2025-01-18 10:14:15
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef VECGEOM_VOLUMES_UNPLACEDORB_H_
0010 #define VECGEOM_VOLUMES_UNPLACEDORB_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/OrbStruct.h" // the pure Orb struct
0018 #include "VecGeom/volumes/kernel/OrbImplementation.h"
0019 #include "VecGeom/volumes/UnplacedVolumeImplHelper.h"
0020
0021 namespace vecgeom {
0022
0023 VECGEOM_DEVICE_FORWARD_DECLARE(class UnplacedOrb;);
0024 VECGEOM_DEVICE_DECLARE_CONV(class, UnplacedOrb);
0025
0026 inline namespace VECGEOM_IMPL_NAMESPACE {
0027
0028 class UnplacedOrb : public SIMDUnplacedVolumeImplHelper<OrbImplementation>, public AlignedBase {
0029
0030 private:
0031 OrbStruct<Precision> fOrb;
0032
0033 Precision fCubicVolume, fSurfaceArea;
0034
0035 Precision fEpsilon, fRTolerance;
0036
0037 public:
0038 using Kernel = OrbImplementation;
0039
0040
0041 VECCORE_ATT_HOST_DEVICE
0042 UnplacedOrb();
0043
0044
0045
0046
0047
0048 VECCORE_ATT_HOST_DEVICE
0049 UnplacedOrb(const Precision r);
0050
0051
0052 VECCORE_ATT_HOST_DEVICE
0053 void SetRadialTolerance();
0054
0055
0056 VECCORE_ATT_HOST_DEVICE
0057 Precision GetRadialTolerance() const { return fRTolerance; }
0058
0059
0060 VECCORE_ATT_HOST_DEVICE
0061 OrbStruct<Precision> const &GetStruct() const { return fOrb; }
0062
0063
0064 VECCORE_ATT_HOST_DEVICE
0065 VECGEOM_FORCE_INLINE
0066 Precision GetRadius() const { return fOrb.fR; }
0067
0068
0069 VECCORE_ATT_HOST_DEVICE
0070 void SetRadius(Precision r);
0071
0072 VECCORE_ATT_HOST_DEVICE
0073 void Extent(Vector3D<Precision> &aMin, Vector3D<Precision> &aMax) const override;
0074
0075 Precision Capacity() const override { return fCubicVolume; }
0076
0077 Precision SurfaceArea() const override { return fSurfaceArea; }
0078
0079 virtual Vector3D<Precision> SamplePointOnSurface() const override;
0080
0081 VECCORE_ATT_HOST_DEVICE
0082 virtual bool Normal(Vector3D<Precision> const &p, Vector3D<Precision> &normal) const override
0083 {
0084 bool valid;
0085 normal = OrbImplementation::NormalKernel(fOrb, p, valid);
0086 return valid;
0087 }
0088
0089
0090
0091 std::string GetEntityType() const;
0092
0093
0094
0095
0096
0097 VECCORE_ATT_HOST_DEVICE
0098 void GetParametersList(int aNumber, Precision *aArray) const;
0099
0100 VECCORE_ATT_HOST_DEVICE
0101 UnplacedOrb *Clone() const;
0102
0103 std::ostream &StreamInfo(std::ostream &os) const;
0104
0105 public:
0106 virtual int MemorySize() const final { return sizeof(*this); }
0107
0108 VECCORE_ATT_HOST_DEVICE
0109 virtual void Print() const override;
0110
0111 virtual void Print(std::ostream &os) const override;
0112
0113 #ifndef VECCORE_CUDA
0114 virtual SolidMesh *CreateMesh3D(Transformation3D const &trans, size_t nSegments) const override;
0115 #endif
0116
0117 #ifdef VECGEOM_CUDA_INTERFACE
0118 virtual size_t DeviceSizeOf() const override { return DevicePtr<cuda::UnplacedOrb>::SizeOf(); }
0119 virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override;
0120 virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override;
0121 #endif
0122
0123 #ifndef VECCORE_CUDA
0124
0125
0126 template <TranslationCode trans_code, RotationCode rot_code>
0127 static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0128 VPlacedVolume *const placement = NULL);
0129
0130 VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume, Transformation3D const *const transformation,
0131 const TranslationCode trans_code, const RotationCode rot_code,
0132 VPlacedVolume *const placement) const override;
0133 #else
0134 template <TranslationCode trans_code, RotationCode rot_code>
0135 VECCORE_ATT_DEVICE
0136 static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0137 const int id, const int copy_no, const int child_id,
0138 VPlacedVolume *const placement = NULL);
0139 VECCORE_ATT_DEVICE VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
0140 Transformation3D const *const transformation,
0141 const TranslationCode trans_code, const RotationCode rot_code,
0142 const int id, const int copy_no, const int child_id,
0143 VPlacedVolume *const placement) const override;
0144
0145 #endif
0146
0147
0148 #ifndef VECCORE_CUDA
0149 #ifdef VECGEOM_ROOT
0150 TGeoShape const *ConvertToRoot(char const *label = "") const;
0151 #endif
0152
0153 #ifdef VECGEOM_GEANT4
0154 G4VSolid const *ConvertToGeant4(char const *label = "") const;
0155 #endif
0156 #endif
0157 };
0158 }
0159 }
0160
0161 #endif