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] =
nullptr;
97 fPreSafetyValues[num]= -1.0;
98 fCurrentPreStepSafety[num] = -1.0;
99 fNewSafetyComputed[num]= -1.0;
108 delete fpMultiNavigator;
109 fpPathFinder =
nullptr;
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;
549#ifdef G4DEBUG_PATHFINDER
559 G4double DistanceStartEnd = (lastEndPosition - fPreStepLocation).mag();
560 G4double endPointSafety_raw = fMinSafety_PreStepPt - DistanceStartEnd;
561 G4double endPointSafety_Est1 = std::max( 0.0, endPointSafety_raw );
574 G4double distCheckEnd_sq = ( moveLenEndPosSq - endPointSafety_Est1
575 *endPointSafety_Est1 );
576 G4double distCheckSaf_sq = ( moveLenSafSq - fMinSafety_atSafLocation
577 *fMinSafety_atSafLocation );
579 G4bool longMoveEnd = distCheckEnd_sq > 0.0;
580 G4bool longMoveSaf = distCheckSaf_sq > 0.0;
584 if( (!fNewTrack) && ( longMoveEnd && longMoveSaf ) )
592 const G4double cErrorTolerance = 1e-12;
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 ) )
609 if( fVerboseLevel > 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;
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) )
656 std::ostringstream message;
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
662 <<
" --> last PreSafety Location was " << fPreSafetyLocation
664 <<
" safety value = " << fPreSafetyMinValue <<
G4endl
665 <<
" --> last PreStep Location was " << fPreStepLocation
667 <<
" safety value = " << fMinSafety_PreStepPt <<
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
676 <<
" its safety value = " << fMinSafety_atSafLocation
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;
687 G4Exception(
"G4PathFinder::ReLocate",
"GeomNav0003",
692 if( fVerboseLevel > 2 )
695 G4cout <<
" G4PathFinder::ReLocate : entered " <<
G4endl;
698 if ( (fVerboseLevel > -1) || ( moveLenEndPosSq > 0.0) )
700 G4cout <<
" lastEndPosition = " << lastEndPosition
701 <<
" moveVec from step-end = " << moveVecEndPos
702 <<
" is new Track = " << fNewTrack
703 <<
" relocated = " << fRelocatedPoint <<
G4endl;
708 for (
auto num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
712 (*pNavIter)->LocateGlobalPointWithinVolume(
position );
716 fLimitedStep[num] =
kDoNot;
717 fCurrentStepSize[num] = 0.0;
718 fLimitTruth[num] =
false;
722 fRelocatedPoint =
true;
724#ifdef G4DEBUG_PATHFINDER
725 if( fVerboseLevel > 2 )
727 G4cout <<
" G4PathFinder::ReLocate : exiting "
728 <<
" at position " << fLastLocatedPosition <<
G4endl <<
G4endl;
741 std::vector<G4Navigator*>::iterator pNavigatorIter;
744 for(
auto num=0; num<fNoActiveNavigators; ++pNavigatorIter,++num )
747 if( safety < minSafety ) { minSafety = safety; }
748 fNewSafetyComputed[num] = safety;
752 fMinSafety_atSafLocation = minSafety;
754#ifdef G4DEBUG_PATHFINDER
755 if( fVerboseLevel > 1 )
757 G4cout <<
" G4PathFinder::ComputeSafety - returns "
770#ifdef G4DEBUG_PATHFINDER
771 if( fVerboseLevel > 2 )
773 G4cout <<
"G4PathFinder::CreateTouchableHandle : navId = "
782 if( locatedVolume ==
nullptr )
789#ifdef G4DEBUG_PATHFINDER
790 if( fVerboseLevel > 2 )
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;
809 G4double minSafety = kInfinity, minStep = kInfinity;
811 const G4int IdTransport = 0;
814#ifdef G4DEBUG_PATHFINDER
815 if( fVerboseLevel > 2 )
817 G4cout <<
" G4PathFinder::DoNextLinearStep : entered " <<
G4endl;
818 G4cout <<
" Input field track= " << initialState <<
G4endl;
819 G4cout <<
" Requested step= " << proposedStepLength <<
G4endl;
826 G4ThreeVector OriginShift = initialPosition - fPreSafetyLocation;
836 MagShift= std::sqrt(MagSqShift) ;
838#ifdef G4PATHFINDER_OPTIMISATION
842 if( MagSqShift >=
sqr(fPreSafetyMinValue) )
848 fullSafety = fPreSafetyMinValue - MagShift;
850 if( proposedStepLength < fullSafety )
855 fPreStepCenterRenewed =
false;
857 for( num=0; num< fNoActiveNavigators; ++num )
859 fCurrentStepSize[num] = kInfinity;
860 safety = std::max( 0.0, fPreSafetyValues[num] - MagShift);
861 minSafety= std::min( safety, minSafety );
862 fCurrentPreStepSafety[num] = safety;
866#ifdef G4DEBUG_PATHFINDER
867 if( fVerboseLevel > 2 )
869 G4cout <<
"G4PathFinder::DoNextLinearStep : Quick Stepping. " <<
G4endl
870 <<
" proposedStepLength " << proposedStepLength
871 <<
" < (full) safety = " << fullSafety
872 <<
" at " << initialPosition
883 fPreStepCenterRenewed =
true;
884 pNavigatorIter = fpTransportManager-> GetActiveNavigatorsIterator();
888 for( num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
890 safety = std::max( 0.0, fPreSafetyValues[num] - MagShift);
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;
910#ifdef G4DEBUG_PATHFINDER
913 step = (*pNavigatorIter)->ComputeStep( initialPosition,
917 minStep = std::min(step, minStep);
920#ifdef G4DEBUG_PATHFINDER
921 if( fVerboseLevel > 0)
924 G4cout <<
"PathFinder::ComputeStep> long proposed step = "
925 << proposedStepLength
926 <<
" > safety = " << previousSafety
927 <<
" for nav " << num
928 <<
" . New safety = " << safety <<
" step= " << step
933 fCurrentStepSize[num] = step;
943 fPreSafetyValues[num] = safety;
944 fCurrentPreStepSafety[num] = safety;
946 minSafety = std::min( safety, minSafety );
948#ifdef G4DEBUG_PATHFINDER
949 if( fVerboseLevel > 2 )
951 G4cout <<
"G4PathFinder::DoNextLinearStep : Navigator ["
952 << num <<
"] -- step size " << step <<
G4endl;
961 fPreSafetyMinValue = minSafety;
966 fPreStepLocation = initialPosition;
967 fMinSafety_PreStepPt = minSafety;
971 if( fMinStep == kInfinity )
973 minStep = proposedStepLength;
975 fTrueMinStep = minStep;
981 fEndState = initialState;
982 endPosition = initialPosition + minStep * initialDirection ;
984#ifdef G4DEBUG_PATHFINDER
985 if( fVerboseLevel > 1 )
988 G4cout <<
"G4PathFinder::DoNextLinearStep : "
989 <<
" initialPosition = " << initialPosition
990 <<
" and endPosition = " << endPosition<<
G4endl;
991 G4cout.precision(oldPrec);
998 if( fNoActiveNavigators == 1 )
1000 G4bool transportLimited = (fMinStep!= kInfinity);
1001 fLimitTruth[IdTransport] = transportLimited;
1002 fLimitedStep[IdTransport] = transportLimited ?
kUnique :
kDoNot;
1005 fNoGeometriesLimiting = transportLimited ? 1 : 0;
1012#ifdef G4DEBUG_PATHFINDER
1013 if( fVerboseLevel > 2 )
1015 G4cout <<
" G4PathFinder::DoNextLinearStep : exits returning "
1017 G4cout <<
" - Endpoint values = " << fEndState <<
G4endl;
1029 G4int num = -1, last = -1;
1030 G4int noLimited = 0;
1033 const G4int IdTransport = 0;
1037 G4bool transportLimited = (fCurrentStepSize[IdTransport] == fMinStep)
1038 && (fMinStep != kInfinity);
1040 if( transportLimited )
1045 for ( num = 0; num < fNoActiveNavigators; ++num )
1049 G4double step = fCurrentStepSize[num];
1051 limitedStep = ( std::fabs(step - fMinStep) < kCarTolerance )
1052 && ( step != kInfinity);
1054 fLimitTruth[ num ] = limitedStep;
1058 fLimitedStep[num] = shared;
1063 fLimitedStep[num] =
kDoNot;
1066 fNoGeometriesLimiting= noLimited;
1068 if( (last > -1) && (noLimited == 1 ) )
1070 fLimitedStep[ last ] =
kUnique;
1073#ifdef G4DEBUG_PATHFINDER
1074 if( fVerboseLevel > 1 )
1077 if( fVerboseLevel > 4 )
1079 G4cout <<
" G4PathFinder::WhichLimited - exiting. " <<
G4endl;
1089 G4cout <<
"G4PathFinder::PrintLimited reports: " ;
1090 G4cout <<
" Minimum step (true)= " << fTrueMinStep
1091 <<
" reported min = " << fMinStep
1093 if( (fCurrentStepNo <= 2) || (fVerboseLevel>=2) )
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 " <<
" "
1104 for (
auto num = 0; num < fNoActiveNavigators; ++num )
1106 G4double rawStep = fCurrentStepSize[num];
1107 G4double stepLen = fCurrentStepSize[num];
1108 if( stepLen > fTrueMinStep )
1110 stepLen = fTrueMinStep;
1114 G4cout << std::setw(5) << fCurrentStepNo <<
" "
1115 << std::setw(5) << num <<
" "
1116 << std::setw(12) << stepLen <<
" "
1117 << std::setw(12) << rawStep <<
" "
1118 << std::setw(12) << fCurrentPreStepSafety[num] <<
" "
1119 << std::setw(5) << (fLimitTruth[num] ?
"YES" :
" NO") <<
" ";
1121 G4cout <<
" " << std::setw(15) << limitedStr <<
" ";
1122 G4cout.precision(oldPrec);
1126 if (pNav !=
nullptr)
1129 if( pWorld !=
nullptr )
1131 WorldName = pWorld->
GetName();
1134 G4cout <<
" " << WorldName ;
1138 if( fVerboseLevel > 4 )
1140 G4cout <<
" G4PathFinder::PrintLimited - exiting. " <<
G4endl;
1149 const G4double toleratedRelativeError = 1.0e-10;
1150 G4double minStep= kInfinity, newSafety = 0.0;
1163#ifdef G4DEBUG_PATHFINDER
1165 if( fVerboseLevel > 2 )
1167 G4cout <<
" G4PathFinder::DoNextCurvedStep ****** " <<
G4endl;
1168 G4cout <<
" Initial value of field track is " << fieldTrack
1169 <<
" and proposed step= " << proposedStepLength <<
G4endl;
1173 fPreStepCenterRenewed =
true;
1175 if( fNoActiveNavigators > 1 )
1179 G4double minSafety= kInfinity, safety;
1180 for( numNav=0; numNav < fNoActiveNavigators; ++numNav )
1183 fPreSafetyValues[numNav] = safety;
1184 fCurrentPreStepSafety[numNav] = safety;
1185 minSafety = std::min( safety, minSafety );
1190 fPreSafetyLocation = startPoint;
1191 fPreSafetyMinValue = minSafety;
1192 fPreStepLocation = startPoint;
1193 fMinSafety_PreStepPt = minSafety;
1198 minStep = fpFieldPropagator->
ComputeStep( fieldTrack,
1201 pCurrentPhysicalVolume,
1206 fEndState = fieldTrack;
1208 fTrueMinStep = std::min( minStep, proposedStepLength );
1210 if( fNoActiveNavigators == 1 )
1215 fPreSafetyValues[0] = newSafety;
1216 fPreSafetyLocation = startPoint;
1217 fPreSafetyMinValue = newSafety;
1221 fCurrentPreStepSafety[0] = newSafety;
1222 fPreStepLocation = startPoint;
1223 fMinSafety_PreStepPt= newSafety;
1226#ifdef G4DEBUG_PATHFINDER
1227 if( fVerboseLevel > 2 )
1229 G4cout <<
"G4PathFinder::DoNextCurvedStep : " <<
G4endl
1230 <<
" initialState = " << initialState <<
G4endl
1231 <<
" and endState = " << fEndState <<
G4endl;
1232 G4cout <<
"G4PathFinder::DoNextCurvedStep : "
1233 <<
" minStep = " << minStep
1234 <<
" proposedStepLength " << proposedStepLength
1235 <<
" safety = " << newSafety <<
G4endl;
1239 if( minStep < proposedStepLength )
1244 G4int noLimited = 0;
1245 for( numNav=0; numNav < fNoActiveNavigators; ++numNav )
1247 G4double finalStep, lastPreSafety = 0.0, minStepLast;
1252 minStepLast, didLimit );
1257 currentStepSize = fTrueMinStep;
1259 if( (minStepLast != kInfinity) )
1261 diffStep = (finalStep-minStepLast);
1262 if ( std::abs(diffStep) <= toleratedRelativeError * finalStep )
1266 currentStepSize += diffStep;
1268 fCurrentStepSize[numNav] = currentStepSize;
1281 fLimitedStep[numNav] = didLimit;
1282 fLimitTruth[numNav] = limited = (didLimit !=
kDoNot );
1283 if( limited ) { ++noLimited; }
1285#ifdef G4DEBUG_PATHFINDER
1286 G4bool StepError = (currentStepSize < 0)
1287 || ( (minStepLast != kInfinity) && (diffStep < 0) ) ;
1288 if( StepError || (fVerboseLevel > 2) )
1292 G4cout <<
" G4PathFinder::ComputeStep. Geometry " << numNav
1293 <<
" step= " << fCurrentStepSize[numNav]
1294 <<
" from final-step= " << finalStep
1295 <<
" fTrueMinStep= " << fTrueMinStep
1296 <<
" minStepLast= " << minStepLast
1297 <<
" limited = " << (fLimitTruth[numNav] ?
"YES" :
" NO")
1299 G4cout <<
" status = " << limitedString <<
" #= " << didLimit
1304 std::ostringstream message;
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.";
1317 fNoGeometriesLimiting = noLimited;
1319 else if ( (minStep == proposedStepLength)
1320 || (minStep == kInfinity)
1321 || ( std::abs(minStep-proposedStepLength)
1322 < toleratedRelativeError * proposedStepLength ) )
1331 currentStepSize = minStep;
1332 for( numNav=0; numNav < fNoActiveNavigators; ++numNav )
1334 fCurrentStepSize[numNav] = minStep;
1336 fLimitedStep[numNav] =
kDoNot;
1337 fLimitTruth[numNav] =
false;
1339 fNoGeometriesLimiting = 0;
1343 std::ostringstream message;
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
1352 if( fVerboseLevel > 2 )
1354 G4cout <<
" Exiting G4PathFinder::DoNextCurvedStep " <<
G4endl;
1366 StrUnique(
"Unique"),
1367 StrUndefined(
"Undefined"),
1368 StrSharedTransport(
"SharedTransport"),
1369 StrSharedOther(
"SharedOther");
1374 case kDoNot: limitedStr = &StrDoNot;
break;
1375 case kUnique: limitedStr = &StrUnique;
break;
1377 case kSharedOther: limitedStr = &StrSharedOther;
break;
1378 default: limitedStr = &StrUndefined;
break;
1385 fPreSafetyLocation = fSafetyLocation;
1386 fPreSafetyMinValue = fMinSafety_atSafLocation;
1387 for(
auto nav=0; nav < fNoActiveNavigators; ++nav )
1389 fPreSafetyValues[nav] = fNewSafetyComputed[nav];
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
#define fPreSafetyLocation
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
void SetPosition(const G4ThreeVector &nPos)
G4double GetCharge() const
G4ThreeVector GetPosition() const
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)
virtual const G4NavigationHistory * GetHistory() const
virtual void UpdateYourself(G4VPhysicalVolume *pPhysVol, const G4NavigationHistory *history=nullptr)
std::vector< G4Navigator * >::iterator GetActiveNavigatorsIterator()
static G4TransportationManager * GetTransportationManager()
G4PropagatorInField * GetPropagatorInField() const
G4SafetyHelper * GetSafetyHelper() const
G4Navigator * GetNavigatorForTracking() const
const G4String & GetName() const