Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4ITSafetyHelper Class Reference

#include <G4ITSafetyHelper.hh>

Inheritance diagram for G4ITSafetyHelper:
Collaboration diagram for G4ITSafetyHelper:

Classes

class  State
 

Public Member Functions

 G4ITSafetyHelper ()
 
 ~G4ITSafetyHelper ()
 
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 ()
 
- Public Member Functions inherited from G4TrackStateDependent< G4ITSafetyHelper >
virtual ~G4TrackStateDependent ()
 
virtual void SetTrackState (G4shared_ptr< StateType > state)
 
virtual G4VTrackStateHandle PopTrackState ()
 
virtual G4VTrackStateHandle GetTrackState () const
 
virtual StateTypeHandle GetConcreteTrackState () const
 
virtual void LoadTrackState (G4TrackStateManager &manager)
 
virtual void SaveTrackState (G4TrackStateManager &manager)
 
virtual void NewTrackState ()
 
virtual StateTypeHandle CreateTrackState () const
 
virtual void ResetTrackState ()
 
- Public Member Functions inherited from G4VTrackStateDependent
 G4VTrackStateDependent ()
 
virtual ~G4VTrackStateDependent ()
 

Additional Inherited Members

- Public Types inherited from G4TrackStateDependent< G4ITSafetyHelper >
typedef G4ITSafetyHelper ClassType
 
typedef G4TrackState
< G4ITSafetyHelper
StateType
 
typedef G4shared_ptr< StateTypeStateTypeHandle
 
- Protected Member Functions inherited from G4TrackStateDependent< G4ITSafetyHelper >
 G4TrackStateDependent ()
 
- Protected Attributes inherited from G4TrackStateDependent< G4ITSafetyHelper >
StateTypeHandle fpTrackState
 

Detailed Description

Definition at line 55 of file G4ITSafetyHelper.hh.

Constructor & Destructor Documentation

G4ITSafetyHelper::G4ITSafetyHelper ( )

Definition at line 42 of file G4ITSafetyHelper.cc.

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

Definition at line 90 of file G4ITSafetyHelper.cc.

91 {
92 }

Member Function Documentation

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

Definition at line 94 of file G4ITSafetyHelper.cc.

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

Here is the caller graph for this function:

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

Definition at line 112 of file G4ITSafetyHelper.cc.

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

Here is the call graph for this function:

void G4ITSafetyHelper::EnableParallelNavigation ( G4bool  parallel)
inline

Definition at line 150 of file G4ITSafetyHelper.hh.

151 {
152  fUseParallelGeometries = parallel;
153 }

Here is the caller graph for this function:

G4VPhysicalVolume * G4ITSafetyHelper::GetWorldVolume ( )
inline

Definition at line 155 of file G4ITSafetyHelper.hh.

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

Here is the caller graph for this function:

void G4ITSafetyHelper::InitialiseHelper ( )

Definition at line 80 of file G4ITSafetyHelper.cc.

81 {
82  NewTrackState();
83  if (fFirstCall)
84  {
86  }
87  fFirstCall = false;
88 }

Here is the call graph for this function:

Here is the caller graph for this function:

void G4ITSafetyHelper::InitialiseNavigator ( )

Definition at line 56 of file G4ITSafetyHelper.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 184 of file G4ITSafetyHelper.cc.

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

Here is the call graph for this function:

void G4ITSafetyHelper::ReLocateWithinVolume ( const G4ThreeVector pGlobalPoint)

Definition at line 152 of file G4ITSafetyHelper.cc.

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

Here is the call graph for this function:

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

Definition at line 161 of file G4ITSafetyHelper.hh.

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

Here is the caller graph for this function:

G4int G4ITSafetyHelper::SetVerboseLevel ( G4int  lev)
inline

Definition at line 98 of file G4ITSafetyHelper.hh.

99  { G4int oldlv= fVerbose; fVerbose= lev; return oldlv;}
int G4int
Definition: G4Types.hh:78

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