48 #define State(X) fpTrackState->X
49 #define fNewTrack State(fNewTrack)
50 #define fLimitedStep State(fLimitedStep)
51 #define fLimitTruth State(fLimitTruth)
52 #define fCurrentStepSize State(fCurrentStepSize)
53 #define fNoGeometriesLimiting State(fNoGeometriesLimiting)
54 #define fPreSafetyLocation State(fPreSafetyLocation)
55 #define fPreSafetyMinValue State(fPreSafetyMinValue)
56 #define fPreSafetyValues State(fPreSafetyValues)
57 #define fPreStepLocation State(fPreStepLocation)
58 #define fMinSafety_PreStepPt State(fMinSafety_PreStepPt)
59 #define fCurrentPreStepSafety State(fCurrentPreStepSafety)
60 #define fPreStepCenterRenewed State(fPreStepCenterRenewed)
61 #define fMinStep State(fMinStep)
62 #define fTrueMinStep State(fTrueMinStep)
63 #define fLocatedVolume State(fLocatedVolume)
64 #define fLastLocatedPosition State(fLastLocatedPosition)
65 #define fEndState State(fEndState)
66 #define fFieldExertedForce State(fFieldExertedForce)
67 #define fRelocatedPoint State(fRelocatedPoint)
68 #define fSafetyLocation State(fSafetyLocation)
69 #define fMinSafety_atSafLocation State(fMinSafety_atSafLocation)
70 #define fNewSafetyComputed State(fNewSafetyComputed)
71 #define fLastStepNo State(fLastStepNo)
72 #define fCurrentStepNo State(fCurrentStepNo)
164 #ifdef G4DEBUG_PATHFINDER
168 G4cout <<
" G4ITPathFinder::ComputeStep - entered " <<
G4endl;
169 G4cout <<
" - stepNo = " << std::setw(4) << stepNo <<
" "
170 <<
" navigatorId = " << std::setw(2) << navigatorNo <<
" "
171 <<
" proposed step len = " << proposedStepLength <<
" " <<
G4endl;
172 G4cout <<
" PF::ComputeStep requested step "
181 message <<
"Bad Navigator ID !" <<
G4endl
182 <<
" Requested Navigator ID = " << navigatorNo <<
G4endl
184 G4Exception(
"G4ITPathFinder::ComputeStep()",
"GeomNav0002",
207 #ifdef G4DEBUG_PATHFINDER
210 G4double moveLen= std::sqrt( moveLenSq );
211 G4cout <<
" G4ITPathFinder::ComputeStep : Point moved since last step "
212 <<
" -- at step # = " << stepNo <<
G4endl
213 <<
" by " << moveLen <<
" to " << newPosition <<
G4endl;
220 Locate( newPosition, newDirection );
254 #ifdef G4DEBUG_PATHFINDER
259 message <<
"Number of geometries limiting the step not set." <<
G4endl
260 <<
" Number of geometries limiting step = "
267 #ifdef G4DEBUG_PATHFINDER
273 message <<
"Problem in step size request." <<
G4endl
274 <<
" Error can be caused by incorrect process ordering."
275 <<
" Being requested to make a step which is shorter"
276 <<
" than the minimum Step " <<
G4endl
277 <<
" already computed for any Navigator/geometry during"
278 <<
" this tracking-step: " <<
G4endl
279 <<
" This can happen due to an error in process ordering."
281 <<
" Check that all physics processes are registered"
283 <<
" before all processes with a navigator/geometry."
285 <<
" If using pre-packaged physics list and/or"
287 <<
" functionality, please report this error."
289 <<
" Additional information for problem: " <<
G4endl
290 <<
" Steps request/proposed = " << proposedStepLength
294 <<
" MinimumStep (navraw) = " <<
fMinStep
296 <<
" Navigator raw return value" <<
G4endl
297 <<
" Requested step now = " << proposedStepLength
299 <<
" Difference min-req = "
301 <<
" -- Step info> stepNo= " << stepNo
316 G4cout <<
" G4P::CS -> Not calling DoNextLinearStep: "
317 <<
" stepNo= " << stepNo <<
" last= " <<
fLastStepNo
335 #ifdef G4DEBUG_PATHFINDER
338 G4cout <<
" G4ITPathFinder::ComputeStep returns "
340 <<
" for Navigator " << navigatorNo
341 <<
" Limited step = " << limitedStep
342 <<
" Safety(mm) = " << pNewSafety /
mm
374 std::vector<G4ITNavigator*>::iterator pNavigatorIter;
380 message <<
"Too many active Navigators / worlds." <<
G4endl
381 <<
" Transportation Manager has "
383 <<
" This is more than the number allowed = "
384 << G4ITNavigator::fMaxNav <<
" !";
385 G4Exception(
"G4ITPathFinder::PrepareNewTrack()",
"GeomNav0002",
407 if( fNoActiveNavigators > 1 )
409 Locate( position, direction,
false );
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 <<
G4endl
455 <<
" and current position to locate is " << NewVector;
456 G4Exception(
"G4ITPathFinder::ReportMove()",
"GeomNav1002",
468 std::vector<G4ITNavigator*>::iterator pNavIter=
477 ReportMove( position, lastEndPosition,
"Position" );
481 #ifdef G4DEBUG_PATHFINDER
485 G4cout <<
" G4ITPathFinder::Locate : entered " <<
G4endl;
487 G4cout <<
" Locating at position " << position
488 <<
" with direction " << direction
489 <<
" relative= " << relative <<
G4endl;
492 G4cout <<
" lastEndPosition = " << lastEndPosition
493 <<
" moveVec = " << moveVec
507 if(
fLimitTruth[
num] ) { (*pNavIter)->SetGeometricallyLimitedStep(); }
510 (*pNavIter)->LocateGlobalPointAndSetup( position, &direction,
522 #ifdef G4DEBUG_PATHFINDER
526 <<
" gives volume= " << pLocated ;
529 G4cout <<
" name = '" << pLocated->GetName() <<
"'";
530 G4cout <<
" - CopyNo= " << pLocated->GetCopyNo();
544 std::vector<G4ITNavigator*>::iterator pNavIter=
547 #ifdef G4DEBUG_PATHFINDER
572 G4double distCheckEnd_sq= ( moveLenEndPosSq - endPointSafety_Est1
573 *endPointSafety_Est1 );
577 G4bool longMoveEnd = distCheckEnd_sq > 0.0;
578 G4bool longMoveSaf = distCheckSaf_sq > 0.0;
582 if( (!
fNewTrack) && ( longMoveEnd && longMoveSaf ) )
593 G4double distCheckRevisedEnd= moveLenEndPosSq-revisedSafety*revisedSafety;
595 G4bool longMoveRevisedEnd= ( distCheckRevisedEnd > 0. ) ;
598 G4double moveLenEndPosition= std::sqrt( moveLenEndPosSq );
599 moveMinusSafety = moveLenEndPosition - revisedSafety;
601 if ( longMoveRevisedEnd && (moveMinusSafety > 0.0 )
602 && ( revisedSafety > 0.0 ) )
609 G4cout <<
" G4PF:Relocate> Ratio to revised safety is "
610 << std::fabs(moveMinusSafety)/revisedSafety <<
G4endl;
613 G4double absMoveMinusSafety= std::fabs(moveMinusSafety);
614 G4bool smallRatio= absMoveMinusSafety < kRadTolerance * revisedSafety ;
617 std::fabs(position.
y())),
618 std::fabs(position.
z()) );
619 G4bool smallValue= absMoveMinusSafety < cErrorTolerance * maxCoordPos;
620 if( ! (smallRatio || smallValue) )
622 G4cout <<
" G4PF:Relocate> Ratio to revised safety is "
623 << std::fabs(moveMinusSafety)/revisedSafety <<
G4endl;
624 G4cout <<
" Difference of move and safety is not very small."
629 moveMinusSafety = 0.0;
630 longMoveRevisedEnd =
false;
632 G4cout <<
" Difference of move & safety is very small in magnitude, "
633 << absMoveMinusSafety <<
G4endl;
636 G4cout <<
" ratio to safety " << revisedSafety
637 <<
" is " << absMoveMinusSafety / revisedSafety
638 <<
"smaller than " << kRadTolerance <<
" of safety ";
642 G4cout <<
" as fraction " << absMoveMinusSafety / maxCoordPos
643 <<
" of position vector max-coord " << maxCoordPos
644 <<
" smaller than " << cErrorTolerance ;
646 G4cout <<
" -- reset moveMinusSafety to "
647 << moveMinusSafety <<
G4endl;
651 if ( longMoveEnd && longMoveSaf
652 && longMoveRevisedEnd && (moveMinusSafety>0.0) )
656 message <<
"ReLocation is further than end-safety value." <<
G4endl
657 <<
" Moved from last endpoint by " << moveLenEndPosition
658 <<
" compared to end safety (from preStep point) = "
659 << endPointSafety_Est1 <<
G4endl
666 <<
" --> last EndStep Location was " << lastEndPosition
668 <<
" safety value = " << endPointSafety_Est1
669 <<
" raw-value = " << endPointSafety_raw <<
G4endl
670 <<
" --> Calling again at this endpoint, we get "
671 << revisedSafety <<
" as safety value." <<
G4endl
672 <<
" --> last position for safety " << fSafetyLocation
676 <<
" move from safety location = "
677 << std::sqrt(moveLenSafSq) <<
G4endl
678 <<
" again= " << moveVecSafety.
mag() <<
G4endl
679 <<
" safety - Move-from-end= "
680 << revisedSafety - moveLenEndPosition
681 <<
" (negative is Bad.)" <<
G4endl
682 <<
" Debug: distCheckRevisedEnd = "
683 << distCheckRevisedEnd;
684 ReportMove( lastEndPosition, position,
"Position" );
685 G4Exception(
"G4ITPathFinder::ReLocate",
"GeomNav0003",
687 G4cout.precision(oldPrec);
694 G4cout <<
" G4ITPathFinder::ReLocate : entered " <<
G4endl;
696 G4cout <<
" *Re*Locating at position " << position <<
G4endl;
701 G4cout <<
" lastEndPosition = " << lastEndPosition
702 <<
" moveVec from step-end = " << moveVecEndPos
707 #endif // G4DEBUG_PATHFINDER
713 (*pNavIter)->LocateGlobalPointWithinVolume( position );
725 #ifdef G4DEBUG_PATHFINDER
728 G4cout <<
" G4ITPathFinder::ReLocate : exiting "
742 std::vector<G4ITNavigator*>::iterator pNavigatorIter;
747 G4double safety = (*pNavigatorIter)->ComputeSafety( position,
true );
748 if( safety < minSafety ) { minSafety = safety; }
755 #ifdef G4DEBUG_PATHFINDER
758 G4cout <<
" G4ITPathFinder::ComputeSafety - returns "
759 << minSafety <<
" at location " << position <<
G4endl;
771 #ifdef G4DEBUG_PATHFINDER
774 G4cout <<
"G4ITPathFinder::CreateTouchableHandle : navId = "
780 touchHist=
GetNavigator(navId) -> CreateTouchableHistory();
783 if( locatedVolume == 0 )
790 #ifdef G4DEBUG_PATHFINDER
794 if( locatedVolume ) { VolumeName= locatedVolume->
GetName(); }
795 G4cout <<
" Touchable History created at address " << touchHist
796 <<
" volume = " << locatedVolume <<
" name= " << VolumeName
808 std::vector<G4ITNavigator*>::iterator pNavigatorIter;
812 const G4int IdTransport= 0;
815 #ifdef G4DEBUG_PATHFINDER
818 G4cout <<
" G4ITPathFinder::DoNextLinearStep : entered " <<
G4endl;
819 G4cout <<
" Input field track= " << initialState <<
G4endl;
820 G4cout <<
" Requested step= " << proposedStepLength <<
G4endl;
837 MagShift= std::sqrt(MagSqShift) ;
839 #ifdef G4PATHFINDER_OPTIMISATION
851 if( proposedStepLength < fullSafety )
862 minSafety=
std::min( safety, minSafety );
867 #ifdef G4DEBUG_PATHFINDER
870 G4cout <<
"G4ITPathFinder::DoNextLinearStep : Quick Stepping. " <<
G4endl
871 <<
" proposedStepLength " << proposedStepLength
872 <<
" < (full) safety = " << fullSafety
873 <<
" at " << initialPosition
879 #endif // End of G4PATHFINDER_OPTIMISATION 1
893 #ifdef G4PATHFINDER_OPTIMISATION
894 if( proposedStepLength <= safety )
900 #ifdef G4DEBUG_PATHFINDER
902 G4cout <<
"G4ITNavigator::ComputeStep> small proposed step = "
903 << proposedStepLength
904 <<
" <= safety = " << safety <<
" for nav " << num
905 <<
" Step fully taken. " <<
G4endl;
909 #endif // End of G4PATHFINDER_OPTIMISATION 2
911 #ifdef G4DEBUG_PATHFINDER
914 step= (*pNavigatorIter)->ComputeStep( initialPosition,
923 #ifdef G4DEBUG_PATHFINDER
927 G4cout <<
"G4ITNavigator::ComputeStep> long proposed step = "
928 << proposedStepLength
929 <<
" > safety = " << previousSafety
930 <<
" for nav " << num
931 <<
" . New safety = " << safety <<
" step= " <<
step
945 minSafety=
std::min( safety, minSafety );
947 #ifdef G4DEBUG_PATHFINDER
950 G4cout <<
"G4ITPathFinder::DoNextLinearStep : Navigator ["
951 << num <<
"] -- step size " <<
step <<
G4endl;
959 fPreSafetyLocation= initialPosition;
972 minStep = proposedStepLength;
981 endPosition= initialPosition + minStep * initialDirection ;
983 #ifdef G4DEBUG_PATHFINDER
986 G4cout <<
"G4ITPathFinder::DoNextLinearStep : "
987 <<
" initialPosition = " << initialPosition
988 <<
" and endPosition = " << endPosition<<
G4endl;
993 fEndState.SetProperTimeOfFlight( -1.000 );
1009 #ifdef G4DEBUG_PATHFINDER
1012 G4cout <<
" G4ITPathFinder::DoNextLinearStep : exits returning "
1030 const G4int IdTransport= 0;
1037 if( transportLimited ) {
1064 if( (last > -1) && (noLimited == 1 ) )
1069 #ifdef G4DEBUG_PATHFINDER
1074 G4cout <<
" G4ITPathFinder::WhichLimited - exiting. " <<
G4endl;
1084 G4cout <<
"G4ITPathFinder::PrintLimited reports: " ;
1090 G4cout << std::setw(5) <<
" Step#" <<
" "
1091 << std::setw(5) <<
" NavId" <<
" "
1092 << std::setw(12) <<
" step-size " <<
" "
1093 << std::setw(12) <<
" raw-size " <<
" "
1094 << std::setw(12) <<
" pre-safety " <<
" "
1095 << std::setw(15) <<
" Limited / flag" <<
" "
1096 << std::setw(15) <<
" World " <<
" "
1111 << std::setw(5) << num <<
" "
1112 << std::setw(12) << stepLen <<
" "
1113 << std::setw(12) << rawStep <<
" "
1117 G4cout <<
" " << std::setw(15) << limitedStr <<
" ";
1118 G4cout.precision(oldPrec);
1127 WorldName = pWorld->
GetName();
1130 G4cout <<
" " << WorldName ;
1136 G4cout <<
" G4ITPathFinder::PrintLimited - exiting. " <<
G4endl;
1145 const G4double toleratedRelativeError= 1.0e-10;
1151 #ifdef G4DEBUG_PATHFINDER
1155 G4cout <<
" G4ITPathFinder::DoNextCurvedStep ****** " <<
G4endl;
1156 G4cout <<
" Initial value of field track is " << fieldTrack
1157 <<
" and proposed step= " << proposedStepLength <<
G4endl;
1170 safety=
fpNavigator[numNav]->ComputeSafety( startPoint,
false );
1173 minSafety =
std::min( safety, minSafety );
1214 #ifdef G4DEBUG_PATHFINDER
1217 G4cout <<
"G4ITPathFinder::DoNextCurvedStep : " <<
G4endl
1218 <<
" initialState = " << initialState <<
G4endl
1220 G4cout <<
"G4ITPathFinder::DoNextCurvedStep : "
1221 <<
" minStep = " << minStep
1222 <<
" proposedStepLength " << proposedStepLength
1223 <<
" safety = " << newSafety <<
G4endl;
1227 if( minStep < proposedStepLength )
1235 G4double finalStep, lastPreSafety=0.0, minStepLast;
1240 minStepLast, didLimit );
1249 diffStep = (finalStep-minStepLast);
1250 if (
std::abs(diffStep) <= toleratedRelativeError * finalStep )
1254 currentStepSize += diffStep;
1271 if( limited ) { noLimited++; }
1273 #ifdef G4DEBUG_PATHFINDER
1274 G4bool StepError= (currentStepSize < 0)
1275 || ( (minStepLast !=
kInfinity) && (diffStep < 0) ) ;
1280 G4cout <<
" G4ITPathFinder::ComputeStep. Geometry " << numNav
1282 <<
" from final-step= " << finalStep
1284 <<
" minStepLast= " << minStepLast
1285 <<
" limited = " << (
fLimitTruth[numNav] ?
"YES" :
" NO")
1287 G4cout <<
" status = " << limitedString <<
" #= " << didLimit
1293 message <<
"Incorrect calculation of step size for one navigator"
1295 <<
" currentStepSize = " << currentStepSize
1296 <<
", diffStep= " << diffStep << G4endl
1297 <<
"ERROR in computing step size for this navigator.";
1307 else if ( (minStep == proposedStepLength)
1309 || (
std::abs(minStep-proposedStepLength)
1310 < toleratedRelativeError * proposedStepLength ) )
1319 currentStepSize= minStep;
1332 message <<
"Incorrect calculation of step size for one navigator." <<
G4endl
1333 <<
" currentStepSize = " << minStep <<
" is larger than "
1334 <<
" proposed StepSize = " << proposedStepLength <<
".";
1339 #ifdef G4DEBUG_PATHFINDER
1342 G4cout <<
" Exiting G4ITPathFinder::DoNextCurvedStep " <<
G4endl;
1354 StrUnique(
"Unique"),
1355 StrUndefined(
"Undefined"),
1356 StrSharedTransport(
"SharedTransport"),
1357 StrSharedOther(
"SharedOther");
1362 case kDoNot: limitedStr= &StrDoNot;
break;
1363 case kUnique: limitedStr = &StrUnique;
break;
1365 case kSharedOther: limitedStr = &StrSharedOther;
break;
1366 default: limitedStr = &StrUndefined;
break;