53 : fWasLimitedByGeometry(false), fVerbose(0),
54 fTopPhysical(0), fCheck(false), fPushed(false), fWarnPush(true)
57 fLastTriedStepComputation=
false;
66 fActionThreshold_NoZeroSteps = 10;
67 fAbandonThreshold_NoZeroSteps = 25;
83 {
delete fpVoxelSafety; }
97 fLastTriedStepComputation=
false;
120 const G4bool relativeSearch,
121 const G4bool ignoreDirection )
123 G4bool notKnownContained=
true, noResult;
130 G4bool considerDirection = (!ignoreDirection) || fLocatedOnEdge;
132 fLastTriedStepComputation=
false;
133 fChangedGrandMotherRefFrame=
false;
135 if( considerDirection && pGlobalDirection != 0 )
137 globalDirection=*pGlobalDirection;
145 G4cout <<
"*** G4Navigator::LocateGlobalPointAndSetup: ***" <<
G4endl;
146 G4cout <<
" Called with arguments: " << G4endl
147 <<
" Globalpoint = " << globalPoint << G4endl
148 <<
" RelativeSearch = " << relativeSearch <<
G4endl;
154 G4cout.precision(oldcoutPrec);
158 if ( !relativeSearch )
179 fLastLocatedPointLocal = localPoint;
180 fLocatedOutsideWorld =
true;
204 fBlockedPhysicalVolume);
207 fBlockedPhysicalVolume->
SetCopyNo(fBlockedReplicaNo);
217 fBlockedPhysicalVolume);
219 fBlockedPhysicalVolume);
221 fBlockedPhysicalVolume);
224 fBlockedPhysicalVolume->
SetCopyNo(fBlockedReplicaNo);
232 ComputeMaterial(fBlockedReplicaNo,
233 fBlockedPhysicalVolume,
239 fBlockedPhysicalVolume = 0;
241 notKnownContained =
false;
246 fBlockedPhysicalVolume = 0;
262 G4int noLevelsExited=0 ;
264 while (notKnownContained)
270 insideCode = targetSolid->
Inside(localPoint);
274 G4String solidResponse =
"-kInside-";
276 solidResponse =
"-kOutside-";
278 solidResponse =
"-kSurface-";
279 G4cout <<
"*** G4Navigator::LocateGlobalPointAndSetup(): ***" <<
G4endl
280 <<
" Invoked Inside() for solid: " << targetSolid->
GetName()
281 <<
". Solid replied: " << solidResponse <<
G4endl
282 <<
" For local point p: " << localPoint <<
G4endl;
289 fExiting, notKnownContained);
307 if( noLevelsExited > 1 )
314 fGrandMotherExitNormal *= (*mRot).inverse();
315 fChangedGrandMotherRefFrame=
true;
321 fLastLocatedPointLocal = localPoint;
322 fLocatedOutsideWorld =
true;
330 G4bool isExiting = fExiting;
331 if( (!fExiting)&&considerDirection )
336 G4bool directionExiting =
false;
347 directionExiting = normal.
dot(localDirection) > 0.0;
348 isExiting = isExiting || directionExiting;
362 fValidExitNormal =
false;
364 if( noLevelsExited > 1 )
371 fGrandMotherExitNormal *= (*mRot).inverse();
372 fChangedGrandMotherRefFrame=
true;
378 fLastLocatedPointLocal = localPoint;
379 fLocatedOutsideWorld =
true;
386 notKnownContained=
false;
391 notKnownContained=
false;
412 if (!targetPhysical) {
break; }
420 fBlockedPhysicalVolume,
430 fBlockedPhysicalVolume,
440 fBlockedPhysicalVolume,
451 fBlockedPhysicalVolume,
461 fBlockedPhysicalVolume,
480 fBlockedPhysicalVolume = 0;
481 fBlockedReplicaNo = -1;
495 fGrandMotherExitNormal *= (*mRot).inverse();
499 #ifdef G4DEBUG_NAVIGATION
503 G4cout <<
"*** G4Navigator::LocateGlobalPointAndSetup() ***" <<
G4endl;
511 fLastLocatedPointLocal = localPoint;
518 if (targetPhysical) { curPhysVol_Name = targetPhysical->
GetName(); }
519 G4cout <<
" Return value = new volume = " << curPhysVol_Name <<
G4endl;
524 G4cout <<
"Upon exiting LocateGlobalPointAndSetup():" <<
G4endl;
527 G4cout.precision(oldcoutPrec);
531 fLocatedOutsideWorld=
false;
533 return targetPhysical;
553 fLastTriedStepComputation=
false;
554 fChangedGrandMotherRefFrame=
false;
556 #ifdef G4DEBUG_NAVIGATION
559 G4cout <<
"Entering LocateGlobalWithinVolume(): History = " <<
G4endl;
581 fvoxelNav.
VoxelLocate( pVoxelHeader, fLastLocatedPointLocal );
593 G4Exception(
"G4Navigator::LocateGlobalPointWithinVolume()",
595 "Not applicable for replicated volumes.");
605 fBlockedPhysicalVolume = 0;
606 fBlockedReplicaNo = -1;
623 fSaveState.sExitNormal = fExitNormal;
624 fSaveState.sValidExitNormal = fValidExitNormal;
625 fSaveState.sExiting = fExiting;
626 fSaveState.sEntering = fEntering;
628 fSaveState.spBlockedPhysicalVolume = fBlockedPhysicalVolume;
629 fSaveState.sBlockedReplicaNo = fBlockedReplicaNo,
631 fSaveState.sLastStepWasZero = fLastStepWasZero;
633 fSaveState.sLocatedOutsideWorld = fLocatedOutsideWorld;
634 fSaveState.sLastLocatedPointLocal= fLastLocatedPointLocal;
640 fSaveState.sPreviousSftOrigin= fPreviousSftOrigin;
641 fSaveState.sPreviousSafety= fPreviousSafety;
652 fExitNormal = fSaveState.sExitNormal;
653 fValidExitNormal = fSaveState.sValidExitNormal;
654 fExiting = fSaveState.sExiting;
655 fEntering = fSaveState.sEntering;
657 fBlockedPhysicalVolume = fSaveState.spBlockedPhysicalVolume;
658 fBlockedReplicaNo = fSaveState.sBlockedReplicaNo,
660 fLastStepWasZero = fSaveState.sLastStepWasZero;
662 fLocatedOutsideWorld = fSaveState.sLocatedOutsideWorld;
663 fLastLocatedPointLocal= fSaveState.sLastLocatedPointLocal;
666 fSaveState.sPreviousSftOrigin= fPreviousSftOrigin;
667 fSaveState.sPreviousSafety= fPreviousSafety;
703 const G4double pCurrentProposedStepLength,
715 fChangedGrandMotherRefFrame=
false;
718 fCalculatedExitNormal =
false;
724 fLastTriedStepComputation=
true;
729 G4cout <<
"*** G4Navigator::ComputeStep: ***" <<
G4endl;
731 <<
" - Proposed step length = " << pCurrentProposedStepLength
733 #ifdef G4DEBUG_NAVIGATION
736 G4cout <<
" Called with the arguments: " << G4endl
737 <<
" Globalpoint = " << std::setw(25) << pGlobalpoint << G4endl
738 <<
" Direction = " << std::setw(25) << pDirection <<
G4endl;
750 if( newLocalPoint != fLastLocatedPointLocal )
755 G4double moveLenSq = (newLocalPoint-oldLocalPoint).mag2();
760 ComputeStepLog(pGlobalpoint, moveLenSq);
765 fLastTriedStepComputation=
true;
775 Step = fvoxelNav.
ComputeStep(fLastLocatedPointLocal,
777 pCurrentProposedStepLength,
784 &fBlockedPhysicalVolume,
792 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
794 pCurrentProposedStepLength,
801 &fBlockedPhysicalVolume,
807 fLastTriedStepComputation=
true;
822 "Point is relocated in voxels, while it should be outside!");
823 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
825 pCurrentProposedStepLength,
832 &fBlockedPhysicalVolume,
838 ComputeStepSkippingEqualMaterials(fLastLocatedPointLocal,
840 pCurrentProposedStepLength,
847 &fBlockedPhysicalVolume,
857 Step = fparamNav.
ComputeStep(fLastLocatedPointLocal,
859 pCurrentProposedStepLength,
866 &fBlockedPhysicalVolume,
871 Step = fregularNav.
ComputeStep(fLastLocatedPointLocal,
873 pCurrentProposedStepLength,
880 &fBlockedPhysicalVolume,
885 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0001",
896 G4bool calculatedExitNormal;
899 fLastLocatedPointLocal,
901 pCurrentProposedStepLength,
905 calculatedExitNormal,
909 &fBlockedPhysicalVolume,
911 fExiting= exitingReplica;
912 fCalculatedExitNormal= calculatedExitNormal;
917 fPreviousSftOrigin = pGlobalpoint;
918 fPreviousSafety = pNewSafety;
930 fLocatedOnEdge = fLastStepWasZero && (Step==0.0);
931 fLastStepWasZero = (Step==0.0);
932 if (fPushed) { fPushed = fLastStepWasZero; }
936 if ( fLastStepWasZero )
939 #ifdef G4DEBUG_NAVIGATION
940 if( fNumberZeroSteps > 1 )
942 G4cout <<
"G4Navigator::ComputeStep(): another zero step, # "
944 <<
" at " << pGlobalpoint
945 <<
" in volume " << motherPhysical->
GetName()
946 <<
" nav-comp-step calls # " << sNavCScalls
950 if( fNumberZeroSteps > fActionThreshold_NoZeroSteps-1 )
956 if ((!fPushed) && (fWarnPush))
958 std::ostringstream message;
959 message <<
"Track stuck or not moving." <<
G4endl
960 <<
" Track stuck, not moving for "
961 << fNumberZeroSteps <<
" steps" <<
G4endl
962 <<
" in volume -" << motherPhysical->
GetName()
963 <<
"- at point " << pGlobalpoint <<
G4endl
964 <<
" direction: " << pDirection <<
"." <<
G4endl
965 <<
" Potential geometry or navigation problem !"
967 <<
" Trying pushing it of " << Step <<
" mm ...";
968 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav1002",
969 JustWarning, message,
"Potential overlap in geometry!");
974 if( fNumberZeroSteps > fAbandonThreshold_NoZeroSteps-1 )
978 std::ostringstream message;
979 message <<
"Stuck Track: potential geometry or navigation problem."
981 <<
" Track stuck, not moving for "
982 << fNumberZeroSteps <<
" steps" <<
G4endl
983 <<
" in volume -" << motherPhysical->
GetName()
984 <<
"- at point " << pGlobalpoint <<
G4endl
985 <<
" direction: " << pDirection <<
".";
987 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0003",
993 if (!fPushed) fNumberZeroSteps = 0;
1004 #ifdef G4DEBUG_NAVIGATION
1007 G4cout <<
" At G4Nav CompStep End - if(exiting) - fExiting= " << fExiting
1008 <<
" fValidExitNormal = " << fValidExitNormal <<
G4endl;
1013 if(fValidExitNormal || fCalculatedExitNormal)
1019 fGrandMotherExitNormal= fExitNormal;
1020 fCalculatedExitNormal=
true;
1024 fGrandMotherExitNormal = fExitNormal;
1032 fLastLocatedPointLocal + localDirection*Step;
1046 fChangedGrandMotherRefFrame=
true;
1047 fGrandMotherExitNormal = (*mRot).inverse() * exitNormalMotherFrame;
1051 fGrandMotherExitNormal = exitNormalMotherFrame;
1057 fCalculatedExitNormal=
true;
1061 fCalculatedExitNormal =
false;
1068 #ifdef G4DEBUG_NAVIGATION
1071 desc <<
"Problem in ComputeStep: Replica Navigation did not provide"
1072 <<
" valid exit Normal. " <<
G4endl;
1073 desc <<
" Do not know how calculate it in this case." <<
G4endl;
1074 desc <<
" Location = " << finalLocalPoint <<
G4endl;
1075 desc <<
" Volume name = " << motherPhysical->
GetName()
1077 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0003",
1078 JustWarning, desc,
"Normal not available for exiting.");
1085 if( fValidExitNormal || fCalculatedExitNormal )
1092 fExitNormalGlobalFrame =
1093 GrandMotherToGlobalTransf.
TransformAxis( fGrandMotherExitNormal );
1097 fExitNormalGlobalFrame= fGrandMotherExitNormal;
1107 if( (Step == pCurrentProposedStepLength) && (!fExiting) && (!fEntering) )
1123 G4cout <<
" Returned step= " << Step;
1125 if( Step == kInfinity )
1127 G4cout <<
" Requested step= " << pCurrentProposedStepLength ;
1145 const G4double pCurrentProposedStepLength,
1156 pCurrentProposedStepLength,
1177 fLocatedOnEdge =
false;
1178 fLastStepWasZero =
false;
1183 fValidExitNormal =
false;
1184 fChangedGrandMotherRefFrame=
false;
1185 fCalculatedExitNormal =
false;
1192 fPreviousSafety = 0.0;
1194 fNumberZeroSteps = 0;
1196 fBlockedPhysicalVolume = 0;
1197 fBlockedReplicaNo = -1;
1199 fLastLocatedPointLocal =
G4ThreeVector( kInfinity, -kInfinity, 0.0 );
1200 fLocatedOutsideWorld =
false;
1219 for ( i=1; i<=cdepth; i++ )
1248 ComputeMaterial(replicaNo, current, &touchable) );
1266 if ( fLastTriedStepComputation )
1272 if( fEntering && (fBlockedPhysicalVolume!=0) )
1275 if( candidateLogical )
1297 currentSolid= candidateLogical->
GetSolid();
1298 inSideIt = currentSolid->
Inside(daughterPointOwnLocal);
1299 onSurface = (inSideIt ==
kSurface);
1304 safety = (currentSolid->
DistanceToIn(daughterPointOwnLocal));
1307 else if (inSideIt ==
kInside )
1309 safety = (currentSolid->
DistanceToOut(daughterPointOwnLocal));
1316 nextSolidExitNormal =
1321 ExitNormal = -nextSolidExitNormal;
1322 fCalculatedExitNormal=
true;
1327 if((
fVerbose == 1 ) && ( fCheck ))
1329 std::ostringstream message;
1330 message <<
"Point not on surface ! " <<
G4endl
1332 << daughterPointOwnLocal <<
G4endl
1333 <<
" Physical volume = "
1335 <<
" Logical volume = "
1337 <<
" Solid = " << currentSolid->
GetName()
1340 << *currentSolid <<
G4endl;
1343 message <<
"Point is Outside. " << G4endl
1344 <<
" Safety (from outside) = " << safety <<
G4endl;
1348 message <<
"Point is Inside. " << G4endl
1349 <<
" Safety (from inside) = " << safety <<
G4endl;
1351 G4Exception(
"G4Navigator::GetLocalExitNormal()",
"GeomNav1001",
1360 else if ( fExiting )
1362 ExitNormal = fGrandMotherExitNormal;
1364 fCalculatedExitNormal=
true;
1371 "Incorrect call to GetLocalSurfaceNormal." );
1380 ExitNormal= -(daughterSolid->
SurfaceNormal(fLastLocatedPointLocal));
1381 if( std::fabs(ExitNormal.
mag2()-1.0 ) > CLHEP::perMillion )
1384 desc <<
" Parameters of solid: " << *daughterSolid
1385 <<
" Point for surface = " << fLastLocatedPointLocal << std::endl;
1388 "Surface Normal returned by Solid is not a Unit Vector." );
1390 fCalculatedExitNormal=
true;
1397 ExitNormal = fGrandMotherExitNormal;
1399 fCalculatedExitNormal=
true;
1404 fCalculatedExitNormal=
false;
1406 message <<
"Function called when *NOT* at a Boundary." <<
G4endl;
1423 G4int enteringReplicaNo,
1426 switch (enteringVolumeType)
1431 G4Exception(
"G4Navigator::GetMotherToDaughterTransform()",
1433 "Method NOT Implemented yet for replica volumes.");
1441 pParam->
ComputeSolid(enteringReplicaNo, pEnteringPhysVol);
1476 #ifdef G4DEBUG_NAVIGATION
1479 if ( fLastTriedStepComputation )
1481 G4ThreeVector ExpectedBoundaryPointLocal;
1484 ExpectedBoundaryPointLocal =
1504 G4bool* pNormalCalculated)
1509 if( fLastTriedStepComputation && fExiting )
1513 globalNormal = fExitNormalGlobalFrame;
1514 *pNormalCalculated =
true;
1520 *pNormalCalculated = fCalculatedExitNormal;
1522 #ifdef G4DEBUG_NAVIGATION
1523 if( (!validNormal) && !fCalculatedExitNormal)
1526 edN <<
" Calculated = " << fCalculatedExitNormal <<
G4endl;
1527 edN <<
" Entering= " << fEntering <<
G4endl;
1530 edN <<
" State of Navigator: " <<
G4endl;
1536 "LocalExitNormalAndCheck() did not calculate Normal.");
1541 if( validNormal && (std::fabs(localMag2-1.0)) > CLHEP::perMillion )
1545 edN <<
"G4Navigator::GetGlobalExitNormal: "
1546 <<
" Using Local Normal - from call to GetLocalExitNormalAndCheck. "
1548 <<
" Local Exit Normal = " << localNormal <<
" || = "
1549 << std::sqrt(localMag2) <<
G4endl
1550 <<
" Global Exit Normal = " << globalNormal <<
" || = "
1552 edN <<
" Calculated It = " << fCalculatedExitNormal <<
G4endl;
1556 "Value obtained from new local *solid* is incorrect.");
1557 localNormal = localNormal.
unit();
1563 #ifdef G4DEBUG_NAVIGATION
1565 if( fLastTriedStepComputation && fExiting)
1568 *pNormalCalculated = fCalculatedExitNormal;
1574 G4ThreeVector diffNorm = globalNormal - fExitNormalGlobalFrame;
1578 edDfn <<
"Found difference in normals in case of exiting mother "
1579 <<
"- when Get is called after ComputingStep " <<
G4endl;
1580 edDfn <<
" Magnitude of diff = " << diffNorm.
mag() <<
G4endl;
1581 edDfn <<
" Normal stored (Global) = " << fExitNormalGlobalFrame
1583 edDfn <<
" Global Computed from Local = " << globalNormal <<
G4endl;
1584 G4Exception(
"G4Navigator::GetGlobalExitNormal()",
"GeomNav0003",
1590 return globalNormal;
1594 #define G4NEW_SAFETY 1
1611 #ifdef G4DEBUG_NAVIGATION
1615 G4cout <<
"*** G4Navigator::ComputeSafety: ***" <<
G4endl
1616 <<
" Called at point: " << pGlobalpoint <<
G4endl;
1620 <<
" - Maximum length = " << pMaxLength <<
G4endl;
1623 G4cout <<
" ----- Upon entering Compute Safety:" <<
G4endl;
1635 if( !(endpointOnSurface && stayedOnEndpoint) )
1648 #ifdef G4DEBUG_NAVIGATION
1651 G4cout <<
" G4Navigator::ComputeSafety() relocates-in-volume to point: "
1652 << pGlobalpoint <<
G4endl;
1669 *motherPhysical, pMaxLength);
1670 newSafety= safetyTwo;
1675 newSafety= safetyOldVoxel;
1694 G4Exception(
"G4Navigator::ComputeSafety()",
"GeomNav0001",
1701 newSafety = freplicaNav.
ComputeSafety(pGlobalpoint, localPoint,
1707 #ifdef G4DEBUG_NAVIGATION
1710 G4cout <<
" G4Navigator::ComputeSafety() finds that point - "
1711 << pGlobalpoint <<
" - is on surface " <<
G4endl;
1723 fPreviousSftOrigin = pGlobalpoint;
1724 fPreviousSafety = newSafety;
1728 #ifdef G4DEBUG_NAVIGATION
1733 G4cout <<
" Returned value of Safety = " << newSafety <<
G4endl;
1735 G4cout.precision(oldcoutPrec);
1759 G4cout <<
"The current state of G4Navigator is: " <<
G4endl;
1760 G4cout <<
" ValidExitNormal= " << fValidExitNormal << G4endl
1761 <<
" ExitNormal = " << fExitNormal << G4endl
1762 <<
" Exiting = " << fExiting << G4endl
1763 <<
" Entering = " << fEntering << G4endl
1764 <<
" BlockedPhysicalVolume= " ;
1765 if (fBlockedPhysicalVolume==0)
1770 <<
" BlockedReplicaNo = " << fBlockedReplicaNo << G4endl
1771 <<
" LastStepWasZero = " << fLastStepWasZero << G4endl
1777 G4cout << std::setw(30) <<
" ExitNormal " <<
" "
1778 << std::setw( 5) <<
" Valid " <<
" "
1779 << std::setw( 9) <<
" Exiting " <<
" "
1780 << std::setw( 9) <<
" Entering" <<
" "
1781 << std::setw(15) <<
" Blocked:Volume " <<
" "
1782 << std::setw( 9) <<
" ReplicaNo" <<
" "
1783 << std::setw( 8) <<
" LastStepZero " <<
" "
1785 G4cout <<
"( " << std::setw(7) << fExitNormal.
x()
1786 <<
", " << std::setw(7) << fExitNormal.
y()
1787 <<
", " << std::setw(7) << fExitNormal.
z() <<
" ) "
1788 << std::setw( 5) << fValidExitNormal <<
" "
1789 << std::setw( 9) << fExiting <<
" "
1790 << std::setw( 9) << fEntering <<
" ";
1791 if ( fBlockedPhysicalVolume==0 )
1792 G4cout << std::setw(15) <<
"None";
1794 G4cout << std::setw(15)<< fBlockedPhysicalVolume->
GetName();
1795 G4cout << std::setw( 9) << fBlockedReplicaNo <<
" "
1796 << std::setw( 8) << fLastStepWasZero <<
" "
1802 G4cout <<
" Current Localpoint = " << fLastLocatedPointLocal <<
G4endl;
1803 G4cout <<
" PreviousSftOrigin = " << fPreviousSftOrigin <<
G4endl;
1804 G4cout <<
" PreviousSafety = " << fPreviousSafety <<
G4endl;
1806 G4cout.precision(oldcoutPrec);
1813 void G4Navigator::ComputeStepLog(
const G4ThreeVector& pGlobalpoint,
1823 TransformPoint(fLastLocatedPointLocal);
1825 G4double shiftOriginSafSq = (fPreviousSftOrigin-pGlobalpoint).mag2();
1833 if( shiftOriginSafSq >=
sqr(fPreviousSafety) )
1835 G4double shiftOrigin = std::sqrt(shiftOriginSafSq);
1836 G4double diffShiftSaf = shiftOrigin - fPreviousSafety;
1838 if( diffShiftSaf > fAccuracyForWarning )
1842 std::ostringstream message, suggestion;
1843 message <<
"Accuracy error or slightly inaccurate position shift."
1845 <<
" The Step's starting point has moved "
1846 << std::sqrt(moveLenSq)/
mm <<
" mm " <<
G4endl
1847 <<
" since the last call to a Locate method." <<
G4endl
1848 <<
" This has resulted in moving "
1849 << shiftOrigin/
mm <<
" mm "
1850 <<
" from the last point at which the safety "
1851 <<
" was calculated " <<
G4endl
1852 <<
" which is more than the computed safety= "
1853 << fPreviousSafety/
mm <<
" mm at that point." <<
G4endl
1854 <<
" This difference is "
1855 << diffShiftSaf/
mm <<
" mm." <<
G4endl
1856 <<
" The tolerated accuracy is "
1857 << fAccuracyForException/
mm <<
" mm.";
1861 if( ((++warnNow % 100) == 1) )
1864 <<
" This problem can be due to either " <<
G4endl
1865 <<
" - a process that has proposed a displacement"
1866 <<
" larger than the current safety , or" <<
G4endl
1867 <<
" - inaccuracy in the computation of the safety";
1868 suggestion <<
"We suggest that you " << G4endl
1869 <<
" - find i) what particle is being tracked, and "
1870 <<
" ii) through what part of your geometry " << G4endl
1871 <<
" for example by re-running this event with "
1873 <<
" /tracking/verbose 1 " << G4endl
1874 <<
" - check which processes you declare for"
1875 <<
" this particle (and look at non-standard ones)"
1877 <<
" - in case, create a detailed logfile"
1878 <<
" of this event using:" << G4endl
1879 <<
" /tracking/verbose 6 ";
1883 message,
G4String(suggestion.str()));
1884 G4cout.precision(oldcoutPrec);
1885 G4cerr.precision(oldcerrPrec);
1887 #ifdef G4DEBUG_NAVIGATION
1890 G4cerr <<
"WARNING - G4Navigator::ComputeStep()" <<
G4endl
1891 <<
" The Step's starting point has moved "
1892 << std::sqrt(moveLenSq) <<
"," <<
G4endl
1893 <<
" which has taken it to the limit of"
1894 <<
" the current safety. " <<
G4endl;
1898 G4double safetyPlus = fPreviousSafety + fAccuracyForException;
1899 if ( shiftOriginSafSq >
sqr(safetyPlus) )
1901 std::ostringstream message;
1902 message <<
"May lead to a crash or unreliable results." <<
G4endl
1903 <<
" Position has shifted considerably without"
1904 <<
" notifying the navigator !" <<
G4endl
1905 <<
" Tolerated safety: " << safetyPlus <<
G4endl
1906 <<
" Computed shift : " << shiftOriginSafSq;
1907 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav1002",
1924 G4int oldcoutPrec = os.precision(4);
1927 os <<
"The current state of G4Navigator is: " <<
G4endl;
1928 os <<
" ValidExitNormal= " << n.fValidExitNormal << G4endl
1929 <<
" ExitNormal = " << n.fExitNormal << G4endl
1930 <<
" Exiting = " << n.fExiting << G4endl
1931 <<
" Entering = " << n.fEntering << G4endl
1932 <<
" BlockedPhysicalVolume= " ;
1933 if (n.fBlockedPhysicalVolume==0)
1936 os << n.fBlockedPhysicalVolume->
GetName();
1938 <<
" BlockedReplicaNo = " << n.fBlockedReplicaNo << G4endl
1939 <<
" LastStepWasZero = " << n.fLastStepWasZero << G4endl
1945 os << std::setw(30) <<
" ExitNormal " <<
" "
1946 << std::setw( 5) <<
" Valid " <<
" "
1947 << std::setw( 9) <<
" Exiting " <<
" "
1948 << std::setw( 9) <<
" Entering" <<
" "
1949 << std::setw(15) <<
" Blocked:Volume " <<
" "
1950 << std::setw( 9) <<
" ReplicaNo" <<
" "
1951 << std::setw( 8) <<
" LastStepZero " <<
" "
1953 os <<
"( " << std::setw(7) << n.fExitNormal.
x()
1954 <<
", " << std::setw(7) << n.fExitNormal.
y()
1955 <<
", " << std::setw(7) << n.fExitNormal.
z() <<
" ) "
1956 << std::setw( 5) << n.fValidExitNormal <<
" "
1957 << std::setw( 9) << n.fExiting <<
" "
1958 << std::setw( 9) << n.fEntering <<
" ";
1959 if ( n.fBlockedPhysicalVolume==0 )
1960 { os << std::setw(15) <<
"None"; }
1962 { os << std::setw(15)<< n.fBlockedPhysicalVolume->
GetName(); }
1963 os << std::setw( 9) << n.fBlockedReplicaNo <<
" "
1964 << std::setw( 8) << n.fLastStepWasZero <<
" "
1970 os <<
" Current Localpoint = " << n.fLastLocatedPointLocal <<
G4endl;
1971 os <<
" PreviousSftOrigin = " << n.fPreviousSftOrigin <<
G4endl;
1972 os <<
" PreviousSafety = " << n.fPreviousSafety <<
G4endl;
1979 os.precision(oldcoutPrec);
G4SmartVoxelHeader * GetVoxelHeader() const
G4VPhysicalVolume * GetTopVolume() const
virtual void ResetState()
virtual 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)
const G4ThreeVector & GetTranslation() const
std::ostringstream G4ExceptionDescription
void UpdateMaterial(G4Material *pMaterial)
CLHEP::Hep3Vector G4ThreeVector
double dot(const Hep3Vector &) const
G4ThreeVector fLastStepEndPointLocal
virtual void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
G4int GetVerboseLevel() const
G4ThreeVector ComputeLocalAxis(const G4ThreeVector &pVec) const
virtual G4TouchableHistoryHandle CreateTouchableHistoryHandle() const
virtual G4VSolid * ComputeSolid(const G4int, G4VPhysicalVolume *)
void ResetStackAndState()
G4double GetSurfaceTolerance() const
virtual G4double ComputeStep(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
G4double ComputeSafety(const G4ThreeVector &localPoint, const G4VPhysicalVolume ¤tPhysical, G4double maxLength=DBL_MAX)
void SetSolid(G4VSolid *pSolid)
G4SmartVoxelNode * ParamVoxelLocate(G4SmartVoxelHeader *pHead, const G4ThreeVector &localPoint)
EVolume GetVolumeType(G4int n) const
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)
const G4AffineTransform GetLocalToGlobalTransform() const
virtual G4GeometryType GetEntityType() const =0
G4ReferenceCountedHandle< G4TouchableHistory > G4TouchableHistoryHandle
G4bool LevelLocate(G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint)
void ComputeTransformation(const G4int replicaNo, G4VPhysicalVolume *pVol, G4ThreeVector &point) const
virtual G4VPhysicalVolume * ResetHierarchyAndLocate(const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h)
virtual G4ThreeVector GetLocalExitNormalAndCheck(const G4ThreeVector &point, G4bool *valid)
G4int GetTopReplicaNo() const
void SetVerboseLevel(G4int level)
G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4NavigationHistory &history, const G4double pMaxLength=DBL_MAX)
G4bool fWasLimitedByGeometry
void SetNormalNavigation(G4NormalNavigation *fnormnav)
G4double ComputeSafety(const G4ThreeVector &localPoint, const G4NavigationHistory &history, const G4double pProposedMaxLength=DBL_MAX)
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual G4ThreeVector GetLocalExitNormal(G4bool *valid)
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 CheckNextStep(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
EVolume GetTopVolumeType() const
virtual G4int GetRegularStructureId() const =0
G4NavigationHistory fHistory
virtual G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4NavigationHistory &history, const G4double pMaxLength=DBL_MAX)
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0
virtual G4VPVParameterisation * GetParameterisation() const =0
virtual void SetCopyNo(G4int CopyNo)=0
G4int GetReplicaNo(G4int n) const
G4bool LevelLocate(G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint)
G4bool EnteredDaughterVolume() const
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
#define G4DEBUG_NAVIGATION
EVolume CharacteriseDaughters(const G4LogicalVolume *pLog) const
G4ThreeVector ComputeLocalPoint(const G4ThreeVector &rGlobPoint) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void NewLevel(G4VPhysicalVolume *pNewMother, EVolume vType=kNormal, G4int nReplica=-1)
G4TouchableHistory * CreateTouchableHistory() 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)
G4AffineTransform GetMotherToDaughterTransform(G4VPhysicalVolume *dVolume, G4int dReplicaNo, EVolume dVolumeType)
G4LogicalVolume * GetLogicalVolume() const
const G4AffineTransform & GetTransform(G4int n) const
virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &point, G4bool *valid)
G4int GetDaughtersRegularStructureId(const G4LogicalVolume *pLog) const
virtual void ComputeTransformation(const G4int, G4VPhysicalVolume *) const =0
virtual G4int GetCopyNo() const =0
const G4AffineTransform & GetGlobalToLocalTransform() const
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=0, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
std::ostream & operator<<(std::ostream &, const BasicVector3D< float > &)
const G4RotationMatrix * GetRotation() const
G4SmartVoxelNode * VoxelLocate(G4SmartVoxelHeader *pHead, const G4ThreeVector &localPoint)
G4double ComputeSafety(const G4ThreeVector &localPoint, const G4NavigationHistory &history, const G4double pProposedMaxLength=DBL_MAX)
const G4AffineTransform & GetTopTransform() const
G4ThreeVector fStepEndPoint
const G4NavigationHistory * GetHistory() const
G4int MoveUpHistory(G4int num_levels=1)
G4double ComputeSafety(const G4ThreeVector &globalPoint, const G4ThreeVector &localPoint, G4NavigationHistory &history, const G4double pProposedMaxLength=DBL_MAX)
G4bool LevelLocate(G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint)
G4VPhysicalVolume * GetVolume(G4int n) const
G4bool LevelLocate(G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint)
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0
virtual G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=true)
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)
EInside BackLocate(G4NavigationHistory &history, const G4ThreeVector &globalPoint, G4ThreeVector &localPoint, const G4bool &exiting, G4bool ¬KnownInside) const
virtual void SetupHierarchy()
virtual G4bool CheckOverlaps(G4int res=1000, G4double tol=0., G4bool verbose=true, G4int errMax=1)
EVolume VolumeType(const G4VPhysicalVolume *pVol) const
static G4GeometryTolerance * GetInstance()
virtual void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
G4VSolid * GetSolid() const
G4GLOB_DLL std::ostream G4cerr