48static const G4double kToleranceNormalCheck = CLHEP::perThousand;
65 G4cout <<
" G4Navigator parameters: Action Threshold (No Zero Steps) = "
66 << fActionThreshold_NoZeroSteps
67 <<
" Abandon Threshold (No Zero Steps) = "
68 << fAbandonThreshold_NoZeroSteps <<
G4endl;
94 delete fpSafetyCalculator;
109 fLastTriedStepComputation =
false;
134 const G4bool relativeSearch,
135 const G4bool ignoreDirection )
137 G4bool notKnownContained =
true, noResult;
144 G4bool considerDirection = (pGlobalDirection !=
nullptr) && ((!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 =
nullptr;
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-";
310 solidResponse =
"-kOutside-";
314 solidResponse =
"-kSurface-";
316 G4cout <<
"*** G4Navigator::LocateGlobalPointAndSetup(): ***" <<
G4endl
317 <<
" Invoked Inside() for solid: " << targetSolid->
GetName()
318 <<
". Solid replied: " << solidResponse <<
G4endl
319 <<
" For local point p: " << localPoint <<
G4endl;
328 fExiting, notKnownContained);
340 insideCode = fpExternalNav->
Inside(targetSolid, localPoint, localDirection);
345 if ( insideCode ==
kInside ) {
break; }
355 fLocatedOutsideWorld =
true;
356 fLastLocatedPointLocal = localPoint;
365 if( noLevelsExited > 1 )
369 if(
const auto *mRot = fBlockedPhysicalVolume->
GetRotation())
371 fGrandMotherExitNormal *= (*mRot).inverse();
372 fChangedGrandMotherRefFrame =
true;
379 G4bool isExiting = fExiting;
380 if( (!fExiting) && considerDirection )
385 G4bool directionExiting =
false;
396 directionExiting = normal.
dot(localDirection) > 0.0;
397 isExiting = isExiting || directionExiting;
402 if ( !isExiting ) {
break; }
409 fLocatedOutsideWorld =
true;
410 fLastLocatedPointLocal = localPoint;
415 fValidExitNormal =
false;
420 if( noLevelsExited > 1 )
426 if( mRot !=
nullptr )
428 fGrandMotherExitNormal *= (*mRot).inverse();
429 fChangedGrandMotherRefFrame =
true;
451 if (targetPhysical ==
nullptr) {
break; }
459 fBlockedPhysicalVolume,
469 fBlockedPhysicalVolume,
479 fBlockedPhysicalVolume,
490 fBlockedPhysicalVolume,
500 fBlockedPhysicalVolume,
510 fBlockedPhysicalVolume,
528 fBlockedPhysicalVolume =
nullptr;
529 fBlockedReplicaNo = -1;
541 if( mRot !=
nullptr )
546 fGrandMotherExitNormal *= (*mRot);
547 fChangedGrandMotherRefFrame=
true;
551#ifdef G4DEBUG_NAVIGATION
555 G4cout <<
"*** G4Navigator::LocateGlobalPointAndSetup() ***" <<
G4endl;
563 fLastLocatedPointLocal = localPoint;
570 if (targetPhysical !=
nullptr) { curPhysVol_Name = targetPhysical->
GetName(); }
571 G4cout <<
" Return value = new volume = " << curPhysVol_Name <<
G4endl;
576 G4cout <<
"Upon exiting LocateGlobalPointAndSetup():" <<
G4endl;
579 G4cout.precision(oldcoutPrec);
583 fLocatedOutsideWorld =
false;
585 return targetPhysical;
604#ifdef G4DEBUG_NAVIGATION
611 fLastTriedStepComputation =
false;
612 fChangedGrandMotherRefFrame =
false;
636 fLastLocatedPointLocal );
645 fBlockedPhysicalVolume =
nullptr;
646 fBlockedReplicaNo = -1;
667 fSaveState.sExitNormal = fExitNormal;
668 fSaveState.sValidExitNormal = fValidExitNormal;
669 fSaveState.sExiting = fExiting;
670 fSaveState.sEntering = fEntering;
672 fSaveState.spBlockedPhysicalVolume = fBlockedPhysicalVolume;
673 fSaveState.sBlockedReplicaNo = fBlockedReplicaNo;
675 fSaveState.sLastStepWasZero =
static_cast<G4int>(fLastStepWasZero);
677 fSaveState.sLocatedOutsideWorld = fLocatedOutsideWorld;
678 fSaveState.sLastLocatedPointLocal = fLastLocatedPointLocal;
685 fSaveState.sPreviousSftOrigin = fPreviousSftOrigin;
686 fSaveState.sPreviousSafety = fPreviousSafety;
697 fExitNormal = fSaveState.sExitNormal;
698 fValidExitNormal = fSaveState.sValidExitNormal;
699 fExiting = fSaveState.sExiting;
700 fEntering = fSaveState.sEntering;
702 fBlockedPhysicalVolume = fSaveState.spBlockedPhysicalVolume;
703 fBlockedReplicaNo = fSaveState.sBlockedReplicaNo;
705 fLastStepWasZero = (fSaveState.sLastStepWasZero != 0);
707 fLocatedOutsideWorld = fSaveState.sLocatedOutsideWorld;
708 fLastLocatedPointLocal = fSaveState.sLastLocatedPointLocal;
714 fPreviousSftOrigin = fSaveState.sPreviousSftOrigin;
715 fPreviousSafety = fSaveState.sPreviousSafety;
751 const G4double pCurrentProposedStepLength,
754#ifdef G4DEBUG_NAVIGATION
768 fChangedGrandMotherRefFrame =
false;
771 fCalculatedExitNormal =
false;
777 G4cout <<
"*** G4Navigator::ComputeStep: ***" <<
G4endl;
779 <<
" - Proposed step length = " << pCurrentProposedStepLength
781#ifdef G4DEBUG_NAVIGATION
785 <<
" Globalpoint = " << std::setw(25) << pGlobalpoint <<
G4endl
786 <<
" Direction = " << std::setw(25) << pDirection <<
G4endl;
799 if( newLocalPoint != fLastLocatedPointLocal )
804 G4double moveLenSq = (newLocalPoint-oldLocalPoint).mag2();
806 if ( moveLenSq >=
fSqTol )
809 ComputeStepLog(pGlobalpoint, moveLenSq);
825 pCurrentProposedStepLength,
832 &fBlockedPhysicalVolume,
840 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
842 pCurrentProposedStepLength,
849 &fBlockedPhysicalVolume,
869 "Point is relocated in voxels, while it should be outside!");
870 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
872 pCurrentProposedStepLength,
879 &fBlockedPhysicalVolume,
885 ComputeStepSkippingEqualMaterials(fLastLocatedPointLocal,
887 pCurrentProposedStepLength,
894 &fBlockedPhysicalVolume,
904 Step = fparamNav.
ComputeStep(fLastLocatedPointLocal,
906 pCurrentProposedStepLength,
913 &fBlockedPhysicalVolume,
918 Step = fregularNav.
ComputeStep(fLastLocatedPointLocal,
920 pCurrentProposedStepLength,
927 &fBlockedPhysicalVolume,
932 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0001",
936 Step = fpExternalNav->
ComputeStep(fLastLocatedPointLocal,
938 pCurrentProposedStepLength,
945 &fBlockedPhysicalVolume,
958 fLastLocatedPointLocal,
960 pCurrentProposedStepLength,
964 fCalculatedExitNormal,
968 &fBlockedPhysicalVolume,
974 fPreviousSftOrigin = pGlobalpoint;
975 fPreviousSafety = pNewSafety;
987 fLocatedOnEdge = fLastStepWasZero && (Step==0.0);
997 G4bool act = fNumberZeroSteps >= fActionThreshold_NoZeroSteps;
998 G4bool actAndReport =
false;
999 G4bool abandon = fNumberZeroSteps >= fAbandonThreshold_NoZeroSteps;
1002 actAndReport = act && (!fPushed) && fWarnPush;
1004#ifdef G4DEBUG_NAVIGATION
1005 inform = fNumberZeroSteps > 1;
1008 if ( act || inform )
1010 if( act && !abandon )
1018 if( actAndReport || abandon || inform )
1020 std::ostringstream message;
1022 message.precision(16);
1023 message <<
"Stuck Track: potential geometry or navigation problem."
1025 message <<
" Track stuck, not moving for "
1026 << fNumberZeroSteps <<
" steps." <<
G4endl
1027 <<
" Current phys volume: '" << motherPhysical->
GetName()
1029 <<
" - at position : " << pGlobalpoint <<
G4endl
1030 <<
" in direction: " << pDirection <<
G4endl
1031 <<
" (local position: " << newLocalPoint <<
")" <<
G4endl
1032 <<
" (local direction: " << localDirection <<
")." <<
G4endl
1033 <<
" Previous phys volume: '"
1034 << ( fLastMotherPhys !=
nullptr ? fLastMotherPhys->
GetName() :
G4String(
"") )
1036 if( actAndReport || abandon )
1038 message <<
" Likely geometry overlap - else navigation problem !"
1047 message <<
" Track *abandoned* due to excessive number of Zero steps."
1049 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0003",
1057 message <<
" *** Trying to get *unstuck* using a push"
1058 <<
" - expanding step to " << Step <<
" (mm) ..."
1059 <<
" Potential overlap in geometry !" <<
G4endl;
1060 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav1002",
1064#ifdef G4DEBUG_NAVIGATION
1067 if( fNumberZeroSteps > 1 )
1069 message <<
", nav-comp-step calls # " << sNavCScalls
1070 <<
", Step= " << Step <<
G4endl;
1081 if (!fPushed) { fNumberZeroSteps = 0; }
1083 fLastMotherPhys = motherPhysical;
1089 + std::min(Step,pCurrentProposedStepLength) * pDirection;
1094#ifdef G4DEBUG_NAVIGATION
1097 G4cout <<
" At G4Nav CompStep End - if(exiting) - fExiting= " << fExiting
1098 <<
" fValidExitNormal = " << fValidExitNormal <<
G4endl;
1103 if ( fValidExitNormal || fCalculatedExitNormal )
1106 fGrandMotherExitNormal = fExitNormal;
1113 + localDirection*Step;
1125 if( mRot !=
nullptr )
1127 fChangedGrandMotherRefFrame =
true;
1128 fGrandMotherExitNormal = (*mRot).inverse() * exitNormalMotherFrame;
1132 fGrandMotherExitNormal = exitNormalMotherFrame;
1140 fCalculatedExitNormal =
false;
1147#ifdef G4DEBUG_NAVIGATION
1150 desc <<
"Problem in ComputeStep: Replica Navigation did not provide"
1151 <<
" valid exit Normal. " <<
G4endl;
1152 desc <<
" Do not know how calculate it in this case." <<
G4endl;
1153 desc <<
" Location = " << finalLocalPoint <<
G4endl;
1154 desc <<
" Volume name = " << motherPhysical->
GetName()
1156 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0003",
1157 JustWarning, desc,
"Normal not available for exiting.");
1164 fCalculatedExitNormal =
true;
1169 if( fValidExitNormal || fCalculatedExitNormal )
1179 fExitNormalGlobalFrame = fGrandMotherExitNormal;
1188 if( (Step == pCurrentProposedStepLength) && (!fExiting) && (!fEntering) )
1204 G4cout <<
" Returned step= " << Step;
1206 if( Step == kInfinity )
1208 G4cout <<
" Requested step= " << pCurrentProposedStepLength ;
1215 fLastTriedStepComputation =
true;
1228 const G4double pCurrentProposedStepLength,
1239 pCurrentProposedStepLength,
1264 fLocatedOnEdge =
false;
1265 fLastStepWasZero =
false;
1270 fValidExitNormal =
false;
1271 fChangedGrandMotherRefFrame =
false;
1272 fCalculatedExitNormal =
false;
1279 fPreviousSafety = 0.0;
1281 fNumberZeroSteps = 0;
1283 fBlockedPhysicalVolume =
nullptr;
1284 fBlockedReplicaNo = -1;
1286 fLastLocatedPointLocal =
G4ThreeVector( kInfinity, -kInfinity, 0.0 );
1287 fLocatedOutsideWorld =
false;
1289 fLastMotherPhys =
nullptr;
1303 for (
auto i = 1; i <= depth; ++i )
1341 ComputeMaterial(replicaNo, current, pTouchable) );
1361 if ( fLastTriedStepComputation )
1367 if( fEntering && (fBlockedPhysicalVolume!=
nullptr) )
1370 if( candidateLogical !=
nullptr )
1392 currentSolid = candidateLogical->
GetSolid();
1393 inSideIt = currentSolid->
Inside(daughterPointOwnLocal);
1394 onSurface = (inSideIt ==
kSurface);
1399 safety = (currentSolid->
DistanceToIn(daughterPointOwnLocal));
1402 else if (inSideIt ==
kInside )
1404 safety = (currentSolid->
DistanceToOut(daughterPointOwnLocal));
1411 nextSolidExitNormal =
1418 ExitNormal = MotherToDaughterTransform
1420 fCalculatedExitNormal =
true;
1425 if((
fVerbose == 1 ) && ( fCheck ))
1427 std::ostringstream message;
1428 message <<
"Point not on surface ! " <<
G4endl
1430 << daughterPointOwnLocal <<
G4endl
1431 <<
" Physical volume = "
1433 <<
" Logical volume = "
1435 <<
" Solid = " << currentSolid->
GetName()
1438 << *currentSolid <<
G4endl;
1441 message <<
"Point is Outside. " <<
G4endl
1442 <<
" Safety (from outside) = " << safety <<
G4endl;
1446 message <<
"Point is Inside. " <<
G4endl
1447 <<
" Safety (from inside) = " << safety <<
G4endl;
1449 G4Exception(
"G4Navigator::GetLocalExitNormal()",
"GeomNav1001",
1458 else if ( fExiting )
1460 ExitNormal = fGrandMotherExitNormal;
1462 fCalculatedExitNormal =
true;
1469 "Incorrect call to GetLocalSurfaceNormal." );
1478 ExitNormal = -(daughterSolid->
SurfaceNormal(fLastLocatedPointLocal));
1479 if( std::fabs(ExitNormal.
mag2()-1.0 ) > kToleranceNormalCheck )
1482 desc <<
" Parameters of solid: " << *daughterSolid
1483 <<
" Point for surface = " << fLastLocatedPointLocal << std::endl;
1486 "Surface Normal returned by Solid is not a Unit Vector." );
1488 fCalculatedExitNormal =
true;
1495 ExitNormal = fGrandMotherExitNormal;
1497 fCalculatedExitNormal =
true;
1502 fCalculatedExitNormal =
false;
1504 message <<
"Function called when *NOT* at a Boundary." <<
G4endl;
1505 message <<
"Exit Normal not calculated." <<
G4endl;
1522 G4int enteringReplicaNo,
1525 switch (enteringVolumeType)
1530 G4Exception(
"G4Navigator::GetMotherToDaughterTransform()",
1532 "Method NOT Implemented yet for replica volumes.");
1540 pParam->
ComputeSolid(enteringReplicaNo, pEnteringPhysVol);
1580#ifdef G4DEBUG_NAVIGATION
1583 if ( fLastTriedStepComputation )
1588 ExpectedBoundaryPointLocal =
1608 G4bool* pNormalCalculated)
1613 G4bool usingStored = fCalculatedExitNormal && (
1614 ( fLastTriedStepComputation && fExiting )
1616 ( !fLastTriedStepComputation
1626 globalNormal = fExitNormalGlobalFrame;
1628 if( std::fabs ( normMag2 - 1.0 ) < perThousand )
1630 *pNormalCalculated =
true;
1636 message.precision(10);
1637 message <<
" WARNING> Expected normal-global-frame to be valid, "
1638 <<
" i.e. a unit vector!" <<
G4endl
1639 <<
" - but |normal| = " << std::sqrt(normMag2)
1640 <<
" - and |normal|^2 = " << normMag2 <<
G4endl
1641 <<
" which differs from 1.0 by " << normMag2 - 1.0 <<
G4endl
1642 <<
" n = " << fExitNormalGlobalFrame <<
G4endl
1643 <<
" Global point: " << IntersectPointGlobal <<
G4endl
1647 if ( candLog !=
nullptr )
1654 message <<
"============================================================"
1658 message <<
" State of Navigator: " <<
G4endl;
1659 message << *
this <<
G4endl;
1661 message <<
"============================================================"
1666 "Value obtained from stored global-normal is not a unit vector.");
1672 *pNormalCalculated = fCalculatedExitNormal;
1680 *pNormalCalculated = fCalculatedExitNormal;
1682#ifdef G4DEBUG_NAVIGATION
1683 usingStored =
false;
1685 if( (!validNormal) && !fCalculatedExitNormal )
1688 edN <<
" Calculated = " << fCalculatedExitNormal <<
G4endl;
1689 edN <<
" Entering= " << fEntering <<
G4endl;
1692 edN <<
" State of Navigator: " <<
G4endl;
1698 "LocalExitNormalAndCheck() did not calculate Normal.");
1703 if( validNormal && (std::fabs(localMag2-1.0)) > kToleranceNormalCheck )
1707 edN <<
"G4Navigator::GetGlobalExitNormal: "
1708 <<
" Using Local Normal - from call to GetLocalExitNormalAndCheck. "
1710 <<
" Local Exit Normal : " <<
" || = " << std::sqrt(localMag2)
1711 <<
" vec = " << localNormal <<
G4endl
1712 <<
" Global Exit Normal : " <<
" || = " << globalNormal.
mag()
1713 <<
" vec = " << globalNormal <<
G4endl
1714 <<
" Global point: " << IntersectPointGlobal <<
G4endl;
1715 edN <<
" Calculated It = " << fCalculatedExitNormal <<
G4endl
1719 if ( candLog !=
nullptr )
1728 "Value obtained from new local *solid* is incorrect.");
1729 localNormal = localNormal.
unit();
1735#ifdef G4DEBUG_NAVIGATION
1746 G4ThreeVector diffNorm = globalNormAgn - fExitNormalGlobalFrame;
1747 if( diffNorm.
mag2() > kToleranceNormalCheck )
1750 edDfn <<
"Found difference in normals in case of exiting mother "
1751 <<
"- when Get is called after ComputingStep " <<
G4endl;
1752 edDfn <<
" Magnitude of diff = " << diffNorm.
mag() <<
G4endl;
1755 edDfn <<
" Global Computed from Local = " << globalNormAgn <<
G4endl;
1756 G4Exception(
"G4Navigator::GetGlobalExitNormal()",
"GeomNav0003",
1764 fExitNormalGlobalFrame = globalNormal;
1766 return globalNormal;
1789 G4bool onSurface = endpointOnSurface && stayedOnEndpoint;
1797 fPreviousSftOrigin = pGlobalpoint;
1798 fPreviousSafety = safety;
1823 G4cout <<
"The current state of G4Navigator is: " <<
G4endl;
1824 G4cout <<
" ValidExitNormal= " << fValidExitNormal
1825 <<
" ExitNormal = " << fExitNormal
1826 <<
" Exiting = " << fExiting
1827 <<
" Entering = " << fEntering
1828 <<
" BlockedPhysicalVolume= " ;
1829 if (fBlockedPhysicalVolume==
nullptr)
1838 <<
" BlockedReplicaNo = " << fBlockedReplicaNo
1839 <<
" LastStepWasZero = " << fLastStepWasZero
1845 G4cout << std::setw(30) <<
" ExitNormal " <<
" "
1846 << std::setw( 5) <<
" Valid " <<
" "
1847 << std::setw( 9) <<
" Exiting " <<
" "
1848 << std::setw( 9) <<
" Entering" <<
" "
1849 << std::setw(15) <<
" Blocked:Volume " <<
" "
1850 << std::setw( 9) <<
" ReplicaNo" <<
" "
1851 << std::setw( 8) <<
" LastStepZero " <<
" "
1853 G4cout <<
"( " << std::setw(7) << fExitNormal.
x()
1854 <<
", " << std::setw(7) << fExitNormal.
y()
1855 <<
", " << std::setw(7) << fExitNormal.
z() <<
" ) "
1856 << std::setw( 5) << fValidExitNormal <<
" "
1857 << std::setw( 9) << fExiting <<
" "
1858 << std::setw( 9) << fEntering <<
" ";
1859 if ( fBlockedPhysicalVolume ==
nullptr )
1860 {
G4cout << std::setw(15) <<
"None"; }
1862 {
G4cout << std::setw(15)<< fBlockedPhysicalVolume->
GetName(); }
1863 G4cout << std::setw( 9) << fBlockedReplicaNo <<
" "
1864 << std::setw( 8) << fLastStepWasZero <<
" "
1870 G4cout <<
" Current Localpoint = " << fLastLocatedPointLocal <<
G4endl;
1871 G4cout <<
" PreviousSftOrigin = " << fPreviousSftOrigin <<
G4endl;
1872 G4cout <<
" PreviousSafety = " << fPreviousSafety <<
G4endl;
1874 G4cout.precision(oldcoutPrec);
1881void G4Navigator::ComputeStepLog(
const G4ThreeVector& pGlobalpoint,
1891 InverseTransformPoint(fLastLocatedPointLocal);
1893 G4double shiftOriginSafSq = (fPreviousSftOrigin-pGlobalpoint).mag2();
1901 if( shiftOriginSafSq >=
sqr(fPreviousSafety) )
1903 G4double shiftOrigin = std::sqrt(shiftOriginSafSq);
1904 G4double diffShiftSaf = shiftOrigin - fPreviousSafety;
1906 if( diffShiftSaf > fAccuracyForWarning )
1910 std::ostringstream message, suggestion;
1911 message <<
"Accuracy error or slightly inaccurate position shift."
1913 <<
" The Step's starting point has moved "
1914 << std::sqrt(moveLenSq)/mm <<
" mm " <<
G4endl
1915 <<
" since the last call to a Locate method." <<
G4endl
1916 <<
" This has resulted in moving "
1917 << shiftOrigin/mm <<
" mm "
1918 <<
" from the last point at which the safety "
1919 <<
" was calculated " <<
G4endl
1920 <<
" which is more than the computed safety= "
1922 <<
" This difference is "
1923 << diffShiftSaf/mm <<
" mm." <<
G4endl
1924 <<
" The tolerated accuracy is "
1925 << fAccuracyForException/mm <<
" mm.";
1929 if( ((++warnNow % 100) == 1) )
1932 <<
" This problem can be due to either " <<
G4endl
1933 <<
" - a process that has proposed a displacement"
1934 <<
" larger than the current safety , or" <<
G4endl
1935 <<
" - inaccuracy in the computation of the safety";
1936 suggestion <<
"We suggest that you " <<
G4endl
1937 <<
" - find i) what particle is being tracked, and "
1938 <<
" ii) through what part of your geometry " <<
G4endl
1939 <<
" for example by re-running this event with "
1941 <<
" /tracking/verbose 1 " <<
G4endl
1942 <<
" - check which processes you declare for"
1943 <<
" this particle (and look at non-standard ones)"
1945 <<
" - in case, create a detailed logfile"
1946 <<
" of this event using:" <<
G4endl
1947 <<
" /tracking/verbose 6 ";
1951 message,
G4String(suggestion.str()));
1952 G4cout.precision(oldcoutPrec);
1953 G4cerr.precision(oldcerrPrec);
1955#ifdef G4DEBUG_NAVIGATION
1958 G4cerr <<
"WARNING - G4Navigator::ComputeStep()" <<
G4endl
1959 <<
" The Step's starting point has moved "
1960 << std::sqrt(moveLenSq) <<
"," <<
G4endl
1961 <<
" which has taken it to the limit of"
1962 <<
" the current safety. " <<
G4endl;
1967 if ( shiftOriginSafSq >
sqr(safetyPlus) )
1969 std::ostringstream message;
1970 message <<
"May lead to a crash or unreliable results." <<
G4endl
1971 <<
" Position has shifted considerably without"
1972 <<
" notifying the navigator !" <<
G4endl
1973 <<
" Tolerated safety: " << safetyPlus <<
G4endl
1974 <<
" Computed shift : " << shiftOriginSafSq;
1975 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav1002",
1988 G4bool foundOverlap =
false;
1989 G4int nPoints = 300000, ntrials = 9, numOverlaps = 5;
1990 G4double trialLength = 1.0 * CLHEP::centimeter;
1991 while ( ntrials-- > 0 && !foundOverlap )
1995 G4cout <<
" ** Running overlap checks in volume "
1997 <<
" with length = " << trialLength <<
G4endl;
2002 if ( trialLength <= 1.0e-5 ) { numOverlaps= 1;}
2004 return foundOverlap;
2019 G4long oldcoutPrec = os.precision(4);
2020 if( n.fVerbose >= 4 )
2022 os <<
"The current state of G4Navigator is: " <<
G4endl;
2023 os <<
" ValidExitNormal= " << n.fValidExitNormal <<
G4endl
2024 <<
" ExitNormal = " << n.fExitNormal <<
G4endl
2025 <<
" Exiting = " << n.fExiting <<
G4endl
2026 <<
" Entering = " << n.fEntering <<
G4endl
2027 <<
" BlockedPhysicalVolume= " ;
2028 if (n.fBlockedPhysicalVolume==
nullptr)
2034 os << n.fBlockedPhysicalVolume->GetName();
2037 <<
" BlockedReplicaNo = " << n.fBlockedReplicaNo <<
G4endl
2038 <<
" LastStepWasZero = " << n.fLastStepWasZero <<
G4endl
2041 if( ( 1 < n.fVerbose) && (n.fVerbose < 4) )
2044 os << std::setw(30) <<
" ExitNormal " <<
" "
2045 << std::setw( 5) <<
" Valid " <<
" "
2046 << std::setw( 9) <<
" Exiting " <<
" "
2047 << std::setw( 9) <<
" Entering" <<
" "
2048 << std::setw(15) <<
" Blocked:Volume " <<
" "
2049 << std::setw( 9) <<
" ReplicaNo" <<
" "
2050 << std::setw( 8) <<
" LastStepZero " <<
" "
2052 os <<
"( " << std::setw(7) << n.fExitNormal.x()
2053 <<
", " << std::setw(7) << n.fExitNormal.y()
2054 <<
", " << std::setw(7) << n.fExitNormal.z() <<
" ) "
2055 << std::setw( 5) << n.fValidExitNormal <<
" "
2056 << std::setw( 9) << n.fExiting <<
" "
2057 << std::setw( 9) << n.fEntering <<
" ";
2058 if ( n.fBlockedPhysicalVolume==
nullptr )
2059 { os << std::setw(15) <<
"None"; }
2061 { os << std::setw(15)<< n.fBlockedPhysicalVolume->GetName(); }
2062 os << std::setw( 9) << n.fBlockedReplicaNo <<
" "
2063 << std::setw( 8) << n.fLastStepWasZero <<
" "
2066 if( n.fVerbose > 2 )
2069 os <<
" Current Localpoint = " << n.fLastLocatedPointLocal <<
G4endl;
2070 os <<
" PreviousSftOrigin = " << n.fPreviousSftOrigin <<
G4endl;
2071 os <<
" PreviousSafety = " << n.fPreviousSafety <<
G4endl;
2073 if( n.fVerbose > 3 || n.fVerbose == 0 )
2075 os <<
"Current History: " <<
G4endl << n.fHistory;
2078 os.precision(oldcoutPrec);
2089 fpvoxelNav = voxelNav;
2099 G4bool zeroStep = ( lastStep == 0.0 );
2100 fLocatedOnEdge = fLastStepWasZero && zeroStep;
2101 fLastStepWasZero = zeroStep;
2103 fExiting = exitsMotherVol;
2104 fEntering = entersDaughtVol;
2113 fpExternalNav = externalNav;
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< G4VTouchable > G4TouchableHandle
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
void SetExternalNavigation(G4VExternalNavigation *externalNav)
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
G4VoxelNavigation & GetVoxelNavigator()
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)
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
virtual G4TouchableHandle CreateTouchableHistoryHandle() const
const G4AffineTransform & GetGlobalToLocalTransform() const
G4bool LevelLocate(G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint) final
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
void RelocateWithinVolume(G4VPhysicalVolume *motherPhysical, const G4ThreeVector &localPoint) override
G4bool LevelLocate(G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint) 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
G4bool LevelLocate(G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint) final
void SetNormalNavigation(G4NormalNavigation *fnormnav)
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)
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
void SetExternalNavigation(G4VExternalNavigation *externalNav)
G4double SafetyInCurrentVolume(const G4ThreeVector &globalpoint, G4VPhysicalVolume *physicalVolume, const G4double pProposedMaxLength=DBL_MAX, G4bool verbose=false)
virtual G4int MoveUpHistory(G4int num_levels=1)
virtual const G4NavigationHistory * GetHistory() const
virtual void RelocateWithinVolume(G4VPhysicalVolume *motherPhysical, const G4ThreeVector &localPoint)
virtual EInside Inside(const G4VSolid *solid, const G4ThreeVector &position, const G4ThreeVector &direction)
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 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 G4bool LevelLocate(G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint) override
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
virtual void RelocateWithinVolume(G4VPhysicalVolume *motherPhysical, const G4ThreeVector &localPoint) override