1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
|
// LICENSING INFORMATION TBD
#ifndef VECGEOM_PLACEDASSEMBLY_H
#define VECGEOM_PLACEDASSEMBLY_H
#include "VecGeom/base/Cuda.h"
#include "VecGeom/volumes/UnplacedAssembly.h"
#include "VecGeom/volumes/PlacedVolume.h"
#include "VecGeom/navigation/NavStateFwd.h"
namespace vecgeom {
VECGEOM_DEVICE_FORWARD_DECLARE(class PlacedAssembly;);
VECGEOM_DEVICE_DECLARE_CONV(class, PlacedAssembly);
inline namespace VECGEOM_IMPL_NAMESPACE {
// class NavigationState;
// placed version of an assembly
// simple and unspecialized implementation
class PlacedAssembly : public VPlacedVolume {
private:
public:
#ifndef VECCORE_CUDA
VECCORE_ATT_HOST_DEVICE
PlacedAssembly(char const *const label, LogicalVolume const *const logicalVolume,
Transformation3D const *const transformation)
: VPlacedVolume(label, logicalVolume, transformation)
{
} // the constructor
#else
VECCORE_ATT_DEVICE PlacedAssembly(char const *const label, LogicalVolume const *const logical_volume,
Transformation3D const *const transformation, const int id, const int copy_no,
const int child_id)
: VPlacedVolume(logical_volume, transformation, id, copy_no, child_id)
{
}
#endif
VECCORE_ATT_HOST_DEVICE
virtual ~PlacedAssembly();
// the VPlacedVolume Interfaces -----
virtual int MemorySize() const override { return sizeof(*this); }
VECCORE_ATT_HOST_DEVICE
virtual void PrintType() const override;
virtual void PrintType(std::ostream &s) const override;
virtual void PrintImplementationType(std::ostream &) const override
{
#ifndef VECCORE_CUDA
throw std::runtime_error("unimplemented function called");
#endif
}
virtual void PrintUnplacedType(std::ostream &) const override
{
#ifndef VECCORE_CUDA
throw std::runtime_error("unimplemented function called");
#endif
}
VECCORE_ATT_HOST_DEVICE
virtual bool Contains(Vector3D<Precision> const &p) const override
{
return static_cast<UnplacedAssembly const *>(GetUnplacedVolume())
->UnplacedAssembly::Contains(GetTransformation()->Transform(p));
}
VECCORE_ATT_HOST_DEVICE
virtual bool Contains(Vector3D<Precision> const &point, Vector3D<Precision> &localPoint) const override
{
localPoint = GetTransformation()->Transform(point);
return static_cast<UnplacedAssembly const *>(GetUnplacedVolume())->UnplacedAssembly::Contains(localPoint);
}
virtual void Contains(SOA3D<Precision> const & /*points*/, bool *const /*output*/) const override
{
throw std::runtime_error("unimplemented function called");
}
VECCORE_ATT_HOST_DEVICE
VECGEOM_FORCE_INLINE
virtual bool UnplacedContains(Vector3D<Precision> const &point) const override
{
return static_cast<UnplacedAssembly const *>(GetUnplacedVolume())->UnplacedAssembly::Contains(point);
}
VECCORE_ATT_HOST_DEVICE
VECGEOM_FORCE_INLINE
virtual EnumInside Inside(Vector3D<Precision> const & /*point*/) const override
{
#ifndef VECCORE_CUDA
throw std::runtime_error("unimplemented function called");
#endif
return vecgeom::kOutside; // dummy return
}
virtual void Inside(SOA3D<Precision> const & /*points*/, Inside_t *const /*output*/) const override
{
throw std::runtime_error("unimplemented function called");
}
VECCORE_ATT_HOST_DEVICE
VECGEOM_FORCE_INLINE
virtual Precision DistanceToIn(Vector3D<Precision> const &position, Vector3D<Precision> const &direction,
const Precision step_max = kInfLength) const override
{
return static_cast<UnplacedAssembly const *>(GetUnplacedVolume())
->UnplacedAssembly::DistanceToIn(GetTransformation()->Transform(position),
GetTransformation()->TransformDirection(direction), step_max);
}
virtual void DistanceToIn(SOA3D<Precision> const & /*position*/, SOA3D<Precision> const & /*direction*/,
Precision const *const /*stepMax*/, Precision *const /*output*/) const override
{
throw std::runtime_error("unimplemented function called");
}
VECCORE_ATT_HOST_DEVICE
VECGEOM_FORCE_INLINE
virtual Precision DistanceToOut(Vector3D<Precision> const & /*position*/, Vector3D<Precision> const & /*direction*/,
Precision const /*stepMax*/) const override
{
#ifndef VECCORE_CUDA
throw std::runtime_error("unimplemented function called");
#endif
return -1.; // dummy return
}
VECCORE_ATT_HOST_DEVICE
virtual Precision PlacedDistanceToOut(Vector3D<Precision> const & /*position*/,
Vector3D<Precision> const & /*direction*/,
Precision const /*stepMax*/) const override
{
#ifndef VECCORE_CUDA
throw std::runtime_error("unimplemented function called");
#endif
return -1.;
}
virtual void DistanceToOut(SOA3D<Precision> const & /*position*/, SOA3D<Precision> const & /*direction*/,
Precision const *const /*step_max*/, Precision *const /*output*/) const override
{
throw std::runtime_error("unimplemented function called");
}
virtual void DistanceToOut(SOA3D<Precision> const & /*position*/, SOA3D<Precision> const & /*direction*/,
Precision const *const /*step_max*/, Precision *const /*output*/,
int *const /*nextnodeindex*/) const override
{
throw std::runtime_error("unimplemented function called");
}
VECCORE_ATT_HOST_DEVICE
VECGEOM_FORCE_INLINE
virtual Precision SafetyToOut(Vector3D<Precision> const &position) const override
{
return GetUnplacedVolume()->SafetyToOut(position);
}
virtual void SafetyToOut(SOA3D<Precision> const & /*position*/, Precision *const /*safeties*/) const override
{
throw std::runtime_error("unimplemented function called");
}
VECCORE_ATT_HOST_DEVICE
VECGEOM_FORCE_INLINE
virtual Precision SafetyToIn(Vector3D<Precision> const &position) const override
{
return static_cast<UnplacedAssembly const *>(GetUnplacedVolume())
->UnplacedAssembly::SafetyToIn(GetTransformation()->Transform(position));
}
virtual void SafetyToIn(SOA3D<Precision> const & /*position*/, Precision *const /*safeties*/) const override
{
throw std::runtime_error("unimplemented function called");
}
// the SIMD vector interfaces (not implemented)
virtual Real_v DistanceToInVec(Vector3D<Real_v> const & /*position*/, Vector3D<Real_v> const & /*direction*/,
Real_v const /*step_max*/ = kInfLength) const override
{
#ifndef VECCORE_CUDA
throw std::runtime_error("unimplemented function called");
#endif
return Real_v(-1.);
}
virtual Real_v DistanceToOutVec(Vector3D<Real_v> const & /*position*/, Vector3D<Real_v> const & /*direction*/,
Real_v const /*step_max*/ = kInfLength) const override
{
#ifndef VECCORE_CUDA
throw std::runtime_error("unimplemented function called");
#endif
return Real_v(-1.);
}
virtual Real_v SafetyToInVec(Vector3D<Real_v> const & /*position*/) const override
{
#ifndef VECCORE_CUDA
throw std::runtime_error("unimplemented function called");
#endif
return Real_v(-1.);
}
virtual Real_v SafetyToOutVec(Vector3D<Real_v> const & /*position*/) const override
{
#ifndef VECCORE_CUDA
throw std::runtime_error("unimplemented function called");
#endif
return Real_v(-1.);
}
Precision SurfaceArea() const override
{
return static_cast<UnplacedAssembly const *>(GetUnplacedVolume())->SurfaceArea();
}
#ifndef VECCORE_CUDA
virtual VPlacedVolume const *ConvertToUnspecialized() const override { return this; }
#ifdef VECGEOM_ROOT
virtual TGeoShape const *ConvertToRoot() const override { throw std::runtime_error("unimplemented function called"); }
#endif
#ifdef VECGEOM_GEANT4
virtual G4VSolid const *ConvertToGeant4() const override
{
throw std::runtime_error("unimplemented function called");
}
#endif
#endif
#ifdef VECGEOM_CUDA_INTERFACE
// TBD properly
virtual size_t DeviceSizeOf() const override { return 0; /*DevicePtr<cuda::PlacedAssembly>::SizeOf();*/ }
virtual DevicePtr<cuda::VPlacedVolume> CopyToGpu(DevicePtr<cuda::LogicalVolume> const /*logical_volume*/,
DevicePtr<cuda::Transformation3D> const /*transform*/,
DevicePtr<cuda::VPlacedVolume> const /*gpu_ptr*/) const override
{
return DevicePtr<cuda::VPlacedVolume>(nullptr);
}
virtual DevicePtr<cuda::VPlacedVolume> CopyToGpu(DevicePtr<cuda::LogicalVolume> const /*logical_volume*/,
DevicePtr<cuda::Transformation3D> const /*transform*/) const override
{
return DevicePtr<cuda::VPlacedVolume>(nullptr);
}
/// Not implemented.
virtual void CopyManyToGpu(std::vector<VPlacedVolume const *> const & host_volumes,
std::vector<DevicePtr<cuda::LogicalVolume>> const & logical_volumes,
std::vector<DevicePtr<cuda::Transformation3D>> const & transforms,
std::vector<DevicePtr<cuda::VPlacedVolume>> const & in_gpu_ptrs) const override
{
}
#endif
// specific PlacedAssembly Interfaces ---------
// an extended contains functions needed for navigation
// if this function returns true it modifies the navigation state to point to the first non-assembly volume
// the point is contained in
// this function is not part of the generic UnplacedVolume interface but we could consider doing so
// N.B To work correctly, the input state must be initialized to point to the parent volume of this placed assembly
// otherwise the Push/Pop cannot work correctly since they do not match a valid navigation state
VECCORE_ATT_HOST_DEVICE
bool Contains(Vector3D<Precision> const &p, Vector3D<Precision> &lp, NavigationState &state) const
{
state.Push(this);
// call unplaced variant with transformed point
auto indaughter = static_cast<UnplacedAssembly const *>(GetUnplacedVolume())
->UnplacedAssembly::Contains(GetTransformation()->Transform(p), lp, state);
if (!indaughter) state.Pop();
return indaughter;
}
}; // end class
} // namespace VECGEOM_IMPL_NAMESPACE
} // namespace vecgeom
#endif // PLACEDASSEMBLY_H
|