Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:15

0001 #ifndef VECGEOM_VOLUMES_UNPLACEDMULTIUNION_H_
0002 #define VECGEOM_VOLUMES_UNPLACEDMULTIUNION_H_
0003 /**
0004  @brief Class representing an unplaced union of multiple placed solids, possibly overlapping.
0005  Implemented based on the class G4MultipleUnion
0006  @author mihaela.gheata@cern.ch
0007 */
0008 
0009 #include "VecGeom/base/Cuda.h"
0010 #include "VecGeom/base/Global.h"
0011 #include "VecGeom/base/AlignedBase.h"
0012 #include "VecGeom/base/Vector3D.h"
0013 #include "VecGeom/volumes/UnplacedVolume.h"
0014 #include "MultiUnionStruct.h"
0015 #include "VecGeom/volumes/kernel/MultiUnionImplementation.h"
0016 #include "VecGeom/volumes/UnplacedVolumeImplHelper.h"
0017 
0018 namespace vecgeom {
0019 
0020 VECGEOM_DEVICE_DECLARE_CONV(class, UnplacedMultiUnion);
0021 VECGEOM_DEVICE_FORWARD_DECLARE(class UnplacedMultiUnion;);
0022 
0023 inline namespace VECGEOM_IMPL_NAMESPACE {
0024 
0025 class UnplacedMultiUnion : public LoopUnplacedVolumeImplHelper<MultiUnionImplementation>, public AlignedBase {
0026 
0027 protected:
0028   mutable MultiUnionStruct fMultiUnion; ///< Structure storing multi-union parameters
0029 
0030 public:
0031   // the constructor
0032   VECCORE_ATT_HOST_DEVICE
0033   UnplacedMultiUnion() : fMultiUnion()
0034   {
0035     fGlobalConvexity = false;
0036     ComputeBBox();
0037   }
0038 
0039   VECCORE_ATT_HOST_DEVICE
0040   VECGEOM_FORCE_INLINE
0041   void AddNode(VUnplacedVolume const *volume, Transformation3D const &transform)
0042   {
0043     LogicalVolume *lvol = new LogicalVolume(volume);
0044     VPlacedVolume *pvol = lvol->Place(new Transformation3D(transform));
0045     fMultiUnion.AddNode(pvol);
0046   }
0047 
0048   VECCORE_ATT_HOST_DEVICE
0049   VECGEOM_FORCE_INLINE
0050   void AddNode(VPlacedVolume const *volume) { fMultiUnion.AddNode(volume); }
0051 
0052   VECCORE_ATT_HOST_DEVICE
0053   void Close() { fMultiUnion.Close(); }
0054 
0055   VECCORE_ATT_HOST_DEVICE
0056   VECGEOM_FORCE_INLINE
0057   VPlacedVolume const *GetNode(size_t i) const { return fMultiUnion.fVolumes[i]; }
0058 
0059   VECCORE_ATT_HOST_DEVICE
0060   MultiUnionStruct const &GetStruct() const { return fMultiUnion; }
0061 
0062   VECCORE_ATT_HOST_DEVICE
0063   bool Normal(Vector3D<Precision> const &point, Vector3D<Precision> &normal) const override;
0064 
0065   Precision Capacity() const override;
0066 
0067   Precision SurfaceArea() const override;
0068 
0069   VECCORE_ATT_HOST_DEVICE
0070   VECGEOM_FORCE_INLINE
0071   size_t GetNumberOfSolids() const { return fMultiUnion.fVolumes.size(); }
0072 
0073   VECCORE_ATT_HOST_DEVICE
0074   void Extent(Vector3D<Precision> &aMin, Vector3D<Precision> &aMax) const override
0075   {
0076     aMin = fMultiUnion.fMinExtent;
0077     aMax = fMultiUnion.fMaxExtent;
0078   }
0079 
0080   Vector3D<Precision> SamplePointOnSurface() const override;
0081 
0082   std::string GetEntityType() const { return "MultiUnion"; }
0083 
0084   VECCORE_ATT_HOST_DEVICE
0085   virtual void Print() const override{};
0086 
0087   virtual void Print(std::ostream & /*os*/) const override{};
0088 
0089   template <TranslationCode transCodeT, RotationCode rotCodeT>
0090   VECCORE_ATT_DEVICE
0091   static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
0092 #ifdef VECCORE_CUDA
0093                                const int id,
0094 #endif
0095                                VPlacedVolume *const placement = NULL);
0096 
0097 #ifdef VECGEOM_CUDA_INTERFACE
0098 #ifdef VECGEOM_CUDA_HYBRID2
0099   virtual size_t DeviceSizeOf() const override { return DevicePtr<cuda::UnplacedMultiUnion>::SizeOf(); }
0100   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override;
0101   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override;
0102 #else
0103   virtual size_t DeviceSizeOf() const override { return 0; }
0104   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override { return DevicePtr<cuda::VUnplacedVolume>(); }
0105   virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override
0106   {
0107     return DevicePtr<cuda::VUnplacedVolume>(gpu_ptr);
0108   }
0109 #endif
0110 #endif
0111 
0112 private:
0113   VECCORE_ATT_DEVICE
0114   virtual VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
0115                                            Transformation3D const *const transformation,
0116                                            const TranslationCode trans_code, const RotationCode rot_code,
0117 #ifdef VECCORE_CUDA
0118                                            const int id,
0119 #endif
0120                                            VPlacedVolume *const placement = NULL) const override;
0121 
0122 }; // End class
0123 } // End impl namespace
0124 } // End global namespace
0125 
0126 #endif /* VECGEOM_VOLUMES_UNPLACEDMULTIUNION_H_ */