117 G4Navigator *navigatorForPropagation =
nullptr, *massNavigator =
nullptr;
130 navigatorForPropagation = massNavigator;
153 #ifdef G4DEBUG_PATHFINDER
157 G4cout <<
" G4PathFinder::ComputeStep - entered " <<
G4endl;
158 G4cout <<
" - stepNo = " << std::setw(4) << stepNo <<
" "
159 <<
" navigatorId = " << std::setw(2) << navigatorNo <<
" "
160 <<
" proposed step len = " << proposedStepLength <<
" " <<
G4endl;
161 G4cout <<
" PF::ComputeStep requested step "
170 message <<
"Bad Navigator ID !" <<
G4endl
171 <<
" Requested Navigator ID = " << navigatorNo <<
G4endl
173 G4Exception(
"G4PathFinder::ComputeStep()",
"GeomNav0002",
196 #ifdef G4DEBUG_PATHFINDER
199 G4double moveLen= std::sqrt( moveLenSq );
200 G4cout <<
" G4PathFinder::ComputeStep : Point moved since last step "
201 <<
" -- at step # = " << stepNo <<
G4endl
202 <<
" by " << moveLen <<
" to " << newPosition <<
G4endl;
209 Locate( newPosition, newDirection );
218 if( particleCharge != 0.0 )
224 fieldExertsForce = (fieldMgr !=
nullptr)
231 if( fieldExertsForce )
242 #ifdef G4DEBUG_PATHFINDER
247 message <<
"Number of geometries limiting the step not set." <<
G4endl
248 <<
" Number of geometries limiting step = "
255 #ifdef G4DEBUG_PATHFINDER
258 const G4double checkTolerance = 1.0e-9;
259 if( proposedStepLength <
fTrueMinStep * ( 1.0 - checkTolerance) )
262 message.precision( 12 );
263 message <<
"Problem in step size request." <<
G4endl
264 <<
" Being requested to make a step which is shorter"
265 <<
" than the minimum Step " <<
G4endl
266 <<
" already computed for any Navigator/geometry during"
267 <<
" this tracking-step: " <<
G4endl
268 <<
" This could happen due to an error in process ordering."
270 <<
" Check that all physics processes are registered"
271 <<
" before all processes with a navigator/geometry."
273 <<
" If using pre-packaged physics list and/or"
274 <<
" functionality, please report this error."
276 <<
" Additional information for problem: " <<
G4endl
277 <<
" Steps request/proposed = " << proposedStepLength
281 <<
" MinimumStep (navraw) = " <<
fMinStep
283 <<
" Navigator raw return value" <<
G4endl
284 <<
" Requested step now = " << proposedStepLength
286 <<
" Difference min-req (absolute) = "
288 <<
" Relative (to max of two) = "
291 <<
" -- Step info> stepNo= " << stepNo
306 G4cout <<
" G4P::CS -> Not calling DoNextLinearStep: "
307 <<
" stepNo= " << stepNo <<
" last= " <<
fLastStepNo
324 #ifdef G4DEBUG_PATHFINDER
327 G4cout <<
" G4PathFinder::ComputeStep returns "
329 <<
" for Navigator " << navigatorNo
330 <<
" Limited step = " << limitedStep
331 <<
" Safety(mm) = " << pNewSafety /
mm
365 std::vector<G4Navigator*>::iterator pNavigatorIter;
371 message <<
"Too many active Navigators / worlds." <<
G4endl
372 <<
" Transportation Manager has "
374 <<
" This is more than the number allowed = "
376 G4Exception(
"G4PathFinder::PrepareNewTrack()",
"GeomNav0002",
398 if( fNoActiveNavigators > 1 )
400 Locate( position, direction,
false );
447 message.precision(16);
448 message <<
"Endpoint moved between value returned by ComputeStep()"
449 <<
" and call to Locate(). " <<
G4endl
450 <<
" Change of " << Quantity <<
" is "
452 <<
" and its vector is "
453 << (1.0/
mm) * moveVec <<
" mm " <<
G4endl
454 <<
" Endpoint of ComputeStep() was " << OldVector
456 <<
" and current position to locate is " << NewVector;
457 G4Exception(
"G4PathFinder::ReportMove()",
"GeomNav1002",
469 std::vector<G4Navigator*>::iterator pNavIter =
476 if( (!
fNewTrack) && ( moveLenSq > movLenTol ) )
479 " (End) Position / G4PathFinder::Locate" );
483 #ifdef G4DEBUG_PATHFINDER
489 G4cout <<
" Locating at position " << position
490 <<
" with direction " << direction
491 <<
" relative= " << relative <<
G4endl;
494 G4cout <<
" lastEndPosition = " << lastEndPosition
495 <<
" moveVec = " << moveVec
509 if(
fLimitTruth[
num] ) { (*pNavIter)->SetGeometricallyLimitedStep(); }
512 (*pNavIter)->LocateGlobalPointAndSetup( position, &direction,
524 #ifdef G4DEBUG_PATHFINDER
528 <<
" gives volume= " << pLocated ;
531 G4cout <<
" name = '" << pLocated->GetName() <<
"'";
532 G4cout <<
" - CopyNo= " << pLocated->GetCopyNo();
546 std::vector<G4Navigator*>::iterator pNavIter =
549 #ifdef G4DEBUG_PATHFINDER
574 G4double distCheckEnd_sq = ( moveLenEndPosSq - endPointSafety_Est1
575 *endPointSafety_Est1 );
579 G4bool longMoveEnd = distCheckEnd_sq > 0.0;
580 G4bool longMoveSaf = distCheckSaf_sq > 0.0;
584 if( (!
fNewTrack) && ( longMoveEnd && longMoveSaf ) )
595 G4double distCheckRevisedEnd = moveLenEndPosSq -
sqr(revisedSafety);
597 G4bool longMoveRevisedEnd = ( distCheckRevisedEnd > 0. ) ;
600 G4double moveLenEndPosition = std::sqrt( moveLenEndPosSq );
601 moveMinusSafety = moveLenEndPosition - revisedSafety;
603 if ( longMoveRevisedEnd && ( moveMinusSafety > 0.0 )
604 && ( revisedSafety > 0.0 ) )
611 G4cout <<
" G4PF:Relocate> Ratio to revised safety is "
612 << std::fabs(moveMinusSafety)/revisedSafety <<
G4endl;
615 G4double absMoveMinusSafety = std::fabs(moveMinusSafety);
616 G4bool smallRatio = absMoveMinusSafety < kRadTolerance * revisedSafety;
619 std::fabs(position.
y())),
620 std::fabs(position.
z()) );
621 G4bool smallValue= absMoveMinusSafety < cErrorTolerance * maxCoordPos;
622 if( !(smallRatio || smallValue) )
624 G4cout <<
" G4PF:Relocate> Ratio to revised safety is "
625 << std::fabs(moveMinusSafety)/revisedSafety <<
G4endl;
626 G4cout <<
" Difference of move and safety is not very small."
631 moveMinusSafety = 0.0;
632 longMoveRevisedEnd =
false;
634 G4cout <<
" Difference of move & safety is very small in magnitude, "
635 << absMoveMinusSafety <<
G4endl;
638 G4cout <<
" ratio to safety " << revisedSafety
639 <<
" is " << absMoveMinusSafety / revisedSafety
640 <<
"smaller than " << kRadTolerance <<
" of safety ";
644 G4cout <<
" as fraction " << absMoveMinusSafety / maxCoordPos
645 <<
" of position vector max-coord " << maxCoordPos
646 <<
" smaller than " << cErrorTolerance ;
648 G4cout <<
" -- reset moveMinusSafety to "
649 << moveMinusSafety <<
G4endl;
653 if ( longMoveEnd && longMoveSaf
654 && longMoveRevisedEnd && (moveMinusSafety>0.0) )
657 message.precision(9);
658 message <<
"ReLocation is further than end-safety value." <<
G4endl
659 <<
" Moved from last endpoint by " << moveLenEndPosition
660 <<
" compared to end safety (from preStep point) = "
661 << endPointSafety_Est1 <<
G4endl
668 <<
" --> last EndStep Location was " << lastEndPosition
670 <<
" safety value = " << endPointSafety_Est1
671 <<
" raw-value = " << endPointSafety_raw <<
G4endl
672 <<
" --> Calling again at this endpoint, we get "
673 << revisedSafety <<
" as safety value." <<
G4endl
674 <<
" --> last position for safety " << fSafetyLocation
678 <<
" move from safety location = "
679 << std::sqrt(moveLenSafSq) <<
G4endl
680 <<
" again= " << moveVecSafety.
mag() <<
G4endl
681 <<
" safety - Move-from-end= "
682 << revisedSafety - moveLenEndPosition
683 <<
" (negative is Bad.)" <<
G4endl
684 <<
" Debug: distCheckRevisedEnd = "
685 << distCheckRevisedEnd;
686 ReportMove( lastEndPosition, position,
"Position" );
687 G4Exception(
"G4PathFinder::ReLocate",
"GeomNav0003",
695 G4cout <<
" G4PathFinder::ReLocate : entered " <<
G4endl;
697 G4cout <<
" *Re*Locating at position " << position <<
G4endl;
700 G4cout <<
" lastEndPosition = " << lastEndPosition
701 <<
" moveVec from step-end = " << moveVecEndPos
706 #endif // G4DEBUG_PATHFINDER
712 (*pNavIter)->LocateGlobalPointWithinVolume( position );
724 #ifdef G4DEBUG_PATHFINDER
727 G4cout <<
" G4PathFinder::ReLocate : exiting "
741 std::vector<G4Navigator*>::iterator pNavigatorIter;
746 G4double safety = (*pNavigatorIter)->ComputeSafety(position,
DBL_MAX,
true);
747 if( safety < minSafety ) { minSafety = safety; }
754 #ifdef G4DEBUG_PATHFINDER
757 G4cout <<
" G4PathFinder::ComputeSafety - returns "
758 << minSafety <<
" at location " << position <<
G4endl;
770 #ifdef G4DEBUG_PATHFINDER
773 G4cout <<
"G4PathFinder::CreateTouchableHandle : navId = "
782 if( locatedVolume ==
nullptr )
789 #ifdef G4DEBUG_PATHFINDER
793 if( locatedVolume ) { VolumeName = locatedVolume->
GetName(); }
794 G4cout <<
" Touchable History created at address " << touchHist
795 <<
"; volume = " << locatedVolume <<
"; name= " << VolumeName
807 std::vector<G4Navigator*>::iterator pNavigatorIter;
811 const G4int IdTransport = 0;
814 #ifdef G4DEBUG_PATHFINDER
817 G4cout <<
" G4PathFinder::DoNextLinearStep : entered " <<
G4endl;
818 G4cout <<
" Input field track= " << initialState <<
G4endl;
819 G4cout <<
" Requested step= " << proposedStepLength <<
G4endl;
836 MagShift= std::sqrt(MagSqShift) ;
838 #ifdef G4PATHFINDER_OPTIMISATION
850 if( proposedStepLength < fullSafety )
861 minSafety=
std::min( safety, minSafety );
866 #ifdef G4DEBUG_PATHFINDER
869 G4cout <<
"G4PathFinder::DoNextLinearStep : Quick Stepping. " <<
G4endl
870 <<
" proposedStepLength " << proposedStepLength
871 <<
" < (full) safety = " << fullSafety
872 <<
" at " << initialPosition
878 #endif // End of G4PATHFINDER_OPTIMISATION 1
892 #ifdef G4PATHFINDER_OPTIMISATION
893 if( proposedStepLength <= safety )
899 #ifdef G4DEBUG_PATHFINDER
901 G4cout <<
"PathFinder::ComputeStep> small proposed step = "
902 << proposedStepLength
903 <<
" <= safety = " << safety <<
" for nav " << num
904 <<
" Step fully taken. " <<
G4endl;
908 #endif // End of G4PATHFINDER_OPTIMISATION 2
910 #ifdef G4DEBUG_PATHFINDER
913 step = (*pNavigatorIter)->ComputeStep( initialPosition,
920 #ifdef G4DEBUG_PATHFINDER
924 G4cout <<
"PathFinder::ComputeStep> long proposed step = "
925 << proposedStepLength
926 <<
" > safety = " << previousSafety
927 <<
" for nav " << num
928 <<
" . New safety = " << safety <<
" step= " <<
step
946 minSafety =
std::min( safety, minSafety );
948 #ifdef G4DEBUG_PATHFINDER
951 G4cout <<
"G4PathFinder::DoNextLinearStep : Navigator ["
952 << num <<
"] -- step size " <<
step <<
G4endl;
960 fPreSafetyLocation = initialPosition;
973 minStep = proposedStepLength;
982 endPosition = initialPosition + minStep * initialDirection ;
984 #ifdef G4DEBUG_PATHFINDER
988 G4cout <<
"G4PathFinder::DoNextLinearStep : "
989 <<
" initialPosition = " << initialPosition
990 <<
" and endPosition = " << endPosition<<
G4endl;
991 G4cout.precision(oldPrec);
1012 #ifdef G4DEBUG_PATHFINDER
1015 G4cout <<
" G4PathFinder::DoNextLinearStep : exits returning "
1030 G4int noLimited = 0;
1033 const G4int IdTransport = 0;
1040 if( transportLimited )
1068 if( (last > -1) && (noLimited == 1 ) )
1073 #ifdef G4DEBUG_PATHFINDER
1079 G4cout <<
" G4PathFinder::WhichLimited - exiting. " <<
G4endl;
1089 G4cout <<
"G4PathFinder::PrintLimited reports: " ;
1095 G4cout << std::setw(5) <<
" Step#" <<
" "
1096 << std::setw(5) <<
" NavId" <<
" "
1097 << std::setw(12) <<
" step-size " <<
" "
1098 << std::setw(12) <<
" raw-size " <<
" "
1099 << std::setw(12) <<
" pre-safety " <<
" "
1100 << std::setw(15) <<
" Limited / flag" <<
" "
1101 << std::setw(15) <<
" World " <<
" "
1115 << std::setw(5) <<
num <<
" "
1116 << std::setw(12) << stepLen <<
" "
1117 << std::setw(12) << rawStep <<
" "
1121 G4cout <<
" " << std::setw(15) << limitedStr <<
" ";
1122 G4cout.precision(oldPrec);
1126 if (pNav !=
nullptr)
1131 WorldName = pWorld->
GetName();
1134 G4cout <<
" " << WorldName ;
1140 G4cout <<
" G4PathFinder::PrintLimited - exiting. " <<
G4endl;
1149 const G4double toleratedRelativeError = 1.0e-10;
1163 #ifdef G4DEBUG_PATHFINDER
1167 G4cout <<
" G4PathFinder::DoNextCurvedStep ****** " <<
G4endl;
1168 G4cout <<
" Initial value of field track is " << fieldTrack
1169 <<
" and proposed step= " << proposedStepLength <<
G4endl;
1185 minSafety =
std::min( safety, minSafety );
1201 pCurrentPhysicalVolume,
1226 #ifdef G4DEBUG_PATHFINDER
1229 G4cout <<
"G4PathFinder::DoNextCurvedStep : " <<
G4endl
1230 <<
" initialState = " << initialState <<
G4endl
1232 G4cout <<
"G4PathFinder::DoNextCurvedStep : "
1233 <<
" minStep = " << minStep
1234 <<
" proposedStepLength " << proposedStepLength
1235 <<
" safety = " << newSafety <<
G4endl;
1239 if( minStep < proposedStepLength )
1244 G4int noLimited = 0;
1247 G4double finalStep, lastPreSafety = 0.0, minStepLast;
1252 minStepLast, didLimit );
1261 diffStep = (finalStep-minStepLast);
1262 if (
std::abs(diffStep) <= toleratedRelativeError * finalStep )
1266 currentStepSize += diffStep;
1283 if( limited ) { ++noLimited; }
1285 #ifdef G4DEBUG_PATHFINDER
1286 G4bool StepError = (currentStepSize < 0)
1287 || ( (minStepLast !=
kInfinity) && (diffStep < 0) ) ;
1292 G4cout <<
" G4PathFinder::ComputeStep. Geometry " << numNav
1294 <<
" from final-step= " << finalStep
1296 <<
" minStepLast= " << minStepLast
1297 <<
" limited = " << (
fLimitTruth[numNav] ?
"YES" :
" NO")
1299 G4cout <<
" status = " << limitedString <<
" #= " << didLimit
1305 message <<
"Incorrect calculation of step size for one navigator"
1307 <<
" currentStepSize = " << currentStepSize
1308 <<
", diffStep= " << diffStep << G4endl
1309 <<
"ERROR in computing step size for this navigator.";
1319 else if ( (minStep == proposedStepLength)
1321 || (
std::abs(minStep-proposedStepLength)
1322 < toleratedRelativeError * proposedStepLength ) )
1331 currentStepSize = minStep;
1344 message <<
"Incorrect calculation of step size for one navigator." <<
G4endl
1345 <<
" currentStepSize = " << minStep <<
" is larger than "
1346 <<
" proposed StepSize = " << proposedStepLength <<
".";
1351 #ifdef G4DEBUG_PATHFINDER
1354 G4cout <<
" Exiting G4PathFinder::DoNextCurvedStep " <<
G4endl;
1390 minSafety =
std::min( safety, minSafety );
1391 minMove =
std::min( distance, minMove );
1397 *prDistance = minMove;
1400 *prNewSafety = minSafety;
1416 StrUnique(
"Unique"),
1417 StrUndefined(
"Undefined"),
1418 StrSharedTransport(
"SharedTransport"),
1419 StrSharedOther(
"SharedOther");
1424 case kDoNot: limitedStr = &StrDoNot;
break;
1425 case kUnique: limitedStr = &StrUnique;
break;
1427 case kSharedOther: limitedStr = &StrSharedOther;
break;
1428 default: limitedStr = &StrUndefined;
break;