Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4MultiNavigator Class Reference

G4MultiNavigator is a utility class for polling the navigators of several geometries to identify the next boundary. More...

#include <G4MultiNavigator.hh>

Inheritance diagram for G4MultiNavigator:

Public Member Functions

 G4MultiNavigator ()
 ~G4MultiNavigator () override=default
G4double ComputeStep (const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety) override
G4double ObtainFinalStep (G4int navigatorId, G4double &pNewSafety, G4double &minStepLast, ELimited &limitedStep)
void PrepareNavigators ()
void PrepareNewTrack (const G4ThreeVector &position, const G4ThreeVector direction)
G4VPhysicalVolumeResetHierarchyAndLocate (const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h) override
G4VPhysicalVolumeLocateGlobalPointAndSetup (const G4ThreeVector &point, const G4ThreeVector *direction=nullptr, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true) override
void LocateGlobalPointWithinVolume (const G4ThreeVector &position) override
G4double ComputeSafety (const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=false) override
G4TouchableHandle CreateTouchableHistoryHandle () const override
G4ThreeVector GetLocalExitNormal (G4bool *obtained) override
G4ThreeVector GetLocalExitNormalAndCheck (const G4ThreeVector &point, G4bool *obtained) override
G4ThreeVector GetGlobalExitNormal (const G4ThreeVector &point, G4bool *obtained) override
G4NavigatorGetNavigator (G4int n) const
Public Member Functions inherited from G4Navigator
 G4Navigator ()
 G4Navigator (const G4Navigator &)=delete
G4Navigatoroperator= (const G4Navigator &)=delete
virtual ~G4Navigator ()
G4double CheckNextStep (const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
void LocateGlobalPointAndUpdateTouchableHandle (const G4ThreeVector &position, const G4ThreeVector &direction, G4TouchableHandle &oldTouchableToUpdate, const G4bool RelativeSearch=true)
void LocateGlobalPointAndUpdateTouchable (const G4ThreeVector &position, const G4ThreeVector &direction, G4VTouchable *touchableToUpdate, const G4bool RelativeSearch=true)
void LocateGlobalPointAndUpdateTouchable (const G4ThreeVector &position, G4VTouchable *touchableToUpdate, const G4bool RelativeSearch=true)
void SetGeometricallyLimitedStep ()
G4VPhysicalVolumeGetWorldVolume () const
void SetWorldVolume (G4VPhysicalVolume *pWorld)
G4TouchableHistoryCreateTouchableHistory () const
G4TouchableHistoryCreateTouchableHistory (const G4NavigationHistory *h) const
G4int GetVerboseLevel () const
void SetVerboseLevel (G4int level)
G4bool IsActive () const
void Activate (G4bool flag)
G4bool EnteredDaughterVolume () const
G4bool ExitedMotherVolume () const
void CheckMode (G4bool mode)
G4bool IsCheckModeActive () const
void SetPushVerbosity (G4bool mode)
void PrintState () const
const G4AffineTransformGetGlobalToLocalTransform () const
const G4AffineTransform GetLocalToGlobalTransform () const
G4AffineTransform GetMotherToDaughterTransform (G4VPhysicalVolume *dVolume, G4int dReplicaNo, EVolume dVolumeType)
void ResetStackAndState ()
G4int SeverityOfZeroStepping (G4int *noZeroSteps) const
G4ThreeVector GetCurrentLocalCoordinate () const
G4ThreeVector NetTranslation () const
G4RotationMatrix NetRotation () const
void EnableBestSafety (G4bool value=false)
G4VExternalNavigationGetExternalNavigation () const
void SetExternalNavigation (G4VExternalNavigation *externalNav)
G4VoxelNavigationGetVoxelNavigator ()
void SetVoxelNavigation (G4VoxelNavigation *voxelNav)
G4NavigatorClone () const
G4ThreeVector GetLastStepEndPoint () const
void InformLastStep (G4double lastStep, G4bool entersDaughtVol, G4bool exitsMotherVol)

Protected Member Functions

void ResetState () override
void SetupHierarchy () override
void WhichLimited ()
void PrintLimited ()
void CheckMassWorld ()
Protected Member Functions inherited from G4Navigator
void SetSavedState ()
void RestoreSavedState ()
G4ThreeVector ComputeLocalPoint (const G4ThreeVector &rGlobP) const
G4ThreeVector ComputeLocalAxis (const G4ThreeVector &pVec) const
EVolume VolumeType (const G4VPhysicalVolume *pVol) const
EVolume CharacteriseDaughters (const G4LogicalVolume *pLog) const
G4int GetDaughtersRegularStructureId (const G4LogicalVolume *pLv) const
G4bool CheckOverlapsIterative (G4VPhysicalVolume *vol)

Friends

std::ostream & operator<< (std::ostream &os, const G4Navigator &n)

Additional Inherited Members

Protected Attributes inherited from G4Navigator
G4double kCarTolerance
G4double fMinStep
G4double fSqTol
G4NavigationHistory fHistory
G4ThreeVector fStepEndPoint
G4ThreeVector fLastStepEndPointLocal
G4int fVerbose = 0
G4bool fEnteredDaughter
G4bool fExitedMother
G4bool fWasLimitedByGeometry = false

Detailed Description

G4MultiNavigator is a utility class for polling the navigators of several geometries to identify the next boundary.

Definition at line 58 of file G4MultiNavigator.hh.

Constructor & Destructor Documentation

◆ G4MultiNavigator()

G4MultiNavigator::G4MultiNavigator ( )

Constructor and default Destructor.

Definition at line 42 of file G4MultiNavigator.cc.

43{
44 G4ThreeVector Big3Vector( kInfinity, kInfinity, kInfinity );
45 fLastLocatedPosition = Big3Vector;
46 fSafetyLocation = Big3Vector;
47 fPreStepLocation = Big3Vector;
48
49 for(auto num=0; num< fMaxNav; ++num )
50 {
51 fpNavigator[num] = nullptr;
52 fLimitTruth[num] = false;
53 fLimitedStep[num] = kUndefLimited;
54 fCurrentStepSize[num] = fNewSafety[num] = -1.0;
55 fLocatedVolume[num] = nullptr;
56 }
57
59
60 G4Navigator* massNav= pTransportManager->GetNavigatorForTracking();
61 if( massNav != nullptr )
62 {
63 G4VPhysicalVolume* pWorld= massNav->GetWorldVolume();
64 if( pWorld != nullptr )
65 {
66 SetWorldVolume( pWorld );
67 fLastMassWorld = pWorld;
68 }
69 }
70}
@ kUndefLimited
CLHEP::Hep3Vector G4ThreeVector
void SetWorldVolume(G4VPhysicalVolume *pWorld)
G4VPhysicalVolume * GetWorldVolume() const
static G4TransportationManager * GetTransportationManager()

◆ ~G4MultiNavigator()

G4MultiNavigator::~G4MultiNavigator ( )
overridedefault

Member Function Documentation

◆ CheckMassWorld()

void G4MultiNavigator::CheckMassWorld ( )
protected

Checks if mass world pointed has been changed => issues and exception.

Definition at line 618 of file G4MultiNavigator.cc.

619{
620 G4VPhysicalVolume* navTrackWorld =
621 pTransportManager->GetNavigatorForTracking()->GetWorldVolume();
622
623 if( navTrackWorld != fLastMassWorld )
624 {
625 G4Exception( "G4MultiNavigator::CheckMassWorld()",
626 "GeomNav0003", FatalException,
627 "Mass world pointer has been changed." );
628 }
629}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)

