Geant4-11
Public Member Functions | Private Attributes
G4SafetyHelper Class Reference

#include <G4SafetyHelper.hh>

Public Member Functions

G4double CheckNextStep (const G4ThreeVector &position, const G4ThreeVector &direction, const G4double currentMaxStep, G4double &newSafety)
 
G4double ComputeSafety (const G4ThreeVector &pGlobalPoint, G4double maxRadius=DBL_MAX)
 
void EnableParallelNavigation (G4bool parallel)
 
 G4SafetyHelper ()
 
G4VPhysicalVolumeGetWorldVolume ()
 
void InitialiseHelper ()
 
void InitialiseNavigator ()
 
void Locate (const G4ThreeVector &pGlobalPoint, const G4ThreeVector &direction)
 
void ReLocateWithinVolume (const G4ThreeVector &pGlobalPoint)
 
void SetCurrentSafety (G4double val, const G4ThreeVector &pos)
 
G4int SetVerboseLevel (G4int lev)
 
 ~G4SafetyHelper ()
 

Private Attributes

G4bool fFirstCall = true
 
G4double fLastSafety = 0.0
 
G4ThreeVector fLastSafetyPosition
 
G4int fMassNavigatorId = -1
 
G4NavigatorfpMassNavigator = nullptr
 
G4PathFinderfpPathFinder = nullptr
 
G4bool fUseParallelGeometries = false
 
G4int fVerbose = 0
 

Detailed Description

Definition at line 46 of file G4SafetyHelper.hh.

Constructor & Destructor Documentation

◆ G4SafetyHelper()

G4SafetyHelper::G4SafetyHelper ( )

Definition at line 38 of file G4SafetyHelper.cc.

39 : fLastSafetyPosition(0.0,0.0,0.0)
40{
41}
G4ThreeVector fLastSafetyPosition

◆ ~G4SafetyHelper()

G4SafetyHelper::~G4SafetyHelper ( )

Definition at line 73 of file G4SafetyHelper.cc.

74{
75}

Member Function Documentation

◆ CheckNextStep()

G4double G4SafetyHelper::CheckNextStep ( const G4ThreeVector position,
const G4ThreeVector direction,
const G4double  currentMaxStep,
G4double newSafety 
)

Definition at line 78 of file G4SafetyHelper.cc.

82{
83 // Distance in the Mass geometry
84 //
86 direction,
87 currentMaxStep,
88 newSafety);
90 fLastSafety = newSafety;
91
92 // TO-DO: Can replace this with a call to PathFinder
93 // giving id of Mass Geometry --> this avoid doing the work twice
94
95 return linstep;
96}
double G4double
Definition: G4Types.hh:83
G4double CheckNextStep(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
G4Navigator * fpMassNavigator
G4double fLastSafety
#define position
Definition: xmlparse.cc:622

References G4Navigator::CheckNextStep(), fLastSafety, fLastSafetyPosition, fpMassNavigator, and position.

Referenced by G4VMscModel::ComputeGeomLimit().

◆ ComputeSafety()

G4double G4SafetyHelper::ComputeSafety ( const G4ThreeVector pGlobalPoint,
G4double  maxRadius = DBL_MAX 
)

Definition at line 98 of file G4SafetyHelper.cc.

100{
101 G4double newSafety;
102
103 // Only recompute (calling Navigator/PathFinder) if 'position'
104 // is *not* the safety location and has moved 'significantly'
105 //
106 G4double moveLengthSq = (position-fLastSafetyPosition).mag2();
107 if( (moveLengthSq > 0.0 ) )
108 {
110 {
111 // Safety for mass geometry
112 newSafety = fpMassNavigator->ComputeSafety(position, maxLength, true);
113
114 // Only store a 'true' safety - one that was not restricted by maxLength
115 if( newSafety < maxLength )
116 {
117 fLastSafety= newSafety;
119 }
120 }
121 else
122 {
123 // Safety for all geometries
124 newSafety = fpPathFinder->ComputeSafety(position);
125
126 fLastSafety= newSafety;
128 }
129
130 }
131 else
132 {
133 // return last value if position is not (significantly) changed
134 //
135 // G4double moveLength = 0;
136 // if( moveLengthSq > 0.0 ) { moveLength= std::sqrt(moveLengthSq); }
137 newSafety = fLastSafety; // -moveLength;
138 }
139
140 return newSafety;
141}
virtual G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=true)
G4double ComputeSafety(const G4ThreeVector &globalPoint)
G4PathFinder * fpPathFinder
G4bool fUseParallelGeometries

