46 #define State(X) fpTrackState->X 
   47 #define fLimitedStep State(fLimitedStep) 
   48 #define fLimitTruth State(fLimitTruth) 
   49 #define fCurrentStepSize State(fCurrentStepSize) 
   50 #define fNewSafety State(fNewSafety) 
   51 #define fNoLimitingStep State(fNoLimitingStep) 
   52 #define fIdNavLimiting State(fIdNavLimiting) 
   53 #define fMinStep  State(fMinStep) 
   54 #define fMinSafety State(fMinSafety) 
   55 #define fTrueMinStep   State(fTrueMinStep) 
   56 #define fLocatedVolume State(fLocatedVolume) 
   57 #define fLastLocatedPosition State(fLastLocatedPosition) 
   58 #define fSafetyLocation State(fSafetyLocation) 
   59 #define fMinSafety_atSafLocation State(fMinSafety_atSafLocation) 
   60 #define fPreStepLocation State(fPreStepLocation) 
   61 #define fMinSafety_PreStepPt State(fMinSafety_PreStepPt) 
   62 #define fWasLimitedByGeometry State(fWasLimitedByGeometry) 
   69   : G4ITNavigator(), fLastMassWorld(0)
 
   71   fNoActiveNavigators= 0; 
 
   73   for(
G4int num=0; num< fMaxNav; ++num )
 
   86       SetWorldVolume( pWorld ); 
 
   87       fLastMassWorld = pWorld; 
 
  107 #ifdef G4DEBUG_NAVIGATION 
  110     G4cout << 
" G4ITMultiNavigator::ComputeStep : entered " << 
G4endl;
 
  111     G4cout << 
"   Input position= " << pGlobalPoint
 
  112            << 
"   direction= "      << pDirection         << 
G4endl;
 
  113     G4cout << 
