Geant4-11
Data Structures | Public Types | Public Member Functions | Protected Attributes | Private Attributes
G4ITSafetyHelper Class Reference

#include <G4ITSafetyHelper.hh>

Inheritance diagram for G4ITSafetyHelper:
G4TrackStateDependent< G4ITSafetyHelper > G4VTrackStateDependent

Data Structures

class  State
 

Public Types

typedef G4ITSafetyHelper ClassType
 
typedef G4TrackState< G4ITSafetyHelper > StateType
 
typedef G4shared_ptr< StateType > StateTypeHandle
 

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)
 
virtual StateTypeHandle CreateTrackState () const
 
void EnableParallelNavigation (G4bool parallel)
 
 G4ITSafetyHelper ()
 
virtual StateTypeHandle GetConcreteTrackState () const
 
virtual G4VTrackStateHandle GetTrackState () const
 
G4VPhysicalVolume * GetWorldVolume ()
 
void InitialiseHelper ()
 
void InitialiseNavigator ()
 
virtual void LoadTrackState (G4TrackStateManager &manager)
 
void Locate (const G4ThreeVector &pGlobalPoint, const G4ThreeVector &direction)
 
virtual void NewTrackState ()
 
virtual G4VTrackStateHandle PopTrackState ()
 
void ReLocateWithinVolume (const G4ThreeVector &pGlobalPoint)
 
virtual void ResetTrackState ()
 
virtual void SaveTrackState (G4TrackStateManager &manager)
 
void SetCurrentSafety (G4double val, const G4ThreeVector &pos)
 
virtual void SetTrackState (G4shared_ptr< StateType > state)
 
G4int SetVerboseLevel (G4int lev)
 
 ~G4ITSafetyHelper ()
 

Protected Attributes

StateTypeHandle fpTrackState
 

Private Attributes

G4bool fFirstCall
 
G4int fMassNavigatorId
 
G4ITNavigator * fpMassNavigator
 
G4PathFinder * fpPathFinder
 
G4bool fUseParallelGeometries
 
G4int fVerbose
 

Detailed Description

Definition at line 54 of file G4ITSafetyHelper.hh.

Member Typedef Documentation

◆ ClassType

typedef G4ITSafetyHelper G4TrackStateDependent< G4ITSafetyHelper >::ClassType
inherited

Definition at line 238 of file G4TrackState.hh.

◆ StateType

Definition at line 239 of file G4TrackState.hh.

◆ StateTypeHandle

typedef G4shared_ptr<StateType> G4TrackStateDependent< G4ITSafetyHelper >::StateTypeHandle
inherited

Definition at line 240 of file G4TrackState.hh.

Constructor & Destructor Documentation

◆ G4ITSafetyHelper()

G4ITSafetyHelper::G4ITSafetyHelper ( )

Definition at line 41 of file G4ITSafetyHelper.cc.

41 :
42 G4TrackStateDependent<G4ITSafetyHelper>(), fUseParallelGeometries(false), // By default, one geometry only
43 fFirstCall(true), fVerbose(0)
44// fRecomputeFactor(0.0)
45{
46 fpPathFinder = 0; // Cannot initialise this yet - a loop results
47
48 // Initialization of the Navigator pointer is postponed, and must
49 // be undertaken by another class calling InitialiseHelper()
50 //
53}
G4ITNavigator * fpMassNavigator
G4PathFinder * fpPathFinder

References fMassNavigatorId, fpMassNavigator, and fpPathFinder.

◆ ~G4ITSafetyHelper()

G4ITSafetyHelper::~G4ITSafetyHelper ( )

Definition at line 89 of file G4ITSafetyHelper.cc.

90{
91}

Member Function Documentation

◆ CheckNextStep()

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

Definition at line 93 of file G4ITSafetyHelper.cc.

