54 if( fpPathFinder ==
nullptr )
85 fLastLocatedPosition= Big3Vector;
86 fSafetyLocation= Big3Vector;
87 fPreSafetyLocation= Big3Vector;
88 fPreStepLocation= Big3Vector;
90 for(
auto num=0; num<fMaxNav; ++num )
92 fpNavigator[num] =
nullptr;
93 fLimitTruth[num] =
false;
95 fCurrentStepSize[num] = -1.0;
96 fLocatedVolume[num] = 0;
97 fPreSafetyValues[num]= -1.0;
98 fCurrentPreStepSafety[num] = -1.0;
99 fNewSafetyComputed[num]= -1.0;
108 delete fpMultiNavigator;
117 G4Navigator *navigatorForPropagation =
nullptr, *massNavigator =
nullptr;
122 navigatorForPropagation = fpMultiNavigator;
130 navigatorForPropagation = massNavigator;
153#ifdef G4DEBUG_PATHFINDER
154 if( fVerboseLevel > 2 )
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 "
167 if( navigatorNo >= fNoActiveNavigators )
169 std::ostringstream message;
170 message <<
"Bad Navigator ID !" <<
G4endl
171 <<
" Requested Navigator ID = " << navigatorNo <<
G4endl
172 <<
" Number of active navigators = " << fNoActiveNavigators;
173 G4Exception(
"G4PathFinder::ComputeStep()",
"GeomNav0002",
178 if( fNewTrack || (stepNo != fLastStepNo) )
185 fCurrentStepNo = stepNo;
191 G4ThreeVector moveVector = newPosition - fLastLocatedPosition;
193 if( moveLenSq >
sqr(kCarTolerance) )
196#ifdef G4DEBUG_PATHFINDER
197 if( fVerboseLevel > 2 )
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 );
217 G4bool fieldExertsForce = false ;
218 if( particleCharge != 0.0 )
224 fieldExertsForce = (fieldMgr !=
nullptr)
227 fFieldExertedForce = fieldExertsForce;
230 fNoGeometriesLimiting = -1;
231 if( fieldExertsForce )
239 fLastStepNo = stepNo;
240 fRelocatedPoint =
false;
242#ifdef G4DEBUG_PATHFINDER
243 if ( (fNoGeometriesLimiting < 0)
244 || (fNoGeometriesLimiting > fNoActiveNavigators) )
246 std::ostringstream message;
247 message <<
"Number of geometries limiting the step not set." <<
G4endl
248 <<
" Number of geometries limiting step = "
249 << fNoGeometriesLimiting;
255#ifdef G4DEBUG_PATHFINDER
258 const G4double checkTolerance = 1.0e-9;
259 if( proposedStepLength < fTrueMinStep * ( 1.0 - checkTolerance) )
261 std::ostringstream message;
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
279 <<
" MinimumStep (true) = " << fTrueMinStep
281 <<
" MinimumStep (navraw) = " << fMinStep
283 <<
" Navigator raw return value" <<
G4endl
284 <<
" Requested step now = " << proposedStepLength
286 <<
" Difference min-req (absolute) = "
287 << fTrueMinStep-proposedStepLength <<
G4endl
288 <<
" Relative (to max of two) = "
289 << (fTrueMinStep-proposedStepLength)
290 / std::max(proposedStepLength, fTrueMinStep) <<
G4endl
291 <<
" -- Step info> stepNo= " << stepNo
292 <<
" last= " << fLastStepNo
293 <<
" newTr= " << fNewTrack <<
G4endl;
304 if( fVerboseLevel > 1 )
306 G4cout <<
" G4P::CS -> Not calling DoNextLinearStep: "
307 <<
" stepNo= " << stepNo <<
" last= " << fLastStepNo
308 <<
" new= " << fNewTrack <<
" Step already done" <<
G4endl;
318 pNewSafety = fCurrentPreStepSafety[ navigatorNo ];
319 limitedStep = fLimitedStep[ navigatorNo ];
321 possibleStep = std::min(proposedStepLength, fCurrentStepSize[ navigatorNo ]);
322 EndState = fEndState;
324#ifdef G4DEBUG_PATHFINDER
325 if( fVerboseLevel > 0 )
327 G4cout <<
" G4PathFinder::ComputeStep returns "
328 << fCurrentStepSize[ navigatorNo ]
329 <<
" for Navigator " << navigatorNo
330 <<
" Limited step = " << limitedStep
331 <<
" Safety(mm) = " << pNewSafety / mm
365 std::vector<G4Navigator*>::iterator pNavigatorIter;
367 fNoActiveNavigators = (
G4int)fpTransportManager-> GetNoActiveNavigators();
368 if( fNoActiveNavigators > fMaxNav )
370 std::ostringstream message;
371 message <<
"Too many active Navigators / worlds." <<
G4endl
372 <<
" Transportation Manager has "
373 << fNoActiveNavigators <<
" active navigators." <<
G4endl
374 <<
" This is more than the number allowed = "
376 G4Exception(
"G4PathFinder::PrepareNewTrack()",
"GeomNav0002",
384 for( num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
388 fpNavigator[num] = *pNavigatorIter;
389 fLimitTruth[num] =
false;
390 fLimitedStep[num] =
kDoNot;
391 fCurrentStepSize[num] = 0.0;
392 fLocatedVolume[num] =
nullptr;
394 fNoGeometriesLimiting = 0;
398 if( fNoActiveNavigators > 1 )
407 fLocatedVolume[0] = massStartVol;
410 fCurrentStepSize[0] = 0.0;
416 fMinSafety_PreStepPt = fPreSafetyMinValue = fMinSafety_atSafLocation = 0.0;
418 for( num=0; num<fNoActiveNavigators; ++num )
420 fPreSafetyValues[num] = 0.0;
421 fNewSafetyComputed[num] = 0.0;
422 fCurrentPreStepSafety[num] = 0.0;
428 fRelocatedPoint =
false;
446 std::ostringstream message;
447 message.precision(16);
448 message <<
"Endpoint moved between value returned by ComputeStep()"
449 <<
" and call to Locate(). " <<
G4endl
450 <<
" Change of " << Quantity <<
" is "
451 << moveVec.
mag() / mm <<
" mm long" <<
G4endl
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",
470 ? fLastLocatedPosition
474#ifdef G4DEBUG_PATHFINDER
475 static const G4double movLenTol = 10*
sqr(kCarTolerance);
479 if( (!fNewTrack) && ( moveLenSq > movLenTol ) )
482 " (End) Position / G4PathFinder::Locate" );
485 if( fVerboseLevel > 2 )
491 <<
" with direction " << direction
492 <<
" relative= " << relative <<
G4endl;
493 if ( (fVerboseLevel > 1) || ( moveLenSq > 0.0) )
495 G4cout <<
" lastEndPosition = " << lastEndPosition
496 <<
" moveVec = " << moveVec
497 <<
" newTr = " << fNewTrack
498 <<
" relocated = " << fRelocatedPoint <<
G4endl;
506 for (
auto num=0; num<fNoActiveNavigators ; ++pNavIter,++num )
510 if( fLimitTruth[num] ) { (*pNavIter)->SetGeometricallyLimitedStep(); }
513 (*pNavIter)->LocateGlobalPointAndSetup(
position, &direction,
518 fLocatedVolume[num] = pLocated;
522 fLimitedStep[num] =
kDoNot;
523 fCurrentStepSize[num] = 0.0;
525#ifdef G4DEBUG_PATHFINDER
526 if( fVerboseLevel > 2 )
528 G4cout <<
" - In world " << num <<
" geomLimStep= " << fLimitTruth[num]
529 <<
" gives volume= " << pLocated ;
532 G4cout <<
" name = '" << pLocated->GetName() <<
"'";
533 G4cout <<
" - CopyNo= " << pLocated->GetCopyNo();
540 fRelocatedPoint =
false;
547 std::vector<G4Navigator*>::iterator pNavIter =
550#ifdef G4DEBUG_PATHFINDER
560 G4double DistanceStartEnd = (lastEndPosition - fPreStepLocation).mag();
561 G4double endPointSafety_raw = fMinSafety_PreStepPt - DistanceStartEnd;
562 G4double endPointSafety_Est1 = std::max( 0.0, endPointSafety_raw );
575 G4double distCheckEnd_sq = ( moveLenEndPosSq - endPointSafety_Est1
576 *endPointSafety_Est1 );
577 G4double distCheckSaf_sq = ( moveLenSafSq - fMinSafety_atSafLocation
578 *fMinSafety_atSafLocation );
580 G4bool longMoveEnd = distCheckEnd_sq > 0.0;
581 G4bool longMoveSaf = distCheckSaf_sq > 0.0;
585 if( (!fNewTrack) && ( longMoveEnd && longMoveSaf ) )
593 const G4double cErrorTolerance = 1e-12;
596 G4double distCheckRevisedEnd = moveLenEndPosSq -
sqr(revisedSafety);
598 G4bool longMoveRevisedEnd = ( distCheckRevisedEnd > 0. ) ;
601 G4double moveLenEndPosition = std::sqrt( moveLenEndPosSq );
602 moveMinusSafety = moveLenEndPosition - revisedSafety;
604 if ( longMoveRevisedEnd && ( moveMinusSafety > 0.0 )
605 && ( revisedSafety > 0.0 ) )
610 if( fVerboseLevel > 0 )
612 G4cout <<
" G4PF:Relocate> Ratio to revised safety is "
613 << std::fabs(moveMinusSafety)/revisedSafety <<
G4endl;
616 G4double absMoveMinusSafety = std::fabs(moveMinusSafety);
617 G4bool smallRatio = absMoveMinusSafety < kRadTolerance * revisedSafety;
622 G4bool smallValue= absMoveMinusSafety < cErrorTolerance * maxCoordPos;
623 if( !(smallRatio || smallValue) )
625 G4cout <<
" G4PF:Relocate> Ratio to revised safety is "
626 << std::fabs(moveMinusSafety)/revisedSafety <<
G4endl;
627 G4cout <<
" Difference of move and safety is not very small."
632 moveMinusSafety = 0.0;
633 longMoveRevisedEnd =
false;
635 G4cout <<
" Difference of move & safety is very small in magnitude, "
636 << absMoveMinusSafety <<
G4endl;
639 G4cout <<
" ratio to safety " << revisedSafety
640 <<
" is " << absMoveMinusSafety / revisedSafety
641 <<
"smaller than " << kRadTolerance <<
" of safety ";
645 G4cout <<
" as fraction " << absMoveMinusSafety / maxCoordPos
646 <<
" of position vector max-coord " << maxCoordPos
647 <<
" smaller than " << cErrorTolerance ;
649 G4cout <<
" -- reset moveMinusSafety to "
650 << moveMinusSafety <<
G4endl;
654 if ( longMoveEnd && longMoveSaf
655 && longMoveRevisedEnd && (moveMinusSafety>0.0) )
657 std::ostringstream message;
658 message.precision(9);
659 message <<
"ReLocation is further than end-safety value." <<
G4endl
660 <<
" Moved from last endpoint by " << moveLenEndPosition
661 <<
" compared to end safety (from preStep point) = "
662 << endPointSafety_Est1 <<
G4endl
663 <<
" --> last PreSafety Location was " << fPreSafetyLocation
665 <<
" safety value = " << fPreSafetyMinValue <<
G4endl
666 <<
" --> last PreStep Location was " << fPreStepLocation
668 <<
" safety value = " << fMinSafety_PreStepPt <<
G4endl
669 <<
" --> last EndStep Location was " << lastEndPosition
671 <<
" safety value = " << endPointSafety_Est1
672 <<
" raw-value = " << endPointSafety_raw <<
G4endl
673 <<
" --> Calling again at this endpoint, we get "
674 << revisedSafety <<
" as safety value." <<
G4endl
677 <<
" its safety value = " << fMinSafety_atSafLocation
679 <<
" move from safety location = "
680 << std::sqrt(moveLenSafSq) <<
G4endl
681 <<
" again= " << moveVecSafety.
mag() <<
G4endl
682 <<
" safety - Move-from-end= "
683 << revisedSafety - moveLenEndPosition
684 <<
" (negative is Bad.)" <<
G4endl
685 <<
" Debug: distCheckRevisedEnd = "
686 << distCheckRevisedEnd;
688 G4Exception(
"G4PathFinder::ReLocate",
"GeomNav0003",
693 if( fVerboseLevel > 2 )
696 G4cout <<
" G4PathFinder::ReLocate : entered " <<
G4endl;
699 if ( (fVerboseLevel > -1) || ( moveLenEndPosSq > 0.0) )
701 G4cout <<
" lastEndPosition = " << lastEndPosition
702 <<
" moveVec from step-end = " << moveVecEndPos
703 <<
" is new Track = " << fNewTrack
704 <<
" relocated = " << fRelocatedPoint <<
G4endl;
709 for (
auto num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
713 (*pNavIter)->LocateGlobalPointWithinVolume(
position );
717 fLimitedStep[num] =
kDoNot;
718 fCurrentStepSize[num] = 0.0;
719 fLimitTruth[num] =
false;
723 fRelocatedPoint =
true;
725#ifdef G4DEBUG_PATHFINDER
726 if( fVerboseLevel > 2 )
728 G4cout <<
" G4PathFinder::ReLocate : exiting "
729 <<
" at position " << fLastLocatedPosition <<
G4endl <<
G4endl;
742 std::vector<G4Navigator*>::iterator pNavigatorIter;
745 for(
auto num=0; num<fNoActiveNavigators; ++pNavigatorIter,++num )
748 if( safety < minSafety ) { minSafety = safety; }
749 fNewSafetyComputed[num] = safety;
753 fMinSafety_atSafLocation = minSafety;
755#ifdef G4DEBUG_PATHFINDER
756 if( fVerboseLevel > 1 )
758 G4cout <<
" G4PathFinder::ComputeSafety - returns "
771#ifdef G4DEBUG_PATHFINDER
772 if( fVerboseLevel > 2 )
774 G4cout <<
"G4PathFinder::CreateTouchableHandle : navId = "
783 if( locatedVolume ==
nullptr )
790#ifdef G4DEBUG_PATHFINDER
791 if( fVerboseLevel > 2 )
794 if( locatedVolume ) { VolumeName = locatedVolume->
GetName(); }
795 G4cout <<
" Touchable History created at address " << touchHist
796 <<
"; volume = " << locatedVolume <<
"; name= " << VolumeName
808 std::vector<G4Navigator*>::iterator pNavigatorIter;
810 G4double minSafety = kInfinity, minStep = kInfinity;
812 const G4int IdTransport = 0;
815#ifdef G4DEBUG_PATHFINDER
816 if( fVerboseLevel > 2 )
818 G4cout <<
" G4PathFinder::DoNextLinearStep : entered " <<
G4endl;
819 G4cout <<
" Input field track= " << initialState <<
G4endl;
820 G4cout <<
" Requested step= " << proposedStepLength <<
G4endl;
827 G4ThreeVector OriginShift = initialPosition - fPreSafetyLocation;
837 MagShift= std::sqrt(MagSqShift) ;
839#ifdef G4PATHFINDER_OPTIMISATION
843 if( MagSqShift >=
sqr(fPreSafetyMinValue) )
849 fullSafety = fPreSafetyMinValue - MagShift;
851 if( proposedStepLength < fullSafety )
856 fPreStepCenterRenewed =
false;
858 for( num=0; num< fNoActiveNavigators; ++num )
860 fCurrentStepSize[num] = kInfinity;
861 safety = std::max( 0.0, fPreSafetyValues[num] - MagShift);
862 minSafety= std::min( safety, minSafety );
863 fCurrentPreStepSafety[num] = safety;
867#ifdef G4DEBUG_PATHFINDER
868 if( fVerboseLevel > 2 )
870 G4cout <<
"G4PathFinder::DoNextLinearStep : Quick Stepping. " <<
G4endl
871 <<
" proposedStepLength " << proposedStepLength
872 <<
" < (full) safety = " << fullSafety
873 <<
" at " << initialPosition
884 fPreStepCenterRenewed =
true;
885 pNavigatorIter = fpTransportManager-> GetActiveNavigatorsIterator();
889 for( num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
891 safety = std::max( 0.0, fPreSafetyValues[num] - MagShift);
893#ifdef G4PATHFINDER_OPTIMISATION
894 if( proposedStepLength <= safety )
900#ifdef G4DEBUG_PATHFINDER
902 G4cout <<
"PathFinder::ComputeStep> small proposed step = "
903 << proposedStepLength
904 <<
" <= safety = " << safety <<
" for nav " << num
905 <<
" Step fully taken. " <<
G4endl;
911#ifdef G4DEBUG_PATHFINDER
914 step = (*pNavigatorIter)->ComputeStep( initialPosition,
918 minStep = std::min(step, minStep);
921#ifdef G4DEBUG_PATHFINDER
922 if( fVerboseLevel > 0)
925 G4cout <<
"PathFinder::ComputeStep> long proposed step = "
926 << proposedStepLength
927 <<
" > safety = " << previousSafety
928 <<
" for nav " << num
929 <<
" . New safety = " << safety <<
" step= " << step
934 fCurrentStepSize[num] = step;
944 fPreSafetyValues[num] = safety;
945 fCurrentPreStepSafety[num] = safety;
947 minSafety = std::min( safety, minSafety );
949#ifdef G4DEBUG_PATHFINDER
950 if( fVerboseLevel > 2 )
952 G4cout <<
"G4PathFinder::DoNextLinearStep : Navigator ["
953 << num <<
"] -- step size " << step <<
G4endl;
962 fPreSafetyMinValue = minSafety;
967 fPreStepLocation = initialPosition;
968 fMinSafety_PreStepPt = minSafety;
972 if( fMinStep == kInfinity )
974 minStep = proposedStepLength;
976 fTrueMinStep = minStep;
982 fEndState = initialState;
983 endPosition = initialPosition + minStep * initialDirection ;
985#ifdef G4DEBUG_PATHFINDER
986 if( fVerboseLevel > 1 )
989 G4cout <<
"G4PathFinder::DoNextLinearStep : "
990 <<
" initialPosition = " << initialPosition
991 <<
" and endPosition = " << endPosition<<
G4endl;
992 G4cout.precision(oldPrec);
999 if( fNoActiveNavigators == 1 )
1001 G4bool transportLimited = (fMinStep!= kInfinity);
1002 fLimitTruth[IdTransport] = transportLimited;
1003 fLimitedStep[IdTransport] = transportLimited ?
kUnique :
kDoNot;
1006 fNoGeometriesLimiting = transportLimited ? 1 : 0;
1013#ifdef G4DEBUG_PATHFINDER
1014 if( fVerboseLevel > 2 )
1016 G4cout <<
" G4PathFinder::DoNextLinearStep : exits returning "
1018 G4cout <<
" - Endpoint values = " << fEndState <<
G4endl;
1030 G4int num = -1, last = -1;
1031 G4int noLimited = 0;
1034 const G4int IdTransport = 0;
1038 G4bool transportLimited = (fCurrentStepSize[IdTransport] == fMinStep)
1039 && (fMinStep != kInfinity);
1041 if( transportLimited )
1046 for ( num = 0; num < fNoActiveNavigators; ++num )
1050 G4double step = fCurrentStepSize[num];
1052 limitedStep = ( std::fabs(step - fMinStep) < kCarTolerance )
1053 && ( step != kInfinity);
1055 fLimitTruth[ num ] = limitedStep;
1059 fLimitedStep[num] = shared;
1064 fLimitedStep[num] =
kDoNot;
1067 fNoGeometriesLimiting= noLimited;
1069 if( (last > -1) && (noLimited == 1 ) )
1071 fLimitedStep[ last ] =
kUnique;
1074#ifdef G4DEBUG_PATHFINDER
1075 if( fVerboseLevel > 1 )
1078 if( fVerboseLevel > 4 )
1080 G4cout <<
" G4PathFinder::WhichLimited - exiting. " <<
G4endl;
1090 G4cout <<
"G4PathFinder::PrintLimited reports: " ;
1091 G4cout <<
" Minimum step (true)= " << fTrueMinStep
1092 <<
" reported min = " << fMinStep
1094 if( (fCurrentStepNo <= 2) || (fVerboseLevel>=2) )
1096 G4cout << std::setw(5) <<
" Step#" <<
" "
1097 << std::setw(5) <<
" NavId" <<
" "
1098 << std::setw(12) <<
" step-size " <<
" "
1099 << std::setw(12) <<
" raw-size " <<
" "
1100 << std::setw(12) <<
" pre-safety " <<
" "
1101 << std::setw(15) <<
" Limited / flag" <<
" "
1102 << std::setw(15) <<
" World " <<
" "
1105 for (
auto num = 0; num < fNoActiveNavigators; ++num )
1107 G4double rawStep = fCurrentStepSize[num];
1108 G4double stepLen = fCurrentStepSize[num];
1109 if( stepLen > fTrueMinStep )
1111 stepLen = fTrueMinStep;
1115 G4cout << std::setw(5) << fCurrentStepNo <<
" "
1116 << std::setw(5) << num <<
" "
1117 << std::setw(12) << stepLen <<
" "
1118 << std::setw(12) << rawStep <<
" "
1119 << std::setw(12) << fCurrentPreStepSafety[num] <<
" "
1120 << std::setw(5) << (fLimitTruth[num] ?
"YES" :
" NO") <<
" ";
1122 G4cout <<
" " << std::setw(15) << limitedStr <<
" ";
1123 G4cout.precision(oldPrec);
1127 if (pNav !=
nullptr)
1132 WorldName = pWorld->
GetName();
1135 G4cout <<
" " << WorldName ;
1139 if( fVerboseLevel > 4 )
1141 G4cout <<
" G4PathFinder::PrintLimited - exiting. " <<
G4endl;
1150 const G4double toleratedRelativeError = 1.0e-10;
1151 G4double minStep= kInfinity, newSafety = 0.0;
1164#ifdef G4DEBUG_PATHFINDER
1166 if( fVerboseLevel > 2 )
1168 G4cout <<
" G4PathFinder::DoNextCurvedStep ****** " <<
G4endl;
1169 G4cout <<
" Initial value of field track is " << fieldTrack
1170 <<
" and proposed step= " << proposedStepLength <<
G4endl;
1174 fPreStepCenterRenewed =
true;
1176 if( fNoActiveNavigators > 1 )
1180 G4double minSafety= kInfinity, safety;
1181 for( numNav=0; numNav < fNoActiveNavigators; ++numNav )
1184 fPreSafetyValues[numNav] = safety;
1185 fCurrentPreStepSafety[numNav] = safety;
1186 minSafety = std::min( safety, minSafety );
1191 fPreSafetyLocation = startPoint;
1192 fPreSafetyMinValue = minSafety;
1193 fPreStepLocation = startPoint;
1194 fMinSafety_PreStepPt = minSafety;
1199 minStep = fpFieldPropagator->
ComputeStep( fieldTrack,
1202 pCurrentPhysicalVolume,
1207 fEndState = fieldTrack;
1209 fTrueMinStep = std::min( minStep, proposedStepLength );
1211 if( fNoActiveNavigators == 1 )
1216 fPreSafetyValues[0] = newSafety;
1217 fPreSafetyLocation = startPoint;
1218 fPreSafetyMinValue = newSafety;
1222 fCurrentPreStepSafety[0] = newSafety;
1223 fPreStepLocation = startPoint;
1224 fMinSafety_PreStepPt= newSafety;
1227#ifdef G4DEBUG_PATHFINDER
1228 if( fVerboseLevel > 2 )
1230 G4cout <<
"G4PathFinder::DoNextCurvedStep : " <<
G4endl
1231 <<
" initialState = " << initialState <<
G4endl
1232 <<
" and endState = " << fEndState <<
G4endl;
1233 G4cout <<
"G4PathFinder::DoNextCurvedStep : "
1234 <<
" minStep = " << minStep
1235 <<
" proposedStepLength " << proposedStepLength
1236 <<
" safety = " << newSafety <<
G4endl;
1240 if( minStep < proposedStepLength )
1245 G4int noLimited = 0;
1246 for( numNav=0; numNav < fNoActiveNavigators; ++numNav )
1248 G4double finalStep, lastPreSafety = 0.0, minStepLast;
1253 minStepLast, didLimit );
1258 currentStepSize = fTrueMinStep;
1260 if( (minStepLast != kInfinity) )
1262 diffStep = (finalStep-minStepLast);
1263 if ( std::abs(diffStep) <= toleratedRelativeError * finalStep )
1267 currentStepSize += diffStep;
1269 fCurrentStepSize[numNav] = currentStepSize;
1282 fLimitedStep[numNav] = didLimit;
1283 fLimitTruth[numNav] = limited = (didLimit !=
kDoNot );
1284 if( limited ) { ++noLimited; }
1286#ifdef G4DEBUG_PATHFINDER
1287 G4bool StepError = (currentStepSize < 0)
1288 || ( (minStepLast != kInfinity) && (diffStep < 0) ) ;
1289 if( StepError || (fVerboseLevel > 2) )
1293 G4cout <<
" G4PathFinder::ComputeStep. Geometry " << numNav
1294 <<
" step= " << fCurrentStepSize[numNav]
1295 <<
" from final-step= " << finalStep
1296 <<
" fTrueMinStep= " << fTrueMinStep
1297 <<
" minStepLast= " << minStepLast
1298 <<
" limited = " << (fLimitTruth[numNav] ?
"YES" :
" NO")
1300 G4cout <<
" status = " << limitedString <<
" #= " << didLimit
1305 std::ostringstream message;
1306 message <<
"Incorrect calculation of step size for one navigator"
1308 <<
" currentStepSize = " << currentStepSize
1309 <<
", diffStep= " << diffStep <<
G4endl
1310 <<
"ERROR in computing step size for this navigator.";
1318 fNoGeometriesLimiting = noLimited;
1320 else if ( (minStep == proposedStepLength)
1321 || (minStep == kInfinity)
1322 || ( std::abs(minStep-proposedStepLength)
1323 < toleratedRelativeError * proposedStepLength ) )
1332 currentStepSize = minStep;
1333 for( numNav=0; numNav < fNoActiveNavigators; ++numNav )
1335 fCurrentStepSize[numNav] = minStep;
1337 fLimitedStep[numNav] =
kDoNot;
1338 fLimitTruth[numNav] =
false;
1340 fNoGeometriesLimiting = 0;
1344 std::ostringstream message;
1345 message <<
"Incorrect calculation of step size for one navigator." <<
G4endl
1346 <<
" currentStepSize = " << minStep <<
" is larger than "
1347 <<
" proposed StepSize = " << proposedStepLength <<
".";
1352#ifdef G4DEBUG_PATHFINDER
1353 if( fVerboseLevel > 2 )
1355 G4cout <<
" Exiting G4PathFinder::DoNextCurvedStep " <<
G4endl;
1367 StrUnique(
"Unique"),
1368 StrUndefined(
"Undefined"),
1369 StrSharedTransport(
"SharedTransport"),
1370 StrSharedOther(
"SharedOther");
1375 case kDoNot: limitedStr = &StrDoNot;
break;
1376 case kUnique: limitedStr = &StrUnique;
break;
1378 case kSharedOther: limitedStr = &StrSharedOther;
break;
1379 default: limitedStr = &StrUndefined;
break;
1386 fPreSafetyLocation = fSafetyLocation;
1387 fPreSafetyMinValue = fMinSafety_atSafLocation;
1388 for(
auto nav=0; nav < fNoActiveNavigators; ++nav )
1390 fPreSafetyValues[nav] = fNewSafetyComputed[nav];
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
#define fPreSafetyLocation
G4ReferenceCountedHandle< G4VTouchable > G4TouchableHandle
G4GLOB_DLL std::ostream G4cout
virtual void SetChargeMomentumMass(G4ChargeState particleCharge, G4double MomentumXc, G4double MassXc2)=0
const G4Field * GetDetectorField() const
void SetProperTimeOfFlight(G4double tofProper)
const G4ChargeState * GetChargeState() const
G4ThreeVector GetMomentumDirection() const
G4double GetCharge() const
G4ThreeVector GetPosition() const
void SetPosition(G4ThreeVector nPos)
G4double GetRestMass() const
G4ThreeVector GetMomentum() const
G4double GetSurfaceTolerance() const
G4double GetRadialTolerance() const
static G4GeometryTolerance * GetInstance()
G4double ObtainFinalStep(G4int navigatorId, G4double &pNewSafety, G4double &minStepLast, ELimited &limitedStep)
G4TouchableHistory * CreateTouchableHistory() const
virtual G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=true)
G4VPhysicalVolume * GetWorldVolume() const
G4double ComputeSafety(const G4ThreeVector &globalPoint)
void EnableParallelNavigation(G4bool enableChoice=true)
G4Navigator * GetNavigator(G4int n) const
void ReLocate(const G4ThreeVector &position)
void ReportMove(const G4ThreeVector &OldV, const G4ThreeVector &NewV, const G4String &Quantity) const
G4double DoNextLinearStep(const G4FieldTrack &FieldTrack, G4double proposedStepLength)
void PushPostSafetyToPreSafety()
G4double ComputeStep(const G4FieldTrack &pFieldTrack, G4double pCurrentProposedStepLength, G4int navigatorId, G4int stepNo, G4double &pNewSafety, ELimited &limitedStep, G4FieldTrack &EndState, G4VPhysicalVolume *currentVolume)
G4double DoNextCurvedStep(const G4FieldTrack &FieldTrack, G4double proposedStepLength, G4VPhysicalVolume *pCurrentPhysVolume)
void Locate(const G4ThreeVector &position, const G4ThreeVector &direction, G4bool relativeSearch=true)
G4String & LimitedString(ELimited lim)
void PrepareNewTrack(const G4ThreeVector &position, const G4ThreeVector &direction, G4VPhysicalVolume *massStartVol=nullptr)
static G4PathFinder * GetInstance()
G4TouchableHandle CreateTouchableHandle(G4int navId) const
static G4PathFinder * GetInstanceIfExist()
G4FieldManager * FindAndSetFieldManager(G4VPhysicalVolume *pCurrentPhysVol)
void SetNavigatorForPropagating(G4Navigator *SimpleOrMultiNavigator)
G4EquationOfMotion * GetCurrentEquationOfMotion()
G4double ComputeStep(G4FieldTrack &pFieldTrack, G4double pCurrentProposedStepLength, G4double &pNewSafety, G4VPhysicalVolume *pPhysVol=nullptr, G4bool canRelaxDeltaChord=false)
void EnableParallelNavigation(G4bool parallel)
void UpdateYourself(G4VPhysicalVolume *pPhysVol, const G4NavigationHistory *history=nullptr)
const G4NavigationHistory * GetHistory() const
std::vector< G4Navigator * >::iterator GetActiveNavigatorsIterator()
static G4TransportationManager * GetTransportationManager()
G4PropagatorInField * GetPropagatorInField() const
G4SafetyHelper * GetSafetyHelper() const
G4Navigator * GetNavigatorForTracking() const
const G4String & GetName() const