62 fpPathFinder = &theInstance;
72 fFieldExertedForce(false),
73 fRelocatedPoint(true),
74 fLastStepNo(-1), fCurrentStepNo(-1),
84 fNoActiveNavigators= 0;
86 fLastLocatedPosition= Big3Vector;
87 fSafetyLocation= Big3Vector;
88 fPreSafetyLocation= Big3Vector;
89 fPreStepLocation= Big3Vector;
91 fPreSafetyMinValue= -1.0;
92 fMinSafety_PreStepPt= -1.0;
93 fMinSafety_atSafLocation= -1.0;
96 fPreStepCenterRenewed=
false;
98 fNoGeometriesLimiting= 0;
100 for(
register int num=0; num< fMaxNav; ++num )
102 fpNavigator[num] = 0;
103 fLimitTruth[num] =
false;
105 fCurrentStepSize[num] = -1.0;
106 fLocatedVolume[num] = 0;
107 fPreSafetyValues[num]= -1.0;
108 fCurrentPreStepSafety[num] = -1.0;
109 fNewSafetyComputed[num]= -1.0;
118 delete fpMultiNavigator;
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 if( proposedStepLength < fTrueMinStep )
268 std::ostringstream message;
269 message <<
"Problem in step size request." <<
G4endl
270 <<
" Error can be caused by incorrect process ordering."
271 <<
" Being requested to make a step which is shorter"
272 <<
" than the minimum Step " <<
G4endl
273 <<
" already computed for any Navigator/geometry during"
274 <<
" this tracking-step: " <<
G4endl
275 <<
" This can happen due to an error in process ordering."
277 <<
" Check that all physics processes are registered"
279 <<
" before all processes with a navigator/geometry."
281 <<
" If using pre-packaged physics list and/or"
283 <<
" functionality, please report this error."
285 <<
" Additional information for problem: " <<
G4endl
286 <<
" Steps request/proposed = " << proposedStepLength
288 <<
" MinimumStep (true) = " << fTrueMinStep
290 <<
" MinimumStep (navraw) = " << fMinStep
292 <<
" Navigator raw return value" <<
G4endl
293 <<
" Requested step now = " << proposedStepLength
295 <<
" Difference min-req = "
296 << fTrueMinStep-proposedStepLength <<
G4endl
297 <<
" -- Step info> stepNo= " << stepNo
298 <<
" last= " << fLastStepNo
299 <<
" newTr= " << fNewTrack <<
G4endl;
310 if( fVerboseLevel > 1 )
312 G4cout <<
" G4P::CS -> Not calling DoNextLinearStep: "
313 <<
" stepNo= " << stepNo <<
" last= " << fLastStepNo
314 <<
" new= " << fNewTrack <<
" Step already done" <<
G4endl;
324 pNewSafety = fCurrentPreStepSafety[ navigatorNo ];
325 limitedStep = fLimitedStep[ navigatorNo ];
326 fRelocatedPoint=
false;
328 possibleStep= std::min(proposedStepLength, fCurrentStepSize[ navigatorNo ]);
329 EndState = fEndState;
331#ifdef G4DEBUG_PATHFINDER
332 if( fVerboseLevel > 0 )
334 G4cout <<
" G4PathFinder::ComputeStep returns "
335 << fCurrentStepSize[ navigatorNo ]
336 <<
" for Navigator " << navigatorNo
337 <<
" Limited step = " << limitedStep
338 <<
" Safety(mm) = " << pNewSafety / mm
370 std::vector<G4Navigator*>::iterator pNavigatorIter;
372 fNoActiveNavigators= fpTransportManager-> GetNoActiveNavigators();
373 if( fNoActiveNavigators > fMaxNav )
375 std::ostringstream message;
376 message <<
"Too many active Navigators / worlds." <<
G4endl
377 <<
" Transportation Manager has "
378 << fNoActiveNavigators <<
" active navigators." <<
G4endl
379 <<
" This is more than the number allowed = "
381 G4Exception(
"G4PathFinder::PrepareNewTrack()",
"GeomNav0002",
389 for( num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
393 fpNavigator[num] = *pNavigatorIter;
394 fLimitTruth[num] =
false;
395 fLimitedStep[num] =
kDoNot;
396 fCurrentStepSize[num] = 0.0;
397 fLocatedVolume[num] = 0;
399 fNoGeometriesLimiting= 0;
403 if( fNoActiveNavigators > 1 )
412 fLocatedVolume[0]= massStartVol;
415 fCurrentStepSize[0] = 0.0;
421 fMinSafety_PreStepPt= fPreSafetyMinValue= fMinSafety_atSafLocation= 0.0;
423 for( num=0; num< fNoActiveNavigators; ++num )
425 fPreSafetyValues[num]= 0.0;
426 fNewSafetyComputed[num]= 0.0;
427 fCurrentPreStepSafety[num] = 0.0;
433 fRelocatedPoint=
false;
443 std::ostringstream message;
444 message <<
"Endpoint moved between value returned by ComputeStep()"
445 <<
" and call to Locate(). " <<
G4endl
446 <<
" Change of " << Quantity <<
" is "
447 << moveVec.
mag() / mm <<
" mm long" <<
G4endl
448 <<
" and its vector is "
449 << (1.0/mm) * moveVec <<
" mm " <<
G4endl
450 <<
" Endpoint of ComputeStep() was " << OldVector <<
G4endl
451 <<
" and current position to locate is " << NewVector;
452 G4Exception(
"G4PathFinder::ReportMove()",
"GeomNav1002",
464 std::vector<G4Navigator*>::iterator pNavIter=
470 if( (!fNewTrack) && (!fRelocatedPoint)
471 && ( moveLenSq> kCarTolerance*kCarTolerance ) )
477#ifdef G4DEBUG_PATHFINDER
478 if( fVerboseLevel > 2 )
484 <<
" with direction " << direction
485 <<
" relative= " << relative <<
G4endl;
486 if ( (fVerboseLevel > 1) || ( moveLenSq > 0.0) )
488 G4cout <<
" lastEndPosition = " << lastEndPosition
489 <<
" moveVec = " << moveVec
490 <<
" newTr = " << fNewTrack
491 <<
" relocated = " << fRelocatedPoint <<
G4endl;
499 for (
register G4int num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
503 if( fLimitTruth[num] ) { (*pNavIter)->SetGeometricallyLimitedStep(); }
506 (*pNavIter)->LocateGlobalPointAndSetup(
position, &direction,
511 fLocatedVolume[num] = pLocated;
515 fLimitedStep[num] =
kDoNot;
516 fCurrentStepSize[num] = 0.0;
518#ifdef G4DEBUG_PATHFINDER
519 if( fVerboseLevel > 2 )
521 G4cout <<
" - In world " << num <<
" geomLimStep= " << fLimitTruth[num]
522 <<
" gives volume= " << pLocated ;
525 G4cout <<
" name = '" << pLocated->GetName() <<
"'";
526 G4cout <<
" - CopyNo= " << pLocated->GetCopyNo();
533 fRelocatedPoint=
false;
540 std::vector<G4Navigator*>::iterator pNavIter=
543#ifdef G4DEBUG_PATHFINDER
553 G4double DistanceStartEnd= (lastEndPosition - fPreStepLocation).mag();
554 G4double endPointSafety_raw = fMinSafety_PreStepPt - DistanceStartEnd;
555 G4double endPointSafety_Est1 = std::max( 0.0, endPointSafety_raw );
568 G4double distCheckEnd_sq= ( moveLenEndPosSq - endPointSafety_Est1
569 *endPointSafety_Est1 );
570 G4double distCheckSaf_sq= ( moveLenSafSq - fMinSafety_atSafLocation
571 *fMinSafety_atSafLocation );
573 G4bool longMoveEnd = distCheckEnd_sq > 0.0;
574 G4bool longMoveSaf = distCheckSaf_sq > 0.0;
578 if( (!fNewTrack) && ( longMoveEnd && longMoveSaf ) )
586 const G4double cErrorTolerance=1e-12;
589 G4double distCheckRevisedEnd= moveLenEndPosSq-revisedSafety*revisedSafety;
591 G4bool longMoveRevisedEnd= ( distCheckRevisedEnd > 0. ) ;
594 G4double moveLenEndPosition= std::sqrt( moveLenEndPosSq );
595 moveMinusSafety = moveLenEndPosition - revisedSafety;
597 if ( longMoveRevisedEnd && (moveMinusSafety > 0.0 )
598 && ( revisedSafety > 0.0 ) )
603 if( fVerboseLevel > 0 )
605 G4cout <<
" G4PF:Relocate> Ratio to revised safety is "
606 << std::fabs(moveMinusSafety)/revisedSafety <<
G4endl;
609 G4double absMoveMinusSafety= std::fabs(moveMinusSafety);
610 G4bool smallRatio= absMoveMinusSafety < kRadTolerance * revisedSafety ;
615 G4bool smallValue= absMoveMinusSafety < cErrorTolerance * maxCoordPos;
616 if( ! (smallRatio || smallValue) )
618 G4cout <<
" G4PF:Relocate> Ratio to revised safety is "
619 << std::fabs(moveMinusSafety)/revisedSafety <<
G4endl;
620 G4cout <<
" Difference of move and safety is not very small."
625 moveMinusSafety = 0.0;
626 longMoveRevisedEnd =
false;
628 G4cout <<
" Difference of move & safety is very small in magnitude, "
629 << absMoveMinusSafety <<
G4endl;
632 G4cout <<
" ratio to safety " << revisedSafety
633 <<
" is " << absMoveMinusSafety / revisedSafety
634 <<
"smaller than " << kRadTolerance <<
" of safety ";
638 G4cout <<
" as fraction " << absMoveMinusSafety / maxCoordPos
639 <<
" of position vector max-coord " << maxCoordPos
640 <<
" smaller than " << cErrorTolerance ;
642 G4cout <<
" -- reset moveMinusSafety to "
643 << moveMinusSafety <<
G4endl;
647 if ( longMoveEnd && longMoveSaf
648 && longMoveRevisedEnd && (moveMinusSafety>0.0) )
651 std::ostringstream message;
652 message <<
"ReLocation is further than end-safety value." <<
G4endl
653 <<
" Moved from last endpoint by " << moveLenEndPosition
654 <<
" compared to end safety (from preStep point) = "
655 << endPointSafety_Est1 <<
G4endl
656 <<
" --> last PreSafety Location was " << fPreSafetyLocation
658 <<
" safety value = " << fPreSafetyMinValue <<
G4endl
659 <<
" --> last PreStep Location was " << fPreStepLocation
661 <<
" safety value = " << fMinSafety_PreStepPt <<
G4endl
662 <<
" --> last EndStep Location was " << lastEndPosition
664 <<
" safety value = " << endPointSafety_Est1
665 <<
" raw-value = " << endPointSafety_raw <<
G4endl
666 <<
" --> Calling again at this endpoint, we get "
667 << revisedSafety <<
" as safety value." <<
G4endl
668 <<
" --> last position for safety " << fSafetyLocation
670 <<
" its safety value = " << fMinSafety_atSafLocation
672 <<
" move from safety location = "
673 << std::sqrt(moveLenSafSq) <<
G4endl
674 <<
" again= " << moveVecSafety.
mag() <<
G4endl
675 <<
" safety - Move-from-end= "
676 << revisedSafety - moveLenEndPosition
677 <<
" (negative is Bad.)" <<
G4endl
678 <<
" Debug: distCheckRevisedEnd = "
679 << distCheckRevisedEnd;
681 G4Exception(
"G4PathFinder::ReLocate",
"GeomNav0003",
683 G4cout.precision(oldPrec);
687 if( fVerboseLevel > 2 )
690 G4cout <<
" G4PathFinder::ReLocate : entered " <<
G4endl;
695 if ( (fVerboseLevel > -1) || ( moveLenEndPosSq > 0.0) )
697 G4cout <<
" lastEndPosition = " << lastEndPosition
698 <<
" moveVec from step-end = " << moveVecEndPos
699 <<
" is new Track = " << fNewTrack
700 <<
" relocated = " << fRelocatedPoint <<
G4endl;
705 for (
register G4int num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
709 (*pNavIter)->LocateGlobalPointWithinVolume(
position );
713 fLimitedStep[num] =
kDoNot;
714 fCurrentStepSize[num] = 0.0;
715 fLimitTruth[num] =
false;
719 fRelocatedPoint=
false;
721#ifdef G4DEBUG_PATHFINDER
722 if( fVerboseLevel > 2 )
724 G4cout <<
" G4PathFinder::ReLocate : exiting "
725 <<
" at position " << fLastLocatedPosition <<
G4endl <<
G4endl;
738 std::vector<G4Navigator*>::iterator pNavigatorIter;
741 for(
register G4int num=0; num<fNoActiveNavigators; ++pNavigatorIter,++num )
744 if( safety < minSafety ) { minSafety = safety; }
745 fNewSafetyComputed[num]= safety;
749 fMinSafety_atSafLocation = minSafety;
751#ifdef G4DEBUG_PATHFINDER
752 if( fVerboseLevel > 1 )
754 G4cout <<
" G4PathFinder::ComputeSafety - returns "
767#ifdef G4DEBUG_PATHFINDER
768 if( fVerboseLevel > 2 )
770 G4cout <<
"G4PathFinder::CreateTouchableHandle : navId = "
776 touchHist=
GetNavigator(navId) -> CreateTouchableHistory();
779 if( locatedVolume == 0 )
786#ifdef G4DEBUG_PATHFINDER
787 if( fVerboseLevel > 2 )
790 if( locatedVolume ) { VolumeName= locatedVolume->
GetName(); }
791 G4cout <<
" Touchable History created at address " << touchHist
792 <<
" volume = " << locatedVolume <<
" name= " << VolumeName
804 std::vector<G4Navigator*>::iterator pNavigatorIter;
806 G4double minSafety= kInfinity, minStep;
808 const G4int IdTransport= 0;
809 register G4int num=0;
811#ifdef G4DEBUG_PATHFINDER
812 if( fVerboseLevel > 2 )
814 G4cout <<
" G4PathFinder::DoNextLinearStep : entered " <<
G4endl;
815 G4cout <<
" Input field track= " << initialState <<
G4endl;
816 G4cout <<
" Requested step= " << proposedStepLength <<
G4endl;
823 G4ThreeVector OriginShift = initialPosition - fPreSafetyLocation;
833 MagShift= std::sqrt(MagSqShift) ;
835#ifdef G4PATHFINDER_OPTIMISATION
839 if( MagSqShift >=
sqr(fPreSafetyMinValue ) )
845 fullSafety = fPreSafetyMinValue - MagShift;
847 if( proposedStepLength < fullSafety )
852 fPreStepCenterRenewed=
false;
854 for( num=0; num< fNoActiveNavigators; ++num )
856 fCurrentStepSize[num]= kInfinity;
857 safety = std::max( 0.0, fPreSafetyValues[num] - MagShift);
858 minSafety= std::min( safety, minSafety );
859 fCurrentPreStepSafety[num]= safety;
863#ifdef G4DEBUG_PATHFINDER
864 if( fVerboseLevel > 2 )
866 G4cout <<
"G4PathFinder::DoNextLinearStep : Quick Stepping. " <<
G4endl
867 <<
" proposedStepLength " << proposedStepLength
868 <<
" < (full) safety = " << fullSafety
869 <<
" at " << initialPosition
880 fPreStepCenterRenewed=
true;
881 pNavigatorIter= fpTransportManager-> GetActiveNavigatorsIterator();
885 for( num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
887 safety = std::max( 0.0, fPreSafetyValues[num] - MagShift);
889#ifdef G4PATHFINDER_OPTIMISATION
890 if( proposedStepLength <= safety )
896#ifdef G4DEBUG_PATHFINDER
898 G4cout <<
"PathFinder::ComputeStep> small proposed step = "
899 << proposedStepLength
900 <<
" <= safety = " << safety <<
" for nav " << num
901 <<
" Step fully taken. " <<
G4endl;
907#ifdef G4DEBUG_PATHFINDER
910 step= (*pNavigatorIter)->ComputeStep( initialPosition,
914 minStep = std::min( step, minStep);
919#ifdef G4DEBUG_PATHFINDER
920 if( fVerboseLevel > 0)
923 G4cout <<
"PathFinder::ComputeStep> long proposed step = "
924 << proposedStepLength
925 <<
" > safety = " << previousSafety
926 <<
" for nav " << num
927 <<
" . New safety = " << safety <<
" step= " << step
932 fCurrentStepSize[num] = step;
938 fPreSafetyValues[num]= safety;
939 fCurrentPreStepSafety[num]= safety;
941 minSafety= std::min( safety, minSafety );
943#ifdef G4DEBUG_PATHFINDER
944 if( fVerboseLevel > 2 )
946 G4cout <<
"G4PathFinder::DoNextLinearStep : Navigator ["
947 << num <<
"] -- step size " << step <<
G4endl;
955 fPreSafetyLocation= initialPosition;
956 fPreSafetyMinValue= minSafety;
961 fPreStepLocation= initialPosition;
962 fMinSafety_PreStepPt= minSafety;
966 if( fMinStep == kInfinity )
968 minStep = proposedStepLength;
970 fTrueMinStep = minStep;
976 fEndState= initialState;
977 endPosition= initialPosition + minStep * initialDirection ;
979#ifdef G4DEBUG_PATHFINDER
980 if( fVerboseLevel > 1 )
982 G4cout <<
"G4PathFinder::DoNextLinearStep : "
983 <<
" initialPosition = " << initialPosition
984 <<
" and endPosition = " << endPosition<<
G4endl;
991 if( fNoActiveNavigators == 1 )
993 G4bool transportLimited = (fMinStep!= kInfinity);
994 fLimitTruth[IdTransport] = transportLimited;
995 fLimitedStep[IdTransport] = transportLimited ?
kUnique :
kDoNot;
998 fNoGeometriesLimiting = transportLimited ? 1 : 0;
1005#ifdef G4DEBUG_PATHFINDER
1006 if( fVerboseLevel > 2 )
1008 G4cout <<
" G4PathFinder::DoNextLinearStep : exits returning "
1010 G4cout <<
" Endpoint values = " << fEndState <<
G4endl;
1022 G4int num=-1, last=-1;
1026 const G4int IdTransport= 0;
1030 G4bool transportLimited = (fCurrentStepSize[IdTransport] == fMinStep)
1031 && ( fMinStep!= kInfinity) ;
1033 if( transportLimited ) {
1037 for ( num= 0; num < fNoActiveNavigators; num++ )
1041 G4double step= fCurrentStepSize[num];
1043 limitedStep = ( std::fabs(step - fMinStep) < kCarTolerance )
1044 && ( step != kInfinity);
1046 fLimitTruth[ num ] = limitedStep;
1050 fLimitedStep[num] = shared;
1055 fLimitedStep[num] =
kDoNot;
1058 fNoGeometriesLimiting= noLimited;
1060 if( (last > -1) && (noLimited == 1 ) )
1062 fLimitedStep[ last ] =
kUnique;
1065#ifdef G4DEBUG_PATHFINDER
1066 if( fVerboseLevel > 1 )
1069 if( fVerboseLevel > 4 ) {
1070 G4cout <<
" G4PathFinder::WhichLimited - exiting. " <<
G4endl;
1080 G4cout <<
"G4PathFinder::PrintLimited reports: " ;
1081 G4cout <<
" Minimum step (true)= " << fTrueMinStep
1082 <<
" reported min = " << fMinStep
1084 if( (fCurrentStepNo <= 2) || (fVerboseLevel>=2) )
1086 G4cout << std::setw(5) <<
" Step#" <<
" "
1087 << std::setw(5) <<
" NavId" <<
" "
1088 << std::setw(12) <<
" step-size " <<
" "
1089 << std::setw(12) <<
" raw-size " <<
" "
1090 << std::setw(12) <<
" pre-safety " <<
" "
1091 << std::setw(15) <<
" Limited / flag" <<
" "
1092 << std::setw(15) <<
" World " <<
" "
1096 for ( num= 0; num < fNoActiveNavigators; num++ )
1098 G4double rawStep = fCurrentStepSize[num];
1099 G4double stepLen = fCurrentStepSize[num];
1100 if( stepLen > fTrueMinStep )
1102 stepLen = fTrueMinStep;
1106 G4cout << std::setw(5) << fCurrentStepNo <<
" "
1107 << std::setw(5) << num <<
" "
1108 << std::setw(12) << stepLen <<
" "
1109 << std::setw(12) << rawStep <<
" "
1110 << std::setw(12) << fCurrentPreStepSafety[num] <<
" "
1111 << std::setw(5) << (fLimitTruth[num] ?
"YES" :
" NO") <<
" ";
1113 G4cout <<
" " << std::setw(15) << limitedStr <<
" ";
1114 G4cout.precision(oldPrec);
1123 WorldName = pWorld->
GetName();
1126 G4cout <<
" " << WorldName ;
1130 if( fVerboseLevel > 4 )
1132 G4cout <<
" G4PathFinder::PrintLimited - exiting. " <<
G4endl;
1141 const G4double toleratedRelativeError= 1.0e-10;
1142 G4double minStep= kInfinity, newSafety=0.0;
1147#ifdef G4DEBUG_PATHFINDER
1149 if( fVerboseLevel > 2 )
1151 G4cout <<
" G4PathFinder::DoNextCurvedStep ****** " <<
G4endl;
1152 G4cout <<
" Initial value of field track is " << fieldTrack
1153 <<
" and proposed step= " << proposedStepLength <<
G4endl;
1157 fPreStepCenterRenewed=
true;
1159 if( fNoActiveNavigators > 1 )
1163 G4double minSafety= kInfinity, safety;
1164 for( numNav=0; numNav < fNoActiveNavigators; ++numNav )
1166 safety= fpNavigator[numNav]->
ComputeSafety( startPoint,
false );
1167 fPreSafetyValues[numNav]= safety;
1168 fCurrentPreStepSafety[numNav]= safety;
1169 minSafety = std::min( safety, minSafety );
1174 fPreSafetyLocation= startPoint;
1175 fPreSafetyMinValue= minSafety;
1176 fPreStepLocation= startPoint;
1177 fMinSafety_PreStepPt= minSafety;
1182 minStep= fpFieldPropagator->
ComputeStep( fieldTrack,
1185 pCurrentPhysicalVolume );
1189 fEndState= fieldTrack;
1191 fTrueMinStep = std::min( minStep, proposedStepLength );
1193 if( fNoActiveNavigators== 1 )
1198 fPreSafetyValues[0]= newSafety;
1199 fPreSafetyLocation= startPoint;
1200 fPreSafetyMinValue= newSafety;
1204 fCurrentPreStepSafety[0]= newSafety;
1205 fPreStepLocation= startPoint;
1206 fMinSafety_PreStepPt= newSafety;
1209#ifdef G4DEBUG_PATHFINDER
1210 if( fVerboseLevel > 2 )
1212 G4cout <<
"G4PathFinder::DoNextCurvedStep : " <<
G4endl
1213 <<
" initialState = " << initialState <<
G4endl
1214 <<
" and endState = " << fEndState <<
G4endl;
1215 G4cout <<
"G4PathFinder::DoNextCurvedStep : "
1216 <<
" minStep = " << minStep
1217 <<
" proposedStepLength " << proposedStepLength
1218 <<
" safety = " << newSafety <<
G4endl;
1222 if( minStep < proposedStepLength )
1228 for( numNav=0; numNav < fNoActiveNavigators; ++numNav )
1230 G4double finalStep, lastPreSafety=0.0, minStepLast;
1235 minStepLast, didLimit );
1240 currentStepSize = fTrueMinStep;
1242 if( (minStepLast != kInfinity) )
1244 diffStep = (finalStep-minStepLast);
1245 if ( std::abs(diffStep) <= toleratedRelativeError * finalStep )
1249 currentStepSize += diffStep;
1251 fCurrentStepSize[numNav] = currentStepSize;
1264 fLimitedStep[numNav] = didLimit;
1265 fLimitTruth[numNav] = limited = (didLimit !=
kDoNot );
1266 if( limited ) { noLimited++; }
1268#ifdef G4DEBUG_PATHFINDER
1269 G4bool StepError= (currentStepSize < 0)
1270 || ( (minStepLast != kInfinity) && (diffStep < 0) ) ;
1271 if( StepError || (fVerboseLevel > 2) )
1275 G4cout <<
" G4PathFinder::ComputeStep. Geometry " << numNav
1276 <<
" step= " << fCurrentStepSize[numNav]
1277 <<
" from final-step= " << finalStep
1278 <<
" fTrueMinStep= " << fTrueMinStep
1279 <<
" minStepLast= " << minStepLast
1280 <<
" limited = " << (fLimitTruth[numNav] ?
"YES" :
" NO")
1282 G4cout <<
" status = " << limitedString <<
" #= " << didLimit
1287 std::ostringstream message;
1288 message <<
"Incorrect calculation of step size for one navigator"
1290 <<
" currentStepSize = " << currentStepSize
1291 <<
", diffStep= " << diffStep <<
G4endl
1292 <<
"ERROR in computing step size for this navigator.";
1300 fNoGeometriesLimiting= noLimited;
1302 else if ( (minStep == proposedStepLength)
1303 || (minStep == kInfinity)
1304 || ( std::abs(minStep-proposedStepLength)
1305 < toleratedRelativeError * proposedStepLength ) )
1314 currentStepSize= minStep;
1315 for( numNav=0; numNav < fNoActiveNavigators; ++numNav )
1317 fCurrentStepSize[numNav] = minStep;
1319 fLimitedStep[numNav] =
kDoNot;
1320 fLimitTruth[numNav] =
false;
1322 fNoGeometriesLimiting= 0;
1326 std::ostringstream message;
1327 message <<
"Incorrect calculation of step size for one navigator." <<
G4endl
1328 <<
" currentStepSize = " << minStep <<
" is larger than "
1329 <<
" proposed StepSize = " << proposedStepLength <<
".";
1334#ifdef G4DEBUG_PATHFINDER
1335 if( fVerboseLevel > 2 )
1337 G4cout <<
" Exiting G4PathFinder::DoNextCurvedStep " <<
G4endl;
1349 StrUnique(
"Unique"),
1350 StrUndefined(
"Undefined"),
1351 StrSharedTransport(
"SharedTransport"),
1352 StrSharedOther(
"SharedOther");
1357 case kDoNot: limitedStr= &StrDoNot;
break;
1358 case kUnique: limitedStr = &StrUnique;
break;
1360 case kSharedOther: limitedStr = &StrSharedOther;
break;
1361 default: limitedStr = &StrUndefined;
break;
1368 fPreSafetyLocation= fSafetyLocation;
1369 fPreSafetyMinValue= fMinSafety_atSafLocation;
1370 for(
register G4int nav=0; nav < fNoActiveNavigators; ++nav )
1372 fPreSafetyValues[nav]= fNewSafetyComputed[nav];
G4ReferenceCountedHandle< G4VTouchable > G4TouchableHandle
G4DLLIMPORT std::ostream G4cerr
G4DLLIMPORT std::ostream G4cout
const G4Field * GetDetectorField() const
G4ThreeVector GetMomentumDirection() const
G4double GetCharge() const
void SetProperTimeOfFlight(G4double nTOF)
G4ThreeVector GetPosition() const
void SetPosition(G4ThreeVector nPos)
G4double GetSurfaceTolerance() const
G4double GetRadialTolerance() const
static G4GeometryTolerance * GetInstance()
G4double ObtainFinalStep(G4int navigatorId, G4double &pNewSafety, G4double &minStepLast, ELimited &limitedStep)
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=0)
static G4PathFinder * GetInstance()
G4TouchableHandle CreateTouchableHandle(G4int navId) const
G4double ComputeStep(G4FieldTrack &pFieldTrack, G4double pCurrentProposedStepLength, G4double &pNewSafety, G4VPhysicalVolume *pPhysVol=0)
G4FieldManager * FindAndSetFieldManager(G4VPhysicalVolume *pCurrentPhysVol)
void SetNavigatorForPropagating(G4Navigator *SimpleOrMultiNavigator)
void EnableParallelNavigation(G4bool parallel)
const G4NavigationHistory * GetHistory() const
void UpdateYourself(G4VPhysicalVolume *pPhysVol, const G4NavigationHistory *history=0)
std::vector< G4Navigator * >::iterator GetActiveNavigatorsIterator()
static G4TransportationManager * GetTransportationManager()
G4PropagatorInField * GetPropagatorInField() const
G4SafetyHelper * GetSafetyHelper() const
G4Navigator * GetNavigatorForTracking() const
const G4String & GetName() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)