◆ ComputeSafety()

G4double G4MultiNavigator::ComputeSafety ( const G4ThreeVector & globalpoint,
const G4double pProposedMaxLength = DBL_MAX,
const G4bool keepState = false )
overridevirtual

Calculates the isotropic distance to the nearest boundary in any geometry from the specified point in the global coordinates system.

Note
The geometry must be closed.
Parameters
[in]globalpointThe point in global coordinates system. The point must be within the current volume.
[in]pProposedMaxLengthThe proposed maximum length is used to avoid volume safety calculations.
[in]keepStateFlag to instruct keeping the state (default false) to ensure minimum side effects from the call.
Returns
Length from current point to closest boundary surface. The value returned is usually an underestimate.

Reimplemented from G4Navigator.

Definition at line 407 of file G4MultiNavigator.cc.

410{
411 // Recompute safety for the relevant point
412
413 G4double minSafety = kInfinity, safety = kInfinity;
414
415 std::vector<G4Navigator*>::iterator pNavigatorIter;
416 pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
417
418 for( auto num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
419 {
420 safety = (*pNavigatorIter)->ComputeSafety( position, maxDistance, state);
421 if( safety < minSafety ) { minSafety = safety; }
422 }
423
424 fSafetyLocation = position;
425 fMinSafety_atSafLocation = minSafety;
426
427#ifdef G4DEBUG_NAVIGATION
428 if( fVerbose > 1 )
429 {
430 G4cout << " G4MultiNavigator::ComputeSafety - returns: "
431 << minSafety << ", at location: " << position << G4endl;
432 }
433#endif
434 return minSafety;
435}
double G4double
Definition G4Types.hh:83
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout

◆ ComputeStep()

G4double G4MultiNavigator::ComputeStep ( const G4ThreeVector & pGlobalPoint,
const G4ThreeVector & pDirection,
const G4double pCurrentProposedStepLength,
G4double & pNewSafety )
overridevirtual

Computes the distance to the next boundary of any geometry.

Parameters
[in]pGlobalPointThe point in global coordinates system.
[in]pDirectionThe normalised vector direction.
[in]pCurrentProposedStepLengthCurrent proposed step length.
[in,out]newSafetyNew safety.
Returns
Length from current point to next boundary surface along pDirection.

Reimplemented from G4Navigator.

Definition at line 74 of file G4MultiNavigator.cc.

78{
79 G4double safety= 0.0, step=0.0;
80 G4double minSafety= kInfinity, minStep= kInfinity;
81
82 fNoLimitingStep= -1;
83 fIdNavLimiting= -1; // Reset for new step
84
85#ifdef G4DEBUG_NAVIGATION
86 if( fVerbose > 2 )
87 {
88 G4cout << " G4MultiNavigator::ComputeStep : entered " << G4endl;
89 G4cout << " Input position= " << pGlobalPoint
90 << " direction= " << pDirection << G4endl;
91 G4cout << " Requested step= " << proposedStepLength << G4endl;
92 }
93#endif
94
95 std::vector<G4Navigator*>::iterator pNavigatorIter;
96
97 pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
98
99 G4ThreeVector initialPosition = pGlobalPoint;
100 G4ThreeVector initialDirection= pDirection;
101
102 for( auto num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
103 {
104 safety= kInfinity;
105
106 step= (*pNavigatorIter)->ComputeStep( initialPosition,
107 initialDirection,
108 proposedStepLength,
109 safety );
110 if( safety < minSafety ){ minSafety = safety; }
111 if( step < minStep ) { minStep= step; }
112
113 fCurrentStepSize[num] = step;
114 fNewSafety[num]= safety;
115 // This is currently the safety from the last sub-step
116
117#ifdef G4DEBUG_NAVIGATION
118 if( fVerbose > 2 )
119 {
120 G4cout << "G4MultiNavigator::ComputeStep : Navigator ["
121 << num << "] -- step size " << step
122 << " safety= " << safety << G4endl;
123 }
124#endif
125 }
126
127 // Save safety value, related position
128 //
129 fPreStepLocation = initialPosition;
130 fMinSafety_PreStepPt = minSafety;
131 fMinStep = minStep;
132
133 if( fMinStep == kInfinity )
134 {
135 fTrueMinStep = proposedStepLength; // Use this below for endpoint !!
136 }
137 else
138 {
139 fTrueMinStep = minStep;
140 }
141
142#ifdef G4DEBUG_NAVIGATION
143 if( fVerbose > 1 )
144 {
145 G4ThreeVector endPosition = initialPosition+fTrueMinStep*initialDirection;
146
147 G4int oldPrec = G4cout.precision(8);
148 G4cout << "G4MultiNavigator::ComputeStep : "
149 << " initialPosition = " << initialPosition
150 << " and endPosition = " << endPosition << G4endl;
151 G4cout.precision( oldPrec );
152 }
153#endif
154
155 pNewSafety = minSafety;
156
157 this->WhichLimited();
158
159#ifdef G4DEBUG_NAVIGATION
160 if( fVerbose > 2 )
161 {
162 G4cout << " G4MultiNavigator::ComputeStep : exits returning "
163 << minStep << G4endl;
164 }
165#endif
166
167 return minStep; // must return kInfinity if do not limit step
168}
int G4int
Definition G4Types.hh:85

◆ CreateTouchableHistoryHandle()

G4TouchableHandle G4MultiNavigator::CreateTouchableHistoryHandle ( ) const
overridevirtual

Returns a reference counted handle to a touchable history.

Reimplemented from G4Navigator.

Definition at line 439 of file G4MultiNavigator.cc.

440{
441 G4Exception( "G4MultiNavigator::CreateTouchableHistoryHandle()",
442 "GeomNav0001", FatalException,
443 "Getting a touchable from G4MultiNavigator is not defined.");
444
445 G4TouchableHistory* touchHist;
446 touchHist= fpNavigator[0] -> CreateTouchableHistory();
447
448 G4VPhysicalVolume* locatedVolume= fLocatedVolume[0];
449 if( locatedVolume == nullptr )
450 {
451 // Workaround to ensure that the touchable is fixed !! // TODO: fix
452 //
453 touchHist->UpdateYourself( locatedVolume, touchHist->GetHistory() );
454 }
455
456 return {touchHist};
457}
G4TouchableHistory * CreateTouchableHistory() const
void UpdateYourself(G4VPhysicalVolume *pPhysVol, const G4NavigationHistory *history=nullptr)
const G4NavigationHistory * GetHistory() const

◆ GetGlobalExitNormal()

G4ThreeVector G4MultiNavigator::GetGlobalExitNormal ( const G4ThreeVector & point,
G4bool * obtained )
overridevirtual

Obtains the Normal vector to a surface (in global coordinates) pointing out of previous volume and into current volume The method takes full care about how to calculate the normal, but if the surfaces are not convex it will return valid=false.

Parameters
[in]pointPoint in global coordinates system to compare to.
[in,out]obtainedFlag indicating if normal is valid.
Returns
A Exit Surface Normal vector and validity too.

Reimplemented from G4Navigator.

Definition at line 672 of file G4MultiNavigator.cc.

674{
675 G4ThreeVector normalGlobalCrd(0.0, 0.0, 0.0);
676 G4bool isObtained = false;
677 // These default values will be used if fNoLimitingStep== 0
678 G4int firstNavigatorId = -1;
679 G4bool oneObtained = false;
680
681 if( fNoLimitingStep == 1 )
682 {
683 // Only message the Navigator which limited the step!
684 normalGlobalCrd = fpNavigator[ fIdNavLimiting ]
685 ->GetGlobalExitNormal( argPoint, &isObtained );
686 *argpObtained = isObtained;
687 }
688 else
689 {
690 if( fNoLimitingStep > 1 )
691 {
692 auto pNavIter= pTransportManager->GetActiveNavigatorsIterator();
693
694 for ( auto num = 0; num < fNoActiveNavigators ; ++pNavIter, ++num )
695 {
696 G4ThreeVector oneNormal;
697 if( fLimitTruth[ num ] ) // Did this geometry limit the step ?
698 {
699 G4ThreeVector newNormal =
700 (*pNavIter)->GetGlobalExitNormal( argPoint, &oneObtained );
701 if( oneObtained )
702 {
703 // Keep first one - only if it is valid (ie not null)
704 if( !isObtained && (newNormal.mag2() != 0.0) )
705 {
706 normalGlobalCrd = newNormal;
707 isObtained = oneObtained;
708 firstNavigatorId = num;
709 }
710 else
711 {
712 // Check for clash
713 G4double dotNewPrevious = newNormal.dot( normalGlobalCrd );
714 G4double productMagSq = normalGlobalCrd.mag2()*newNormal.mag2();
715 if( productMagSq > 0.0 )
716 {
717 G4double productMag = std::sqrt( productMagSq );
718 dotNewPrevious /= productMag; // Normalise
719 if( dotNewPrevious < (1 - perThousand) )
720 {
721 *argpObtained = false;
722
723 if( fVerbose > 2 ) // dotNewPrevious <= 0.0 )
724 {
725 std::ostringstream message;
726 message << "Clash of Normal from different Navigators!"
727 << G4endl
728 << " Previous Navigator Id = "
729 << firstNavigatorId << G4endl
730 << " Current Navigator Id = "
731 << num << G4endl;
732 message << " Dot product of 2 normals = "
733 << dotNewPrevious << G4endl;
734 message << " Normal (previous) = "
735 << normalGlobalCrd << G4endl;
736 message << " Normal (current) = " << newNormal << G4endl;
737 G4Exception("G4MultiNavigator::GetGlobalExitNormal()",
738 "GeomNav0002", JustWarning, message);
739 }
740 }
741 else
742 {
743 // Close agreement - Do not change
744 }
745 }
746 }
747 }
748 }
749 } // end for over the Navigators
750
751 // Report if no Normal was obtained
752 if( !oneObtained )
753 {
754 std::ostringstream message;
755 message << "No Normal obtained despite having " << fNoLimitingStep
756 << " candidate Navigators limiting the step!" << G4endl;
757 G4Exception("G4MultiNavigator::GetGlobalExitNormal()", "GeomNav0002",
758 JustWarning, message);
759 }
760
761 } // end if ( fNoLimiting > 1 )
762 } // end else
763
764 *argpObtained = isObtained;
765 return normalGlobalCrd;
766}
@ JustWarning
bool G4bool
Definition G4Types.hh:86
double mag2() const
double dot(const Hep3Vector &) const

◆ GetLocalExitNormal()

G4ThreeVector G4MultiNavigator::GetLocalExitNormal ( G4bool * obtained)
overridevirtual

Obtains the Normal vector to a surface (in local coordinates) pointing out of previous volume and into current volume Convention: the local normal is in the coordinate system of the final volume. The method takes full care about how to calculate this normal, but if the surfaces are not convex it will return valid=false.

Parameters
[in,out]obtainedFlag indicating if normal is valid.
Returns
A Exit Surface Normal vector and validity too.

Reimplemented from G4Navigator.

Definition at line 771 of file G4MultiNavigator.cc.

772{
773 // If it is the mass navigator, then expect
774 G4ThreeVector normalGlobalCrd(0.0, 0.0, 0.0);
775 G4bool isObtained = false;
776 // These default values will be used if fNoLimitingStep== 0
777
778 if( fNoLimitingStep == 1 )
779 {
780 // Only message the Navigator which limited the step!
781 normalGlobalCrd = fpNavigator[ fIdNavLimiting ]
782 ->GetLocalExitNormal( &isObtained );
783 *argpObtained = isObtained;
784
785 static G4ThreadLocal G4int numberWarnings = 0;
786 G4int noWarningsStart = 10, noModuloWarnings = 100;
787 ++numberWarnings;
788 if( (numberWarnings < noWarningsStart )
789 || (numberWarnings%noModuloWarnings == 0) )
790 {
791 std::ostringstream message;
792 message << "Cannot obtain normal in local coordinates of two or more "
793 << "coordinate systems." << G4endl;
794 G4Exception("G4MultiNavigator::GetGlobalExitNormal()", "GeomNav0002",
795 JustWarning, message);
796 }
797 }
798 else
799 {
800 if( fNoLimitingStep > 1 )
801 {
802 std::ostringstream message;
803 message << "Cannot obtain normal in local coordinates of two or more "
804 << "coordinate systems." << G4endl;
805 G4Exception("G4MultiNavigator::GetGlobalExitNormal()", "GeomNav0002",
806 FatalException, message);
807 }
808 }
809
810 *argpObtained = isObtained;
811 return normalGlobalCrd;
812}
#define G4ThreadLocal
Definition tls.hh:77

Referenced by GetLocalExitNormalAndCheck().

◆ GetLocalExitNormalAndCheck()

G4ThreeVector G4MultiNavigator::GetLocalExitNormalAndCheck ( const G4ThreeVector & point,
G4bool * obtained )
overridevirtual

Obtains the Normal vector to a surface (in local coordinates) pointing out of previous volume and into current volume, and checks the current point against expected 'local' value. Convention: the local normal is in the coordinate system of the final volume. The method takes full care about how to calculate this normal, but if the surfaces are not convex it will return valid=false.

Parameters
[in]pointPoint in global coordinates system to compare to.
[in,out]obtainedFlag indicating if normal is valid.
Returns
A Exit Surface Normal vector and validity too.

Reimplemented from G4Navigator.

Definition at line 817 of file G4MultiNavigator.cc.

819{
820 return G4MultiNavigator::GetLocalExitNormal( obtained );
821}
G4ThreeVector GetLocalExitNormal(G4bool *obtained) override

◆ GetNavigator()

G4Navigator * G4MultiNavigator::GetNavigator ( G4int n) const
inline

Returns a pointer to a navigator, given its index.

Definition at line 286 of file G4MultiNavigator.hh.

287{
288 if( (n>fNoActiveNavigators) || (n<0) ) { n=0; }
289 return fpNavigator[n];
290}

◆ LocateGlobalPointAndSetup()

G4VPhysicalVolume * G4MultiNavigator::LocateGlobalPointAndSetup ( const G4ThreeVector & point,
const G4ThreeVector * direction = nullptr,
const G4bool pRelativeSearch = true,
const G4bool ignoreDirection = true )
overridevirtual

Locates the point in all geometries. Maintains a vector of other volumes, to be returned separately.

Note
In order to call this the geometry MUST be closed.
Parameters
[in]pointThe point in global coordinates system.
[in]directionThe normalised vector direction.
[in]pRelativeSearchFlag to specify where search starts from.
[in]ignoreDirectionFlag to specify if to use direction or not.
Returns
The volume in the first (mass) geometry.

Reimplemented from G4Navigator.

Definition at line 297 of file G4MultiNavigator.cc.

301{
302 // Locate the point in each geometry
303
304 G4ThreeVector direction(0.0, 0.0, 0.0);
305 G4bool relative = pRelativeSearch;
306 auto pNavIter = pTransportManager->GetActiveNavigatorsIterator();
307
308 if( pDirection != nullptr ) { direction = *pDirection; }
309
310#ifdef G4DEBUG_NAVIGATION
311 if( fVerbose > 2 )
312 {
313 G4cout << " Entered G4MultiNavigator::LocateGlobalPointAndSetup() "
314 << G4endl;
315 G4cout << " Locating at position: " << position
316 << ", with direction: " << direction << G4endl
317 << " Relative: " << relative
318 << ", ignore direction: " << ignoreDirection << G4endl;
319 G4cout << " Number of active navigators: " << fNoActiveNavigators
320 << G4endl;
321 }
322#endif
323
324 for ( auto num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
325 {
326 if( fWasLimitedByGeometry && fLimitTruth[num] )
327 {
328 (*pNavIter)->SetGeometricallyLimitedStep();
329 }
330
331 G4VPhysicalVolume *pLocated
332 = (*pNavIter)->LocateGlobalPointAndSetup( position, &direction,
333 relative, ignoreDirection );
334 // Set the state related to the location
335 //
336 fLocatedVolume[num] = pLocated;
337
338 // Clear state related to the step
339 //
340 fLimitedStep[num] = kDoNot;
341 fCurrentStepSize[num] = 0.0;
342 fLimitTruth[ num ] = false; // Always clear on locating (see Navigator)
343
344#ifdef G4DEBUG_NAVIGATION
345 if( fVerbose > 2 )
346 {
347 G4cout << " Located in world: " << num << ", at: " << position << G4endl
348 << " Used geomLimStp: " << fLimitTruth[num]
349 << ", found in volume: " << pLocated << G4endl;
350 G4cout << " Name = '" ;
351 if( pLocated )
352 {
353 G4cout << pLocated->GetName() << "'";
354 G4cout << " - CopyNo= " << pLocated->GetCopyNo();
355 }
356 else
357 {
358 G4cout << "Null' Id: Not-Set ";
359 }
360 G4cout << G4endl;
361 }
362#endif
363 }
364
365 fWasLimitedByGeometry = false; // Clear on locating
366 G4VPhysicalVolume* volMassLocated = fLocatedVolume[0];
367
368 return volMassLocated;
369}
@ kDoNot
G4bool fWasLimitedByGeometry
virtual G4int GetCopyNo() const =0
const G4String & GetName() const

Referenced by PrepareNewTrack(), and ResetHierarchyAndLocate().

◆ LocateGlobalPointWithinVolume()

void G4MultiNavigator::LocateGlobalPointWithinVolume ( const G4ThreeVector & position)
overridevirtual

Relocates in all geometries for point that has not changed volume, i.e. is within safety in all geometries or its distance is less that along the direction of a computed step.

Parameters
[in]positionThe position point in global coordinates system.

Reimplemented from G4Navigator.

Definition at line 374 of file G4MultiNavigator.cc.

375{
376 // Relocate the point in each geometry
377
378 auto pNavIter = pTransportManager->GetActiveNavigatorsIterator();
379
380#ifdef G4DEBUG_NAVIGATION
381 if( fVerbose > 2 )
382 {
383 G4cout << " Entered G4MultiNavigator::ReLocate() " << G4endl
384 << " Re-locating at position: " << position << G4endl;
385 }
386#endif
387
388 for ( auto num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
389 {
390 // ... none limited the step
391
392 (*pNavIter)->LocateGlobalPointWithinVolume( position );
393
394 // Clear state related to the step
395 //
396 fLimitedStep[num] = kDoNot;
397 fCurrentStepSize[num] = 0.0;
398
399 fLimitTruth[ num ] = false; // Always clear on locating (see Navigator)
400 }
401 fWasLimitedByGeometry = false; // Clear on locating
402 fLastLocatedPosition = position;
403}

◆ ObtainFinalStep()

G4double G4MultiNavigator::ObtainFinalStep ( G4int navigatorId,
G4double & pNewSafety,
G4double & minStepLast,
ELimited & limitedStep )

Gets values for a single geometry.

Parameters
[in]navigatorIdThe navigator identifier.
[in,out]pnewSafetyNew safety for this geometry.
[in,out]minStepLastThe last minimum step returned.
[in,out]limitedStepThe step characterisation returned.
Returns
The step size for the geometry associated to 'navigatorId'.

Definition at line 173 of file G4MultiNavigator.cc.

177{
178 if( navigatorId > fNoActiveNavigators )
179 {
180 std::ostringstream message;
181 message << "Bad Navigator Id!" << G4endl
182 << " Navigator Id = " << navigatorId
183 << " No Active = " << fNoActiveNavigators << ".";
184 G4Exception("G4MultiNavigator::ObtainFinalStep()", "GeomNav0002",
185 FatalException, message);
186 }
187
188 // Prepare the information to return
189 //
190 pNewSafety = fNewSafety[ navigatorId ];
191 limitedStep = fLimitedStep[ navigatorId ];
192 minStep= fMinStep;
193
194#ifdef G4DEBUG_NAVIGATION
195 if( fVerbose > 1 )
196 {
197 G4cout << " G4MultiNavigator::ComputeStep returns "
198 << fCurrentStepSize[ navigatorId ]
199 << " for Navigator " << navigatorId
200 << " Limited step = " << limitedStep
201 << " Safety(mm) = " << pNewSafety / mm << G4endl;
202 }
203#endif
204
205 return fCurrentStepSize[ navigatorId ];
206}

◆ PrepareNavigators()

void G4MultiNavigator::PrepareNavigators ( )

Finds which geometries are registered for this particles, and keeps info.

Definition at line 231 of file G4MultiNavigator.cc.

232{
233 // Key purposes:
234 // - Check and cache set of active navigators
235 // - Reset state for new track
236
237#ifdef G4DEBUG_NAVIGATION
238 if( fVerbose > 1 )
239 {
240 G4cout << " Entered G4MultiNavigator::PrepareNavigators() " << G4endl;
241 }
242#endif
243
244 // Message the transportation-manager to find active navigators
245
246 std::vector<G4Navigator*>::const_iterator pNavigatorIter;
247 fNoActiveNavigators = (G4int)pTransportManager-> GetNoActiveNavigators();
248
249 if( fNoActiveNavigators > fMaxNav )
250 {
251 std::ostringstream message;
252 message << "Too many active Navigators / worlds !" << G4endl
253 << " Active Navigators (worlds): "
254 << fNoActiveNavigators << G4endl
255 << " which is more than the number allowed: "
256 << fMaxNav << " !";
257 G4Exception("G4MultiNavigator::PrepareNavigators()", "GeomNav0002",
258 FatalException, message);
259 }
260
261 pNavigatorIter= pTransportManager->GetActiveNavigatorsIterator();
262 for( auto num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
263 {
264 fpNavigator[num] = *pNavigatorIter;
265 fLimitTruth[num] = false;
266 fLimitedStep[num] = kDoNot;
267 fCurrentStepSize[num] = 0.0;
268 fLocatedVolume[num] = nullptr;
269 }
270 fWasLimitedByGeometry = false;
271
272 // Check the world volume of the mass navigator
273 // in case a call to SetWorldVolume() changed it
274
275 G4VPhysicalVolume* massWorld = GetWorldVolume();
276
277 if( (massWorld != fLastMassWorld) && (massWorld!=nullptr) )
278 {
279 // Pass along change to Mass Navigator
280 fpNavigator[0] -> SetWorldVolume( massWorld );
281
282#ifdef G4DEBUG_NAVIGATION
283 if( fVerbose > 0 )
284 {
285 G4cout << " G4MultiNavigator::PrepareNavigators() changed world volume "
286 << " for mass geometry to " << massWorld->GetName() << G4endl;
287 }
288#endif
289
290 fLastMassWorld = massWorld;
291 }
292}

Referenced by PrepareNewTrack().

◆ PrepareNewTrack()

void G4MultiNavigator::PrepareNewTrack ( const G4ThreeVector & position,
const G4ThreeVector direction )

Prepares Navigators and locates.

Parameters
[in]positionThe position point in global coordinates system.
[in]directionThe normalised vector direction.

Definition at line 210 of file G4MultiNavigator.cc.

212{
213#ifdef G4DEBUG_NAVIGATION
214 if( fVerbose > 1 )
215 {
216 G4cout << " Entered G4MultiNavigator::PrepareNewTrack() " << G4endl;
217 }
218#endif
219
221
222 LocateGlobalPointAndSetup( position, &direction, false, false );
223 //
224 // The first location for each Navigator must be non-relative
225 // or else call ResetStackAndState() for each Navigator
226 // Use direction to get correct side of boundary (ignore dir= false)
227}
G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=nullptr, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true) override

◆ PrintLimited()

void G4MultiNavigator::PrintLimited ( )
protected

Auxiliary, debugging printing.

Definition at line 520 of file G4MultiNavigator.cc.

521{
522 // Report results -- for checking
523
524 static const G4String StrDoNot("DoNot"), StrUnique("Unique"),
525 StrUndefined("Undefined"),
526 StrSharedTransport("SharedTransport"),
527 StrSharedOther("SharedOther");
528 G4cout << "### G4MultiNavigator::PrintLimited() reports: " << G4endl;
529 G4cout << " Minimum step (true): " << fTrueMinStep
530 << ", reported min: " << fMinStep << G4endl;
531
532#ifdef G4DEBUG_NAVIGATION
533 if(fVerbose>=2)
534 {
535 G4cout << std::setw(5) << " NavId" << " "
536 << std::setw(12) << " step-size " << " "
537 << std::setw(12) << " raw-size " << " "
538 << std::setw(12) << " pre-safety " << " "
539 << std::setw(15) << " Limited / flag" << " "
540 << std::setw(15) << " World " << " "
541 << G4endl;
542 }
543#endif
544
545 for ( auto num = 0; num < fNoActiveNavigators; ++num )
546 {
547 G4double rawStep = fCurrentStepSize[num];
548 G4double stepLen = fCurrentStepSize[num];
549 if( stepLen > fTrueMinStep )
550 {
551 stepLen = fTrueMinStep; // did not limit (went as far as asked)
552 }
553 G4long oldPrec = G4cout.precision(9);
554
555 G4cout << std::setw(5) << num << " "
556 << std::setw(12) << stepLen << " "
557 << std::setw(12) << rawStep << " "
558 << std::setw(12) << fNewSafety[num] << " "
559 << std::setw(5) << (fLimitTruth[num] ? "YES" : " NO") << " ";
560 G4String limitedStr;
561 switch ( fLimitedStep[num] )
562 {
563 case kDoNot : limitedStr = StrDoNot; break;
564 case kUnique : limitedStr = StrUnique; break;
565 case kSharedTransport: limitedStr = StrSharedTransport; break;
566 case kSharedOther : limitedStr = StrSharedOther; break;
567 default : limitedStr = StrUndefined; break;
568 }
569 G4cout << " " << std::setw(15) << limitedStr << " ";
570 G4cout.precision(oldPrec);
571
572 G4Navigator *pNav = fpNavigator[ num ];
573 G4String WorldName( "Not-Set" );
574 if (pNav != nullptr)
575 {
576 G4VPhysicalVolume *pWorld = pNav->GetWorldVolume();
577 if( pWorld != nullptr )
578 {
579 WorldName = pWorld->GetName();
580 }
581 }
582 G4cout << " " << WorldName ;
583 G4cout << G4endl;
584 }
585}
@ kUnique
@ kSharedOther
@ kSharedTransport
long G4long
Definition G4Types.hh:87

◆ ResetHierarchyAndLocate()

G4VPhysicalVolume * G4MultiNavigator::ResetHierarchyAndLocate ( const G4ThreeVector & point,
const G4ThreeVector & direction,
const G4TouchableHistory & h )
overridevirtual

Resets the geometrical hierarchy for all geometries. Use the touchable history for the first (mass) geometry.

Note
In order to call this the geometries MUST be closed.
Parameters
[in]pointThe point in global coordinates system.
[in]directionThe normalised vector direction.
[in]hThe touchable history to be used for initialisation.
Returns
The pointer to the volume in the first (mass) geometry.

Reimplemented from G4Navigator.

Definition at line 634 of file G4MultiNavigator.cc.

637{
638 // Reset geometry for all -- and use the touchable for the mass history
639
640 G4VPhysicalVolume* massVolume = nullptr;
641 G4Navigator* pMassNavigator = fpNavigator[0];
642
643 if( pMassNavigator != nullptr )
644 {
645 massVolume= pMassNavigator->ResetHierarchyAndLocate( point, direction,
646 MassHistory);
647 }
648 else
649 {
650 G4Exception("G4MultiNavigator::ResetHierarchyAndLocate()",
651 "GeomNav0002", FatalException,
652 "Cannot reset hierarchy before navigators are initialised.");
653 }
654
655 auto pNavIter= pTransportManager->GetActiveNavigatorsIterator();
656
657 for ( auto num = 0; num < fNoActiveNavigators ; ++pNavIter,++num )
658 {
659 G4bool relativeSearch, ignoreDirection;
660
661 (*pNavIter)-> LocateGlobalPointAndSetup( point,
662 &direction,
663 relativeSearch=false,
664 ignoreDirection=false);
665 }
666 return massVolume;
667}
virtual G4VPhysicalVolume * ResetHierarchyAndLocate(const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h)

◆ ResetState()

void G4MultiNavigator::ResetState ( )
overrideprotectedvirtual

Utility method to reset the navigator state machine.

Reimplemented from G4Navigator.

Definition at line 590 of file G4MultiNavigator.cc.

591{
592 fWasLimitedByGeometry = false;
593
594 G4Exception("G4MultiNavigator::ResetState()", "GeomNav0001",
596 "Cannot reset state for navigators of G4MultiNavigator.");
597/*
598 std::vector<G4Navigator*>::iterator pNavigatorIter;
599 pNavigatorIter = pTransportManager->GetActiveNavigatorsIterator();
600 for( auto num = 0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
601 {
602 // (*pNavigatorIter)->ResetState(); // KEEP THIS comment !!!
603 }
604*/
605}

◆ SetupHierarchy()

void G4MultiNavigator::SetupHierarchy ( )
overrideprotectedvirtual

Renavigates & resets hierarchy described by the current history, i.e. resets volumes and recomputes transforms and/or solids of replicated/parameterised volumes.

Reimplemented from G4Navigator.

Definition at line 609 of file G4MultiNavigator.cc.

610{
611 G4Exception( "G4MultiNavigator::SetupHierarchy()",
612 "GeomNav0001", FatalException,
613 "Cannot setup hierarchy for navigators of G4MultiNavigator.");
614}

◆ WhichLimited()

void G4MultiNavigator::WhichLimited ( )
protected

Flags which processes limited the step.

Definition at line 461 of file G4MultiNavigator.cc.

462{
463 // Flag which processes limited the step
464
465 G4int last=-1;
466 const G4int IdTransport= 0; // Id of Mass Navigator !!
467 G4int noLimited=0;
468 ELimited shared= kSharedOther;
469
470#ifdef G4DEBUG_NAVIGATION
471 if( fVerbose > 2 )
472 {
473 G4cout << " Entered G4MultiNavigator::WhichLimited() " << G4endl;
474 }
475#endif
476
477 // Assume that [IdTransport] is Mass / Transport
478 //
479 G4bool transportLimited = (fCurrentStepSize[IdTransport] == fMinStep)
480 && ( fMinStep!= kInfinity);
481 if( transportLimited )
482 {
483 shared = kSharedTransport;
484 }
485
486 for ( auto num = 0; num < fNoActiveNavigators; ++num )
487 {
488 G4bool limitedStep;
489
490 G4double step = fCurrentStepSize[num];
491
492 limitedStep = ( step == fMinStep ) && ( step != kInfinity);
493
494 fLimitTruth[ num ] = limitedStep;
495 if( limitedStep )
496 {
497 ++noLimited;
498 fLimitedStep[num] = shared;
499 last= num;
500 }
501 else
502 {
503 fLimitedStep[num] = kDoNot;
504 }
505 }
506 if( (last > -1) && (noLimited == 1 ) )
507 {
508 fLimitedStep[ last ] = kUnique;
509 fIdNavLimiting = last;
510 }
511
512 fNoLimitingStep = noLimited;
513
514 return;
515}

Referenced by ComputeStep().

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const G4Navigator & n )
friend

Definition at line 2013 of file G4Navigator.cc.

2014{
2015 // Old version did only the following:
2016 // os << "Current History: " << G4endl << n.fHistory;
2017 // Old behaviour is recovered for fVerbose = 0
2018
2019 // Adapted from G4Navigator::PrintState() const
2020
2021 G4long oldcoutPrec = os.precision(4);
2022 if( n.fVerbose >= 4 )
2023 {
2024 os << "The current state of G4Navigator is: " << G4endl;
2025 os << " ValidExitNormal= " << n.fValidExitNormal << G4endl
2026 << " ExitNormal = " << n.fExitNormal << G4endl
2027 << " Exiting = " << n.fExiting << G4endl
2028 << " Entering = " << n.fEntering << G4endl
2029 << " BlockedPhysicalVolume= " ;
2030 if (n.fBlockedPhysicalVolume==nullptr)
2031 {
2032 os << "None";
2033 }
2034 else
2035 {
2036 os << n.fBlockedPhysicalVolume->GetName();
2037 }
2038 os << G4endl
2039 << " BlockedReplicaNo = " << n.fBlockedReplicaNo << G4endl
2040 << " LastStepWasZero = " << n.fLastStepWasZero << G4endl
2041 << G4endl;
2042 }
2043 if( ( 1 < n.fVerbose) && (n.fVerbose < 4) )
2044 {
2045 os << G4endl; // Make sure to line up
2046 os << std::setw(30) << " ExitNormal " << " "
2047 << std::setw( 5) << " Valid " << " "
2048 << std::setw( 9) << " Exiting " << " "
2049 << std::setw( 9) << " Entering" << " "
2050 << std::setw(15) << " Blocked:Volume " << " "
2051 << std::setw( 9) << " ReplicaNo" << " "
2052 << std::setw( 8) << " LastStepZero " << " "
2053 << G4endl;
2054 os << "( " << std::setw(7) << n.fExitNormal.x()
2055 << ", " << std::setw(7) << n.fExitNormal.y()
2056 << ", " << std::setw(7) << n.fExitNormal.z() << " ) "
2057 << std::setw( 5) << n.fValidExitNormal << " "
2058 << std::setw( 9) << n.fExiting << " "
2059 << std::setw( 9) << n.fEntering << " ";
2060 if ( n.fBlockedPhysicalVolume==nullptr )
2061 { os << std::setw(15) << "None"; }
2062 else
2063 { os << std::setw(15)<< n.fBlockedPhysicalVolume->GetName(); }
2064 os << std::setw( 9) << n.fBlockedReplicaNo << " "
2065 << std::setw( 8) << n.fLastStepWasZero << " "
2066 << G4endl;
2067 }
2068 if( n.fVerbose > 2 )
2069 {
2070 os.precision(8);
2071 os << " Current Localpoint = " << n.fLastLocatedPointLocal << G4endl;
2072 os << " PreviousSftOrigin = " << n.fPreviousSftOrigin << G4endl;
2073 os << " PreviousSafety = " << n.fPreviousSafety << G4endl;
2074 }
2075 if( n.fVerbose > 3 || n.fVerbose == 0 )
2076 {
2077 os << "Current History: " << G4endl << n.fHistory;
2078 }
2079
2080 os.precision(oldcoutPrec);
2081 return os;
2082}

The documentation for this class was generated from the following files: