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.

00042   : fId(id), fVerbose(0)
00043 {
00044 }

G4NavigationLogger::~G4NavigationLogger (  ) 

Definition at line 46 of file G4NavigationLogger.cc.

00047 {
00048 }


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(), G4GeometryTolerance::GetInstance(), G4VSolid::GetName(), G4VSolid::Inside(), JustWarning, kInside, kOutside, and kSurface.

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

00131 {
00132   // Check to see that the resulting point is indeed in/on volume.
00133   // This check could eventually be made only for successful candidate.
00134 
00135   if ( sampleStep < kInfinity )
00136   {
00137     G4ThreeVector intersectionPoint;
00138     intersectionPoint= samplePoint + sampleStep * sampleDirection;
00139     EInside insideIntPt= sampleSolid->Inside(intersectionPoint); 
00140     G4String fType = fId + "::ComputeStep()";
00141 
00142     G4String solidResponse = "-kInside-";
00143     if (insideIntPt == kOutside)
00144       { solidResponse = "-kOutside-"; }
00145     else if (insideIntPt == kSurface)
00146       { solidResponse = "-kSurface-"; }
00147 
00148     if ( fVerbose == 1 )
00149     {
00150       G4cout << "    Invoked Inside() for solid: "
00151              << sampleSolid->GetName()
00152              << ". Solid replied: " << solidResponse << G4endl
00153              << "    For point p: " << intersectionPoint
00154              << ", considered as 'intersection' point." << G4endl;
00155     }
00156 
00157     G4double safetyIn= -1, safetyOut= -1;  //  Set to invalid values
00158     G4double newDistIn= -1,  newDistOut= -1;
00159     if( insideIntPt != kInside )
00160     {
00161       safetyIn= sampleSolid->DistanceToIn(intersectionPoint);
00162       newDistIn= sampleSolid->DistanceToIn(intersectionPoint,
00163                                            sampleDirection);
00164     }
00165     if( insideIntPt != kOutside )
00166     {
00167       safetyOut= sampleSolid->DistanceToOut(intersectionPoint);
00168       newDistOut= sampleSolid->DistanceToOut(intersectionPoint,
00169                                              sampleDirection);
00170     }
00171     if( insideIntPt != kSurface )
00172     {
00173       G4int oldcoutPrec = G4cout.precision(16); 
00174       std::ostringstream message;
00175       message << "Conflicting response from Solid." << G4endl
00176               << "          Inaccurate solid DistanceToIn"
00177               << " for solid " << sampleSolid->GetName() << G4endl
00178               << "          Solid gave DistanceToIn = "
00179               << sampleStep << " yet returns " << solidResponse
00180               << " for this point !" << G4endl
00181               << "          Point = " << intersectionPoint << G4endl
00182               << "          Safety values: " << G4endl;
00183       if ( insideIntPt != kInside )
00184       {
00185         message << "          DistanceToIn(p)  = " << safetyIn;
00186       }
00187       if ( insideIntPt != kOutside )
00188       {
00189         message << "          DistanceToOut(p) = " << safetyOut;
00190       }
00191       G4Exception(fType, "GeomNav1001", JustWarning, message);
00192       G4cout.precision(oldcoutPrec);
00193     }
00194     else
00195     {  
00196       // If it is on the surface, *ensure* that either DistanceToIn
00197       // or DistanceToOut returns a finite value ( >= Tolerance).
00198       //
00199       if( std::max( newDistIn, newDistOut ) <=
00200           G4GeometryTolerance::GetInstance()->GetSurfaceTolerance() )
00201       { 
00202         std::ostringstream message;
00203         message << "Zero from both Solid DistanceIn and Out(p,v)." << G4endl
00204                 << "  Identified point for which the solid " 
00205                 << sampleSolid->GetName() << G4endl
00206                 << "  has MAJOR problem:  " << G4endl
00207                 << "  --> Both DistanceToIn(p,v) and DistanceToOut(p,v) "
00208                 << "return Zero, an equivalent value or negative value."
00209                 << G4endl 
00210                 << "    Solid: " << sampleSolid << G4endl
00211                 << "    Point p= " << intersectionPoint << G4endl
00212                 << "    Direction v= " << sampleDirection << G4endl
00213                 << "    DistanceToIn(p,v)     = " << newDistIn << G4endl
00214                 << "    DistanceToOut(p,v,..) = " << newDistOut << G4endl
00215                 << "    Safety values: " << G4endl
00216                 << "      DistanceToIn(p)  = " << safetyIn << G4endl
00217                 << "      DistanceToOut(p) = " << safetyOut;
00218         G4Exception(fType, "GeomNav0003", FatalException, message);
00219       }
00220     }
00221 
00222     // Verification / verbosity
00223     //
00224     if ( fVerbose > 1 )
00225     {
00226       static G4int precVerf= 20;  // Precision 
00227       G4int oldprec = G4cout.precision(precVerf);
00228       G4cout << "Daughter "
00229              << std::setw(12)         << sampleSolid->GetName() << " "
00230              << std::setw(4+precVerf) << samplePoint  << " "
00231              << std::setw(4+precVerf) << sampleSafety << " "
00232              << std::setw(4+precVerf) << sampleStep   << " "
00233              << std::setw(16)         << "distanceToIn" << " "
00234              << std::setw(4+precVerf) << localDirection << " "
00235              << G4endl;
00236       G4cout.precision(oldprec);
00237     }
00238   }
00239 }

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 G4VoxelNavigation::ComputeSafety(), and G4NormalNavigation::ComputeSafety().

