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

#include <G4SafetyHelper.hh>

Public Member Functions

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

Detailed Description

Definition at line 46 of file G4SafetyHelper.hh.

Constructor & Destructor Documentation

◆ G4SafetyHelper()

G4SafetyHelper::G4SafetyHelper ( )

Definition at line 39 of file G4SafetyHelper.cc.

40 : fLastSafetyPosition(0.0,0.0,0.0)
41{
42}

◆ ~G4SafetyHelper()

G4SafetyHelper::~G4SafetyHelper ( )
default

Member Function Documentation

◆ CheckNextStep()

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

Definition at line 77 of file G4SafetyHelper.cc.

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

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 {
109 if( !fUseParallelGeometries )
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;
118 fLastSafetyPosition = position;
119 }
120 }
121 else
122 {
123 // Safety for all geometries
124 newSafety = fpPathFinder->ComputeSafety(position);
125
126 fLastSafety= newSafety;
127 fLastSafetyPosition = position;
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)

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

◆ EnableParallelNavigation()

void G4SafetyHelper::EnableParallelNavigation ( G4bool parallel)
inline

Definition at line 128 of file G4SafetyHelper.hh.

129{
130 fUseParallelGeometries = parallel;
131}

Referenced by G4PathFinder::EnableParallelNavigation().

◆ GetWorldVolume()

G4VPhysicalVolume * G4SafetyHelper::GetWorldVolume ( )
inline

Definition at line 134 of file G4SafetyHelper.hh.

135{
136 return fpMassNavigator->GetWorldVolume();
137}
G4VPhysicalVolume * GetWorldVolume() const

◆ InitialiseHelper()

◆ InitialiseNavigator()

void G4SafetyHelper::InitialiseNavigator ( )

Definition at line 45 of file G4SafetyHelper.cc.

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

Referenced by InitialiseHelper().

◆ Locate()

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

Definition at line 179 of file G4SafetyHelper.cc.

181{
182 if( !fUseParallelGeometries )
183 {
184 fpMassNavigator->LocateGlobalPointAndSetup(newPosition, &newDirection,
185 true, false);
186 }
187 else
188 {
189 fpPathFinder->Locate( newPosition, newDirection );
190 }
191}
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=nullptr, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
void Locate(const G4ThreeVector &position, const G4ThreeVector &direction, G4bool relativeSearch=true)

◆ ReLocateWithinVolume()

void G4SafetyHelper::ReLocateWithinVolume ( const G4ThreeVector & pGlobalPoint)

Definition at line 144 of file G4SafetyHelper.cc.

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

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

◆ SetCurrentSafety()

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

Definition at line 140 of file G4SafetyHelper.hh.

141{
142 fLastSafety = val;
143 fLastSafetyPosition = pos;
144}

Referenced by G4CoupledTransportation::AlongStepGetPhysicalInteractionLength(), and G4Transportation::AlongStepGetPhysicalInteractionLength().

◆ SetVerboseLevel()

G4int G4SafetyHelper::SetVerboseLevel ( G4int lev)
inline

Definition at line 120 of file G4SafetyHelper.hh.

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

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