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

#include <G4MultiNavigator.hh>

+ Inheritance diagram for G4MultiNavigator:

Public Member Functions

 G4MultiNavigator ()
 
 ~G4MultiNavigator ()
 
G4double ComputeStep (const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
 
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)
 
G4VPhysicalVolumeLocateGlobalPointAndSetup (const G4ThreeVector &point, const G4ThreeVector *direction=nullptr, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
 
void LocateGlobalPointWithinVolume (const G4ThreeVector &position)
 
G4double ComputeSafety (const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=false)
 
G4TouchableHistoryHandle CreateTouchableHistoryHandle () const
 
virtual G4ThreeVector GetLocalExitNormal (G4bool *obtained)
 
virtual G4ThreeVector GetLocalExitNormalAndCheck (const G4ThreeVector &E_Pt, G4bool *obtained)
 
virtual G4ThreeVector GetGlobalExitNormal (const G4ThreeVector &E_Pt, G4bool *obtained)
 
G4NavigatorGetNavigator (G4int n) const
 
- Public Member Functions inherited from G4Navigator
 G4Navigator ()
 
 G4Navigator (const G4Navigator &)=delete
 
G4Navigatoroperator= (const G4Navigator &)=delete
 
virtual ~G4Navigator ()
 
virtual G4double ComputeStep (const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
 
G4double CheckNextStep (const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
 
virtual G4VPhysicalVolumeResetHierarchyAndLocate (const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h)
 
virtual G4VPhysicalVolumeLocateGlobalPointAndSetup (const G4ThreeVector &point, const G4ThreeVector *direction=nullptr, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
 
virtual void LocateGlobalPointWithinVolume (const G4ThreeVector &position)
 
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 ()
 
virtual G4double ComputeSafety (const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=true)
 
G4VPhysicalVolumeGetWorldVolume () const
 
void SetWorldVolume (G4VPhysicalVolume *pWorld)
 
G4GRSVolumeCreateGRSVolume () const
 
G4GRSSolidCreateGRSSolid () const
 
G4TouchableHistoryCreateTouchableHistory () const
 
G4TouchableHistoryCreateTouchableHistory (const G4NavigationHistory *) const
 
virtual G4TouchableHistoryHandle CreateTouchableHistoryHandle () const
 
virtual G4ThreeVector GetLocalExitNormal (G4bool *valid)
 
virtual G4ThreeVector GetLocalExitNormalAndCheck (const G4ThreeVector &point, G4bool *valid)
 
virtual G4ThreeVector GetGlobalExitNormal (const G4ThreeVector &point, G4bool *valid)
 
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)
 
G4NavigatorClone () const
 
G4ThreeVector GetLastStepEndPoint () const
 
void InformLastStep (G4double lastStep, G4bool entersDaughtVol, G4bool exitsMotherVol)
 
void SetVoxelNavigation (G4VoxelNavigation *voxelNav)
 

Protected Member Functions

void ResetState ()
 
void SetupHierarchy ()
 
void WhichLimited ()
 
void PrintLimited ()
 
void CheckMassWorld ()
 
- Protected Member Functions inherited from G4Navigator
void SetSavedState ()
 
void RestoreSavedState ()
 
virtual void ResetState ()
 
G4ThreeVector ComputeLocalPoint (const G4ThreeVector &rGlobPoint) 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
 
virtual void SetupHierarchy ()
 
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

Definition at line 54 of file G4MultiNavigator.hh.

Constructor & Destructor Documentation

◆ G4MultiNavigator()

G4MultiNavigator::G4MultiNavigator ( )

Definition at line 46 of file G4MultiNavigator.cc.

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

◆ ~G4MultiNavigator()

G4MultiNavigator::~G4MultiNavigator ( )

Definition at line 77 of file G4MultiNavigator.cc.

78{
79}

Member Function Documentation

◆ CheckMassWorld()

void G4MultiNavigator::CheckMassWorld ( )
protected

Definition at line 628 of file G4MultiNavigator.cc.

629{
630 G4VPhysicalVolume* navTrackWorld =
631 pTransportManager->GetNavigatorForTracking()->GetWorldVolume();
632
633 if( navTrackWorld != fLastMassWorld )
634 {
635 G4Exception( "G4MultiNavigator::CheckMassWorld()",
636 "GeomNav0003", FatalException,
637 "Mass world pointer has been changed." );
638 }
639}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59

◆ ComputeSafety()

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

Reimplemented from G4Navigator.

Definition at line 416 of file G4MultiNavigator.cc.

419{
420 // Recompute safety for the relevant point
421
422 G4double minSafety = kInfinity, safety = kInfinity;
423
424 std::vector<G4Navigator*>::iterator pNavigatorIter;
425 pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
426
427 for( auto num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
428 {
429 safety = (*pNavigatorIter)->ComputeSafety( position, maxDistance, state);
430 if( safety < minSafety ) { minSafety = safety; }
431 }
432
433 fSafetyLocation = position;
434 fMinSafety_atSafLocation = minSafety;
435
436#ifdef G4DEBUG_NAVIGATION
437 if( fVerbose > 1 )
438 {
439 G4cout << " G4MultiNavigator::ComputeSafety - returns: "
440 << minSafety << ", at location: " << position << G4endl;
441 }
442#endif
443 return minSafety;
444}
double G4double
Definition: G4Types.hh:83
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4int fVerbose
Definition: G4Navigator.hh:395

◆ ComputeStep()

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

Reimplemented from G4Navigator.

Definition at line 81 of file G4MultiNavigator.cc.

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

◆ CreateTouchableHistoryHandle()

G4TouchableHistoryHandle G4MultiNavigator::CreateTouchableHistoryHandle ( ) const
virtual

Reimplemented from G4Navigator.

Definition at line 449 of file G4MultiNavigator.cc.

450{
451 G4Exception( "G4MultiNavigator::CreateTouchableHistoryHandle()",
452 "GeomNav0001", FatalException,
453 "Getting a touchable from G4MultiNavigator is not defined.");
454
455 G4TouchableHistory* touchHist;
456 touchHist= fpNavigator[0] -> CreateTouchableHistory();
457
458 G4VPhysicalVolume* locatedVolume= fLocatedVolume[0];
459 if( locatedVolume == nullptr )
460 {
461 // Workaround to ensure that the touchable is fixed !! // TODO: fix
462 //
463 touchHist->UpdateYourself( locatedVolume, touchHist->GetHistory() );
464 }
465
466 return G4TouchableHistoryHandle(touchHist);
467}
G4ReferenceCountedHandle< G4TouchableHistory > G4TouchableHistoryHandle
G4TouchableHistory * CreateTouchableHistory() const
void UpdateYourself(G4VPhysicalVolume *pPhysVol, const G4NavigationHistory *history=nullptr)
const G4NavigationHistory * GetHistory() const

◆ GetGlobalExitNormal()

G4ThreeVector G4MultiNavigator::GetGlobalExitNormal ( const G4ThreeVector E_Pt,
G4bool obtained 
)
virtual

Reimplemented from G4Navigator.

Definition at line 683 of file G4MultiNavigator.cc.

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

◆ GetLocalExitNormal()

G4ThreeVector G4MultiNavigator::GetLocalExitNormal ( G4bool obtained)
virtual

Reimplemented from G4Navigator.

Definition at line 783 of file G4MultiNavigator.cc.

784{
785 // If it is the mass navigator, then expect
786 G4ThreeVector normalGlobalCrd(0.0, 0.0, 0.0);
787 G4bool isObtained = false;
788 // These default values will be used if fNoLimitingStep== 0
789
790 if( fNoLimitingStep == 1 )
791 {
792 // Only message the Navigator which limited the step!
793 normalGlobalCrd = fpNavigator[ fIdNavLimiting ]
794 ->GetLocalExitNormal( &isObtained );
795 *argpObtained = isObtained;
796
797 static G4ThreadLocal G4int numberWarnings = 0;
798 G4int noWarningsStart = 10, noModuloWarnings = 100;
799 ++numberWarnings;
800 if( (numberWarnings < noWarningsStart )
801 || (numberWarnings%noModuloWarnings == 0) )
802 {
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",
807 JustWarning, message);
808 }
809 }
810 else
811 {
812 if( fNoLimitingStep > 1 )
813 {
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",
818 FatalException, message);
819 }
820 }
821
822 *argpObtained = isObtained;
823 return normalGlobalCrd;
824}
virtual G4ThreeVector GetLocalExitNormal(G4bool *valid)
#define G4ThreadLocal
Definition: tls.hh:77

Referenced by GetLocalExitNormalAndCheck().

◆ GetLocalExitNormalAndCheck()

G4ThreeVector G4MultiNavigator::GetLocalExitNormalAndCheck ( const G4ThreeVector E_Pt,
G4bool obtained 
)
virtual

Reimplemented from G4Navigator.

Definition at line 829 of file G4MultiNavigator.cc.

831{
832 return G4MultiNavigator::GetLocalExitNormal( obtained );
833}
virtual G4ThreeVector GetLocalExitNormal(G4bool *obtained)

◆ GetNavigator()

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

Definition at line 136 of file G4MultiNavigator.hh.

137 {
138 if( (n>fNoActiveNavigators) || (n<0) ) { n=0; }
139 return fpNavigator[n];
140 }

◆ LocateGlobalPointAndSetup()

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

Reimplemented from G4Navigator.

Definition at line 304 of file G4MultiNavigator.cc.

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

Referenced by PrepareNewTrack(), and ResetHierarchyAndLocate().

◆ LocateGlobalPointWithinVolume()

void G4MultiNavigator::LocateGlobalPointWithinVolume ( const G4ThreeVector position)
virtual

Reimplemented from G4Navigator.

Definition at line 382 of file G4MultiNavigator.cc.

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

◆ ObtainFinalStep()

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

Definition at line 180 of file G4MultiNavigator.cc.

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

Referenced by G4PathFinder::DoNextCurvedStep().

◆ PrepareNavigators()

void G4MultiNavigator::PrepareNavigators ( )

Definition at line 238 of file G4MultiNavigator.cc.

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

Referenced by G4PathFinder::PrepareNewTrack(), and PrepareNewTrack().

◆ PrepareNewTrack()

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

Definition at line 217 of file G4MultiNavigator.cc.

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

◆ PrintLimited()

void G4MultiNavigator::PrintLimited ( )
protected

Definition at line 530 of file G4MultiNavigator.cc.

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

◆ ResetHierarchyAndLocate()

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

Reimplemented from G4Navigator.

Definition at line 644 of file G4MultiNavigator.cc.

647{
648 // Reset geometry for all -- and use the touchable for the mass history
649
650 G4VPhysicalVolume* massVolume = nullptr;
651 G4Navigator* pMassNavigator = fpNavigator[0];
652
653 if( pMassNavigator != nullptr )
654 {
655 massVolume= pMassNavigator->ResetHierarchyAndLocate( point, direction,
656 MassHistory);
657 }
658 else
659 {
660 G4Exception("G4MultiNavigator::ResetHierarchyAndLocate()",
661 "GeomNav0002", FatalException,
662 "Cannot reset hierarchy before navigators are initialised.");
663 }
664
665 std::vector<G4Navigator*>::iterator pNavIter=
666 pTransportManager->GetActiveNavigatorsIterator();
667
668 for ( auto num = 0; num < fNoActiveNavigators ; ++pNavIter,++num )
669 {
670 G4bool relativeSearch, ignoreDirection;
671
672 (*pNavIter)-> LocateGlobalPointAndSetup( point,
673 &direction,
674 relativeSearch=false,
675 ignoreDirection=false);
676 }
677 return massVolume;
678}
virtual G4VPhysicalVolume * ResetHierarchyAndLocate(const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h)
Definition: G4Navigator.cc:102

◆ ResetState()

void G4MultiNavigator::ResetState ( )
protectedvirtual

Reimplemented from G4Navigator.

Definition at line 600 of file G4MultiNavigator.cc.

601{
602 fWasLimitedByGeometry = false;
603
604 G4Exception("G4MultiNavigator::ResetState()", "GeomNav0001",
606 "Cannot reset state for navigators of G4MultiNavigator.");
607/*
608 std::vector<G4Navigator*>::iterator pNavigatorIter;
609 pNavigatorIter = pTransportManager->GetActiveNavigatorsIterator();
610 for( auto num = 0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
611 {
612 // (*pNavigatorIter)->ResetState(); // KEEP THIS comment !!!
613 }
614*/
615}

◆ SetupHierarchy()

void G4MultiNavigator::SetupHierarchy ( )
protectedvirtual

Reimplemented from G4Navigator.

Definition at line 619 of file G4MultiNavigator.cc.

620{
621 G4Exception( "G4MultiNavigator::SetupHierarchy()",
622 "GeomNav0001", FatalException,
623 "Cannot setup hierarchy for navigators of G4MultiNavigator.");
624}

◆ WhichLimited()

void G4MultiNavigator::WhichLimited ( )
protected

Definition at line 471 of file G4MultiNavigator.cc.

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

Referenced by ComputeStep().

Friends And Related Function Documentation

◆ operator<<

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

Definition at line 2130 of file G4Navigator.cc.

2131{
2132 // Old version did only the following:
2133 // os << "Current History: " << G4endl << n.fHistory;
2134 // Old behaviour is recovered for fVerbose = 0
2135
2136 // Adapted from G4Navigator::PrintState() const
2137
2138 G4long oldcoutPrec = os.precision(4);
2139 if( n.fVerbose >= 4 )
2140 {
2141 os << "The current state of G4Navigator is: " << G4endl;
2142 os << " ValidExitNormal= " << n.fValidExitNormal << G4endl
2143 << " ExitNormal = " << n.fExitNormal << G4endl
2144 << " Exiting = " << n.fExiting << G4endl
2145 << " Entering = " << n.fEntering << G4endl
2146 << " BlockedPhysicalVolume= " ;
2147 if (n.fBlockedPhysicalVolume==0)
2148 os << "None";
2149 else
2150 os << n.fBlockedPhysicalVolume->GetName();
2151 os << G4endl
2152 << " BlockedReplicaNo = " << n.fBlockedReplicaNo << G4endl
2153 << " LastStepWasZero = " << n.fLastStepWasZero << G4endl
2154 << G4endl;
2155 }
2156 if( ( 1 < n.fVerbose) && (n.fVerbose < 4) )
2157 {
2158 os << G4endl; // Make sure to line up
2159 os << std::setw(30) << " ExitNormal " << " "
2160 << std::setw( 5) << " Valid " << " "
2161 << std::setw( 9) << " Exiting " << " "
2162 << std::setw( 9) << " Entering" << " "
2163 << std::setw(15) << " Blocked:Volume " << " "
2164 << std::setw( 9) << " ReplicaNo" << " "
2165 << std::setw( 8) << " LastStepZero " << " "
2166 << G4endl;
2167 os << "( " << std::setw(7) << n.fExitNormal.x()
2168 << ", " << std::setw(7) << n.fExitNormal.y()
2169 << ", " << std::setw(7) << n.fExitNormal.z() << " ) "
2170 << std::setw( 5) << n.fValidExitNormal << " "
2171 << std::setw( 9) << n.fExiting << " "
2172 << std::setw( 9) << n.fEntering << " ";
2173 if ( n.fBlockedPhysicalVolume==0 )
2174 { os << std::setw(15) << "None"; }
2175 else
2176 { os << std::setw(15)<< n.fBlockedPhysicalVolume->GetName(); }
2177 os << std::setw( 9) << n.fBlockedReplicaNo << " "
2178 << std::setw( 8) << n.fLastStepWasZero << " "
2179 << G4endl;
2180 }
2181 if( n.fVerbose > 2 )
2182 {
2183 os.precision(8);
2184 os << " Current Localpoint = " << n.fLastLocatedPointLocal << G4endl;
2185 os << " PreviousSftOrigin = " << n.fPreviousSftOrigin << G4endl;
2186 os << " PreviousSafety = " << n.fPreviousSafety << G4endl;
2187 }
2188 if( n.fVerbose > 3 || n.fVerbose == 0 )
2189 {
2190 os << "Current History: " << G4endl << n.fHistory;
2191 }
2192
2193 os.precision(oldcoutPrec);
2194 return os;
2195}

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