Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:26:19

0001 #pragma once
0002 
0003 #include "VecGeom/base/Global.h"
0004 #include "VecGeom/base/SOA3D.h"
0005 #include "VecGeom/volumes/PlacedVolume.h"
0006 
0007 #include <algorithm>
0008 
0009 namespace vecgeom {
0010 
0011 VECGEOM_DEVICE_DECLARE_CONV_TEMPLATE_2v(struct, PlacedVolumeImplHelper, class, Arg1, class, Arg2);
0012 
0013 inline namespace VECGEOM_IMPL_NAMESPACE {
0014 
0015 // A helper template class to automatically implement (wire)
0016 // interfaces from PlacedVolume using kernel functions and functionality
0017 // from the unplaced shapes
0018 template <class UnplacedShape_t, class BaseVol = VPlacedVolume>
0019 struct PlacedVolumeImplHelper : public BaseVol {
0020 
0021   using Helper_t = PlacedVolumeImplHelper<UnplacedShape_t, BaseVol>;
0022   using Struct_t = typename UnplacedShape_t::UnplacedStruct_t;
0023 
0024 public:
0025   using BaseVol::BaseVol;
0026   using BaseVol::GetLogicalVolume;
0027   using BaseVol::PrintType;
0028 
0029   // destructor
0030   VECCORE_ATT_HOST_DEVICE
0031   virtual ~PlacedVolumeImplHelper() {}
0032 
0033   virtual int MemorySize() const override { return sizeof(*this); }
0034 
0035   VECCORE_ATT_HOST_DEVICE
0036   UnplacedShape_t const *GetUnplacedVolume() const
0037   {
0038     return static_cast<UnplacedShape_t const *>(GetLogicalVolume()->GetUnplacedVolume());
0039   }
0040 
0041   VECCORE_ATT_HOST_DEVICE
0042   Struct_t const *GetUnplacedStruct() const { return static_cast<Struct_t const *>(&GetUnplacedVolume()->GetStruct()); }
0043 
0044 #if !defined(VECCORE_CUDA)
0045   virtual Precision Capacity() override { return const_cast<UnplacedShape_t *>(GetUnplacedVolume())->Capacity(); }
0046 
0047   virtual void Extent(Vector3D<Precision> &aMin, Vector3D<Precision> &aMax) const override
0048   {
0049     VPlacedVolume::Extent(aMin, aMax);
0050   }
0051 
0052   VECCORE_ATT_HOST_DEVICE
0053   virtual bool Normal(Vector3D<Precision> const &point, Vector3D<Precision> &normal) const override
0054   {
0055     return VPlacedVolume::Normal(point, normal);
0056   }
0057 #endif
0058 
0059   virtual Precision SurfaceArea() const override { return GetUnplacedVolume()->SurfaceArea(); }
0060 
0061   VECCORE_ATT_HOST_DEVICE
0062   virtual bool UnplacedContains(Vector3D<Precision> const &point) const override
0063   {
0064     return GetUnplacedVolume()->UnplacedShape_t::Contains(point);
0065   }
0066 
0067   VECCORE_ATT_HOST_DEVICE
0068   virtual Precision DistanceToOut(Vector3D<Precision> const &point, Vector3D<Precision> const &direction,
0069                                   const Precision stepMax = kInfLength) const override
0070   {
0071     return GetUnplacedVolume()->UnplacedShape_t::DistanceToOut(point, direction, stepMax);
0072   }
0073 
0074   virtual Real_v DistanceToOutVec(Vector3D<Real_v> const &position, Vector3D<Real_v> const &direction,
0075                                   Real_v const step_max = kInfLength) const override
0076   {
0077     return GetUnplacedVolume()->UnplacedShape_t::DistanceToOutVec(position, direction, step_max);
0078   }
0079 
0080   // a helper tramponline to dispatch to DistanceToOutVec if type is not scalar
0081   template <typename T>
0082   VECGEOM_FORCE_INLINE
0083   VECCORE_ATT_HOST_DEVICE
0084   T DistanceToOut(Vector3D<T> const &p, Vector3D<T> const &d, T const &step_max) const
0085   {
0086     return DistanceToOutVec(p, d, step_max);
0087   }
0088 
0089   VECCORE_ATT_HOST_DEVICE
0090   virtual Precision SafetyToOut(Vector3D<Precision> const &point) const override
0091   {
0092     return GetUnplacedVolume()->UnplacedShape_t::SafetyToOut(point);
0093   }
0094 
0095   virtual Real_v SafetyToOutVec(Vector3D<Real_v> const &position) const override
0096   {
0097     return GetUnplacedVolume()->UnplacedShape_t::SafetyToOutVec(position);
0098   }
0099 
0100   virtual void DistanceToOut(SOA3D<Precision> const &points, SOA3D<Precision> const &directions,
0101                              Precision const *const stepMax, Precision *const output) const override
0102   {
0103     GetUnplacedVolume()->UnplacedShape_t::DistanceToOut(points, directions, stepMax, output);
0104   }
0105 
0106   virtual void DistanceToOut(SOA3D<Precision> const & /* position */, SOA3D<Precision> const & /* direction */,
0107                              Precision const *const /* step_max */, Precision *const /* output */,
0108                              int *const /* nextnodeindex */) const override
0109   {
0110     // interface not implemented (depcrecated)
0111   }
0112 
0113   virtual void SafetyToOut(SOA3D<Precision> const &points, Precision *const output) const override
0114   {
0115     GetUnplacedVolume()->UnplacedShape_t::SafetyToOut(points, output);
0116   }
0117 
0118 }; // End class PlacedVolumeImplHelper
0119 } // namespace VECGEOM_IMPL_NAMESPACE
0120 } // namespace vecgeom