Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
G4NavigationLogger Class Reference

#include <G4NavigationLogger.hh>

Public Member Functions

 G4NavigationLogger (const G4String &id)
 
 ~G4NavigationLogger ()
 
void PreComputeStepLog (const G4VPhysicalVolume *motherPhysical, G4double motherSafety, const G4ThreeVector &localPoint) const
 
void AlongComputeStepLog (const G4VSolid *sampleSolid, const G4ThreeVector &samplePoint, const G4ThreeVector &sampleDirection, const G4ThreeVector &localDirection, G4double sampleSafety, G4double sampleStep) const
 
void PostComputeStepLog (const G4VSolid *motherSolid, const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, G4double motherStep, G4double motherSafety) const
 
void ComputeSafetyLog (const G4VSolid *solid, const G4ThreeVector &point, G4double safety, G4bool banner) const
 
void PrintDaughterLog (const G4VSolid *sampleSolid, const G4ThreeVector &samplePoint, G4double sampleSafety, G4double sampleStep) const
 
G4int GetVerboseLevel () const
 
void SetVerboseLevel (G4int level)
 

Detailed Description

Definition at line 49 of file G4NavigationLogger.hh.

Constructor & Destructor Documentation

G4NavigationLogger::G4NavigationLogger ( const G4String id)

Definition at line 41 of file G4NavigationLogger.cc.

42  : fId(id), fVerbose(0)
43 {
44 }
G4NavigationLogger::~G4NavigationLogger ( )

Definition at line 46 of file G4NavigationLogger.cc.

47 {
48 }

Member Function Documentation

void G4NavigationLogger::AlongComputeStepLog ( const G4VSolid sampleSolid,
const G4ThreeVector samplePoint,
const G4ThreeVector sampleDirection,
const G4ThreeVector localDirection,
G4double  sampleSafety,
G4double  sampleStep 
) const

Definition at line 125 of file G4NavigationLogger.cc.

References G4VSolid::DistanceToIn(), G4VSolid::DistanceToOut(), FatalException, G4cout, G4endl, G4Exception(), G4ThreadLocal, G4GeometryTolerance::GetInstance(), G4VSolid::GetName(), G4VSolid::Inside(), JustWarning, kInside, kOutside, kSurface, and G4INCL::Math::max().

Referenced by G4NormalNavigation::ComputeStep(), and G4VoxelNavigation::ComputeStep().