00293 {
00294   G4String volumeType = "Daughter ";
00295   if (banner)
00296   {
00297     G4cout << "************** " << fId << "::ComputeSafety() ****************" << G4endl;
00298     G4cout << " VolType "
00299            << std::setw(15) << "Safety/mm" << " "
00300            << std::setw(52) << "Position (local coordinates)"
00301            << " - Solid" << G4endl;
00302     volumeType = "  Mother ";
00303   }
00304   G4cout << volumeType
00305          << std::setw(15) << safety << " " << point  << " - "
00306          << solid->GetEntityType() << ": " << solid->GetName() << G4endl;
00307 }

G4int G4NavigationLogger::GetVerboseLevel (  )  const [inline]

Definition at line 80 of file G4NavigationLogger.hh.

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

00080 { 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(), G4VSolid::GetEntityType(), and G4VSolid::GetName().

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

00247 {
00248   if( fVerbose == 1 )
00249   {
00250     G4cout << "  Mother "
00251            << std::setw(15) << motherSafety << " " 
00252            << std::setw(15) << motherStep   << " " << localPoint   << " - "
00253            << motherSolid->GetEntityType() << ": " << motherSolid->GetName()
00254            << G4endl;
00255   }
00256   if( ( motherStep < 0.0 ) || ( motherStep >= kInfinity) )
00257   {
00258     G4String fType = fId + "::ComputeStep()";
00259     G4int oldPrOut= G4cout.precision(16); 
00260     G4int oldPrErr= G4cerr.precision(16);
00261     std::ostringstream message;
00262     message << "Current point is outside the current solid !" << G4endl
00263             << "        Problem in Navigation"  << G4endl
00264             << "        Point (local coordinates): "
00265             << localPoint << G4endl
00266             << "        Local Direction: " << localDirection << G4endl
00267             << "        Solid: " << motherSolid->GetName(); 
00268     motherSolid->DumpInfo();
00269     G4Exception(fType, "GeomNav0003", FatalException, message);
00270     G4cout.precision(oldPrOut);
00271     G4cerr.precision(oldPrErr);
00272   }
00273   if ( fVerbose > 1 )
00274   {
00275     static G4int precVerf= 20;  // Precision 
00276     G4int oldprec = G4cout.precision(precVerf);
00277     G4cout << "  Mother " << std::setw(12) << motherSolid->GetName() << " "
00278            << std::setw(4+precVerf)       << localPoint   << " "
00279            << std::setw(4+precVerf)       << motherSafety << " "
00280            << std::setw(4+precVerf)       << motherStep   << " "
00281            << std::setw(16)               << "distanceToOut" << " "
00282            << std::setw(4+precVerf)       << localDirection << " "
00283            << G4endl;
00284     G4cout.precision(oldprec);      
00285   }
00286 }

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(), G4VSolid::GetEntityType(), G4VPhysicalVolume::GetLogicalVolume(), G4VPhysicalVolume::GetName(), G4VSolid::GetName(), G4LogicalVolume::GetSolid(), G4VSolid::GetTolerance(), G4VSolid::Inside(), JustWarning, and kOutside.

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

00054 {
00055     G4VSolid* motherSolid = motherPhysical->GetLogicalVolume()->GetSolid();
00056     G4String fType = fId + "::ComputeStep()";
00057     if( fVerbose == 1 )
00058     {
00059       G4cout << "*************** " << fType << " *****************" << G4endl
00060              << " VolType "
00061              << std::setw(15) << "Safety/mm" << " "
00062              << std::setw(15) << "Distance/mm" << " "
00063              << std::setw(52) << "Position (local coordinates)"
00064              << " - Solid" << G4endl;
00065       G4cout << "  Mother "
00066              << std::setw(15) << motherSafety << " " 
00067              << std::setw(15) << "N/C"        << " " << localPoint << " - "
00068              << motherSolid->GetEntityType() << ": " << motherSolid->GetName()
00069              << G4endl;
00070     }
00071     if ( motherSafety < 0.0 )
00072     {
00073       std::ostringstream message;
00074       message << "Negative Safety In Voxel Navigation !" << G4endl
00075              << "        Current solid " << motherSolid->GetName()
00076              << " gave negative safety: " << motherSafety << G4endl
00077              << "        for the current (local) point " << localPoint;
00078       motherSolid->DumpInfo();
00079       G4Exception(fType, "GeomNav0003", FatalException, message);
00080     }
00081     if( motherSolid->Inside(localPoint)==kOutside )
00082     {
00083       std::ostringstream message;
00084       message << "Point is outside Current Volume - " << G4endl
00085               << "          Point " << localPoint
00086               << " is outside current volume " << motherPhysical->GetName()
00087               << G4endl;
00088       G4double estDistToSolid= motherSolid->DistanceToIn(localPoint); 
00089       message << "          Estimated isotropic distance to solid (distToIn)= " 
00090               << estDistToSolid;
00091       if( estDistToSolid > 100.0 * motherSolid->GetTolerance() )
00092       {
00093         motherSolid->DumpInfo();
00094         G4Exception(fType, "GeomNav0003", FatalException, message,
00095                     "Point is far outside Current Volume !" ); 
00096       }
00097       else
00098         G4Exception(fType, "GeomNav1001", JustWarning, message,
00099                     "Point is a little outside Current Volume."); 
00100     }
00101 
00102     // Verification / verbosity
00103     //
00104     if ( fVerbose > 1 )
00105     {
00106       static G4int precVerf= 20;  // Precision 
00107       G4int oldprec = G4cout.precision(precVerf);
00108       G4cout << " - Information on mother / key daughters ..." << G4endl;
00109       G4cout << "  Type   " << std::setw(12) << "Solid-Name"   << " " 
00110              << std::setw(3*(6+precVerf))    << " local point" << " "
00111              << std::setw(4+precVerf)        << "solid-Safety" << " "
00112              << std::setw(4+precVerf)        << "solid-Step"   << " "
00113              << std::setw(17)                << "distance Method "
00114              << std::setw(3*(6+precVerf))    << " local direction" << " "
00115              << G4endl;
00116       G4cout << "  Mother " << std::setw(12) << motherSolid->GetName() << " "
00117              << std::setw(4+precVerf)        << localPoint   << " "
00118              << std::setw(4+precVerf)        << motherSafety << " "
00119              << G4endl;
00120       G4cout.precision(oldprec);
00121     }
00122 }

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 G4VoxelNavigation::ComputeStep(), and G4NormalNavigation::ComputeStep().

00314 {
00315   if ( fVerbose == 1 )
00316   {
00317     G4cout << "Daughter "
00318            << std::setw(15) << sampleSafety << " ";
00319     if (sampleStep)
00320     {
00321       G4cout << std::setw(15) << sampleStep << " ";
00322     }
00323     else
00324     {
00325       G4cout << std::setw(15) << "N/C" << " ";
00326     }
00327     G4cout << samplePoint   << " - "
00328            << sampleSolid->GetEntityType() << ": " << sampleSolid->GetName()
00329            << G4endl;
00330   }
00331 }

void G4NavigationLogger::SetVerboseLevel ( G4int  level  )  [inline]

Definition at line 81 of file G4NavigationLogger.hh.

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

00081 { fVerbose = level; }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:52:33 2013 for Geant4 by  doxygen 1.4.7