52 #define G4DEBUG_NAVIGATION 1
161 const G4bool relativeSearch,
162 const G4bool ignoreDirection )
164 G4bool notKnownContained=
true, noResult;
176 if( considerDirection && pGlobalDirection != 0 )
178 globalDirection=*pGlobalDirection;
186 G4cout <<
"*** G4ITNavigator1::LocateGlobalPointAndSetup: ***" <<
G4endl;
187 G4cout <<
" Called with arguments: " << G4endl
188 <<
" Globalpoint = " << globalPoint << G4endl
189 <<
" RelativeSearch = " << relativeSearch <<
G4endl;
195 G4cout.precision(oldcoutPrec);
199 if ( !relativeSearch )
279 G4Exception(
"G4ITNavigator1::LocateGlobalPointAndSetup()",
281 "Not applicable for external volumes.");
287 notKnownContained =
false;
308 G4int noLevelsExited=0 ;
310 while (notKnownContained)
316 insideCode = targetSolid->
Inside(localPoint);
320 G4String solidResponse =
"-kInside-";
322 solidResponse =
"-kOutside-";
324 solidResponse =
"-kSurface-";
325 G4cout <<
"*** G4ITNavigator1::LocateGlobalPointAndSetup(): ***" <<
G4endl
326 <<
" Invoked Inside() for solid: " << targetSolid->
GetName()
327 <<
". Solid replied: " << solidResponse <<
G4endl
328 <<
" For local point p: " << localPoint <<
G4endl;
353 if( noLevelsExited > 1 )
377 if( (!
fExiting)&&considerDirection )
382 G4bool directionExiting =
false;
393 directionExiting = normal.
dot(localDirection) > 0.0;
394 isExiting = isExiting || directionExiting;
410 if( noLevelsExited > 1 )
432 notKnownContained=
false;
437 notKnownContained=
false;
458 if (!targetPhysical) {
break; }
516 G4Exception(
"G4ITNavigator1::LocateGlobalPointAndSetup()",
518 "Not applicable for external volumes.");
550 #ifdef G4DEBUG_NAVIGATION
554 G4cout <<
"*** G4ITNavigator1::LocateGlobalPointAndSetup() ***" <<
G4endl;
569 if (targetPhysical) { curPhysVol_Name = targetPhysical->
GetName(); }
570 G4cout <<
" Return value = new volume = " << curPhysVol_Name <<
G4endl;
575 G4cout <<
"Upon exiting LocateGlobalPointAndSetup():" <<
G4endl;
578 G4cout.precision(oldcoutPrec);
584 return targetPhysical;
607 #ifdef G4DEBUG_NAVIGATION
610 G4cout <<
"Entering LocateGlobalWithinVolume(): History = " <<
G4endl;
644 G4Exception(
"G4ITNavigator1::LocateGlobalPointWithinVolume()",
646 "Not applicable for replicated volumes.");
649 G4Exception(
"G4ITNavigator1::LocateGlobalPointWithinVolume()",
651 "Not applicable for external volumes.");
803 const G4double pCurrentProposedStepLength,
829 G4cout <<
"*** G4ITNavigator1::ComputeStep: ***" <<
G4endl;
831 <<
" - Proposed step length = " << pCurrentProposedStepLength
833 #ifdef G4DEBUG_NAVIGATION
836 G4cout <<
" Called with the arguments: " << G4endl
837 <<
" Globalpoint = " << std::setw(25) << pGlobalpoint << G4endl
838 <<
" Direction = " << std::setw(25) << pDirection <<
G4endl;
855 G4double moveLenSq = (newLocalPoint-oldLocalPoint).mag2();
877 pCurrentProposedStepLength,
894 pCurrentProposedStepLength,
922 "Point is relocated in voxels, while it should be outside!");
925 pCurrentProposedStepLength,
940 pCurrentProposedStepLength,
959 pCurrentProposedStepLength,
973 pCurrentProposedStepLength,
985 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav0001",
989 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav0001",
1000 G4bool calculatedExitNormal=
false;
1006 pCurrentProposedStepLength,
1010 calculatedExitNormal,
1044 #ifdef G4DEBUG_NAVIGATION
1047 G4cout <<
"G4ITNavigator1::ComputeStep(): another zero step, # "
1049 <<
" at " << pGlobalpoint
1050 <<
" in volume " << motherPhysical->
GetName()
1051 <<
" nav-comp-step calls # " << sNavCScalls
1064 message <<
"Track stuck or not moving." <<
G4endl
1065 <<
" Track stuck, not moving for "
1067 <<
" in volume -" << motherPhysical->
GetName()
1068 <<
"- at point " << pGlobalpoint <<
G4endl
1069 <<
" direction: " << pDirection <<
"." <<
G4endl
1070 <<
" Potential geometry or navigation problem !"
1072 <<
" Trying pushing it of " << Step <<
" mm ...";
1073 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav1002",
1074 JustWarning, message,
"Potential overlap in geometry!");
1084 message <<
"Stuck Track: potential geometry or navigation problem."
1086 <<
" Track stuck, not moving for "
1088 <<
" in volume -" << motherPhysical->
GetName()
1089 <<
"- at point " << pGlobalpoint <<
G4endl
1090 <<
" direction: " << pDirection <<
".";
1092 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav0003",
1109 #ifdef G4DEBUG_NAVIGATION
1112 G4cout <<
" At G4Nav CompStep End - if(exiting) - fExiting= " <<
fExiting
1173 #ifdef G4DEBUG_NAVIGATION
1176 desc <<
"Problem in ComputeStep: Replica Navigation did not provide"
1177 <<
" valid exit Normal. " <<
G4endl;
1178 desc <<
" Do not know how calculate it in this case." <<
G4endl;
1179 desc <<
" Location = " << finalLocalPoint <<
G4endl;
1180 desc <<
" Volume name = " << motherPhysical->
GetName()
1182 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav0003",
1183 JustWarning, desc,
"Normal not available for exiting.");
1228 G4cout <<
" Returned step= " << Step;
1232 G4cout <<
" Requested step= " << pCurrentProposedStepLength ;
1250 const G4double pCurrentProposedStepLength,
1261 pCurrentProposedStepLength,
1324 for ( i=1; i<=cdepth; i++ )
1353 ComputeMaterial(replicaNo, current, &touchable) );
1359 "Not applicable for external volumes.");
1386 if( candidateLogical )
1408 currentSolid= candidateLogical->
GetSolid();
1409 inSideIt = currentSolid->
Inside(daughterPointOwnLocal);
1410 onSurface = (inSideIt ==
kSurface);
1415 safety = (currentSolid->
DistanceToIn(daughterPointOwnLocal));
1418 else if (inSideIt ==
kInside )
1420 safety = (currentSolid->
DistanceToOut(daughterPointOwnLocal));
1427 nextSolidExitNormal =
1432 ExitNormal = -nextSolidExitNormal;
1441 message <<
"Point not on surface ! " <<
G4endl
1443 << daughterPointOwnLocal <<
G4endl
1444 <<
" Physical volume = "
1446 <<
" Logical volume = "
1448 <<
" Solid = " << currentSolid->
GetName()
1451 << *currentSolid <<
G4endl;
1454 message <<
"Point is Outside. " << G4endl
1455 <<
" Safety (from outside) = " << safety <<
G4endl;
1459 message <<
"Point is Inside. " << G4endl
1460 <<
" Safety (from inside) = " << safety <<
G4endl;
1462 G4Exception(
"G4ITNavigator1::GetLocalExitNormal()",
"GeomNav1001",
1480 G4Exception(
"G4ITNavigator1::GetLocalExitNormal()",
1482 "Incorrect call to GetLocalSurfaceNormal." );
1495 desc <<
" Parameters of solid: " << *daughterSolid
1497 G4Exception(
"G4ITNavigator1::GetLocalExitNormal()",
1499 "Surface Normal returned by Solid is not a Unit Vector." );
1517 message <<
"Function called when *NOT* at a Boundary." <<
G4endl;
1518 G4Exception(
"G4ITNavigator1::GetLocalExitNormal()",
1534 G4int enteringReplicaNo,
1537 switch (enteringVolumeType)
1542 G4Exception(
"G4ITNavigator1::GetMotherToDaughterTransform()",
1544 "Method NOT Implemented yet for replica volumes.");
1552 pParam->
ComputeSolid(enteringReplicaNo, pEnteringPhysVol);
1566 G4Exception(
"G4ITNavigator1::GetMotherToDaughterTransform()",
1568 "Not applicable for external volumes.");
1592 #ifdef G4DEBUG_NAVIGATION
1597 G4ThreeVector ExpectedBoundaryPointLocal;
1600 ExpectedBoundaryPointLocal =
1620 G4bool* pNormalCalculated)
1630 *pNormalCalculated =
true;
1638 #ifdef G4DEBUG_NAVIGATION
1646 edN <<
" State of Navigator: " <<
G4endl;
1650 G4Exception(
"G4ITNavigator1::GetGlobalExitNormal()",
1652 "LocalExitNormalAndCheck() did not calculate Normal.");
1661 edN <<
"G4ITNavigator1::GetGlobalExitNormal: "
1662 <<
" Using Local Normal - from call to GetLocalExitNormalAndCheck. "
1664 <<
" Local Exit Normal = " << localNormal <<
" || = "
1665 << std::sqrt(localMag2) <<
G4endl
1666 <<
" Global Exit Normal = " << globalNormal <<
" || = "
1670 G4Exception(
"G4ITNavigator1::GetGlobalExitNormal()",
1672 "Value obtained from new local *solid* is incorrect.");
1673 localNormal = localNormal.
unit();
1679 #ifdef G4DEBUG_NAVIGATION
1694 edDfn <<
"Found difference in normals in case of exiting mother "
1695 <<
"- when Get is called after ComputingStep " <<
G4endl;
1696 edDfn <<
" Magnitude of diff = " << diffNorm.
mag() <<
G4endl;
1697 edDfn <<
" Normal stored (Global) = " << fExitNormalGlobalFrame
1699 edDfn <<
" Global Computed from Local = " << globalNormal <<
G4endl;
1700 G4Exception(
"G4ITNavigator1::GetGlobalExitNormal()",
"GeomNav0003",
1706 return globalNormal;
1710 #define G4NEW_SAFETY 1
1727 #ifdef G4DEBUG_NAVIGATION
1731 G4cout <<
"*** G4ITNavigator1::ComputeSafety: ***" <<
G4endl
1732 <<
" Called at point: " << pGlobalpoint <<
G4endl;
1736 <<
" - Maximum length = " << pMaxLength <<
G4endl;
1739 G4cout <<
" ----- Upon entering Compute Safety:" <<
G4endl;
1751 if( !(endpointOnSurface && stayedOnEndpoint) )
1764 #ifdef G4DEBUG_NAVIGATION
1767 G4cout <<
" G4ITNavigator1::ComputeSafety() relocates-in-volume to point: "
1768 << pGlobalpoint <<
G4endl;
1785 *motherPhysical, pMaxLength);
1786 newSafety= safetyTwo;
1791 newSafety= safetyOldVoxel;
1810 G4Exception(
"G4ITNavigator1::ComputeSafety()",
"GeomNav0001",
1816 "Not applicable for external volumes.");
1828 #ifdef G4DEBUG_NAVIGATION
1831 G4cout <<
" G4ITNavigator1::ComputeSafety() finds that point - "
1832 << pGlobalpoint <<
" - is on surface " <<
G4endl;
1849 #ifdef G4DEBUG_NAVIGATION
1854 G4cout <<
" Returned value of Safety = " << newSafety <<
G4endl;
1856 G4cout.precision(oldcoutPrec);
1880 G4cout <<
"The current state of G4ITNavigator1 is: " <<
G4endl;
1883 <<
" Exiting = " <<
fExiting << G4endl
1884 <<
" Entering = " <<
fEntering << G4endl
1885 <<
" BlockedPhysicalVolume= " ;
1898 G4cout << std::setw(30) <<
" ExitNormal " <<
" "
1899 << std::setw( 5) <<
" Valid " <<
" "
1900 << std::setw( 9) <<
" Exiting " <<
" "
1901 << std::setw( 9) <<
" Entering" <<
" "
1902 << std::setw(15) <<
" Blocked:Volume " <<
" "
1903 << std::setw( 9) <<
" ReplicaNo" <<
" "
1904 << std::setw( 8) <<
" LastStepZero " <<
" "
1910 << std::setw( 9) <<
fExiting <<
" "
1914 G4cout << std::setw(15) <<
"None";
1931 G4cout.precision(oldcoutPrec);
1960 G4double shiftOrigin = std::sqrt(shiftOriginSafSq);
1963 if( diffShiftSaf > fAccuracyForWarning )
1967 std::ostringstream
message, suggestion;
1968 message <<
"Accuracy error or slightly inaccurate position shift."
1970 <<
" The Step's starting point has moved "
1971 << std::sqrt(moveLenSq)/
mm <<
" mm " <<
G4endl
1972 <<
" since the last call to a Locate method." <<
G4endl
1973 <<
" This has resulted in moving "
1974 << shiftOrigin/
mm <<
" mm "
1975 <<
" from the last point at which the safety "
1976 <<
" was calculated " <<
G4endl
1977 <<
" which is more than the computed safety= "
1978 << fPreviousSafety/
mm <<
" mm at that point." <<
G4endl
1979 <<
" This difference is "
1980 << diffShiftSaf/
mm <<
" mm." <<
G4endl
1981 <<
" The tolerated accuracy is "
1982 << fAccuracyForException/
mm <<
" mm.";
1986 if( ((++warnNow % 100) == 1) )
1989 <<
" This problem can be due to either " <<
G4endl
1990 <<
" - a process that has proposed a displacement"
1991 <<
" larger than the current safety , or" <<
G4endl
1992 <<
" - inaccuracy in the computation of the safety";
1993 suggestion <<
"We suggest that you " << G4endl
1994 <<
" - find i) what particle is being tracked, and "
1995 <<
" ii) through what part of your geometry " << G4endl
1996 <<
" for example by re-running this event with "
1998 <<
" /tracking/verbose 1 " << G4endl
1999 <<
" - check which processes you declare for"
2000 <<
" this particle (and look at non-standard ones)"
2002 <<
" - in case, create a detailed logfile"
2003 <<
" of this event using:" << G4endl
2004 <<
" /tracking/verbose 6 ";
2008 message,
G4String(suggestion.str()));
2009 G4cout.precision(oldcoutPrec);
2010 G4cerr.precision(oldcerrPrec);
2012 #ifdef G4DEBUG_NAVIGATION
2015 G4cerr <<
"WARNING - G4ITNavigator1::ComputeStep()" <<
G4endl
2016 <<
" The Step's starting point has moved "
2017 << std::sqrt(moveLenSq) <<
"," <<
G4endl
2018 <<
" which has taken it to the limit of"
2019 <<
" the current safety. " <<
G4endl;
2024 if ( shiftOriginSafSq >
sqr(safetyPlus) )
2027 message <<
"May lead to a crash or unreliable results." <<
G4endl
2028 <<
" Position has shifted considerably without"
2029 <<
" notifying the navigator !" <<
G4endl
2030 <<
" Tolerated safety: " << safetyPlus <<
G4endl
2031 <<
" Computed shift : " << shiftOriginSafSq;
2032 G4Exception(
"G4ITNavigator1::ComputeStep()",
"GeomNav1002",
2049 G4int oldcoutPrec = os.precision(4);
2052 os <<
"The current state of G4ITNavigator1 is: " <<
G4endl;
2055 <<
" Exiting = " << n.
fExiting << G4endl
2056 <<
" Entering = " << n.
fEntering << G4endl
2057 <<
" BlockedPhysicalVolume= " ;
2070 os << std::setw(30) <<
" ExitNormal " <<
" "
2071 << std::setw( 5) <<
" Valid " <<
" "
2072 << std::setw( 9) <<
" Exiting " <<
" "
2073 << std::setw( 9) <<
" Entering" <<
" "
2074 << std::setw(15) <<
" Blocked:Volume " <<
" "
2075 << std::setw( 9) <<
" ReplicaNo" <<
" "
2076 << std::setw( 8) <<
" LastStepZero " <<
" "
2082 << std::setw( 9) << n.
fExiting <<
" "
2085 { os << std::setw(15) <<
"None"; }
2104 os.precision(oldcoutPrec);