Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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)
 
G4bool RecheckDistanceToCurrentBoundary (const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double *prDistance, G4double *prNewSafety=0) const
 
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 53 of file G4SafetyHelper.hh.

Constructor & Destructor Documentation

G4SafetyHelper::G4SafetyHelper ( )

Definition at line 42 of file G4SafetyHelper.cc.

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

Definition at line 89 of file G4SafetyHelper.cc.

90 {
91 }

Member Function Documentation

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

Definition at line 94 of file G4SafetyHelper.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 114 of file G4SafetyHelper.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

void G4SafetyHelper::EnableParallelNavigation ( G4bool  parallel)
inline

Definition at line 146 of file G4SafetyHelper.hh.

147 {
148  fUseParallelGeometries = parallel;
149 }

Here is the caller graph for this function:

G4VPhysicalVolume * G4SafetyHelper::GetWorldVolume ( )
inline

Definition at line 152 of file G4SafetyHelper.hh.

153 {
154  return fpMassNavigator->GetWorldVolume();
155 }
G4VPhysicalVolume * GetWorldVolume() const

Here is the call graph for this function:

void G4SafetyHelper::InitialiseHelper ( )

Definition at line 81 of file G4SafetyHelper.cc.

82 {
83  fLastSafetyPosition = G4ThreeVector(0.0,0.0,0.0);
84  fLastSafety = 0.0;
85  if (fFirstCall) { InitialiseNavigator(); }
86  fFirstCall = false;
87 }
CLHEP::Hep3Vector G4ThreeVector
void InitialiseNavigator()

Here is the call graph for this function:

Here is the caller graph for this function:

void G4SafetyHelper::InitialiseNavigator ( )

Definition at line 59 of file G4SafetyHelper.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 183 of file G4SafetyHelper.cc.

185 {
186  if( !fUseParallelGeometries)
187  {
188  fpMassNavigator->LocateGlobalPointAndSetup(newPosition, &newDirection,
189  true, false);
190  }
191  else
192  {
193  fpPathFinder->Locate( newPosition, newDirection );
194  }
195 }
void Locate(const G4ThreeVector &position, const G4ThreeVector &direction, G4bool relativeSearch=true)
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=0, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
Definition: G4Navigator.cc:125

Here is the call graph for this function:

G4bool G4SafetyHelper::RecheckDistanceToCurrentBoundary ( const G4ThreeVector pGlobalPoint,
const G4ThreeVector pDirection,
const G4double  pCurrentProposedStepLength,
G4double prDistance,
G4double prNewSafety = 0 
) const

Definition at line 197 of file G4SafetyHelper.cc.

203 {
204  G4bool retval;
205  if( !fUseParallelGeometries)
206  {
207  retval= fpMassNavigator->RecheckDistanceToCurrentBoundary(
208  pGlobalPoint,
209  pDirection,
210  aProposedMove,
211  prDistance,
212  prNewSafety);
213  }
214  else
215  {
216  //G4Exception("G4Navigator::RecheckDistanceToCurrentBoundary()", "GeomNav0001",
217  // JustWarning, "Method NOT Available (yet) in case of Multiple Geometries (where PathFinder is involved.).");
218  retval= fpPathFinder->RecheckDistanceToCurrentBoundary(
219  pGlobalPoint,
220  pDirection,
221  aProposedMove,
222  prDistance,
223  prNewSafety);
224  }
225  return retval;
226 }
bool G4bool
Definition: G4Types.hh:79
virtual G4bool RecheckDistanceToCurrentBoundary(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double CurrentProposedStepLength, G4double *prDistance, G4double *prNewSafety=0) const
G4bool RecheckDistanceToCurrentBoundary(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double *prDistance, G4double *prNewSafety=0) const

Here is the call graph for this function:

Here is the caller graph for this function:

void G4SafetyHelper::ReLocateWithinVolume ( const G4ThreeVector pGlobalPoint)

Definition at line 153 of file G4SafetyHelper.cc.

154 {
155 #ifdef G4VERBOSE
156  if( fVerbose > 0 ) {
157  // There is an opportunity - and need - to check whether the proposed move is safe
158  G4ThreeVector moveVec= newPosition - fLastSafetyPosition;
159  if( moveVec.mag2() > sqr(fLastSafety) )
160  {
161  // A problem exists - we are proposing to move outside 'Safety Sphere'
163  ed << " Safety Sphere: Radius = " << fLastSafety;
164  ed << " Center = " << fLastSafetyPosition << G4endl;
165  ed << " New Location : Move = " << moveVec.mag2();
166  ed << " Position = " << newPosition << G4endl;
167  G4Exception("G4SafetyHelper::ReLocateWithinVolume", "GeomNav999", JustWarning,
168  "Unsafe Move> Asked to relocate beyond 'Safety sphere'.");
169  }
170  }
171 #endif
172 
173  if( !fUseParallelGeometries )
174  {
175  fpMassNavigator->LocateGlobalPointWithinVolume( newPosition );
176  }
177  else
178  {
179  fpPathFinder->ReLocate( newPosition );
180  }
181 }
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
virtual void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
Definition: G4Navigator.cc:582

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 158 of file G4SafetyHelper.hh.

159 {
160  fLastSafety = val;
161  fLastSafetyPosition = pos;
162 }
static const G4double pos

Here is the caller graph for this function:

G4int G4SafetyHelper::SetVerboseLevel ( G4int  lev)
inline

Definition at line 112 of file G4SafetyHelper.hh.

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

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