47static const G4double kToleranceNormalCheck = CLHEP::perThousand;
64 G4cout <<
" G4Navigator parameters: Action Threshold (No Zero Steps) = "
65 << fActionThreshold_NoZeroSteps
66 <<
" Abandon Threshold (No Zero Steps) = "
67 << fAbandonThreshold_NoZeroSteps <<
G4endl;
79#ifdef ALTERNATIVE_VOXEL_NAV
92#ifdef ALTERNATIVE_VOXEL_NAV
109 fLastTriedStepComputation =
false;
134 const G4bool relativeSearch,
135 const G4bool ignoreDirection )
137 G4bool notKnownContained =
true, noResult;
144 G4bool considerDirection = pGlobalDirection && ((!ignoreDirection) || fLocatedOnEdge);
146 fLastTriedStepComputation =
false;
147 fChangedGrandMotherRefFrame =
false;
149 if( considerDirection )
151 globalDirection=*pGlobalDirection;
158 G4cout <<
"*** G4Navigator::LocateGlobalPointAndSetup: ***" <<
G4endl;
160 <<
" Globalpoint = " << globalPoint <<
G4endl
161 <<
" RelativeSearch = " << relativeSearch <<
G4endl;
167 G4cout.precision(oldcoutPrec);
171 G4int noLevelsExited = 0;
173 if ( !relativeSearch )
196 fLastLocatedPointLocal = localPoint;
197 fLocatedOutsideWorld =
true;
198 fBlockedPhysicalVolume = 0;
199 fBlockedReplicaNo = -1;
232 fBlockedPhysicalVolume);
235 fBlockedPhysicalVolume->
SetCopyNo(fBlockedReplicaNo);
245 fBlockedPhysicalVolume);
247 fBlockedPhysicalVolume);
249 fBlockedPhysicalVolume);
252 fBlockedPhysicalVolume->
SetCopyNo(fBlockedReplicaNo);
260 ComputeMaterial(fBlockedReplicaNo,
261 fBlockedPhysicalVolume,
266 G4Exception(
"G4Navigator::LocateGlobalPointAndSetup()",
268 "Extra levels not applicable for external volumes.");
272 fBlockedPhysicalVolume =
nullptr;
274 notKnownContained =
false;
279 fBlockedPhysicalVolume =
nullptr;
296 while (notKnownContained)
303 insideCode = targetSolid->
Inside(localPoint);
307 G4String solidResponse =
"-kInside-";
309 solidResponse =
"-kOutside-";
311 solidResponse =
"-kSurface-";
312 G4cout <<
"*** G4Navigator::LocateGlobalPointAndSetup(): ***" <<
G4endl
313 <<
" Invoked Inside() for solid: " << targetSolid->
GetName()
314 <<
". Solid replied: " << solidResponse <<
G4endl
315 <<
" For local point p: " << localPoint <<
G4endl;
324 fExiting, notKnownContained);
336 insideCode = fpExternalNav->
Inside(targetSolid, localPoint, localDirection);
352 fLocatedOutsideWorld =
true;
353 fLastLocatedPointLocal = localPoint;
362 if( noLevelsExited > 1 )
366 if(
const auto *mRot = fBlockedPhysicalVolume->
GetRotation())
368 fGrandMotherExitNormal *= (*mRot).inverse();
369 fChangedGrandMotherRefFrame =
true;
376 G4bool isExiting = fExiting;
377 if( (!fExiting) && considerDirection )
382 G4bool directionExiting =
false;
393 directionExiting = normal.
dot(localDirection) > 0.0;
394 isExiting = isExiting || directionExiting;
407 fLocatedOutsideWorld =
true;
408 fLastLocatedPointLocal = localPoint;
413 fValidExitNormal =
false;
418 if( noLevelsExited > 1 )
426 fGrandMotherExitNormal *= (*mRot).inverse();
427 fChangedGrandMotherRefFrame =
true;
449 if (!targetPhysical) {
break; }
457 fBlockedPhysicalVolume,
467 fBlockedPhysicalVolume,
477 fBlockedPhysicalVolume,
488 fBlockedPhysicalVolume,
498 fBlockedPhysicalVolume,
508 fBlockedPhysicalVolume,
526 fBlockedPhysicalVolume =
nullptr;
527 fBlockedReplicaNo = -1;
544 fGrandMotherExitNormal *= (*mRot);
545 fChangedGrandMotherRefFrame=
true;
549#ifdef G4DEBUG_NAVIGATION
553 G4cout <<
"*** G4Navigator::LocateGlobalPointAndSetup() ***" <<
G4endl;
561 fLastLocatedPointLocal = localPoint;
568 if (targetPhysical) { curPhysVol_Name = targetPhysical->
GetName(); }
569 G4cout <<
" Return value = new volume = " << curPhysVol_Name <<
G4endl;
574 G4cout <<
"Upon exiting LocateGlobalPointAndSetup():" <<
G4endl;
577 G4cout.precision(oldcoutPrec);
581 fLocatedOutsideWorld =
false;
583 return targetPhysical;
602#ifdef G4DEBUG_NAVIGATION
609 fLastTriedStepComputation =
false;
610 fChangedGrandMotherRefFrame =
false;
627 GetVoxelNavigator().
VoxelLocate( pVoxelHeader, fLastLocatedPointLocal );
643 fLastLocatedPointLocal );
652 fBlockedPhysicalVolume =
nullptr;
653 fBlockedReplicaNo = -1;
674 fSaveState.sExitNormal = fExitNormal;
675 fSaveState.sValidExitNormal = fValidExitNormal;
676 fSaveState.sExiting = fExiting;
677 fSaveState.sEntering = fEntering;
679 fSaveState.spBlockedPhysicalVolume = fBlockedPhysicalVolume;
680 fSaveState.sBlockedReplicaNo = fBlockedReplicaNo;
682 fSaveState.sLastStepWasZero = fLastStepWasZero;
684 fSaveState.sLocatedOutsideWorld = fLocatedOutsideWorld;
685 fSaveState.sLastLocatedPointLocal = fLastLocatedPointLocal;
692 fSaveState.sPreviousSftOrigin = fPreviousSftOrigin;
693 fSaveState.sPreviousSafety = fPreviousSafety;
704 fExitNormal = fSaveState.sExitNormal;
705 fValidExitNormal = fSaveState.sValidExitNormal;
706 fExiting = fSaveState.sExiting;
707 fEntering = fSaveState.sEntering;
709 fBlockedPhysicalVolume = fSaveState.spBlockedPhysicalVolume;
710 fBlockedReplicaNo = fSaveState.sBlockedReplicaNo;
712 fLastStepWasZero = fSaveState.sLastStepWasZero;
714 fLocatedOutsideWorld = fSaveState.sLocatedOutsideWorld;
715 fLastLocatedPointLocal = fSaveState.sLastLocatedPointLocal;
721 fPreviousSftOrigin = fSaveState.sPreviousSftOrigin;
722 fPreviousSafety = fSaveState.sPreviousSafety;
758 const G4double pCurrentProposedStepLength,
761#ifdef G4DEBUG_NAVIGATION
775 fChangedGrandMotherRefFrame =
false;
778 fCalculatedExitNormal =
false;
784 G4cout <<
"*** G4Navigator::ComputeStep: ***" <<
G4endl;
786 <<
" - Proposed step length = " << pCurrentProposedStepLength
788#ifdef G4DEBUG_NAVIGATION
792 <<
" Globalpoint = " << std::setw(25) << pGlobalpoint <<
G4endl
793 <<
" Direction = " << std::setw(25) << pDirection <<
G4endl;
806 if( newLocalPoint != fLastLocatedPointLocal )
811 G4double moveLenSq = (newLocalPoint-oldLocalPoint).mag2();
813 if ( moveLenSq >=
fSqTol )
816 ComputeStepLog(pGlobalpoint, moveLenSq);
830 Step = GetVoxelNavigator().
ComputeStep(fLastLocatedPointLocal,
832 pCurrentProposedStepLength,
839 &fBlockedPhysicalVolume,
847 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
849 pCurrentProposedStepLength,
856 &fBlockedPhysicalVolume,
876 "Point is relocated in voxels, while it should be outside!");
877 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
879 pCurrentProposedStepLength,
886 &fBlockedPhysicalVolume,
892 ComputeStepSkippingEqualMaterials(fLastLocatedPointLocal,
894 pCurrentProposedStepLength,
901 &fBlockedPhysicalVolume,
911 Step = fparamNav.
ComputeStep(fLastLocatedPointLocal,
913 pCurrentProposedStepLength,
920 &fBlockedPhysicalVolume,
925 Step = fregularNav.
ComputeStep(fLastLocatedPointLocal,
927 pCurrentProposedStepLength,
934 &fBlockedPhysicalVolume,
939 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0001",
943 Step = fpExternalNav->
ComputeStep(fLastLocatedPointLocal,
945 pCurrentProposedStepLength,
952 &fBlockedPhysicalVolume,
965 fLastLocatedPointLocal,
967 pCurrentProposedStepLength,
971 fCalculatedExitNormal,
975 &fBlockedPhysicalVolume,
981 fPreviousSftOrigin = pGlobalpoint;
982 fPreviousSafety = pNewSafety;
994 fLocatedOnEdge = fLastStepWasZero && (Step==0.0);
1004 G4bool act = fNumberZeroSteps >= fActionThreshold_NoZeroSteps;
1005 G4bool actAndReport =
false;
1006 G4bool abandon = fNumberZeroSteps >= fAbandonThreshold_NoZeroSteps;
1009 actAndReport = act && (!fPushed) && fWarnPush;
1011#ifdef G4DEBUG_NAVIGATION
1012 inform = fNumberZeroSteps > 1;
1015 if ( act || inform )
1017 if( act && !abandon )
1025 if( actAndReport || abandon || inform )
1027 std::ostringstream message;
1029 message.precision(16);
1030 message <<
"Stuck Track: potential geometry or navigation problem."
1032 message <<
" Track stuck, not moving for "
1033 << fNumberZeroSteps <<
" steps." <<
G4endl
1034 <<
" Current phys volume: '" << motherPhysical->
GetName()
1036 <<
" - at position : " << pGlobalpoint <<
G4endl
1037 <<
" in direction: " << pDirection <<
G4endl
1038 <<
" (local position: " << newLocalPoint <<
")" <<
G4endl
1039 <<
" (local direction: " << localDirection <<
")." <<
G4endl
1040 <<
" Previous phys volume: '"
1041 << ( fLastMotherPhys ? fLastMotherPhys->
GetName() :
"" )
1043 if( actAndReport || abandon )
1045 message <<
" Likely geometry overlap - else navigation problem !"
1054 message <<
" Track *abandoned* due to excessive number of Zero steps."
1056 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0003",
1064 message <<
" *** Trying to get *unstuck* using a push"
1065 <<
" - expanding step to " << Step <<
" (mm) ..."
1066 <<
" Potential overlap in geometry !" <<
G4endl;
1067 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav1002",
1071#ifdef G4DEBUG_NAVIGATION
1074 if( fNumberZeroSteps > 1 )
1076 message <<
", nav-comp-step calls # " << sNavCScalls
1077 <<
", Step= " << Step <<
G4endl;
1088 if (!fPushed) { fNumberZeroSteps = 0; }
1090 fLastMotherPhys = motherPhysical;
1096 + std::min(Step,pCurrentProposedStepLength) * pDirection;
1101#ifdef G4DEBUG_NAVIGATION
1104 G4cout <<
" At G4Nav CompStep End - if(exiting) - fExiting= " << fExiting
1105 <<
" fValidExitNormal = " << fValidExitNormal <<
G4endl;
1110 if ( fValidExitNormal || fCalculatedExitNormal )
1113 fGrandMotherExitNormal = fExitNormal;
1120 + localDirection*Step;
1134 fChangedGrandMotherRefFrame =
true;
1135 fGrandMotherExitNormal = (*mRot).inverse() * exitNormalMotherFrame;
1139 fGrandMotherExitNormal = exitNormalMotherFrame;
1147 fCalculatedExitNormal =
false;
1154#ifdef G4DEBUG_NAVIGATION
1157 desc <<
"Problem in ComputeStep: Replica Navigation did not provide"
1158 <<
" valid exit Normal. " <<
G4endl;
1159 desc <<
" Do not know how calculate it in this case." <<
G4endl;
1160 desc <<
" Location = " << finalLocalPoint <<
G4endl;
1161 desc <<
" Volume name = " << motherPhysical->
GetName()
1163 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0003",
1164 JustWarning, desc,
"Normal not available for exiting.");
1170 fCalculatedExitNormal =
true;
1174 if( fValidExitNormal || fCalculatedExitNormal )
1184 fExitNormalGlobalFrame = fGrandMotherExitNormal;
1193 if( (Step == pCurrentProposedStepLength) && (!fExiting) && (!fEntering) )
1209 G4cout <<
" Returned step= " << Step;
1211 if( Step == kInfinity )
1213 G4cout <<
" Requested step= " << pCurrentProposedStepLength ;
1220 fLastTriedStepComputation =
true;
1233 const G4double pCurrentProposedStepLength,
1244 pCurrentProposedStepLength,
1269 fLocatedOnEdge =
false;
1270 fLastStepWasZero =
false;
1275 fValidExitNormal =
false;
1276 fChangedGrandMotherRefFrame =
false;
1277 fCalculatedExitNormal =
false;
1284 fPreviousSafety = 0.0;
1286 fNumberZeroSteps = 0;
1288 fBlockedPhysicalVolume =
nullptr;
1289 fBlockedReplicaNo = -1;
1291 fLastLocatedPointLocal =
G4ThreeVector( kInfinity, -kInfinity, 0.0 );
1292 fLocatedOutsideWorld =
false;
1294 fLastMotherPhys =
nullptr;
1308 for (
auto i = 1; i <= depth; ++i )
1346 ComputeMaterial(replicaNo, current, pTouchable) );
1366 if ( fLastTriedStepComputation )
1372 if( fEntering && (fBlockedPhysicalVolume!=0) )
1375 if( candidateLogical )
1397 currentSolid = candidateLogical->
GetSolid();
1398 inSideIt = currentSolid->
Inside(daughterPointOwnLocal);
1399 onSurface = (inSideIt ==
kSurface);
1404 safety = (currentSolid->
DistanceToIn(daughterPointOwnLocal));
1407 else if (inSideIt ==
kInside )
1409 safety = (currentSolid->
DistanceToOut(daughterPointOwnLocal));
1416 nextSolidExitNormal =
1423 ExitNormal = MotherToDaughterTransform
1425 fCalculatedExitNormal =
true;
1430 if((
fVerbose == 1 ) && ( fCheck ))
1432 std::ostringstream message;
1433 message <<
"Point not on surface ! " <<
G4endl
1435 << daughterPointOwnLocal <<
G4endl
1436 <<
" Physical volume = "
1438 <<
" Logical volume = "
1440 <<
" Solid = " << currentSolid->
GetName()
1443 << *currentSolid <<
G4endl;
1446 message <<
"Point is Outside. " <<
G4endl
1447 <<
" Safety (from outside) = " << safety <<
G4endl;
1451 message <<
"Point is Inside. " <<
G4endl
1452 <<
" Safety (from inside) = " << safety <<
G4endl;
1454 G4Exception(
"G4Navigator::GetLocalExitNormal()",
"GeomNav1001",
1463 else if ( fExiting )
1465 ExitNormal = fGrandMotherExitNormal;
1467 fCalculatedExitNormal =
true;
1474 "Incorrect call to GetLocalSurfaceNormal." );
1483 ExitNormal = -(daughterSolid->
SurfaceNormal(fLastLocatedPointLocal));
1484 if( std::fabs(ExitNormal.
mag2()-1.0 ) > kToleranceNormalCheck )
1487 desc <<
" Parameters of solid: " << *daughterSolid
1488 <<
" Point for surface = " << fLastLocatedPointLocal << std::endl;
1491 "Surface Normal returned by Solid is not a Unit Vector." );
1493 fCalculatedExitNormal =
true;
1500 ExitNormal = fGrandMotherExitNormal;
1502 fCalculatedExitNormal =
true;
1507 fCalculatedExitNormal =
false;
1509 message <<
"Function called when *NOT* at a Boundary." <<
G4endl;
1510 message <<
"Exit Normal not calculated." <<
G4endl;
1527 G4int enteringReplicaNo,
1530 switch (enteringVolumeType)
1535 G4Exception(
"G4Navigator::GetMotherToDaughterTransform()",
1537 "Method NOT Implemented yet for replica volumes.");
1545 pParam->
ComputeSolid(enteringReplicaNo, pEnteringPhysVol);
1585#ifdef G4DEBUG_NAVIGATION
1588 if ( fLastTriedStepComputation )
1593 ExpectedBoundaryPointLocal =
1614 G4bool* pNormalCalculated)
1619 G4bool usingStored = fCalculatedExitNormal && (
1620 ( fLastTriedStepComputation && fExiting )
1622 ( !fLastTriedStepComputation
1632 globalNormal = fExitNormalGlobalFrame;
1634 if( std::fabs ( normMag2 - 1.0 ) < perThousand )
1636 *pNormalCalculated =
true;
1642 message.precision(10);
1643 message <<
" WARNING> Expected normal-global-frame to be valid, "
1644 <<
" i.e. a unit vector!" <<
G4endl
1645 <<
" - but |normal| = " << std::sqrt(normMag2)
1646 <<
" - and |normal|^2 = " << normMag2 <<
G4endl
1647 <<
" which differs from 1.0 by " << normMag2 - 1.0 <<
G4endl
1648 <<
" n = " << fExitNormalGlobalFrame <<
G4endl
1649 <<
" Global point: " << IntersectPointGlobal <<
G4endl
1660 message <<
"============================================================"
1664 message <<
" State of Navigator: " <<
G4endl;
1665 message << *
this <<
G4endl;
1667 message <<
"============================================================"
1672 "Value obtained from stored global-normal is not a unit vector.");
1678 *pNormalCalculated = fCalculatedExitNormal;
1686 *pNormalCalculated = fCalculatedExitNormal;
1688#ifdef G4DEBUG_NAVIGATION
1689 usingStored =
false;
1691 if( (!validNormal) && !fCalculatedExitNormal )
1694 edN <<
" Calculated = " << fCalculatedExitNormal <<
G4endl;
1695 edN <<
" Entering= " << fEntering <<
G4endl;
1698 edN <<
" State of Navigator: " <<
G4endl;
1704 "LocalExitNormalAndCheck() did not calculate Normal.");
1709 if( validNormal && (std::fabs(localMag2-1.0)) > kToleranceNormalCheck )
1713 edN <<
"G4Navigator::GetGlobalExitNormal: "
1714 <<
" Using Local Normal - from call to GetLocalExitNormalAndCheck. "
1716 <<
" Local Exit Normal : " <<
" || = " << std::sqrt(localMag2)
1717 <<
" vec = " << localNormal <<
G4endl
1718 <<
" Global Exit Normal : " <<
" || = " << globalNormal.
mag()
1719 <<
" vec = " << globalNormal <<
G4endl
1720 <<
" Global point: " << IntersectPointGlobal <<
G4endl;
1721 edN <<
" Calculated It = " << fCalculatedExitNormal <<
G4endl
1734 "Value obtained from new local *solid* is incorrect.");
1735 localNormal = localNormal.
unit();
1741#ifdef G4DEBUG_NAVIGATION
1752 G4ThreeVector diffNorm = globalNormAgn - fExitNormalGlobalFrame;
1753 if( diffNorm.
mag2() > kToleranceNormalCheck )
1756 edDfn <<
"Found difference in normals in case of exiting mother "
1757 <<
"- when Get is called after ComputingStep " <<
G4endl;
1758 edDfn <<
" Magnitude of diff = " << diffNorm.
mag() <<
G4endl;
1761 edDfn <<
" Global Computed from Local = " << globalNormAgn <<
G4endl;
1762 G4Exception(
"G4Navigator::GetGlobalExitNormal()",
"GeomNav0003",
1770 fExitNormalGlobalFrame = globalNormal;
1772 return globalNormal;
1788#ifdef G4DEBUG_NAVIGATION
1792 G4cout <<
"*** G4Navigator::ComputeSafety: ***" <<
G4endl
1793 <<
" Called at point: " << pGlobalpoint <<
G4endl;
1797 <<
" - Maximum length = " << pMaxLength <<
G4endl;
1800 G4cout <<
" ----- Upon entering Compute Safety:" <<
G4endl;
1810 if( endpointOnSurface && stayedOnEndpoint )
1812#ifdef G4DEBUG_NAVIGATION
1815 G4cout <<
" G4Navigator::ComputeSafety() finds that point - "
1816 << pGlobalpoint <<
" - is on surface " <<
G4endl;
1823 G4cout <<
" Returned value of Safety is zero " <<
G4endl;
1824 G4cout.precision(oldcoutPrec);
1845#ifdef G4DEBUG_NAVIGATION
1848 G4cout <<
" G4Navigator::ComputeSafety() relocates-in-volume to point: "
1849 << pGlobalpoint <<
G4endl;
1865 *motherPhysical, pMaxLength);
1884 G4Exception(
"G4Navigator::ComputeSafety()",
"GeomNav0001",
1895 newSafety = freplicaNav.
ComputeSafety(pGlobalpoint, localPoint,
1908 fPreviousSftOrigin = pGlobalpoint;
1909 fPreviousSafety = newSafety;
1911#ifdef G4DEBUG_NAVIGATION
1916 G4cout <<
" Returned value of Safety = " << newSafety <<
G4endl;
1918 G4cout.precision(oldcoutPrec);
1942 G4cout <<
"The current state of G4Navigator is: " <<
G4endl;
1943 G4cout <<
" ValidExitNormal= " << fValidExitNormal
1944 <<
" ExitNormal = " << fExitNormal
1945 <<
" Exiting = " << fExiting
1946 <<
" Entering = " << fEntering
1947 <<
" BlockedPhysicalVolume= " ;
1948 if (fBlockedPhysicalVolume==0)
1957 <<
" BlockedReplicaNo = " << fBlockedReplicaNo
1958 <<
" LastStepWasZero = " << fLastStepWasZero
1964 G4cout << std::setw(30) <<
" ExitNormal " <<
" "
1965 << std::setw( 5) <<
" Valid " <<
" "
1966 << std::setw( 9) <<
" Exiting " <<
" "
1967 << std::setw( 9) <<
" Entering" <<
" "
1968 << std::setw(15) <<
" Blocked:Volume " <<
" "
1969 << std::setw( 9) <<
" ReplicaNo" <<
" "
1970 << std::setw( 8) <<
" LastStepZero " <<
" "
1972 G4cout <<
"( " << std::setw(7) << fExitNormal.
x()
1973 <<
", " << std::setw(7) << fExitNormal.
y()
1974 <<
", " << std::setw(7) << fExitNormal.
z() <<
" ) "
1975 << std::setw( 5) << fValidExitNormal <<
" "
1976 << std::setw( 9) << fExiting <<
" "
1977 << std::setw( 9) << fEntering <<
" ";
1978 if ( fBlockedPhysicalVolume ==
nullptr )
1979 {
G4cout << std::setw(15) <<
"None"; }
1981 {
G4cout << std::setw(15)<< fBlockedPhysicalVolume->
GetName(); }
1982 G4cout << std::setw( 9) << fBlockedReplicaNo <<
" "
1983 << std::setw( 8) << fLastStepWasZero <<
" "
1989 G4cout <<
" Current Localpoint = " << fLastLocatedPointLocal <<
G4endl;
1990 G4cout <<
" PreviousSftOrigin = " << fPreviousSftOrigin <<
G4endl;
1991 G4cout <<
" PreviousSafety = " << fPreviousSafety <<
G4endl;
1993 G4cout.precision(oldcoutPrec);
2000void G4Navigator::ComputeStepLog(
const G4ThreeVector& pGlobalpoint,
2010 InverseTransformPoint(fLastLocatedPointLocal);
2012 G4double shiftOriginSafSq = (fPreviousSftOrigin-pGlobalpoint).mag2();
2020 if( shiftOriginSafSq >=
sqr(fPreviousSafety) )
2022 G4double shiftOrigin = std::sqrt(shiftOriginSafSq);
2023 G4double diffShiftSaf = shiftOrigin - fPreviousSafety;
2025 if( diffShiftSaf > fAccuracyForWarning )
2029 std::ostringstream message, suggestion;
2030 message <<
"Accuracy error or slightly inaccurate position shift."
2032 <<
" The Step's starting point has moved "
2033 << std::sqrt(moveLenSq)/mm <<
" mm " <<
G4endl
2034 <<
" since the last call to a Locate method." <<
G4endl
2035 <<
" This has resulted in moving "
2036 << shiftOrigin/mm <<
" mm "
2037 <<
" from the last point at which the safety "
2038 <<
" was calculated " <<
G4endl
2039 <<
" which is more than the computed safety= "
2041 <<
" This difference is "
2042 << diffShiftSaf/mm <<
" mm." <<
G4endl
2043 <<
" The tolerated accuracy is "
2044 << fAccuracyForException/mm <<
" mm.";
2048 if( ((++warnNow % 100) == 1) )
2051 <<
" This problem can be due to either " <<
G4endl
2052 <<
" - a process that has proposed a displacement"
2053 <<
" larger than the current safety , or" <<
G4endl
2054 <<
" - inaccuracy in the computation of the safety";
2055 suggestion <<
"We suggest that you " <<
G4endl
2056 <<
" - find i) what particle is being tracked, and "
2057 <<
" ii) through what part of your geometry " <<
G4endl
2058 <<
" for example by re-running this event with "
2060 <<
" /tracking/verbose 1 " <<
G4endl
2061 <<
" - check which processes you declare for"
2062 <<
" this particle (and look at non-standard ones)"
2064 <<
" - in case, create a detailed logfile"
2065 <<
" of this event using:" <<
G4endl
2066 <<
" /tracking/verbose 6 ";
2070 message,
G4String(suggestion.str()));
2071 G4cout.precision(oldcoutPrec);
2072 G4cerr.precision(oldcerrPrec);
2074#ifdef G4DEBUG_NAVIGATION
2077 G4cerr <<
"WARNING - G4Navigator::ComputeStep()" <<
G4endl
2078 <<
" The Step's starting point has moved "
2079 << std::sqrt(moveLenSq) <<
"," <<
G4endl
2080 <<
" which has taken it to the limit of"
2081 <<
" the current safety. " <<
G4endl;
2086 if ( shiftOriginSafSq >
sqr(safetyPlus) )
2088 std::ostringstream message;
2089 message <<
"May lead to a crash or unreliable results." <<
G4endl
2090 <<
" Position has shifted considerably without"
2091 <<
" notifying the navigator !" <<
G4endl
2092 <<
" Tolerated safety: " << safetyPlus <<
G4endl
2093 <<
" Computed shift : " << shiftOriginSafSq;
2094 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav1002",
2107 G4bool foundOverlap =
false;
2108 G4int nPoints = 300000, ntrials = 9, numOverlaps = 5;
2109 G4double trialLength = 1.0 * CLHEP::centimeter;
2110 while ( ntrials-- > 0 && !foundOverlap )
2114 G4cout <<
" ** Running overlap checks in volume "
2116 <<
" with length = " << trialLength <<
G4endl;
2121 if ( trialLength <= 1.0e-5 ) { numOverlaps= 1;}
2123 return foundOverlap;
2138 G4long oldcoutPrec = os.precision(4);
2139 if( n.fVerbose >= 4 )
2141 os <<
"The current state of G4Navigator is: " <<
G4endl;
2142 os <<
" ValidExitNormal= " << n.fValidExitNormal <<
G4endl
2143 <<
" ExitNormal = " << n.fExitNormal <<
G4endl
2144 <<
" Exiting = " << n.fExiting <<
G4endl
2145 <<
" Entering = " << n.fEntering <<
G4endl
2146 <<
" BlockedPhysicalVolume= " ;
2147 if (n.fBlockedPhysicalVolume==0)
2150 os << n.fBlockedPhysicalVolume->GetName();
2152 <<
" BlockedReplicaNo = " << n.fBlockedReplicaNo <<
G4endl
2153 <<
" LastStepWasZero = " << n.fLastStepWasZero <<
G4endl
2156 if( ( 1 < n.fVerbose) && (n.fVerbose < 4) )
2159 os << std::setw(30) <<
" ExitNormal " <<
" "
2160 << std::setw( 5) <<
" Valid " <<
" "
2161 << std::setw( 9) <<
" Exiting " <<
" "
2162 << std::setw( 9) <<
" Entering" <<
" "
2163 << std::setw(15) <<
" Blocked:Volume " <<
" "
2164 << std::setw( 9) <<
" ReplicaNo" <<
" "
2165 << std::setw( 8) <<
" LastStepZero " <<
" "
2167 os <<
"( " << std::setw(7) << n.fExitNormal.x()
2168 <<
", " << std::setw(7) << n.fExitNormal.y()
2169 <<
", " << std::setw(7) << n.fExitNormal.z() <<
" ) "
2170 << std::setw( 5) << n.fValidExitNormal <<
" "
2171 << std::setw( 9) << n.fExiting <<
" "
2172 << std::setw( 9) << n.fEntering <<
" ";
2173 if ( n.fBlockedPhysicalVolume==0 )
2174 { os << std::setw(15) <<
"None"; }
2176 { os << std::setw(15)<< n.fBlockedPhysicalVolume->GetName(); }
2177 os << std::setw( 9) << n.fBlockedReplicaNo <<
" "
2178 << std::setw( 8) << n.fLastStepWasZero <<
" "
2181 if( n.fVerbose > 2 )
2184 os <<
" Current Localpoint = " << n.fLastLocatedPointLocal <<
G4endl;
2185 os <<
" PreviousSftOrigin = " << n.fPreviousSftOrigin <<
G4endl;
2186 os <<
" PreviousSafety = " << n.fPreviousSafety <<
G4endl;
2188 if( n.fVerbose > 3 || n.fVerbose == 0 )
2190 os <<
"Current History: " <<
G4endl << n.fHistory;
2193 os.precision(oldcoutPrec);
2197#ifdef ALTERNATIVE_VOXEL_NAV
2205 fpvoxelNav = voxelNav;
2215 G4bool zeroStep = ( lastStep == 0.0 );
2216 fLocatedOnEdge = fLastStepWasZero && zeroStep;
2217 fLastStepWasZero = zeroStep;
2219 fExiting = exitsMotherVol;
2220 fEntering = entersDaughtVol;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define G4DEBUG_NAVIGATION
#define fExitNormalGlobalFrame
std::ostream & operator<<(std::ostream &os, const G4Navigator &n)
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()
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
std::size_t GetDepth() const
G4VPhysicalVolume * GetTopVolume() const
EVolume GetVolumeType(G4int n) const
const G4AffineTransform & GetTransform(G4int n) const
void SetVerboseLevel(G4int level)
virtual void SetupHierarchy()
G4TouchableHistory * CreateTouchableHistory() const
G4ThreeVector fStepEndPoint
G4int GetVerboseLevel() const
virtual void ResetState()
virtual G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=true)
EVolume VolumeType(const G4VPhysicalVolume *pVol) const
virtual void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
G4ThreeVector fLastStepEndPointLocal
G4bool fWasLimitedByGeometry
G4bool CheckOverlapsIterative(G4VPhysicalVolume *vol)
EVolume CharacteriseDaughters(const G4LogicalVolume *pLog) const
virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &point, G4bool *valid)
G4ThreeVector ComputeLocalPoint(const G4ThreeVector &rGlobPoint) const
void SetVoxelNavigation(G4VoxelNavigation *voxelNav)
virtual G4TouchableHistoryHandle CreateTouchableHistoryHandle() const
G4ThreeVector ComputeLocalAxis(const G4ThreeVector &pVec) const
virtual G4ThreeVector GetLocalExitNormalAndCheck(const G4ThreeVector &point, G4bool *valid)
virtual G4ThreeVector GetLocalExitNormal(G4bool *valid)
void InformLastStep(G4double lastStep, G4bool entersDaughtVol, G4bool exitsMotherVol)
virtual G4double ComputeStep(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=nullptr, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
G4AffineTransform GetMotherToDaughterTransform(G4VPhysicalVolume *dVolume, G4int dReplicaNo, EVolume dVolumeType)
void ResetStackAndState()
G4bool EnteredDaughterVolume() const
G4double CheckNextStep(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
virtual G4VPhysicalVolume * ResetHierarchyAndLocate(const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h)
G4int GetDaughtersRegularStructureId(const G4LogicalVolume *pLv) const
G4NavigationHistory fHistory
const G4AffineTransform & GetGlobalToLocalTransform() 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 void RelocateWithinVolume(G4VPhysicalVolume *motherPhysical, const G4ThreeVector &localPoint)
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
virtual G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4NavigationHistory &history, const G4double pMaxLength=DBL_MAX)=0
virtual EInside Inside(const G4VSolid *solid, const G4ThreeVector &position, const G4ThreeVector &direction)
virtual G4bool LevelLocate(G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint)=0
virtual G4VSolid * ComputeSolid(const G4int, G4VPhysicalVolume *)
virtual void ComputeTransformation(const G4int, G4VPhysicalVolume *) const =0
virtual G4bool IsNested() const
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 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)