97{
98 // Distance in the Mass geometry
99 //
100 G4double linstep = fpMassNavigator->CheckNextStep(position, direction,
101 currentMaxStep, newSafety);
102 fpTrackState->fLastSafetyPosition = position;
103 fpTrackState->fLastSafety = newSafety;
104
105 // TODO: Can replace this with a call to PathFinder
106 // giving id of Mass Geometry --> this avoid doing the work twice
107
108 return linstep;
109}
double G4double
Definition: G4Types.hh:83
#define position
Definition: xmlparse.cc:622

References fpMassNavigator, G4TrackStateDependent< G4ITSafetyHelper >::fpTrackState, and position.

Referenced by G4DNABrownianTransportation::ComputeGeomLimit().

◆ ComputeSafety()

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

Definition at line 111 of file G4ITSafetyHelper.cc.

113{
114 G4double newSafety;
115
116 // Only recompute (calling Navigator/PathFinder) if 'position'
117 // is *not* the safety location and has moved 'significantly'
118 //
119 G4double moveLengthSq = (position - fpTrackState->fLastSafetyPosition).mag2();
120 if ((moveLengthSq > 0.0))
121 {
123 {
124 // Safety for mass geometry
125 newSafety = fpMassNavigator->ComputeSafety(position, maxLength, true);
126 }
127 else
128 {
129 // Safety for all geometries
130 newSafety = fpPathFinder->ComputeSafety(position);
131 }
132
133 // We can only store a 'true' safety - one that was not restricted by maxLength
134 if (newSafety < maxLength)
135 {
136 fpTrackState->fLastSafety = newSafety;
137 fpTrackState->fLastSafetyPosition = position;
138 }
139 }
140 else
141 {
142 // return last value if position is not (significantly) changed
143 //
144 // G4double moveLength = 0;
145 // if( moveLengthSq > 0.0 ) { moveLength= std::sqrt(moveLengthSq); }
146 newSafety = fpTrackState->fLastSafety; // -moveLength;
147 }
148 return newSafety;
149}
G4double ComputeSafety(const G4ThreeVector &globalPoint)

References G4PathFinder::ComputeSafety(), fpMassNavigator, fpPathFinder, G4TrackStateDependent< G4ITSafetyHelper >::fpTrackState, fUseParallelGeometries, and position.

◆ CreateTrackState()

virtual StateTypeHandle G4TrackStateDependent< G4ITSafetyHelper >::CreateTrackState ( ) const
inlinevirtualinherited

Definition at line 290 of file G4TrackState.hh.

291 {
292 return StateTypeHandle(new StateType());
293 }
G4shared_ptr< StateType > StateTypeHandle
G4TrackState< G4ITSafetyHelper > StateType

◆ EnableParallelNavigation()

void G4ITSafetyHelper::EnableParallelNavigation ( G4bool  parallel)
inline

◆ GetConcreteTrackState()

virtual StateTypeHandle G4TrackStateDependent< G4ITSafetyHelper >::GetConcreteTrackState ( ) const
inlinevirtualinherited

Definition at line 264 of file G4TrackState.hh.

265 {
266 return fpTrackState;
267 }

◆ GetTrackState()

virtual G4VTrackStateHandle G4TrackStateDependent< G4ITSafetyHelper >::GetTrackState ( ) const
inlinevirtualinherited

Implements G4VTrackStateDependent.

Definition at line 257 of file G4TrackState.hh.

258 {
259 G4VTrackStateHandle output =
260 G4dynamic_pointer_cast<G4VTrackState>(fpTrackState);
261 return output;
262 }
G4shared_ptr< G4VTrackState > G4VTrackStateHandle
Definition: G4TrackState.hh:93

◆ GetWorldVolume()

G4VPhysicalVolume * G4ITSafetyHelper::GetWorldVolume ( )
inline

Definition at line 154 of file G4ITSafetyHelper.hh.

155{
156 return fpMassNavigator->GetWorldVolume();
157}

References fpMassNavigator.

Referenced by G4DNABrownianTransportation::ComputeGeomLimit().

◆ InitialiseHelper()

void G4ITSafetyHelper::InitialiseHelper ( )

