Geant4-11
Public Member Functions | Private Attributes
G4NormalNavigation Class Reference

#include <G4NormalNavigation.hh>

Public Member Functions

void CheckMode (G4bool mode)
 
G4double ComputeSafety (const G4ThreeVector &globalpoint, const G4NavigationHistory &history, const G4double pMaxLength=DBL_MAX)
 
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)
 
 G4NormalNavigation ()
 
G4int GetVerboseLevel () const
 
G4bool LevelLocate (G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint)
 
void SetVerboseLevel (G4int level)
 
 ~G4NormalNavigation ()
 

Private Attributes

G4bool fCheck = false
 
G4NavigationLoggerfLogger
 

Detailed Description

Definition at line 51 of file G4NormalNavigation.hh.

Constructor & Destructor Documentation

◆ G4NormalNavigation()

G4NormalNavigation::G4NormalNavigation ( )

Definition at line 40 of file G4NormalNavigation.cc.

41{
42 fLogger = new G4NavigationLogger("G4NormalNavigation");
43}
G4NavigationLogger * fLogger

References fLogger.

◆ ~G4NormalNavigation()

G4NormalNavigation::~G4NormalNavigation ( )

Definition at line 49 of file G4NormalNavigation.cc.

50{
51 delete fLogger;
52}

References fLogger.

Member Function Documentation

◆ CheckMode()

void G4NormalNavigation::CheckMode ( G4bool  mode)
inline

◆ ComputeSafety()

G4double G4NormalNavigation::ComputeSafety ( const G4ThreeVector globalpoint,
const G4NavigationHistory history,
const G4double  pMaxLength = DBL_MAX 
)

Definition at line 332 of file G4NormalNavigation.cc.

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

References G4NavigationLogger::ComputeSafetyLog(), G4VSolid::DistanceToIn(), G4VSolid::DistanceToOut(), fCheck, fLogger, G4LogicalVolume::GetDaughter(), G4VPhysicalVolume::GetLogicalVolume(), G4LogicalVolume::GetNoDaughters(), G4VPhysicalVolume::GetRotation(), G4LogicalVolume::GetSolid(), G4VPhysicalVolume::GetTranslation(), g4zmq::history(), G4AffineTransform::Invert(), and G4AffineTransform::TransformPoint().

Referenced by G4Navigator::ComputeSafety(), G4ITNavigator1::ComputeSafety(), G4ITNavigator2::ComputeSafety(), and G4RegularNavigation::ComputeSafety().

◆ ComputeStep()

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 64 of file G4NormalNavigation.cc.

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

References G4NavigationLogger::AlongComputeStepLog(), G4NavigationLogger::CheckAndReportBadNormal(), G4NavigationLogger::CheckDaughterEntryPoint(), DBL_MAX, G4VSolid::DistanceToIn(), G4VSolid::DistanceToOut(), CLHEP::Hep3Vector::dot(), fCheck, fLogger, G4LogicalVolume::GetDaughter(), G4VPhysicalVolume::GetLogicalVolume(), G4LogicalVolume::GetNoDaughters(), G4VPhysicalVolume::GetRotation(), G4LogicalVolume::GetSolid(), G4VPhysicalVolume::GetTranslation(), g4zmq::history(), CLHEP::HepRotation::inverse(), G4AffineTransform::Invert(), kInfinity, kMinExitingNormalCosine, G4NavigationLogger::PostComputeStepLog(), G4NavigationLogger::PreComputeStepLog(), G4NavigationLogger::PrintDaughterLog(), G4NavigationLogger::ReportOutsideMother(), G4AffineTransform::TransformAxis(), and G4AffineTransform::TransformPoint().

Referenced by G4RegularNavigation::ComputeStep(), G4Navigator::ComputeStep(), G4ITNavigator1::ComputeStep(), G4ITNavigator2::ComputeStep(), and G4RegularNavigation::ComputeStepSkippingEqualMaterials().

◆ GetVerboseLevel()

G4int G4NormalNavigation::GetVerboseLevel ( ) const

Definition at line 397 of file G4NormalNavigation.cc.

398{
399 return fLogger->GetVerboseLevel();
400}
G4int GetVerboseLevel() const

References fLogger, and G4NavigationLogger::GetVerboseLevel().

◆ LevelLocate()

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

◆ SetVerboseLevel()

void G4NormalNavigation::SetVerboseLevel ( G4int  level)

Definition at line 406 of file G4NormalNavigation.cc.

407{
408 fLogger->SetVerboseLevel(level);
409}
void SetVerboseLevel(G4int level)

References fLogger, and G4NavigationLogger::SetVerboseLevel().

Field Documentation

◆ fCheck

G4bool G4NormalNavigation::fCheck = false
private

Definition at line 103 of file G4NormalNavigation.hh.

Referenced by ComputeSafety(), and ComputeStep().

◆ fLogger

G4NavigationLogger* G4NormalNavigation::fLogger
private

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