54 for(
auto num=0; num<
fMaxNav; ++num )
92#ifdef G4DEBUG_NAVIGATION
95 G4cout <<
" G4MultiNavigator::ComputeStep : entered " <<
G4endl;
96 G4cout <<
" Input position= " << pGlobalPoint
97 <<
" direction= " << pDirection <<
G4endl;
98 G4cout <<
" Requested step= " << proposedStepLength <<
G4endl;
102 std::vector<G4Navigator*>::iterator pNavigatorIter;
113 step= (*pNavigatorIter)->ComputeStep( initialPosition,
117 if( safety < minSafety ){ minSafety = safety; }
118 if( step < minStep ) { minStep= step; }
124#ifdef G4DEBUG_NAVIGATION
127 G4cout <<
"G4MultiNavigator::ComputeStep : Navigator ["
128 << num <<
"] -- step size " << step
129 <<
" safety= " << safety <<
G4endl;
149#ifdef G4DEBUG_NAVIGATION
155 G4cout <<
"G4MultiNavigator::ComputeStep : "
156 <<
" initialPosition = " << initialPosition
157 <<
" and endPosition = " << endPosition <<
G4endl;
158 G4cout.precision( oldPrec );
162 pNewSafety = minSafety;
166#ifdef G4DEBUG_NAVIGATION
169 G4cout <<
" G4MultiNavigator::ComputeStep : exits returning "
187 std::ostringstream message;
188 message <<
"Bad Navigator Id!" <<
G4endl
189 <<
" Navigator Id = " << navigatorId
191 G4Exception(
"G4MultiNavigator::ObtainFinalStep()",
"GeomNav0002",
201#ifdef G4DEBUG_NAVIGATION
204 G4cout <<
" G4MultiNavigator::ComputeStep returns "
206 <<
" for Navigator " << navigatorId
207 <<
" Limited step = " << limitedStep
208 <<
" Safety(mm) = " << pNewSafety /
mm <<
G4endl;
220#ifdef G4DEBUG_NAVIGATION
223 G4cout <<
" Entered G4MultiNavigator::PrepareNewTrack() " <<
G4endl;
244#ifdef G4DEBUG_NAVIGATION
247 G4cout <<
" Entered G4MultiNavigator::PrepareNavigators() " <<
G4endl;
253 std::vector<G4Navigator*>::iterator pNavigatorIter;
258 std::ostringstream message;
259 message <<
"Too many active Navigators / worlds !" <<
G4endl
260 <<
" Active Navigators (worlds): "
262 <<
" which is more than the number allowed: "
264 G4Exception(
"G4MultiNavigator::PrepareNavigators()",
"GeomNav0002",
289#ifdef G4DEBUG_NAVIGATION
292 G4cout <<
" G4MultiNavigator::PrepareNavigators() changed world volume "
293 <<
" for mass geometry to " << massWorld->
GetName() <<
G4endl;
306 const G4bool pRelativeSearch,
307 const G4bool ignoreDirection )
312 G4bool relative = pRelativeSearch;
313 std::vector<G4Navigator*>::iterator pNavIter
316 if( pDirection ) { direction = *pDirection; }
318#ifdef G4DEBUG_NAVIGATION
321 G4cout <<
" Entered G4MultiNavigator::LocateGlobalPointAndSetup() "
324 <<
", with direction: " << direction <<
G4endl
325 <<
" Relative: " << relative
326 <<
", ignore direction: " << ignoreDirection <<
G4endl;
336 (*pNavIter)->SetGeometricallyLimitedStep();
340 = (*pNavIter)->LocateGlobalPointAndSetup(
position, &direction,
341 relative, ignoreDirection );
352#ifdef G4DEBUG_NAVIGATION
357 <<
", found in volume: " << pLocated <<
G4endl;
366 G4cout <<
"Null' Id: Not-Set ";
376 return volMassLocated;
386 std::vector<G4Navigator*>::iterator pNavIter
389#ifdef G4DEBUG_NAVIGATION
392 G4cout <<
" Entered G4MultiNavigator::ReLocate() " <<
G4endl
401 (*pNavIter)->LocateGlobalPointWithinVolume(
position );
424 std::vector<G4Navigator*>::iterator pNavigatorIter;
429 safety = (*pNavigatorIter)->ComputeSafety(
position, maxDistance, state);
430 if( safety < minSafety ) { minSafety = safety; }
436#ifdef G4DEBUG_NAVIGATION
439 G4cout <<
" G4MultiNavigator::ComputeSafety - returns: "
451 G4Exception(
"G4MultiNavigator::CreateTouchableHistoryHandle()",
453 "Getting a touchable from G4MultiNavigator is not defined.");
459 if( locatedVolume ==
nullptr )
476 const G4int IdTransport= 0;
480#ifdef G4DEBUG_NAVIGATION
483 G4cout <<
" Entered G4MultiNavigator::WhichLimited() " <<
G4endl;
491 if( transportLimited )
516 if( (last > -1) && (noLimited == 1 ) )
534 static const G4String StrDoNot(
"DoNot"), StrUnique(
"Unique"),
535 StrUndefined(
"Undefined"),
536 StrSharedTransport(
"SharedTransport"),
537 StrSharedOther(
"SharedOther");
538 G4cout <<
"### G4MultiNavigator::PrintLimited() reports: " <<
G4endl;
542#ifdef G4DEBUG_NAVIGATION
545 G4cout << std::setw(5) <<
" NavId" <<
" "
546 << std::setw(12) <<
" step-size " <<
" "
547 << std::setw(12) <<
" raw-size " <<
" "
548 << std::setw(12) <<
" pre-safety " <<
" "
549 << std::setw(15) <<
" Limited / flag" <<
" "
550 << std::setw(15) <<
" World " <<
" "
565 G4cout << std::setw(5) << num <<
" "
566 << std::setw(12) << stepLen <<
" "
567 << std::setw(12) << rawStep <<
" "
569 << std::setw(5) << (
fLimitTruth[num] ?
"YES" :
" NO") <<
" ";
573 case kDoNot : limitedStr = StrDoNot;
break;
574 case kUnique : limitedStr = StrUnique;
break;
577 default : limitedStr = StrUndefined;
break;
579 G4cout <<
" " << std::setw(15) << limitedStr <<
" ";
580 G4cout.precision(oldPrec);
592 G4cout <<
" " << WorldName ;
604 G4Exception(
"G4MultiNavigator::ResetState()",
"GeomNav0001",
606 "Cannot reset state for navigators of G4MultiNavigator.");
623 "Cannot setup hierarchy for navigators of G4MultiNavigator.");
637 "Mass world pointer has been changed." );
653 if( pMassNavigator !=
nullptr )
660 G4Exception(
"G4MultiNavigator::ResetHierarchyAndLocate()",
662 "Cannot reset hierarchy before navigators are initialised.");
665 std::vector<G4Navigator*>::iterator pNavIter=
670 G4bool relativeSearch, ignoreDirection;
674 relativeSearch=
false,
675 ignoreDirection=
false);
687 G4bool isObtained =
false;
689 G4int firstNavigatorId = -1;
690 G4bool oneObtained =
false;
697 *argpObtained = isObtained;
703 std::vector<G4Navigator*>::iterator pNavIter=
712 (*pNavIter)->GetGlobalExitNormal( argPoint, &oneObtained );
716 if( !isObtained && (newNormal.
mag2() != 0.0) )
718 normalGlobalCrd = newNormal;
719 isObtained = oneObtained;
720 firstNavigatorId = num;
725 G4double dotNewPrevious = newNormal.
dot( normalGlobalCrd );
727 if( productMagSq > 0.0 )
729 G4double productMag = std::sqrt( productMagSq );
730 dotNewPrevious /= productMag;
733 *argpObtained =
false;
737 std::ostringstream message;
738 message <<
"Clash of Normal from different Navigators!"
740 <<
" Previous Navigator Id = "
741 << firstNavigatorId <<
G4endl
742 <<
" Current Navigator Id = "
744 message <<
" Dot product of 2 normals = "
745 << dotNewPrevious <<
G4endl;
746 message <<
" Normal (previous) = "
747 << normalGlobalCrd <<
G4endl;
748 message <<
" Normal (current) = " << newNormal <<
G4endl;
749 G4Exception(
"G4MultiNavigator::GetGlobalExitNormal()",
766 std::ostringstream message;
768 <<
" candidate Navigators limiting the step!" <<
G4endl;
769 G4Exception(
"G4MultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
776 *argpObtained = isObtained;
777 return normalGlobalCrd;
787 G4bool isObtained =
false;
795 *argpObtained = isObtained;
798 G4int noWarningsStart = 10, noModuloWarnings = 100;
800 if( (numberWarnings < noWarningsStart )
801 || (numberWarnings%noModuloWarnings == 0) )
803 std::ostringstream message;
804 message <<
"Cannot obtain normal in local coordinates of two or more "
805 <<
"coordinate systems." <<
G4endl;
806 G4Exception(
"G4MultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
814 std::ostringstream message;
815 message <<
"Cannot obtain normal in local coordinates of two or more "
816 <<
"coordinate systems." <<
G4endl;
817 G4Exception(
"G4MultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
822 *argpObtained = isObtained;
823 return normalGlobalCrd;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
static constexpr double mm
static constexpr double perThousand
G4ReferenceCountedHandle< G4TouchableHistory > G4TouchableHistoryHandle
G4GLOB_DLL std::ostream G4cout
double dot(const Hep3Vector &) const
G4double fCurrentStepSize[fMaxNav]
G4Navigator * fpNavigator[fMaxNav]
virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &E_Pt, G4bool *obtained)
G4double fNewSafety[fMaxNav]
G4double fMinSafety_PreStepPt
G4ThreeVector fSafetyLocation
G4double ObtainFinalStep(G4int navigatorId, G4double &pNewSafety, G4double &minStepLast, ELimited &limitedStep)
void PrepareNewTrack(const G4ThreeVector position, const G4ThreeVector direction)
G4bool fLimitTruth[fMaxNav]
G4VPhysicalVolume * fLocatedVolume[fMaxNav]
G4VPhysicalVolume * ResetHierarchyAndLocate(const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h)
G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=false)
G4TransportationManager * pTransportManager
ELimited fLimitedStep[fMaxNav]
G4double ComputeStep(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
virtual G4ThreeVector GetLocalExitNormalAndCheck(const G4ThreeVector &E_Pt, G4bool *obtained)
void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
G4ThreeVector fPreStepLocation
G4ThreeVector fLastLocatedPosition
virtual G4ThreeVector GetLocalExitNormal(G4bool *obtained)
G4TouchableHistoryHandle CreateTouchableHistoryHandle() const
static const G4int fMaxNav
G4double fMinSafety_atSafLocation
G4VPhysicalVolume * fLastMassWorld
G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=nullptr, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
G4int fNoActiveNavigators
G4TouchableHistory * CreateTouchableHistory() const
G4bool fWasLimitedByGeometry
virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &point, G4bool *valid)
virtual G4ThreeVector GetLocalExitNormal(G4bool *valid)
void SetWorldVolume(G4VPhysicalVolume *pWorld)
virtual G4VPhysicalVolume * ResetHierarchyAndLocate(const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h)
G4VPhysicalVolume * GetWorldVolume() const
void UpdateYourself(G4VPhysicalVolume *pPhysVol, const G4NavigationHistory *history=nullptr)
const G4NavigationHistory * GetHistory() const
std::vector< G4Navigator * >::iterator GetActiveNavigatorsIterator()
static G4TransportationManager * GetTransportationManager()
G4Navigator * GetNavigatorForTracking() const
virtual G4int GetCopyNo() const =0
const G4String & GetName() const
static const G4double kInfinity