131 {
132  // Check to see that the resulting point is indeed in/on volume.
133  // This check could eventually be made only for successful candidate.
134 
135  if ( sampleStep < kInfinity )
136  {
137  G4ThreeVector intersectionPoint;
138  intersectionPoint= samplePoint + sampleStep * sampleDirection;
139  EInside insideIntPt= sampleSolid->Inside(intersectionPoint);
140  G4String fType = fId + "::ComputeStep()";
141 
142  G4String solidResponse = "-kInside-";
143  if (insideIntPt == kOutside)
144  { solidResponse = "-kOutside-"; }
145  else if (insideIntPt == kSurface)
146  { solidResponse = "-kSurface-"; }
147 
148  if ( fVerbose == 1 )
149  {
150  G4cout << " Invoked Inside() for solid: "
151  << sampleSolid->GetName()
152  << ". Solid replied: " << solidResponse << G4endl
153  << " For point p: " << intersectionPoint
154  << ", considered as 'intersection' point." << G4endl;
155  }
156 
157  G4double safetyIn= -1, safetyOut= -1; // Set to invalid values
158  G4double newDistIn= -1, newDistOut= -1;
159  if( insideIntPt != kInside )
160  {
161  safetyIn= sampleSolid->DistanceToIn(intersectionPoint);
162  newDistIn= sampleSolid->DistanceToIn(intersectionPoint,
163  sampleDirection);
164  }
165  if( insideIntPt != kOutside )
166  {
167  safetyOut= sampleSolid->DistanceToOut(intersectionPoint);
168  newDistOut= sampleSolid->DistanceToOut(intersectionPoint,
169  sampleDirection);
170  }
171  if( insideIntPt != kSurface )
172  {
173  G4int oldcoutPrec = G4cout.precision(16);
174  std::ostringstream message;
175  message << "Conflicting response from Solid." << G4endl
176  << " Inaccurate solid DistanceToIn"
177  << " for solid " << sampleSolid->GetName() << G4endl
178  << " Solid gave DistanceToIn = "
179  << sampleStep << " yet returns " << solidResponse
180  << " for this point !" << G4endl
181  << " Point = " << intersectionPoint << G4endl
182  << " Safety values: " << G4endl;
183  if ( insideIntPt != kInside )
184  {
185  message << " DistanceToIn(p) = " << safetyIn;
186  }
187  if ( insideIntPt != kOutside )
188  {
189  message << " DistanceToOut(p) = " << safetyOut;
190  }
191  G4Exception(fType, "GeomNav1001", JustWarning, message);
192  G4cout.precision(oldcoutPrec);
193  }
194  else
195  {
196  // If it is on the surface, *ensure* that either DistanceToIn
197  // or DistanceToOut returns a finite value ( >= Tolerance).
198  //
199  if( std::max( newDistIn, newDistOut ) <=
200  G4GeometryTolerance::GetInstance()->GetSurfaceTolerance() )
201  {
202  std::ostringstream message;
203  message << "Zero from both Solid DistanceIn and Out(p,v)." << G4endl
204  << " Identified point for which the solid "
205  << sampleSolid->GetName() << G4endl
206  << " has MAJOR problem: " << G4endl
207  << " --> Both DistanceToIn(p,v) and DistanceToOut(p,v) "
208  << "return Zero, an equivalent value or negative value."
209  << G4endl
210  << " Solid: " << sampleSolid << G4endl
211  << " Point p= " << intersectionPoint << G4endl
212  << " Direction v= " << sampleDirection << G4endl
213  << " DistanceToIn(p,v) = " << newDistIn << G4endl
214  << " DistanceToOut(p,v,..) = " << newDistOut << G4endl
215  << " Safety values: " << G4endl
216  << " DistanceToIn(p) = " << safetyIn << G4endl
217  << " DistanceToOut(p) = " << safetyOut;
218  G4Exception(fType, "GeomNav0003", FatalException, message);
219  }
220  }
221 
222  // Verification / verbosity
223  //
224  if ( fVerbose > 1 )
225  {
226  static G4ThreadLocal G4int precVerf= 20; // Precision
227  G4int oldprec = G4cout.precision(precVerf);
228  G4cout << "Daughter "
229  << std::setw(12) << sampleSolid->GetName() << " "
230  << std::setw(4+precVerf) << samplePoint << " "
231  << std::setw(4+precVerf) << sampleSafety << " "
232  << std::setw(4+precVerf) << sampleStep << " "
233  << std::setw(16) << "distanceToIn" << " "
234  << std::setw(4+precVerf) << localDirection << " "
235  << G4endl;
236  G4cout.precision(oldprec);
237  }
238  }
239 }
G4String GetName() const
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
T max(const T t1, const T t2)
brief Return the largest of the two arguments
EInside
Definition: geomdefs.hh:58
#define G4endl
Definition: G4ios.hh:61
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
static G4GeometryTolerance * GetInstance()
void G4NavigationLogger::ComputeSafetyLog ( const G4VSolid solid,
const G4ThreeVector point,
G4double  safety,
G4bool  banner 
) const

Definition at line 289 of file G4NavigationLogger.cc.

References G4cout, G4endl, G4VSolid::GetEntityType(), and G4VSolid::GetName().

Referenced by G4NormalNavigation::ComputeSafety(), and G4VoxelNavigation::ComputeSafety().

293 {
294  G4String volumeType = "Daughter ";
295  if (banner)
296  {
297  G4cout << "************** " << fId << "::ComputeSafety() ****************" << G4endl;
298  G4cout << " VolType "
299  << std::setw(15) << "Safety/mm" << " "
300  << std::setw(52) << "Position (local coordinates)"
301  << " - Solid" << G4endl;
302  volumeType = " Mother ";
303  }
304  G4cout << volumeType
305  << std::setw(15) << safety << " " << point << " - "
306  << solid->GetEntityType() << ": " << solid->GetName() << G4endl;
307 }
G4String GetName() const
virtual G4GeometryType GetEntityType() const =0
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
G4int G4NavigationLogger::GetVerboseLevel ( ) const
inline

