52#define G4DEBUG_NAVIGATION 1
62 fLastTriedStepComputation=
false;
71 fActionThreshold_NoZeroSteps = 10;
72 fAbandonThreshold_NoZeroSteps = 25;
81 fpSaveState =
nullptr;
89G4ITNavigator1::G4SaveNavigatorState::G4SaveNavigatorState()
91 sWasLimitedByGeometry =
false;
94 sLocatedOnEdge =
false;
96 sEnteredDaughter =
false;
97 sExitedMother =
false;
100 sValidExitNormal =
false;
104 sPreviousSafety = 0.0;
106 sNumberZeroSteps = 0;
108 spBlockedPhysicalVolume =
nullptr;
109 sBlockedReplicaNo = -1;
111 sLastLocatedPointLocal =
G4ThreeVector( kInfinity, -kInfinity, 0.0 );
112 sLocatedOutsideWorld =
false;
122{
delete fpVoxelSafety; }
136 fLastTriedStepComputation=
false;
159 const G4bool relativeSearch,
160 const G4bool ignoreDirection )
162 G4bool notKnownContained=
true, noResult;
169 G4bool considerDirection = (!ignoreDirection) || fLocatedOnEdge;
171 fLastTriedStepComputation=
false;
172 fChangedGrandMotherRefFrame=
false;
174 if( considerDirection && pGlobalDirection !=
nullptr )
176 globalDirection=*pGlobalDirection;
184 G4cout <<
"*** G4ITNavigator1::LocateGlobalPointAndSetup: ***" <<
G4endl;
186 <<
" Globalpoint = " << globalPoint <<
G4endl
187 <<
" RelativeSearch = " << relativeSearch <<
G4endl;
193 G4cout.precision(oldcoutPrec);
197 if ( !relativeSearch )
218 fLastLocatedPointLocal = localPoint;
219 fLocatedOutsideWorld =
true;
243 fBlockedPhysicalVolume);
246 fBlockedPhysicalVolume->
SetCopyNo(fBlockedReplicaNo);
256 fBlockedPhysicalVolume);
258 fBlockedPhysicalVolume);
260 fBlockedPhysicalVolume);
263 fBlockedPhysicalVolume->
SetCopyNo(fBlockedReplicaNo);
271 ComputeMaterial(fBlockedReplicaNo,
272 fBlockedPhysicalVolume,
277 G4Exception(
"G4ITNavigator1::LocateGlobalPointAndSetup()",
279 "Not applicable for external volumes.");
283 fBlockedPhysicalVolume =
nullptr;
285 notKnownContained =
false;
290 fBlockedPhysicalVolume =
nullptr;
306 G4int noLevelsExited=0 ;
308 while (notKnownContained)
314 insideCode = targetSolid->
Inside(localPoint);
318 G4String solidResponse =
"-kInside-";
320 solidResponse =
"-kOutside-";
322 solidResponse =
"-kSurface-";
323 G4cout <<
"*** G4ITNavigator1::LocateGlobalPointAndSetup(): ***" <<
G4endl
324 <<
" Invoked Inside() for solid: " << targetSolid->
GetName()
325 <<
". Solid replied: " << solidResponse <<
G4endl
326 <<
" For local point p: " << localPoint <<
G4endl;
333 fExiting, notKnownContained);
351 if( noLevelsExited > 1 )
356 if( mRot !=
nullptr )
358 fGrandMotherExitNormal *= (*mRot).inverse();
359 fChangedGrandMotherRefFrame=
true;
365 fLastLocatedPointLocal = localPoint;
366 fLocatedOutsideWorld =
true;
374 G4bool isExiting = fExiting;
375 if( (!fExiting)&&considerDirection )
380 G4bool directionExiting =
false;
391 directionExiting = normal.
dot(localDirection) > 0.0;
392 isExiting = isExiting || directionExiting;
406 fValidExitNormal =
false;
408 if( noLevelsExited > 1 )
413 if( mRot !=
nullptr )
415 fGrandMotherExitNormal *= (*mRot).inverse();
416 fChangedGrandMotherRefFrame=
true;
422 fLastLocatedPointLocal = localPoint;
423 fLocatedOutsideWorld =
true;
430 notKnownContained=
false;
435 notKnownContained=
false;
456 if (targetPhysical ==
nullptr) {
break; }
464 fBlockedPhysicalVolume,
474 fBlockedPhysicalVolume,
484 fBlockedPhysicalVolume,
495 fBlockedPhysicalVolume,
505 fBlockedPhysicalVolume,
514 G4Exception(
"G4ITNavigator1::LocateGlobalPointAndSetup()",
516 "Not applicable for external volumes.");
529 fBlockedPhysicalVolume =
nullptr;
530 fBlockedReplicaNo = -1;
542 if( mRot !=
nullptr )
544 fGrandMotherExitNormal *= (*mRot).inverse();
548#ifdef G4DEBUG_NAVIGATION
552 G4cout <<
"*** G4ITNavigator1::LocateGlobalPointAndSetup() ***" <<
G4endl;
560 fLastLocatedPointLocal = localPoint;
567 if (targetPhysical !=
nullptr) { curPhysVol_Name = targetPhysical->
GetName(); }
568 G4cout <<
" Return value = new volume = " << curPhysVol_Name <<
G4endl;
573 G4cout <<
"Upon exiting LocateGlobalPointAndSetup():" <<
G4endl;
576 G4cout.precision(oldcoutPrec);
580 fLocatedOutsideWorld=
false;
582 return targetPhysical;
602 fLastTriedStepComputation=
false;
603 fChangedGrandMotherRefFrame=
false;
605#ifdef G4DEBUG_NAVIGATION
608 G4cout <<
"Entering LocateGlobalWithinVolume(): History = " <<
G4endl;
628 if ( pVoxelHeader !=
nullptr )
630 fvoxelNav.
VoxelLocate( pVoxelHeader, fLastLocatedPointLocal );
642 G4Exception(
"G4ITNavigator1::LocateGlobalPointWithinVolume()",
644 "Not applicable for replicated volumes.");
647 G4Exception(
"G4ITNavigator1::LocateGlobalPointWithinVolume()",
649 "Not applicable for external volumes.");
659 fBlockedPhysicalVolume =
nullptr;
660 fBlockedReplicaNo = -1;
676 fpSaveState = (G4SaveNavigatorState*) navState;
682 fpSaveState =
new G4SaveNavigatorState();
707 fpSaveState->sExitNormal = fExitNormal;
708 fpSaveState->sValidExitNormal = fValidExitNormal;
709 fpSaveState->sExiting = fExiting;
710 fpSaveState->sEntering = fEntering;
712 fpSaveState->spBlockedPhysicalVolume = fBlockedPhysicalVolume;
713 fpSaveState->sBlockedReplicaNo = fBlockedReplicaNo,
715 fpSaveState->sLastStepWasZero =
static_cast<G4int>(fLastStepWasZero);
718 fpSaveState->sPreviousSftOrigin = fPreviousSftOrigin;
719 fpSaveState->sPreviousSafety = fPreviousSafety;
720 fpSaveState->sNumberZeroSteps = fNumberZeroSteps;
721 fpSaveState->sLocatedOnEdge = fLocatedOnEdge;
723 fpSaveState->sPushed=fPushed;
724 fpSaveState->sNumberZeroSteps=fNumberZeroSteps;
728 fpSaveState->sLastLocatedPointLocal = fLastLocatedPointLocal;
729 fpSaveState->sLocatedOutsideWorld = fLocatedOutsideWorld;
741 fExitNormal = fpSaveState->sExitNormal;
742 fValidExitNormal = fpSaveState->sValidExitNormal;
743 fExiting = fpSaveState->sExiting;
744 fEntering = fpSaveState->sEntering;
746 fBlockedPhysicalVolume = fpSaveState->spBlockedPhysicalVolume;
747 fBlockedReplicaNo = fpSaveState->sBlockedReplicaNo,
749 fLastStepWasZero = (fpSaveState->sLastStepWasZero != 0);
752 fPreviousSftOrigin = fpSaveState->sPreviousSftOrigin ;
753 fPreviousSafety = fpSaveState->sPreviousSafety ;
754 fNumberZeroSteps = fpSaveState->sNumberZeroSteps ;
755 fLocatedOnEdge = fpSaveState->sLocatedOnEdge ;
757 fPushed = fpSaveState->sPushed;
758 fNumberZeroSteps = fpSaveState->sNumberZeroSteps;
762 fLastLocatedPointLocal = fpSaveState->sLastLocatedPointLocal ;
763 fLocatedOutsideWorld = fpSaveState->sLocatedOutsideWorld;
801 const G4double pCurrentProposedStepLength,
813 fChangedGrandMotherRefFrame=
false;
816 fCalculatedExitNormal =
false;
822 fLastTriedStepComputation=
true;
827 G4cout <<
"*** G4ITNavigator1::ComputeStep: ***" <<
G4endl;
829 <<
" - Proposed step length = " << pCurrentProposedStepLength
831#ifdef G4DEBUG_NAVIGATION
835 <<
" Globalpoint = " << std::setw(25) << pGlobalpoint <<
G4endl
836 <<
" Direction = " << std::setw(25) << pDirection <<
G4endl;
848 if( newLocalPoint != fLastLocatedPointLocal )
853 G4double moveLenSq = (newLocalPoint-oldLocalPoint).mag2();
858 ComputeStepLog(pGlobalpoint, moveLenSq);
863 fLastTriedStepComputation=
true;
873 Step = fvoxelNav.
ComputeStep(fLastLocatedPointLocal,
875 pCurrentProposedStepLength,
882 &fBlockedPhysicalVolume,
890 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
892 pCurrentProposedStepLength,
899 &fBlockedPhysicalVolume,
905 fLastTriedStepComputation=
true;
920 "Point is relocated in voxels, while it should be outside!");
921 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
923 pCurrentProposedStepLength,
930 &fBlockedPhysicalVolume,
936 ComputeStepSkippingEqualMaterials(fLastLocatedPointLocal,
938 pCurrentProposedStepLength,
945 &fBlockedPhysicalVolume,
955 Step = fparamNav.
ComputeStep(fLastLocatedPointLocal,
957 pCurrentProposedStepLength,
964 &fBlockedPhysicalVolume,
969 Step = fregularNav.
ComputeStep(fLastLocatedPointLocal,
971 pCurrentProposedStepLength,
978 &fBlockedPhysicalVolume,
983 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav0001",
987 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav0001",
998 G4bool calculatedExitNormal=
false;
1002 fLastLocatedPointLocal,
1004 pCurrentProposedStepLength,
1008 calculatedExitNormal,
1012 &fBlockedPhysicalVolume,
1014 fExiting= exitingReplica;
1015 fCalculatedExitNormal= calculatedExitNormal;
1020 fPreviousSftOrigin = pGlobalpoint;
1021 fPreviousSafety = pNewSafety;
1033 fLocatedOnEdge = fLastStepWasZero && (Step==0.0);
1034 fLastStepWasZero = (Step==0.0);
1042#ifdef G4DEBUG_NAVIGATION
1043 if( fNumberZeroSteps > 1 )
1045 G4cout <<
"G4ITNavigator1::ComputeStep(): another zero step, # "
1047 <<
" at " << pGlobalpoint
1048 <<
" in volume " << motherPhysical->
GetName()
1049 <<
" nav-comp-step calls # " << sNavCScalls
1053 if( fNumberZeroSteps > fActionThreshold_NoZeroSteps-1 )
1059 if ((!fPushed) && (fWarnPush))
1061 std::ostringstream message;
1062 message <<
"Track stuck or not moving." <<
G4endl
1063 <<
" Track stuck, not moving for "
1064 << fNumberZeroSteps <<
" steps" <<
G4endl
1065 <<
" in volume -" << motherPhysical->
GetName()
1066 <<
"- at point " << pGlobalpoint <<
G4endl
1067 <<
" direction: " << pDirection <<
"." <<
G4endl
1068 <<
" Potential geometry or navigation problem !"
1070 <<
" Trying pushing it of " << Step <<
" mm ...";
1071 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav1002",
1072 JustWarning, message,
"Potential overlap in geometry!");
1077 if( fNumberZeroSteps > fAbandonThreshold_NoZeroSteps-1 )
1081 std::ostringstream message;
1082 message <<
"Stuck Track: potential geometry or navigation problem."
1084 <<
" Track stuck, not moving for "
1085 << fNumberZeroSteps <<
" steps" <<
G4endl
1086 <<
" in volume -" << motherPhysical->
GetName()
1087 <<
"- at point " << pGlobalpoint <<
G4endl
1088 <<
" direction: " << pDirection <<
".";
1090 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav0003",
1096 if (!fPushed) fNumberZeroSteps = 0;
1107#ifdef G4DEBUG_NAVIGATION
1110 G4cout <<
" At G4Nav CompStep End - if(exiting) - fExiting= " << fExiting
1111 <<
" fValidExitNormal = " << fValidExitNormal <<
G4endl;
1116 if(fValidExitNormal || fCalculatedExitNormal)
1122 fGrandMotherExitNormal= fExitNormal;
1123 fCalculatedExitNormal=
true;
1127 fGrandMotherExitNormal = fExitNormal;
1135 fLastLocatedPointLocal + localDirection*Step;
1147 if( mRot !=
nullptr )
1149 fChangedGrandMotherRefFrame=
true;
1150 fGrandMotherExitNormal = (*mRot).inverse() * exitNormalMotherFrame;
1154 fGrandMotherExitNormal = exitNormalMotherFrame;
1160 fCalculatedExitNormal=
true;
1164 fCalculatedExitNormal =
false;
1171#ifdef G4DEBUG_NAVIGATION
1174 desc <<
"Problem in ComputeStep: Replica Navigation did not provide"
1175 <<
" valid exit Normal. " <<
G4endl;
1176 desc <<
" Do not know how calculate it in this case." <<
G4endl;
1177 desc <<
" Location = " << finalLocalPoint <<
G4endl;
1178 desc <<
" Volume name = " << motherPhysical->
GetName()
1180 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav0003",
1181 JustWarning, desc,
"Normal not available for exiting.");
1188 if( fValidExitNormal || fCalculatedExitNormal )
1195 fExitNormalGlobalFrame =
1196 GrandMotherToGlobalTransf.
TransformAxis( fGrandMotherExitNormal );
1200 fExitNormalGlobalFrame= fGrandMotherExitNormal;
1210 if( (Step == pCurrentProposedStepLength) && (!fExiting) && (!fEntering) )
1226 G4cout <<
" Returned step= " << Step;
1228 if( Step == kInfinity )
1230 G4cout <<
" Requested step= " << pCurrentProposedStepLength ;
1248 const G4double pCurrentProposedStepLength,
1259 pCurrentProposedStepLength,
1280 fLocatedOnEdge =
false;
1281 fLastStepWasZero =
false;
1286 fValidExitNormal =
false;
1287 fChangedGrandMotherRefFrame=
false;
1288 fCalculatedExitNormal =
false;
1295 fPreviousSafety = 0.0;
1297 fNumberZeroSteps = 0;
1299 fBlockedPhysicalVolume =
nullptr;
1300 fBlockedReplicaNo = -1;
1302 fLastLocatedPointLocal =
G4ThreeVector( kInfinity, -kInfinity, 0.0 );
1303 fLocatedOutsideWorld =
false;
1322 for ( i=1; i<=cdepth; i++ )
1351 ComputeMaterial(replicaNo, current, &touchable) );
1357 "Not applicable for external volumes.");
1375 if ( fLastTriedStepComputation )
1381 if( fEntering && (fBlockedPhysicalVolume!=
nullptr) )
1384 if( candidateLogical !=
nullptr )
1406 currentSolid= candidateLogical->
GetSolid();
1407 inSideIt = currentSolid->
Inside(daughterPointOwnLocal);
1408 onSurface = (inSideIt ==
kSurface);
1413 safety = (currentSolid->
DistanceToIn(daughterPointOwnLocal));
1416 else if (inSideIt ==
kInside )
1418 safety = (currentSolid->
DistanceToOut(daughterPointOwnLocal));
1425 nextSolidExitNormal =
1430 ExitNormal = -nextSolidExitNormal;
1431 fCalculatedExitNormal=
true;
1436 if((
fVerbose == 1 ) && ( fCheck ))
1438 std::ostringstream message;
1439 message <<
"Point not on surface ! " <<
G4endl
1441 << daughterPointOwnLocal <<
G4endl
1442 <<
" Physical volume = "
1444 <<
" Logical volume = "
1446 <<
" Solid = " << currentSolid->
GetName()
1449 << *currentSolid <<
G4endl;
1452 message <<
"Point is Outside. " <<
G4endl
1453 <<
" Safety (from outside) = " << safety <<
G4endl;
1457 message <<
"Point is Inside. " <<
G4endl
1458 <<
" Safety (from inside) = " << safety <<
G4endl;
1460 G4Exception(
"G4ITNavigator1::GetLocalExitNormal()",
"GeomNav1001",
1469 else if ( fExiting )
1471 ExitNormal = fGrandMotherExitNormal;
1473 fCalculatedExitNormal=
true;
1478 G4Exception(
"G4ITNavigator1::GetLocalExitNormal()",
1480 "Incorrect call to GetLocalSurfaceNormal." );
1489 ExitNormal= -(daughterSolid->
SurfaceNormal(fLastLocatedPointLocal));
1490 if( std::fabs(ExitNormal.
mag2()-1.0 ) > CLHEP::perMillion )
1493 desc <<
" Parameters of solid: " << *daughterSolid
1494 <<
" Point for surface = " << fLastLocatedPointLocal << std::endl;
1495 G4Exception(
"G4ITNavigator1::GetLocalExitNormal()",
1497 "Surface Normal returned by Solid is not a Unit Vector." );
1499 fCalculatedExitNormal=
true;
1506 ExitNormal = fGrandMotherExitNormal;
1508 fCalculatedExitNormal=
true;
1513 fCalculatedExitNormal=
false;
1515 message <<
"Function called when *NOT* at a Boundary." <<
G4endl;
1516 G4Exception(
"G4ITNavigator1::GetLocalExitNormal()",
1532 G4int enteringReplicaNo,
1535 switch (enteringVolumeType)
1540 G4Exception(
"G4ITNavigator1::GetMotherToDaughterTransform()",
1542 "Method NOT Implemented yet for replica volumes.");
1550 pParam->
ComputeSolid(enteringReplicaNo, pEnteringPhysVol);
1564 G4Exception(
"G4ITNavigator1::GetMotherToDaughterTransform()",
1566 "Not applicable for external volumes.");
1590#ifdef G4DEBUG_NAVIGATION
1593 if ( fLastTriedStepComputation )
1598 ExpectedBoundaryPointLocal =
1618 G4bool* pNormalCalculated)
1623 if( fLastTriedStepComputation && fExiting )
1627 globalNormal = fExitNormalGlobalFrame;
1628 *pNormalCalculated =
true;
1634 *pNormalCalculated = fCalculatedExitNormal;
1636#ifdef G4DEBUG_NAVIGATION
1637 if( (!validNormal) && !fCalculatedExitNormal)
1640 edN <<
" Calculated = " << fCalculatedExitNormal <<
G4endl;
1641 edN <<
" Entering= " << fEntering <<
G4endl;
1644 edN <<
" State of Navigator: " <<
G4endl;
1648 G4Exception(
"G4ITNavigator1::GetGlobalExitNormal()",
1650 "LocalExitNormalAndCheck() did not calculate Normal.");
1655 if( validNormal && (std::fabs(localMag2-1.0)) > CLHEP::perMillion )
1659 edN <<
"G4ITNavigator1::GetGlobalExitNormal: "
1660 <<
" Using Local Normal - from call to GetLocalExitNormalAndCheck. "
1662 <<
" Local Exit Normal = " << localNormal <<
" || = "
1663 << std::sqrt(localMag2) <<
G4endl
1664 <<
" Global Exit Normal = " << globalNormal <<
" || = "
1666 edN <<
" Calculated It = " << fCalculatedExitNormal <<
G4endl;
1668 G4Exception(
"G4ITNavigator1::GetGlobalExitNormal()",
1670 "Value obtained from new local *solid* is incorrect.");
1671 localNormal = localNormal.
unit();
1677#ifdef G4DEBUG_NAVIGATION
1679 if( fLastTriedStepComputation && fExiting)
1682 *pNormalCalculated = fCalculatedExitNormal;
1688 G4ThreeVector diffNorm = globalNormal - fExitNormalGlobalFrame;
1689 if( diffNorm.
mag2() > perMillion*CLHEP::perMillion)
1692 edDfn <<
"Found difference in normals in case of exiting mother "
1693 <<
"- when Get is called after ComputingStep " <<
G4endl;
1694 edDfn <<
" Magnitude of diff = " << diffNorm.
mag() <<
G4endl;
1697 edDfn <<
" Global Computed from Local = " << globalNormal <<
G4endl;
1698 G4Exception(
"G4ITNavigator1::GetGlobalExitNormal()",
"GeomNav0003",
1704 return globalNormal;
1708#define G4NEW_SAFETY 1
1725#ifdef G4DEBUG_NAVIGATION
1729 G4cout <<
"*** G4ITNavigator1::ComputeSafety: ***" <<
G4endl
1730 <<
" Called at point: " << pGlobalpoint <<
G4endl;
1734 <<
" - Maximum length = " << pMaxLength <<
G4endl;
1737 G4cout <<
" ----- Upon entering Compute Safety:" <<
G4endl;
1749 if( !(endpointOnSurface && stayedOnEndpoint) )
1762#ifdef G4DEBUG_NAVIGATION
1765 G4cout <<
" G4ITNavigator1::ComputeSafety() relocates-in-volume to point: "
1766 << pGlobalpoint <<
G4endl;
1779 if ( pVoxelHeader !=
nullptr )
1783 *motherPhysical, pMaxLength);
1784 newSafety= safetyTwo;
1789 newSafety= safetyOldVoxel;
1808 G4Exception(
"G4ITNavigator1::ComputeSafety()",
"GeomNav0001",
1814 "Not applicable for external volumes.");
1820 newSafety = freplicaNav.
ComputeSafety(pGlobalpoint, localPoint,
1826#ifdef G4DEBUG_NAVIGATION
1829 G4cout <<
" G4ITNavigator1::ComputeSafety() finds that point - "
1830 << pGlobalpoint <<
" - is on surface " <<
G4endl;
1842 fPreviousSftOrigin = pGlobalpoint;
1843 fPreviousSafety = newSafety;
1847#ifdef G4DEBUG_NAVIGATION
1852 G4cout <<
" Returned value of Safety = " << newSafety <<
G4endl;
1854 G4cout.precision(oldcoutPrec);
1878 G4cout <<
"The current state of G4ITNavigator1 is: " <<
G4endl;
1879 G4cout <<
" ValidExitNormal= " << fValidExitNormal <<
G4endl
1880 <<
" ExitNormal = " << fExitNormal <<
G4endl
1881 <<
" Exiting = " << fExiting <<
G4endl
1882 <<
" Entering = " << fEntering <<
G4endl
1883 <<
" BlockedPhysicalVolume= " ;
1884 if (fBlockedPhysicalVolume==
nullptr)
1889 <<
" BlockedReplicaNo = " << fBlockedReplicaNo <<
G4endl
1890 <<
" LastStepWasZero = " << fLastStepWasZero <<
G4endl
1896 G4cout << std::setw(30) <<
" ExitNormal " <<
" "
1897 << std::setw( 5) <<
" Valid " <<
" "
1898 << std::setw( 9) <<
" Exiting " <<
" "
1899 << std::setw( 9) <<
" Entering" <<
" "
1900 << std::setw(15) <<
" Blocked:Volume " <<
" "
1901 << std::setw( 9) <<
" ReplicaNo" <<
" "
1902 << std::setw( 8) <<
" LastStepZero " <<
" "
1904 G4cout <<
"( " << std::setw(7) << fExitNormal.
x()
1905 <<
", " << std::setw(7) << fExitNormal.
y()
1906 <<
", " << std::setw(7) << fExitNormal.
z() <<
" ) "
1907 << std::setw( 5) << fValidExitNormal <<
" "
1908 << std::setw( 9) << fExiting <<
" "
1909 << std::setw( 9) << fEntering <<
" ";
1910 if ( fBlockedPhysicalVolume==
nullptr )
1912 G4cout << std::setw(15) <<
"None";
1916 G4cout << std::setw(15)<< fBlockedPhysicalVolume->
GetName();
1918 G4cout << std::setw( 9) << fBlockedReplicaNo <<
" "
1919 << std::setw( 8) << fLastStepWasZero <<
" "
1925 G4cout <<
" Current Localpoint = " << fLastLocatedPointLocal <<
G4endl;
1926 G4cout <<
" PreviousSftOrigin = " << fPreviousSftOrigin <<
G4endl;
1927 G4cout <<
" PreviousSafety = " << fPreviousSafety <<
G4endl;
1929 G4cout.precision(oldcoutPrec);
1936void G4ITNavigator1::ComputeStepLog(
const G4ThreeVector& pGlobalpoint,
1946 TransformPoint(fLastLocatedPointLocal);
1948 G4double shiftOriginSafSq = (fPreviousSftOrigin-pGlobalpoint).mag2();
1956 if( shiftOriginSafSq >=
sqr(fPreviousSafety) )
1958 G4double shiftOrigin = std::sqrt(shiftOriginSafSq);
1959 G4double diffShiftSaf = shiftOrigin - fPreviousSafety;
1961 if( diffShiftSaf > fAccuracyForWarning )
1965 std::ostringstream message, suggestion;
1966 message <<
"Accuracy error or slightly inaccurate position shift."
1968 <<
" The Step's starting point has moved "
1969 << std::sqrt(moveLenSq)/mm <<
" mm " <<
G4endl
1970 <<
" since the last call to a Locate method." <<
G4endl
1971 <<
" This has resulted in moving "
1972 << shiftOrigin/mm <<
" mm "
1973 <<
" from the last point at which the safety "
1974 <<
" was calculated " <<
G4endl
1975 <<
" which is more than the computed safety= "
1977 <<
" This difference is "
1978 << diffShiftSaf/mm <<
" mm." <<
G4endl
1979 <<
" The tolerated accuracy is "
1980 << fAccuracyForException/mm <<
" mm.";
1984 if( ((++warnNow % 100) == 1) )
1987 <<
" This problem can be due to either " <<
G4endl
1988 <<
" - a process that has proposed a displacement"
1989 <<
" larger than the current safety , or" <<
G4endl
1990 <<
" - inaccuracy in the computation of the safety";
1991 suggestion <<
"We suggest that you " <<
G4endl
1992 <<
" - find i) what particle is being tracked, and "
1993 <<
" ii) through what part of your geometry " <<
G4endl
1994 <<
" for example by re-running this event with "
1996 <<
" /tracking/verbose 1 " <<
G4endl
1997 <<
" - check which processes you declare for"
1998 <<
" this particle (and look at non-standard ones)"
2000 <<
" - in case, create a detailed logfile"
2001 <<
" of this event using:" <<
G4endl
2002 <<
" /tracking/verbose 6 ";
2006 message,
G4String(suggestion.str()));
2007 G4cout.precision(oldcoutPrec);
2008 G4cerr.precision(oldcerrPrec);
2010#ifdef G4DEBUG_NAVIGATION
2013 G4cerr <<
"WARNING - G4ITNavigator1::ComputeStep()" <<
G4endl
2014 <<
" The Step's starting point has moved "
2015 << std::sqrt(moveLenSq) <<
"," <<
G4endl
2016 <<
" which has taken it to the limit of"
2017 <<
" the current safety. " <<
G4endl;
2022 if ( shiftOriginSafSq >
sqr(safetyPlus) )
2024 std::ostringstream message;
2025 message <<
"May lead to a crash or unreliable results." <<
G4endl
2026 <<
" Position has shifted considerably without"
2027 <<
" notifying the navigator !" <<
G4endl
2028 <<
" Tolerated safety: " << safetyPlus <<
G4endl
2029 <<
" Computed shift : " << shiftOriginSafSq;
2030 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav1002",
2047 G4long oldcoutPrec = os.precision(4);
2048 if( n.fVerbose >= 4 )
2050 os <<
"The current state of G4ITNavigator1 is: " <<
G4endl;
2051 os <<
" ValidExitNormal= " << n.fValidExitNormal <<
G4endl
2052 <<
" ExitNormal = " << n.fExitNormal <<
G4endl
2053 <<
" Exiting = " << n.fExiting <<
G4endl
2054 <<
" Entering = " << n.fEntering <<
G4endl
2055 <<
" BlockedPhysicalVolume= " ;
2056 if (n.fBlockedPhysicalVolume==
nullptr)
2059 os << n.fBlockedPhysicalVolume->GetName();
2061 <<
" BlockedReplicaNo = " << n.fBlockedReplicaNo <<
G4endl
2062 <<
" LastStepWasZero = " << n.fLastStepWasZero <<
G4endl
2065 if( ( 1 < n.fVerbose) && (n.fVerbose < 4) )
2068 os << std::setw(30) <<
" ExitNormal " <<
" "
2069 << std::setw( 5) <<
" Valid " <<
" "
2070 << std::setw( 9) <<
" Exiting " <<
" "
2071 << std::setw( 9) <<
" Entering" <<
" "
2072 << std::setw(15) <<
" Blocked:Volume " <<
" "
2073 << std::setw( 9) <<
" ReplicaNo" <<
" "
2074 << std::setw( 8) <<
" LastStepZero " <<
" "
2076 os <<
"( " << std::setw(7) << n.fExitNormal.x()
2077 <<
", " << std::setw(7) << n.fExitNormal.y()
2078 <<
", " << std::setw(7) << n.fExitNormal.z() <<
" ) "
2079 << std::setw( 5) << n.fValidExitNormal <<
" "
2080 << std::setw( 9) << n.fExiting <<
" "
2081 << std::setw( 9) << n.fEntering <<
" ";
2082 if ( n.fBlockedPhysicalVolume==
nullptr )
2083 { os << std::setw(15) <<
"None"; }
2085 { os << std::setw(15)<< n.fBlockedPhysicalVolume->GetName(); }
2086 os << std::setw( 9) << n.fBlockedReplicaNo <<
" "
2087 << std::setw( 8) << n.fLastStepWasZero <<
" "
2090 if( n.fVerbose > 2 )
2093 os <<
" Current Localpoint = " << n.fLastLocatedPointLocal <<
G4endl;
2094 os <<
" PreviousSftOrigin = " << n.fPreviousSftOrigin <<
G4endl;
2095 os <<
" PreviousSafety = " << n.fPreviousSafety <<
G4endl;
2097 if( n.fVerbose > 3 || n.fVerbose == 0 )
2099 os <<
"Current History: " <<
G4endl << n.fHistory;
2102 os.precision(oldcoutPrec);
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define G4DEBUG_NAVIGATION
#define fExitNormalGlobalFrame
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()
virtual void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
G4TouchableHistory * CreateTouchableHistory() const
virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &point, G4bool *valid)
const G4AffineTransform GetLocalToGlobalTransform() const
G4int GetVerboseLevel() const
G4ThreeVector fStepEndPoint
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=nullptr, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
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 G4TouchableHandle CreateTouchableHistoryHandle() 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()
friend std::ostream & operator<<(std::ostream &os, const G4ITNavigator1 &n)
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
std::size_t GetDepth() const
G4VPhysicalVolume * GetTopVolume() const
EVolume GetVolumeType(G4int n) const
const G4AffineTransform & GetTransform(G4int n) const
G4bool LevelLocate(G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint) final
G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4NavigationHistory &history, const G4double pMaxLength=DBL_MAX) 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
G4SmartVoxelNode * ParamVoxelLocate(G4SmartVoxelHeader *pHead, const 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) override
G4double ComputeSafety(const G4ThreeVector &localPoint, const G4NavigationHistory &history, const G4double pProposedMaxLength=DBL_MAX) 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 ComputeSafety(const G4ThreeVector &localPoint, const G4NavigationHistory &history, const G4double pProposedMaxLength=DBL_MAX) final
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, const G4NavigationHistory &history, const G4double pProposedMaxLength=DBL_MAX) const
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
virtual G4int MoveUpHistory(G4int num_levels=1)
virtual const G4NavigationHistory * GetHistory() const
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) override
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
G4SmartVoxelNode * VoxelLocate(G4SmartVoxelHeader *pHead, const G4ThreeVector &localPoint)
G4double ComputeSafety(const G4ThreeVector &localPoint, const G4VPhysicalVolume ¤tPhysical, G4double maxLength=DBL_MAX)