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

#include <G4NormalNavigation.hh>

Public Member Functions

 G4NormalNavigation ()
 
 ~G4NormalNavigation ()
 
G4bool LevelLocate (G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint)
 
G4double ComputeStep (const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4double currentProposedStepLength, G4double &newSafety, G4NavigationHistory &history, G4bool &validExitNormal, G4ThreeVector &exitNormal, G4bool &exiting, G4bool &entering, G4VPhysicalVolume *(*pBlockedPhysical), G4int &blockedReplicaNo)
 
G4double ComputeSafety (const G4ThreeVector &globalpoint, const G4NavigationHistory &history, const G4double pMaxLength=DBL_MAX)
 
G4int GetVerboseLevel () const
 
void SetVerboseLevel (G4int level)
 
void CheckMode (G4bool mode)
 

Detailed Description

Definition at line 55 of file G4NormalNavigation.hh.

Constructor & Destructor Documentation

G4NormalNavigation::G4NormalNavigation ( )

Definition at line 44 of file G4NormalNavigation.cc.

45  : fCheck(false)
46 {
47  fLogger = new G4NavigationLogger("G4NormalNavigation");
48 }
G4NormalNavigation::~G4NormalNavigation ( )

Definition at line 54 of file G4NormalNavigation.cc.

55 {
56  delete fLogger;
57 }

Member Function Documentation

void G4NormalNavigation::CheckMode ( G4bool  mode)
inline
G4double G4NormalNavigation::ComputeSafety ( const G4ThreeVector globalpoint,
const G4NavigationHistory history,
const G4double  pMaxLength = DBL_MAX 
)

Definition at line 335 of file G4NormalNavigation.cc.

338 {
339  G4VPhysicalVolume *motherPhysical, *samplePhysical;
340  G4LogicalVolume *motherLogical;
341  G4VSolid *motherSolid;
342  G4double motherSafety, ourSafety;
343  G4int localNoDaughters, sampleNo;
344 
345  motherPhysical = history.GetTopVolume();
346  motherLogical = motherPhysical->GetLogicalVolume();
347  motherSolid = motherLogical->GetSolid();
348 
349  // Compute mother safety
350  //
351  motherSafety = motherSolid->DistanceToOut(localPoint);
352  ourSafety = motherSafety; // Working isotropic safety
353 
354 #ifdef G4VERBOSE
355  if( fCheck )
356  {
357  fLogger->ComputeSafetyLog(motherSolid,localPoint,motherSafety,true,true);
358  }
359 #endif
360 
361  // Compute daughter safeties
362  //
363  localNoDaughters = motherLogical->GetNoDaughters();
364  for ( sampleNo=localNoDaughters-1; sampleNo>=0; sampleNo-- )
365  {
366  samplePhysical = motherLogical->GetDaughter(sampleNo);
367  G4AffineTransform sampleTf(samplePhysical->GetRotation(),
368  samplePhysical->GetTranslation());
369  sampleTf.Invert();
370  const G4ThreeVector samplePoint =
371  sampleTf.TransformPoint(localPoint);
372  const G4VSolid *sampleSolid =
373  samplePhysical->GetLogicalVolume()->GetSolid();
374  const G4double sampleSafety =
375  sampleSolid->DistanceToIn(samplePoint);
376  if ( sampleSafety<ourSafety )
377  {
378  ourSafety = sampleSafety;
379  }
380 #ifdef G4VERBOSE
381  if(fCheck)
382  {
383  fLogger->ComputeSafetyLog(sampleSolid,samplePoint,
384  sampleSafety,false,false);
385  // Not mother, no banner
386  }
387 #endif
388  }
389  return ourSafety;
390 }
G4VPhysicalVolume * GetTopVolume() const
G4VSolid * GetSolid() const
G4VPhysicalVolume * GetDaughter(const G4int i) const
const G4RotationMatrix * GetRotation() const
int G4int
Definition: G4Types.hh:78
G4AffineTransform & Invert()
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
G4int GetNoDaughters() const
const G4ThreeVector & GetTranslation() const
G4LogicalVolume * GetLogicalVolume() const
void ComputeSafetyLog(const G4VSolid *solid, const G4ThreeVector &point, G4double safety, G4bool isMotherVolume, G4int banner=-1) const
double G4double
Definition: G4Types.hh:76
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4NormalNavigation::ComputeStep ( const G4ThreeVector localPoint,
const G4ThreeVector localDirection,
const G4double  currentProposedStepLength,
G4double newSafety,
G4NavigationHistory history,
G4bool validExitNormal,
G4ThreeVector exitNormal,
G4bool exiting,
G4bool entering,
G4VPhysicalVolume **  pBlockedPhysical,
G4int blockedReplicaNo 
)