References G4PathFinder::ComputeSafety(), G4Navigator::ComputeSafety(), fLastSafety, fLastSafetyPosition, fpMassNavigator, fpPathFinder, fUseParallelGeometries, and position.

Referenced by G4VMultipleScattering::AlongStepDoIt(), and G4VMscModel::ComputeSafety().

◆ EnableParallelNavigation()

void G4SafetyHelper::EnableParallelNavigation ( G4bool  parallel)
inline

Definition at line 129 of file G4SafetyHelper.hh.

130{
131 fUseParallelGeometries = parallel;
132}

References fUseParallelGeometries.

Referenced by G4PathFinder::EnableParallelNavigation().

◆ GetWorldVolume()

G4VPhysicalVolume * G4SafetyHelper::GetWorldVolume ( )
inline

Definition at line 135 of file G4SafetyHelper.hh.

136{
138}
G4VPhysicalVolume * GetWorldVolume() const

References fpMassNavigator, and G4Navigator::GetWorldVolume().

◆ InitialiseHelper()

void G4SafetyHelper::InitialiseHelper ( )

◆ InitialiseNavigator()

void G4SafetyHelper::InitialiseNavigator ( )

Definition at line 43 of file G4SafetyHelper.cc.

44{
46
47 G4TransportationManager* pTransportMgr=
49
50 fpMassNavigator = pTransportMgr->GetNavigatorForTracking();
51
52 // Check
53 //
55 if( worldPV == nullptr )
56 {
57 G4Exception("G4SafetyHelper::InitialiseNavigator",
58 "GeomNav0003", FatalException,
59 "Found that existing tracking Navigator has NULL world");
60 }
61
63}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
static G4PathFinder * GetInstance()
Definition: G4PathFinder.cc:52
static G4TransportationManager * GetTransportationManager()
G4Navigator * GetNavigatorForTracking() const
G4int ActivateNavigator(G4Navigator *aNavigator)

References G4TransportationManager::ActivateNavigator(), FatalException, fMassNavigatorId, fpMassNavigator, fpPathFinder, G4Exception(), G4PathFinder::GetInstance(), G4TransportationManager::GetNavigatorForTracking(), G4TransportationManager::GetTransportationManager(), and G4Navigator::GetWorldVolume().

Referenced by InitialiseHelper().

◆ Locate()

void G4SafetyHelper::Locate ( const G4ThreeVector pGlobalPoint,
const G4ThreeVector direction 
)

Definition at line 177 of file G4SafetyHelper.cc.

179{
181 {
182 fpMassNavigator->LocateGlobalPointAndSetup(newPosition, &newDirection,
183 true, false);
184 }
185 else
186 {
187 fpPathFinder->Locate( newPosition, newDirection );
188 }
189}
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=nullptr, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
Definition: G4Navigator.cc:132
void Locate(const G4ThreeVector &position, const G4ThreeVector &direction, G4bool relativeSearch=true)

References fpMassNavigator, fpPathFinder, fUseParallelGeometries, G4PathFinder::Locate(), and G4Navigator::LocateGlobalPointAndSetup().

◆ ReLocateWithinVolume()

void G4SafetyHelper::ReLocateWithinVolume ( const G4ThreeVector pGlobalPoint)

