Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/geometry/navigation/src/G4MultiNavigator.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/G4MultiNavigator.cc (Version 11.3.0) and /geometry/navigation/src/G4MultiNavigator.cc (Version 8.2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
                                                   >>  25 //
                                                   >>  26 //
                                                   >>  27 // $Id: G4MultiNavigator.cc,v 1.4 2006/11/14 15:41:56 japost Exp $
                                                   >>  28 // GEANT4 tag $ Name:  $
 25 //                                                 29 // 
 26 // class G4MultiNavigator Implementation       <<  30 // class G4PathFinder Implementation
 27 //                                                 31 //
 28 // Author:  John Apostolakis, November 2006        32 // Author:  John Apostolakis, November 2006
 29 // -------------------------------------------     33 // --------------------------------------------------------------------
 30                                                    34 
 31 #include <iomanip>                             << 
 32                                                << 
 33 #include "G4MultiNavigator.hh"                     35 #include "G4MultiNavigator.hh"
 34                                                    36 
 35 class G4FieldManager;                              37 class G4FieldManager;
 36                                                    38 
 37 #include "G4SystemOfUnits.hh"                  << 
 38 #include "G4Navigator.hh"                          39 #include "G4Navigator.hh"
 39 #include "G4PropagatorInField.hh"                  40 #include "G4PropagatorInField.hh"
 40 #include "G4TransportationManager.hh"              41 #include "G4TransportationManager.hh"
 41                                                    42 
 42 // ------------------------------------------- <<  43 #include <iomanip>
 43                                                    44 
 44 G4MultiNavigator::G4MultiNavigator()           <<  45 // ********************************************************************
 45 {                                              <<  46 // Constructor
 46   G4ThreeVector Big3Vector( kInfinity, kInfini <<  47 // ********************************************************************
 47   fLastLocatedPosition = Big3Vector;           <<  48 //
 48   fSafetyLocation  = Big3Vector;               <<  49 G4MultiNavigator::G4MultiNavigator() 
 49   fPreStepLocation = Big3Vector;               <<  50   // : fpActiveNavigators()
 50                                                <<  51   : G4Navigator(), 
 51   for(auto num=0; num< fMaxNav; ++num )        <<  52     fVerboseLevel(1)
 52   {                                            <<  53 {
 53     fpNavigator[num] = nullptr;                <<  54    fNoActiveNavigators= 0; 
 54     fLimitTruth[num] = false;                  <<  55    G4ThreeVector  Big3Vector( DBL_MAX, DBL_MAX, DBL_MAX ); 
 55     fLimitedStep[num] = kUndefLimited;         <<  56    fLastLocatedPosition= Big3Vector;
 56     fCurrentStepSize[num] = fNewSafety[num] =  <<  57    fSafetyLocation=  Big3Vector;
 57     fLocatedVolume[num] = nullptr;             <<  58    fPreStepLocation= Big3Vector;
 58   }                                            <<  59 
 59                                                <<  60    fMinSafety_PreStepPt=  -1.0; 
 60   pTransportManager= G4TransportationManager:: <<  61    fMinSafety_atSafLocation= -1.0; 
 61                                                <<  62    fMinSafety= -DBL_MAX;  
 62   G4Navigator* massNav= pTransportManager->Get <<  63    fMinStep=   -DBL_MAX;  
 63   if( massNav != nullptr )                     <<  64    // fNewTrack= false; 
 64   {                                            <<  65 
 65     G4VPhysicalVolume* pWorld= massNav->GetWor <<  66    G4int num;
 66     if( pWorld != nullptr )                    <<  67    for( num=0; num<= fMaxNav; ++num ) {
 67     {                                          <<  68       fpNavigator[num] =  0;   
 68       SetWorldVolume( pWorld );                <<  69       fLimitTruth[num] = false;
 69       fLastMassWorld = pWorld;                 <<  70       fLimitedStep[num] = kUndefLimited;
 70     }                                          <<  71       fCurrentStepSize[num] = -1.0; 
 71   }                                            <<  72       fLocatedVolume[num] = 0; 
 72 }                                              <<  73    }
                                                   >>  74    // fpNavigator= new[MaxNav] (G4Navigator*); 
 73                                                    75 
 74 // ------------------------------------------- <<  76    pTransportManager= G4TransportationManager::GetTransportationManager();
                                                   >>  77 
                                                   >>  78    // EndState = G4FieldTrack( G4ThreeVector(), G4ThreeVector(), 0., 0., 0., 0., 0.) ); 
                                                   >>  79    // fRelocatedPoint(
                                                   >>  80    // fLastStepNo= -1;  
                                                   >>  81 
                                                   >>  82    G4Navigator* massNav= pTransportManager->GetNavigatorForTracking();
                                                   >>  83    if( massNav ) { 
                                                   >>  84      G4VPhysicalVolume* pWorld= massNav->GetWorldVolume(); 
                                                   >>  85      if( pWorld ) { 
                                                   >>  86        this->SetWorldVolume( pWorld ); 
                                                   >>  87        fLastMassWorld= pWorld; 
                                                   >>  88      }
                                                   >>  89    }
                                                   >>  90 }
 75                                                    91 
 76 G4MultiNavigator::~G4MultiNavigator() = defaul <<  92 G4MultiNavigator::~G4MultiNavigator() 
                                                   >>  93 {
                                                   >>  94    // delete[] fpNavigator;
                                                   >>  95 }
 77                                                    96 
 78 // ------------------------------------------- <<  97 // static G4int lastStepNo= -1;
                                                   >>  98   // To find the field do not forget to call
                                                   >>  99   // G4FieldManager*  FindAndSetFieldManager(G4VPhysicalVolume* pCurrentPhysVol);
                                                   >> 100   // which sets and returns the correct field manager (global or local), if any.
                                                   >> 101   // Need to call it before PropagatorInField::ComputeStep is called.
 79                                                   102 
 80 G4double G4MultiNavigator::ComputeStep(const G << 103 G4double G4MultiNavigator::ComputeStep(const G4ThreeVector &pGlobalPoint,
 81                                        const G << 104                      const G4ThreeVector &pDirection,
 82                                        const G << 105                      const G4double      proposedStepLength,
 83                                              G << 106                            G4double      &pNewSafety)
 84 {                                                 107 {
 85   G4double safety= 0.0, step=0.0;                 108   G4double safety= 0.0, step=0.0;
 86   G4double minSafety= kInfinity, minStep= kInf << 109   G4double minSafety= DBL_MAX, minStep= DBL_MAX;
 87                                                   110 
 88   fNoLimitingStep= -1;                         << 111   if( fVerboseLevel > 2 ){
 89   fIdNavLimiting= -1;     // Reset for new ste << 
 90                                                << 
 91 #ifdef G4DEBUG_NAVIGATION                      << 
 92   if( fVerbose > 2 )                           << 
 93   {                                            << 
 94     G4cout << " G4MultiNavigator::ComputeStep     112     G4cout << " G4MultiNavigator::ComputeStep : entered " << G4endl;
 95     G4cout << "   Input position= " << pGlobal    113     G4cout << "   Input position= " << pGlobalPoint
 96            << "   direction= "      << pDirect    114            << "   direction= "      << pDirection         << G4endl;
 97     G4cout << "   Requested step= " << propose    115     G4cout << "   Requested step= " << proposedStepLength << G4endl;
 98   }                                               116   }
 99 #endif                                         << 
100                                                   117 
101   std::vector<G4Navigator*>::iterator pNavigat    118   std::vector<G4Navigator*>::iterator pNavigatorIter;
102                                                   119 
103   pNavigatorIter= pTransportManager-> GetActiv    120   pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
104                                                   121 
105   G4ThreeVector initialPosition = pGlobalPoint << 122   G4ThreeVector initialPosition=  pGlobalPoint;
106   G4ThreeVector initialDirection= pDirection;     123   G4ThreeVector initialDirection= pDirection;
107                                                   124 
108   for( auto num=0; num< fNoActiveNavigators; + << 125   G4int num=0; 
109   {                                            << 126   for( num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num ) {
110      safety= kInfinity;                        << 127      safety= DBL_MAX;
111                                                   128 
112      step= (*pNavigatorIter)->ComputeStep( ini    129      step= (*pNavigatorIter)->ComputeStep( initialPosition, 
113                                            ini    130                                            initialDirection,
114                                            pro    131                                            proposedStepLength,
115                                            saf    132                                            safety ); 
116      if( safety < minSafety ){ minSafety = saf    133      if( safety < minSafety ){ minSafety = safety; } 
117      if( step < minStep )    { minStep= step;     134      if( step < minStep )    { minStep= step; } 
118                                                << 135      //  Later could reduce the proposed step to the latest minStep value ?
                                                   >> 136      // if( step == kInfinity ) { step = proposedStepLength; }
119      fCurrentStepSize[num] = step;                137      fCurrentStepSize[num] = step; 
120      fNewSafety[num]= safety;                     138      fNewSafety[num]= safety; 
121       // This is currently the safety from the    139       // This is currently the safety from the last sub-step
122                                                   140 
123 #ifdef G4DEBUG_NAVIGATION                      << 141      if( fVerboseLevel > 2 ){
124      if( fVerbose > 2 )                        << 142        G4cout << "G4MultiNavigator::ComputeStep : Navigator [" << num << "] -- step size " << step << " safety= " << safety << G4endl;
125      {                                         << 
126        G4cout << "G4MultiNavigator::ComputeSte << 
127               << num << "] -- step size " << s << 
128               << " safety= " << safety << G4en << 
129      }                                            143      }
130 #endif                                         << 
131   }                                               144   } 
132                                                   145 
                                                   >> 146   // fWasLimitedByGeometry= false;  // <----- Could reset(?), but navigator leaves it as is
                                                   >> 147   // Whether any geometry limited the step
                                                   >> 148   // G4bool StepLimited = ( minStep <= proposedStepLength);
                                                   >> 149   // G4cout << "G4MultiNavigator::ComputeStep - StepLimited is " << StepLimited
                                                   >> 150   //  << " given minStep= " << minStep << " and proposed Step= " << proposedStepLength << G4endl;
                                                   >> 151 
133   // Save safety value, related position          152   // Save safety value, related position
134   //                                           << 153   fPreStepLocation=     initialPosition; 
135   fPreStepLocation     = initialPosition;      << 154   fMinSafety_PreStepPt= minSafety;
136   fMinSafety_PreStepPt = minSafety;            << 155 
137   fMinStep = minStep;                          << 156   fMinStep=  minStep; 
138                                                << 157 
139   if( fMinStep == kInfinity )                  << 158   G4double trueMinStep= minStep; 
140   {                                            << 159   if( fMinStep == kInfinity ){
141      fTrueMinStep = proposedStepLength;   //   << 160      trueMinStep = proposedStepLength;   //  Use this below for endpoint !!
142   }                                            << 161   }
143   else                                         << 162   fTrueMinStep = trueMinStep;
144   {                                            << 
145      fTrueMinStep = minStep;                   << 
146   }                                            << 
147                                                << 
148 #ifdef G4DEBUG_NAVIGATION                      << 
149   if( fVerbose > 1 )                           << 
150   {                                            << 
151     G4ThreeVector endPosition = initialPositio << 
152                                                   163 
153     G4int oldPrec = G4cout.precision(8);       << 164   if( fVerboseLevel > 1 ){
                                                   >> 165     G4ThreeVector endPosition;
                                                   >> 166     endPosition= initialPosition + trueMinStep * initialDirection ; 
                                                   >> 167 
                                                   >> 168     int oldPrec= G4cout.precision(8); 
154     G4cout << "G4MultiNavigator::ComputeStep :    169     G4cout << "G4MultiNavigator::ComputeStep : "
155            << " initialPosition = " << initial    170            << " initialPosition = " << initialPosition 
156            << " and endPosition = " << endPosi << 171            << " and endPosition = " << endPosition<< G4endl;
157     G4cout.precision( oldPrec );                  172     G4cout.precision( oldPrec );
158   }                                               173   }
159 #endif                                         << 
160                                                   174 
161   pNewSafety = minSafety;                      << 175   pNewSafety= minSafety; 
                                                   >> 176   // Set the EndState
                                                   >> 177   // fEndState= initialState; 
                                                   >> 178   // fEndState.SetPosition( endPosition ); 
                                                   >> 179   // fEndState.SetProperTimeOfFlight( -1.000 );   // Not defined YET
                                                   >> 180   // fEndState.SetMomentum( initialState.GetMomentum ); 
162                                                   181 
163   this->WhichLimited();                           182   this->WhichLimited(); 
164                                                   183 
165 #ifdef G4DEBUG_NAVIGATION                      << 184   if( fVerboseLevel > 2 ){
166   if( fVerbose > 2 )                           << 185     G4cout << " G4MultiNavigator::ComputeStep : exits returning " << minStep << G4endl;
167   {                                            << 
168     G4cout << " G4MultiNavigator::ComputeStep  << 
169            << minStep << G4endl;               << 
170   }                                               186   }
171 #endif                                         << 
172                                                   187 
173   return minStep;  // must return kInfinity if    188   return minStep;  // must return kInfinity if do not limit step
174 }                                                 189 }
175                                                   190 
176 // ------------------------------------------- << 
177                                                << 
178 G4double                                          191 G4double 
179 G4MultiNavigator::ObtainFinalStep( G4int     n << 192 G4MultiNavigator::ObtainFinalStep( G4int        navigatorId, 
180                                    G4double& p << 193                                    G4double     &pNewSafety,     // for this geom 
181                                    G4double& m << 194                                    G4double     &minStep,
182                                    ELimited& l << 195                                    ELimited     &limitedStep) 
183 {                                              << 196 {
184   if( navigatorId > fNoActiveNavigators )      << 197   G4int navigatorNo=-1; 
185   {                                            << 198 
186      std::ostringstream message;               << 199   if( navigatorId <= fNoActiveNavigators ){
187      message << "Bad Navigator Id!" << G4endl  << 200      navigatorNo= navigatorId;
188              << "        Navigator Id = " << n << 201   } else { 
189              << "        No Active = " << fNoA << 202      G4cerr << " Navigator Id = " << navigatorId 
190      G4Exception("G4MultiNavigator::ObtainFina << 203             << " No Active = " << fNoActiveNavigators << " . " << G4endl;
191                  FatalException, message);     << 204      G4Exception( "G4MultiNavigator::ObtainFinalStep : Bad Navigator Id" ); 
192   }                                               205   }
                                                   >> 206   // if( ! ){ G4Exception( "G4MultiNavigator::ObtainFinalStep Called without call to ComputeStep"); }
193                                                   207 
194   // Prepare the information to return            208   // Prepare the information to return
195   //                                           << 209   pNewSafety  = fNewSafety[ navigatorNo ]; 
196   pNewSafety  = fNewSafety[ navigatorId ];     << 210   limitedStep = fLimitedStep[ navigatorNo ];
197   limitedStep = fLimitedStep[ navigatorId ];   << 
198   minStep= fMinStep;                              211   minStep= fMinStep; 
199                                                   212 
200 #ifdef G4DEBUG_NAVIGATION                      << 213   // if( (minStep==kInfinity) || (fVerboseLevel > 1) ){ 
201   if( fVerbose > 1 )                           << 214   if( fVerboseLevel > 1 ){ 
202   {                                            << 215      G4cout << " G4MultiNavigator::ComputeStep returns " << fCurrentStepSize[ navigatorNo ]
203      G4cout << " G4MultiNavigator::ComputeStep << 216             << " for Navigator " << navigatorNo << " Limited step = " << limitedStep 
204             << fCurrentStepSize[ navigatorId ] << 
205             << " for Navigator " << navigatorI << 
206             << " Limited step = " << limitedSt << 
207             << " Safety(mm) = " << pNewSafety     217             << " Safety(mm) = " << pNewSafety / mm << G4endl; 
208   }                                               218   }
209 #endif                                         << 
210                                                   219 
211   return fCurrentStepSize[ navigatorId ];      << 220   return fCurrentStepSize[ navigatorNo ];
212 }                                                 221 }
213                                                   222 
214 // -------------------------------------------    223 // ----------------------------------------------------------------------
215                                                   224 
216 void G4MultiNavigator::PrepareNewTrack( const  << 225 void
217                                         const  << 226 G4MultiNavigator::PrepareNewTrack( const G4ThreeVector position, 
                                                   >> 227                                    const G4ThreeVector direction )
218 {                                                 228 {
219 #ifdef G4DEBUG_NAVIGATION                      << 229   if( fVerboseLevel > 1 ) 
220   if( fVerbose > 1 )                           << 
221   {                                            << 
222     G4cout << " Entered G4MultiNavigator::Prep    230     G4cout << " Entered G4MultiNavigator::PrepareNewTrack() " << G4endl;
223   }                                            << 
224 #endif                                         << 
225                                                   231 
226   G4MultiNavigator::PrepareNavigators();          232   G4MultiNavigator::PrepareNavigators(); 
                                                   >> 233   //***********************************
227                                                   234 
228   LocateGlobalPointAndSetup( position, &direct << 235   if( fVerboseLevel > 1 ) {
229   //                                           << 236     G4cout << " Calling MultiNavigator::Locate() from G4MultiNavigator::PrepareNewTrack() " 
                                                   >> 237            << G4endl;
                                                   >> 238   }
                                                   >> 239 
                                                   >> 240   this->LocateGlobalPointAndSetup( position, &direction, false, false );   
                                                   >> 241   //    =========================
230   // The first location for each Navigator mus    242   // The first location for each Navigator must be non-relative
231   // or else call ResetStackAndState() for eac << 243   //   or else call ResetStackAndState() for each Navigator
232   // Use direction to get correct side of boun    244   // Use direction to get correct side of boundary (ignore dir= false)
233 }                                              << 
234                                                   245 
235 // ------------------------------------------- << 246   // fRelocatedPoint= false; 
                                                   >> 247 
                                                   >> 248   if( fVerboseLevel > 0 ) {
                                                   >> 249     G4cout << " G4MultiNavigator::PrepareNewTrack : exiting. " << G4endl;
                                                   >> 250   }
236                                                   251 
237 void G4MultiNavigator::PrepareNavigators()     << 252 }
                                                   >> 253 
                                                   >> 254 void
                                                   >> 255 G4MultiNavigator::PrepareNavigators()
238 {                                                 256 {
239   // Key purposes:                                257   // Key purposes:
240   //   - Check and cache set of active navigat    258   //   - Check and cache set of active navigators
241   //   - Reset state for new track                259   //   - Reset state for new track
                                                   >> 260   G4int num=0; 
242                                                   261 
243 #ifdef G4DEBUG_NAVIGATION                      << 262   if( fVerboseLevel > 1 ) 
244   if( fVerbose > 1 )                           << 263     G4cout << " G4MultiNavigator::PrepareNavigators - entered " << G4endl;
245   {                                            << 264   // static G4TransportationManager* pTransportManager= 
246     G4cout << " Entered G4MultiNavigator::Prep << 265   //       G4TransportationManager::GetTransportationManager();
                                                   >> 266 
                                                   >> 267   // fNavigators= true; 
                                                   >> 268   // this->MovePoint();   // Signal further that the last status is wiped
                                                   >> 269 
                                                   >> 270   // Message the G4NavigatorPanel / Dispatcher to find active navigators
                                                   >> 271   std::vector<G4Navigator*>::iterator pNavigatorIter; 
                                                   >> 272 
                                                   >> 273   fNoActiveNavigators=  pTransportManager-> GetNoActiveNavigators();
                                                   >> 274   if( fNoActiveNavigators > fMaxNav ){
                                                   >> 275     G4cerr << "Too many active Navigators (worlds). G4MultiNavigator fails." 
                                                   >> 276            << G4endl;
                                                   >> 277     G4cout << " Fatal error: Transportation Manager reports " << fNoActiveNavigators 
                                                   >> 278            << " which is more than the number allowed = "     << fMaxNav << G4endl;
                                                   >> 279     G4Exception("G4MultiNavigator::PrepareNavigators()", "TooManyNavigators",  
                                                   >> 280                 FatalException,  "Too many active Navigators / worlds"); 
247   }                                               281   }
248 #endif                                         << 
249                                                   282 
250   // Message the transportation-manager to fin << 283   pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
251                                                << 284   for( num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num ) {
252   std::vector<G4Navigator*>::const_iterator pN << 285  
253   fNoActiveNavigators = (G4int)pTransportManag << 286      // Keep information in carray ... for returning information stored
254                                                << 287      fpNavigator[num] =  *pNavigatorIter;   
255   if( fNoActiveNavigators > fMaxNav )          << 
256   {                                            << 
257     std::ostringstream message;                << 
258     message << "Too many active Navigators / w << 
259             << "        Active Navigators (wor << 
260             << fNoActiveNavigators << G4endl   << 
261             << "        which is more than the << 
262             << fMaxNav << " !";                << 
263     G4Exception("G4MultiNavigator::PrepareNavi << 
264                 FatalException, message);      << 
265   }                                            << 
266                                                << 
267   pNavigatorIter= pTransportManager->GetActive << 
268   for( auto num=0; num< fNoActiveNavigators; + << 
269   {                                            << 
270      fpNavigator[num] = *pNavigatorIter;       << 
271      fLimitTruth[num] = false;                    288      fLimitTruth[num] = false;
272      fLimitedStep[num] = kDoNot;                  289      fLimitedStep[num] = kDoNot;
273      fCurrentStepSize[num] = 0.0;                 290      fCurrentStepSize[num] = 0.0; 
274      fLocatedVolume[num] = nullptr;            << 291      fLocatedVolume[num] = 0; 
275   }                                               292   }
276   fWasLimitedByGeometry = false;               << 293   fWasLimitedByGeometry= false; 
277                                                   294 
278   // Check the world volume of the mass naviga << 295   // Check the world volume of the mass navigator (in case a SetWorldVolume changed it)
279   // in case a call to SetWorldVolume() change << 296   G4VPhysicalVolume* massWorld =  this-> GetWorldVolume();
280                                                << 297     // fpNavigator[0] -> GetWorldVolume();  
281   G4VPhysicalVolume* massWorld = GetWorldVolum << 298   if( (massWorld != fLastMassWorld) && (massWorld!=0) ) { 
282                                                << 
283   if( (massWorld != fLastMassWorld) && (massWo << 
284   {                                            << 
285      // Pass along change to Mass Navigator       299      // Pass along change to Mass Navigator
286      fpNavigator[0] -> SetWorldVolume( massWor << 300      fpNavigator[0] -> SetWorldVolume( massWorld ); 
287                                                << 301      if( fVerboseLevel > 0 ) { 
288 #ifdef G4DEBUG_NAVIGATION                      << 302        G4cout << "G4MultiNavigator::PrepareNavigators changed world volume " 
289      if( fVerbose > 0 )                        << 
290      {                                         << 
291        G4cout << " G4MultiNavigator::PrepareNa << 
292               << " for mass geometry to " << m    303               << " for mass geometry to " << massWorld->GetName() << G4endl; 
293      }                                            304      }
294 #endif                                         << 305      fLastMassWorld= massWorld;
                                                   >> 306   }else{
                                                   >> 307      if( fVerboseLevel > 2 ) { 
                                                   >> 308           G4cout << "G4MultiNavigator::PrepareNavigators retained world volume " 
                                                   >> 309                  << " Pointer= " << massWorld << G4endl;
                                                   >> 310           if( massWorld ) 
                                                   >> 311              G4cout << " Name= " << massWorld->GetName() << G4endl;
                                                   >> 312      }
                                                   >> 313   }
295                                                   314 
296      fLastMassWorld = massWorld;               << 315   if( fVerboseLevel > 2 ) {
                                                   >> 316     G4cout << " G4MultiNavigator::PrepareNavigators : exiting. " << G4endl;
297   }                                               317   }
298 }                                                 318 }
299                                                   319 
300 // ------------------------------------------- << 
301                                                   320 
302 G4VPhysicalVolume*                                321 G4VPhysicalVolume* 
303 G4MultiNavigator::LocateGlobalPointAndSetup(co    322 G4MultiNavigator::LocateGlobalPointAndSetup(const G4ThreeVector& position,
304                                             co    323                                             const G4ThreeVector* pDirection,
305                                             co    324                                             const G4bool pRelativeSearch,
306                                             co    325                                             const G4bool ignoreDirection )
307 {                                                 326 {
308   // Locate the point in each geometry            327   // Locate the point in each geometry
309                                                   328 
310   G4ThreeVector direction(0.0, 0.0, 0.0);         329   G4ThreeVector direction(0.0, 0.0, 0.0);
311   G4bool relative = pRelativeSearch;           << 330   G4bool  relative= pRelativeSearch; 
312   auto pNavIter = pTransportManager->GetActive << 331   std::vector<G4Navigator*>::iterator pNavIter= pTransportManager->GetActiveNavigatorsIterator(); 
313                                                << 332   G4int num=0; 
314   if( pDirection != nullptr ) { direction = *p << 333 
                                                   >> 334   if( pDirection ) direction = *pDirection; 
                                                   >> 335 
                                                   >> 336 #if 0
                                                   >> 337   G4ThreeVector lastEndPosition= fEndState.GetPosition(); 
                                                   >> 338   G4ThreeVector moveVec = (position - lastEndPosition );
                                                   >> 339   G4double      moveLenSq= moveVec.mag2();
                                                   >> 340   if( (!fNewTrack) && (!fRelocatedPoint) && ( moveLenSq> 0.0) ){
                                                   >> 341      ReportMove( position, lastEndPosition, "Position" ); 
                                                   >> 342      G4Exception( "G4MultiNavigator::LocateGlobalPointAndSetup", 
                                                   >> 343                   "211-LocateUnexpectedPoint",  
                                                   >> 344                   JustWarning,   
                                                   >> 345                   // FatalException,  
                                                   >> 346                   "Location is not where last ComputeStep ended."); 
                                                   >> 347   }
                                                   >> 348   fLastLocatedPosition= position; 
                                                   >> 349 #endif
                                                   >> 350 
                                                   >> 351   if( fVerboseLevel > 2 ){
                                                   >> 352     G4cout << " G4MultiNavigator::LocateGlobalPointAndSetup : entered " << " ---------------" <<  G4endl;
                                                   >> 353     G4cout << "   Locating at position " << position << "  with direction " << direction 
                                                   >> 354            << "  relative= " << relative << " ignore direction= " << ignoreDirection<< G4endl;
                                                   >> 355     G4cout << "   Number of active navigators= " << fNoActiveNavigators << G4endl;
                                                   >> 356   }
                                                   >> 357 
                                                   >> 358   for ( num=0; num< fNoActiveNavigators ; ++pNavIter,++num ) {
                                                   >> 359      //  ... who limited the step ....
                                                   >> 360 
                                                   >> 361      // G4cout << " -- Navigator id= " << num << " NavigatorPtr " << *pNavIter << G4endl;
                                                   >> 362      // G4VPhysicalVolume* world= (*pNavIter)->GetWorldVolume(); 
                                                   >> 363      // if( world ) { G4cout << "    Navigator world= " <<  world->GetName() << G4endl; }
                                                   >> 364      // else{  G4cout << "    No world set in Navigator. " << G4endl;   }
315                                                   365 
316 #ifdef G4DEBUG_NAVIGATION                      << 366      if( fWasLimitedByGeometry && fLimitTruth[num] ) { 
317   if( fVerbose > 2 )                           << 
318   {                                            << 
319     G4cout << " Entered G4MultiNavigator::Loca << 
320            << G4endl;                          << 
321     G4cout << "   Locating at position: " << p << 
322            << ", with direction: " << directio << 
323            << "   Relative: " << relative      << 
324            << ", ignore direction: " << ignore << 
325     G4cout << "   Number of active navigators: << 
326            << G4endl;                          << 
327   }                                            << 
328 #endif                                         << 
329                                                << 
330   for ( auto num=0; num< fNoActiveNavigators ; << 
331   {                                            << 
332      if( fWasLimitedByGeometry && fLimitTruth[ << 
333      {                                         << 
334         (*pNavIter)->SetGeometricallyLimitedSt    367         (*pNavIter)->SetGeometricallyLimitedStep(); 
335      }                                            368      }
336                                                   369 
337      G4VPhysicalVolume *pLocated               << 370      G4VPhysicalVolume *pLocated= 
338        = (*pNavIter)->LocateGlobalPointAndSetu << 371      (*pNavIter)->LocateGlobalPointAndSetup( position, &direction,
339                                                << 372      //*************************************//
                                                   >> 373                                              relative,  
                                                   >> 374                                              ignoreDirection);   
340      // Set the state related to the location     375      // Set the state related to the location
341      //                                        << 
342      fLocatedVolume[num] = pLocated;              376      fLocatedVolume[num] = pLocated; 
343                                                   377 
344      // Clear state related to the step           378      // Clear state related to the step
345      //                                        << 
346      fLimitedStep[num]   = kDoNot;                379      fLimitedStep[num]   = kDoNot; 
347      fCurrentStepSize[num] = 0.0;                 380      fCurrentStepSize[num] = 0.0;      
348      fLimitTruth[ num ] = false;   // Always c    381      fLimitTruth[ num ] = false;   // Always clear on locating (see Navigator)
349                                                   382     
350 #ifdef G4DEBUG_NAVIGATION                      << 383      if( fVerboseLevel > 2 ){
351      if( fVerbose > 2 )                        << 384        G4cout << " Located in world " << num << " at " << position
352      {                                         << 385               << "  used geomLimStp " << fLimitTruth[num]
353        G4cout << " Located in world: " << num  << 386               << "  - found in volume " << pLocated ; 
354               << " Used geomLimStp: " << fLimi << 387        G4cout << "  name = '" ;       
355               << ", found in volume: " << pLoc << 388        if( pLocated ){ 
356        G4cout << " Name = '" ;                 << 
357        if( pLocated )                          << 
358        {                                       << 
359          G4cout << pLocated->GetName() << "'";    389          G4cout << pLocated->GetName() << "'"; 
360          G4cout << " - CopyNo= " << pLocated->    390          G4cout << " - CopyNo= " << pLocated->GetCopyNo(); 
361        }                                       << 391        } else { 
362        else                                    << 
363        {                                       << 
364          G4cout <<  "Null'   Id: Not-Set ";       392          G4cout <<  "Null'   Id: Not-Set "; 
365        }                                          393        }
366        G4cout << G4endl;                       << 394        G4cout  << G4endl; 
367      }                                            395      }
368 #endif                                         << 396   } // ending for (num= ....
369   }                                            << 397   fWasLimitedByGeometry= false;   // Clear on locating
370                                                   398 
371   fWasLimitedByGeometry = false;   // Clear on << 399   if( fVerboseLevel > 2 ){
372   G4VPhysicalVolume* volMassLocated = fLocated << 400     G4cout << " G4MultiNavigator::Locate : exiting. " << G4endl << G4endl; 
                                                   >> 401   }
                                                   >> 402   // fRelocatedPoint= false;
373                                                   403 
                                                   >> 404   G4VPhysicalVolume* volMassLocated= fLocatedVolume[0]; 
374   return volMassLocated;                          405   return volMassLocated;
375 }                                                 406 }
376                                                   407 
377 // ------------------------------------------- << 
378                                                << 
379 void                                              408 void
380 G4MultiNavigator::LocateGlobalPointWithinVolum    409 G4MultiNavigator::LocateGlobalPointWithinVolume(const G4ThreeVector& position)
381 {                                                 410 {
382   // Relocate the point in each geometry          411   // Relocate the point in each geometry
383                                                << 412   std::vector<G4Navigator*>::iterator pNavIter= pTransportManager->GetActiveNavigatorsIterator(); 
384   auto pNavIter = pTransportManager->GetActive << 413   // const G4double cErrorTolerance=1e-12;   
385                                                << 414   // Maximum relative error from roundoff of arithmetic 
386 #ifdef G4DEBUG_NAVIGATION                      << 415   G4int num=0; 
387   if( fVerbose > 2 )                           << 416 
388   {                                            << 417   if( fVerboseLevel > 2 ){
389     G4cout << " Entered G4MultiNavigator::ReLo << 418     G4cout << G4endl; 
390            << "  Re-locating at position: " << << 419     G4cout << " G4MultiNavigator::ReLocate : entered " << G4endl;
                                                   >> 420     G4cout << " ----------------------   -------" <<  G4endl;
                                                   >> 421     G4cout << "  *Re*Locating at position " << position  << G4endl; 
391   }                                               422   }
392 #endif                                         << 
393                                                   423 
394   for ( auto num=0; num< fNoActiveNavigators ; << 424   for ( num=0; num< fNoActiveNavigators ; ++pNavIter,++num ) {
395   {                                            << 
396      //  ... none limited the step                425      //  ... none limited the step
397                                                   426 
                                                   >> 427      // G4VPhysicalVolume physVolume= 
398      (*pNavIter)->LocateGlobalPointWithinVolum    428      (*pNavIter)->LocateGlobalPointWithinVolume( position ); 
                                                   >> 429      //*************************************//
399                                                   430 
400      // Clear state related to the step           431      // Clear state related to the step
401      //                                        << 432      fLimitedStep[num]   = kDoNot; 
402      fLimitedStep[num]     = kDoNot;           << 
403      fCurrentStepSize[num] = 0.0;                 433      fCurrentStepSize[num] = 0.0;      
404                                                   434 
405      fLimitTruth[ num ] = false;   // Always c    435      fLimitTruth[ num ] = false;   // Always clear on locating (see Navigator)
                                                   >> 436      // fLocatedVolume[num]= physVolume; 
                                                   >> 437     
                                                   >> 438      // G4cout << " ReLocated in world " << num << " at " << position << G4endl;
406   }                                               439   }
407   fWasLimitedByGeometry = false;   // Clear on << 440   fWasLimitedByGeometry= false;   // Clear on locating
408   fLastLocatedPosition  = position;            << 441 
                                                   >> 442   fLastLocatedPosition= position; 
                                                   >> 443   // fRelocatedPoint= false;
                                                   >> 444 
                                                   >> 445   if( fVerboseLevel > 2 ){
                                                   >> 446     G4cout << " G4MultiNavigator::LocateGlobalPointWithinVolume : exiting " 
                                                   >> 447            << "  at position " << position << G4endl;
                                                   >> 448     G4cout << G4endl;
                                                   >> 449   }
                                                   >> 450 
409 }                                                 451 }
410                                                   452 
411 // ------------------------------------------- << 453 // -----------------------------------------------------------------------------
412                                                   454 
413 G4double G4MultiNavigator::ComputeSafety( cons << 455 G4double  G4MultiNavigator::ComputeSafety( const G4ThreeVector& position,
414                                           cons << 456                                                  G4double       maxDistance)
415                                           cons << 457      // Recompute safety for the relevant point
416 {                                                 458 {
417     // Recompute safety for the relevant point << 459     G4double minSafety= DBL_MAX; 
418                                                << 460     // G4cout << " G4MultiNavigator::ComputeSafety - called at " << position << G4endl;
419     G4double minSafety = kInfinity, safety = k << 
420                                                   461   
421     std::vector<G4Navigator*>::iterator pNavig    462     std::vector<G4Navigator*>::iterator pNavigatorIter;
422     pNavigatorIter= pTransportManager-> GetAct    463     pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
423                                                   464 
424     for( auto num=0; num< fNoActiveNavigators; << 465     G4int num=0; 
425     {                                          << 466     for( num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num ) {
426        safety = (*pNavigatorIter)->ComputeSafe << 467 
427        if( safety < minSafety ) { minSafety =  << 468        G4double safety;
                                                   >> 469        safety= (*pNavigatorIter)->ComputeSafety( position, maxDistance ); 
                                                   >> 470   
                                                   >> 471        if( safety < minSafety ){ minSafety = safety; } 
                                                   >> 472        // fNewSafety[num]= safety; 
428     }                                             473     } 
429                                                   474 
430     fSafetyLocation = position;                << 475     fSafetyLocation= position;
431     fMinSafety_atSafLocation = minSafety;         476     fMinSafety_atSafLocation = minSafety;
432                                                   477 
433 #ifdef G4DEBUG_NAVIGATION                      << 478     if( fVerboseLevel > 1 ) { 
434     if( fVerbose > 1 )                         << 479       G4cout << " G4MultiNavigator::ComputeSafety - returns " 
435     {                                          << 480              << minSafety << " at location " << position 
436       G4cout << " G4MultiNavigator::ComputeSaf << 481              << G4endl;
437              << minSafety << ", at location: " << 
438     }                                             482     }
439 #endif                                         << 
440     return minSafety;                             483     return minSafety; 
441 }                                                 484 }
442                                                   485 
443 // ------------------------------------------- << 
444                                                   486 
445 G4TouchableHandle G4MultiNavigator::CreateTouc << 487 // -----------------------------------------------------------------------------
                                                   >> 488 
                                                   >> 489 G4TouchableHistoryHandle 
                                                   >> 490 G4MultiNavigator::CreateTouchableHistoryHandle() const
446 {                                                 491 {
447   G4Exception( "G4MultiNavigator::CreateToucha << 492   G4Exception( "G4MultiNavigator::CreateTouchableHistoryHandle", 
448                "GeomNav0001", FatalException,  << 493                "215-TouchableFromWrongNavigator",  
                                                   >> 494                FatalException,  
449                "Getting a touchable from G4Mul    495                "Getting a touchable from G4MultiNavigator is not defined."); 
450                                                   496 
                                                   >> 497   if( fVerboseLevel > 2 ){
                                                   >> 498     G4cout << "G4MultiNavigator::CreateTouchableHandle : navId = " << 0 ;
                                                   >> 499       //   << " -- " << GetNavigator(navId) << G4endl;
                                                   >> 500   }
                                                   >> 501 
451   G4TouchableHistory* touchHist;                  502   G4TouchableHistory* touchHist;
452   touchHist= fpNavigator[0] -> CreateTouchable    503   touchHist= fpNavigator[0] -> CreateTouchableHistory(); 
453                                                   504 
                                                   >> 505   // G4TouchableHistory* touchHist= new G4TouchableHistory(); 
                                                   >> 506 
454   G4VPhysicalVolume* locatedVolume= fLocatedVo    507   G4VPhysicalVolume* locatedVolume= fLocatedVolume[0]; 
455   if( locatedVolume == nullptr )               << 508   if( locatedVolume == 0 )
456   {                                            << 509      {
457     // Workaround to ensure that the touchable << 510        // Workaround to ensure that the touchable is fixed !! // TODO: fix
458     //                                         << 511        touchHist->UpdateYourself( locatedVolume, 
459     touchHist->UpdateYourself( locatedVolume,  << 512                                   touchHist->GetHistory() );
460   }                                            << 513      }
461                                                   514     
462   return {touchHist};                          << 515   return G4TouchableHistoryHandle(touchHist); 
463 }                                                 516 }
464                                                   517 
465 // ------------------------------------------- << 518 void
466                                                << 519 G4MultiNavigator::WhichLimited()       // Flag which processes limited the step
467 void G4MultiNavigator::WhichLimited()          << 
468 {                                                 520 {
469   // Flag which processes limited the step     << 521   G4int num=-1, last=-1; 
470                                                << 522   const G4int  IdTransport= 0;  // Id of Mass Navigator !!
471   G4int last=-1;                               << 
472   const G4int IdTransport= 0;  // Id of Mass N << 
473   G4int noLimited=0;                              523   G4int noLimited=0; 
474   ELimited shared= kSharedOther;                  524   ELimited shared= kSharedOther; 
475                                                   525 
476 #ifdef G4DEBUG_NAVIGATION                      << 526   if( fVerboseLevel > 2 )
477   if( fVerbose > 2 )                           << 527     G4cout << " G4MultiNavigator::WhichLimited - entered " << G4endl;
478   {                                            << 
479     G4cout << " Entered G4MultiNavigator::Whic << 
480   }                                            << 
481 #endif                                         << 
482                                                   528 
483   // Assume that [IdTransport] is Mass / Trans    529   // Assume that [IdTransport] is Mass / Transport
484   //                                           << 530   // G4bool transportLimited = (fCurrentStepSize[IdTransport] == fMinStep); 
485   G4bool transportLimited = (fCurrentStepSize[    531   G4bool transportLimited = (fCurrentStepSize[IdTransport] == fMinStep)
486                          && ( fMinStep!= kInfi << 532                            && ( fMinStep!= kInfinity) ; 
487   if( transportLimited )                       << 533   if( transportLimited ){ 
488   {                                            << 534      shared= kSharedTransport;
489      shared = kSharedTransport;                << 
490   }                                               535   }
491                                                   536 
492   for ( auto num = 0; num < fNoActiveNavigator << 537   for ( num= 0; num < fNoActiveNavigators; num++ ) { 
493   {                                            << 
494     G4bool limitedStep;                           538     G4bool limitedStep;
495                                                   539 
496     G4double step = fCurrentStepSize[num];     << 540     G4double step= fCurrentStepSize[num]; 
497                                                   541 
498     limitedStep = ( step == fMinStep ) && ( st    542     limitedStep = ( step == fMinStep ) && ( step != kInfinity); 
                                                   >> 543     // if( step == kInfinity ) { fCurrentStepSize[num] = proposedStepLength; }
499                                                   544    
500     fLimitTruth[ num ] = limitedStep;             545     fLimitTruth[ num ] = limitedStep; 
501     if( limitedStep )                          << 546     if( limitedStep ) {
502     {                                          << 547       noLimited++;  
503       ++noLimited;                             << 
504       fLimitedStep[num] = shared;                 548       fLimitedStep[num] = shared;
505       last= num;                                  549       last= num; 
506     }                                          << 550     }else{
507     else                                       << 
508     {                                          << 
509       fLimitedStep[num] = kDoNot;                 551       fLimitedStep[num] = kDoNot;
510     }                                             552     }
511   }                                               553   }
512   if( (last > -1) && (noLimited == 1 ) )       << 554   if( (last > -1) && (noLimited == 1 ) ){
513   {                                            << 555     fLimitedStep[ last ] = kUnique; 
514     fLimitedStep[ last ] = kUnique;            << 
515     fIdNavLimiting = last;                     << 
516   }                                               556   }
517                                                   557 
518   fNoLimitingStep = noLimited;                 << 558 #ifndef G4NO_VERBOSE
                                                   >> 559   if( fVerboseLevel > 1 ){
                                                   >> 560     this->PrintLimited();   // --> for tracing 
                                                   >> 561     G4cout << " G4MultiNavigator::WhichLimited - exiting. " << G4endl;
                                                   >> 562   }
                                                   >> 563 #endif
519                                                   564 
520   return;                                      << 
521 }                                                 565 }
522                                                   566 
523 // ------------------------------------------- << 
524                                                << 
525 void                                              567 void
526 G4MultiNavigator::PrintLimited()                  568 G4MultiNavigator::PrintLimited()
527 {                                                 569 {
                                                   >> 570   static G4String StrDoNot("DoNot"), StrUnique("Unique"), StrUndefined("Undefined"),
                                                   >> 571     StrSharedTransport("SharedTransport"),  StrSharedOther("SharedOther");
528   // Report results -- for checking               572   // Report results -- for checking   
529                                                << 573   G4cout << "G4MultiNavigator::PrintLimited reports: " ; 
530   static const G4String StrDoNot("DoNot"), Str << 574   G4cout << "  Minimum step (true)= " << fTrueMinStep 
531                   StrUndefined("Undefined"),   << 575          << "  reported min = " << fMinStep 
532                   StrSharedTransport("SharedTr << 576          << G4endl; 
533                   StrSharedOther("SharedOther" << 577   if(  // (fCurrentStepNo <= 2) || 
534   G4cout << "### G4MultiNavigator::PrintLimite << 578       (fVerboseLevel>=2) ) {
535   G4cout << "    Minimum step (true): " << fTr << 579     G4cout // << std::setw(5) << " Step#"  << " "
536          << ", reported min: " << fMinStep <<  << 580          << std::setw(5) << " NavId"  << " "
537                                                << 581          << std::setw(12) << " step-size " << " "
538 #ifdef G4DEBUG_NAVIGATION                      << 582          << std::setw(12) << " raw-size "  << " "
539   if(fVerbose>=2)                              << 583          << std::setw(12) << " pre-safety " << " " 
540   {                                            << 584          << std::setw(15) << " Limited / flag"  << " "
541     G4cout << std::setw(5) << " NavId"  << " " << 585          << std::setw(15) << "  World "  << " "
542            << std::setw(12) << " step-size " < << 586          << G4endl;  
543            << std::setw(12) << " raw-size "  < << 
544            << std::setw(12) << " pre-safety "  << 
545            << std::setw(15) << " Limited / fla << 
546            << std::setw(15) << "  World "  <<  << 
547            << G4endl;                          << 
548   }                                               587   }
549 #endif                                         << 588   int num;
550                                                << 589   for ( num= 0; num < fNoActiveNavigators; num++ ) { 
551   for ( auto num = 0; num < fNoActiveNavigator << 
552   {                                            << 
553     G4double rawStep = fCurrentStepSize[num];     590     G4double rawStep = fCurrentStepSize[num]; 
554     G4double stepLen = fCurrentStepSize[num];     591     G4double stepLen = fCurrentStepSize[num]; 
555     if( stepLen > fTrueMinStep )               << 592     if( stepLen > fTrueMinStep ) { 
556     {                                          << 
557       stepLen = fTrueMinStep;     // did not l    593       stepLen = fTrueMinStep;     // did not limit (went as far as asked)
558     }                                             594     }
559     G4long oldPrec = G4cout.precision(9);      << 595     G4int oldPrec= G4cout.precision(9); 
560                                                << 596     // const char *BooleanValue[2] = { " NO", "YES" } ; 
561     G4cout << std::setw(5) << num  << " "      << 597     G4cout // << std::setw(5) << fCurrentStepNo  << " " 
                                                   >> 598            << std::setw(5) << num  << " "
562            << std::setw(12) << stepLen << " "     599            << std::setw(12) << stepLen << " "
563            << std::setw(12) << rawStep << " "     600            << std::setw(12) << rawStep << " "
564            << std::setw(12) << fNewSafety[num]    601            << std::setw(12) << fNewSafety[num] << " "
565            << std::setw(5) << (fLimitTruth[num    602            << std::setw(5) << (fLimitTruth[num] ? "YES" : " NO") << " ";
566     G4String limitedStr;                          603     G4String limitedStr;
567     switch ( fLimitedStep[num] )               << 604     switch ( fLimitedStep[num] ) {
568     {                                          << 605       case kDoNot:  limitedStr= StrDoNot; break;
569       case kDoNot          : limitedStr = StrD << 606       case kUnique: limitedStr = StrUnique; break; 
570       case kUnique         : limitedStr = StrU << 607       case kSharedTransport:  limitedStr= StrSharedTransport; break; 
571       case kSharedTransport: limitedStr = StrS << 608       case kSharedOther: limitedStr = StrSharedOther; break;
572       case kSharedOther    : limitedStr = StrS << 609       default: limitedStr = StrUndefined; break;
573       default              : limitedStr = StrU << 
574     }                                             610     }
575     G4cout << " " << std::setw(15) << limitedS    611     G4cout << " " << std::setw(15) << limitedStr << " ";  
576     G4cout.precision(oldPrec);                    612     G4cout.precision(oldPrec); 
577                                                   613 
578     G4Navigator *pNav = fpNavigator[ num ];    << 614     G4Navigator *pNav= fpNavigator[ num ]; 
579     G4String  WorldName( "Not-Set" );             615     G4String  WorldName( "Not-Set" ); 
580     if (pNav != nullptr)                       << 616     if (pNav) {
581     {                                          << 617        G4VPhysicalVolume *pWorld= pNav->GetWorldVolume(); 
582        G4VPhysicalVolume *pWorld = pNav->GetWo << 618        if( pWorld ) {
583        if( pWorld != nullptr )                 << 
584        {                                       << 
585            WorldName = pWorld->GetName();         619            WorldName = pWorld->GetName(); 
586        }                                          620        }
587     }                                             621     }
588     G4cout << " " << WorldName ;                  622     G4cout << " " << WorldName ; 
589     G4cout << G4endl;                             623     G4cout << G4endl;
590   }                                               624   }
                                                   >> 625 
                                                   >> 626   if( fVerboseLevel > 2 )
                                                   >> 627     G4cout << " G4MultiNavigator::PrintLimited - exiting. " << G4endl;
591 }                                                 628 }
592                                                   629  
593                                                   630 
594 // ------------------------------------------- << 631 void 
595                                                << 632 G4MultiNavigator::ResetState()
596 void G4MultiNavigator::ResetState()            << 
597 {                                                 633 {
598    fWasLimitedByGeometry = false;              << 634    G4int num; 
                                                   >> 635    fWasLimitedByGeometry= false; 
599                                                   636 
600    G4Exception("G4MultiNavigator::ResetState() << 637    G4Exception( "G4MultiNavigator::ResetState", 
                                                   >> 638                "217-CannotImplement",  
601                FatalException,                    639                FatalException,  
602                "Cannot reset state for navigat << 640                "Cannot call ResetState for active navigators of G4MultiNavigator.");   
603 /*                                             << 
604    std::vector<G4Navigator*>::iterator pNaviga    641    std::vector<G4Navigator*>::iterator pNavigatorIter;
605    pNavigatorIter = pTransportManager->GetActi << 642    pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
606    for( auto num = 0; num< fNoActiveNavigators << 643    for( num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num ) {
607    {                                           << 
608        //  (*pNavigatorIter)->ResetState();  /    644        //  (*pNavigatorIter)->ResetState();  // KEEP THIS comment !!!
609    }                                           << 645    } 
610 */                                             << 
611 }                                                 646 }
612                                                   647 
613 // ------------------------------------------- << 648 void 
614                                                << 649 G4MultiNavigator::SetupHierarchy()
615 void G4MultiNavigator::SetupHierarchy()        << 
616 {                                                 650 {
617   G4Exception( "G4MultiNavigator::SetupHierarc << 651    // G4Navigator::SetupHierarchy(); 
618                "GeomNav0001", FatalException,  << 652    G4Exception( "G4MultiNavigator::SetupHierarchy", 
619                "Cannot setup hierarchy for nav << 653                "217-CannotImplement",  
                                                   >> 654                FatalException,  
                                                   >> 655                "Cannot call SetupHierarchy for active navigators of G4MultiNavigator."); 
620 }                                                 656 }
621                                                   657 
622 // ------------------------------------------- << 658 void 
623                                                << 659 G4MultiNavigator::CheckMassWorld()
624 void G4MultiNavigator::CheckMassWorld()        << 
625 {                                                 660 {
626    G4VPhysicalVolume* navTrackWorld =          << 661    // 
627      pTransportManager->GetNavigatorForTrackin << 662    G4VPhysicalVolume* navTrackWorld= pTransportManager->GetNavigatorForTracking()
628                                                << 663                                                       ->GetWorldVolume();
629    if( navTrackWorld != fLastMassWorld )       << 664    if( navTrackWorld != fLastMassWorld ) { 
630    {                                           << 665       G4Exception( "G4MultiNavigator::CheckMassWorld", "MultiNav-220", FatalException, 
631       G4Exception( "G4MultiNavigator::CheckMas << 
632                    "GeomNav0003", FatalExcepti << 
633                    "Mass world pointer has bee    666                    "Mass world pointer has been changed." ); 
634    }                                           << 667    } 
635 }                                                 668 }
636                                                   669 
637 // ------------------------------------------- << 670 G4VPhysicalVolume* G4MultiNavigator::ResetHierarchyAndLocate(const G4ThreeVector &point,
638                                                << 671                                            const G4ThreeVector &direction,
639 G4VPhysicalVolume*                             << 672                                            const G4TouchableHistory &MassHistory)
640 G4MultiNavigator::ResetHierarchyAndLocate(cons << 
641                                           cons << 
642                                           cons << 
643 {                                              << 
644    // Reset geometry for all -- and use the to    673    // Reset geometry for all -- and use the touchable for the mass history
645                                                << 674 {
646    G4VPhysicalVolume* massVolume = nullptr;    << 675    G4VPhysicalVolume* massVolume=0; 
647    G4Navigator* pMassNavigator = fpNavigator[0 << 676    G4int num; 
648                                                << 677    G4Navigator* pMassNavigator= fpNavigator[0]; 
649    if( pMassNavigator != nullptr )             << 678 
650    {                                           << 679    if( pMassNavigator ){
651       massVolume= pMassNavigator->ResetHierarc << 680       massVolume= pMassNavigator->ResetHierarchyAndLocate( point, direction, MassHistory); 
652                                                << 681    }else{
653    }                                           << 682       G4Exception("G4MultiNavigator::ResetHierarchyAndLocate",
654    else                                        << 683                   "218-TooEarlyToReset",
655    {                                           << 684                   FatalException,
656       G4Exception("G4MultiNavigator::ResetHier << 685                   "Cannot reset hierarchy before object is initialised with valid navigators, including a mass Navigator" );
657                   "GeomNav0002", FatalExceptio << 
658                   "Cannot reset hierarchy befo << 
659    }                                              686    }
660                                                   687 
661    auto pNavIter= pTransportManager->GetActive << 688    std::vector<G4Navigator*>::iterator pNavIter= 
                                                   >> 689        pTransportManager->GetActiveNavigatorsIterator(); 
662                                                   690 
663    for ( auto num = 0; num < fNoActiveNavigato << 691    for ( num=0; num< fNoActiveNavigators ; ++pNavIter,++num ) {
664    {                                           << 
665       G4bool relativeSearch, ignoreDirection;     692       G4bool relativeSearch, ignoreDirection; 
666                                                   693 
667       (*pNavIter)-> LocateGlobalPointAndSetup(    694       (*pNavIter)-> LocateGlobalPointAndSetup( point, 
668                                                   695                                                &direction, 
669                                                   696                                                relativeSearch=false,
670                                                   697                                                ignoreDirection=false);
671    }                                              698    }
672    return massVolume;                             699    return massVolume; 
673 }                                              << 
674                                                << 
675 // ------------------------------------------- << 
676                                                << 
677 G4ThreeVector                                  << 
678 G4MultiNavigator::GetGlobalExitNormal(const G4 << 
679                                       G4bool*  << 
680 {                                              << 
681   G4ThreeVector normalGlobalCrd(0.0, 0.0, 0.0) << 
682   G4bool isObtained = false;                   << 
683   // These default values will be used if fNoL << 
684   G4int firstNavigatorId = -1;                 << 
685   G4bool oneObtained = false;                  << 
686                                                << 
687   if( fNoLimitingStep == 1 )                   << 
688   {                                            << 
689     // Only message the Navigator which limite << 
690     normalGlobalCrd = fpNavigator[ fIdNavLimit << 
691                     ->GetGlobalExitNormal( arg << 
692     *argpObtained = isObtained;                << 
693   }                                            << 
694   else                                         << 
695   {                                            << 
696     if( fNoLimitingStep > 1 )                  << 
697     {                                          << 
698       auto pNavIter= pTransportManager->GetAct << 
699                                                << 
700       for ( auto num = 0; num < fNoActiveNavig << 
701       {                                        << 
702         G4ThreeVector oneNormal;               << 
703         if( fLimitTruth[ num ] )  // Did this  << 
704         {                                      << 
705           G4ThreeVector newNormal =            << 
706             (*pNavIter)->GetGlobalExitNormal(  << 
707           if( oneObtained )                    << 
708           {                                    << 
709             // Keep first one - only if it is  << 
710             if( !isObtained && (newNormal.mag2 << 
711             {                                  << 
712               normalGlobalCrd = newNormal;     << 
713               isObtained = oneObtained;        << 
714               firstNavigatorId = num;          << 
715             }                                  << 
716             else                               << 
717             {                                  << 
718               // Check for clash               << 
719               G4double dotNewPrevious = newNor << 
720               G4double productMagSq = normalGl << 
721               if( productMagSq > 0.0 )         << 
722               {                                << 
723                 G4double productMag = std::sqr << 
724                 dotNewPrevious /= productMag;  << 
725                 if( dotNewPrevious < (1 - perT << 
726                 {                              << 
727                   *argpObtained = false;       << 
728                                                << 
729                   if( fVerbose > 2 )  //  dotN << 
730                   {                            << 
731                     std::ostringstream message << 
732                     message << "Clash of Norma << 
733                             << G4endl          << 
734                             << "        Previo << 
735                             << firstNavigatorI << 
736                             << "        Curren << 
737                             << num << G4endl;  << 
738                     message << "  Dot product  << 
739                             << dotNewPrevious  << 
740                     message << "        Normal << 
741                             << normalGlobalCrd << 
742                     message << "        Normal << 
743                     G4Exception("G4MultiNaviga << 
744                                 "GeomNav0002", << 
745                   }                            << 
746                 }                              << 
747                 else                           << 
748                 {                              << 
749                   // Close agreement - Do not  << 
750                 }                              << 
751               }                                << 
752             }                                  << 
753           }                                    << 
754         }                                      << 
755       } // end for over the Navigators         << 
756                                                << 
757       // Report if no Normal was obtained      << 
758       if( !oneObtained )                       << 
759       {                                        << 
760         std::ostringstream message;            << 
761         message << "No Normal obtained despite << 
762                 << " candidate Navigators limi << 
763         G4Exception("G4MultiNavigator::GetGlob << 
764                     JustWarning, message);     << 
765       }                                        << 
766                                                << 
767     } // end if ( fNoLimiting > 1 )            << 
768   } // end else                                << 
769                                                << 
770   *argpObtained = isObtained;                  << 
771   return normalGlobalCrd;                      << 
772 }                                              << 
773                                                << 
774 // ------------------------------------------- << 
775                                                << 
776 G4ThreeVector                                  << 
777 G4MultiNavigator::GetLocalExitNormal(G4bool* a << 
778 {                                              << 
779   // If it is the mass navigator, then expect  << 
780   G4ThreeVector normalGlobalCrd(0.0, 0.0, 0.0) << 
781   G4bool isObtained = false;                   << 
782   // These default values will be used if fNoL << 
783                                                << 
784   if( fNoLimitingStep == 1 )                   << 
785   {                                            << 
786     // Only message the Navigator which limite << 
787     normalGlobalCrd = fpNavigator[ fIdNavLimit << 
788                     ->GetLocalExitNormal( &isO << 
789     *argpObtained = isObtained;                << 
790                                                << 
791     static G4ThreadLocal G4int numberWarnings  << 
792     G4int noWarningsStart = 10, noModuloWarnin << 
793     ++numberWarnings;                          << 
794     if( (numberWarnings < noWarningsStart )    << 
795      || (numberWarnings%noModuloWarnings == 0) << 
796     {                                          << 
797       std::ostringstream message;              << 
798       message << "Cannot obtain normal in loca << 
799               << "coordinate systems." << G4en << 
800       G4Exception("G4MultiNavigator::GetGlobal << 
801                   JustWarning, message);       << 
802     }                                          << 
803   }                                            << 
804   else                                         << 
805   {                                            << 
806     if( fNoLimitingStep > 1 )                  << 
807     {                                          << 
808       std::ostringstream message;              << 
809       message << "Cannot obtain normal in loca << 
810               << "coordinate systems." << G4en << 
811       G4Exception("G4MultiNavigator::GetGlobal << 
812                   FatalException, message);    << 
813     }                                          << 
814   }                                            << 
815                                                << 
816   *argpObtained = isObtained;                  << 
817   return normalGlobalCrd;                      << 
818 }                                              << 
819                                                << 
820 // ------------------------------------------- << 
821                                                << 
822 G4ThreeVector                                  << 
823 G4MultiNavigator::GetLocalExitNormalAndCheck(c << 
824                                                << 
825 {                                              << 
826   return G4MultiNavigator::GetLocalExitNormal( << 
827 }                                                 700 }
828                                                   701