Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/geometry/navigation/src/G4NavigationLogger.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /geometry/navigation/src/G4NavigationLogger.cc (Version 11.3.0) and /geometry/navigation/src/G4NavigationLogger.cc (Version 6.0)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 // class G4NavigationLogger Implementation        
 27 //                                                
 28 // Author: G.Cosmo, 2010                          
 29 // -------------------------------------------    
 30                                                   
 31 #include <iomanip>                                
 32 #include <CLHEP/Units/SystemOfUnits.h>            
 33                                                   
 34 #include "G4NavigationLogger.hh"                  
 35 #include "G4GeometryTolerance.hh"                 
 36                                                   
 37 using CLHEP::millimeter;                          
 38                                                   
 39 G4NavigationLogger::G4NavigationLogger(const G    
 40   : fId(id)                                       
 41 {                                                 
 42 }                                                 
 43                                                   
 44 G4NavigationLogger::~G4NavigationLogger() = de    
 45                                                   
 46 // *******************************************    
 47 // PreComputeStepLog                              
 48 // *******************************************    
 49 //                                                
 50 void                                              
 51 G4NavigationLogger::PreComputeStepLog(const G4    
 52                                             G4    
 53                                       const G4    
 54 {                                                 
 55   G4VSolid* motherSolid = motherPhysical->GetL    
 56   G4String fType = fId + "::ComputeStep()";       
 57                                                   
 58   if ( fVerbose == 1 || fVerbose > 4 )            
 59   {                                               
 60     G4cout << "*************** " << fType << "    
 61            << " VolType "                         
 62            << std::setw(15) << "Safety/mm" <<     
 63            << std::setw(15) << "Distance/mm" <    
 64            << std::setw(52) << "Position (loca    
 65            << " - Solid" << G4endl;               
 66     G4cout << "  Mother "                         
 67            << std::setw(15) << motherSafety /     
 68            << std::setw(15) << "N/C"        <<    
 69            << motherSolid->GetEntityType() <<     
 70            << G4endl;                             
 71   }                                               
 72   if ( motherSafety < 0.0 )                       
 73   {                                               
 74     std::ostringstream message;                   
 75     message << "Negative Safety In Voxel Navig    
 76             << "        Current solid " << mot    
 77             << " gave negative safety: " << mo    
 78             << "        for the current (local    
 79     message << " Solid info: " << *motherSolid    
 80     G4Exception(fType, "GeomNav0003", FatalExc    
 81   }                                               
 82   if( motherSolid->Inside(localPoint)==kOutsid    
 83   {                                               
 84     std::ostringstream message;                   
 85     message << "Point is outside Current Volum    
 86             << "          Point " << localPoin    
 87             << " is outside current volume '"     
 88             << "'" << G4endl;                     
 89     G4double estDistToSolid= motherSolid->Dist    
 90     message << "          Estimated isotropic     
 91             << estDistToSolid << G4endl;          
 92     if( estDistToSolid > 100.0 * motherSolid->    
 93     {                                             
 94       message << " Solid info: " << *motherSol    
 95       G4Exception(fType, "GeomNav0003", JustWa    
 96                   "Point is far outside Curren    
 97     }                                             
 98     else                                          
 99     {                                             
100       G4Exception(fType, "GeomNav1001", JustWa    
101                   "Point is a little outside C    
102     }                                             
103   }                                               
104                                                   
105   // Verification / verbosity                     
106   //                                              
107   if ( fVerbose > 1 )                             
108   {                                               
109     static const G4int precVerf = 16;  // Prec    
110     G4long oldprec = G4cout.precision(precVerf    
111     G4cout << " - Information on mother / key     
112     G4cout << "  Type   " << std::setw(12) <<     
113            << std::setw(3*(6+precVerf))    <<     
114            << std::setw(4+precVerf)        <<     
115            << std::setw(4+precVerf)        <<     
116            << std::setw(17)                <<     
117            << std::setw(3*(6+precVerf))    <<     
118            << G4endl;                             
119     G4cout << "  Mother " << std::setw(12) <<     
120            << std::setw(4+precVerf)        <<     
121            << std::setw(4+precVerf)        <<     
122            << G4endl;                             
123     G4cout.precision(oldprec);                    
124   }                                               
125 }                                                 
126                                                   
127 // *******************************************    
128 // AlongComputeStepLog                            
129 // *******************************************    
130 //                                                
131 void                                              
132 G4NavigationLogger::AlongComputeStepLog(const     
133                                         const     
134                                         const     
135                                         const     
136                                                   
137                                                   
138 {                                                 
139   // Check to see that the resulting point is     
140   // This check could eventually be made only     
141                                                   
142   if ( sampleStep < kInfinity )                   
143   {                                               
144     G4ThreeVector intersectionPoint;              
145     intersectionPoint = samplePoint + sampleSt    
146     EInside insideIntPt = sampleSolid->Inside(    
147     G4String fType = fId + "::ComputeStep()";     
148                                                   
149     G4String solidResponse = "-kInside-";         
150     if (insideIntPt == kOutside)                  
151       { solidResponse = "-kOutside-"; }           
152     else if (insideIntPt == kSurface)             
153       { solidResponse = "-kSurface-"; }           
154                                                   
155     if ( fVerbose == 1 || fVerbose > 4 )          
156     {                                             
157       G4cout << "    Invoked Inside() for soli    
158              << sampleSolid->GetName()            
159              << ". Solid replied: " << solidRe    
160              << "    For point p: " << interse    
161              << ", considered as 'intersection    
162     }                                             
163                                                   
164     G4double safetyIn = -1, safetyOut = -1;  /    
165     G4double newDistIn = -1,  newDistOut = -1;    
166     if( insideIntPt != kInside )                  
167     {                                             
168       safetyIn = sampleSolid->DistanceToIn(int    
169       newDistIn = sampleSolid->DistanceToIn(in    
170                                             sa    
171     }                                             
172     if( insideIntPt != kOutside )                 
173     {                                             
174       safetyOut = sampleSolid->DistanceToOut(i    
175       newDistOut = sampleSolid->DistanceToOut(    
176                                                   
177     }                                             
178     if( insideIntPt != kSurface )                 
179     {                                             
180       std::ostringstream message;                 
181       message.precision(16);                      
182       message << "Conflicting response from So    
183               << "          Inaccurate solid D    
184               << " for solid " << sampleSolid-    
185               << "          Solid gave Distanc    
186               << sampleStep << " yet returns "    
187               << " for this point !" << G4endl    
188               << "          Original Point        
189               << "          Original Direction    
190               << "          Intersection Point    
191               << "            Safety values: "    
192       if ( insideIntPt != kInside )               
193       {                                           
194         message << "          DistanceToIn(p)     
195       }                                           
196       if ( insideIntPt != kOutside )              
197       {                                           
198         message << "          DistanceToOut(p)    
199       }                                           
200       message << G4endl;                          
201       message << " Solid Parameters: " << *sam    
202       G4Exception(fType, "GeomNav1001", JustWa    
203     }                                             
204     else                                          
205     {                                             
206       // If it is on the surface, *ensure* tha    
207       // or DistanceToOut returns a finite val    
208       //                                          
209       if( std::max( newDistIn, newDistOut ) <=    
210           G4GeometryTolerance::GetInstance()->    
211       {                                           
212         std::ostringstream message;               
213         message << "Zero from both Solid Dista    
214                 << "  Identified point for whi    
215                 << sampleSolid->GetName() << G    
216                 << "  has MAJOR problem:  " <<    
217                 << "  --> Both DistanceToIn(p,    
218                 << "return Zero, an equivalent    
219                 << G4endl                         
220                 << "    Solid: " << sampleSoli    
221                 << "    Point p= " << intersec    
222                 << "    Direction v= " << samp    
223                 << "    DistanceToIn(p,v)         
224                 << "    DistanceToOut(p,v,..)     
225                 << "    Safety values: " << G4    
226                 << "      DistanceToIn(p)  = "    
227                 << "      DistanceToOut(p) = "    
228         G4Exception(fType, "GeomNav0003", Fata    
229       }                                           
230     }                                             
231                                                   
232     // Verification / verbosity                   
233     //                                            
234     if ( fVerbose > 1 )                           
235     {                                             
236       static const G4int precVerf= 20;  // Pre    
237       G4long oldprec = G4cout.precision(precVe    
238       G4cout << "Daughter "                       
239              << std::setw(12)         << sampl    
240              << std::setw(4+precVerf) << sampl    
241              << std::setw(4+precVerf) << sampl    
242              << std::setw(4+precVerf) << sampl    
243              << std::setw(16)         << "dist    
244              << std::setw(4+precVerf) << local    
245              << G4endl;                           
246       G4cout.precision(oldprec);                  
247     }                                             
248   }                                               
249 }                                                 
250                                                   
251 // *******************************************    
252 // CheckDaughterEntryPoint                        
253 // *******************************************    
254 //                                                
255 void                                              
256 G4NavigationLogger::CheckDaughterEntryPoint(co    
257                                             co    
258                                             co    
259                                             co    
260                                             co    
261                                             co    
262                                                   
263                                                   
264 {                                                 
265   const G4double kCarTolerance = motherSolid->    
266                                                   
267   // Double check the expected condition of be    
268   //                                              
269   G4bool SuspiciousDaughterDist = ( sampleStep    
270                                && ( sampleStep    
271                                                   
272   if( sampleStep >= kInfinity )                   
273   {                                               
274     G4ExceptionDescription msg;                   
275     msg.precision(12);                            
276     msg << " WARNING - Called with 'infinite'     
277     msg << "    Checks have no meaning if daug    
278     msg << "    kInfinity  = " << kInfinity  /    
279     msg << "    sampleStep = " << sampleStep /    
280     msg << "    sampleStep < kInfinity " << (s    
281     msg << "    kInfinity - sampleStep " << (k    
282     msg << " Returning immediately.";             
283     G4Exception("G4NavigationLogger::CheckDaug    
284                 "GeomNav0003", JustWarning, ms    
285     return;                                       
286   }                                               
287                                                   
288   // The intersection point with the daughter     
289   // from the mother volume !!                    
290   // This is legal / allowed to occur only if     
291   // *****************************************    
292   // If mother is convex the daughter volume m    
293   // before the exit from the current volume!     
294                                                   
295   // Check #1) whether the track will re-enter    
296   //           in the extension past its curre    
297   G4ThreeVector localExitMotherPos = localPoin    
298   G4double distExitToReEntry = motherSolid->Di    
299                                                   
300                                                   
301   // Check #2) whether the 'entry' point in th    
302   //                                              
303   G4ThreeVector localEntryInDaughter = localPo    
304   EInside insideMother = motherSolid->Inside(     
305                                                   
306   G4String solidResponse = "-kInside-";           
307   if (insideMother == kOutside)       { solidR    
308   else if (insideMother == kSurface)  { solidR    
309                                                   
310   G4double       distToReEntry = distExitToReE    
311   G4ThreeVector  localReEntryPoint = localPoin    
312                                                   
313   // Clear error  -- Daughter entry point is b    
314   constexpr G4double eps= 1.0e-10;                
315   G4bool DaughterEntryIsOutside = SuspiciousDa    
316      && ( (sampleStep * (1.0+eps) < distToReEn    
317   G4bool EntryIsMotherExit = std::fabs(sampleS    
318                                                   
319   // Check for more subtle error - is exit poi    
320   G4ThreeVector sampleEntryPoint = samplePoint    
321   G4double sampleCrossingDist = sampleSolid->D    
322                                                   
323   G4double      sampleExitDist = sampleStep+sa    
324   G4ThreeVector sampleExitPoint = samplePoint+    
325                                                   
326   G4bool TransitProblem = ( (sampleStep < moth    
327                          && (sampleExitDist >     
328            || ( EntryIsMotherExit && (sampleCr    
329                                                   
330   if( DaughterEntryIsOutside                      
331        || TransitProblem                          
332        || (SuspiciousDaughterDist && (fVerbose    
333   {                                               
334     G4ExceptionDescription msg;                   
335     msg.precision(16);                            
336                                                   
337     if( DaughterEntryIsOutside )                  
338     {                                             
339       msg << "WARNING> Intersection distance t    
340           <<    " than the distance to boundar    
341           << "  It appears that part of the da    
342           <<    " this mother. " << G4endl;       
343       msg << "  One of the following checks si    
344           << "  -sampleStep (dist to daugh) <     
345           <<      "to ReEntry point for mother    
346           << "  -position of daughter intersec    
347           << G4endl;                              
348     }                                             
349     else if( TransitProblem )                     
350     {                                             
351       G4double protrusion = sampleExitDist - m    
352                                                   
353       msg << "WARNING>  Daughter volume extend    
354           << G4endl;                              
355       if ( ( sampleStep < motherStep )            
356         && (sampleExitDist > motherStep + kCar    
357       {                                           
358         // 1st Issue with Daughter                
359         msg << "        Crossing distance in t    
360             << " beyond the mother exit. " <<     
361         msg << "        Length protruding = "     
362       }                                           
363       if( EntryIsMotherExit )                     
364       {                                           
365         // 1st Issue with Daughter                
366         msg << "        Intersection distance     
367             << " tolerance of the distance" <<    
368         msg << "        to the mother boundary    
369         msg << "        the crossing distance     
370             << G4endl;                            
371       }                                           
372     }                                             
373     else                                          
374     {                                             
375       msg << "NearMiss> Intersection to Daught    
376           <<   " current exit point of the mot    
377       msg << "          This is not an error -    
378           <<   " possible in the case of conca    
379     }                                             
380     msg << "---- Information about intersectio    
381         << G4endl;                                
382     msg << "    sampleStep (daughter) = " << s    
383         << "    motherStep            = " << m    
384         << "    distToRentry(mother)  = " << d    
385         << "    Inside(entry pnt daug): " << s    
386         << "    dist across daughter  = " << s    
387     msg << " Mother Name (Solid) : " << mother    
388         << " In local (mother) coordinates: "     
389         << "    Starting     Point    = " << l    
390         << "    Direction             = " << l    
391         << "    Exit Point    (mother)= " << l    
392         << "    Entry Point (daughter)= " << l    
393         << G4endl;                                
394     if( distToReEntry < kInfinity )               
395     {                                             
396       msg << "    ReEntry Point (mother)= " <<    
397     }                                             
398     else                                          
399     {                                             
400       msg << "    No ReEntry - track does not     
401           << G4endl;                              
402     }                                             
403     msg << " Daughter Name (Solid): " << sampl    
404         << " In daughter coordinates: " << G4e    
405         << "    Starting     Point    = " << s    
406         << "    Direction             = " << s    
407         << "    Entry Point (daughter)= " << s    
408         << G4endl;                                
409     msg << "  Description of mother solid: " <    
410         << *motherSolid << G4endl                 
411         << "  Description of daughter solid: "    
412         << *sampleSolid << G4endl;                
413     G4String fType = fId + "::ComputeStep()";     
414                                                   
415     if( DaughterEntryIsOutside || TransitProbl    
416     {                                             
417       G4Exception(fType, "GeomNav0003", JustWa    
418     }                                             
419     else                                          
420     {                                             
421       G4cout << fType                             
422              << " -- Checked distance of Entry    
423              << G4endl;                           
424       G4cout << msg.str();                        
425       G4cout << G4endl;                           
426     }                                             
427   }                                               
428 }                                                 
429                                                   
430 // *******************************************    
431 // PostComputeStepLog                             
432 // *******************************************    
433 //                                                
434 void                                              
435 G4NavigationLogger::PostComputeStepLog(const G    
436                                        const G    
437                                        const G    
438                                              G    
439                                              G    
440 {                                                 
441   if ( fVerbose == 1 || fVerbose > 4 )            
442   {                                               
443     G4cout << "  Mother "                         
444            << std::setw(15) << motherSafety <<    
445            << std::setw(15) << motherStep   <<    
446            << motherSolid->GetEntityType() <<     
447            << G4endl;                             
448   }                                               
449   if( ( motherStep < 0.0 ) || ( motherStep >=     
450   {                                               
451     G4String fType = fId + "::ComputeStep()";     
452     G4long oldPrOut = G4cout.precision(16);       
453     G4long oldPrErr = G4cerr.precision(16);       
454     std::ostringstream message;                   
455     message << "Current point is outside the c    
456             << "        Problem in Navigation"    
457             << "        Point (local coordinat    
458             << localPoint << G4endl               
459             << "        Local Direction: " <<     
460             << "        Solid: " << motherSoli    
461     motherSolid->DumpInfo();                      
462     G4Exception(fType, "GeomNav0003", FatalExc    
463     G4cout.precision(oldPrOut);                   
464     G4cerr.precision(oldPrErr);                   
465   }                                               
466   if ( fVerbose > 1 )                             
467   {                                               
468     static const G4int precVerf = 20;  // Prec    
469     G4long oldprec = G4cout.precision(precVerf    
470     G4cout << "  Mother " << std::setw(12) <<     
471            << std::setw(4+precVerf)       << l    
472            << std::setw(4+precVerf)       << m    
473            << std::setw(4+precVerf)       << m    
474            << std::setw(16)               << "    
475            << std::setw(4+precVerf)       << l    
476            << G4endl;                             
477     G4cout.precision(oldprec);                    
478   }                                               
479 }                                                 
480                                                   
481 // *******************************************    
482 // ComputeSafetyLog                               
483 // *******************************************    
484 //                                                
485 void                                              
486 G4NavigationLogger::ComputeSafetyLog(const G4V    
487                                      const G4T    
488                                            G4d    
489                                            G4b    
490                                            G4i    
491 {                                                 
492   if( banner < 0 )                                
493   {                                               
494     banner = static_cast<G4int>(isMotherVolume    
495   }                                               
496   if( fVerbose >= 1 )                             
497   {                                               
498     G4String volumeType = isMotherVolume ? " M    
499     if (banner != 0)                              
500     {                                             
501       G4cout << "************** " << fId << ":    
502              << G4endl;                           
503       G4cout << " VolType "                       
504              << std::setw(15) << "Safety/mm" <    
505              << std::setw(52) << "Position (lo    
506              << " - Solid" << G4endl;             
507     }                                             
508     G4cout << volumeType                          
509            << std::setw(15) << safety << " " <    
510            << solid->GetEntityType() << ": " <    
511   }                                               
512 }                                                 
513                                                   
514 // *******************************************    
515 // PrintDaughterLog                               
516 // *******************************************    
517 //                                                
518 void                                              
519 G4NavigationLogger::PrintDaughterLog (const G4    
520                                       const G4    
521                                             G4    
522                                             G4    
523                                       const G4    
524 {                                                 
525   if ( fVerbose >= 1 )                            
526   {                                               
527     G4long oldPrec = G4cout.precision(8);         
528     G4cout << "Daughter "                         
529            << std::setw(15) << sampleSafety <<    
530     if (withStep)  // (sampleStep != -1.0 )       
531     {                                             
532       G4cout << std::setw(15) << sampleStep <<    
533     }                                             
534     else                                          
535     {                                             
536       G4cout << std::setw(15) << "Not-Availabl    
537     }                                             
538     G4cout << samplePoint   << " - "              
539            << sampleSolid->GetEntityType() <<     
540     if( withStep )                                
541     {                                             
542       G4cout << " dir= " << sampleDirection;      
543     }                                             
544     G4cout << G4endl;                             
545     G4cout.precision(oldPrec);                    
546   }                                               
547 }                                                 
548                                                   
549 // *******************************************    
550 // CheckAndReportBadNormal                        
551 // *******************************************    
552 //                                                
553 G4bool                                            
554 G4NavigationLogger::                              
555 CheckAndReportBadNormal(const G4ThreeVector& u    
556                         const G4ThreeVector& l    
557                         const G4ThreeVector& l    
558                               G4double            
559                         const G4VSolid*      s    
560                         const char*          m    
561 {                                                 
562   G4double normMag2 = unitNormal.mag2();          
563   G4bool badLength = ( std::fabs ( normMag2 -     
564                                                   
565   if( badLength )                                 
566   {                                               
567     G4double  normMag = std::sqrt(normMag2);      
568     G4ExceptionDescription message;               
569     message.precision(10);                        
570     message << "==============================    
571             << G4endl;                            
572     message << " WARNING>  Normal is not a uni    
573             << "  - but |normal|   = "  << nor    
574             << "  - and |normal|^2     = "  <<    
575             << "    which differ from 1.0 by:     
576             << "        |normal|-1 = " << norm    
577             << "    and |normal|^2 - 1 = " <<     
578             << "   n = " << unitNormal << G4en    
579     message << " Info string: " << msg << G4en    
580     message << "==============================    
581             << G4endl;                            
582                                                   
583     message.precision(16);                        
584                                                   
585     message << " Information on call to Distan    
586     message << "   Position  = " << localPoint    
587             << "   Direction = " << localDirec    
588     message << "   Obtained> distance      = "    
589     message << "           > Exit position = "    
590             << G4endl;                            
591     message << " Parameters of solid:     " <<    
592     message << *solid;                            
593     message << "==============================    
594                                                   
595     G4String fMethod = fId + "::ComputeStep()"    
596     G4Exception( fMethod, "GeomNav0003", JustW    
597   }                                               
598   return badLength;                               
599 }                                                 
600                                                   
601 // *******************************************    
602 // CheckAndReportBadNormal - due to Rotation M    
603 // *******************************************    
604 //                                                
605 G4bool                                            
606 G4NavigationLogger::                              
607 CheckAndReportBadNormal(const G4ThreeVector& r    
608                         const G4ThreeVector& o    
609                         const G4RotationMatrix    
610                         const char*          m    
611 {                                                 
612   G4double  normMag2 = rotatedNormal.mag2();      
613   G4bool badLength = ( std::fabs ( normMag2 -     
614                                                   
615   if( badLength )                                 
616   {                                               
617     G4double  normMag = std::sqrt(normMag2);      
618     G4ExceptionDescription message;               
619     message.precision(10);                        
620     message << "==============================    
621             << G4endl;                            
622     message << " WARNING>  Rotated n(ormal) is    
623             << "     |normal|   = "  << normMa    
624             << "   and |normal|^2     = "  <<     
625             << "   Diff from 1.0: " <<  G4endl    
626             << "     |normal|-1 = " << normMag    
627             << "   and |normal|^2 - 1 = " << n    
628     message << "   Rotated  n = (" << rotatedN    
629             << rotatedNormal.z() << ")" << G4e    
630     message << "   Original n = (" << original    
631             << originalNormal.z() << ")" << G4    
632     message << " Info string: " << msg << G4en    
633     message << "==============================    
634             << G4endl;                            
635                                                   
636     message.precision(16);                        
637                                                   
638     message << " Information on RotationMatrix    
639     message << " Original: " << G4endl;           
640     message << rotationM << G4endl;               
641     message << " Inverse (used in transformati    
642     message << rotationM.inverse() << G4endl;     
643     message << "==============================    
644                                                   
645     G4String fMethod = fId + "::ComputeStep()"    
646     G4Exception( fMethod, "GeomNav0003", JustW    
647   }                                               
648   return badLength;                               
649 }                                                 
650                                                   
651 // *******************************************    
652 // ReportOutsideMother                            
653 // *******************************************    
654 //                                                
655 // Report Exception if point is outside mother    
656 // Fatal exception will be used if either 'che    
657 //                                                
658 void                                              
659 G4NavigationLogger::ReportOutsideMother(const     
660                                         const     
661                                         const     
662                                                   
663 {                                                 
664   const G4LogicalVolume* logicalVol = physical    
665                                     ? physical    
666   const G4VSolid* solid = logicalVol != nullpt    
667                         ? logicalVol->GetSolid    
668                                                   
669   G4String fMethod = fId + "::ComputeStep()";     
670                                                   
671   if( solid == nullptr )                          
672   {                                               
673     G4Exception(fMethod, "GeomNav0003", FatalE    
674                 "Erroneous call to ReportOutsi    
675     return;                                       
676   }                                               
677   const G4double kCarTolerance = solid->GetTol    
678                                                   
679   // Double check reply - it should be kInfini    
680   const G4double distToOut = solid->DistanceTo    
681   const EInside  inSolid   = solid->Inside(loc    
682   const G4double safetyToIn  = solid->Distance    
683   const G4double safetyToOut = solid->Distance    
684   // const G4double distToInPos =                 
685   //                solid->DistanceToIn(localP    
686                                                   
687   // 1. Check consistency between Safety obtai    
688   //     We must ensure that (mother)Safety <=    
689   //       in the case that the point is outsi    
690   //    [ If this is not the case, this proble    
691   //       except in Check mode ! ]               
692   if( safetyToOut > kCarTolerance                 
693       && ( distToOut < 0.0 || distToOut >= kIn    
694   {                                               
695      G4ExceptionDescription msg1;                 
696      // fNavClerk->ReportBadSafety(localPoint,    
697      //                     motherPhysical, mo    
698      msg1 << " Dangerous inconsistency in resp    
699           << "    Solid type: " << solid->GetE    
700           << "    Name= " << solid->GetName()     
701      msg1 << " Mother volume gives safety > 0     
702           << G4endl                               
703           << "   Location = " << localPoint       
704           << "   Direction= " << localDirectio    
705           << "   - Safety (Isotropic d) = " <<    
706           << "   - Intersection Distance= " <<    
707           << G4endl;                              
708      G4Exception( fMethod, "GeomNav0123", Just    
709   }                                               
710                                                   
711   // 2. Inconsistency - Too many distances are    
712                                                   
713 //  if( std::fabs(distToOut) < kCarTolerance      
714 //   && std::fabs(distToInPos) < kCarTolerance    
715 //  {                                             
716      // If both distanceToIn and distanceToOut    
717      // one direction, the particle could get     
718 //  }                                             
719                                                   
720   G4ExceptionDescription msg;                     
721   msg.precision(10);                              
722                                                   
723   if( std::fabs(distToOut) < kCarTolerance )      
724   {                                               
725     // 3. Soft error - safety is not rounded t    
726     //    Report nothing - except in 'loud' mo    
727     if( fReportSoftWarnings )                     
728     {                                             
729       msg << " Warning>  DistanceToOut(p,v): "    
730           << "Distance from surface is not rou    
731     }                                             
732     else                                          
733     {                                             
734       return;                                     
735     }                                             
736   }                                               
737   else                                            
738   {                                               
739     // 4. General message - complain that the     
740     //     and provide all information about t    
741     //     direction and the answers of the so    
742     msg << "==================================    
743         << G4endl;                                
744     msg << " WARNING>  Current Point appears t    
745         << G4endl;                                
746     msg << "   Response of DistanceToOut was n    
747         << " when called in " << fMethod << G4    
748   }                                               
749                                                   
750   // Generate and 'print'/stream all the infor    
751   this->ReportVolumeAndIntersection(msg, local    
752                                                   
753   // Default for distance of 'major' error        
754   if( triggerDist <= 0.0 )                        
755   {                                               
756     triggerDist = std::max ( 1.0e+6 * kCarTole    
757                              fMinTriggerDistan    
758   }                                               
759                                                   
760   G4bool majorError = inSolid == kOutside         
761                     ? ( safetyToIn > triggerDi    
762                     : ( safetyToOut > triggerD    
763                                                   
764   G4ExceptionSeverity exceptionType = JustWarn    
765   if ( majorError )                               
766   {                                               
767     exceptionType = FatalException;               
768   }                                               
769                                                   
770   G4Exception( fMethod, "GeomNav0003", excepti    
771 }                                                 
772                                                   
773 namespace  G4NavigationLogger_Namespace           
774 {                                                 
775   const G4String EInsideNames[3] = { "kOutside    
776 }                                                 
777                                                   
778 void G4NavigationLogger::                         
779 ReportVolumeAndIntersection( std::ostream& os,    
780                              const G4ThreeVect    
781                              const G4ThreeVect    
782                              const G4VPhysical    
783 {                                                 
784   G4String fMethod = fId + "::ComputeStep()";     
785   const G4LogicalVolume* logicalVol = physical    
786                                     ? physical    
787   const G4VSolid* solid = logicalVol != nullpt    
788                         ? logicalVol->GetSolid    
789   if( solid == nullptr )                          
790   {                                               
791      os << " ERROR> Solid is not available. Lo    
792         << logicalVol << std::endl;               
793      return;                                      
794   }                                               
795   const G4double kCarTolerance = solid->GetTol    
796                                                   
797   // Double check reply - it should be kInfini    
798   const G4double distToOut = solid->DistanceTo    
799   const G4double distToOutNeg = solid->Distanc    
800                                                   
801   const EInside  inSolid   = solid->Inside(loc    
802   const G4double safetyToIn  = solid->Distance    
803   const G4double safetyToOut = solid->Distance    
804                                                   
805   const G4double distToInPos = solid->Distance    
806   const G4double distToInNeg = solid->Distance    
807                                                   
808   const G4ThreeVector exitNormal = solid->Surf    
809                                                   
810   // Double check whether points nearby are in    
811   const G4double epsilonDist = 1000.0 * kCarTo    
812   const G4ThreeVector PointPlusDir = localPoin    
813   const G4ThreeVector PointMinusDir = localPoi    
814   const G4ThreeVector PointPlusNorm = localPoi    
815   const G4ThreeVector PointMinusNorm = localPo    
816                                                   
817   const EInside inPlusDir = solid->Inside(Poin    
818   const EInside inMinusDir = solid->Inside(Poi    
819   const EInside inPlusNorm = solid->Inside(Poi    
820   const EInside inMinusNorm = solid->Inside(Po    
821                                                   
822   // Basic information                            
823   os << "   Current physical volume = " << phy    
824   os << "   Position (loc)  = " << localPoint     
825      << "   Direction (dir) = " << localDirect    
826   os << " For confirmation:" << G4endl;           
827   os << "   Response of DistanceToOut (loc, +d    
828   os << "   Response of DistanceToOut (loc, -d    
829                                                   
830   os << "   Inside responds = " << inSolid <<     
831   if( inSolid == kOutside )                       
832   {                                               
833     os << " Outside -- a problem, as observed     
834   }                                               
835   else if( inSolid == kSurface )                  
836   {                                               
837     os << " Surface -- unexpected / inconsiste    
838   }                                               
839   else                                            
840   {                                               
841     os << " Inside  -- unexpected / inconsiste    
842   }                                               
843   os << "   Obtain safety(ToIn) = " << safetyT    
844   os << "   Obtain safety(ToOut) = " << safety    
845   os << " Response of DistanceToIn (loc, +dir)    
846   os << " Response of DistanceToIn (loc, -dir)    
847                                                   
848   os << " Exit Normal at loc = " << exitNormal    
849   os << "     Dir . Normal   = " << exitNormal    
850   os << G4endl;                                   
851                                                   
852   os << " Checking points moved from position     
853      << " Solid responses: " << G4endl            
854      << "  +eps in direction :    "               
855      << G4NavigationLogger_Namespace::EInsideN    
856      << "  +eps in Normal  :    "                 
857      << G4NavigationLogger_Namespace::EInsideN    
858      << "  -eps in direction :    "               
859      << G4NavigationLogger_Namespace::EInsideN    
860      << "  -eps in Normal  :    "                 
861      << G4NavigationLogger_Namespace::EInsideN    
862                                                   
863   os << " Parameters of solid:     " << G4endl    
864   os << *solid;                                   
865   os << "=====================================    
866 }                                                 
867