File indexing completed on 2026-11-28 10:34:59
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 Precision ddistance = daughter->DistanceToIn(localpoint, localdir, step);
0041
0042 if (ddistance <= 0. && in_state && in_state->GetLastExited() == daughter) continue;
0043 ddistance = Max(ddistance, Precision(0.));
0044 const bool valid = ddistance < step;
0045 hitcandidate = valid ? daughter : hitcandidate;
0046 step = valid ? ddistance : step;
0047 }
0048 return false;
0049 }
0050
0051 VECGEOM_FORCE_INLINE
0052 VECCORE_ATT_HOST_DEVICE
0053 virtual bool CheckDaughterIntersections(LogicalVolume const *lvol, Vector3D<Precision> const &localpoint,
0054 Vector3D<Precision> const &localdir, VPlacedVolume const *blocked,
0055 Precision &step, VPlacedVolume const *&hitcandidate) const override
0056 {
0057
0058 static const double kMinExitingCos = 1.e-3;
0059 VPlacedVolume const *excludedVol = nullptr;
0060 if (blocked) {
0061 Vector3D<Precision> normal;
0062 blocked->Normal(localpoint, normal);
0063 if (normal.Dot(localdir) >= kMinExitingCos) {
0064 excludedVol = blocked;
0065 }
0066 }
0067
0068
0069 auto *daughters = lvol->GetDaughtersp();
0070 auto ndaughters = daughters->size();
0071 for (decltype(ndaughters) d = 0; d < ndaughters; ++d) {
0072 auto daughter = daughters->operator[](d);
0073 if (daughter != excludedVol) {
0074 Precision ddistance = daughter->DistanceToIn(localpoint, localdir, step);
0075 const bool valid = ddistance < step;
0076 hitcandidate = valid ? daughter : hitcandidate;
0077 step = valid ? ddistance : step;
0078 }
0079 }
0080 return false;
0081 }
0082
0083 #ifndef VECCORE_CUDA
0084 static VNavigator *Instance()
0085 {
0086 static NewSimpleNavigator instance;
0087 return &instance;
0088 }
0089 #else
0090 VECCORE_ATT_DEVICE
0091 static VNavigator *Instance();
0092 #endif
0093
0094 static constexpr const char *gClassNameString = "NewSimpleNavigator";
0095 typedef SimpleSafetyEstimator SafetyEstimator_t;
0096 };
0097 }
0098 }
0099
0100 #endif