File indexing completed on 2026-06-01 08:41:03
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef NAVIGATION_NEWSIMPLENAVIGATOR_H_
0009 #define NAVIGATION_NEWSIMPLENAVIGATOR_H_
0010
0011 #include "VNavigator.h"
0012 #include "SimpleSafetyEstimator.h"
0013
0014 namespace vecgeom {
0015 inline namespace VECGEOM_IMPL_NAMESPACE {
0016
0017
0018 template <bool MotherIsConvex = false>
0019 class NewSimpleNavigator : public VNavigatorHelper<class NewSimpleNavigator<MotherIsConvex>, MotherIsConvex> {
0020
0021 private:
0022 VECCORE_ATT_DEVICE
0023 NewSimpleNavigator()
0024 : VNavigatorHelper<class NewSimpleNavigator<MotherIsConvex>, MotherIsConvex>(SimpleSafetyEstimator::Instance()) {
0025 } VECCORE_ATT_DEVICE virtual ~NewSimpleNavigator() {}
0026
0027 public:
0028 VECGEOM_FORCE_INLINE
0029 VECCORE_ATT_HOST_DEVICE
0030 virtual bool CheckDaughterIntersections(LogicalVolume const *lvol, Vector3D<Precision> const &localpoint,
0031 Vector3D<Precision> const &localdir, NavigationState const *in_state,
0032 NavigationState * , Precision &step,
0033 VPlacedVolume const *&hitcandidate) const override
0034 {
0035
0036 auto *daughters = lvol->GetDaughtersp();
0037 auto ndaughters = daughters->size();
0038 for (decltype(ndaughters) d = 0; d < ndaughters; ++d) {
0039 auto daughter = daughters->operator[](d);
0040 if (in_state && in_state->GetLastExited() == daughter) continue;
0041 Precision ddistance = daughter->DistanceToIn(localpoint, localdir, step);
0042 ddistance = vecCore::math::Max(ddistance, 0.);
0043 const bool valid = ddistance < step;
0044 hitcandidate = valid ? daughter : hitcandidate;
0045 step = valid ? ddistance : step;
0046 }
0047 return false;
0048 }
0049
0050 VECGEOM_FORCE_INLINE
0051 VECCORE_ATT_HOST_DEVICE
0052 virtual bool CheckDaughterIntersections(LogicalVolume const *lvol, Vector3D<Precision> const &localpoint,
0053 Vector3D<Precision> const &localdir, VPlacedVolume const *blocked,
0054 Precision &step, VPlacedVolume const *&hitcandidate) const override
0055 {
0056
0057 static const double kMinExitingCos = 1.e-3;
0058 VPlacedVolume const *excludedVol = nullptr;
0059 if (blocked) {
0060 Vector3D<Precision> normal;
0061 blocked->Normal(localpoint, normal);
0062 if (normal.Dot(localdir) >= kMinExitingCos) {
0063 excludedVol = blocked;
0064 }
0065 }
0066
0067
0068 auto *daughters = lvol->GetDaughtersp();
0069 auto ndaughters = daughters->size();
0070 for (decltype(ndaughters) d = 0; d < ndaughters; ++d) {
0071 auto daughter = daughters->operator[](d);
0072 if (daughter != excludedVol) {
0073 Precision ddistance = daughter->DistanceToIn(localpoint, localdir, step);
0074 const bool valid = ddistance < step;
0075 hitcandidate = valid ? daughter : hitcandidate;
0076 step = valid ? ddistance : step;
0077 }
0078 }
0079 return false;
0080 }
0081
0082 #ifndef VECCORE_CUDA
0083 static VNavigator *Instance()
0084 {
0085 static NewSimpleNavigator instance;
0086 return &instance;
0087 }
0088 #else
0089 VECCORE_ATT_DEVICE
0090 static VNavigator *Instance();
0091 #endif
0092
0093 static constexpr const char *gClassNameString = "NewSimpleNavigator";
0094 typedef SimpleSafetyEstimator SafetyEstimator_t;
0095 };
0096 }
0097 }
0098
0099 #endif