File indexing completed on 2026-09-26 09:15:39
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef NAVIGATION_SIMPLESAFETYESTIMATOR_H_
0009 #define NAVIGATION_SIMPLESAFETYESTIMATOR_H_
0010
0011 #include "VecGeom/navigation/VSafetyEstimator.h"
0012
0013
0014 namespace vecgeom {
0015 inline namespace VECGEOM_IMPL_NAMESPACE {
0016
0017
0018 class SimpleSafetyEstimator : public VSafetyEstimatorHelper<SimpleSafetyEstimator> {
0019
0020 public:
0021 static constexpr const char *gClassNameString = "SimpleSafetyEstimator";
0022
0023
0024
0025 VECCORE_ATT_HOST_DEVICE
0026 virtual Precision ComputeSafetyToDaughtersForLocalPoint(Vector3D<Precision> const &localpoint,
0027 LogicalVolume const *lvol) const override
0028 {
0029
0030 double safety(kInfLength);
0031 auto daughters = lvol->GetDaughtersp();
0032 auto numberdaughters = daughters->size();
0033 for (decltype(numberdaughters) d = 0; d < numberdaughters; ++d) {
0034 VPlacedVolume const *daughter = daughters->operator[](d);
0035 double tmp = daughter->SafetyToIn(localpoint);
0036 safety = Min(safety, tmp);
0037 }
0038 return safety;
0039 }
0040
0041 VECGEOM_FORCE_INLINE
0042 VECCORE_ATT_HOST_DEVICE
0043 virtual Precision ComputeSafetyForLocalPoint(Vector3D<Precision> const &localpoint,
0044 VPlacedVolume const *pvol) const override
0045 {
0046
0047 double safety = pvol->SafetyToOut(localpoint);
0048
0049
0050 auto daughters = pvol->GetLogicalVolume()->GetDaughtersp();
0051 auto numberdaughters = daughters->size();
0052 for (decltype(numberdaughters) d = 0; d < numberdaughters; ++d) {
0053 VPlacedVolume const *daughter = daughters->operator[](d);
0054 double tmp = daughter->SafetyToIn(localpoint);
0055 safety = Min(safety, tmp);
0056 }
0057 return safety;
0058 }
0059
0060 #ifndef VECCORE_CUDA
0061 static VSafetyEstimator *Instance()
0062 {
0063 static SimpleSafetyEstimator instance;
0064 return &instance;
0065 }
0066 #else
0067 VECCORE_ATT_DEVICE
0068 static VSafetyEstimator *Instance();
0069 #endif
0070
0071 };
0072 }
0073 }
0074
0075 #endif