◆ InitialiseNavigator()

void G4ITSafetyHelper::InitialiseNavigator ( )

Definition at line 55 of file G4ITSafetyHelper.cc.

56{
58
59 G4ITTransportationManager* pTransportMgr =
61
63
64 if(fpMassNavigator == 0) abort();
65
66 // Check
67 //
68 G4VPhysicalVolume* worldPV = fpMassNavigator->GetWorldVolume();
69 if (worldPV == 0)
70 {
71 G4Exception("G4ITSafetyHelper::InitialiseNavigator",
72 "InvalidNavigatorWorld", FatalException,
73 "Found that existing tracking Navigator has NULL world");
74 }
75
76 // fMassNavigatorId = pTransportMgr->ActivateNavigator( fpMassNavigator );
77}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
static G4ITTransportationManager * GetTransportationManager()
G4ITNavigator * GetNavigatorForTracking() const
static G4PathFinder * GetInstance()
Definition: G4PathFinder.cc:52

References FatalException, fpMassNavigator, fpPathFinder, G4Exception(), G4PathFinder::GetInstance(), G4ITTransportationManager::GetNavigatorForTracking(), and G4ITTransportationManager::GetTransportationManager().

Referenced by InitialiseHelper().

◆ LoadTrackState()

virtual void G4TrackStateDependent< G4ITSafetyHelper >::LoadTrackState ( G4TrackStateManager &  manager)
inlinevirtualinherited

Implements G4VTrackStateDependent.

Definition at line 269 of file G4TrackState.hh.

270 {
272 ConvertToConcreteTrackState<ClassType>(manager.GetTrackState(this));
273 if (fpTrackState == nullptr)
274 {
276 SaveTrackState(manager);
277 }
278 }
virtual void SaveTrackState(G4TrackStateManager &manager)
G4VTrackStateHandle GetTrackState(void *adress) const

◆ Locate()

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

Definition at line 183 of file G4ITSafetyHelper.cc.

185{
187 {
188 fpMassNavigator->LocateGlobalPointAndSetup(newPosition, &newDirection, true,
189 false);
190 }
191 else
192 {
193 fpPathFinder->Locate(newPosition, newDirection);
194 }
195}
void Locate(const G4ThreeVector &position, const G4ThreeVector &direction, G4bool relativeSearch=true)

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

◆ NewTrackState()

virtual void G4TrackStateDependent< G4ITSafetyHelper >::NewTrackState ( )
inlinevirtualinherited

Implements G4VTrackStateDependent.

Definition at line 285 of file G4TrackState.hh.

286 {
288 }

◆ PopTrackState()

virtual G4VTrackStateHandle G4TrackStateDependent< G4ITSafetyHelper >::PopTrackState ( )
inlinevirtualinherited

Implements G4VTrackStateDependent.

Definition at line 249 of file G4TrackState.hh.

250 {
251 G4VTrackStateHandle output =
252 G4dynamic_pointer_cast<G4VTrackState>(fpTrackState);
253 fpTrackState.reset();
254 return output;
255 }

◆ ReLocateWithinVolume()

void G4ITSafetyHelper::ReLocateWithinVolume ( const G4ThreeVector &  pGlobalPoint)

Definition at line 151 of file G4ITSafetyHelper.cc.

152{
153#ifdef G4VERBOSE
154 if (fVerbose > 0)
155 {
156 // There is an opportunity - and need - to check whether the proposed move is safe
157 G4ThreeVector moveVec = newPosition - fpTrackState->fLastSafetyPosition;
158 if (moveVec.mag2() > sqr(fpTrackState->fLastSafety))
159 {
160 // A problem exists - we are proposing to move outside 'Safety Sphere'
162 ed << " Safety Sphere: Radius = " << fpTrackState->fLastSafety;
163 ed << " Center = " << fpTrackState->fLastSafetyPosition << G4endl;
164 ed << " New Location : Move = " << moveVec.mag2();
165 ed << " Position = " << newPosition << G4endl;
166 G4Exception("G4ITSafetyHelper::ReLocateWithinVolume", "GeomNav999",
168 "Unsafe Move> Asked to relocate beyond 'Safety sphere'.");
169 }
170 }
171#endif
172
174 {
175 fpMassNavigator->LocateGlobalPointWithinVolume(newPosition);
176 }
177 else
178 {
179 fpPathFinder->ReLocate(newPosition);
180 }
181}
@ JustWarning
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
#define G4endl
Definition: G4ios.hh:57
double mag2() const
void ReLocate(const G4ThreeVector &position)
T sqr(const T &x)
Definition: templates.hh:128

