52#define G4DEBUG_NAVIGATION 1
61 fTopPhysical(0), fCheck(false),
fPushed(false), fWarnPush(true)
64 fLastTriedStepComputation=
false;
73 fActionThreshold_NoZeroSteps = 10;
74 fAbandonThreshold_NoZeroSteps = 25;
93 sWasLimitedByGeometry =
false;
96 sLocatedOnEdge =
false;
97 sLastStepWasZero =
false;
98 sEnteredDaughter =
false;
99 sExitedMother =
false;
102 sValidExitNormal =
false;
106 sPreviousSafety = 0.0;
108 sNumberZeroSteps = 0;
110 spBlockedPhysicalVolume = 0;
111 sBlockedReplicaNo = -1;
113 sLastLocatedPointLocal =
G4ThreeVector( kInfinity, -kInfinity, 0.0 );
114 sLocatedOutsideWorld =
false;
124{
delete fpVoxelSafety; }
138 fLastTriedStepComputation=
false;
161 const G4bool relativeSearch,
162 const G4bool ignoreDirection )
164 G4bool notKnownContained=
true, noResult;
171 G4bool considerDirection = (!ignoreDirection) || fLocatedOnEdge;
173 fLastTriedStepComputation=
false;
174 fChangedGrandMotherRefFrame=
false;
176 if( considerDirection && pGlobalDirection != 0 )
178 globalDirection=*pGlobalDirection;
186 G4cout <<
"*** G4ITNavigator1::LocateGlobalPointAndSetup: ***" <<
G4endl;
188 <<
" Globalpoint = " << globalPoint <<
G4endl
189 <<
" RelativeSearch = " << relativeSearch <<
G4endl;
195 G4cout.precision(oldcoutPrec);
199 if ( !relativeSearch )
220 fLastLocatedPointLocal = localPoint;
221 fLocatedOutsideWorld =
true;
245 fBlockedPhysicalVolume);
248 fBlockedPhysicalVolume->
SetCopyNo(fBlockedReplicaNo);
258 fBlockedPhysicalVolume);
260 fBlockedPhysicalVolume);
262 fBlockedPhysicalVolume);
265 fBlockedPhysicalVolume->
SetCopyNo(fBlockedReplicaNo);
273 ComputeMaterial(fBlockedReplicaNo,
274 fBlockedPhysicalVolume,
279 G4Exception(
"G4ITNavigator1::LocateGlobalPointAndSetup()",
281 "Not applicable for external volumes.");
285 fBlockedPhysicalVolume = 0;
287 notKnownContained =
false;
292 fBlockedPhysicalVolume = 0;
308 G4int noLevelsExited=0 ;
310 while (notKnownContained)
316 insideCode = targetSolid->
Inside(localPoint);
320 G4String solidResponse =
"-kInside-";
322 solidResponse =
"-kOutside-";
324 solidResponse =
"-kSurface-";
325 G4cout <<
"*** G4ITNavigator1::LocateGlobalPointAndSetup(): ***" <<
G4endl
326 <<
" Invoked Inside() for solid: " << targetSolid->
GetName()
327 <<
". Solid replied: " << solidResponse <<
G4endl
328 <<
" For local point p: " << localPoint <<
G4endl;
335 fExiting, notKnownContained);
353 if( noLevelsExited > 1 )
360 fGrandMotherExitNormal *= (*mRot).inverse();
361 fChangedGrandMotherRefFrame=
true;
367 fLastLocatedPointLocal = localPoint;
368 fLocatedOutsideWorld =
true;
376 G4bool isExiting = fExiting;
377 if( (!fExiting)&&considerDirection )
382 G4bool directionExiting =
false;
393 directionExiting = normal.
dot(localDirection) > 0.0;
394 isExiting = isExiting || directionExiting;
408 fValidExitNormal =
false;
410 if( noLevelsExited > 1 )
417 fGrandMotherExitNormal *= (*mRot).inverse();
418 fChangedGrandMotherRefFrame=
true;
424 fLastLocatedPointLocal = localPoint;
425 fLocatedOutsideWorld =
true;
432 notKnownContained=
false;
437 notKnownContained=
false;
458 if (!targetPhysical) {
break; }
466 fBlockedPhysicalVolume,
476 fBlockedPhysicalVolume,
486 fBlockedPhysicalVolume,
497 fBlockedPhysicalVolume,
507 fBlockedPhysicalVolume,
516 G4Exception(
"G4ITNavigator1::LocateGlobalPointAndSetup()",
518 "Not applicable for external volumes.");
531 fBlockedPhysicalVolume = 0;
532 fBlockedReplicaNo = -1;
546 fGrandMotherExitNormal *= (*mRot).inverse();
550#ifdef G4DEBUG_NAVIGATION
554 G4cout <<
"*** G4ITNavigator1::LocateGlobalPointAndSetup() ***" <<
G4endl;
562 fLastLocatedPointLocal = localPoint;
569 if (targetPhysical) { curPhysVol_Name = targetPhysical->
GetName(); }
570 G4cout <<
" Return value = new volume = " << curPhysVol_Name <<
G4endl;
575 G4cout <<
"Upon exiting LocateGlobalPointAndSetup():" <<
G4endl;
578 G4cout.precision(oldcoutPrec);
582 fLocatedOutsideWorld=
false;
584 return targetPhysical;
604 fLastTriedStepComputation=
false;
605 fChangedGrandMotherRefFrame=
false;
607#ifdef G4DEBUG_NAVIGATION
610 G4cout <<
"Entering LocateGlobalWithinVolume(): History = " <<
G4endl;
632 fvoxelNav.
VoxelLocate( pVoxelHeader, fLastLocatedPointLocal );
644 G4Exception(
"G4ITNavigator1::LocateGlobalPointWithinVolume()",
646 "Not applicable for replicated volumes.");
649 G4Exception(
"G4ITNavigator1::LocateGlobalPointWithinVolume()",
651 "Not applicable for external volumes.");
661 fBlockedPhysicalVolume = 0;
662 fBlockedReplicaNo = -1;
678 fpSaveState = (G4SaveNavigatorState*) navState;
684 fpSaveState =
new G4SaveNavigatorState();
709 fpSaveState->sExitNormal = fExitNormal;
710 fpSaveState->sValidExitNormal = fValidExitNormal;
711 fpSaveState->sExiting = fExiting;
712 fpSaveState->sEntering = fEntering;
714 fpSaveState->spBlockedPhysicalVolume = fBlockedPhysicalVolume;
715 fpSaveState->sBlockedReplicaNo = fBlockedReplicaNo,
717 fpSaveState->sLastStepWasZero = fLastStepWasZero;
720 fpSaveState->sPreviousSftOrigin = fPreviousSftOrigin;
721 fpSaveState->sPreviousSafety = fPreviousSafety;
722 fpSaveState->sNumberZeroSteps = fNumberZeroSteps;
723 fpSaveState->sLocatedOnEdge = fLocatedOnEdge;
725 fpSaveState->sPushed=fPushed;
726 fpSaveState->sNumberZeroSteps=fNumberZeroSteps;
730 fpSaveState->sLastLocatedPointLocal = fLastLocatedPointLocal;
731 fpSaveState->sLocatedOutsideWorld = fLocatedOutsideWorld;
743 fExitNormal = fpSaveState->sExitNormal;
744 fValidExitNormal = fpSaveState->sValidExitNormal;
745 fExiting = fpSaveState->sExiting;
746 fEntering = fpSaveState->sEntering;
748 fBlockedPhysicalVolume = fpSaveState->spBlockedPhysicalVolume;
749 fBlockedReplicaNo = fpSaveState->sBlockedReplicaNo,
751 fLastStepWasZero = fpSaveState->sLastStepWasZero;
754 fPreviousSftOrigin = fpSaveState->sPreviousSftOrigin ;
755 fPreviousSafety = fpSaveState->sPreviousSafety ;
756 fNumberZeroSteps = fpSaveState->sNumberZeroSteps ;
757 fLocatedOnEdge = fpSaveState->sLocatedOnEdge ;
759 fPushed = fpSaveState->sPushed;
760 fNumberZeroSteps = fpSaveState->sNumberZeroSteps;
764 fLastLocatedPointLocal = fpSaveState->sLastLocatedPointLocal ;
765 fLocatedOutsideWorld = fpSaveState->sLocatedOutsideWorld;
803 const G4double pCurrentProposedStepLength,
815 fChangedGrandMotherRefFrame=
false;
818 fCalculatedExitNormal =
false;
824 fLastTriedStepComputation=
true;
829 G4cout <<
"*** G4ITNavigator1::ComputeStep: ***" <<
G4endl;
831 <<
" - Proposed step length = " << pCurrentProposedStepLength
833#ifdef G4DEBUG_NAVIGATION
837 <<
" Globalpoint = " << std::setw(25) << pGlobalpoint <<
G4endl
838 <<
" Direction = " << std::setw(25) << pDirection <<
G4endl;
850 if( newLocalPoint != fLastLocatedPointLocal )
855 G4double moveLenSq = (newLocalPoint-oldLocalPoint).mag2();
860 ComputeStepLog(pGlobalpoint, moveLenSq);
865 fLastTriedStepComputation=
true;
875 Step = fvoxelNav.
ComputeStep(fLastLocatedPointLocal,
877 pCurrentProposedStepLength,
884 &fBlockedPhysicalVolume,
892 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
894 pCurrentProposedStepLength,
901 &fBlockedPhysicalVolume,
907 fLastTriedStepComputation=
true;
922 "Point is relocated in voxels, while it should be outside!");
923 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
925 pCurrentProposedStepLength,
932 &fBlockedPhysicalVolume,
938 ComputeStepSkippingEqualMaterials(fLastLocatedPointLocal,
940 pCurrentProposedStepLength,
947 &fBlockedPhysicalVolume,
957 Step = fparamNav.
ComputeStep(fLastLocatedPointLocal,
959 pCurrentProposedStepLength,
966 &fBlockedPhysicalVolume,
971 Step = fregularNav.
ComputeStep(fLastLocatedPointLocal,
973 pCurrentProposedStepLength,
980 &fBlockedPhysicalVolume,
985 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav0001",
989 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav0001",
1000 G4bool calculatedExitNormal=
false;
1004 fLastLocatedPointLocal,
1006 pCurrentProposedStepLength,
1010 calculatedExitNormal,
1014 &fBlockedPhysicalVolume,
1016 fExiting= exitingReplica;
1017 fCalculatedExitNormal= calculatedExitNormal;
1022 fPreviousSftOrigin = pGlobalpoint;
1023 fPreviousSafety = pNewSafety;
1035 fLocatedOnEdge = fLastStepWasZero && (Step==0.0);
1036 fLastStepWasZero = (Step==0.0);
1044#ifdef G4DEBUG_NAVIGATION
1045 if( fNumberZeroSteps > 1 )
1047 G4cout <<
"G4ITNavigator1::ComputeStep(): another zero step, # "
1049 <<
" at " << pGlobalpoint
1050 <<
" in volume " << motherPhysical->
GetName()
1051 <<
" nav-comp-step calls # " << sNavCScalls
1055 if( fNumberZeroSteps > fActionThreshold_NoZeroSteps-1 )
1061 if ((!fPushed) && (fWarnPush))
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!");
1079 if( fNumberZeroSteps > fAbandonThreshold_NoZeroSteps-1 )
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",
1098 if (!fPushed) fNumberZeroSteps = 0;
1109#ifdef G4DEBUG_NAVIGATION
1112 G4cout <<
" At G4Nav CompStep End - if(exiting) - fExiting= " << fExiting
1113 <<
" fValidExitNormal = " << fValidExitNormal <<
G4endl;
1118 if(fValidExitNormal || fCalculatedExitNormal)
1124 fGrandMotherExitNormal= fExitNormal;
1125 fCalculatedExitNormal=
true;
1129 fGrandMotherExitNormal = fExitNormal;
1137 fLastLocatedPointLocal + localDirection*Step;
1151 fChangedGrandMotherRefFrame=
true;
1152 fGrandMotherExitNormal = (*mRot).inverse() * exitNormalMotherFrame;
1156 fGrandMotherExitNormal = exitNormalMotherFrame;
1162 fCalculatedExitNormal=
true;
1166 fCalculatedExitNormal =
false;
1173#ifdef G4DEBUG_NAVIGATION
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.");
1190 if( fValidExitNormal || fCalculatedExitNormal )
1197 fExitNormalGlobalFrame =
1198 GrandMotherToGlobalTransf.
TransformAxis( fGrandMotherExitNormal );
1202 fExitNormalGlobalFrame= fGrandMotherExitNormal;
1212 if( (Step == pCurrentProposedStepLength) && (!fExiting) && (!fEntering) )
1228 G4cout <<
" Returned step= " << Step;
1230 if( Step == kInfinity )
1232 G4cout <<
" Requested step= " << pCurrentProposedStepLength ;
1250 const G4double pCurrentProposedStepLength,
1261 pCurrentProposedStepLength,
1282 fLocatedOnEdge =
false;
1283 fLastStepWasZero =
false;
1288 fValidExitNormal =
false;
1289 fChangedGrandMotherRefFrame=
false;
1290 fCalculatedExitNormal =
false;
1297 fPreviousSafety = 0.0;
1299 fNumberZeroSteps = 0;
1301 fBlockedPhysicalVolume = 0;
1302 fBlockedReplicaNo = -1;
1304 fLastLocatedPointLocal =
G4ThreeVector( kInfinity, -kInfinity, 0.0 );
1305 fLocatedOutsideWorld =
false;
1324 for ( i=1; i<=cdepth; i++ )
1353 ComputeMaterial(replicaNo, current, &touchable) );
1359 "Not applicable for external volumes.");
1377 if ( fLastTriedStepComputation )
1383 if( fEntering && (fBlockedPhysicalVolume!=0) )
1386 if( candidateLogical )
1408 currentSolid= candidateLogical->
GetSolid();
1409 inSideIt = currentSolid->
Inside(daughterPointOwnLocal);
1410 onSurface = (inSideIt ==
kSurface);
1415 safety = (currentSolid->
DistanceToIn(daughterPointOwnLocal));
1418 else if (inSideIt ==
kInside )
1420 safety = (currentSolid->
DistanceToOut(daughterPointOwnLocal));
1427 nextSolidExitNormal =
1432 ExitNormal = -nextSolidExitNormal;
1433 fCalculatedExitNormal=
true;
1438 if((
fVerbose == 1 ) && ( fCheck ))
1440 std::ostringstream message;
1441 message <<
"Point not on surface ! " <<
G4endl
1443 << daughterPointOwnLocal <<
G4endl
1444 <<
" Physical volume = "
1446 <<
" Logical volume = "
1448 <<
" Solid = " << currentSolid->
GetName()
1451 << *currentSolid <<
G4endl;
1454 message <<
"Point is Outside. " <<
G4endl
1455 <<
" Safety (from outside) = " << safety <<
G4endl;
1459 message <<
"Point is Inside. " <<
G4endl
1460 <<
" Safety (from inside) = " << safety <<
G4endl;
1462 G4Exception(
"G4ITNavigator1::GetLocalExitNormal()",
"GeomNav1001",
1471 else if ( fExiting )
1473 ExitNormal = fGrandMotherExitNormal;
1475 fCalculatedExitNormal=
true;
1480 G4Exception(
"G4ITNavigator1::GetLocalExitNormal()",
1482 "Incorrect call to GetLocalSurfaceNormal." );
1491 ExitNormal= -(daughterSolid->
SurfaceNormal(fLastLocatedPointLocal));
1492 if( std::fabs(ExitNormal.
mag2()-1.0 ) > CLHEP::perMillion )
1495 desc <<
" Parameters of solid: " << *daughterSolid
1496 <<
" Point for surface = " << fLastLocatedPointLocal << std::endl;
1497 G4Exception(
"G4ITNavigator1::GetLocalExitNormal()",
1499 "Surface Normal returned by Solid is not a Unit Vector." );
1501 fCalculatedExitNormal=
true;
1508 ExitNormal = fGrandMotherExitNormal;
1510 fCalculatedExitNormal=
true;
1515 fCalculatedExitNormal=
false;
1517 message <<
"Function called when *NOT* at a Boundary." <<
G4endl;
1518 G4Exception(
"G4ITNavigator1::GetLocalExitNormal()",
1534 G4int enteringReplicaNo,
1537 switch (enteringVolumeType)
1542 G4Exception(
"G4ITNavigator1::GetMotherToDaughterTransform()",
1544 "Method NOT Implemented yet for replica volumes.");
1552 pParam->
ComputeSolid(enteringReplicaNo, pEnteringPhysVol);
1566 G4Exception(
"G4ITNavigator1::GetMotherToDaughterTransform()",
1568 "Not applicable for external volumes.");
1592#ifdef G4DEBUG_NAVIGATION
1595 if ( fLastTriedStepComputation )
1600 ExpectedBoundaryPointLocal =
1620 G4bool* pNormalCalculated)
1625 if( fLastTriedStepComputation && fExiting )
1629 globalNormal = fExitNormalGlobalFrame;
1630 *pNormalCalculated =
true;
1636 *pNormalCalculated = fCalculatedExitNormal;
1638#ifdef G4DEBUG_NAVIGATION
1639 if( (!validNormal) && !fCalculatedExitNormal)
1642 edN <<
" Calculated = " << fCalculatedExitNormal <<
G4endl;
1643 edN <<
" Entering= " << fEntering <<
G4endl;
1646 edN <<
" State of Navigator: " <<
G4endl;
1650 G4Exception(
"G4ITNavigator1::GetGlobalExitNormal()",
1652 "LocalExitNormalAndCheck() did not calculate Normal.");
1657 if( validNormal && (std::fabs(localMag2-1.0)) > CLHEP::perMillion )
1661 edN <<
"G4ITNavigator1::GetGlobalExitNormal: "
1662 <<
" Using Local Normal - from call to GetLocalExitNormalAndCheck. "
1664 <<
" Local Exit Normal = " << localNormal <<
" || = "
1665 << std::sqrt(localMag2) <<
G4endl
1666 <<
" Global Exit Normal = " << globalNormal <<
" || = "
1668 edN <<
" Calculated It = " << fCalculatedExitNormal <<
G4endl;
1670 G4Exception(
"G4ITNavigator1::GetGlobalExitNormal()",
1672 "Value obtained from new local *solid* is incorrect.");
1673 localNormal = localNormal.
unit();
1679#ifdef G4DEBUG_NAVIGATION
1681 if( fLastTriedStepComputation && fExiting)
1684 *pNormalCalculated = fCalculatedExitNormal;
1690 G4ThreeVector diffNorm = globalNormal - fExitNormalGlobalFrame;
1691 if( diffNorm.
mag2() > perMillion*CLHEP::perMillion)
1694 edDfn <<
"Found difference in normals in case of exiting mother "
1695 <<
"- when Get is called after ComputingStep " <<
G4endl;
1696 edDfn <<
" Magnitude of diff = " << diffNorm.
mag() <<
G4endl;
1699 edDfn <<
" Global Computed from Local = " << globalNormal <<
G4endl;
1700 G4Exception(
"G4ITNavigator1::GetGlobalExitNormal()",
"GeomNav0003",
1706 return globalNormal;
1710#define G4NEW_SAFETY 1
1727#ifdef G4DEBUG_NAVIGATION
1731 G4cout <<
"*** G4ITNavigator1::ComputeSafety: ***" <<
G4endl
1732 <<
" Called at point: " << pGlobalpoint <<
G4endl;
1736 <<
" - Maximum length = " << pMaxLength <<
G4endl;
1739 G4cout <<
" ----- Upon entering Compute Safety:" <<
G4endl;
1751 if( !(endpointOnSurface && stayedOnEndpoint) )
1764#ifdef G4DEBUG_NAVIGATION
1767 G4cout <<
" G4ITNavigator1::ComputeSafety() relocates-in-volume to point: "
1768 << pGlobalpoint <<
G4endl;
1785 *motherPhysical, pMaxLength);
1786 newSafety= safetyTwo;
1791 newSafety= safetyOldVoxel;
1810 G4Exception(
"G4ITNavigator1::ComputeSafety()",
"GeomNav0001",
1816 "Not applicable for external volumes.");
1822 newSafety = freplicaNav.
ComputeSafety(pGlobalpoint, localPoint,
1828#ifdef G4DEBUG_NAVIGATION
1831 G4cout <<
" G4ITNavigator1::ComputeSafety() finds that point - "
1832 << pGlobalpoint <<
" - is on surface " <<
G4endl;
1844 fPreviousSftOrigin = pGlobalpoint;
1845 fPreviousSafety = newSafety;
1849#ifdef G4DEBUG_NAVIGATION
1854 G4cout <<
" Returned value of Safety = " << newSafety <<
G4endl;
1856 G4cout.precision(oldcoutPrec);
1880 G4cout <<
"The current state of G4ITNavigator1 is: " <<
G4endl;
1881 G4cout <<
" ValidExitNormal= " << fValidExitNormal <<
G4endl
1882 <<
" ExitNormal = " << fExitNormal <<
G4endl
1883 <<
" Exiting = " << fExiting <<
G4endl
1884 <<
" Entering = " << fEntering <<
G4endl
1885 <<
" BlockedPhysicalVolume= " ;
1886 if (fBlockedPhysicalVolume==0)
1891 <<
" BlockedReplicaNo = " << fBlockedReplicaNo <<
G4endl
1892 <<
" LastStepWasZero = " << fLastStepWasZero <<
G4endl
1898 G4cout << std::setw(30) <<
" ExitNormal " <<
" "
1899 << std::setw( 5) <<
" Valid " <<
" "
1900 << std::setw( 9) <<
" Exiting " <<
" "
1901 << std::setw( 9) <<
" Entering" <<
" "
1902 << std::setw(15) <<
" Blocked:Volume " <<
" "
1903 << std::setw( 9) <<
" ReplicaNo" <<
" "
1904 << std::setw( 8) <<
" LastStepZero " <<
" "
1906 G4cout <<
"( " << std::setw(7) << fExitNormal.
x()
1907 <<
", " << std::setw(7) << fExitNormal.
y()
1908 <<
", " << std::setw(7) << fExitNormal.
z() <<
" ) "
1909 << std::setw( 5) << fValidExitNormal <<
" "
1910 << std::setw( 9) << fExiting <<
" "
1911 << std::setw( 9) << fEntering <<
" ";
1912 if ( fBlockedPhysicalVolume==0 )
1914 G4cout << std::setw(15) <<
"None";
1918 G4cout << std::setw(15)<< fBlockedPhysicalVolume->
GetName();
1920 G4cout << std::setw( 9) << fBlockedReplicaNo <<
" "
1921 << std::setw( 8) << fLastStepWasZero <<
" "
1927 G4cout <<
" Current Localpoint = " << fLastLocatedPointLocal <<
G4endl;
1928 G4cout <<
" PreviousSftOrigin = " << fPreviousSftOrigin <<
G4endl;
1929 G4cout <<
" PreviousSafety = " << fPreviousSafety <<
G4endl;
1931 G4cout.precision(oldcoutPrec);
1938void G4ITNavigator1::ComputeStepLog(
const G4ThreeVector& pGlobalpoint,
1948 TransformPoint(fLastLocatedPointLocal);
1950 G4double shiftOriginSafSq = (fPreviousSftOrigin-pGlobalpoint).mag2();
1958 if( shiftOriginSafSq >=
sqr(fPreviousSafety) )
1960 G4double shiftOrigin = std::sqrt(shiftOriginSafSq);
1961 G4double diffShiftSaf = shiftOrigin - fPreviousSafety;
1963 if( diffShiftSaf > fAccuracyForWarning )
1967 std::ostringstream message, suggestion;
1968 message <<
"Accuracy error or slightly inaccurate position shift."
1970 <<
" The Step's starting point has moved "
1971 << std::sqrt(moveLenSq)/mm <<
" mm " <<
G4endl
1972 <<
" since the last call to a Locate method." <<
G4endl
1973 <<
" This has resulted in moving "
1974 << shiftOrigin/mm <<
" mm "
1975 <<
" from the last point at which the safety "
1976 <<
" was calculated " <<
G4endl
1977 <<
" which is more than the computed safety= "
1979 <<
" This difference is "
1980 << diffShiftSaf/mm <<
" mm." <<
G4endl
1981 <<
" The tolerated accuracy is "
1982 << fAccuracyForException/mm <<
" mm.";
1986 if( ((++warnNow % 100) == 1) )
1989 <<
" This problem can be due to either " <<
G4endl
1990 <<
" - a process that has proposed a displacement"
1991 <<
" larger than the current safety , or" <<
G4endl
1992 <<
" - inaccuracy in the computation of the safety";
1993 suggestion <<
"We suggest that you " <<
G4endl
1994 <<
" - find i) what particle is being tracked, and "
1995 <<
" ii) through what part of your geometry " <<
G4endl
1996 <<
" for example by re-running this event with "
1998 <<
" /tracking/verbose 1 " <<
G4endl
1999 <<
" - check which processes you declare for"
2000 <<
" this particle (and look at non-standard ones)"
2002 <<
" - in case, create a detailed logfile"
2003 <<
" of this event using:" <<
G4endl
2004 <<
" /tracking/verbose 6 ";
2008 message,
G4String(suggestion.str()));
2009 G4cout.precision(oldcoutPrec);
2010 G4cerr.precision(oldcerrPrec);
2012#ifdef G4DEBUG_NAVIGATION
2015 G4cerr <<
"WARNING - G4ITNavigator1::ComputeStep()" <<
G4endl
2016 <<
" The Step's starting point has moved "
2017 << std::sqrt(moveLenSq) <<
"," <<
G4endl
2018 <<
" which has taken it to the limit of"
2019 <<
" the current safety. " <<
G4endl;
2024 if ( shiftOriginSafSq >
sqr(safetyPlus) )
2026 std::ostringstream message;
2027 message <<
"May lead to a crash or unreliable results." <<
G4endl
2028 <<
" Position has shifted considerably without"
2029 <<
" notifying the navigator !" <<
G4endl
2030 <<
" Tolerated safety: " << safetyPlus <<
G4endl
2031 <<
" Computed shift : " << shiftOriginSafSq;
2032 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav1002",
2049 G4int oldcoutPrec = os.precision(4);
2050 if( n.fVerbose >= 4 )
2052 os <<
"The current state of G4ITNavigator1 is: " <<
G4endl;
2053 os <<
" ValidExitNormal= " << n.fValidExitNormal <<
G4endl
2054 <<
" ExitNormal = " << n.fExitNormal <<
G4endl
2055 <<
" Exiting = " << n.fExiting <<
G4endl
2056 <<
" Entering = " << n.fEntering <<
G4endl
2057 <<
" BlockedPhysicalVolume= " ;
2058 if (n.fBlockedPhysicalVolume==0)
2061 os << n.fBlockedPhysicalVolume->GetName();
2063 <<
" BlockedReplicaNo = " << n.fBlockedReplicaNo <<
G4endl
2064 <<
" LastStepWasZero = " << n.fLastStepWasZero <<
G4endl
2067 if( ( 1 < n.fVerbose) && (n.fVerbose < 4) )
2070 os << std::setw(30) <<
" ExitNormal " <<
" "
2071 << std::setw( 5) <<
" Valid " <<
" "
2072 << std::setw( 9) <<
" Exiting " <<
" "
2073 << std::setw( 9) <<
" Entering" <<
" "
2074 << std::setw(15) <<
" Blocked:Volume " <<
" "
2075 << std::setw( 9) <<
" ReplicaNo" <<
" "
2076 << std::setw( 8) <<
" LastStepZero " <<
" "
2078 os <<
"( " << std::setw(7) << n.fExitNormal.x()
2079 <<
", " << std::setw(7) << n.fExitNormal.y()
2080 <<
", " << std::setw(7) << n.fExitNormal.z() <<
" ) "
2081 << std::setw( 5) << n.fValidExitNormal <<
" "
2082 << std::setw( 9) << n.fExiting <<
" "
2083 << std::setw( 9) << n.fEntering <<
" ";
2084 if ( n.fBlockedPhysicalVolume==0 )
2085 { os << std::setw(15) <<
"None"; }
2087 { os << std::setw(15)<< n.fBlockedPhysicalVolume->GetName(); }
2088 os << std::setw( 9) << n.fBlockedReplicaNo <<
" "
2089 << std::setw( 8) << n.fLastStepWasZero <<
" "
2092 if( n.fVerbose > 2 )
2095 os <<
" Current Localpoint = " << n.fLastLocatedPointLocal <<
G4endl;
2096 os <<
" PreviousSftOrigin = " << n.fPreviousSftOrigin <<
G4endl;
2097 os <<
" PreviousSafety = " << n.fPreviousSafety <<
G4endl;
2099 if( n.fVerbose > 3 || n.fVerbose == 0 )
2101 os <<
"Current History: " <<
G4endl << n.fHistory;
2104 os.precision(oldcoutPrec);
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define fWasLimitedByGeometry
#define G4DEBUG_NAVIGATION
std::ostream & operator<<(std::ostream &os, const G4ITNavigator1 &n)
#define fExitNormalGlobalFrame
CLHEP::Hep3Vector G4ThreeVector
G4ReferenceCountedHandle< G4TouchableHistory > G4TouchableHistoryHandle
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
double dot(const Hep3Vector &) const
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
virtual void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
G4TouchableHistory * CreateTouchableHistory() const
virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &point, G4bool *valid)
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=0, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
const G4AffineTransform GetLocalToGlobalTransform() const
G4int GetVerboseLevel() const
G4ThreeVector fStepEndPoint
G4double CheckNextStep(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
G4ThreeVector ComputeLocalAxis(const G4ThreeVector &pVec) const
virtual G4VPhysicalVolume * ResetHierarchyAndLocate(const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h)
void ResetStackAndState()
G4int GetDaughtersRegularStructureId(const G4LogicalVolume *pLog) const
const G4AffineTransform & GetGlobalToLocalTransform() const
G4bool EnteredDaughterVolume() const
virtual G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=true)
EVolume CharacteriseDaughters(const G4LogicalVolume *pLog) const
G4NavigationHistory fHistory
virtual G4ThreeVector GetLocalExitNormalAndCheck(const G4ThreeVector &point, G4bool *valid)
G4ThreeVector fLastStepEndPointLocal
void SetNavigatorState(G4ITNavigatorState_Lock1 *)
virtual void SetupHierarchy()
G4AffineTransform GetMotherToDaughterTransform(G4VPhysicalVolume *dVolume, G4int dReplicaNo, EVolume dVolumeType)
EVolume VolumeType(const G4VPhysicalVolume *pVol) const
virtual G4double ComputeStep(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
G4bool fWasLimitedByGeometry
virtual G4ThreeVector GetLocalExitNormal(G4bool *valid)
G4ITNavigatorState_Lock1 * GetNavigatorState()
virtual ~G4ITNavigator1()
virtual G4TouchableHistoryHandle CreateTouchableHistoryHandle() const
void SetVerboseLevel(G4int level)
G4ThreeVector ComputeLocalPoint(const G4ThreeVector &rGlobPoint) const
virtual void ResetState()
G4VSolid * GetSolid() const
const G4String & GetName() const
void SetSolid(G4VSolid *pSolid)
G4SmartVoxelHeader * GetVoxelHeader() const
void UpdateMaterial(G4Material *pMaterial)
EVolume GetTopVolumeType() const
void NewLevel(G4VPhysicalVolume *pNewMother, EVolume vType=kNormal, G4int nReplica=-1)
G4int GetReplicaNo(G4int n) const
const G4AffineTransform & GetTopTransform() const
G4int GetTopReplicaNo() const
G4VPhysicalVolume * GetVolume(G4int n) const
G4VPhysicalVolume * GetTopVolume() const
EVolume GetVolumeType(G4int n) 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 ComputeSafety(const G4ThreeVector &globalpoint, const G4NavigationHistory &history, const G4double pMaxLength=DBL_MAX)
G4bool LevelLocate(G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint)
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)
G4SmartVoxelNode * ParamVoxelLocate(G4SmartVoxelHeader *pHead, const G4ThreeVector &localPoint)
G4bool LevelLocate(G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint)
G4double ComputeSafety(const G4ThreeVector &localPoint, const G4NavigationHistory &history, const G4double pProposedMaxLength=DBL_MAX)
void SetNormalNavigation(G4NormalNavigation *fnormnav)
G4bool LevelLocate(G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint)
G4double ComputeSafety(const G4ThreeVector &localPoint, const G4NavigationHistory &history, const G4double pProposedMaxLength=DBL_MAX)
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)
G4double ComputeSafety(const G4ThreeVector &globalPoint, const G4ThreeVector &localPoint, G4NavigationHistory &history, const G4double pProposedMaxLength=DBL_MAX)
void ComputeTransformation(const G4int replicaNo, G4VPhysicalVolume *pVol, G4ThreeVector &point) const
G4bool LevelLocate(G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint)
EInside BackLocate(G4NavigationHistory &history, const G4ThreeVector &globalPoint, G4ThreeVector &localPoint, const G4bool &exiting, G4bool ¬KnownInside) const
const G4NavigationHistory * GetHistory() const
G4int MoveUpHistory(G4int num_levels=1)
virtual G4VSolid * ComputeSolid(const G4int, G4VPhysicalVolume *)
virtual void ComputeTransformation(const G4int, G4VPhysicalVolume *) const =0
const G4RotationMatrix * GetRotation() const
virtual void SetCopyNo(G4int CopyNo)=0
const G4ThreeVector GetTranslation() const
virtual G4bool CheckOverlaps(G4int res=1000, G4double tol=0., G4bool verbose=true, G4int errMax=1)
G4LogicalVolume * GetLogicalVolume() const
virtual G4int GetCopyNo() const =0
const G4String & GetName() const
virtual G4int GetRegularStructureId() const =0
virtual G4VPVParameterisation * GetParameterisation() const =0
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const =0
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
virtual G4GeometryType GetEntityType() const =0
virtual G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4NavigationHistory &history, const G4double pMaxLength=DBL_MAX)
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)
G4SmartVoxelNode * VoxelLocate(G4SmartVoxelHeader *pHead, const G4ThreeVector &localPoint)
virtual G4bool LevelLocate(G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint)
G4double ComputeSafety(const G4ThreeVector &localPoint, const G4VPhysicalVolume ¤tPhysical, G4double maxLength=DBL_MAX)