83 fNoActiveNavigators= 0;
85 fLastLocatedPosition= Big3Vector;
86 fSafetyLocation= Big3Vector;
87 fPreSafetyLocation= Big3Vector;
88 fPreStepLocation= Big3Vector;
90 fPreSafetyMinValue= -1.0;
91 fMinSafety_PreStepPt= -1.0;
92 fMinSafety_atSafLocation= -1.0;
95 fPreStepCenterRenewed=
false;
97 fNoGeometriesLimiting= 0;
99 for(
G4int num=0; num< fMaxNav; ++num )
101 fpNavigator[num] = 0;
102 fLimitTruth[num] =
false;
104 fCurrentStepSize[num] = -1.0;
105 fLocatedVolume[num] = 0;
106 fPreSafetyValues[num]= -1.0;
107 fCurrentPreStepSafety[num] = -1.0;
108 fNewSafetyComputed[num]= -1.0;
117 delete fpMultiNavigator;
118 if (fpPathFinder) {
delete fpPathFinder; fpPathFinder=0; }
126 G4Navigator *navigatorForPropagation=0, *massNavigator=0;
131 navigatorForPropagation= fpMultiNavigator;
139 navigatorForPropagation= massNavigator;
162 #ifdef G4DEBUG_PATHFINDER
163 if( fVerboseLevel > 2 )
166 G4cout <<
" G4PathFinder::ComputeStep - entered " <<
G4endl;
167 G4cout <<
" - stepNo = " << std::setw(4) << stepNo <<
" "
168 <<
" navigatorId = " << std::setw(2) << navigatorNo <<
" "
169 <<
" proposed step len = " << proposedStepLength <<
" " <<
G4endl;
170 G4cout <<
" PF::ComputeStep requested step "
176 if( navigatorNo >= fNoActiveNavigators )
178 std::ostringstream message;
179 message <<
"Bad Navigator ID !" <<
G4endl
180 <<
" Requested Navigator ID = " << navigatorNo <<
G4endl
181 <<
" Number of active navigators = " << fNoActiveNavigators;
182 G4Exception(
"G4PathFinder::ComputeStep()",
"GeomNav0002",
187 if( fNewTrack || (stepNo != fLastStepNo) )
194 fCurrentStepNo = stepNo;
200 G4ThreeVector moveVector= newPosition - fLastLocatedPosition;
202 if( moveLenSq > kCarTolerance * kCarTolerance )
205 #ifdef G4DEBUG_PATHFINDER
206 if( fVerboseLevel > 2 )
208 G4double moveLen= std::sqrt( moveLenSq );
209 G4cout <<
" G4PathFinder::ComputeStep : Point moved since last step "
210 <<
" -- at step # = " << stepNo <<
G4endl
211 <<
" by " << moveLen <<
" to " << newPosition <<
G4endl;
218 Locate( newPosition, newDirection );
226 G4bool fieldExertsForce = false ;
227 if( (particleCharge != 0.0) )
233 fieldExertsForce = (fieldMgr != 0)
236 fFieldExertedForce = fieldExertsForce;
239 fNoGeometriesLimiting= -1;
240 if( fieldExertsForce )
250 #ifdef G4DEBUG_PATHFINDER
251 if ( (fNoGeometriesLimiting < 0)
252 || (fNoGeometriesLimiting > fNoActiveNavigators) )
254 std::ostringstream message;
255 message <<
"Number of geometries limiting the step not set." <<
G4endl
256 <<
" Number of geometries limiting step = "
257 << fNoGeometriesLimiting;
263 #ifdef G4DEBUG_PATHFINDER
266 const G4double checkTolerance = 1.0e-9;
267 if( proposedStepLength < fTrueMinStep * ( 1.0 + checkTolerance) )
269 std::ostringstream message;
270 message.precision( 12 );
271 message <<
"Problem in step size request." <<
G4endl
272 <<
" Being requested to make a step which is shorter"
273 <<
" than the minimum Step " <<
G4endl
274 <<
" already computed for any Navigator/geometry during"
275 <<
" this tracking-step: " <<
G4endl
276 <<
" This could happen due to an error in process ordering."
278 <<
" Check that all physics processes are registered"
279 <<
" before all processes with a navigator/geometry."
281 <<
" If using pre-packaged physics list and/or"
282 <<
" functionality, please report this error."
284 <<
" Additional information for problem: " <<
G4endl
285 <<
" Steps request/proposed = " << proposedStepLength
287 <<
" MinimumStep (true) = " << fTrueMinStep
289 <<
" MinimumStep (navraw) = " << fMinStep
291 <<
" Navigator raw return value" <<
G4endl
292 <<
" Requested step now = " << proposedStepLength
294 <<
" Difference min-req (absolute) = "
295 << fTrueMinStep-proposedStepLength <<
G4endl
296 <<
" Relative (to max of two) = "
297 << (fTrueMinStep-proposedStepLength)
299 <<
" -- Step info> stepNo= " << stepNo
300 <<
" last= " << fLastStepNo
301 <<
" newTr= " << fNewTrack <<
G4endl;
312 if( fVerboseLevel > 1 )
314 G4cout <<
" G4P::CS -> Not calling DoNextLinearStep: "
315 <<
" stepNo= " << stepNo <<
" last= " << fLastStepNo
316 <<
" new= " << fNewTrack <<
" Step already done" <<
G4endl;
326 pNewSafety = fCurrentPreStepSafety[ navigatorNo ];
327 limitedStep = fLimitedStep[ navigatorNo ];
328 fRelocatedPoint=
false;
330 possibleStep=
std::min(proposedStepLength, fCurrentStepSize[ navigatorNo ]);
331 EndState = fEndState;
333 #ifdef G4DEBUG_PATHFINDER
334 if( fVerboseLevel > 0 )
336 G4cout <<
" G4PathFinder::ComputeStep returns "
337 << fCurrentStepSize[ navigatorNo ]
338 <<
" for Navigator " << navigatorNo
339 <<
" Limited step = " << limitedStep
340 <<
" Safety(mm) = " << pNewSafety /
mm
374 std::vector<G4Navigator*>::iterator pNavigatorIter;
376 fNoActiveNavigators= fpTransportManager-> GetNoActiveNavigators();
377 if( fNoActiveNavigators > fMaxNav )
379 std::ostringstream message;
380 message <<
"Too many active Navigators / worlds." <<
G4endl
381 <<
" Transportation Manager has "
382 << fNoActiveNavigators <<
" active navigators." <<
G4endl
383 <<
" This is more than the number allowed = "
385 G4Exception(
"G4PathFinder::PrepareNewTrack()",
"GeomNav0002",
393 for( num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
397 fpNavigator[num] = *pNavigatorIter;
398 fLimitTruth[num] =
false;
399 fLimitedStep[num] =
kDoNot;
400 fCurrentStepSize[num] = 0.0;
401 fLocatedVolume[num] = 0;
403 fNoGeometriesLimiting= 0;
407 if( fNoActiveNavigators > 1 )
409 Locate( position, direction,
false );
416 fLocatedVolume[0]= massStartVol;
419 fCurrentStepSize[0] = 0.0;
425 fMinSafety_PreStepPt= fPreSafetyMinValue= fMinSafety_atSafLocation= 0.0;
427 for( num=0; num< fNoActiveNavigators; ++num )
429 fPreSafetyValues[num]= 0.0;
430 fNewSafetyComputed[num]= 0.0;
431 fCurrentPreStepSafety[num] = 0.0;
437 fRelocatedPoint=
false;
456 std::ostringstream message;
457 message <<
"Endpoint moved between value returned by ComputeStep()"
458 <<
" and call to Locate(). " <<
G4endl
459 <<
" Change of " << Quantity <<
" is "
461 <<
" and its vector is "
462 << (1.0/
mm) * moveVec <<
" mm " <<
G4endl
463 <<
" Endpoint of ComputeStep() was " << OldVector <<
G4endl
464 <<
" and current position to locate is " << NewVector;
465 G4Exception(
"G4PathFinder::ReportMove()",
"GeomNav1002",
477 std::vector<G4Navigator*>::iterator pNavIter=
483 if( (!fNewTrack) && (!fRelocatedPoint)
484 && ( moveLenSq> 10*kCarTolerance*kCarTolerance ) )
486 ReportMove( position, lastEndPosition,
"Position" );
490 #ifdef G4DEBUG_PATHFINDER
491 if( fVerboseLevel > 2 )
496 G4cout <<
" Locating at position " << position
497 <<
" with direction " << direction
498 <<
" relative= " << relative <<
G4endl;
499 if ( (fVerboseLevel > 1) || ( moveLenSq > 0.0) )
501 G4cout <<
" lastEndPosition = " << lastEndPosition
502 <<
" moveVec = " << moveVec
503 <<
" newTr = " << fNewTrack
504 <<
" relocated = " << fRelocatedPoint <<
G4endl;
512 for (
G4int num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
516 if( fLimitTruth[num] ) { (*pNavIter)->SetGeometricallyLimitedStep(); }
519 (*pNavIter)->LocateGlobalPointAndSetup( position, &direction,
524 fLocatedVolume[num] = pLocated;
528 fLimitedStep[num] =
kDoNot;
529 fCurrentStepSize[num] = 0.0;
531 #ifdef G4DEBUG_PATHFINDER
532 if( fVerboseLevel > 2 )
534 G4cout <<
" - In world " << num <<
" geomLimStep= " << fLimitTruth[num]
535 <<
" gives volume= " << pLocated ;
538 G4cout <<
" name = '" << pLocated->GetName() <<
"'";
539 G4cout <<
" - CopyNo= " << pLocated->GetCopyNo();
546 fRelocatedPoint=
false;
553 std::vector<G4Navigator*>::iterator pNavIter=
556 #ifdef G4DEBUG_PATHFINDER
566 G4double DistanceStartEnd= (lastEndPosition - fPreStepLocation).mag();
567 G4double endPointSafety_raw = fMinSafety_PreStepPt - DistanceStartEnd;
581 G4double distCheckEnd_sq= ( moveLenEndPosSq - endPointSafety_Est1
582 *endPointSafety_Est1 );
583 G4double distCheckSaf_sq= ( moveLenSafSq - fMinSafety_atSafLocation
584 *fMinSafety_atSafLocation );
586 G4bool longMoveEnd = distCheckEnd_sq > 0.0;
587 G4bool longMoveSaf = distCheckSaf_sq > 0.0;
591 if( (!fNewTrack) && ( longMoveEnd && longMoveSaf ) )
599 const G4double cErrorTolerance=1e-12;
602 G4double distCheckRevisedEnd= moveLenEndPosSq-revisedSafety*revisedSafety;
604 G4bool longMoveRevisedEnd= ( distCheckRevisedEnd > 0. ) ;
607 G4double moveLenEndPosition= std::sqrt( moveLenEndPosSq );
608 moveMinusSafety = moveLenEndPosition - revisedSafety;
610 if ( longMoveRevisedEnd && (moveMinusSafety > 0.0 )
611 && ( revisedSafety > 0.0 ) )
616 if( fVerboseLevel > 0 )
618 G4cout <<
" G4PF:Relocate> Ratio to revised safety is "
619 << std::fabs(moveMinusSafety)/revisedSafety <<
G4endl;
622 G4double absMoveMinusSafety= std::fabs(moveMinusSafety);
623 G4bool smallRatio= absMoveMinusSafety < kRadTolerance * revisedSafety ;
626 std::fabs(position.
y())),
627 std::fabs(position.
z()) );
628 G4bool smallValue= absMoveMinusSafety < cErrorTolerance * maxCoordPos;
629 if( ! (smallRatio || smallValue) )
631 G4cout <<
" G4PF:Relocate> Ratio to revised safety is "
632 << std::fabs(moveMinusSafety)/revisedSafety <<
G4endl;
633 G4cout <<
" Difference of move and safety is not very small."
638 moveMinusSafety = 0.0;
639 longMoveRevisedEnd =
false;
641 G4cout <<
" Difference of move & safety is very small in magnitude, "
642 << absMoveMinusSafety <<
G4endl;
645 G4cout <<
" ratio to safety " << revisedSafety
646 <<
" is " << absMoveMinusSafety / revisedSafety
647 <<
"smaller than " << kRadTolerance <<
" of safety ";
651 G4cout <<
" as fraction " << absMoveMinusSafety / maxCoordPos
652 <<
" of position vector max-coord " << maxCoordPos
653 <<
" smaller than " << cErrorTolerance ;
655 G4cout <<
" -- reset moveMinusSafety to "
656 << moveMinusSafety <<
G4endl;
660 if ( longMoveEnd && longMoveSaf
661 && longMoveRevisedEnd && (moveMinusSafety>0.0) )
664 std::ostringstream message;
665 message <<
"ReLocation is further than end-safety value." <<
G4endl
666 <<
" Moved from last endpoint by " << moveLenEndPosition
667 <<
" compared to end safety (from preStep point) = "
668 << endPointSafety_Est1 <<
G4endl
669 <<
" --> last PreSafety Location was " << fPreSafetyLocation
671 <<
" safety value = " << fPreSafetyMinValue <<
G4endl
672 <<
" --> last PreStep Location was " << fPreStepLocation
674 <<
" safety value = " << fMinSafety_PreStepPt <<
G4endl
675 <<
" --> last EndStep Location was " << lastEndPosition
677 <<
" safety value = " << endPointSafety_Est1
678 <<
" raw-value = " << endPointSafety_raw <<
G4endl
679 <<
" --> Calling again at this endpoint, we get "
680 << revisedSafety <<
" as safety value." <<
G4endl
681 <<
" --> last position for safety " << fSafetyLocation
683 <<
" its safety value = " << fMinSafety_atSafLocation
685 <<
" move from safety location = "
686 << std::sqrt(moveLenSafSq) <<
G4endl
687 <<
" again= " << moveVecSafety.
mag() <<
G4endl
688 <<
" safety - Move-from-end= "
689 << revisedSafety - moveLenEndPosition
690 <<
" (negative is Bad.)" <<
G4endl
691 <<
" Debug: distCheckRevisedEnd = "
692 << distCheckRevisedEnd;
693 ReportMove( lastEndPosition, position,
"Position" );
694 G4Exception(
"G4PathFinder::ReLocate",
"GeomNav0003",
696 G4cout.precision(oldPrec);
700 if( fVerboseLevel > 2 )
703 G4cout <<
" G4PathFinder::ReLocate : entered " <<
G4endl;
705 G4cout <<
" *Re*Locating at position " << position <<
G4endl;
708 if ( (fVerboseLevel > -1) || ( moveLenEndPosSq > 0.0) )
710 G4cout <<
" lastEndPosition = " << lastEndPosition
711 <<
" moveVec from step-end = " << moveVecEndPos
712 <<
" is new Track = " << fNewTrack
713 <<
" relocated = " << fRelocatedPoint <<
G4endl;
716 #endif // G4DEBUG_PATHFINDER
718 for (
G4int num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
722 (*pNavIter)->LocateGlobalPointWithinVolume( position );
726 fLimitedStep[num] =
kDoNot;
727 fCurrentStepSize[num] = 0.0;
728 fLimitTruth[num] =
false;
732 fRelocatedPoint=
false;
734 #ifdef G4DEBUG_PATHFINDER
735 if( fVerboseLevel > 2 )
737 G4cout <<
" G4PathFinder::ReLocate : exiting "
738 <<
" at position " << fLastLocatedPosition <<
G4endl <<
G4endl;
751 std::vector<G4Navigator*>::iterator pNavigatorIter;
754 for(
G4int num=0; num<fNoActiveNavigators; ++pNavigatorIter,++num )
756 G4double safety = (*pNavigatorIter)->ComputeSafety( position,
DBL_MAX,
true );
757 if( safety < minSafety ) { minSafety = safety; }
758 fNewSafetyComputed[num]= safety;
762 fMinSafety_atSafLocation = minSafety;
764 #ifdef G4DEBUG_PATHFINDER
765 if( fVerboseLevel > 1 )
767 G4cout <<
" G4PathFinder::ComputeSafety - returns "
768 << minSafety <<
" at location " << position <<
G4endl;
780 #ifdef G4DEBUG_PATHFINDER
781 if( fVerboseLevel > 2 )
783 G4cout <<
"G4PathFinder::CreateTouchableHandle : navId = "
789 touchHist=
GetNavigator(navId) -> CreateTouchableHistory();
792 if( locatedVolume == 0 )
799 #ifdef G4DEBUG_PATHFINDER
800 if( fVerboseLevel > 2 )
803 if( locatedVolume ) { VolumeName= locatedVolume->
GetName(); }
804 G4cout <<
" Touchable History created at address " << touchHist
805 <<
" volume = " << locatedVolume <<
" name= " << VolumeName
817 std::vector<G4Navigator*>::iterator pNavigatorIter;
821 const G4int IdTransport= 0;
824 #ifdef G4DEBUG_PATHFINDER
825 if( fVerboseLevel > 2 )
827 G4cout <<
" G4PathFinder::DoNextLinearStep : entered " <<
G4endl;
828 G4cout <<
" Input field track= " << initialState <<
G4endl;
829 G4cout <<
" Requested step= " << proposedStepLength <<
G4endl;
836 G4ThreeVector OriginShift = initialPosition - fPreSafetyLocation;
846 MagShift= std::sqrt(MagSqShift) ;
848 #ifdef G4PATHFINDER_OPTIMISATION
852 if( MagSqShift >=
sqr(fPreSafetyMinValue ) )
858 fullSafety = fPreSafetyMinValue - MagShift;
860 if( proposedStepLength < fullSafety )
865 fPreStepCenterRenewed=
false;
867 for( num=0; num< fNoActiveNavigators; ++num )
870 safety =
std::max( 0.0, fPreSafetyValues[num] - MagShift);
871 minSafety=
std::min( safety, minSafety );
872 fCurrentPreStepSafety[num]= safety;
876 #ifdef G4DEBUG_PATHFINDER
877 if( fVerboseLevel > 2 )
879 G4cout <<
"G4PathFinder::DoNextLinearStep : Quick Stepping. " <<
G4endl
880 <<
" proposedStepLength " << proposedStepLength
881 <<
" < (full) safety = " << fullSafety
882 <<
" at " << initialPosition
888 #endif // End of G4PATHFINDER_OPTIMISATION 1
893 fPreStepCenterRenewed=
true;
894 pNavigatorIter= fpTransportManager-> GetActiveNavigatorsIterator();
898 for( num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
900 safety =
std::max( 0.0, fPreSafetyValues[num] - MagShift);
902 #ifdef G4PATHFINDER_OPTIMISATION
903 if( proposedStepLength <= safety )
909 #ifdef G4DEBUG_PATHFINDER
911 G4cout <<
"PathFinder::ComputeStep> small proposed step = "
912 << proposedStepLength
913 <<
" <= safety = " << safety <<
" for nav " << num
914 <<
" Step fully taken. " <<
G4endl;
918 #endif // End of G4PATHFINDER_OPTIMISATION 2
920 #ifdef G4DEBUG_PATHFINDER
923 step= (*pNavigatorIter)->ComputeStep( initialPosition,
932 #ifdef G4DEBUG_PATHFINDER
933 if( fVerboseLevel > 0)
936 G4cout <<
"PathFinder::ComputeStep> long proposed step = "
937 << proposedStepLength
938 <<
" > safety = " << previousSafety
939 <<
" for nav " << num
940 <<
" . New safety = " << safety <<
" step= " << step
945 fCurrentStepSize[num] = step;
951 fPreSafetyValues[num]= safety;
952 fCurrentPreStepSafety[num]= safety;
954 minSafety=
std::min( safety, minSafety );
956 #ifdef G4DEBUG_PATHFINDER
957 if( fVerboseLevel > 2 )
959 G4cout <<
"G4PathFinder::DoNextLinearStep : Navigator ["
960 << num <<
"] -- step size " << step <<
G4endl;
968 fPreSafetyLocation= initialPosition;
969 fPreSafetyMinValue= minSafety;
974 fPreStepLocation= initialPosition;
975 fMinSafety_PreStepPt= minSafety;
981 minStep = proposedStepLength;
983 fTrueMinStep = minStep;
989 fEndState= initialState;
990 endPosition= initialPosition + minStep * initialDirection ;
992 #ifdef G4DEBUG_PATHFINDER
993 if( fVerboseLevel > 1 )
995 G4cout <<
"G4PathFinder::DoNextLinearStep : "
996 <<
" initialPosition = " << initialPosition
997 <<
" and endPosition = " << endPosition<<
G4endl;
1004 if( fNoActiveNavigators == 1 )
1007 fLimitTruth[IdTransport] = transportLimited;
1008 fLimitedStep[IdTransport] = transportLimited ?
kUnique :
kDoNot;
1011 fNoGeometriesLimiting = transportLimited ? 1 : 0;
1018 #ifdef G4DEBUG_PATHFINDER
1019 if( fVerboseLevel > 2 )
1021 G4cout <<
" G4PathFinder::DoNextLinearStep : exits returning "
1023 G4cout <<
" Endpoint values = " << fEndState <<
G4endl;
1035 G4int num=-1, last=-1;
1039 const G4int IdTransport= 0;
1043 G4bool transportLimited = (fCurrentStepSize[IdTransport] == fMinStep)
1046 if( transportLimited ) {
1050 for ( num= 0; num < fNoActiveNavigators; num++ )
1054 G4double step= fCurrentStepSize[num];
1056 limitedStep = ( std::fabs(step - fMinStep) < kCarTolerance )
1059 fLimitTruth[ num ] = limitedStep;
1063 fLimitedStep[num] = shared;
1068 fLimitedStep[num] =
kDoNot;
1071 fNoGeometriesLimiting= noLimited;
1073 if( (last > -1) && (noLimited == 1 ) )
1075 fLimitedStep[ last ] =
kUnique;
1078 #ifdef G4DEBUG_PATHFINDER
1079 if( fVerboseLevel > 1 )
1082 if( fVerboseLevel > 4 ) {
1083 G4cout <<
" G4PathFinder::WhichLimited - exiting. " <<
G4endl;
1093 G4cout <<
"G4PathFinder::PrintLimited reports: " ;
1094 G4cout <<
" Minimum step (true)= " << fTrueMinStep
1095 <<
" reported min = " << fMinStep
1097 if( (fCurrentStepNo <= 2) || (fVerboseLevel>=2) )
1099 G4cout << std::setw(5) <<
" Step#" <<
" "
1100 << std::setw(5) <<
" NavId" <<
" "
1101 << std::setw(12) <<
" step-size " <<
" "
1102 << std::setw(12) <<
" raw-size " <<
" "
1103 << std::setw(12) <<
" pre-safety " <<
" "
1104 << std::setw(15) <<
" Limited / flag" <<
" "
1105 << std::setw(15) <<
" World " <<
" "
1109 for ( num= 0; num < fNoActiveNavigators; num++ )
1111 G4double rawStep = fCurrentStepSize[num];
1112 G4double stepLen = fCurrentStepSize[num];
1113 if( stepLen > fTrueMinStep )
1115 stepLen = fTrueMinStep;
1119 G4cout << std::setw(5) << fCurrentStepNo <<
" "
1120 << std::setw(5) << num <<
" "
1121 << std::setw(12) << stepLen <<
" "
1122 << std::setw(12) << rawStep <<
" "
1123 << std::setw(12) << fCurrentPreStepSafety[num] <<
" "
1124 << std::setw(5) << (fLimitTruth[num] ?
"YES" :
" NO") <<
" ";
1126 G4cout <<
" " << std::setw(15) << limitedStr <<
" ";
1127 G4cout.precision(oldPrec);
1136 WorldName = pWorld->
GetName();
1139 G4cout <<
" " << WorldName ;
1143 if( fVerboseLevel > 4 )
1145 G4cout <<
" G4PathFinder::PrintLimited - exiting. " <<
G4endl;
1154 const G4double toleratedRelativeError= 1.0e-10;
1163 ->GetEquationOfMotion();
1169 #ifdef G4DEBUG_PATHFINDER
1171 if( fVerboseLevel > 2 )
1173 G4cout <<
" G4PathFinder::DoNextCurvedStep ****** " <<
G4endl;
1174 G4cout <<
" Initial value of field track is " << fieldTrack
1175 <<
" and proposed step= " << proposedStepLength <<
G4endl;
1179 fPreStepCenterRenewed=
true;
1181 if( fNoActiveNavigators > 1 )
1186 for( numNav=0; numNav < fNoActiveNavigators; ++numNav )
1189 fPreSafetyValues[numNav]= safety;
1190 fCurrentPreStepSafety[numNav]= safety;
1191 minSafety =
std::min( safety, minSafety );
1196 fPreSafetyLocation= startPoint;
1197 fPreSafetyMinValue= minSafety;
1198 fPreStepLocation= startPoint;
1199 fMinSafety_PreStepPt= minSafety;
1204 minStep= fpFieldPropagator->
ComputeStep( fieldTrack,
1207 pCurrentPhysicalVolume );
1211 fEndState= fieldTrack;
1213 fTrueMinStep =
std::min( minStep, proposedStepLength );
1215 if( fNoActiveNavigators== 1 )
1220 fPreSafetyValues[0]= newSafety;
1221 fPreSafetyLocation= startPoint;
1222 fPreSafetyMinValue= newSafety;
1226 fCurrentPreStepSafety[0]= newSafety;
1227 fPreStepLocation= startPoint;
1228 fMinSafety_PreStepPt= newSafety;
1231 #ifdef G4DEBUG_PATHFINDER
1232 if( fVerboseLevel > 2 )
1234 G4cout <<
"G4PathFinder::DoNextCurvedStep : " <<
G4endl
1235 <<
" initialState = " << initialState <<
G4endl
1236 <<
" and endState = " << fEndState <<
G4endl;
1237 G4cout <<
"G4PathFinder::DoNextCurvedStep : "
1238 <<
" minStep = " << minStep
1239 <<
" proposedStepLength " << proposedStepLength
1240 <<
" safety = " << newSafety <<
G4endl;
1244 if( minStep < proposedStepLength )
1250 for( numNav=0; numNav < fNoActiveNavigators; ++numNav )
1252 G4double finalStep, lastPreSafety=0.0, minStepLast;
1257 minStepLast, didLimit );
1262 currentStepSize = fTrueMinStep;
1266 diffStep = (finalStep-minStepLast);
1267 if ( std::abs(diffStep) <= toleratedRelativeError * finalStep )
1271 currentStepSize += diffStep;
1273 fCurrentStepSize[numNav] = currentStepSize;
1286 fLimitedStep[numNav] = didLimit;
1287 fLimitTruth[numNav] = limited = (didLimit !=
kDoNot );
1288 if( limited ) { noLimited++; }
1290 #ifdef G4DEBUG_PATHFINDER
1291 G4bool StepError= (currentStepSize < 0)
1292 || ( (minStepLast !=
kInfinity) && (diffStep < 0) ) ;
1293 if( StepError || (fVerboseLevel > 2) )
1297 G4cout <<
" G4PathFinder::ComputeStep. Geometry " << numNav
1298 <<
" step= " << fCurrentStepSize[numNav]
1299 <<
" from final-step= " << finalStep
1300 <<
" fTrueMinStep= " << fTrueMinStep
1301 <<
" minStepLast= " << minStepLast
1302 <<
" limited = " << (fLimitTruth[numNav] ?
"YES" :
" NO")
1304 G4cout <<
" status = " << limitedString <<
" #= " << didLimit
1309 std::ostringstream message;
1310 message <<
"Incorrect calculation of step size for one navigator"
1312 <<
" currentStepSize = " << currentStepSize
1313 <<
", diffStep= " << diffStep << G4endl
1314 <<
"ERROR in computing step size for this navigator.";
1322 fNoGeometriesLimiting= noLimited;
1324 else if ( (minStep == proposedStepLength)
1326 || ( std::abs(minStep-proposedStepLength)
1327 < toleratedRelativeError * proposedStepLength ) )
1336 currentStepSize= minStep;
1337 for( numNav=0; numNav < fNoActiveNavigators; ++numNav )
1339 fCurrentStepSize[numNav] = minStep;
1341 fLimitedStep[numNav] =
kDoNot;
1342 fLimitTruth[numNav] =
false;
1344 fNoGeometriesLimiting= 0;
1348 std::ostringstream message;
1349 message <<
"Incorrect calculation of step size for one navigator." <<
G4endl
1350 <<
" currentStepSize = " << minStep <<
" is larger than "
1351 <<
" proposed StepSize = " << proposedStepLength <<
".";
1356 #ifdef G4DEBUG_PATHFINDER
1357 if( fVerboseLevel > 2 )
1359 G4cout <<
" Exiting G4PathFinder::DoNextCurvedStep " <<
G4endl;
1378 if( fNoActiveNavigators > 0 )
1385 for( numNav=0; numNav < fNoActiveNavigators; ++numNav )
1395 minSafety =
std::min( safety, minSafety );
1396 minMove =
std::min( distance, minMove );
1402 *prDistance= minMove;
1403 if( prNewSafety ) *prNewSafety= minSafety;
1417 StrUnique(
"Unique"),
1418 StrUndefined(
"Undefined"),
1419 StrSharedTransport(
"SharedTransport"),
1420 StrSharedOther(
"SharedOther");
1425 case kDoNot: limitedStr= &StrDoNot;
break;
1426 case kUnique: limitedStr = &StrUnique;
break;
1428 case kSharedOther: limitedStr = &StrSharedOther;
break;
1429 default: limitedStr = &StrUndefined;
break;
1436 fPreSafetyLocation= fSafetyLocation;
1437 fPreSafetyMinValue= fMinSafety_atSafLocation;
1438 for(
G4int nav=0; nav < fNoActiveNavigators; ++nav )
1440 fPreSafetyValues[nav]= fNewSafetyComputed[nav];
void PrepareNewTrack(const G4ThreeVector &position, const G4ThreeVector &direction, G4VPhysicalVolume *massStartVol=0)
G4String & LimitedString(ELimited lim)
static G4PathFinder * GetInstance()
void SetPosition(G4ThreeVector nPos)
void Locate(const G4ThreeVector &position, const G4ThreeVector &direction, G4bool relativeSearch=true)
void SetNavigatorForPropagating(G4Navigator *SimpleOrMultiNavigator)
G4SafetyHelper * GetSafetyHelper() const
void EnableParallelNavigation(G4bool enableChoice=true)
static constexpr double mm
static const G4double kInfinity
virtual void SetChargeMomentumMass(G4ChargeState particleCharge, G4double MomentumXc, G4double MassXc2)=0
const G4MagIntegratorStepper * GetStepper() const
void ReLocate(const G4ThreeVector &position)
G4double GetSurfaceTolerance() const
G4Navigator * GetNavigatorForTracking() const
G4TouchableHandle CreateTouchableHandle(G4int navId) const
#define fFieldExertedForce
G4double DoNextCurvedStep(const G4FieldTrack &FieldTrack, G4double proposedStepLength, G4VPhysicalVolume *pCurrentPhysVolume)
G4ReferenceCountedHandle< G4VTouchable > G4TouchableHandle
G4ThreeVector GetPosition() const
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
G4double GetRadialTolerance() const
void EnableParallelNavigation(G4bool parallel)
G4double GetRestMass() const
G4double ComputeStep(const G4FieldTrack &pFieldTrack, G4double pCurrentProposedStepLength, G4int navigatorId, G4int stepNo, G4double &pNewSafety, ELimited &limitedStep, G4FieldTrack &EndState, G4VPhysicalVolume *currentVolume)
virtual G4bool RecheckDistanceToCurrentBoundary(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double CurrentProposedStepLength, G4double *prDistance, G4double *prNewSafety=0) const
G4double DoNextLinearStep(const G4FieldTrack &FieldTrack, G4double proposedStepLength)
G4double ComputeSafety(const G4ThreeVector &globalPoint)
G4FieldManager * FindAndSetFieldManager(G4VPhysicalVolume *pCurrentPhysVol)
void PushPostSafetyToPreSafety()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static G4TransportationManager * GetTransportationManager()
G4bool RecheckDistanceToCurrentBoundary(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double *prDistance, G4double *prNewSafety=0) const
G4double GetCharge() const
G4double ComputeStep(G4FieldTrack &pFieldTrack, G4double pCurrentProposedStepLength, G4double &pNewSafety, G4VPhysicalVolume *pPhysVol=0)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
std::vector< G4Navigator * >::iterator GetActiveNavigatorsIterator()
G4ChordFinder * GetChordFinder()
G4double ObtainFinalStep(G4int navigatorId, G4double &pNewSafety, G4double &minStepLast, ELimited &limitedStep)
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
void UpdateYourself(G4VPhysicalVolume *pPhysVol, const G4NavigationHistory *history=0)
const G4NavigationHistory * GetHistory() const
G4ThreeVector GetMomentum() const
const G4Field * GetDetectorField() const
virtual G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=true)
G4MagInt_Driver * GetIntegrationDriver()
G4PropagatorInField * GetPropagatorInField() const
const G4ChargeState * GetChargeState() const
void ReportMove(const G4ThreeVector &OldV, const G4ThreeVector &NewV, const G4String &Quantity) const
G4VPhysicalVolume * GetWorldVolume() const
G4Navigator * GetNavigator(G4int n) const
static G4GeometryTolerance * GetInstance()
G4GLOB_DLL std::ostream G4cerr
G4ThreeVector GetMomentumDirection() const
void SetProperTimeOfFlight(G4double tofProper)