Definition at line 80 of file G4NavigationLogger.hh.

80 { return fVerbose; }
void G4NavigationLogger::PostComputeStepLog ( const G4VSolid motherSolid,
const G4ThreeVector localPoint,
const G4ThreeVector localDirection,
G4double  motherStep,
G4double  motherSafety 
) const

Definition at line 242 of file G4NavigationLogger.cc.

References G4VSolid::DumpInfo(), FatalException, G4cerr, G4cout, G4endl, G4Exception(), G4ThreadLocal, G4VSolid::GetEntityType(), and G4VSolid::GetName().

Referenced by G4NormalNavigation::ComputeStep(), and G4VoxelNavigation::ComputeStep().

247 {
248  if( fVerbose == 1 )
249  {
250  G4cout << " Mother "
251  << std::setw(15) << motherSafety << " "
252  << std::setw(15) << motherStep << " " << localPoint << " - "
253  << motherSolid->GetEntityType() << ": " << motherSolid->GetName()
254  << G4endl;
255  }
256  if( ( motherStep < 0.0 ) || ( motherStep >= kInfinity) )
257  {
258  G4String fType = fId + "::ComputeStep()";
259  G4int oldPrOut= G4cout.precision(16);
260  G4int oldPrErr= G4cerr.precision(16);
261  std::ostringstream message;
262  message << "Current point is outside the current solid !" << G4endl
263  << " Problem in Navigation" << G4endl
264  << " Point (local coordinates): "
265  << localPoint << G4endl
266  << " Local Direction: " << localDirection << G4endl
267  << " Solid: " << motherSolid->GetName();
268  motherSolid->DumpInfo();
269  G4Exception(fType, "GeomNav0003", FatalException, message);
270  G4cout.precision(oldPrOut);
271  G4cerr.precision(oldPrErr);
272  }
273  if ( fVerbose > 1 )
274  {
275  static G4ThreadLocal G4int precVerf= 20; // Precision
276  G4int oldprec = G4cout.precision(precVerf);
277  G4cout << " Mother " << std::setw(12) << motherSolid->GetName() << " "
278  << std::setw(4+precVerf) << localPoint << " "
279  << std::setw(4+precVerf) << motherSafety << " "
280  << std::setw(4+precVerf) << motherStep << " "
281  << std::setw(16) << "distanceToOut" << " "
282  << std::setw(4+precVerf) << localDirection << " "
283  << G4endl;
284  G4cout.precision(oldprec);
285  }
286 }
G4String GetName() const
virtual G4GeometryType GetEntityType() const =0
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
void DumpInfo() const
G4GLOB_DLL std::ostream G4cout
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
void G4NavigationLogger::PreComputeStepLog ( const G4VPhysicalVolume motherPhysical,
G4double  motherSafety,
const G4ThreeVector localPoint 
) const

Definition at line 51 of file G4NavigationLogger.cc.

References G4VSolid::DistanceToIn(), G4VSolid::DumpInfo(), FatalException, G4cout, G4endl, G4Exception(), G4ThreadLocal, G4VSolid::GetEntityType(), G4VPhysicalVolume::GetLogicalVolume(), G4VSolid::GetName(), G4VPhysicalVolume::GetName(), G4LogicalVolume::GetSolid(), G4VSolid::GetTolerance(), G4VSolid::Inside(), JustWarning, and kOutside.

Referenced by G4NormalNavigation::ComputeStep(), and G4VoxelNavigation::ComputeStep().

