768{
773
774
775
777
778 fChangedGrandMotherRefFrame = false;
779
781 fCalculatedExitNormal = false;
782
783
785 ++sNavCScalls;
786
787 fLastTriedStepComputation = true;
788
789#ifdef G4VERBOSE
791 {
792 G4cout <<
"*** G4Navigator::ComputeStep: ***" <<
G4endl;
794 << " - Proposed step length = " << pCurrentProposedStepLength
796#ifdef G4DEBUG_NAVIGATION
798 {
800 <<
" Globalpoint = " << std::setw(25) << pGlobalpoint <<
G4endl
801 <<
" Direction = " << std::setw(25) << pDirection <<
G4endl;
803 {
806 }
807 }
808#endif
809 }
810#endif
811
813 if( newLocalPoint != fLastLocatedPointLocal )
814 {
815
816
818 G4double moveLenSq = (newLocalPoint-oldLocalPoint).mag2();
819
820 if ( moveLenSq >=
fSqTol )
821 {
822#ifdef G4VERBOSE
823 ComputeStepLog(pGlobalpoint, moveLenSq);
824#endif
825
826
828 fLastTriedStepComputation = true;
829 }
830 }
832 {
834 {
837 {
838 Step = fvoxelNav.
ComputeStep(fLastLocatedPointLocal,
839 localDirection,
840 pCurrentProposedStepLength,
841 pNewSafety,
843 fValidExitNormal,
844 fExitNormal,
845 fExiting,
846 fEntering,
847 &fBlockedPhysicalVolume,
848 fBlockedReplicaNo);
849
850 }
851 else
852 {
854 {
855 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
856 localDirection,
857 pCurrentProposedStepLength,
858 pNewSafety,
860 fValidExitNormal,
861 fExitNormal,
862 fExiting,
863 fEntering,
864 &fBlockedPhysicalVolume,
865 fBlockedReplicaNo);
866 }
867 else
868 {
870 fLastTriedStepComputation = true;
871
872
873
874
875
876
877
878
879
880
882 {
885 "Point is relocated in voxels, while it should be outside!");
886 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
887 localDirection,
888 pCurrentProposedStepLength,
889 pNewSafety,
891 fValidExitNormal,
892 fExitNormal,
893 fExiting,
894 fEntering,
895 &fBlockedPhysicalVolume,
896 fBlockedReplicaNo);
897 }
898 else
899 {
900 Step = fregularNav.
901 ComputeStepSkippingEqualMaterials(fLastLocatedPointLocal,
902 localDirection,
903 pCurrentProposedStepLength,
904 pNewSafety,
906 fValidExitNormal,
907 fExitNormal,
908 fExiting,
909 fEntering,
910 &fBlockedPhysicalVolume,
911 fBlockedReplicaNo,
912 motherPhysical);
913 }
914 }
915 }
916 break;
919 {
920 Step = fparamNav.
ComputeStep(fLastLocatedPointLocal,
921 localDirection,
922 pCurrentProposedStepLength,
923 pNewSafety,
925 fValidExitNormal,
926 fExitNormal,
927 fExiting,
928 fEntering,
929 &fBlockedPhysicalVolume,
930 fBlockedReplicaNo);
931 }
932 else
933 {
934 Step = fregularNav.
ComputeStep(fLastLocatedPointLocal,
935 localDirection,
936 pCurrentProposedStepLength,
937 pNewSafety,
939 fValidExitNormal,
940 fExitNormal,
941 fExiting,
942 fEntering,
943 &fBlockedPhysicalVolume,
944 fBlockedReplicaNo);
945 }
946 break;
948 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0001",
950 break;
952 Step = fpExternalNav->
ComputeStep(fLastLocatedPointLocal,
953 localDirection,
954 pCurrentProposedStepLength,
955 pNewSafety,
957 fValidExitNormal,
958 fExitNormal,
959 fExiting,
960 fEntering,
961 &fBlockedPhysicalVolume,
962 fBlockedReplicaNo);
963 break;
964 }
965 }
966 else
967 {
968
969
970
972 G4bool calculatedExitNormal;
974 pDirection,
975 fLastLocatedPointLocal,
976 localDirection,
977 pCurrentProposedStepLength,
978 pNewSafety,
980 fValidExitNormal,
981 calculatedExitNormal,
982 fExitNormal,
983 exitingReplica,
984 fEntering,
985 &fBlockedPhysicalVolume,
986 fBlockedReplicaNo);
987 fExiting = exitingReplica;
988 fCalculatedExitNormal = calculatedExitNormal;
989 }
990
991
992
993 fPreviousSftOrigin = pGlobalpoint;
994 fPreviousSafety = pNewSafety;
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006 fLocatedOnEdge = fLastStepWasZero && (Step==0.0);
1007 fLastStepWasZero = (Step<
fMinStep);
1009
1010
1011
1012 if ( fLastStepWasZero )
1013 {
1014 ++fNumberZeroSteps;
1015
1016 G4bool act = fNumberZeroSteps >= fActionThreshold_NoZeroSteps;
1017 G4bool actAndReport =
false;
1018 G4bool abandon = fNumberZeroSteps >= fAbandonThreshold_NoZeroSteps;
1020#ifdef G4VERBOSE
1021 actAndReport = act && (!fPushed) && fWarnPush;
1022#endif
1023#ifdef G4DEBUG_NAVIGATION
1024 inform = fNumberZeroSteps > 1;
1025#endif
1026
1027 if ( act || inform )
1028 {
1029 if( act && !abandon )
1030 {
1031
1032
1034 fPushed = true;
1035 }
1036
1037 if( actAndReport || abandon || inform )
1038 {
1039 std::ostringstream message;
1040
1041 message.precision(16);
1042 message << "Stuck Track: potential geometry or navigation problem."
1044 message << " Track stuck, not moving for "
1045 << fNumberZeroSteps <<
" steps." <<
G4endl
1046 <<
" Current phys volume: '" << motherPhysical->
GetName()
1048 <<
" - at position : " << pGlobalpoint <<
G4endl
1049 <<
" in direction: " << pDirection <<
G4endl
1050 <<
" (local position: " << newLocalPoint <<
")" <<
G4endl
1051 <<
" (local direction: " << localDirection <<
")." <<
G4endl
1052 << " Previous phys volume: '"
1053 << ( fLastMotherPhys ? fLastMotherPhys->
GetName() :
"" )
1055 if( actAndReport || abandon )
1056 {
1057 message << " Likely geometry overlap - else navigation problem !"
1059 }
1060 if( abandon )
1061 {
1062
1063#ifdef G4VERBOSE
1065#endif
1066 message << " Track *abandoned* due to excessive number of Zero steps."
1068 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0003",
1070 }
1071 else
1072 {
1073#ifdef G4VERBOSE
1074 if ( actAndReport )
1075 {
1076 message << " *** Trying to get *unstuck* using a push"
1077 << " - expanding step to " << Step << " (mm) ..."
1078 <<
" Potential overlap in geometry !" <<
G4endl;
1079 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav1002",
1081 }
1082#endif
1083#ifdef G4DEBUG_NAVIGATION
1084 else
1085 {
1086 if( fNumberZeroSteps > 1 )
1087 {
1088 message << ", nav-comp-step calls # " << sNavCScalls
1089 <<
", Step= " << Step <<
G4endl;
1091 }
1092 }
1093#endif
1094 }
1095 }
1096 }
1097 }
1098 else
1099 {
1100 if (!fPushed) { fNumberZeroSteps = 0; }
1101 }
1102 fLastMotherPhys = motherPhysical;
1103
1106
1108 + std::min(Step,pCurrentProposedStepLength) * pDirection;
1110
1111 if( fExiting )
1112 {
1113#ifdef G4DEBUG_NAVIGATION
1115 {
1116 G4cout <<
" At G4Nav CompStep End - if(exiting) - fExiting= " << fExiting
1117 <<
" fValidExitNormal = " << fValidExitNormal <<
G4endl;
1119 }
1120#endif
1121
1122 if ( fValidExitNormal || fCalculatedExitNormal )
1123 {
1125 {
1126
1127
1128 fGrandMotherExitNormal = fExitNormal;
1129 fCalculatedExitNormal = true;
1130 }
1131 else
1132 {
1133 fGrandMotherExitNormal = fExitNormal;
1134 }
1135 }
1136 else
1137 {
1138
1139
1141 + localDirection*Step;
1142
1144 {
1145
1146
1149
1150
1151
1153 if( mRot )
1154 {
1155 fChangedGrandMotherRefFrame = true;
1156 fGrandMotherExitNormal = (*mRot).inverse() * exitNormalMotherFrame;
1157 }
1158 else
1159 {
1160 fGrandMotherExitNormal = exitNormalMotherFrame;
1161 }
1162
1163
1164
1165
1166 fCalculatedExitNormal = true;
1167 }
1168 else
1169 {
1170 fCalculatedExitNormal = false;
1171
1172
1173
1174
1175
1176
1177#ifdef G4DEBUG_NAVIGATION
1179
1180 desc << "Problem in ComputeStep: Replica Navigation did not provide"
1181 <<
" valid exit Normal. " <<
G4endl;
1182 desc <<
" Do not know how calculate it in this case." <<
G4endl;
1183 desc <<
" Location = " << finalLocalPoint <<
G4endl;
1184 desc <<
" Volume name = " << motherPhysical->
GetName()
1186 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0003",
1187 JustWarning, desc,
"Normal not available for exiting.");
1188#endif
1189 }
1190 }
1191
1192
1193
1194 if( fValidExitNormal || fCalculatedExitNormal )
1195 {
1197 if( depth > 0 )
1198 {
1201 }
1202 else
1203 {
1204 fExitNormalGlobalFrame = fGrandMotherExitNormal;
1205 }
1206 }
1207 else
1208 {
1210 }
1211 }
1212
1213 if( (Step == pCurrentProposedStepLength) && (!fExiting) && (!fEntering) )
1214 {
1215
1216
1217
1218 Step = kInfinity;
1219 }
1220
1221#ifdef G4VERBOSE
1223 {
1225 {
1228 }
1229 G4cout <<
" Returned step= " << Step;
1231 if( Step == kInfinity )
1232 {
1233 G4cout <<
" Requested step= " << pCurrentProposedStepLength ;
1235 }
1237 }
1238#endif
1239
1240 return Step;
1241}
std::ostringstream G4ExceptionDescription
G4VSolid * GetSolid() const
const G4AffineTransform & GetTransform(G4int n) const
G4bool CheckOverlapsIterative(G4VPhysicalVolume *vol)
G4ThreeVector ComputeLocalAxis(const G4ThreeVector &pVec) const
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=nullptr, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
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)
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)
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)
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
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)