File indexing completed on 2025-01-30 10:26:18
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
0046 virtual int MemorySize() const override { return sizeof(*this); }
0047
0048 VECCORE_ATT_HOST_DEVICE
0049 virtual void PrintType() const override;
0050
0051 virtual void PrintType(std::ostream &s) const override;
0052
0053 virtual void PrintImplementationType(std::ostream &) const override
0054 {
0055 #ifndef VECCORE_CUDA
0056 throw std::runtime_error("unimplemented function called");
0057 #endif
0058 }
0059 virtual void PrintUnplacedType(std::ostream &) const override
0060 {
0061 #ifndef VECCORE_CUDA
0062 throw std::runtime_error("unimplemented function called");
0063 #endif
0064 }
0065
0066 VECCORE_ATT_HOST_DEVICE
0067 virtual bool Contains(Vector3D<Precision> const &p) const override
0068 {
0069 return static_cast<UnplacedAssembly const *>(GetUnplacedVolume())
0070 ->UnplacedAssembly::Contains(GetTransformation()->Transform(p));
0071 }
0072
0073 VECCORE_ATT_HOST_DEVICE
0074 virtual bool Contains(Vector3D<Precision> const &point, Vector3D<Precision> &localPoint) const override
0075 {
0076 localPoint = GetTransformation()->Transform(point);
0077 return static_cast<UnplacedAssembly const *>(GetUnplacedVolume())->UnplacedAssembly::Contains(localPoint);
0078 }
0079
0080 virtual void Contains(SOA3D<Precision> const & , bool *const ) const override
0081 {
0082 throw std::runtime_error("unimplemented function called");
0083 }
0084
0085 VECCORE_ATT_HOST_DEVICE
0086 VECGEOM_FORCE_INLINE
0087 virtual bool UnplacedContains(Vector3D<Precision> const &point) const override
0088 {
0089 return static_cast<UnplacedAssembly const *>(GetUnplacedVolume())->UnplacedAssembly::Contains(point);
0090 }
0091
0092 VECCORE_ATT_HOST_DEVICE
0093 VECGEOM_FORCE_INLINE
0094 virtual EnumInside Inside(Vector3D<Precision> const & ) const override
0095 {
0096 #ifndef VECCORE_CUDA
0097 throw std::runtime_error("unimplemented function called");
0098 #endif
0099 return vecgeom::kOutside;
0100 }
0101
0102 virtual void Inside(SOA3D<Precision> const & , Inside_t *const ) const override
0103 {
0104 throw std::runtime_error("unimplemented function called");
0105 }
0106
0107 VECCORE_ATT_HOST_DEVICE
0108 VECGEOM_FORCE_INLINE
0109 virtual Precision DistanceToIn(Vector3D<Precision> const &position, Vector3D<Precision> const &direction,
0110 const Precision step_max = kInfLength) const override
0111 {
0112 return static_cast<UnplacedAssembly const *>(GetUnplacedVolume())
0113 ->UnplacedAssembly::DistanceToIn(GetTransformation()->Transform(position),
0114 GetTransformation()->TransformDirection(direction), step_max);
0115 }
0116
0117 virtual void DistanceToIn(SOA3D<Precision> const & , SOA3D<Precision> const & ,
0118 Precision const *const , Precision *const ) const override
0119 {
0120 throw std::runtime_error("unimplemented function called");
0121 }
0122
0123 VECCORE_ATT_HOST_DEVICE
0124 VECGEOM_FORCE_INLINE
0125 virtual Precision DistanceToOut(Vector3D<Precision> const & , Vector3D<Precision> const & ,
0126 Precision const ) const override
0127 {
0128 #ifndef VECCORE_CUDA
0129 throw std::runtime_error("unimplemented function called");
0130 #endif
0131 return -1.;
0132 }
0133
0134 VECCORE_ATT_HOST_DEVICE
0135 virtual Precision PlacedDistanceToOut(Vector3D<Precision> const & ,
0136 Vector3D<Precision> const & ,
0137 Precision const ) const override
0138 {
0139 #ifndef VECCORE_CUDA
0140 throw std::runtime_error("unimplemented function called");
0141 #endif
0142 return -1.;
0143 }
0144
0145 virtual void DistanceToOut(SOA3D<Precision> const & , SOA3D<Precision> const & ,
0146 Precision const *const , Precision *const ) const override
0147 {
0148 throw std::runtime_error("unimplemented function called");
0149 }
0150
0151 virtual void DistanceToOut(SOA3D<Precision> const & , SOA3D<Precision> const & ,
0152 Precision const *const , Precision *const ,
0153 int *const ) const override
0154 {
0155 throw std::runtime_error("unimplemented function called");
0156 }
0157
0158 VECCORE_ATT_HOST_DEVICE
0159 VECGEOM_FORCE_INLINE
0160 virtual Precision SafetyToOut(Vector3D<Precision> const &position) const override
0161 {
0162 return GetUnplacedVolume()->SafetyToOut(position);
0163 }
0164
0165 virtual void SafetyToOut(SOA3D<Precision> const & , Precision *const ) const override
0166 {
0167 throw std::runtime_error("unimplemented function called");
0168 }
0169
0170 VECCORE_ATT_HOST_DEVICE
0171 VECGEOM_FORCE_INLINE
0172 virtual Precision SafetyToIn(Vector3D<Precision> const &position) const override
0173 {
0174 return static_cast<UnplacedAssembly const *>(GetUnplacedVolume())
0175 ->UnplacedAssembly::SafetyToIn(GetTransformation()->Transform(position));
0176 }
0177
0178 virtual void SafetyToIn(SOA3D<Precision> const & , Precision *const ) const override
0179 {
0180 throw std::runtime_error("unimplemented function called");
0181 }
0182
0183
0184 virtual Real_v DistanceToInVec(Vector3D<Real_v> const & , Vector3D<Real_v> const & ,
0185 Real_v const = kInfLength) const override
0186 {
0187 #ifndef VECCORE_CUDA
0188 throw std::runtime_error("unimplemented function called");
0189 #endif
0190 return Real_v(-1.);
0191 }
0192
0193 virtual Real_v DistanceToOutVec(Vector3D<Real_v> const & , Vector3D<Real_v> const & ,
0194 Real_v const = kInfLength) const override
0195 {
0196 #ifndef VECCORE_CUDA
0197 throw std::runtime_error("unimplemented function called");
0198 #endif
0199 return Real_v(-1.);
0200 }
0201
0202 virtual Real_v SafetyToInVec(Vector3D<Real_v> const & ) const override
0203 {
0204 #ifndef VECCORE_CUDA
0205 throw std::runtime_error("unimplemented function called");
0206 #endif
0207 return Real_v(-1.);
0208 }
0209
0210 virtual Real_v SafetyToOutVec(Vector3D<Real_v> const & ) const override
0211 {
0212 #ifndef VECCORE_CUDA
0213 throw std::runtime_error("unimplemented function called");
0214 #endif
0215 return Real_v(-1.);
0216 }
0217
0218 Precision SurfaceArea() const override
0219 {
0220 return static_cast<UnplacedAssembly const *>(GetUnplacedVolume())->SurfaceArea();
0221 }
0222
0223 #ifndef VECCORE_CUDA
0224 virtual VPlacedVolume const *ConvertToUnspecialized() const override { return this; }
0225 #ifdef VECGEOM_ROOT
0226 virtual TGeoShape const *ConvertToRoot() const override { throw std::runtime_error("unimplemented function called"); }
0227 #endif
0228 #ifdef VECGEOM_GEANT4
0229 virtual G4VSolid const *ConvertToGeant4() const override
0230 {
0231 throw std::runtime_error("unimplemented function called");
0232 }
0233 #endif
0234 #endif
0235
0236 #ifdef VECGEOM_CUDA_INTERFACE
0237
0238 virtual size_t DeviceSizeOf() const override { return 0; }
0239 virtual DevicePtr<cuda::VPlacedVolume> CopyToGpu(DevicePtr<cuda::LogicalVolume> const ,
0240 DevicePtr<cuda::Transformation3D> const ,
0241 DevicePtr<cuda::VPlacedVolume> const ) const override
0242 {
0243 return DevicePtr<cuda::VPlacedVolume>(nullptr);
0244 }
0245 virtual DevicePtr<cuda::VPlacedVolume> CopyToGpu(DevicePtr<cuda::LogicalVolume> const ,
0246 DevicePtr<cuda::Transformation3D> const ) const override
0247 {
0248 return DevicePtr<cuda::VPlacedVolume>(nullptr);
0249 }
0250
0251
0252 virtual void CopyManyToGpu(std::vector<VPlacedVolume const *> const &host_volumes,
0253 std::vector<DevicePtr<cuda::LogicalVolume>> const &logical_volumes,
0254 std::vector<DevicePtr<cuda::Transformation3D>> const &transforms,
0255 std::vector<DevicePtr<cuda::VPlacedVolume>> const &in_gpu_ptrs) const override
0256 {
0257 }
0258 #endif
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268 VECCORE_ATT_HOST_DEVICE
0269 bool Contains(Vector3D<Precision> const &p, Vector3D<Precision> &lp, NavigationState &state) const
0270 {
0271 state.Push(this);
0272
0273 auto indaughter = static_cast<UnplacedAssembly const *>(GetUnplacedVolume())
0274 ->UnplacedAssembly::Contains(GetTransformation()->Transform(p), lp, state);
0275 if (!indaughter) state.Pop();
0276 return indaughter;
0277 }
0278
0279 };
0280 }
0281 }
0282
0283 #endif