Definition at line 69 of file G4NormalNavigation.cc.

80 {
81  G4VPhysicalVolume *motherPhysical, *samplePhysical, *blockedExitedVol=0;
82  G4LogicalVolume *motherLogical;
83  G4VSolid *motherSolid;
84  G4ThreeVector sampleDirection;
85  G4double ourStep=currentProposedStepLength, ourSafety;
86  G4double motherSafety, motherStep=DBL_MAX;
87  G4int localNoDaughters, sampleNo;
88  G4bool motherValidExitNormal=false;
89  G4ThreeVector motherExitNormal;
90 
91  motherPhysical = history.GetTopVolume();
92  motherLogical = motherPhysical->GetLogicalVolume();
93  motherSolid = motherLogical->GetSolid();
94 
95  // Compute mother safety
96  //
97  motherSafety = motherSolid->DistanceToOut(localPoint);
98  ourSafety = motherSafety; // Working isotropic safety
99 
100  localNoDaughters = motherLogical->GetNoDaughters();
101 
102 #ifdef G4VERBOSE
103  if ( fCheck && ( (localNoDaughters>0) || (ourStep < motherSafety) ) )
104  {
105  fLogger->PreComputeStepLog(motherPhysical, motherSafety, localPoint);
106  }
107 #endif
108  // Compute daughter safeties & intersections
109  //
110 
111  // Exiting normal optimisation
112  //
113  if ( exiting&&validExitNormal )
114  {
115  if ( localDirection.dot(exitNormal)>=kMinExitingNormalCosine )
116  {
117  // Block exited daughter volume
118  //
119  blockedExitedVol = (*pBlockedPhysical);
120  ourSafety = 0;
121  }
122  }
123  exiting = false;
124  entering = false;
125 
126 #ifdef G4VERBOSE
127  if ( fCheck )
128  {
129  // Compute early:
130  // a) to check whether point is (wrongly) outside
131  // (signaled if step < 0 or step == kInfinity )
132  // b) to check value against answer of daughters!
133 
134  motherStep = motherSolid->DistanceToOut(localPoint,
135  localDirection,
136  true,
137  &motherValidExitNormal,
138  &motherExitNormal);
139 
140  if( (motherStep >= kInfinity) || (motherStep < 0.0) )
141  {
142  // Error - indication of being outside solid !!
143  fLogger->ReportOutsideMother(localPoint, localDirection, motherPhysical);
144 
145  ourStep = motherStep = 0.0;
146 
147  exiting= true;
148  entering= false;
149 
150  // If we are outside the solid does the normal make sense?
151  validExitNormal= motherValidExitNormal;
152  exitNormal= motherExitNormal;
153 
154  *pBlockedPhysical= 0; // or motherPhysical ?
155  blockedReplicaNo= 0; // or motherReplicaNumber ?
156 
157  newSafety= 0.0;
158  return ourStep;
159  }
160  }
161 #endif
162 
163  for ( sampleNo=localNoDaughters-1; sampleNo>=0; sampleNo--)
164  {
165  samplePhysical = motherLogical->GetDaughter(sampleNo);
166  if ( samplePhysical!=blockedExitedVol )
167  {
168  G4AffineTransform sampleTf(samplePhysical->GetRotation(),
169  samplePhysical->GetTranslation());
170  sampleTf.Invert();
171  const G4ThreeVector samplePoint = sampleTf.TransformPoint(localPoint);
172  const G4VSolid *sampleSolid =
173  samplePhysical->GetLogicalVolume()->GetSolid();
174  const G4double sampleSafety =
175  sampleSolid->DistanceToIn(samplePoint);
176 
177  if ( sampleSafety<ourSafety )
178  {
179  ourSafety=sampleSafety;
180  }
181 
182  if ( sampleSafety<=ourStep )
183  {
184  sampleDirection = sampleTf.TransformAxis(localDirection);
185  const G4double sampleStep =
186  sampleSolid->DistanceToIn(samplePoint,sampleDirection);
187 #ifdef G4VERBOSE
188  if( fCheck )
189  {
190  fLogger->PrintDaughterLog(sampleSolid, samplePoint,
191  sampleSafety, true,
192  sampleDirection, sampleStep);
193  }
194 #endif
195  if ( sampleStep<=ourStep )
196  {
197  ourStep = sampleStep;
198  entering = true;
199  exiting = false;
200  *pBlockedPhysical = samplePhysical;
201  blockedReplicaNo = -1;
202 #ifdef G4VERBOSE
203  if( fCheck )
204  {
205  fLogger->AlongComputeStepLog(sampleSolid, samplePoint,
206  sampleDirection, localDirection, sampleSafety, sampleStep);
207  }
208 #endif
209  }
210 
211 #ifdef G4VERBOSE
212  if( fCheck && (sampleStep < kInfinity) && (sampleStep >= motherStep) )
213  {
214  // The intersection point with the daughter is at or after the exit
215  // point from the mother volume. Double check!
216  fLogger->CheckDaughterEntryPoint(sampleSolid,
217  samplePoint, sampleDirection,
218  motherSolid,
219  localPoint, localDirection,
220  motherStep, sampleStep);
221  }
222 #endif
223  } // end of if ( sampleSafety <= ourStep )
224 #ifdef G4VERBOSE
225  else if( fCheck )
226  {
227  fLogger->PrintDaughterLog(sampleSolid, samplePoint,
228  sampleSafety, false,
229  G4ThreeVector(0.,0.,0.), -1.0 );
230  }
231 #endif
232  }
233  }
234  if ( currentProposedStepLength<ourSafety )
235  {
236  // Guaranteed physics limited
237  //
238  entering = false;
239  exiting = false;
240  *pBlockedPhysical = 0;
241  ourStep = kInfinity;
242  }
243  else
244  {
245  // Consider intersection with mother solid
246  //
247  if ( motherSafety<=ourStep )
248  {
249  if ( !fCheck ) // The call is moved above when running in check_mode
250  {
251  motherStep = motherSolid->DistanceToOut(localPoint,
252  localDirection,
253  true,
254  &motherValidExitNormal,
255  &motherExitNormal);
256  }
257 #ifdef G4VERBOSE
258  else // check_mode
259  {
260  fLogger->PostComputeStepLog(motherSolid, localPoint, localDirection,
261  motherStep, motherSafety);
262  if( motherValidExitNormal )
263  {
264  fLogger->CheckAndReportBadNormal(motherExitNormal,
265  localPoint,
266  localDirection,
267  motherStep,
268  motherSolid,
269  "From motherSolid::DistanceToOut" );
270  }
271  }
272 #endif
273 
274  if( (motherStep >= kInfinity) || (motherStep < 0.0) )
275  {
276 #ifdef G4VERBOSE
277  if( fCheck ) // Clearly outside the mother solid!
278  {
279  fLogger->ReportOutsideMother(localPoint, localDirection,
280  motherPhysical);
281  }
282 #endif
283  ourStep = motherStep = 0.0;
284  exiting = true;
285  entering = false;
286  // validExitNormal= motherValidExitNormal;
287  // exitNormal= motherExitNormal;
288  // The normal could be useful - but only if near the mother
289  // But it could be unreliable!
290  validExitNormal = false;
291  *pBlockedPhysical= 0; // or motherPhysical ?
292  blockedReplicaNo= 0; // or motherReplicaNumber ?
293  newSafety= 0.0;
294  return ourStep;
295  }
296 
297  if ( motherStep<=ourStep )
298  {
299  ourStep = motherStep;
300  exiting = true;
301  entering = false;
302  validExitNormal= motherValidExitNormal;
303  exitNormal= motherExitNormal;
304 
305  if ( motherValidExitNormal )
306  {
307  const G4RotationMatrix *rot = motherPhysical->GetRotation();
308  if (rot)
309  {
310  exitNormal *= rot->inverse();
311 #ifdef G4VERBOSE
312  if( fCheck )
313  fLogger->CheckAndReportBadNormal(exitNormal, // rotated
314  motherExitNormal, // original
315  *rot,
316  "From RotationMatrix" );
317 #endif
318  }
319  }
320  }
321  else
322  {
323  validExitNormal = false;
324  }
325  }
326  }
327  newSafety = ourSafety;
328  return ourStep;
329 }
void AlongComputeStepLog(const G4VSolid *sampleSolid, const G4ThreeVector &samplePoint, const G4ThreeVector &sampleDirection, const G4ThreeVector &localDirection, G4double sampleSafety, G4double sampleStep) const
G4VPhysicalVolume * GetTopVolume() const
void PrintDaughterLog(const G4VSolid *sampleSolid, const G4ThreeVector &samplePoint, G4double sampleSafety, G4bool onlySafety, const G4ThreeVector &sampleDirection, G4double sampleStep) const
static const G4double kInfinity
Definition: geomdefs.hh:42
CLHEP::Hep3Vector G4ThreeVector
double dot(const Hep3Vector &) const
G4VSolid * GetSolid() const
G4VPhysicalVolume * GetDaughter(const G4int i) const
const G4RotationMatrix * GetRotation() const
int G4int
Definition: G4Types.hh:78
HepRotation inverse() const
void ReportOutsideMother(const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4VPhysicalVolume *motherPV, G4double tDist=30.0 *CLHEP::cm) const
G4AffineTransform & Invert()
bool G4bool
Definition: G4Types.hh:79
G4bool CheckAndReportBadNormal(const G4ThreeVector &unitNormal, const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, G4double step, const G4VSolid *solid, const char *msg) const
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
static const double kMinExitingNormalCosine
Definition: geomdefs.hh:46
G4int GetNoDaughters() const
const G4ThreeVector & GetTranslation() const
G4LogicalVolume * GetLogicalVolume() const
void PreComputeStepLog(const G4VPhysicalVolume *motherPhysical, G4double motherSafety, const G4ThreeVector &localPoint) const
void PostComputeStepLog(const G4VSolid *motherSolid, const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, G4double motherStep, G4double motherSafety) const
void CheckDaughterEntryPoint(const G4VSolid *sampleSolid, const G4ThreeVector &samplePoint, const G4ThreeVector &sampleDirection, const G4VSolid *motherSolid, const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, G4double motherStep, G4double sampleStep) const
double G4double
Definition: G4Types.hh:76
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0
#define DBL_MAX
Definition: templates.hh:83

Here is the call graph for this function:

Here is the caller graph for this function:

G4int G4NormalNavigation::GetVerboseLevel ( ) const

Definition at line 400 of file G4NormalNavigation.cc.

401 {
402  return fLogger->GetVerboseLevel();
403 }
G4int GetVerboseLevel() const

Here is the call graph for this function:

G4bool G4NormalNavigation::LevelLocate ( G4NavigationHistory history,
const G4VPhysicalVolume blockedVol,
const G4int  blockedNum,
const G4ThreeVector globalPoint,
const G4ThreeVector globalDirection,
const G4bool  pLocatedOnEdge,
G4ThreeVector localPoint 
)
inline

Here is the caller graph for this function:

void G4NormalNavigation::SetVerboseLevel ( G4int  level)

Definition at line 409 of file G4NormalNavigation.cc.

410 {
411  fLogger->SetVerboseLevel(level);
412 }
void SetVerboseLevel(G4int level)

Here is the call graph for this function:


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