Definition at line 143 of file G4SafetyHelper.cc.

144{
145#ifdef G4VERBOSE
146 if( fVerbose > 0 )
147 {
148 // There is an opportunity - and need - to check whether
149 // the proposed move is safe
150 G4ThreeVector moveVec = newPosition - fLastSafetyPosition;
151 if( moveVec.mag2() > sqr(fLastSafety) )
152 {
153 // A problem exists - we are proposing to move outside 'Safety Sphere'
155 ed << "Unsafe Move> Asked to relocate beyond 'Safety sphere'. Details: "
156 << G4endl;
157 ed << " Safety Sphere: Radius = " << fLastSafety;
158 ed << " Center = " << fLastSafetyPosition << G4endl;
159 ed << " New Location : Move = " << moveVec.mag();
160 ed << " Position = " << newPosition << G4endl;
161 G4Exception("G4SafetyHelper::ReLocateWithinVolume",
162 "GeomNav1001", JustWarning, ed);
163 }
164 }
165#endif
166
168 {
170 }
171 else
172 {
173 fpPathFinder->ReLocate( newPosition );
174 }
175}
@ JustWarning
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
#define G4endl
Definition: G4ios.hh:57
double mag2() const
double mag() const
virtual void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
Definition: G4Navigator.cc:614
void ReLocate(const G4ThreeVector &position)
T sqr(const T &x)
Definition: templates.hh:128

References fLastSafety, fLastSafetyPosition, fpMassNavigator, fpPathFinder, fUseParallelGeometries, fVerbose, G4endl, G4Exception(), JustWarning, G4Navigator::LocateGlobalPointWithinVolume(), CLHEP::Hep3Vector::mag(), CLHEP::Hep3Vector::mag2(), G4PathFinder::ReLocate(), and sqr().

Referenced by G4VMultipleScattering::AlongStepDoIt(), G4NeutrinoElectronProcess::PostStepDoIt(), G4ElNeutrinoNucleusProcess::PostStepDoIt(), and G4MuNeutrinoNucleusProcess::PostStepDoIt().

◆ SetCurrentSafety()

void G4SafetyHelper::SetCurrentSafety ( G4double  val,
const G4ThreeVector pos 
)
inline

◆ SetVerboseLevel()

G4int G4SafetyHelper::SetVerboseLevel ( G4int  lev)
inline

Definition at line 121 of file G4SafetyHelper.hh.

122{
123 G4int oldlv = fVerbose;
124 fVerbose = lev;
125 return oldlv;
126}
int G4int
Definition: G4Types.hh:85

References fVerbose.

Field Documentation

◆ fFirstCall

G4bool G4SafetyHelper::fFirstCall = true
private

Definition at line 100 of file G4SafetyHelper.hh.

Referenced by InitialiseHelper().

◆ fLastSafety

G4double G4SafetyHelper::fLastSafety = 0.0
private

◆ fLastSafetyPosition

G4ThreeVector G4SafetyHelper::fLastSafetyPosition
private

◆ fMassNavigatorId

G4int G4SafetyHelper::fMassNavigatorId = -1
private

Definition at line 95 of file G4SafetyHelper.hh.

Referenced by InitialiseNavigator().

◆ fpMassNavigator

G4Navigator* G4SafetyHelper::fpMassNavigator = nullptr
private

◆ fpPathFinder

G4PathFinder* G4SafetyHelper::fpPathFinder = nullptr
private

Definition at line 93 of file G4SafetyHelper.hh.

Referenced by ComputeSafety(), InitialiseNavigator(), Locate(), and ReLocateWithinVolume().

◆ fUseParallelGeometries

G4bool G4SafetyHelper::fUseParallelGeometries = false
private

◆ fVerbose

G4int G4SafetyHelper::fVerbose = 0
private

Definition at line 102 of file G4SafetyHelper.hh.

Referenced by ReLocateWithinVolume(), and SetVerboseLevel().


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