753{
754#ifdef G4DEBUG_NAVIGATION
756 ++sNavCScalls;
757#endif
758
763
764
765
767
768 fChangedGrandMotherRefFrame = false;
769
771 fCalculatedExitNormal = false;
772
773
774#ifdef G4VERBOSE
776 {
777 G4cout <<
"*** G4Navigator::ComputeStep: ***" <<
G4endl;
779 << " - Proposed step length = " << pCurrentProposedStepLength
781#ifdef G4DEBUG_NAVIGATION
783 {
785 <<
" Globalpoint = " << std::setw(25) << pGlobalpoint <<
G4endl
786 <<
" Direction = " << std::setw(25) << pDirection <<
G4endl;
788 {
791 }
792 }
793#endif
794 }
795#endif
796
798
799 if( newLocalPoint != fLastLocatedPointLocal )
800 {
801
802
804 G4double moveLenSq = (newLocalPoint-oldLocalPoint).mag2();
805
806 if ( moveLenSq >=
fSqTol )
807 {
808#ifdef G4VERBOSE
809 ComputeStepLog(pGlobalpoint, moveLenSq);
810#endif
811
812
814 }
815 }
817 {
819 {
822 {
824 localDirection,
825 pCurrentProposedStepLength,
826 pNewSafety,
828 fValidExitNormal,
829 fExitNormal,
830 fExiting,
831 fEntering,
832 &fBlockedPhysicalVolume,
833 fBlockedReplicaNo);
834
835 }
836 else
837 {
839 {
840 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
841 localDirection,
842 pCurrentProposedStepLength,
843 pNewSafety,
845 fValidExitNormal,
846 fExitNormal,
847 fExiting,
848 fEntering,
849 &fBlockedPhysicalVolume,
850 fBlockedReplicaNo);
851 }
852 else
853 {
855
856
857
858
859
860
861
862
863
864
866 {
869 "Point is relocated in voxels, while it should be outside!");
870 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
871 localDirection,
872 pCurrentProposedStepLength,
873 pNewSafety,
875 fValidExitNormal,
876 fExitNormal,
877 fExiting,
878 fEntering,
879 &fBlockedPhysicalVolume,
880 fBlockedReplicaNo);
881 }
882 else
883 {
884 Step = fregularNav.
885 ComputeStepSkippingEqualMaterials(fLastLocatedPointLocal,
886 localDirection,
887 pCurrentProposedStepLength,
888 pNewSafety,
890 fValidExitNormal,
891 fExitNormal,
892 fExiting,
893 fEntering,
894 &fBlockedPhysicalVolume,
895 fBlockedReplicaNo,
896 motherPhysical);
897 }
898 }
899 }
900 break;
903 {
904 Step = fparamNav.
ComputeStep(fLastLocatedPointLocal,
905 localDirection,
906 pCurrentProposedStepLength,
907 pNewSafety,
909 fValidExitNormal,
910 fExitNormal,
911 fExiting,
912 fEntering,
913 &fBlockedPhysicalVolume,
914 fBlockedReplicaNo);
915 }
916 else
917 {
918 Step = fregularNav.
ComputeStep(fLastLocatedPointLocal,
919 localDirection,
920 pCurrentProposedStepLength,
921 pNewSafety,
923 fValidExitNormal,
924 fExitNormal,
925 fExiting,
926 fEntering,
927 &fBlockedPhysicalVolume,
928 fBlockedReplicaNo);
929 }
930 break;
932 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0001",
934 break;
936 Step = fpExternalNav->
ComputeStep(fLastLocatedPointLocal,
937 localDirection,
938 pCurrentProposedStepLength,
939 pNewSafety,
941 fValidExitNormal,
942 fExitNormal,
943 fExiting,
944 fEntering,
945 &fBlockedPhysicalVolume,
946 fBlockedReplicaNo);
947 break;
948 }
949 }
950 else
951 {
952
953
954
957 pDirection,
958 fLastLocatedPointLocal,
959 localDirection,
960 pCurrentProposedStepLength,
961 pNewSafety,
963 fValidExitNormal,
964 fCalculatedExitNormal,
965 fExitNormal,
966 fExiting,
967 fEntering,
968 &fBlockedPhysicalVolume,
969 fBlockedReplicaNo);
970 }
971
972
973
974 fPreviousSftOrigin = pGlobalpoint;
975 fPreviousSafety = pNewSafety;
976
977
978
979
980
981
982
983
984
985
986
987 fLocatedOnEdge = fLastStepWasZero && (Step==0.0);
990
991
992
993 if ( fLastStepWasZero )
994 {
995 ++fNumberZeroSteps;
996
997 G4bool act = fNumberZeroSteps >= fActionThreshold_NoZeroSteps;
998 G4bool actAndReport =
false;
999 G4bool abandon = fNumberZeroSteps >= fAbandonThreshold_NoZeroSteps;
1001#ifdef G4VERBOSE
1002 actAndReport = act && (!fPushed) && fWarnPush;
1003#endif
1004#ifdef G4DEBUG_NAVIGATION
1005 inform = fNumberZeroSteps > 1;
1006#endif
1007
1008 if ( act || inform )
1009 {
1010 if( act && !abandon )
1011 {
1012
1013
1015 fPushed = true;
1016 }
1017
1018 if( actAndReport || abandon || inform )
1019 {
1020 std::ostringstream message;
1021
1022 message.precision(16);
1023 message << "Stuck Track: potential geometry or navigation problem."
1025 message << " Track stuck, not moving for "
1026 << fNumberZeroSteps <<
" steps." <<
G4endl
1027 <<
" Current phys volume: '" << motherPhysical->
GetName()
1029 <<
" - at position : " << pGlobalpoint <<
G4endl
1030 <<
" in direction: " << pDirection <<
G4endl
1031 <<
" (local position: " << newLocalPoint <<
")" <<
G4endl
1032 <<
" (local direction: " << localDirection <<
")." <<
G4endl
1033 << " Previous phys volume: '"
1034 << ( fLastMotherPhys !=
nullptr ? fLastMotherPhys->
GetName() :
G4String(
"") )
1036 if( actAndReport || abandon )
1037 {
1038 message << " Likely geometry overlap - else navigation problem !"
1040 }
1041 if( abandon )
1042 {
1043
1044#ifdef G4VERBOSE
1046#endif
1047 message << " Track *abandoned* due to excessive number of Zero steps."
1049 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0003",
1051 }
1052 else
1053 {
1054#ifdef G4VERBOSE
1055 if ( actAndReport )
1056 {
1057 message << " *** Trying to get *unstuck* using a push"
1058 << " - expanding step to " << Step << " (mm) ..."
1059 <<
" Potential overlap in geometry !" <<
G4endl;
1060 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav1002",
1062 }
1063#endif
1064#ifdef G4DEBUG_NAVIGATION
1065 else
1066 {
1067 if( fNumberZeroSteps > 1 )
1068 {
1069 message << ", nav-comp-step calls # " << sNavCScalls
1070 <<
", Step= " << Step <<
G4endl;
1072 }
1073 }
1074#endif
1075 }
1076 }
1077 }
1078 }
1079 else
1080 {
1081 if (!fPushed) { fNumberZeroSteps = 0; }
1082 }
1083 fLastMotherPhys = motherPhysical;
1084
1087
1089 + std::min(Step,pCurrentProposedStepLength) * pDirection;
1091
1092 if( fExiting )
1093 {
1094#ifdef G4DEBUG_NAVIGATION
1096 {
1097 G4cout <<
" At G4Nav CompStep End - if(exiting) - fExiting= " << fExiting
1098 <<
" fValidExitNormal = " << fValidExitNormal <<
G4endl;
1100 }
1101#endif
1102
1103 if ( fValidExitNormal || fCalculatedExitNormal )
1104 {
1105
1106 fGrandMotherExitNormal = fExitNormal;
1107 }
1108 else
1109 {
1110
1111
1113 + localDirection*Step;
1114
1116 {
1117
1118
1121
1122
1123
1125 if( mRot != nullptr )
1126 {
1127 fChangedGrandMotherRefFrame = true;
1128 fGrandMotherExitNormal = (*mRot).inverse() * exitNormalMotherFrame;
1129 }
1130 else
1131 {
1132 fGrandMotherExitNormal = exitNormalMotherFrame;
1133 }
1134
1135
1136
1137 }
1138 else
1139 {
1140 fCalculatedExitNormal = false;
1141
1142
1143
1144
1145
1146
1147#ifdef G4DEBUG_NAVIGATION
1149
1150 desc << "Problem in ComputeStep: Replica Navigation did not provide"
1151 <<
" valid exit Normal. " <<
G4endl;
1152 desc <<
" Do not know how calculate it in this case." <<
G4endl;
1153 desc <<
" Location = " << finalLocalPoint <<
G4endl;
1154 desc <<
" Volume name = " << motherPhysical->
GetName()
1156 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0003",
1157 JustWarning, desc,
"Normal not available for exiting.");
1158#endif
1159 }
1160 }
1161
1163 {
1164 fCalculatedExitNormal = true;
1165 }
1166
1167
1168
1169 if( fValidExitNormal || fCalculatedExitNormal )
1170 {
1172 if( depth > 0 )
1173 {
1176 }
1177 else
1178 {
1179 fExitNormalGlobalFrame = fGrandMotherExitNormal;
1180 }
1181 }
1182 else
1183 {
1185 }
1186 }
1187
1188 if( (Step == pCurrentProposedStepLength) && (!fExiting) && (!fEntering) )
1189 {
1190
1191
1192
1193 Step = kInfinity;
1194 }
1195
1196#ifdef G4VERBOSE
1198 {
1200 {
1203 }
1204 G4cout <<
" Returned step= " << Step;
1206 if( Step == kInfinity )
1207 {
1208 G4cout <<
" Requested step= " << pCurrentProposedStepLength ;
1210 }
1212 }
1213#endif
1214
1215 fLastTriedStepComputation = true;
1216
1217 return Step;
1218}
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4VSolid * GetSolid() const
G4SmartVoxelHeader * GetVoxelHeader() const
EVolume GetTopVolumeType() const
std::size_t GetDepth() const
const G4AffineTransform & GetTransform(G4int n) const
virtual void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
G4VoxelNavigation & GetVoxelNavigator()
G4bool CheckOverlapsIterative(G4VPhysicalVolume *vol)
EVolume CharacteriseDaughters(const G4LogicalVolume *pLog) const
G4ThreeVector ComputeLocalPoint(const G4ThreeVector &rGlobPoint) const
G4ThreeVector ComputeLocalAxis(const G4ThreeVector &pVec) const
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=nullptr, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
G4int GetDaughtersRegularStructureId(const G4LogicalVolume *pLv) const
G4double ComputeStep(const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4double currentProposedStepLength, G4double &newSafety, G4NavigationHistory &history, G4bool &validExitNormal, G4ThreeVector &exitNormal, G4bool &exiting, G4bool &entering, G4VPhysicalVolume *(*pBlockedPhysical), G4int &blockedReplicaNo) final
G4double ComputeStep(const G4ThreeVector &globalPoint, const G4ThreeVector &globalDirection, const G4double currentProposedStepLength, G4double &newSafety, G4NavigationHistory &history, G4bool &validExitNormal, G4ThreeVector &exitNormal, G4bool &exiting, G4bool &entering, G4VPhysicalVolume *(*pBlockedPhysical), G4int &blockedReplicaNo) override
G4double ComputeStep(const G4ThreeVector &globalPoint, const G4ThreeVector &globalDirection, const G4double currentProposedStepLength, G4double &newSafety, G4NavigationHistory &history, G4bool &validExitNormal, G4ThreeVector &exitNormal, G4bool &exiting, G4bool &entering, G4VPhysicalVolume *(*pBlockedPhysical), G4int &blockedReplicaNo) final
G4double ComputeStep(const G4ThreeVector &globalPoint, const G4ThreeVector &globalDirection, const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4double currentProposedStepLength, G4double &newSafety, G4NavigationHistory &history, G4bool &validExitNormal, G4bool &calculatedExitNormal, G4ThreeVector &exitNormal, G4bool &exiting, G4bool &entering, G4VPhysicalVolume *(*pBlockedPhysical), G4int &blockedReplicaNo)
virtual G4double ComputeStep(const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4double currentProposedStepLength, G4double &newSafety, G4NavigationHistory &history, G4bool &validExitNormal, G4ThreeVector &exitNormal, G4bool &exiting, G4bool &entering, G4VPhysicalVolume *(*pBlockedPhysical), G4int &blockedReplicaNo)=0
const G4RotationMatrix * GetRotation() const
G4LogicalVolume * GetLogicalVolume() const
virtual G4int GetCopyNo() const =0
virtual G4int GetRegularStructureId() const =0
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0
virtual G4double ComputeStep(const G4ThreeVector &globalPoint, const G4ThreeVector &globalDirection, const G4double currentProposedStepLength, G4double &newSafety, G4NavigationHistory &history, G4bool &validExitNormal, G4ThreeVector &exitNormal, G4bool &exiting, G4bool &entering, G4VPhysicalVolume *(*pBlockedPhysical), G4int &blockedReplicaNo) override