File indexing completed on 2025-01-18 10:13:57
0001
0002
0003
0004 #ifndef VECGEOM_NAVIGATION_BVHSAFETYESTIMATOR_H_
0005 #define VECGEOM_NAVIGATION_BVHSAFETYESTIMATOR_H_
0006
0007 #include "VecGeom/management/BVHManager.h"
0008 #include "VecGeom/navigation/VSafetyEstimator.h"
0009
0010 namespace vecgeom {
0011 inline namespace VECGEOM_IMPL_NAMESPACE {
0012
0013
0014
0015
0016
0017
0018 class BVHSafetyEstimator : public VSafetyEstimatorHelper<BVHSafetyEstimator> {
0019 private:
0020
0021 VECCORE_ATT_DEVICE
0022 BVHSafetyEstimator() : VSafetyEstimatorHelper<BVHSafetyEstimator>() {}
0023
0024 public:
0025 static constexpr const char *gClassNameString = "BVHSafetyEstimator";
0026
0027 #ifndef VECCORE_CUDA
0028
0029 static VSafetyEstimator *Instance()
0030 {
0031 static BVHSafetyEstimator instance;
0032 return &instance;
0033 }
0034 #else
0035
0036
0037
0038 VECCORE_ATT_DEVICE
0039 static VSafetyEstimator *Instance();
0040 #endif
0041
0042
0043
0044
0045
0046
0047 VECCORE_ATT_HOST_DEVICE
0048 Precision ComputeSafetyForLocalPoint(Vector3D<Precision> const &localpoint, VPlacedVolume const *pvol) const final
0049 {
0050 Precision safety = pvol->SafetyToOut(localpoint);
0051
0052 if (safety > 0.0 && pvol->GetDaughters().size() > 0)
0053 safety = BVHManager::GetBVH(pvol->GetLogicalVolume())->ComputeSafety(localpoint, safety);
0054
0055 return safety;
0056 }
0057
0058
0059
0060
0061
0062
0063
0064
0065 VECCORE_ATT_HOST_DEVICE
0066 Precision ComputeSafetyToDaughtersForLocalPoint(Vector3D<Precision> const &localpoint,
0067 LogicalVolume const *lvol) const final
0068 {
0069 return BVHManager::GetBVH(lvol)->ComputeSafety(localpoint, kInfLength);
0070 }
0071
0072
0073
0074
0075
0076
0077
0078 VECCORE_ATT_HOST_DEVICE
0079 Real_v ComputeSafetyForLocalPoint(Vector3D<Real_v> const &localpoint, VPlacedVolume const *pvol, Bool_v m) const final
0080 {
0081 using vecCore::Get;
0082 using vecCore::Set;
0083 using vecCore::VectorSize;
0084
0085 Real_v safeties(kInfLength);
0086 for (size_t i = 0; i < VectorSize<Real_v>(); ++i) {
0087 if (Get(m, i) == true) {
0088 Vector3D<Precision> point(Get(localpoint[0], i), Get(localpoint[1], i), Get(localpoint[2], i));
0089 Set(safeties, i, ComputeSafetyForLocalPoint(point, pvol));
0090 }
0091 }
0092 return safeties;
0093 }
0094
0095
0096
0097
0098
0099
0100
0101 void ComputeSafetyForLocalPoints(SOA3D<Precision> const &localpoints, VPlacedVolume const *pvol,
0102 Precision *safeties) const final
0103 {
0104 for (size_t i = 0; i < localpoints.size(); ++i)
0105 safeties[i] = ComputeSafetyForLocalPoint({localpoints.x(i), localpoints.y(i), localpoints.z(i)}, pvol);
0106 }
0107 };
0108
0109 }
0110 }
0111
0112 #endif