Geant4 11.1.1
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 38 of file G4SafetyHelper.cc.

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

◆ ~G4SafetyHelper()

G4SafetyHelper::~G4SafetyHelper ( )

Definition at line 71 of file G4SafetyHelper.cc.

72{
73}

Member Function Documentation

◆ CheckNextStep()

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

Definition at line 76 of file G4SafetyHelper.cc.

80{
81 // Distance in the Mass geometry
82 //
83 G4double linstep = fpMassNavigator->CheckNextStep( position,
84 direction,
85 currentMaxStep,
86 newSafety);
87 fLastSafetyPosition = position;
88 fLastSafety = newSafety;
89
90 // TO-DO: Can replace this with a call to PathFinder
91 // giving id of Mass Geometry --> this avoid doing the work twice
92
93 return linstep;
94}
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 96 of file G4SafetyHelper.cc.

98{
99 G4double newSafety;
100
101 // Only recompute (calling Navigator/PathFinder) if 'position'
102 // is *not* the safety location and has moved 'significantly'
103 //
104 G4double moveLengthSq = (position-fLastSafetyPosition).mag2();
105 if( (moveLengthSq > 0.0 ) )
106 {
107 if( !fUseParallelGeometries )
108 {
109 // Safety for mass geometry
110 newSafety = fpMassNavigator->ComputeSafety(position, maxLength, true);
111
112 // Only store a 'true' safety - one that was not restricted by maxLength
113 if( newSafety < maxLength )
114 {
115 fLastSafety= newSafety;
116 fLastSafetyPosition = position;
117 }
118 }
119 else
120 {
121 // Safety for all geometries
122 newSafety = fpPathFinder->ComputeSafety(position);
123
124 fLastSafety= newSafety;
125 fLastSafetyPosition = position;
126 }
127
128 }
129 else
130 {
131 // return last value if position is not (significantly) changed
132 //
133 // G4double moveLength = 0;
134 // if( moveLengthSq > 0.0 ) { moveLength= std::sqrt(moveLengthSq); }
135 newSafety = fLastSafety; // -moveLength;
136 }
137
138 return newSafety;
139}
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 43 of file G4SafetyHelper.cc.

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

Referenced by InitialiseHelper().

◆ Locate()

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

Definition at line 175 of file G4SafetyHelper.cc.

177{
178 if( !fUseParallelGeometries )
179 {
180 fpMassNavigator->LocateGlobalPointAndSetup(newPosition, &newDirection,
181 true, false);
182 }
183 else
184 {
185 fpPathFinder->Locate( newPosition, newDirection );
186 }
187}
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)

◆ ReLocateWithinVolume()

void G4SafetyHelper::ReLocateWithinVolume ( const G4ThreeVector pGlobalPoint)

Definition at line 141 of file G4SafetyHelper.cc.

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

Referenced by G4VMultipleScattering::AlongStepDoIt(), G4TransportationWithMsc::AlongStepGetPhysicalInteractionLength(), G4NeutrinoElectronProcess::PostStepDoIt(), G4ElNeutrinoNucleusProcess::PostStepDoIt(), G4MuNeutrinoNucleusProcess::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: