54 fTopPhysical(0), fCheck(false),
fPushed(false), fWarnPush(true)
57 fLastTriedStepComputation=
false;
66 fActionThreshold_NoZeroSteps = 10;
67 fAbandonThreshold_NoZeroSteps = 25;
102 fLastTriedStepComputation=
false;
127 const G4bool relativeSearch,
128 const G4bool ignoreDirection )
130 G4bool notKnownContained=
true, noResult;
137 G4bool considerDirection = (!ignoreDirection) || fLocatedOnEdge;
139 fLastTriedStepComputation=
false;
140 fChangedGrandMotherRefFrame=
false;
142 if( considerDirection && pGlobalDirection != 0 )
144 globalDirection=*pGlobalDirection;
151 G4cout <<
"*** G4Navigator::LocateGlobalPointAndSetup: ***" <<
G4endl;
152 G4cout <<
" Called with arguments: " << G4endl
153 <<
" Globalpoint = " << globalPoint << G4endl
154 <<
" RelativeSearch = " << relativeSearch <<
G4endl;
160 G4cout.precision(oldcoutPrec);
164 G4int noLevelsExited=0 ;
165 G4int noLevelsEntered= 0;
167 if ( !relativeSearch )
190 fLastLocatedPointLocal = localPoint;
191 fLocatedOutsideWorld =
true;
192 fBlockedPhysicalVolume = 0;
193 fBlockedReplicaNo = -1;
230 fBlockedPhysicalVolume);
233 fBlockedPhysicalVolume->
SetCopyNo(fBlockedReplicaNo);
243 fBlockedPhysicalVolume);
245 fBlockedPhysicalVolume);
247 fBlockedPhysicalVolume);
250 fBlockedPhysicalVolume->
SetCopyNo(fBlockedReplicaNo);
258 ComputeMaterial(fBlockedReplicaNo,
259 fBlockedPhysicalVolume,
265 fBlockedPhysicalVolume = 0;
267 notKnownContained =
false;
272 fBlockedPhysicalVolume = 0;
289 while (notKnownContained)
295 insideCode = targetSolid->
Inside(localPoint);
299 G4String solidResponse =
"-kInside-";
301 solidResponse =
"-kOutside-";
303 solidResponse =
"-kSurface-";
304 G4cout <<
"*** G4Navigator::LocateGlobalPointAndSetup(): ***" <<
G4endl
305 <<
" Invoked Inside() for solid: " << targetSolid->
GetName()
306 <<
". Solid replied: " << solidResponse <<
G4endl
307 <<
" For local point p: " << localPoint <<
G4endl;
314 fExiting, notKnownContained);
332 if( noLevelsExited > 1 )
339 fGrandMotherExitNormal *= (*mRot).inverse();
340 fChangedGrandMotherRefFrame=
true;
346 fLastLocatedPointLocal = localPoint;
347 fLocatedOutsideWorld =
true;
355 G4bool isExiting = fExiting;
356 if( (!fExiting)&&considerDirection )
361 G4bool directionExiting =
false;
372 directionExiting = normal.
dot(localDirection) > 0.0;
373 isExiting = isExiting || directionExiting;
387 fValidExitNormal =
false;
389 if( noLevelsExited > 1 )
397 fGrandMotherExitNormal *= (*mRot).inverse();
398 fChangedGrandMotherRefFrame=
true;
404 fLastLocatedPointLocal = localPoint;
405 fLocatedOutsideWorld =
true;
412 notKnownContained=
false;
417 notKnownContained=
false;
438 if (!targetPhysical) {
break; }
446 fBlockedPhysicalVolume,
456 fBlockedPhysicalVolume,
466 fBlockedPhysicalVolume,
477 fBlockedPhysicalVolume,
487 fBlockedPhysicalVolume,
508 fBlockedPhysicalVolume = 0;
509 fBlockedReplicaNo = -1;
526 fGrandMotherExitNormal *= (*mRot);
527 fChangedGrandMotherRefFrame=
true;
531 #ifdef G4DEBUG_NAVIGATION
535 G4cout <<
"*** G4Navigator::LocateGlobalPointAndSetup() ***" <<
G4endl;
543 fLastLocatedPointLocal = localPoint;
550 if (targetPhysical) { curPhysVol_Name = targetPhysical->
GetName(); }
551 G4cout <<
" Return value = new volume = " << curPhysVol_Name <<
G4endl;
556 G4cout <<
"Upon exiting LocateGlobalPointAndSetup():" <<
G4endl;
559 G4cout.precision(oldcoutPrec);
563 fLocatedOutsideWorld=
false;
565 return targetPhysical;
584 #ifdef G4DEBUG_NAVIGATION
591 fLastTriedStepComputation=
false;
592 fChangedGrandMotherRefFrame=
false;
594 #ifdef G4DEBUG_NAVIGATION
597 G4cout <<
"Entering LocateGlobalWithinVolume(): History = " <<
G4endl;
619 fvoxelNav.
VoxelLocate( pVoxelHeader, fLastLocatedPointLocal );
631 G4Exception(
"G4Navigator::LocateGlobalPointWithinVolume()",
633 "Not applicable for replicated volumes.");
643 fBlockedPhysicalVolume = 0;
644 fBlockedReplicaNo = -1;
665 fSaveState.sExitNormal = fExitNormal;
666 fSaveState.sValidExitNormal = fValidExitNormal;
667 fSaveState.sExiting = fExiting;
668 fSaveState.sEntering = fEntering;
670 fSaveState.spBlockedPhysicalVolume = fBlockedPhysicalVolume;
671 fSaveState.sBlockedReplicaNo = fBlockedReplicaNo,
673 fSaveState.sLastStepWasZero = fLastStepWasZero;
675 fSaveState.sLocatedOutsideWorld = fLocatedOutsideWorld;
676 fSaveState.sLastLocatedPointLocal= fLastLocatedPointLocal;
683 fSaveState.sPreviousSftOrigin= fPreviousSftOrigin;
684 fSaveState.sPreviousSafety= fPreviousSafety;
695 fExitNormal = fSaveState.sExitNormal;
696 fValidExitNormal = fSaveState.sValidExitNormal;
697 fExiting = fSaveState.sExiting;
698 fEntering = fSaveState.sEntering;
700 fBlockedPhysicalVolume = fSaveState.spBlockedPhysicalVolume;
701 fBlockedReplicaNo = fSaveState.sBlockedReplicaNo,
703 fLastStepWasZero = fSaveState.sLastStepWasZero;
705 fLocatedOutsideWorld = fSaveState.sLocatedOutsideWorld;
706 fLastLocatedPointLocal= fSaveState.sLastLocatedPointLocal;
712 fPreviousSftOrigin= fSaveState.sPreviousSftOrigin;
713 fPreviousSafety= fSaveState.sPreviousSafety;
749 const G4double pCurrentProposedStepLength,
761 fChangedGrandMotherRefFrame=
false;
764 fCalculatedExitNormal =
false;
770 fLastTriedStepComputation=
true;
775 G4cout <<
"*** G4Navigator::ComputeStep: ***" <<
G4endl;
777 <<
" - Proposed step length = " << pCurrentProposedStepLength
779 #ifdef G4DEBUG_NAVIGATION
782 G4cout <<
" Called with the arguments: " << G4endl
783 <<
" Globalpoint = " << std::setw(25) << pGlobalpoint << G4endl
784 <<
" Direction = " << std::setw(25) << pDirection <<
G4endl;
796 if( newLocalPoint != fLastLocatedPointLocal )
801 G4double moveLenSq = (newLocalPoint-oldLocalPoint).mag2();
803 if ( moveLenSq >=
fSqTol )
806 ComputeStepLog(pGlobalpoint, moveLenSq);
811 fLastTriedStepComputation=
true;
821 Step = fvoxelNav.
ComputeStep(fLastLocatedPointLocal,
823 pCurrentProposedStepLength,
830 &fBlockedPhysicalVolume,
838 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
840 pCurrentProposedStepLength,
847 &fBlockedPhysicalVolume,
853 fLastTriedStepComputation=
true;
868 "Point is relocated in voxels, while it should be outside!");
869 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
871 pCurrentProposedStepLength,
878 &fBlockedPhysicalVolume,
884 ComputeStepSkippingEqualMaterials(fLastLocatedPointLocal,
886 pCurrentProposedStepLength,
893 &fBlockedPhysicalVolume,
903 Step = fparamNav.
ComputeStep(fLastLocatedPointLocal,
905 pCurrentProposedStepLength,
912 &fBlockedPhysicalVolume,
917 Step = fregularNav.
ComputeStep(fLastLocatedPointLocal,
919 pCurrentProposedStepLength,
926 &fBlockedPhysicalVolume,
931 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0001",
942 G4bool calculatedExitNormal;
945 fLastLocatedPointLocal,
947 pCurrentProposedStepLength,
951 calculatedExitNormal,
955 &fBlockedPhysicalVolume,
957 fExiting= exitingReplica;
958 fCalculatedExitNormal= calculatedExitNormal;
963 fPreviousSftOrigin = pGlobalpoint;
964 fPreviousSafety = pNewSafety;
976 fLocatedOnEdge = fLastStepWasZero && (Step==0.0);
978 if (fPushed) { fPushed = fLastStepWasZero; }
982 if ( fLastStepWasZero )
985 #ifdef G4DEBUG_NAVIGATION
986 if( fNumberZeroSteps > 1 )
988 G4cout <<
"G4Navigator::ComputeStep(): another 'zero' step, # "
990 <<
", at " << pGlobalpoint
991 <<
", in volume " << motherPhysical->
GetName()
992 <<
", nav-comp-step calls # " << sNavCScalls
993 <<
", Step= " << Step
997 if( fNumberZeroSteps > fActionThreshold_NoZeroSteps-1 )
1003 if ((!fPushed) && (fWarnPush))
1005 std::ostringstream message;
1006 message <<
"Track stuck or not moving." <<
G4endl
1007 <<
" Track stuck, not moving for "
1008 << fNumberZeroSteps <<
" steps" <<
G4endl
1009 <<
" in volume -" << motherPhysical->
GetName()
1010 <<
"- at point " << pGlobalpoint
1011 <<
" (local point " << newLocalPoint <<
")" <<
G4endl
1012 <<
" direction: " << pDirection
1013 <<
" (local direction: " << localDirection <<
")." <<
G4endl
1014 <<
" Potential geometry or navigation problem !"
1016 <<
" Trying pushing it of " << Step <<
" mm ...";
1017 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav1002",
1018 JustWarning, message,
"Potential overlap in geometry!");
1023 if( fNumberZeroSteps > fAbandonThreshold_NoZeroSteps-1 )
1027 std::ostringstream message;
1028 message <<
"Stuck Track: potential geometry or navigation problem."
1030 <<
" Track stuck, not moving for "
1031 << fNumberZeroSteps <<
" steps" <<
G4endl
1032 <<
" in volume -" << motherPhysical->
GetName()
1033 <<
"- at point " << pGlobalpoint <<
G4endl
1034 <<
" direction: " << pDirection <<
".";
1041 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0003",
1047 if (!fPushed) fNumberZeroSteps = 0;
1054 +
std::min(Step,pCurrentProposedStepLength) * pDirection;
1059 #ifdef G4DEBUG_NAVIGATION
1062 G4cout <<
" At G4Nav CompStep End - if(exiting) - fExiting= " << fExiting
1063 <<
" fValidExitNormal = " << fValidExitNormal <<
G4endl;
1068 if(fValidExitNormal || fCalculatedExitNormal)
1074 fGrandMotherExitNormal= fExitNormal;
1075 fCalculatedExitNormal=
true;
1079 fGrandMotherExitNormal = fExitNormal;
1087 fLastLocatedPointLocal + localDirection*Step;
1101 fChangedGrandMotherRefFrame=
true;
1102 fGrandMotherExitNormal = (*mRot).inverse() * exitNormalMotherFrame;
1106 fGrandMotherExitNormal = exitNormalMotherFrame;
1112 fCalculatedExitNormal=
true;
1116 fCalculatedExitNormal =
false;
1123 #ifdef G4DEBUG_NAVIGATION
1126 desc <<
"Problem in ComputeStep: Replica Navigation did not provide"
1127 <<
" valid exit Normal. " <<
G4endl;
1128 desc <<
" Do not know how calculate it in this case." <<
G4endl;
1129 desc <<
" Location = " << finalLocalPoint <<
G4endl;
1130 desc <<
" Volume name = " << motherPhysical->
GetName()
1132 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0003",
1133 JustWarning, desc,
"Normal not available for exiting.");
1140 if( fValidExitNormal || fCalculatedExitNormal )
1147 fExitNormalGlobalFrame =
1148 GrandMotherToGlobalTransf.
TransformAxis( fGrandMotherExitNormal );
1152 fExitNormalGlobalFrame= fGrandMotherExitNormal;
1161 if( (Step == pCurrentProposedStepLength) && (!fExiting) && (!fEntering) )
1177 G4cout <<
" Returned step= " << Step;
1181 G4cout <<
" Requested step= " << pCurrentProposedStepLength ;
1199 const G4double pCurrentProposedStepLength,
1210 pCurrentProposedStepLength,
1235 fLocatedOnEdge =
false;
1236 fLastStepWasZero =
false;
1241 fValidExitNormal =
false;
1242 fChangedGrandMotherRefFrame=
false;
1243 fCalculatedExitNormal =
false;
1250 fPreviousSafety = 0.0;
1252 fNumberZeroSteps = 0;
1254 fBlockedPhysicalVolume = 0;
1255 fBlockedReplicaNo = -1;
1258 fLocatedOutsideWorld =
false;
1277 for ( i=1; i<=cdepth; i++ )
1315 ComputeMaterial(replicaNo, current, pTouchable) );
1334 if ( fLastTriedStepComputation )
1340 if( fEntering && (fBlockedPhysicalVolume!=0) )
1343 if( candidateLogical )
1365 currentSolid= candidateLogical->
GetSolid();
1366 inSideIt = currentSolid->
Inside(daughterPointOwnLocal);
1367 onSurface = (inSideIt ==
kSurface);
1372 safety = (currentSolid->
DistanceToIn(daughterPointOwnLocal));
1375 else if (inSideIt ==
kInside )
1377 safety = (currentSolid->
DistanceToOut(daughterPointOwnLocal));
1384 nextSolidExitNormal =
1389 ExitNormal = -nextSolidExitNormal;
1390 fCalculatedExitNormal=
true;
1395 if((
fVerbose == 1 ) && ( fCheck ))
1397 std::ostringstream message;
1398 message <<
"Point not on surface ! " <<
G4endl
1400 << daughterPointOwnLocal <<
G4endl
1401 <<
" Physical volume = "
1403 <<
" Logical volume = "
1405 <<
" Solid = " << currentSolid->
GetName()
1408 << *currentSolid <<
G4endl;
1411 message <<
"Point is Outside. " << G4endl
1412 <<
" Safety (from outside) = " << safety <<
G4endl;
1416 message <<
"Point is Inside. " << G4endl
1417 <<
" Safety (from inside) = " << safety <<
G4endl;
1419 G4Exception(
"G4Navigator::GetLocalExitNormal()",
"GeomNav1001",
1428 else if ( fExiting )
1430 ExitNormal = fGrandMotherExitNormal;
1432 fCalculatedExitNormal=
true;
1439 "Incorrect call to GetLocalSurfaceNormal." );
1448 ExitNormal= -(daughterSolid->
SurfaceNormal(fLastLocatedPointLocal));
1452 desc <<
" Parameters of solid: " << *daughterSolid
1453 <<
" Point for surface = " << fLastLocatedPointLocal << std::endl;
1456 "Surface Normal returned by Solid is not a Unit Vector." );
1458 fCalculatedExitNormal=
true;
1465 ExitNormal = fGrandMotherExitNormal;
1467 fCalculatedExitNormal=
true;
1472 fCalculatedExitNormal=
false;
1474 message <<
"Function called when *NOT* at a Boundary." <<
G4endl;
1475 message <<
"Exit Normal not calculated." <<
G4endl;
1492 G4int enteringReplicaNo,
1495 switch (enteringVolumeType)
1500 G4Exception(
"G4Navigator::GetMotherToDaughterTransform()",
1502 "Method NOT Implemented yet for replica volumes.");
1510 pParam->
ComputeSolid(enteringReplicaNo, pEnteringPhysVol);
1546 #ifdef G4DEBUG_NAVIGATION
1549 if ( fLastTriedStepComputation )
1551 G4ThreeVector ExpectedBoundaryPointLocal;
1554 ExpectedBoundaryPointLocal =
1575 G4bool* pNormalCalculated)
1580 G4bool usingStored = fCalculatedExitNormal && (
1581 ( fLastTriedStepComputation && fExiting )
1583 ( !fLastTriedStepComputation
1593 globalNormal = fExitNormalGlobalFrame;
1595 if( std::fabs ( normMag2 - 1.0 ) <
perMillion )
1597 *pNormalCalculated =
true;
1603 message.precision(10);
1604 message <<
" WARNING> Expected normal-global-frame to be valid, "
1605 <<
" i.e. a unit vector!" <<
G4endl
1606 <<
" - but |normal| = " << std::sqrt(normMag2)
1607 <<
" - and |normal|^2 = " << normMag2 <<
G4endl
1608 <<
" which differs from 1.0 by " << normMag2 - 1.0 <<
G4endl
1609 <<
" n = " << fExitNormalGlobalFrame <<
G4endl
1610 <<
" Global point: " << IntersectPointGlobal <<
G4endl
1621 message <<
"============================================================"
1625 message <<
" State of Navigator: " <<
G4endl;
1626 message << *
this <<
G4endl;
1628 message <<
"============================================================"
1633 "Value obtained from stored global-normal is not a unit vector.");
1639 *pNormalCalculated = fCalculatedExitNormal;
1648 *pNormalCalculated = fCalculatedExitNormal;
1650 #ifdef G4DEBUG_NAVIGATION
1653 if( (!validNormal) && !fCalculatedExitNormal )
1656 edN <<
" Calculated = " << fCalculatedExitNormal <<
G4endl;
1657 edN <<
" Entering= " << fEntering <<
G4endl;
1660 edN <<
" State of Navigator: " <<
G4endl;
1666 "LocalExitNormalAndCheck() did not calculate Normal.");
1675 edN <<
"G4Navigator::GetGlobalExitNormal: "
1676 <<
" Using Local Normal - from call to GetLocalExitNormalAndCheck. "
1678 <<
" Local Exit Normal : " <<
" || = " << std::sqrt(localMag2)
1679 <<
" vec = " << localNormal <<
G4endl
1680 <<
" Global Exit Normal : " <<
" || = " << globalNormal.
mag()
1681 <<
" vec = " << globalNormal <<
G4endl
1682 <<
" Global point: " << IntersectPointGlobal <<
G4endl;
1683 edN <<
" Calculated It = " << fCalculatedExitNormal << G4endl
1696 "Value obtained from new local *solid* is incorrect.");
1697 localNormal = localNormal.
unit();
1703 #ifdef G4DEBUG_NAVIGATION
1714 G4ThreeVector diffNorm = globalNormAgn - fExitNormalGlobalFrame;
1718 edDfn <<
"Found difference in normals in case of exiting mother "
1719 <<
"- when Get is called after ComputingStep " <<
G4endl;
1720 edDfn <<
" Magnitude of diff = " << diffNorm.
mag() <<
G4endl;
1721 edDfn <<
" Normal stored (Global) = " << fExitNormalGlobalFrame
1723 edDfn <<
" Global Computed from Local = " << globalNormAgn <<
G4endl;
1724 G4Exception(
"G4Navigator::GetGlobalExitNormal()",
"GeomNav0003",
1732 fExitNormalGlobalFrame = globalNormal;
1734 return globalNormal;
1738 #define G4NEW_SAFETY 1
1755 #ifdef G4DEBUG_NAVIGATION
1759 G4cout <<
"*** G4Navigator::ComputeSafety: ***" <<
G4endl
1760 <<
" Called at point: " << pGlobalpoint <<
G4endl;
1764 <<
" - Maximum length = " << pMaxLength <<
G4endl;
1767 G4cout <<
" ----- Upon entering Compute Safety:" <<
G4endl;
1777 if( endpointOnSurface && stayedOnEndpoint )
1779 #ifdef G4DEBUG_NAVIGATION
1782 G4cout <<
" G4Navigator::ComputeSafety() finds that point - "
1783 << pGlobalpoint <<
" - is on surface " <<
G4endl;
1808 #ifdef G4DEBUG_NAVIGATION
1811 G4cout <<
" G4Navigator::ComputeSafety() relocates-in-volume to point: "
1812 << pGlobalpoint <<
G4endl;
1829 *motherPhysical, pMaxLength);
1830 newSafety= safetyTwo;
1835 newSafety= safetyOldVoxel;
1854 G4Exception(
"G4Navigator::ComputeSafety()",
"GeomNav0001",
1861 newSafety = freplicaNav.
ComputeSafety(pGlobalpoint, localPoint,
1874 fPreviousSftOrigin = pGlobalpoint;
1875 fPreviousSafety = newSafety;
1878 #ifdef G4DEBUG_NAVIGATION
1883 G4cout <<
" Returned value of Safety = " << newSafety <<
G4endl;
1885 G4cout.precision(oldcoutPrec);
1926 #ifdef CHECK_ORDER_OF_METHODS
1927 if( ! fLastTriedStepComputation )
1929 G4Exception(
"G4Navigator::RecheckDistanceToCurrentBoundary()",
1931 "Method must be called after ComputeStep(), before call to LocateMethod.");
1960 G4ThreeVector dgPosition= nextLevelTrf.TransformPoint(localPosition);
1961 G4ThreeVector dgDirection= nextLevelTrf.TransformAxis(localDirection);
1962 locatedDaug = candSolid->
Inside(dgPosition);
1971 true, &validExitNormal, &exitNormal);
1972 daughterStep= - distanceBackOut;
1999 daughterSafety= 0.0;
2008 *prDistance= daughterStep;
2009 if( prNewSafety ) { *prNewSafety= daughterSafety; }
2029 if( ProposedMove >= motherSafety )
2033 true, &validExitNormal, &exitNormal);
2037 motherStep= ProposedMove;
2042 motherSafety= motherSolid->
DistanceToIn(localPosition);
2043 if( ProposedMove >= motherSafety )
2053 if( prNewSafety ) { *prNewSafety= motherSafety; }
2062 *prDistance=
std::min( motherStep, daughterStep );
2065 *prNewSafety=
std::min( motherSafety, daughterSafety );
2089 G4cout <<
"The current state of G4Navigator is: " <<
G4endl;
2090 G4cout <<
" ValidExitNormal= " << fValidExitNormal
2091 <<
" ExitNormal = " << fExitNormal
2092 <<
" Exiting = " << fExiting
2093 <<
" Entering = " << fEntering
2094 <<
" BlockedPhysicalVolume= " ;
2095 if (fBlockedPhysicalVolume==0)
2104 <<
" BlockedReplicaNo = " << fBlockedReplicaNo
2105 <<
" LastStepWasZero = " << fLastStepWasZero
2111 G4cout << std::setw(30) <<
" ExitNormal " <<
" "
2112 << std::setw( 5) <<
" Valid " <<
" "
2113 << std::setw( 9) <<
" Exiting " <<
" "
2114 << std::setw( 9) <<
" Entering" <<
" "
2115 << std::setw(15) <<
" Blocked:Volume " <<
" "
2116 << std::setw( 9) <<
" ReplicaNo" <<
" "
2117 << std::setw( 8) <<
" LastStepZero " <<
" "
2119 G4cout <<
"( " << std::setw(7) << fExitNormal.
x()
2120 <<
", " << std::setw(7) << fExitNormal.
y()
2121 <<
", " << std::setw(7) << fExitNormal.
z() <<
" ) "
2122 << std::setw( 5) << fValidExitNormal <<
" "
2123 << std::setw( 9) << fExiting <<
" "
2124 << std::setw( 9) << fEntering <<
" ";
2125 if ( fBlockedPhysicalVolume==0 )
2126 {
G4cout << std::setw(15) <<
"None"; }
2128 {
G4cout << std::setw(15)<< fBlockedPhysicalVolume->
GetName(); }
2129 G4cout << std::setw( 9) << fBlockedReplicaNo <<
" "
2130 << std::setw( 8) << fLastStepWasZero <<
" "
2136 G4cout <<
" Current Localpoint = " << fLastLocatedPointLocal <<
G4endl;
2137 G4cout <<
" PreviousSftOrigin = " << fPreviousSftOrigin <<
G4endl;
2138 G4cout <<
" PreviousSafety = " << fPreviousSafety <<
G4endl;
2140 G4cout.precision(oldcoutPrec);
2147 void G4Navigator::ComputeStepLog(
const G4ThreeVector& pGlobalpoint,
2157 TransformPoint(fLastLocatedPointLocal);
2159 G4double shiftOriginSafSq = (fPreviousSftOrigin-pGlobalpoint).mag2();
2167 if( shiftOriginSafSq >=
sqr(fPreviousSafety) )
2169 G4double shiftOrigin = std::sqrt(shiftOriginSafSq);
2170 G4double diffShiftSaf = shiftOrigin - fPreviousSafety;
2172 if( diffShiftSaf > fAccuracyForWarning )
2176 std::ostringstream message, suggestion;
2177 message <<
"Accuracy error or slightly inaccurate position shift."
2179 <<
" The Step's starting point has moved "
2180 << std::sqrt(moveLenSq)/
mm <<
" mm " <<
G4endl
2181 <<
" since the last call to a Locate method." <<
G4endl
2182 <<
" This has resulted in moving "
2183 << shiftOrigin/
mm <<
" mm "
2184 <<
" from the last point at which the safety "
2185 <<
" was calculated " <<
G4endl
2186 <<
" which is more than the computed safety= "
2187 << fPreviousSafety/
mm <<
" mm at that point." <<
G4endl
2188 <<
" This difference is "
2189 << diffShiftSaf/
mm <<
" mm." <<
G4endl
2190 <<
" The tolerated accuracy is "
2191 << fAccuracyForException/
mm <<
" mm.";
2195 if( ((++warnNow % 100) == 1) )
2198 <<
" This problem can be due to either " <<
G4endl
2199 <<
" - a process that has proposed a displacement"
2200 <<
" larger than the current safety , or" <<
G4endl
2201 <<
" - inaccuracy in the computation of the safety";
2202 suggestion <<
"We suggest that you " << G4endl
2203 <<
" - find i) what particle is being tracked, and "
2204 <<
" ii) through what part of your geometry " << G4endl
2205 <<
" for example by re-running this event with "
2207 <<
" /tracking/verbose 1 " << G4endl
2208 <<
" - check which processes you declare for"
2209 <<
" this particle (and look at non-standard ones)"
2211 <<
" - in case, create a detailed logfile"
2212 <<
" of this event using:" << G4endl
2213 <<
" /tracking/verbose 6 ";
2217 message,
G4String(suggestion.str()));
2218 G4cout.precision(oldcoutPrec);
2219 G4cerr.precision(oldcerrPrec);
2221 #ifdef G4DEBUG_NAVIGATION
2224 G4cerr <<
"WARNING - G4Navigator::ComputeStep()" <<
G4endl
2225 <<
" The Step's starting point has moved "
2226 << std::sqrt(moveLenSq) <<
"," <<
G4endl
2227 <<
" which has taken it to the limit of"
2228 <<
" the current safety. " <<
G4endl;
2232 G4double safetyPlus = fPreviousSafety + fAccuracyForException;
2233 if ( shiftOriginSafSq >
sqr(safetyPlus) )
2235 std::ostringstream message;
2236 message <<
"May lead to a crash or unreliable results." <<
G4endl
2237 <<
" Position has shifted considerably without"
2238 <<
" notifying the navigator !" <<
G4endl
2239 <<
" Tolerated safety: " << safetyPlus <<
G4endl
2240 <<
" Computed shift : " << shiftOriginSafSq;
2241 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav1002",
2258 G4int oldcoutPrec = os.precision(4);
2261 os <<
"The current state of G4Navigator is: " <<
G4endl;
2262 os <<
" ValidExitNormal= " << n.fValidExitNormal << G4endl
2263 <<
" ExitNormal = " << n.fExitNormal << G4endl
2264 <<
" Exiting = " << n.fExiting << G4endl
2265 <<
" Entering = " << n.fEntering << G4endl
2266 <<
" BlockedPhysicalVolume= " ;
2267 if (n.fBlockedPhysicalVolume==0)
2270 os << n.fBlockedPhysicalVolume->
GetName();
2272 <<
" BlockedReplicaNo = " << n.fBlockedReplicaNo << G4endl
2273 <<
" LastStepWasZero = " << n.fLastStepWasZero << G4endl
2279 os << std::setw(30) <<
" ExitNormal " <<
" "
2280 << std::setw( 5) <<
" Valid " <<
" "
2281 << std::setw( 9) <<
" Exiting " <<
" "
2282 << std::setw( 9) <<
" Entering" <<
" "
2283 << std::setw(15) <<
" Blocked:Volume " <<
" "
2284 << std::setw( 9) <<
" ReplicaNo" <<
" "
2285 << std::setw( 8) <<
" LastStepZero " <<
" "
2287 os <<
"( " << std::setw(7) << n.fExitNormal.
x()
2288 <<
", " << std::setw(7) << n.fExitNormal.
y()
2289 <<
", " << std::setw(7) << n.fExitNormal.
z() <<
" ) "
2290 << std::setw( 5) << n.fValidExitNormal <<
" "
2291 << std::setw( 9) << n.fExiting <<
" "
2292 << std::setw( 9) << n.fEntering <<
" ";
2293 if ( n.fBlockedPhysicalVolume==0 )
2294 { os << std::setw(15) <<
"None"; }
2296 { os << std::setw(15)<< n.fBlockedPhysicalVolume->
GetName(); }
2297 os << std::setw( 9) << n.fBlockedReplicaNo <<
" "
2298 << std::setw( 8) << n.fLastStepWasZero <<
" "
2304 os <<
" Current Localpoint = " << n.fLastLocatedPointLocal <<
G4endl;
2305 os <<
" PreviousSftOrigin = " << n.fPreviousSftOrigin <<
G4endl;
2306 os <<
" PreviousSafety = " << n.fPreviousSafety <<
G4endl;
2313 os.precision(oldcoutPrec);
static constexpr double perMillion
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)
static constexpr double mm
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)
static const G4double kInfinity
virtual G4bool IsNested() const
#define fWasLimitedByGeometry
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)
G4VSolid * GetSolid() const
G4double ComputeSafety(const G4ThreeVector &localPoint, const G4VPhysicalVolume ¤tPhysical, G4double maxLength=DBL_MAX)
void SetSolid(G4VSolid *pSolid)
G4SmartVoxelNode * ParamVoxelLocate(G4SmartVoxelHeader *pHead, const G4ThreeVector &localPoint)
const G4RotationMatrix * GetRotation() const
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)
static double normal(HepRandomEngine *eptr)
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)
EVolume CharacteriseDaughters() const
virtual G4bool RecheckDistanceToCurrentBoundary(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double CurrentProposedStepLength, G4double *prDistance, G4double *prNewSafety=0) const
G4bool EnteredDaughterVolume() const
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
static constexpr double perMillion
#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)
const G4ThreeVector & GetTranslation() const
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 > &)
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
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)
const G4String & GetName() const
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)
G4GLOB_DLL std::ostream G4cerr