803{
808
809
810
812
813 fChangedGrandMotherRefFrame= false;
814
816 fCalculatedExitNormal = false;
817
818
820 sNavCScalls++;
821
822 fLastTriedStepComputation= true;
823
824#ifdef G4VERBOSE
826 {
827 G4cout <<
"*** G4ITNavigator1::ComputeStep: ***" <<
G4endl;
829 << " - Proposed step length = " << pCurrentProposedStepLength
831#ifdef G4DEBUG_NAVIGATION
833 {
835 <<
" Globalpoint = " << std::setw(25) << pGlobalpoint <<
G4endl
836 <<
" Direction = " << std::setw(25) << pDirection <<
G4endl;
838 {
841 }
842 }
843#endif
844 }
845#endif
846
848 if( newLocalPoint != fLastLocatedPointLocal )
849 {
850
851
853 G4double moveLenSq = (newLocalPoint-oldLocalPoint).mag2();
854
856 {
857#ifdef G4VERBOSE
858 ComputeStepLog(pGlobalpoint, moveLenSq);
859#endif
860
861
863 fLastTriedStepComputation= true;
864 }
865 }
867 {
869 {
872 {
873 Step = fvoxelNav.
ComputeStep(fLastLocatedPointLocal,
874 localDirection,
875 pCurrentProposedStepLength,
876 pNewSafety,
878 fValidExitNormal,
879 fExitNormal,
880 fExiting,
881 fEntering,
882 &fBlockedPhysicalVolume,
883 fBlockedReplicaNo);
884
885 }
886 else
887 {
889 {
890 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
891 localDirection,
892 pCurrentProposedStepLength,
893 pNewSafety,
895 fValidExitNormal,
896 fExitNormal,
897 fExiting,
898 fEntering,
899 &fBlockedPhysicalVolume,
900 fBlockedReplicaNo);
901 }
902 else
903 {
905 fLastTriedStepComputation= true;
906
907
908
909
910
911
912
913
914
915
917 {
920 "Point is relocated in voxels, while it should be outside!");
921 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
922 localDirection,
923 pCurrentProposedStepLength,
924 pNewSafety,
926 fValidExitNormal,
927 fExitNormal,
928 fExiting,
929 fEntering,
930 &fBlockedPhysicalVolume,
931 fBlockedReplicaNo);
932 }
933 else
934 {
935 Step = fregularNav.
936 ComputeStepSkippingEqualMaterials(fLastLocatedPointLocal,
937 localDirection,
938 pCurrentProposedStepLength,
939 pNewSafety,
941 fValidExitNormal,
942 fExitNormal,
943 fExiting,
944 fEntering,
945 &fBlockedPhysicalVolume,
946 fBlockedReplicaNo,
947 motherPhysical);
948 }
949 }
950 }
951 break;
954 {
955 Step = fparamNav.
ComputeStep(fLastLocatedPointLocal,
956 localDirection,
957 pCurrentProposedStepLength,
958 pNewSafety,
960 fValidExitNormal,
961 fExitNormal,
962 fExiting,
963 fEntering,
964 &fBlockedPhysicalVolume,
965 fBlockedReplicaNo);
966 }
967 else
968 {
969 Step = fregularNav.
ComputeStep(fLastLocatedPointLocal,
970 localDirection,
971 pCurrentProposedStepLength,
972 pNewSafety,
974 fValidExitNormal,
975 fExitNormal,
976 fExiting,
977 fEntering,
978 &fBlockedPhysicalVolume,
979 fBlockedReplicaNo);
980 }
981 break;
983 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav0001",
985 break;
987 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav0001",
989 break;
990 }
991 }
992 else
993 {
994
995
996
998 G4bool calculatedExitNormal=
false;
999
1001 pDirection,
1002 fLastLocatedPointLocal,
1003 localDirection,
1004 pCurrentProposedStepLength,
1005 pNewSafety,
1007 fValidExitNormal,
1008 calculatedExitNormal,
1009 fExitNormal,
1010 exitingReplica,
1011 fEntering,
1012 &fBlockedPhysicalVolume,
1013 fBlockedReplicaNo);
1014 fExiting= exitingReplica;
1015 fCalculatedExitNormal= calculatedExitNormal;
1016 }
1017
1018
1019
1020 fPreviousSftOrigin = pGlobalpoint;
1021 fPreviousSafety = pNewSafety;
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033 fLocatedOnEdge = fLastStepWasZero && (Step==0.0);
1034 fLastStepWasZero = (Step==0.0);
1036
1037
1038
1039 if ( fLastStepWasZero )
1040 {
1041 fNumberZeroSteps++;
1042#ifdef G4DEBUG_NAVIGATION
1043 if( fNumberZeroSteps > 1 )
1044 {
1045 G4cout <<
"G4ITNavigator1::ComputeStep(): another zero step, # "
1046 << fNumberZeroSteps
1047 << " at " << pGlobalpoint
1048 <<
" in volume " << motherPhysical->
GetName()
1049 << " nav-comp-step calls # " << sNavCScalls
1051 }
1052#endif
1053 if( fNumberZeroSteps > fActionThreshold_NoZeroSteps-1 )
1054 {
1055
1056
1058#ifdef G4VERBOSE
1059 if ((!fPushed) && (fWarnPush))
1060 {
1061 std::ostringstream message;
1062 message <<
"Track stuck or not moving." <<
G4endl
1063 << " Track stuck, not moving for "
1064 << fNumberZeroSteps <<
" steps" <<
G4endl
1065 <<
" in volume -" << motherPhysical->
GetName()
1066 <<
"- at point " << pGlobalpoint <<
G4endl
1067 <<
" direction: " << pDirection <<
"." <<
G4endl
1068 << " Potential geometry or navigation problem !"
1070 << " Trying pushing it of " << Step << " mm ...";
1071 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav1002",
1072 JustWarning, message,
"Potential overlap in geometry!");
1073 }
1074#endif
1075 fPushed = true;
1076 }
1077 if( fNumberZeroSteps > fAbandonThreshold_NoZeroSteps-1 )
1078 {
1079
1080
1081 std::ostringstream message;
1082 message << "Stuck Track: potential geometry or navigation problem."
1084 << " Track stuck, not moving for "
1085 << fNumberZeroSteps <<
" steps" <<
G4endl
1086 <<
" in volume -" << motherPhysical->
GetName()
1087 <<
"- at point " << pGlobalpoint <<
G4endl
1088 << " direction: " << pDirection << ".";
1090 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav0003",
1092 }
1093 }
1094 else
1095 {
1096 if (!fPushed) fNumberZeroSteps = 0;
1097 }
1098
1101
1104
1105 if( fExiting )
1106 {
1107#ifdef G4DEBUG_NAVIGATION
1109 {
1110 G4cout <<
" At G4Nav CompStep End - if(exiting) - fExiting= " << fExiting
1111 <<
" fValidExitNormal = " << fValidExitNormal <<
G4endl;
1113 }
1114#endif
1115
1116 if(fValidExitNormal || fCalculatedExitNormal)
1117 {
1119 {
1120
1121
1122 fGrandMotherExitNormal= fExitNormal;
1123 fCalculatedExitNormal= true;
1124 }
1125 else
1126 {
1127 fGrandMotherExitNormal = fExitNormal;
1128 }
1129 }
1130 else
1131 {
1132
1133
1135 fLastLocatedPointLocal + localDirection*Step;
1136
1138 {
1139
1140
1143
1144
1145
1147 if( mRot != nullptr )
1148 {
1149 fChangedGrandMotherRefFrame= true;
1150 fGrandMotherExitNormal = (*mRot).inverse() * exitNormalMotherFrame;
1151 }
1152 else
1153 {
1154 fGrandMotherExitNormal = exitNormalMotherFrame;
1155 }
1156
1157
1158
1159
1160 fCalculatedExitNormal= true;
1161 }
1162 else
1163 {
1164 fCalculatedExitNormal = false;
1165
1166
1167
1168
1169
1170
1171#ifdef G4DEBUG_NAVIGATION
1173
1174 desc << "Problem in ComputeStep: Replica Navigation did not provide"
1175 <<
" valid exit Normal. " <<
G4endl;
1176 desc <<
" Do not know how calculate it in this case." <<
G4endl;
1177 desc <<
" Location = " << finalLocalPoint <<
G4endl;
1178 desc <<
" Volume name = " << motherPhysical->
GetName()
1180 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav0003",
1181 JustWarning, desc,
"Normal not available for exiting.");
1182#endif
1183 }
1184 }
1185
1186
1187
1188 if( fValidExitNormal || fCalculatedExitNormal )
1189 {
1191 if( depth > 0 )
1192 {
1195 fExitNormalGlobalFrame =
1196 GrandMotherToGlobalTransf.
TransformAxis( fGrandMotherExitNormal );
1197 }
1198 else
1199 {
1200 fExitNormalGlobalFrame= fGrandMotherExitNormal;
1201 }
1202 }
1203 else
1204 {
1206 }
1207 }
1209
1210 if( (Step == pCurrentProposedStepLength) && (!fExiting) && (!fEntering) )
1211 {
1212
1213
1214
1215 Step = kInfinity;
1216 }
1217
1218#ifdef G4VERBOSE
1220 {
1222 {
1225 }
1226 G4cout <<
" Returned step= " << Step;
1228 if( Step == kInfinity )
1229 {
1230 G4cout <<
" Requested step= " << pCurrentProposedStepLength ;
1232 }
1234 }
1235#endif
1236
1237 return Step;
1238}
std::ostringstream G4ExceptionDescription
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=nullptr, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
G4ThreeVector ComputeLocalAxis(const G4ThreeVector &pVec) const
G4VSolid * GetSolid() const
std::size_t GetDepth() const
const G4AffineTransform & GetTransform(G4int n) 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)
const G4RotationMatrix * GetRotation() const
virtual G4bool CheckOverlaps(G4int res=1000, G4double tol=0., G4bool verbose=true, G4int errMax=1)
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