File indexing completed on 2026-09-16 09:29:36
0001
0002
0003 #ifndef VECGEOM_PLACEDASSEMBLY_H
0004 #define VECGEOM_PLACEDASSEMBLY_H
0005
0006 #include "VecGeom/base/Cuda.h"
0007 #include "VecGeom/volumes/UnplacedAssembly.h"
0008 #include "VecGeom/volumes/PlacedVolume.h"
0009 #include "VecGeom/navigation/NavStateFwd.h"
0010
0011 namespace vecgeom {
0012
0013 VECGEOM_DEVICE_FORWARD_DECLARE(class PlacedAssembly;);
0014 VECGEOM_DEVICE_DECLARE_CONV(class, PlacedAssembly);
0015
0016 inline namespace VECGEOM_IMPL_NAMESPACE {
0017
0018
0019
0020
0021
0022 class PlacedAssembly : public VPlacedVolume {
0023
0024 private:
0025 public:
0026 #ifndef VECCORE_CUDA
0027 VECCORE_ATT_HOST_DEVICE
0028 PlacedAssembly(char const *const label, LogicalVolume const *const logicalVolume,
0029 Transformation3D const *const transformation)
0030 : VPlacedVolume(label, logicalVolume, transformation)
0031 {
0032 }
0033 #else
0034 VECCORE_ATT_DEVICE PlacedAssembly(char const *const label, LogicalVolume const *const logical_volume,
0035 Transformation3D const *const transformation, const int id, const int copy_no,
0036 const int child_id)
0037 : VPlacedVolume(logical_volume, transformation, id, copy_no, child_id)
0038 {
0039 }
0040 #endif
0041
0042 VECCORE_ATT_HOST_DEVICE
0043 virtual ~PlacedAssembly() {}
0044
0045 VECCORE_ATT_HOST_DEVICE
0046 virtual void PrintType() const override;
0047 virtual void PrintType(std::ostream &os) const override;
0048
0049
0050 virtual int MemorySize() const override { return sizeof(*this); }
0051
0052 VECCORE_ATT_HOST_DEVICE
0053 virtual bool Contains(Vector3D<Precision> const &p) const override
0054 {
0055 return static_cast<UnplacedAssembly const *>(GetUnplacedVolume())
0056 ->UnplacedAssembly::Contains(GetTransformation()->Transform(p));
0057 }
0058
0059 VECCORE_ATT_HOST_DEVICE
0060 virtual bool Contains(Vector3D<Precision> const &point, Vector3D<Precision> &localPoint) const override
0061 {
0062 localPoint = GetTransformation()->Transform(point);
0063 return static_cast<UnplacedAssembly const *>(GetUnplacedVolume())->UnplacedAssembly::Contains(localPoint);
0064 }
0065
0066 VECCORE_ATT_HOST_DEVICE
0067 virtual bool UnplacedContains(Vector3D<Precision> const &point) const override
0068 {
0069 return static_cast<UnplacedAssembly const *>(GetUnplacedVolume())->UnplacedAssembly::Contains(point);
0070 }
0071
0072 VECCORE_ATT_HOST_DEVICE
0073 virtual EnumInside Inside(Vector3D<Precision> const & ) const override
0074 {
0075 #ifndef VECCORE_CUDA
0076 throw std::runtime_error("unimplemented function called");
0077 #endif
0078 return vecgeom::kOutside;
0079 }
0080
0081 VECCORE_ATT_HOST_DEVICE
0082 virtual Precision DistanceToIn(Vector3D<Precision> const &position, Vector3D<Precision> const &direction,
0083 const Precision step_max = kInfLength) const override
0084 {
0085 return static_cast<UnplacedAssembly const *>(GetUnplacedVolume())
0086 ->UnplacedAssembly::DistanceToIn(GetTransformation()->Transform(position),
0087 GetTransformation()->TransformDirection(direction), step_max);
0088 }
0089
0090 VECCORE_ATT_HOST_DEVICE
0091 virtual Precision DistanceToOut(Vector3D<Precision> const & , Vector3D<Precision> const & ,
0092 Precision const ) const override
0093 {
0094 #ifndef VECCORE_CUDA
0095 throw std::runtime_error("unimplemented function called");
0096 #endif
0097 return -1.;
0098 }
0099
0100 VECCORE_ATT_HOST_DEVICE
0101 virtual Precision PlacedDistanceToOut(Vector3D<Precision> const & ,
0102 Vector3D<Precision> const & ,
0103 Precision const ) const override
0104 {
0105 #ifndef VECCORE_CUDA
0106 throw std::runtime_error("unimplemented function called");
0107 #endif
0108 return -1.;
0109 }
0110
0111 VECCORE_ATT_HOST_DEVICE
0112 virtual Precision SafetyToOut(Vector3D<Precision> const &position) const override
0113 {
0114 return GetUnplacedVolume()->SafetyToOut(position);
0115 }
0116
0117 VECCORE_ATT_HOST_DEVICE
0118 virtual Precision SafetyToIn(Vector3D<Precision> const &position) const override
0119 {
0120 return static_cast<UnplacedAssembly const *>(GetUnplacedVolume())
0121 ->UnplacedAssembly::SafetyToIn(GetTransformation()->Transform(position));
0122 }
0123
0124 Precision SurfaceArea() const override
0125 {
0126 return static_cast<UnplacedAssembly const *>(GetUnplacedVolume())->SurfaceArea();
0127 }
0128
0129 #ifndef VECCORE_CUDA
0130 virtual VPlacedVolume const *ConvertToUnspecialized() const override { return this; }
0131 #ifdef VECGEOM_ROOT
0132 virtual TGeoShape const *ConvertToRoot() const override { throw std::runtime_error("unimplemented function called"); }
0133 #endif
0134 #ifdef VECGEOM_GEANT4
0135 virtual G4VSolid const *ConvertToGeant4() const override
0136 {
0137 throw std::runtime_error("unimplemented function called");
0138 }
0139 #endif
0140 #endif
0141
0142 #ifdef VECGEOM_CUDA_INTERFACE
0143
0144 virtual size_t DeviceSizeOf() const override { return 0; }
0145 virtual DevicePtr<cuda::VPlacedVolume> CopyToGpu(DevicePtr<cuda::LogicalVolume> const ,
0146 DevicePtr<cuda::Transformation3D> const ,
0147 DevicePtr<cuda::VPlacedVolume> const ) const override
0148 {
0149 return DevicePtr<cuda::VPlacedVolume>(nullptr);
0150 }
0151 virtual DevicePtr<cuda::VPlacedVolume> CopyToGpu(DevicePtr<cuda::LogicalVolume> const ,
0152 DevicePtr<cuda::Transformation3D> const ) const override
0153 {
0154 return DevicePtr<cuda::VPlacedVolume>(nullptr);
0155 }
0156
0157
0158 virtual void CopyManyToGpu(std::vector<VPlacedVolume const *> const &host_volumes,
0159 std::vector<DevicePtr<cuda::LogicalVolume>> const &logical_volumes,
0160 std::vector<DevicePtr<cuda::Transformation3D>> const &transforms,
0161 std::vector<DevicePtr<cuda::VPlacedVolume>> const &in_gpu_ptrs) const override
0162 {
0163 }
0164 #endif
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174 VECCORE_ATT_HOST_DEVICE
0175 bool Contains(Vector3D<Precision> const &p, Vector3D<Precision> &lp, NavigationState &state) const
0176 {
0177 state.Push(this);
0178
0179 auto indaughter = static_cast<UnplacedAssembly const *>(GetUnplacedVolume())
0180 ->UnplacedAssembly::Contains(GetTransformation()->Transform(p), lp, state);
0181 if (!indaughter) state.Pop();
0182 return indaughter;
0183 }
0184
0185 };
0186 }
0187 }
0188
0189 #endif