805{
810
811
812
814
815 fChangedGrandMotherRefFrame= false;
816
818 fCalculatedExitNormal = false;
819
820
822 sNavCScalls++;
823
824 fLastTriedStepComputation= true;
825
826#ifdef G4VERBOSE
828 {
829 G4cout <<
"*** G4ITNavigator1::ComputeStep: ***" <<
G4endl;
831 << " - Proposed step length = " << pCurrentProposedStepLength
833#ifdef G4DEBUG_NAVIGATION
835 {
837 <<
" Globalpoint = " << std::setw(25) << pGlobalpoint <<
G4endl
838 <<
" Direction = " << std::setw(25) << pDirection <<
G4endl;
840 {
843 }
844 }
845#endif
846 }
847#endif
848
850 if( newLocalPoint != fLastLocatedPointLocal )
851 {
852
853
855 G4double moveLenSq = (newLocalPoint-oldLocalPoint).mag2();
856
858 {
859#ifdef G4VERBOSE
860 ComputeStepLog(pGlobalpoint, moveLenSq);
861#endif
862
863
865 fLastTriedStepComputation= true;
866 }
867 }
869 {
871 {
874 {
875 Step = fvoxelNav.
ComputeStep(fLastLocatedPointLocal,
876 localDirection,
877 pCurrentProposedStepLength,
878 pNewSafety,
880 fValidExitNormal,
881 fExitNormal,
882 fExiting,
883 fEntering,
884 &fBlockedPhysicalVolume,
885 fBlockedReplicaNo);
886
887 }
888 else
889 {
891 {
892 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
893 localDirection,
894 pCurrentProposedStepLength,
895 pNewSafety,
897 fValidExitNormal,
898 fExitNormal,
899 fExiting,
900 fEntering,
901 &fBlockedPhysicalVolume,
902 fBlockedReplicaNo);
903 }
904 else
905 {
907 fLastTriedStepComputation= true;
908
909
910
911
912
913
914
915
916
917
919 {
922 "Point is relocated in voxels, while it should be outside!");
923 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
924 localDirection,
925 pCurrentProposedStepLength,
926 pNewSafety,
928 fValidExitNormal,
929 fExitNormal,
930 fExiting,
931 fEntering,
932 &fBlockedPhysicalVolume,
933 fBlockedReplicaNo);
934 }
935 else
936 {
937 Step = fregularNav.
938 ComputeStepSkippingEqualMaterials(fLastLocatedPointLocal,
939 localDirection,
940 pCurrentProposedStepLength,
941 pNewSafety,
943 fValidExitNormal,
944 fExitNormal,
945 fExiting,
946 fEntering,
947 &fBlockedPhysicalVolume,
948 fBlockedReplicaNo,
949 motherPhysical);
950 }
951 }
952 }
953 break;
956 {
957 Step = fparamNav.
ComputeStep(fLastLocatedPointLocal,
958 localDirection,
959 pCurrentProposedStepLength,
960 pNewSafety,
962 fValidExitNormal,
963 fExitNormal,
964 fExiting,
965 fEntering,
966 &fBlockedPhysicalVolume,
967 fBlockedReplicaNo);
968 }
969 else
970 {
971 Step = fregularNav.
ComputeStep(fLastLocatedPointLocal,
972 localDirection,
973 pCurrentProposedStepLength,
974 pNewSafety,
976 fValidExitNormal,
977 fExitNormal,
978 fExiting,
979 fEntering,
980 &fBlockedPhysicalVolume,
981 fBlockedReplicaNo);
982 }
983 break;
985 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav0001",
987 break;
989 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav0001",
991 break;
992 }
993 }
994 else
995 {
996
997
998
1000 G4bool calculatedExitNormal=
false;
1001
1003 pDirection,
1004 fLastLocatedPointLocal,
1005 localDirection,
1006 pCurrentProposedStepLength,
1007 pNewSafety,
1009 fValidExitNormal,
1010 calculatedExitNormal,
1011 fExitNormal,
1012 exitingReplica,
1013 fEntering,
1014 &fBlockedPhysicalVolume,
1015 fBlockedReplicaNo);
1016 fExiting= exitingReplica;
1017 fCalculatedExitNormal= calculatedExitNormal;
1018 }
1019
1020
1021
1022 fPreviousSftOrigin = pGlobalpoint;
1023 fPreviousSafety = pNewSafety;
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035 fLocatedOnEdge = fLastStepWasZero && (Step==0.0);
1036 fLastStepWasZero = (Step==0.0);
1038
1039
1040
1041 if ( fLastStepWasZero )
1042 {
1043 fNumberZeroSteps++;
1044#ifdef G4DEBUG_NAVIGATION
1045 if( fNumberZeroSteps > 1 )
1046 {
1047 G4cout <<
"G4ITNavigator1::ComputeStep(): another zero step, # "
1048 << fNumberZeroSteps
1049 << " at " << pGlobalpoint
1050 <<
" in volume " << motherPhysical->
GetName()
1051 << " nav-comp-step calls # " << sNavCScalls
1053 }
1054#endif
1055 if( fNumberZeroSteps > fActionThreshold_NoZeroSteps-1 )
1056 {
1057
1058
1060#ifdef G4VERBOSE
1061 if ((!fPushed) && (fWarnPush))
1062 {
1063 std::ostringstream message;
1064 message <<
"Track stuck or not moving." <<
G4endl
1065 << " Track stuck, not moving for "
1066 << fNumberZeroSteps <<
" steps" <<
G4endl
1067 <<
" in volume -" << motherPhysical->
GetName()
1068 <<
"- at point " << pGlobalpoint <<
G4endl
1069 <<
" direction: " << pDirection <<
"." <<
G4endl
1070 << " Potential geometry or navigation problem !"
1072 << " Trying pushing it of " << Step << " mm ...";
1073 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav1002",
1074 JustWarning, message,
"Potential overlap in geometry!");
1075 }
1076#endif
1077 fPushed = true;
1078 }
1079 if( fNumberZeroSteps > fAbandonThreshold_NoZeroSteps-1 )
1080 {
1081
1082
1083 std::ostringstream message;
1084 message << "Stuck Track: potential geometry or navigation problem."
1086 << " Track stuck, not moving for "
1087 << fNumberZeroSteps <<
" steps" <<
G4endl
1088 <<
" in volume -" << motherPhysical->
GetName()
1089 <<
"- at point " << pGlobalpoint <<
G4endl
1090 << " direction: " << pDirection << ".";
1092 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav0003",
1094 }
1095 }
1096 else
1097 {
1098 if (!fPushed) fNumberZeroSteps = 0;
1099 }
1100
1103
1106
1107 if( fExiting )
1108 {
1109#ifdef G4DEBUG_NAVIGATION
1111 {
1112 G4cout <<
" At G4Nav CompStep End - if(exiting) - fExiting= " << fExiting
1113 <<
" fValidExitNormal = " << fValidExitNormal <<
G4endl;
1115 }
1116#endif
1117
1118 if(fValidExitNormal || fCalculatedExitNormal)
1119 {
1121 {
1122
1123
1124 fGrandMotherExitNormal= fExitNormal;
1125 fCalculatedExitNormal= true;
1126 }
1127 else
1128 {
1129 fGrandMotherExitNormal = fExitNormal;
1130 }
1131 }
1132 else
1133 {
1134
1135
1137 fLastLocatedPointLocal + localDirection*Step;
1138
1140 {
1141
1142
1145
1146
1147
1149 if( mRot )
1150 {
1151 fChangedGrandMotherRefFrame= true;
1152 fGrandMotherExitNormal = (*mRot).inverse() * exitNormalMotherFrame;
1153 }
1154 else
1155 {
1156 fGrandMotherExitNormal = exitNormalMotherFrame;
1157 }
1158
1159
1160
1161
1162 fCalculatedExitNormal= true;
1163 }
1164 else
1165 {
1166 fCalculatedExitNormal = false;
1167
1168
1169
1170
1171
1172
1173#ifdef G4DEBUG_NAVIGATION
1175
1176 desc << "Problem in ComputeStep: Replica Navigation did not provide"
1177 <<
" valid exit Normal. " <<
G4endl;
1178 desc <<
" Do not know how calculate it in this case." <<
G4endl;
1179 desc <<
" Location = " << finalLocalPoint <<
G4endl;
1180 desc <<
" Volume name = " << motherPhysical->
GetName()
1182 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav0003",
1183 JustWarning, desc,
"Normal not available for exiting.");
1184#endif
1185 }
1186 }
1187
1188
1189
1190 if( fValidExitNormal || fCalculatedExitNormal )
1191 {
1193 if( depth > 0 )
1194 {
1197 fExitNormalGlobalFrame =
1198 GrandMotherToGlobalTransf.
TransformAxis( fGrandMotherExitNormal );
1199 }
1200 else
1201 {
1202 fExitNormalGlobalFrame= fGrandMotherExitNormal;
1203 }
1204 }
1205 else
1206 {
1208 }
1209 }
1211
1212 if( (Step == pCurrentProposedStepLength) && (!fExiting) && (!fEntering) )
1213 {
1214
1215
1216
1217 Step = kInfinity;
1218 }
1219
1220#ifdef G4VERBOSE
1222 {
1224 {
1227 }
1228 G4cout <<
" Returned step= " << Step;
1230 if( Step == kInfinity )
1231 {
1232 G4cout <<
" Requested step= " << pCurrentProposedStepLength ;
1234 }
1236 }
1237#endif
1238
1239 return Step;
1240}
std::ostringstream G4ExceptionDescription
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=0, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
G4ThreeVector ComputeLocalAxis(const G4ThreeVector &pVec) const
G4VSolid * GetSolid() 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)
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)
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)