"   Requested step= " << proposedStepLength << 
G4endl;
 
  117   std::vector<G4ITNavigator*>::iterator pNavigatorIter;
 
  119   pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
 
  124   for( 
G4int num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
 
  128      step= (*pNavigatorIter)->ComputeStep( initialPosition, 
 
  132      if( safety < minSafety ){ minSafety = safety; } 
 
  133      if( step < minStep )    { minStep= step; } 
 
  139 #ifdef G4DEBUG_NAVIGATION 
  142        G4cout << 
"G4ITMultiNavigator::ComputeStep : Navigator [" 
  143               << num << 
"] -- step size " << step
 
  144               << 
" safety= " << safety << 
G4endl;
 
  164 #ifdef G4DEBUG_NAVIGATION 
  170     G4cout << 
"G4ITMultiNavigator::ComputeStep : " 
  171            << 
" initialPosition = " << initialPosition 
 
  172            << 
" and endPosition = " << endPosition << 
G4endl;
 
  173     G4cout.precision( oldPrec );
 
  177   pNewSafety = minSafety; 
 
  181 #ifdef G4DEBUG_NAVIGATION 
  184     G4cout << 
" G4ITMultiNavigator::ComputeStep : exits returning " 
  200   if( navigatorId > fNoActiveNavigators )
 
  202      std::ostringstream message;
 
  203      message << 
"Bad Navigator Id!" << 
G4endl 
  204              << 
"        Navigator Id = " << navigatorId 
 
  205              << 
"        No Active = " << fNoActiveNavigators << 
".";
 
  206      G4Exception(
"G4ITMultiNavigator::ObtainFinalStep()", 
"GeomNav0002",
 
  216 #ifdef G4DEBUG_NAVIGATION 
  219      G4cout << 
" G4ITMultiNavigator::ComputeStep returns " 
  221             << 
" for Navigator " << navigatorId
 
  222             << 
" Limited step = " << limitedStep 
 
  223             << 
" Safety(mm) = " << pNewSafety / 
mm << 
G4endl; 
 
  235 #ifdef G4DEBUG_NAVIGATION 
  238     G4cout << 
" Entered G4ITMultiNavigator::PrepareNewTrack() " << 
G4endl;
 
  259 #ifdef G4DEBUG_NAVIGATION 
  262     G4cout << 
" Entered G4ITMultiNavigator::PrepareNavigators() " << 
G4endl;
 
  268   std::vector<G4ITNavigator*>::iterator pNavigatorIter;
 
  269   fNoActiveNavigators=  pTransportManager-> GetNoActiveNavigators();
 
  271   if( fNoActiveNavigators > fMaxNav )
 
  273     std::ostringstream message;
 
  274     message << 
"Too many active Navigators / worlds !" << 
G4endl 
  275             << 
"        Active Navigators (worlds): " 
  276             << fNoActiveNavigators << 
G4endl 
  277             << 
"        which is more than the number allowed: " 
  279     G4Exception(
"G4ITMultiNavigator::PrepareNavigators()", 
"GeomNav0002",
 
  283   pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
 
  284   for( 
G4int num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
 
  286      fpNavigator[num] =  *pNavigatorIter;   
 
  299   if( (massWorld != fLastMassWorld) && (massWorld!=0) )
 
  302      fpNavigator[0] -> SetWorldVolume( massWorld );
 
  304 #ifdef G4DEBUG_NAVIGATION 
  307        G4cout << 
" G4ITMultiNavigator::PrepareNavigators() changed world volume " 
  308               << 
" for mass geometry to " << massWorld->
GetName() << 
G4endl; 
 
  312      fLastMassWorld = massWorld;
 
  321                                             const G4bool pRelativeSearch,
 
  322                                             const G4bool ignoreDirection )
 
  327   G4bool relative = pRelativeSearch; 
 
  328   std::vector<G4ITNavigator*>::iterator pNavIter
 
  331   if( pDirection ) { direction = *pDirection; }
 
  333 #ifdef G4DEBUG_NAVIGATION 
  336     G4cout << 
" Entered G4ITMultiNavigator::LocateGlobalPointAndSetup() " 
  338     G4cout << 
"   Locating at position: " << position
 
  339            << 
", with direction: " << direction << G4endl
 
  340            << 
"   Relative: " << relative 
 
  341            << 
", ignore direction: " << ignoreDirection << 
G4endl;
 
  342     G4cout << 
"   Number of active navigators: " << fNoActiveNavigators
 
  347   for ( 
G4int num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
 
  351         (*pNavIter)->SetGeometricallyLimitedStep(); 
 
  355        = (*pNavIter)->LocateGlobalPointAndSetup( position, &direction,
 
  356                                                  relative, ignoreDirection );   
 
  367 #ifdef G4DEBUG_NAVIGATION 
  370        G4cout << 
" Located in world: " << num << 
", at: " << position << 
G4endl 
  372               << 
", found in volume: " << pLocated << 
G4endl; 
 
  381          G4cout <<  
"Null'   Id: Not-Set "; 
 
  391   return volMassLocated;
 
  401   std::vector<G4ITNavigator*>::iterator pNavIter
 
  404 #ifdef G4DEBUG_NAVIGATION 
  407     G4cout << 
" Entered G4ITMultiNavigator::ReLocate() " << 
G4endl 
  408            << 
"  Re-locating at position: " << position  << 
G4endl; 
 
  412   for ( 
G4int num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
 
  416      (*pNavIter)->LocateGlobalPointWithinVolume( position ); 
 
  439     std::vector<G4ITNavigator*>::iterator pNavigatorIter;
 
  440     pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
 
  442     for( 
G4int num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
 
  444        safety = (*pNavigatorIter)->ComputeSafety( position, maxDistance, state);
 
  445        if( safety < minSafety ) { minSafety = safety; } 
 
  451 #ifdef G4DEBUG_NAVIGATION 
  454       G4cout << 
" G4ITMultiNavigator::ComputeSafety - returns: " 
  455              << minSafety << 
", at location: " << position << 
G4endl;
 
  466   G4Exception( 
"G4ITMultiNavigator::CreateTouchableHistoryHandle()",
 
  468                "Getting a touchable from G4ITMultiNavigator is not defined.");
 
  471   touchHist= fpNavigator[0] -> CreateTouchableHistory(); 
 
  474   if( locatedVolume == 0 )
 
  491   const G4int IdTransport= 0;  
 
  495 #ifdef G4DEBUG_NAVIGATION 
  498     G4cout << 
" Entered G4ITMultiNavigator::WhichLimited() " << 
G4endl;
 
  506   if( transportLimited )
 
  511   for ( 
G4int num= 0; num < fNoActiveNavigators; num++ )
 
  531   if( (last > -1) && (noLimited == 1 ) )
 
  548   static const G4String StrDoNot(
"DoNot"), StrUnique(
"Unique"),
 
  549                   StrUndefined(
"Undefined"),
 
  550                   StrSharedTransport(
"SharedTransport"),
 
  551                   StrSharedOther(
"SharedOther");
 
  552   G4cout << 
"### G4ITMultiNavigator::PrintLimited() reports: " << 
G4endl;
 
  556 #ifdef G4DEBUG_NAVIGATION 
  559     G4cout << std::setw(5) << 
" NavId"  << 
" " 
  560            << std::setw(12) << 
" step-size " << 
" " 
  561            << std::setw(12) << 
" raw-size "  << 
" " 
  562            << std::setw(12) << 
" pre-safety " << 
" "  
  563            << std::setw(15) << 
" Limited / flag"  << 
" " 
  564            << std::setw(15) << 
"  World "  << 
" " 
  569   for ( 
G4int num= 0; num < fNoActiveNavigators; num++ )
 
  579     G4cout << std::setw(5) << num  << 
" " 
  580            << std::setw(12) << stepLen << 
" " 
  581            << std::setw(12) << rawStep << 
" " 
  583            << std::setw(5) << (
fLimitTruth[num] ? 
"YES" : 
" NO") << 
" ";
 
  587       case kDoNot          : limitedStr= StrDoNot; 
break;
 
  588       case kUnique         : limitedStr = StrUnique; 
break; 
 
  591       default              : limitedStr = StrUndefined; 
break;
 
  593     G4cout << 
" " << std::setw(15) << limitedStr << 
" ";  
 
  594     G4cout.precision(oldPrec); 
 
  596     G4ITNavigator *pNav= fpNavigator[ num ];
 
  606     G4cout << 
" " << WorldName ; 
 
  618    G4Exception(
"G4ITMultiNavigator::ResetState()", 
"GeomNav0001",
 
  620                "Cannot reset state for navigators of G4ITMultiNavigator.");
 
  622    std::vector<G4ITNavigator*>::iterator pNavigatorIter;
 
  623    pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
 
  624    for( 
G4int num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
 
  634   G4Exception( 
"G4ITMultiNavigator::SetupHierarchy()",
 
  636                "Cannot setup hierarchy for navigators of G4ITMultiNavigator.");
 
  646    if( navTrackWorld != fLastMassWorld )
 
  648       G4Exception( 
"G4ITMultiNavigator::CheckMassWorld()",
 
  650                    "Mass world pointer has been changed." ); 
 
  664    G4ITNavigator* pMassNavigator= fpNavigator[0];
 
  668       massVolume= pMassNavigator->ResetHierarchyAndLocate( point, direction,
 
  673       G4Exception(
"G4ITMultiNavigator::ResetHierarchyAndLocate()",
 
  675                   "Cannot reset hierarchy before navigators are initialised.");
 
  678    std::vector<G4ITNavigator*>::iterator pNavIter=
 
  681    for ( 
G4int num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
 
  683       G4bool relativeSearch, ignoreDirection; 
 
  687                                                relativeSearch=
false,
 
  688                                                ignoreDirection=
false);
 
  702   G4int  firstNavigatorId= -1;
 
  703   G4bool        oneObtained= 
false;
 
  708     normalGlobalCrd= fpNavigator[ 
fIdNavLimiting ]->GetGlobalExitNormal( argPoint, &isObtained); 
 
  709     *argpObtained= isObtained; 
 
  715       std::vector<G4ITNavigator*>::iterator pNavIter=
 
  718       for ( 
G4int num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
 
  727             if( !isObtained && (newNormal.
mag2() != 0.0) )
 
  729               normalGlobalCrd= newNormal; 
 
  730               isObtained =     oneObtained;
 
  731               firstNavigatorId= num; 
 
  734               G4double dotNewPrevious= newNormal.
dot( normalGlobalCrd );
 
  736               if( productMagSq > 0.0 ) 
 
  738                 G4double productMag= std::sqrt( productMagSq ); 
 
  739                 dotNewPrevious /= productMag; 
 
  742                   *argpObtained= 
false; 
 
  746                     std::ostringstream message;
 
  747                     message << 
"Clash of Normal from different Navigators!" << 
G4endl 
  748                             << 
"        Previous Navigator Id = " << firstNavigatorId << 
G4endl 
  749                             << 
"        Current  Navigator Id = " << num << 
G4endl;
 
  750                     message << 
"  Dot product of 2 normals = " << dotNewPrevious << 
G4endl;
 
  751                     message << 
"        Normal (previous) = " << normalGlobalCrd << 
G4endl;
 
  752                     message << 
"        Normal (current)  = " << newNormal       << 
G4endl;
 
  753                     G4Exception(
"G4ITMultiNavigator::GetGlobalExitNormal()", 
"GeomNav0002",
 
  770         std::ostringstream message;
 
  772                 << 
" candidate Navigators limiting the step!" << 
G4endl;
 
  773         G4Exception(
"G4ITMultiNavigator::GetGlobalExitNormal()", 
"GeomNav0002",
 
  780   *argpObtained= isObtained;
 
  781   return normalGlobalCrd;
 
  797     normalGlobalCrd= fpNavigator[ 
fIdNavLimiting ]->GetLocalExitNormal( &isObtained); 
 
  798     *argpObtained= isObtained;
 
  801     G4int noWarningsStart= 10, noModuloWarnings=100; 
 
  803     if( (numberWarnings < noWarningsStart ) || (numberWarnings%noModuloWarnings==0) ) 
 
  805     std::ostringstream message;
 
  806     message << 
"Cannot obtain normal in local coordinates of two or more coordinate systems." << 
G4endl;
 
  807     G4Exception(
"G4ITMultiNavigator::GetGlobalExitNormal()", 
"GeomNav0002",
 
  816         std::ostringstream message;
 
  817         message << 
"Cannot obtain normal in local coordinates of two or more coordinate systems." << 
G4endl;
 
  818         G4Exception(
"G4ITMultiNavigator::GetGlobalExitNormal()", 
"GeomNav0002",
 
  823   *argpObtained= isObtained;
 
  824   return normalGlobalCrd; 
 
virtual G4ThreeVector GetLocalExitNormalAndCheck(const G4ThreeVector &CurrentE_Point, G4bool *obtained)
 
static constexpr double mm
 
static const G4double kInfinity
 
#define fWasLimitedByGeometry
 
double dot(const Hep3Vector &) const 
 
void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
 
G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=0, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
 
#define fMinSafety_atSafLocation
 
G4ReferenceCountedHandle< G4TouchableHistory > G4TouchableHistoryHandle
 
#define fLastLocatedPosition
 
void PrepareNewTrack(const G4ThreeVector position, const G4ThreeVector direction)
 
static G4ITTransportationManager * GetTransportationManager()
 
G4GLOB_DLL std::ostream G4cout
 
const G4String & GetName() const 
 
G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=false)
 
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
 
G4double ObtainFinalStep(G4int navigatorId, G4double &pNewSafety, G4double &minStepLast, ELimited &limitedStep)
 
virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &CurrentE_Point, G4bool *obtained)
 
std::vector< G4ITNavigator * >::iterator GetActiveNavigatorsIterator()
 
G4ITNavigator * GetNavigatorForTracking() const 
 
virtual G4int GetCopyNo() const =0
 
#define fMinSafety_PreStepPt
 
void UpdateYourself(G4VPhysicalVolume *pPhysVol, const G4NavigationHistory *history=0)
 
static constexpr double perThousand
 
const G4NavigationHistory * GetHistory() const 
 
G4VPhysicalVolume * ResetHierarchyAndLocate(const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h)
 
G4double ComputeStep(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
 
virtual G4ThreeVector GetLocalExitNormal(G4bool *obtained)
 
G4TouchableHistoryHandle CreateTouchableHistoryHandle() const