File indexing completed on 2026-09-08 09:27:58
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 VECCORE_ATT_HOST_DEVICE
0043 static Precision CandidateSafetyToIn(int aItemIndex, int index, Vector3D<Precision> localpoint)
0044 {
0045 #ifdef VECCORE_CUDA_DEVICE_COMPILATION
0046 return vecgeom::globaldevicegeomdata::gDeviceLogicalVolumes[aItemIndex].GetDaughters()[index]->SafetyToIn(
0047 localpoint);
0048 #else
0049 return GeoManager::Instance().FindLogicalVolume(aItemIndex)->GetDaughters()[index]->SafetyToIn(localpoint);
0050 #endif
0051 };
0052
0053
0054
0055
0056
0057
0058 VECCORE_ATT_HOST_DEVICE
0059 Precision ComputeSafetyForLocalPoint(Vector3D<Precision> const &localpoint, VPlacedVolume const *pvol) const final
0060 {
0061 Precision safety = pvol->SafetyToOut(localpoint);
0062
0063 if (safety > 0.0 && pvol->GetDaughters().size() > 0)
0064 safety = BVHManager::GetBVH(pvol->GetLogicalVolume())->ComputeSafety<BVHSafetyEstimator>(localpoint, safety);
0065 return safety;
0066 }
0067
0068
0069
0070
0071
0072
0073
0074
0075 VECCORE_ATT_HOST_DEVICE
0076 Precision ComputeSafetyToDaughtersForLocalPoint(Vector3D<Precision> const &localpoint,
0077 LogicalVolume const *lvol) const final
0078 {
0079 return BVHManager::GetBVH(lvol)->ComputeSafety<BVHSafetyEstimator>(localpoint, kInfLength);
0080 }
0081 };
0082
0083 }
0084 }
0085
0086 #endif