54 {
55  G4VSolid* motherSolid = motherPhysical->GetLogicalVolume()->GetSolid();
56  G4String fType = fId + "::ComputeStep()";
57  if( fVerbose == 1 )
58  {
59  G4cout << "*************** " << fType << " *****************" << G4endl
60  << " VolType "
61  << std::setw(15) << "Safety/mm" << " "
62  << std::setw(15) << "Distance/mm" << " "
63  << std::setw(52) << "Position (local coordinates)"
64  << " - Solid" << G4endl;
65  G4cout << " Mother "
66  << std::setw(15) << motherSafety << " "
67  << std::setw(15) << "N/C" << " " << localPoint << " - "
68  << motherSolid->GetEntityType() << ": " << motherSolid->GetName()
69  << G4endl;
70  }
71  if ( motherSafety < 0.0 )
72  {
73  std::ostringstream message;
74  message << "Negative Safety In Voxel Navigation !" << G4endl
75  << " Current solid " << motherSolid->GetName()
76  << " gave negative safety: " << motherSafety << G4endl
77  << " for the current (local) point " << localPoint;
78  motherSolid->DumpInfo();
79  G4Exception(fType, "GeomNav0003", FatalException, message);
80  }
81  if( motherSolid->Inside(localPoint)==kOutside )
82  {
83  std::ostringstream message;
84  message << "Point is outside Current Volume - " << G4endl
85  << " Point " << localPoint
86  << " is outside current volume " << motherPhysical->GetName()
87  << G4endl;
88  G4double estDistToSolid= motherSolid->DistanceToIn(localPoint);
89  message << " Estimated isotropic distance to solid (distToIn)= "
90  << estDistToSolid;
91  if( estDistToSolid > 100.0 * motherSolid->GetTolerance() )
92  {
93  motherSolid->DumpInfo();
94  G4Exception(fType, "GeomNav0003", FatalException, message,
95  "Point is far outside Current Volume !" );
96  }
97  else
98  G4Exception(fType, "GeomNav1001", JustWarning, message,
99  "Point is a little outside Current Volume.");
100  }
101 
102  // Verification / verbosity
103  //
104  if ( fVerbose > 1 )
105  {
106  static G4ThreadLocal G4int precVerf= 20; // Precision
107  G4int oldprec = G4cout.precision(precVerf);
108  G4cout << " - Information on mother / key daughters ..." << G4endl;
109  G4cout << " Type " << std::setw(12) << "Solid-Name" << " "
110  << std::setw(3*(6+precVerf)) << " local point" << " "
111  << std::setw(4+precVerf) << "solid-Safety" << " "
112  << std::setw(4+precVerf) << "solid-Step" << " "
113  << std::setw(17) << "distance Method "
114  << std::setw(3*(6+precVerf)) << " local direction" << " "
115  << G4endl;
116  G4cout << " Mother " << std::setw(12) << motherSolid->GetName() << " "
117  << std::setw(4+precVerf) << localPoint << " "
118  << std::setw(4+precVerf) << motherSafety << " "
119  << G4endl;
120  G4cout.precision(oldprec);
121  }
122 }
G4String GetName() const
G4double GetTolerance() const
virtual G4GeometryType GetEntityType() const =0
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
void DumpInfo() const
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4LogicalVolume * GetLogicalVolume() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4VSolid * GetSolid() const
void G4NavigationLogger::PrintDaughterLog ( const G4VSolid sampleSolid,
const G4ThreeVector samplePoint,
G4double  sampleSafety,
G4double  sampleStep 
) const

Definition at line 310 of file G4NavigationLogger.cc.

References G4cout, G4endl, G4VSolid::GetEntityType(), and G4VSolid::GetName().

Referenced by G4NormalNavigation::ComputeStep(), and G4VoxelNavigation::ComputeStep().

314 {
315  if ( fVerbose == 1 )
316  {
317  G4cout << "Daughter "
318  << std::setw(15) << sampleSafety << " ";
319  if (sampleStep)
320  {
321  G4cout << std::setw(15) << sampleStep << " ";
322  }
323  else
324  {
325  G4cout << std::setw(15) << "N/C" << " ";
326  }
327  G4cout << samplePoint << " - "
328  << sampleSolid->GetEntityType() << ": " << sampleSolid->GetName()
329  << G4endl;
330  }
331 }
G4String GetName() const
virtual G4GeometryType GetEntityType() const =0
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
void G4NavigationLogger::SetVerboseLevel ( G4int  level)
inline

Definition at line 81 of file G4NavigationLogger.hh.

Referenced by G4VoxelNavigation::SetVerboseLevel().

81 { fVerbose = level; }

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