References fpMassNavigator, fpPathFinder, G4TrackStateDependent< G4ITSafetyHelper >::fpTrackState, fUseParallelGeometries, fVerbose, G4endl, G4Exception(), JustWarning, CLHEP::Hep3Vector::mag2(), G4PathFinder::ReLocate(), and sqr().

◆ ResetTrackState()

virtual void G4TrackStateDependent< G4ITSafetyHelper >::ResetTrackState ( )
inlinevirtualinherited

Implements G4VTrackStateDependent.

Definition at line 295 of file G4TrackState.hh.

296 {
297 fpTrackState.reset();
298 }

◆ SaveTrackState()

virtual void G4TrackStateDependent< G4ITSafetyHelper >::SaveTrackState ( G4TrackStateManager &  manager)
inlinevirtualinherited

Implements G4VTrackStateDependent.

Definition at line 280 of file G4TrackState.hh.

281 {
283 }
G4shared_ptr< G4VTrackState > ConvertToAbstractTrackState(G4shared_ptr< G4TrackState< OriginalType > > state)
void SetTrackState(void *adress, G4VTrackStateHandle state)

◆ SetCurrentSafety()

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

Definition at line 160 of file G4ITSafetyHelper.hh.

161{
162 fpTrackState->fLastSafety = val;
163 fpTrackState->fLastSafetyPosition = pos;
164}
static const G4double pos

References G4TrackStateDependent< G4ITSafetyHelper >::fpTrackState, and pos.

Referenced by G4ITTransportation::AlongStepGetPhysicalInteractionLength().

◆ SetTrackState()

virtual void G4TrackStateDependent< G4ITSafetyHelper >::SetTrackState ( G4shared_ptr< StateType >  state)
inlinevirtualinherited

Definition at line 244 of file G4TrackState.hh.

245 {
246 fpTrackState = state;
247 }

◆ SetVerboseLevel()

G4int G4ITSafetyHelper::SetVerboseLevel ( G4int  lev)
inline

Definition at line 97 of file G4ITSafetyHelper.hh.

98 { G4int oldlv= fVerbose; fVerbose= lev; return oldlv;}
int G4int
Definition: G4Types.hh:85

References fVerbose.

Field Documentation

◆ fFirstCall

G4bool G4ITSafetyHelper::fFirstCall
private

Definition at line 115 of file G4ITSafetyHelper.hh.

Referenced by InitialiseHelper().

◆ fMassNavigatorId

G4int G4ITSafetyHelper::fMassNavigatorId
private

Definition at line 111 of file G4ITSafetyHelper.hh.

Referenced by G4ITSafetyHelper().

◆ fpMassNavigator

G4ITNavigator* G4ITSafetyHelper::fpMassNavigator
private

◆ fpPathFinder

G4PathFinder* G4ITSafetyHelper::fpPathFinder
private

◆ fpTrackState

StateTypeHandle G4TrackStateDependent< G4ITSafetyHelper >::fpTrackState
protectedinherited

Definition at line 305 of file G4TrackState.hh.

◆ fUseParallelGeometries

G4bool G4ITSafetyHelper::fUseParallelGeometries
private

◆ fVerbose

G4int G4ITSafetyHelper::fVerbose
private

Definition at line 117 of file G4ITSafetyHelper.hh.

Referenced by ReLocateWithinVolume(), and SetVerboseLevel().


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