703{
708
709
710
712
713 fChangedGrandMotherRefFrame= false;
714
716 fCalculatedExitNormal = false;
717
718
719 static G4int sNavCScalls=0;
720 sNavCScalls++;
721
722 fLastTriedStepComputation= true;
723
724#ifdef G4VERBOSE
726 {
727 G4cout <<
"*** G4Navigator::ComputeStep: ***" <<
G4endl;
729 << " - Proposed step length = " << pCurrentProposedStepLength
731#ifdef G4DEBUG_NAVIGATION
733 {
735 <<
" Globalpoint = " << std::setw(25) << pGlobalpoint <<
G4endl
736 <<
" Direction = " << std::setw(25) << pDirection <<
G4endl;
738 {
741 }
742 }
743#endif
744 }
745#endif
746
748 if( newLocalPoint != fLastLocatedPointLocal )
749 {
750
751
753 G4double moveLenSq = (newLocalPoint-oldLocalPoint).mag2();
754
756 {
757#ifdef G4VERBOSE
758 ComputeStepLog(pGlobalpoint, moveLenSq);
759#endif
760
761
763 fLastTriedStepComputation= true;
764 }
765 }
767 {
769 {
772 {
773 Step = fvoxelNav.
ComputeStep(fLastLocatedPointLocal,
774 localDirection,
775 pCurrentProposedStepLength,
776 pNewSafety,
778 fValidExitNormal,
779 fExitNormal,
780 fExiting,
781 fEntering,
782 &fBlockedPhysicalVolume,
783 fBlockedReplicaNo);
784
785 }
786 else
787 {
789 {
790 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
791 localDirection,
792 pCurrentProposedStepLength,
793 pNewSafety,
795 fValidExitNormal,
796 fExitNormal,
797 fExiting,
798 fEntering,
799 &fBlockedPhysicalVolume,
800 fBlockedReplicaNo);
801 }
802 else
803 {
805 fLastTriedStepComputation= true;
806
807
808
809
810
811
812
813
814
815
817 {
820 "Point is relocated in voxels, while it should be outside!");
821 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
822 localDirection,
823 pCurrentProposedStepLength,
824 pNewSafety,
826 fValidExitNormal,
827 fExitNormal,
828 fExiting,
829 fEntering,
830 &fBlockedPhysicalVolume,
831 fBlockedReplicaNo);
832 }
833 else
834 {
835 Step = fregularNav.
836 ComputeStepSkippingEqualMaterials(fLastLocatedPointLocal,
837 localDirection,
838 pCurrentProposedStepLength,
839 pNewSafety,
841 fValidExitNormal,
842 fExitNormal,
843 fExiting,
844 fEntering,
845 &fBlockedPhysicalVolume,
846 fBlockedReplicaNo,
847 motherPhysical);
848 }
849 }
850 }
851 break;
854 {
855 Step = fparamNav.
ComputeStep(fLastLocatedPointLocal,
856 localDirection,
857 pCurrentProposedStepLength,
858 pNewSafety,
860 fValidExitNormal,
861 fExitNormal,
862 fExiting,
863 fEntering,
864 &fBlockedPhysicalVolume,
865 fBlockedReplicaNo);
866 }
867 else
868 {
869 Step = fregularNav.
ComputeStep(fLastLocatedPointLocal,
870 localDirection,
871 pCurrentProposedStepLength,
872 pNewSafety,
874 fValidExitNormal,
875 fExitNormal,
876 fExiting,
877 fEntering,
878 &fBlockedPhysicalVolume,
879 fBlockedReplicaNo);
880 }
881 break;
883 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0001",
885 break;
886 }
887 }
888 else
889 {
890
891
892
894 G4bool calculatedExitNormal;
896 pDirection,
897 fLastLocatedPointLocal,
898 localDirection,
899 pCurrentProposedStepLength,
900 pNewSafety,
902 fValidExitNormal,
903 calculatedExitNormal,
904 fExitNormal,
905 exitingReplica,
906 fEntering,
907 &fBlockedPhysicalVolume,
908 fBlockedReplicaNo);
909 fExiting= exitingReplica;
910 fCalculatedExitNormal= calculatedExitNormal;
911 }
912
913
914
915 fPreviousSftOrigin = pGlobalpoint;
916 fPreviousSafety = pNewSafety;
917
918
919
920
921
922
923
924
925
926
927
928 fLocatedOnEdge = fLastStepWasZero && (Step==0.0);
929 fLastStepWasZero = (Step==0.0);
930 if (fPushed) { fPushed = fLastStepWasZero; }
931
932
933
934 if ( fLastStepWasZero )
935 {
936 fNumberZeroSteps++;
937#ifdef G4DEBUG_NAVIGATION
938 if( fNumberZeroSteps > 1 )
939 {
940 G4cout <<
"G4Navigator::ComputeStep(): another zero step, # "
941 << fNumberZeroSteps
942 << " at " << pGlobalpoint
943 <<
" in volume " << motherPhysical->
GetName()
944 << " nav-comp-step calls # " << sNavCScalls
946 }
947#endif
948 if( fNumberZeroSteps > fActionThreshold_NoZeroSteps-1 )
949 {
950
951
953#ifdef G4VERBOSE
954 if ((!fPushed) && (fWarnPush))
955 {
956 std::ostringstream message;
957 message <<
"Track stuck or not moving." <<
G4endl
958 << " Track stuck, not moving for "
959 << fNumberZeroSteps <<
" steps" <<
G4endl
960 <<
" in volume -" << motherPhysical->
GetName()
961 <<
"- at point " << pGlobalpoint <<
G4endl
962 <<
" direction: " << pDirection <<
"." <<
G4endl
963 << " Potential geometry or navigation problem !"
965 << " Trying pushing it of " << Step << " mm ...";
966 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav1002",
967 JustWarning, message,
"Potential overlap in geometry!");
968 }
969#endif
970 fPushed = true;
971 }
972 if( fNumberZeroSteps > fAbandonThreshold_NoZeroSteps-1 )
973 {
974
975
976 std::ostringstream message;
977 message << "Stuck Track: potential geometry or navigation problem."
979 << " Track stuck, not moving for "
980 << fNumberZeroSteps <<
" steps" <<
G4endl
981 <<
" in volume -" << motherPhysical->
GetName()
982 <<
"- at point " << pGlobalpoint <<
G4endl
983 << " direction: " << pDirection << ".";
985 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0003",
987 }
988 }
989 else
990 {
991 if (!fPushed) fNumberZeroSteps = 0;
992 }
993
996
999
1000 if( fExiting )
1001 {
1002#ifdef G4DEBUG_NAVIGATION
1004 {
1005 G4cout <<
" At G4Nav CompStep End - if(exiting) - fExiting= " << fExiting
1006 <<
" fValidExitNormal = " << fValidExitNormal <<
G4endl;
1008 }
1009#endif
1010
1011 if(fValidExitNormal || fCalculatedExitNormal)
1012 {
1014 {
1015
1016
1017 fGrandMotherExitNormal= fExitNormal;
1018 fCalculatedExitNormal= true;
1019 }
1020 else
1021 {
1022 fGrandMotherExitNormal = fExitNormal;
1023 }
1024 }
1025 else
1026 {
1027
1028
1030 fLastLocatedPointLocal + localDirection*Step;
1031
1033 {
1034
1035
1038
1039
1040
1042 if( mRot )
1043 {
1044 fChangedGrandMotherRefFrame= true;
1045 fGrandMotherExitNormal = (*mRot).inverse() * exitNormalMotherFrame;
1046 }
1047 else
1048 {
1049 fGrandMotherExitNormal = exitNormalMotherFrame;
1050 }
1051
1052
1053
1054
1055 fCalculatedExitNormal= true;
1056 }
1057 else
1058 {
1059 fCalculatedExitNormal = false;
1060
1061
1062
1063
1064
1065
1066#ifdef G4DEBUG_NAVIGATION
1068
1069 desc << "Problem in ComputeStep: Replica Navigation did not provide"
1070 <<
" valid exit Normal. " <<
G4endl;
1071 desc <<
" Do not know how calculate it in this case." <<
G4endl;
1072 desc <<
" Location = " << finalLocalPoint <<
G4endl;
1073 desc <<
" Volume name = " << motherPhysical->
GetName()
1075 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0003",
1076 JustWarning, desc,
"Normal not available for exiting.");
1077#endif
1078 }
1079 }
1080
1081
1082
1083 if( fValidExitNormal || fCalculatedExitNormal )
1084 {
1086 if( depth > 0 )
1087 {
1090 fExitNormalGlobalFrame =
1091 GrandMotherToGlobalTransf.
TransformAxis( fGrandMotherExitNormal );
1092 }
1093 else
1094 {
1095 fExitNormalGlobalFrame= fGrandMotherExitNormal;
1096 }
1097 }
1098 else
1099 {
1101 }
1102 }
1104
1105 if( (Step == pCurrentProposedStepLength) && (!fExiting) && (!fEntering) )
1106 {
1107
1108
1109
1110 Step = kInfinity;
1111 }
1112
1113#ifdef G4VERBOSE
1115 {
1117 {
1120 }
1121 G4cout <<
" Returned step= " << Step;
1123 if( Step == kInfinity )
1124 {
1125 G4cout <<
" Requested step= " << pCurrentProposedStepLength ;
1127 }
1129 }
1130#endif
1131
1132 return Step;
1133}
G4VSolid * GetSolid() const
const G4AffineTransform & GetTransform(G4int n) const
G4ThreeVector ComputeLocalAxis(const G4ThreeVector &pVec) const
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=0, 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)
const G4RotationMatrix * GetRotation() const
virtual G4int GetRegularStructureId() const =0
virtual G4bool CheckOverlaps(G4int res=1000, G4double tol=0., G4bool verbose=true)
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)