Ignore:
Timestamp:
Dec 22, 2010, 3:52:27 PM (15 years ago)
Author:
garnier
Message:

geant4 tag 9.4

Location:
trunk/source/geometry/navigation/src
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/geometry/navigation/src/G4AuxiliaryNavServices.cc

    r1337 r1347  
    2525//
    2626// $Id: G4AuxiliaryNavServices.cc,v 1.3 2006/06/29 18:36:32 gunter Exp $
    27 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// GEANT4 tag $Name: geant4-09-04-ref-00 $
    2828//
    2929// --------------------------------------------------------------------
  • trunk/source/geometry/navigation/src/G4BrentLocator.cc

    r1337 r1347  
    2424// ********************************************************************
    2525//
    26 // $Id: G4BrentLocator.cc,v 1.8 2009/05/15 12:55:48 tnikitin Exp $
    27 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     26// $Id: G4BrentLocator.cc,v 1.9 2010/07/13 15:59:42 gcosmo Exp $
     27// GEANT4 tag $Name: geant4-09-04-ref-00 $
    2828//
    2929// Class G4BrentLocator implementation
     
    142142  G4bool restoredFullEndpoint = false;
    143143
     144  G4int oldprc;  // cout, cerr precision
    144145  G4int substep_no = 0;
    145146   
     
    505506                   << GetEpsilonStepFor() << G4endl;
    506507          }
    507           G4cerr.precision(20);
     508          oldprc = G4cerr.precision(20);
    508509          G4cerr << " Point A (Curve start)     is " << CurveStartPointVelocity
    509510                 << G4endl;
     
    529530                 << GetEpsilonStepFor() <<" DeltaInters= "
    530531                 << GetDeltaIntersectionFor() << G4endl;
     532          G4cerr.precision( oldprc );
    531533
    532534          G4Exception("G4BrentLocator::EstimateIntersectionPoint()",
     
    728730                 -1.0, NewSafety, substep_no);
    729731    G4cout << G4endl;
    730     G4cout.precision( 10 );
     732    oldprc = G4cout.precision( 10 );
    731733    G4double done_len = CurrentA_PointVelocity.GetCurveLength();
    732734    G4double full_len = CurveEndPointVelocity.GetCurveLength();
     
    736738           << " out of " << full_len << " required." << G4endl;
    737739    G4cout << "        Remaining length = " << full_len - done_len << G4endl;
     740    G4cout.precision( oldprc );
    738741
    739742    G4Exception("G4BrentLocator::EstimateIntersectionPoint()",
     
    743746  else if( substep_no >= warn_substeps )
    744747  { 
    745     G4int oldprc= G4cout.precision( 10 );
     748    oldprc= G4cout.precision( 10 );
    746749    G4cout << "WARNING - G4BrentLocator::EstimateIntersectionPoint()"
    747750           << G4endl
  • trunk/source/geometry/navigation/src/G4DrawVoxels.cc

    r1337 r1347  
    2626//
    2727// $Id: G4DrawVoxels.cc,v 1.4 2006/06/29 18:36:34 gunter Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     28// GEANT4 tag $Name: geant4-09-04-ref-00 $
    2929//
    3030//
  • trunk/source/geometry/navigation/src/G4ErrorPropagationNavigator.cc

    r1337 r1347  
    2626//
    2727// $Id: G4ErrorPropagationNavigator.cc,v 1.2 2008/10/24 14:00:03 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     28// GEANT4 tag $Name: geant4-09-04-ref-00 $
    2929//
    3030//
  • trunk/source/geometry/navigation/src/G4GeomTestErrorList.cc

    r1337 r1347  
    2626//
    2727// $Id: G4GeomTestErrorList.cc,v 1.3 2006/06/29 18:36:36 gunter Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     28// GEANT4 tag $Name: geant4-09-04-ref-00 $
    2929//
    3030// --------------------------------------------------------------------
  • trunk/source/geometry/navigation/src/G4GeomTestOverlapList.cc

    r1337 r1347  
    2626//
    2727// $Id: G4GeomTestOverlapList.cc,v 1.3 2006/06/29 18:36:39 gunter Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     28// GEANT4 tag $Name: geant4-09-04-ref-00 $
    2929//
    3030// --------------------------------------------------------------------
  • trunk/source/geometry/navigation/src/G4GeomTestOvershootList.cc

    r1337 r1347  
    2626//
    2727// $Id: G4GeomTestOvershootList.cc,v 1.3 2006/06/29 18:36:41 gunter Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     28// GEANT4 tag $Name: geant4-09-04-ref-00 $
    2929//
    3030// --------------------------------------------------------------------
  • trunk/source/geometry/navigation/src/G4GeomTestPoint.cc

    r1337 r1347  
    2626//
    2727// $Id: G4GeomTestPoint.cc,v 1.3 2006/06/29 18:36:44 gunter Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     28// GEANT4 tag $Name: geant4-09-04-ref-00 $
    2929//
    3030// --------------------------------------------------------------------
  • trunk/source/geometry/navigation/src/G4GeomTestSegment.cc

    r1337 r1347  
    2525//
    2626//
    27 // $Id: G4GeomTestSegment.cc,v 1.11 2007/11/16 09:39:14 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4GeomTestSegment.cc,v 1.13 2010/08/20 09:03:54 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-04-ref-00 $
    2929//
    3030// --------------------------------------------------------------------
     
    275275  G4bool entering;
    276276  G4double vSurfN;
    277   // G4cout<<"Entering Find Some Points vSearch="<<vSearch<<" p="<<p<<G4endl;
    278   //
     277 
    279278  // Look for nearest intersection point in the specified
    280279  // direction and return if there isn't one
     
    283282  switch(solid->Inside(p)) {
    284283    case kInside:
    285        dist = solid->DistanceToOut(p,vSearch);
    286        // G4cout<<"Inside DistToOut="<<dist<<G4endl;
     284      dist = solid->DistanceToOut(p,vSearch);
    287285      if (dist >= kInfinity) {
    288286        logger->SolidProblem( solid,
     
    290288        return;
    291289      }
    292      
    293290      s += sign*dist;
    294291      entering = false;
     
    296293    case kOutside:
    297294      dist = solid->DistanceToIn(p,vSearch);
    298       //G4cout<<"Outside DistToIn="<<dist<<G4endl;
    299295      if (dist >= kInfinity) return;
    300      
    301296      s += sign*dist;
    302297      entering = true;
    303298      break;
    304299    case kSurface:
    305       vSurfN=vSearch.dot(solid->SurfaceNormal(p));
    306       if(std::abs(vSurfN)<kCarTolerance)vSurfN=0;
     300      vSurfN=v.dot(solid->SurfaceNormal(p));
     301      if(std::fabs(vSurfN)<kCarTolerance)vSurfN=0;
    307302      entering = (vSurfN < 0);
    308       //G4cout<<"Surface SurfN="<<solid->SurfaceNormal(p)<<" v.dotN="<<vSurfN<<" entering="<<entering<<G4endl;
    309303      break;
    310304    default:
     
    361355      //
    362356      points.push_back( G4GeomTestPoint( p, s, entering==forward ) );
    363       //G4cout<<"Add point p"<<p<<" s="<<s<<" entering="<<entering<<G4endl;
     357     
    364358    }
    365359   
     
    369363    if (entering) {
    370364      dist = solid->DistanceToOut(p,vSearch);
    371       //G4cout<<"if entering distToOut="<<dist<<G4endl;
    372365      if (dist >= kInfinity) {
    373366        logger->SolidProblem( solid,
     
    389382        return;
    390383      }
    391 
    392        if(std::abs(dist)<=kCarTolerance){
    393           G4double push = 1E-6;
    394           s += sign*push;
    395           p = p0 + s*v;
    396           EInside inside = solid->Inside(p);
    397           if (inside == kOutside) {
    398           entering = false;
    399           break;
    400         }
    401       }
    402 
    403      
     384           
    404385      entering = false;
    405386    }
    406387    else {
    407388      dist = solid->DistanceToIn(p,vSearch);
    408       //G4cout<<"if exiting distToIn="<<dist<<G4endl;
    409389      if (dist >= kInfinity) return;
    410390     
  • trunk/source/geometry/navigation/src/G4GeomTestStreamLogger.cc

    r1337 r1347  
    2626//
    2727// $Id: G4GeomTestStreamLogger.cc,v 1.3 2006/06/29 18:36:49 gunter Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     28// GEANT4 tag $Name: geant4-09-04-ref-00 $
    2929//
    3030// --------------------------------------------------------------------
  • trunk/source/geometry/navigation/src/G4GeomTestVolPoint.cc

    r1337 r1347  
    2626//
    2727// $Id: G4GeomTestVolPoint.cc,v 1.3 2006/06/29 18:36:52 gunter Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     28// GEANT4 tag $Name: geant4-09-04-ref-00 $
    2929//
    3030// --------------------------------------------------------------------
  • trunk/source/geometry/navigation/src/G4GeomTestVolume.cc

    r1337 r1347  
    2626//
    2727// $Id: G4GeomTestVolume.cc,v 1.6 2007/11/16 09:39:14 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     28// GEANT4 tag $Name: geant4-09-04-ref-00 $
    2929//
    3030// --------------------------------------------------------------------
  • trunk/source/geometry/navigation/src/G4GeometryMessenger.cc

    r1337 r1347  
    2525//
    2626//
    27 // $Id: G4GeometryMessenger.cc,v 1.5 2006/06/29 18:36:57 gunter Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4GeometryMessenger.cc,v 1.6 2010/11/10 14:06:40 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-04-ref-00 $
    2929//
    3030// --------------------------------------------------------------------
     
    106106  chkCmd->AvailableForStates(G4State_Idle);
    107107
     108  pchkCmd = new G4UIcmdWithABool( "/geometry/navigator/push_notify", this );
     109  pchkCmd->SetGuidance( "Set navigator verbosity push notifications." );
     110  pchkCmd->SetGuidance( "This allows to disable/re-enable verbosity in" );
     111  pchkCmd->SetGuidance( "navigation, when tracks may get stuck and require" );
     112  pchkCmd->SetGuidance( "one artificial push along the direction by the" );
     113  pchkCmd->SetGuidance( "navigator. Notification is active by default." );
     114  pchkCmd->SetGuidance( "NOTE: this command has effect -only- if Geant4 has" );
     115  pchkCmd->SetGuidance( "      been installed with the G4VERBOSE flag set!" );
     116  pchkCmd->SetParameterName("pushFlag",true);
     117  pchkCmd->SetDefaultValue(true);
     118  pchkCmd->AvailableForStates(G4State_Idle);
     119
    108120  //
    109121  // Geometry verification test commands
     
    244256  delete cyzCmd; delete cfzCmd; delete cfrCmd; delete cylCmd;
    245257  delete tolCmd;
    246   delete resCmd; delete verbCmd; delete chkCmd;
     258  delete resCmd; delete verbCmd; delete pchkCmd; delete chkCmd;
    247259  delete geodir; delete navdir; delete testdir;
    248260  delete tvolume; delete tlogger;
     
    423435  G4Navigator* navigator = tmanager->GetNavigatorForTracking();
    424436  navigator->CheckMode(mode);
     437}
     438
     439//
     440// Set navigator verbosity for push notifications
     441//
     442void
     443G4GeometryMessenger::SetPushFlag(G4String input)
     444{
     445  G4bool mode = pchkCmd->GetNewBoolValue(input);
     446  G4Navigator* navigator = tmanager->GetNavigatorForTracking();
     447  navigator->SetPushVerbosity(mode);
    425448}
    426449
  • trunk/source/geometry/navigation/src/G4MultiLevelLocator.cc

    r1337 r1347  
    2424// ********************************************************************
    2525//
    26 // $Id: G4MultiLevelLocator.cc,v 1.5 2008/12/11 10:01:02 tnikitin Exp $
    27 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     26// $Id: G4MultiLevelLocator.cc,v 1.6 2010/07/13 15:59:42 gcosmo Exp $
     27// GEANT4 tag $Name: geant4-09-04-ref-00 $
    2828//
    2929// Class G4MultiLevelLocator implementation
     
    120120
    121121  G4int substep_no = 0;
    122    
     122
     123  G4int oldprc;   // cout/cerr precision settings
     124
    123125  // Limits for substep number
    124126  //
     
    156158
    157159#ifdef G4DEBUG_FIELD
    158   static G4double tolerance= 1.0e-8;
     160  static const G4double tolerance = 1.0e-8 * mm;
    159161  G4ThreeVector  StartPosition= CurveStartPointVelocity.GetPosition();
    160   if( (TrialPoint - StartPosition).mag() < tolerance * mm )
     162  if( (TrialPoint - StartPosition).mag() < tolerance)
    161163  {
    162164     G4cerr << "WARNING - G4MultiLevelLocator::EstimateIntersectionPoint()"
     
    455457                   << GetEpsilonStepFor() << G4endl;
    456458          }
    457           G4cerr.precision(20);
     459          oldprc = G4cerr.precision(20);
    458460          G4cerr << " Point A (Curve start)   is " << CurveStartPointVelocity
    459461                 << G4endl;
     
    474476          G4cerr << "        Substep depth no= "<< substep_no_p  << " Depth= "
    475477                 << depth << G4endl;
     478          G4cerr.precision(oldprc);
    476479
    477480          G4Exception("G4MultiLevelLocator::EstimateIntersectionPoint()",
     
    691694#endif
    692695
    693     G4cout.precision( 10 );
     696    oldprc = G4cout.precision( 10 );
    694697    G4double done_len = CurrentA_PointVelocity.GetCurveLength();
    695698    G4double full_len = CurveEndPointVelocity.GetCurveLength();
     
    699702           << " out of " << full_len << " required." << G4endl;
    700703    G4cout << "        Remaining length = " << full_len - done_len << G4endl;
     704    G4cout.precision( oldprc );
    701705
    702706    G4Exception("G4MultiLevelLocator::EstimateIntersectionPoint()",
     
    706710  else if( substep_no >= warn_substeps )
    707711  { 
    708     G4int oldprc= G4cout.precision( 10 );
     712    oldprc = G4cout.precision( 10 );
    709713    G4cout << "WARNING - G4MultiLevelLocator::EstimateIntersectionPoint()"
    710714           << G4endl
  • trunk/source/geometry/navigation/src/G4MultiNavigator.cc

    r921 r1347  
    2525//
    2626//
    27 // $Id: G4MultiNavigator.cc,v 1.8 2008/10/24 14:00:03 gcosmo Exp $
     27// $Id: G4MultiNavigator.cc,v 1.11 2010/09/06 09:49:15 gcosmo Exp $
    2828// GEANT4 tag $ Name:  $
    2929//
     
    4848//
    4949G4MultiNavigator::G4MultiNavigator()
    50   : G4Navigator()
     50  : G4Navigator(), fLastMassWorld(0)
    5151{
    5252  fNoActiveNavigators= 0;
    53   G4ThreeVector Big3Vector( DBL_MAX, DBL_MAX, DBL_MAX );
     53  G4ThreeVector Big3Vector( kInfinity, kInfinity, kInfinity );
    5454  fLastLocatedPosition = Big3Vector;
    5555  fSafetyLocation  = Big3Vector;
     
    5858  fMinSafety_PreStepPt=  -1.0;
    5959  fMinSafety_atSafLocation= -1.0;
    60   fMinSafety= -DBL_MAX
    61   fMinStep=   -DBL_MAX
    62 
    63   for(register int num=0; num<= fMaxNav; ++num )
     60  fMinSafety= -kInfinity
     61  fTrueMinStep= fMinStep= -kInfinity
     62
     63  for(register int num=0; num< fMaxNav; ++num )
    6464  {
    6565    fpNavigator[num] =  0;   
    6666    fLimitTruth[num] = false;
    6767    fLimitedStep[num] = kUndefLimited;
    68     fCurrentStepSize[num] = -1.0;
     68    fCurrentStepSize[num] = fNewSafety[num] = -1.0;
    6969    fLocatedVolume[num] = 0;
    7070  }
     
    9494{
    9595  G4double safety= 0.0, step=0.0;
    96   G4double minSafety= DBL_MAX, minStep= DBL_MAX;
     96  G4double minSafety= kInfinity, minStep= kInfinity;
    9797
    9898#ifdef G4DEBUG_NAVIGATION
     
    115115  for( register int num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
    116116  {
    117      safety= DBL_MAX;
     117     safety= kInfinity;
    118118
    119119     step= (*pNavigatorIter)->ComputeStep( initialPosition,
     
    189189                                   ELimited &limitedStep)
    190190{
    191   G4int navigatorNo=-1;
    192 
    193   if( navigatorId <= fNoActiveNavigators )
    194   {
    195      navigatorNo= navigatorId;
    196   }
    197   else
     191  if( navigatorId > fNoActiveNavigators )
    198192  {
    199193     G4cerr << "ERROR - G4MultiNavigator::ObtainFinalStep()"
     
    206200
    207201  // Prepare the information to return
    208   pNewSafety  = fNewSafety[ navigatorNo ];
    209   limitedStep = fLimitedStep[ navigatorNo ];
     202  //
     203  pNewSafety  = fNewSafety[ navigatorId ];
     204  limitedStep = fLimitedStep[ navigatorId ];
    210205  minStep= fMinStep;
    211206
    212   // if( (minStep==kInfinity) || (fVerbose > 1) ){
    213 #ifdef G4DEBUG_NAVIGATION
    214   if( fVerbose > 1 ){
    215      G4cout << " G4MultiNavigator::ComputeStep returns " << fCurrentStepSize[ navigatorNo ]
    216             << " for Navigator " << navigatorNo << " Limited step = " << limitedStep
     207#ifdef G4DEBUG_NAVIGATION
     208  if( fVerbose > 1 )
     209  {
     210     G4cout << " G4MultiNavigator::ComputeStep returns "
     211            << fCurrentStepSize[ navigatorId ]
     212            << " for Navigator " << navigatorId
     213            << " Limited step = " << limitedStep
    217214            << " Safety(mm) = " << pNewSafety / mm << G4endl;
    218215  }
    219216#endif
    220217
    221   return fCurrentStepSize[ navigatorNo ];
     218  return fCurrentStepSize[ navigatorId ];
    222219}
    223220
     
    428425    // Recompute safety for the relevant point
    429426
    430     G4double minSafety = DBL_MAX, safety = DBL_MAX;
     427    G4double minSafety = kInfinity, safety = kInfinity;
    431428 
    432429    std::vector<G4Navigator*>::iterator pNavigatorIter;
  • trunk/source/geometry/navigation/src/G4Navigator.cc

    r1058 r1347  
    2525//
    2626//
    27 // $Id: G4Navigator.cc,v 1.39 2009/05/08 06:47:32 tnikitin Exp $
     27// $Id: G4Navigator.cc,v 1.46 2010/11/15 14:03:27 gcosmo Exp $
    2828// GEANT4 tag $ Name:  $
    2929//
     
    4747G4Navigator::G4Navigator()
    4848  : fWasLimitedByGeometry(false), fVerbose(0),
    49     fTopPhysical(0), fCheck(false), fPushed(false)
     49    fTopPhysical(0), fCheck(false), fPushed(false), fWarnPush(true)
    5050{
    5151  fActive= false;
     
    128128
    129129#ifdef G4VERBOSE
    130   G4int oldcoutPrec = G4cout.precision(8);
    131130  if( fVerbose > 2 )
    132131  {
     132    G4int oldcoutPrec = G4cout.precision(8);
    133133    G4cout << "*** G4Navigator::LocateGlobalPointAndSetup: ***" << G4endl;
    134134    G4cout << "    Called with arguments: " << G4endl
     
    140140      PrintState();
    141141    }
     142    G4cout.precision(oldcoutPrec);
    142143  }
    143144#endif
     
    195196              break;
    196197            case kParameterised:
    197               if( fBlockedPhysicalVolume->GetRegularStructureId() != 1 )
     198              if( fBlockedPhysicalVolume->GetRegularStructureId() == 0 )
    198199              {
    199200                G4VSolid *pSolid;
     
    360361    //
    361362    targetPhysical = fHistory.GetTopVolume();
     363    if (!targetPhysical) { break; }
    362364    targetLogical = targetPhysical->GetLogicalVolume();
    363365    switch( CharacteriseDaughters(targetLogical) )
     
    452454  if( fVerbose == 4 )
    453455  {
    454     G4cout.precision(6);
     456    G4int oldcoutPrec = G4cout.precision(8);
    455457    G4String curPhysVol_Name("None");
    456     if (targetPhysical!=0)
    457     {
    458       curPhysVol_Name = targetPhysical->GetName();
    459     }
     458    if (targetPhysical)  { curPhysVol_Name = targetPhysical->GetName(); }
    460459    G4cout << "    Return value = new volume = " << curPhysVol_Name << G4endl;
    461460    G4cout << "    ----- Upon exiting:" << G4endl;
     
    465464    G4cout << "    History = " << G4endl << fHistory << G4endl << G4endl;
    466465#endif
    467   }
    468   G4cout.precision(oldcoutPrec);
     466    G4cout.precision(oldcoutPrec);
     467  }
    469468#endif
    470469
     
    627626{
    628627  G4ThreeVector localDirection = ComputeLocalAxis(pDirection);
    629   G4double Step = DBL_MAX;
     628  G4double Step = kInfinity;
    630629  G4VPhysicalVolume  *motherPhysical = fHistory.GetTopVolume();
    631630  G4LogicalVolume *motherLogical = motherPhysical->GetLogicalVolume();
     
    635634
    636635#ifdef G4VERBOSE
    637   G4int oldcoutPrec= G4cout.precision(8);
    638   G4int oldcerrPrec= G4cerr.precision(10);
    639636  if( fVerbose > 0 )
    640637  {
     
    654651#endif
    655652  }
    656 
    657   static G4double fAccuracyForWarning   = kCarTolerance,
    658                   fAccuracyForException = 1000*kCarTolerance;
    659653#endif
    660654
     
    670664    {
    671665#ifdef G4VERBOSE
    672       //  The following checks only make sense if the move is larger
    673       //  than the tolerance.
    674       //
    675       G4ThreeVector OriginalGlobalpoint =
    676                     fHistory.GetTopTransform().Inverse().
    677                     TransformPoint(fLastLocatedPointLocal);
    678 
    679       G4double shiftOriginSafSq = (fPreviousSftOrigin-pGlobalpoint).mag2();
    680 
    681       // Check that the starting point of this step is
    682       // within the isotropic safety sphere of the last point
    683       // to a accuracy/precision  given by fAccuracyForWarning.
    684       //   If so give warning.
    685       //   If it fails by more than fAccuracyForException exit with error.
    686       //
    687       if( shiftOriginSafSq >= sqr(fPreviousSafety) )
    688       {
    689         G4double shiftOrigin = std::sqrt(shiftOriginSafSq);
    690         G4double diffShiftSaf = shiftOrigin - fPreviousSafety;
    691 
    692         if( diffShiftSaf > fAccuracyForWarning )
    693         {
    694           G4Exception("G4Navigator::ComputeStep()",
    695                       "UnexpectedPositionShift", JustWarning,
    696                       "Accuracy ERROR or slightly inaccurate position shift.");
    697           G4cerr << "     The Step's starting point has moved "
    698                  << std::sqrt(moveLenSq)/mm << " mm " << G4endl
    699                  << "     since the last call to a Locate method." << G4endl;
    700           G4cerr << "     This has resulted in moving "
    701                  << shiftOrigin/mm << " mm "
    702                  << " from the last point at which the safety "
    703                  << "     was calculated " << G4endl;
    704           G4cerr << "     which is more than the computed safety= "
    705                  << fPreviousSafety/mm << " mm  at that point." << G4endl;
    706           G4cerr << "     This difference is "
    707                  << diffShiftSaf/mm << " mm." << G4endl
    708                  << "     The tolerated accuracy is "
    709                  << fAccuracyForException/mm << " mm." << G4endl;
    710 
    711           static G4int warnNow = 0;
    712           if( ((++warnNow % 100) == 1) )
    713           {
    714             G4cerr << "  This problem can be due to either " << G4endl;
    715             G4cerr << "    - a process that has proposed a displacement"
    716                    << " larger than the current safety , or" << G4endl;
    717             G4cerr << "    - inaccuracy in the computation of the safety"
    718                    << G4endl;
    719             G4cerr << "  We suggest that you " << G4endl
    720                    << "   - find i) what particle is being tracked, and "
    721                    << " ii) through what part of your geometry " << G4endl
    722                    << "      for example by re-running this event with "
    723                    << G4endl
    724                    << "         /tracking/verbose 1 "  << G4endl
    725                    << "    - check which processes you declare for"
    726                    << " this particle (and look at non-standard ones)"
    727                    << G4endl
    728                    << "   - in case, create a detailed logfile"
    729                    << " of this event using:" << G4endl
    730                    << "         /tracking/verbose 6 "
    731                    << G4endl;
    732           }
    733         }
    734 #ifdef G4DEBUG_NAVIGATION
    735         else
    736         {
    737           G4cerr << "WARNING - G4Navigator::ComputeStep()" << G4endl
    738                  << "          The Step's starting point has moved "
    739                  << std::sqrt(moveLenSq) << "," << G4endl
    740                  << "          which has taken it to the limit of"
    741                  << " the current safety. " << G4endl;
    742         }
    743 #endif
    744       }
    745       G4double safetyPlus = fPreviousSafety + fAccuracyForException;
    746       if ( shiftOriginSafSq > sqr(safetyPlus) )
    747       {
    748         G4cerr << "ERROR - G4Navigator::ComputeStep()" << G4endl
    749                << "        Position has shifted considerably without"
    750                << " notifying the navigator !" << G4endl
    751                << "        Tolerated safety: " << safetyPlus << G4endl
    752                << "        Computed shift  : " << shiftOriginSafSq << G4endl;
    753         G4Exception("G4Navigator::ComputeStep()",
    754                     "SignificantPositionShift", JustWarning,
    755                     "May lead to a crash or unreliable results.");
    756       }
    757 #endif  // end G4VERBOSE
    758 
     666      ComputeStepLog(pGlobalpoint, moveLenSq);
     667#endif
    759668      // Relocate the point within the same volume
    760669      //
     
    784693        else
    785694        {
    786           if( motherPhysical->GetRegularStructureId() != 1 )
     695          if( motherPhysical->GetRegularStructureId() == 0 )
    787696          {
    788697            Step = fnormalNav.ComputeStep(fLastLocatedPointLocal,
     
    811720            // reset the history topvolume to world.
    812721            //
    813             if(fHistory.GetTopVolume()->GetRegularStructureId() != 1 )
     722            if(fHistory.GetTopVolume()->GetRegularStructureId() == 0 )
    814723            {
    815724              G4Exception("G4Navigator::ComputeStep()",
     
    944853       // Act to recover this stuck track. Pushing it along direction
    945854       //
    946        Step += 0.9*kCarTolerance;
     855       Step += 100*kCarTolerance;
    947856#ifdef G4VERBOSE
    948        if (!fPushed)
     857       if ((!fPushed) && (fWarnPush))
    949858       {
    950859         G4cerr << "WARNING - G4Navigator::ComputeStep()" << G4endl
     
    1048957    G4cout << "    Safety = " << pNewSafety << G4endl;
    1049958  }
    1050   G4cout.precision(oldcoutPrec);
    1051   G4cerr.precision(oldcerrPrec);
    1052959#endif
    1053960
     
    11121019  fBlockedReplicaNo      = -1;
    11131020
    1114   fLastLocatedPointLocal = G4ThreeVector( DBL_MAX, -DBL_MAX, 0.0 );
     1021  fLastLocatedPointLocal = G4ThreeVector( kInfinity, -kInfinity, 0.0 );
    11151022  fLocatedOutsideWorld   = false;
    11161023}
     
    11321039  G4VPVParameterisation *pParam;
    11331040
    1134   mother = fHistory.GetVolume(0);
    11351041  for ( i=1; i<=cdepth; i++ )
    11361042  {
     
    14081314
    14091315// ********************************************************************
     1316// ComputeStepLog
     1317// ********************************************************************
     1318//
     1319void G4Navigator::ComputeStepLog(const G4ThreeVector& pGlobalpoint,
     1320                                       G4double moveLenSq) const
     1321{
     1322  //  The following checks only make sense if the move is larger
     1323  //  than the tolerance.
     1324
     1325  static const G4double fAccuracyForWarning   = kCarTolerance,
     1326                        fAccuracyForException = 1000*kCarTolerance;
     1327
     1328  G4ThreeVector OriginalGlobalpoint = fHistory.GetTopTransform().Inverse().
     1329                                      TransformPoint(fLastLocatedPointLocal);
     1330
     1331  G4double shiftOriginSafSq = (fPreviousSftOrigin-pGlobalpoint).mag2();
     1332
     1333  // Check that the starting point of this step is
     1334  // within the isotropic safety sphere of the last point
     1335  // to a accuracy/precision  given by fAccuracyForWarning.
     1336  //   If so give warning.
     1337  //   If it fails by more than fAccuracyForException exit with error.
     1338  //
     1339  if( shiftOriginSafSq >= sqr(fPreviousSafety) )
     1340  {
     1341    G4double shiftOrigin = std::sqrt(shiftOriginSafSq);
     1342    G4double diffShiftSaf = shiftOrigin - fPreviousSafety;
     1343
     1344    if( diffShiftSaf > fAccuracyForWarning )
     1345    {
     1346      G4int oldcoutPrec= G4cout.precision(8);
     1347      G4int oldcerrPrec= G4cerr.precision(10);
     1348      G4Exception("G4Navigator::ComputeStep()",
     1349                  "UnexpectedPositionShift", JustWarning,
     1350                  "Accuracy error or slightly inaccurate position shift.");
     1351      G4cerr << "     The Step's starting point has moved "
     1352             << std::sqrt(moveLenSq)/mm << " mm " << G4endl
     1353             << "     since the last call to a Locate method." << G4endl;
     1354      G4cerr << "     This has resulted in moving "
     1355             << shiftOrigin/mm << " mm "
     1356             << " from the last point at which the safety "
     1357             << "     was calculated " << G4endl;
     1358      G4cerr << "     which is more than the computed safety= "
     1359             << fPreviousSafety/mm << " mm  at that point." << G4endl;
     1360      G4cerr << "     This difference is "
     1361             << diffShiftSaf/mm << " mm." << G4endl
     1362             << "     The tolerated accuracy is "
     1363             << fAccuracyForException/mm << " mm." << G4endl;
     1364
     1365      static G4int warnNow = 0;
     1366      if( ((++warnNow % 100) == 1) )
     1367      {
     1368        G4cerr << "  This problem can be due to either " << G4endl;
     1369        G4cerr << "    - a process that has proposed a displacement"
     1370               << " larger than the current safety , or" << G4endl;
     1371        G4cerr << "    - inaccuracy in the computation of the safety"
     1372                   << G4endl;
     1373        G4cerr << "  We suggest that you " << G4endl
     1374               << "   - find i) what particle is being tracked, and "
     1375               << " ii) through what part of your geometry " << G4endl
     1376               << "      for example by re-running this event with "
     1377               << G4endl
     1378               << "         /tracking/verbose 1 "  << G4endl
     1379               << "    - check which processes you declare for"
     1380               << " this particle (and look at non-standard ones)"
     1381               << G4endl
     1382               << "   - in case, create a detailed logfile"
     1383               << " of this event using:" << G4endl
     1384               << "         /tracking/verbose 6 "
     1385               << G4endl;
     1386      }
     1387      G4cout.precision(oldcoutPrec);
     1388      G4cerr.precision(oldcerrPrec);
     1389    }
     1390#ifdef G4DEBUG_NAVIGATION
     1391    else
     1392    {
     1393      G4cerr << "WARNING - G4Navigator::ComputeStep()" << G4endl
     1394             << "          The Step's starting point has moved "
     1395             << std::sqrt(moveLenSq) << "," << G4endl
     1396             << "          which has taken it to the limit of"
     1397             << " the current safety. " << G4endl;
     1398    }
     1399#endif
     1400  }
     1401  G4double safetyPlus = fPreviousSafety + fAccuracyForException;
     1402  if ( shiftOriginSafSq > sqr(safetyPlus) )
     1403  {
     1404    G4cerr << "ERROR - G4Navigator::ComputeStep()" << G4endl
     1405           << "        Position has shifted considerably without"
     1406           << " notifying the navigator !" << G4endl
     1407           << "        Tolerated safety: " << safetyPlus << G4endl
     1408           << "        Computed shift  : " << shiftOriginSafSq << G4endl;
     1409    G4Exception("G4Navigator::ComputeStep()",
     1410                "SignificantPositionShift", JustWarning,
     1411                "May lead to a crash or unreliable results.");
     1412  }
     1413}
     1414
     1415// ********************************************************************
    14101416// Operator <<
    14111417// ********************************************************************
  • trunk/source/geometry/navigation/src/G4NormalNavigation.cc

    r1337 r1347  
    2525//
    2626//
    27 // $Id: G4NormalNavigation.cc,v 1.9 2007/05/11 13:43:59 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4NormalNavigation.cc,v 1.11 2010/11/04 08:57:56 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-04-ref-00 $
    2929//
    3030//
     
    3838#include "G4AffineTransform.hh"
    3939
    40 #include <iomanip>
    41 
    4240// ********************************************************************
    4341// Constructor
     
    4543//
    4644G4NormalNavigation::G4NormalNavigation()
    47   : fCheck(false), fVerbose(0)
    48 {
     45  : fCheck(false)
     46{
     47  fLogger = new G4NavigationLogger("G4NormalNavigation");
    4948}
    5049
     
    5453//
    5554G4NormalNavigation::~G4NormalNavigation()
    56 {;}
     55{
     56  delete fLogger;
     57}
    5758
    5859// ********************************************************************
     
    9091 
    9192#ifdef G4VERBOSE
    92   static G4int precVerf= 20;  // Precision
    9393  if ( fCheck )
    9494  {
    95     if( fVerbose == 1 )
    96     {
    97       G4cout << "*** G4NormalNavigation::ComputeStep(): ***" << G4endl
    98              << "    Invoked DistanceToOut(p) for mother solid: "
    99              << motherSolid->GetName()
    100              << ". Solid replied: " << motherSafety << G4endl
    101              << "    For local point p: " << localPoint << G4endl
    102              << "    To be considered as 'mother safety'." << G4endl;
    103     }
    104     if ( motherSafety < 0.0 )
    105     {
    106       G4cerr << "ERROR - G4NormalNavigation::ComputeStep()" << G4endl
    107              << "        Current solid " << motherSolid->GetName()
    108              << " gave negative safety: " << motherSafety << G4endl
    109              << "        for the current (local) point " << localPoint
    110              << G4endl;
    111       motherSolid->DumpInfo();
    112       G4Exception("G4NormalNavigation::ComputeStep()",
    113                   "NegativeSafetyMotherVol", FatalException,
    114                   "Negative Safety In Voxel Navigation !" );
    115     }
    116     if( motherSolid->Inside(localPoint)==kOutside )
    117     {
    118       G4cout << "WARNING - G4NormalNavigation::ComputeStep()" << G4endl
    119              << "          Point " << localPoint
    120              << " is outside current volume " << motherPhysical->GetName()
    121              << G4endl;
    122       G4double estDistToSolid= motherSolid->DistanceToIn(localPoint);
    123       G4cout << "          Estimated isotropic distance to solid (distToIn)= "
    124              << estDistToSolid << G4endl;
    125       if( estDistToSolid > 100.0 * motherSolid->GetTolerance() )
    126       {
    127         motherSolid->DumpInfo();
    128         G4Exception("G4NormalNavigation::ComputeStep()",
    129                     "FarOutsideCurrentVolume", FatalException,
    130                     "Point is far outside Current Volume !" );
    131       }
    132       else
    133         G4Exception("G4NormalNavigation::ComputeStep()", "OutsideCurrentVolume",
    134                     JustWarning, "Point is a little outside Current Volume.");
    135     }
    136 
    137     // Verification / verbosity
    138     //
    139     if ( fVerbose > 1 )
    140     {
    141       G4int oldprec = G4cout.precision(precVerf);
    142       G4cout << " G4NormalNavigation::ComputeStep()"
    143              << " - Information on mother / key daughters ..." << G4endl;
    144       G4cout << " Type   " << std::setw(12) << "Solid-Name"   << " "
    145              << std::setw(3*(6+precVerf))   << " local point" << " "
    146              << std::setw(4+precVerf)       << "solid-Safety" << " "
    147              << std::setw(4+precVerf)       << "solid-Step"   << " "
    148              << std::setw(17)               << "distance Method "
    149              << std::setw(3*(6+precVerf))   << " local direction" << " "
    150              << G4endl;
    151       G4cout << " Mother " << std::setw(12) << motherSolid->GetName() << " "
    152              << std::setw(4+precVerf)       << localPoint   << " "
    153              << std::setw(4+precVerf)       << motherSafety << " "
    154              << G4endl;
    155       G4cout.precision(oldprec);
    156     }
    157 
     95    fLogger->PreComputeStepLog(motherPhysical, motherSafety, localPoint);
    15896  }
    15997#endif
     
    193131      const G4double sampleSafety =
    194132              sampleSolid->DistanceToIn(samplePoint);
     133#ifdef G4VERBOSE
     134      if( fCheck )
     135      {
     136        fLogger->PrintDaughterLog(sampleSolid, samplePoint, sampleSafety, 0);
     137      }
     138#endif
    195139      if ( sampleSafety<ourSafety )
    196140      {
     
    202146        const G4double sampleStep =
    203147                sampleSolid->DistanceToIn(samplePoint,sampleDirection);
    204 #ifdef G4VERBOSE
    205         if(( fCheck ) && ( fVerbose == 1 ))
     148
     149#ifdef G4VERBOSE
     150        if( fCheck )
    206151        {
    207           G4cout << "*** G4NormalNavigation::ComputeStep(): ***" << G4endl
    208                  << "    Invoked DistanceToIn(p,v) for daughter solid: "
    209                  << sampleSolid->GetName()
    210                  << ". Solid replied: " << sampleStep << G4endl
    211                  << "    For local point p: " << samplePoint << G4endl
    212                  << "    Direction v: " << sampleDirection
    213                  << ", to be considered as 'daughter step'." << G4endl;
     152          fLogger->PrintDaughterLog(sampleSolid, samplePoint,
     153                                    sampleSafety, sampleStep);
    214154        }
    215155#endif
     
    221161          *pBlockedPhysical = samplePhysical;
    222162          blockedReplicaNo  = -1;
    223 
    224 #ifdef G4VERBOSE
    225           // Check to see that the resulting point is indeed in/on volume.
    226           // This check could eventually be made only for successful candidate.
    227 
    228           if ( ( fCheck ) && ( sampleStep < kInfinity ) )
     163#ifdef G4VERBOSE
     164          if( fCheck )
    229165          {
    230             G4ThreeVector intersectionPoint;
    231             intersectionPoint= samplePoint + sampleStep * sampleDirection;
    232             EInside insideIntPt= sampleSolid->Inside(intersectionPoint);
    233             G4String solidResponse = "-kInside-";
    234             if (insideIntPt == kOutside)
    235               solidResponse = "-kOutside-";
    236             else if (insideIntPt == kSurface)
    237               solidResponse = "-kSurface-";
    238             if( fVerbose == 1 )
    239             {
    240               G4cout << "*** G4NormalNavigation::ComputeStep(): ***" << G4endl
    241                      << "    Invoked Inside() for solid: "
    242                      << sampleSolid->GetName()
    243                      << ". Solid replied: " << solidResponse << G4endl
    244                      << "    For point p: " << intersectionPoint
    245                      << ", considered as 'intersection' point." << G4endl;
    246             }
    247             if ( insideIntPt != kSurface )
    248             {
    249               G4int oldcoutPrec = G4cout.precision(16);
    250               G4cout << "WARNING - G4NormalNavigation::ComputeStep()" << G4endl
    251                      << "          Inaccurate DistanceToIn for solid "
    252                      << sampleSolid->GetName() << G4endl;
    253               G4cout << "          Solid gave DistanceToIn = " << sampleStep
    254                      << " yet returns " << solidResponse
    255                      << " for this point !" << G4endl;
    256               G4cout << "          Point = " << intersectionPoint << G4endl;
    257               if ( insideIntPt != kInside )
    258                 G4cout << "        DistanceToIn(p) = "
    259                        << sampleSolid->DistanceToIn(intersectionPoint)
    260                        << G4endl;
    261               if ( insideIntPt != kOutside )
    262                 G4cout << "        DistanceToOut(p) = "
    263                        << sampleSolid->DistanceToOut(intersectionPoint)
    264                        << G4endl;
    265               G4Exception("G4NormalNavigation::ComputeStep()",
    266                           "InaccurateDistanceToIn", JustWarning,
    267                           "Navigator gets conflicting response from Solid.");
    268               G4cout.precision(oldcoutPrec);
    269             }
    270           }
    271 
    272           // Verification / verbosity
    273           //
    274           if ( fVerbose > 1 )
    275           {
    276             G4int oldprec = G4cout.precision(precVerf);
    277             G4cout << " Daught "
    278                    << std::setw(12)         << sampleSolid->GetName() << " "
    279                    << std::setw(4+precVerf) << samplePoint  << " "
    280                    << std::setw(4+precVerf) << sampleSafety << " "
    281                    << std::setw(4+precVerf) << sampleStep   << " "
    282                    << std::setw(16)         << "distanceToIn" << " "
    283                    << std::setw(4+precVerf) << localDirection << " "
    284                    << G4endl;
    285             G4cout.precision(oldprec);
     166            fLogger->AlongComputeStepLog(sampleSolid, samplePoint,
     167              sampleDirection, localDirection, sampleSafety, sampleStep);
    286168          }
    287169#endif
     
    313195      if ( fCheck )
    314196      {
    315         if( fVerbose == 1 )
    316         {
    317           G4cout << "*** G4NormalNavigation::ComputeStep(): ***" << G4endl
    318                  << "    Invoked DistanceToOut(p,v,...) for mother solid: "
    319                  << motherSolid->GetName()
    320                  << ". Solid replied: " << motherStep << G4endl
    321                  << "    For local point p: " << localPoint << G4endl
    322                  << "    Direction v: " << localDirection
    323                  << ", to be considered as 'mother step'." << G4endl;
    324         }
    325         if( ( motherStep < 0.0 ) || ( motherStep >= kInfinity) )
    326         {
    327           G4cerr << "ERROR - G4NormalNavigation::ComputeStep()" << G4endl
    328                  << "        Problem in Navigation"  << G4endl
    329                  << "        Point (local coordinates): "
    330                  << localPoint << G4endl
    331                  << "        Local Direction: " << localDirection << G4endl
    332                  << "        Solid: " << motherSolid->GetName() << G4endl;
    333           motherSolid->DumpInfo();
    334           G4Exception("G4NormalNavigation::ComputeStep()",
    335                       "PointDistOutInvalid", FatalException,
    336                       "Current point is outside the current solid !");
    337         }
    338       }
    339       if ( fVerbose > 1 )
    340       {
    341         G4int oldprec = G4cout.precision(precVerf);
    342         G4cout << " Mother " << std::setw(12) << motherSolid->GetName() << " "
    343                << std::setw(4+precVerf)       << localPoint   << " "
    344                << std::setw(4+precVerf)       << motherSafety << " "
    345                << std::setw(4+precVerf)       << motherStep   << " "
    346                << std::setw(16)               << "distanceToOut" << " "
    347                << std::setw(4+precVerf)       << localDirection << " "
    348                << G4endl;
    349         G4cout.precision(oldprec);     
     197        fLogger->PostComputeStepLog(motherSolid, localPoint, localDirection,
     198                                    motherStep, motherSafety);
    350199      }
    351200#endif
     
    399248
    400249#ifdef G4VERBOSE
    401   if(( fCheck ) && ( fVerbose == 1 ))
    402   {
    403     G4cout << "*** G4NormalNavigation::ComputeSafety(): ***" << G4endl
    404            << "    Invoked DistanceToOut(p) for mother solid: "
    405            << motherSolid->GetName()
    406            << ". Solid replied: " << motherSafety << G4endl
    407            << "    For local point p: " << localPoint
    408            << ", to be considered as 'mother safety'." << G4endl;
     250  if( fCheck )
     251  {
     252    fLogger->ComputeSafetyLog(motherSolid, localPoint, motherSafety, true);
    409253  }
    410254#endif
     
    430274    }
    431275#ifdef G4VERBOSE
    432     if(( fCheck ) && ( fVerbose == 1 ))
    433     {
    434       G4cout << "*** G4NormalNavigation::ComputeSafety(): ***" << G4endl
    435              << "    Invoked DistanceToIn(p) for daughter solid: "
    436              << sampleSolid->GetName()
    437              << ". Solid replied: " << sampleSafety << G4endl
    438              << "    For local point p: " << samplePoint
    439              << ", to be considered as 'daughter safety'." << G4endl;
     276    if(fCheck)
     277    {
     278      fLogger->ComputeSafetyLog(sampleSolid, samplePoint, sampleSafety, false);
    440279    }
    441280#endif
  • trunk/source/geometry/navigation/src/G4ParameterisedNavigation.cc

    r1337 r1347  
    2525//
    2626//
    27 // $Id: G4ParameterisedNavigation.cc,v 1.12 2007/11/09 16:06:02 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4ParameterisedNavigation.cc,v 1.13 2010/07/13 15:59:42 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-04-ref-00 $
    2929//
    3030//
     
    5858//
    5959G4ParameterisedNavigation::G4ParameterisedNavigation()
    60   : fVoxelHeader(0)
     60  : fVoxelAxis(kUndefined), fVoxelNoSlices(0), fVoxelSliceWidth(0.),
     61    fVoxelNodeNo(0), fVoxelHeader(0)
    6162{
    6263}
  • trunk/source/geometry/navigation/src/G4PathFinder.cc

    r1058 r1347  
    2525//
    2626//
    27 // $Id: G4PathFinder.cc,v 1.62 2009/05/13 23:20:54 japost Exp $
     27// $Id: G4PathFinder.cc,v 1.64 2010/07/13 15:59:42 gcosmo Exp $
    2828// GEANT4 tag $ Name:  $
    2929//
     
    6969G4PathFinder::G4PathFinder()
    7070  : fEndState( G4ThreeVector(), G4ThreeVector(), 0., 0., 0., 0., 0.),
     71    fFieldExertedForce(false),
    7172    fRelocatedPoint(true),
    72     fLastStepNo(-1),
     73    fLastStepNo(-1), fCurrentStepNo(-1),
    7374    fVerboseLevel(0)
    7475{
     
    9192   fMinSafety_atSafLocation= -1.0;
    9293   fMinStep=   -1.0;
     94   fTrueMinStep= -1.0;
     95   fPreStepCenterRenewed= false;
    9396   fNewTrack= false;
    9497   fNoGeometriesLimiting= 0;
    9598
    96    for( register int num=0; num<= fMaxNav; ++num )
     99   for( register int num=0; num< fMaxNav; ++num )
    97100   {
    98101      fpNavigator[num] =  0;   
  • trunk/source/geometry/navigation/src/G4PhantomParameterisation.cc

    r1058 r1347  
    2525//
    2626//
    27 // $Id: G4PhantomParameterisation.cc,v 1.6 2009/05/20 08:27:10 gcosmo Exp $
     27// $Id: G4PhantomParameterisation.cc,v 1.7 2010/07/13 15:59:42 gcosmo Exp $
    2828// GEANT4 tag $ Name:$
    2929//
     
    4545//------------------------------------------------------------------
    4646G4PhantomParameterisation::G4PhantomParameterisation()
    47 {
    48   // Initialise data
    49   //
    50   fMaterialIndices = 0;
    51   fContainerWallX = 0.;
    52   fContainerWallY = 0.;
    53   fContainerWallZ = 0.;
    54 
     47  : fVoxelHalfX(0.), fVoxelHalfY(0.), fVoxelHalfZ(0.),
     48    fNoVoxelX(0), fNoVoxelY(0), fNoVoxelZ(0), fNoVoxelXY(0), fNoVoxel(0),
     49    fMaterialIndices(0), fContainerSolid(0),
     50    fContainerWallX(0.), fContainerWallY(0.), fContainerWallZ(0.),
     51    bSkipEqualMaterials(true)
     52{
    5553  kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
    56 
    57   bSkipEqualMaterials = 1;
    5854}
    5955
  • trunk/source/geometry/navigation/src/G4PropagatorInField.cc

    r1315 r1347  
    3636// 17.03.97 John Apostolakis,   renaming new set functions being added
    3737//
    38 // $Id: G4PropagatorInField.cc,v 1.51 2010/03/08 13:57:34 gcosmo Exp $
     38// $Id: G4PropagatorInField.cc,v 1.52 2010/07/13 15:59:42 gcosmo Exp $
    3939// GEANT4 tag $ Name:  $
    4040// ---------------------------------------------------------------------------
     
    470470                                        G4VPhysicalVolume*   startVolume)
    471471{
    472   const G4int verboseLevel= fVerboseLevel;
     472  const G4int verboseLevel=fVerboseLevel;
    473473  const G4ThreeVector StartPosition       = StartFT.GetPosition();
    474474  const G4ThreeVector StartUnitVelocity   = StartFT.GetMomentumDir();
     
    477477
    478478  G4double step_len = CurrentFT.GetCurveLength() - StartFT.GetCurveLength();
     479
     480  G4int oldprec;   // cout/cerr precision settings
    479481     
    480   if( ((stepNo == 0) && (verboseLevel <3))
    481       || (verboseLevel >= 3) )
    482   {
    483     static G4int noPrecision= 4;
    484     G4cout.precision(noPrecision);
    485     // G4cout.setf(ios_base::fixed,ios_base::floatfield);
     482  if( ((stepNo == 0) && (verboseLevel <3)) || (verboseLevel >= 3) )
     483  {
     484    oldprec = G4cout.precision(4);
    486485    G4cout << std::setw( 6)  << " "
    487486           << std::setw( 25) << " Current Position  and  Direction" << " "
     
    495494           << std::setw( 7) << " N_y " << " "
    496495           << std::setw( 7) << " N_z " << " " ;
    497     //            << G4endl;
    498     G4cout     // << " >>> "
    499            << std::setw( 7) << " Delta|N|" << " "
    500       //   << std::setw( 7) << " Delta(N_z) " << " "
     496    G4cout << std::setw( 7) << " Delta|N|" << " "
    501497           << std::setw( 9) << "StepLen" << " " 
    502498           << std::setw(12) << "StartSafety" << " " 
    503499           << std::setw( 9) << "PhsStep" << " "; 
    504     if( startVolume ) {
    505       G4cout << std::setw(18) << "NextVolume" << " ";
    506     }
     500    if( startVolume )
     501      { G4cout << std::setw(18) << "NextVolume" << " "; }
     502    G4cout.precision(oldprec);
    507503    G4cout << G4endl;
    508504  }
    509   if((stepNo == 0) && (verboseLevel <=3)){
    510      // Recurse to print the start values
    511      //
    512      printStatus( StartFT, StartFT, -1.0, safety, -1, startVolume);
    513    }
    514    if( verboseLevel <= 3 )
    515    {
    516      if( stepNo >= 0)
    517        G4cout << std::setw( 4) << stepNo << " ";
    518      else
    519        G4cout << std::setw( 5) << "Start" ;
    520      G4cout.precision(8);
    521      G4cout << std::setw(10) << CurrentFT.GetCurveLength() << " ";
    522      G4cout.precision(8);
    523      G4cout << std::setw(10) << CurrentPosition.x() << " "
    524             << std::setw(10) << CurrentPosition.y() << " "
    525             << std::setw(10) << CurrentPosition.z() << " ";
    526      G4cout.precision(4);
    527      G4cout << std::setw( 7) << CurrentUnitVelocity.x() << " "
    528             << std::setw( 7) << CurrentUnitVelocity.y() << " "
    529             << std::setw( 7) << CurrentUnitVelocity.z() << " ";
    530      //  G4cout << G4endl;
    531      //     G4cout << " >>> " ;
    532      G4cout.precision(3);
    533      G4cout << std::setw( 7) << CurrentFT.GetMomentum().mag()- StartFT.GetMomentum().mag() << " ";
    534      //   << std::setw( 7) << CurrentUnitVelocity.z() - InitialUnitVelocity.z() << " ";
    535      G4cout << std::setw( 9) << step_len << " ";
    536      G4cout << std::setw(12) << safety << " ";
    537      if( requestStep != -1.0 )
    538        G4cout << std::setw( 9) << requestStep << " ";
    539      else
    540        G4cout << std::setw( 9) << "Init/NotKnown" << " ";
    541 
    542      if( startVolume != 0)
    543      {
    544        G4cout << std::setw(12) << startVolume->GetName() << " ";
    545      }
    546 #if 0
    547      else
    548      {
    549        if( step_len != -1 )
    550          G4cout << std::setw(12) << "OutOfWorld" << " ";
    551        else
    552          G4cout << std::setw(12) << "NotGiven" << " ";
    553      }
    554 #endif
    555 
    556      G4cout << G4endl;
    557    }
    558    else // if( verboseLevel > 3 )
    559    {
    560      //  Multi-line output
    561        
    562      G4cout << "Step taken was " << step_len 
    563             << " out of PhysicalStep = " <<  requestStep << G4endl;
    564      G4cout << "Final safety is: " << safety << G4endl;
    565 
    566      G4cout << "Chord length = " << (CurrentPosition-StartPosition).mag()
    567             << G4endl;
    568      G4cout << G4endl;
    569    }
     505  if((stepNo == 0) && (verboseLevel <=3))
     506  {
     507    // Recurse to print the start values
     508    //
     509    printStatus( StartFT, StartFT, -1.0, safety, -1, startVolume);
     510  }
     511  if( verboseLevel <= 3 )
     512  {
     513    if( stepNo >= 0)
     514      { G4cout << std::setw( 4) << stepNo << " "; }
     515    else
     516      { G4cout << std::setw( 5) << "Start" ; }
     517    oldprec = G4cout.precision(8);
     518    G4cout << std::setw(10) << CurrentFT.GetCurveLength() << " ";
     519    G4cout.precision(8);
     520    G4cout << std::setw(10) << CurrentPosition.x() << " "
     521           << std::setw(10) << CurrentPosition.y() << " "
     522           << std::setw(10) << CurrentPosition.z() << " ";
     523    G4cout.precision(4);
     524    G4cout << std::setw( 7) << CurrentUnitVelocity.x() << " "
     525           << std::setw( 7) << CurrentUnitVelocity.y() << " "
     526           << std::setw( 7) << CurrentUnitVelocity.z() << " ";
     527    G4cout.precision(3);
     528    G4cout << std::setw( 7)
     529           << CurrentFT.GetMomentum().mag()-StartFT.GetMomentum().mag() << " ";
     530    G4cout << std::setw( 9) << step_len << " ";
     531    G4cout << std::setw(12) << safety << " ";
     532    if( requestStep != -1.0 )
     533      { G4cout << std::setw( 9) << requestStep << " "; }
     534    else
     535      { G4cout << std::setw( 9) << "Init/NotKnown" << " "; }
     536    if( startVolume != 0)
     537      { G4cout << std::setw(12) << startVolume->GetName() << " "; }
     538    G4cout.precision(oldprec);
     539    G4cout << G4endl;
     540  }
     541  else // if( verboseLevel > 3 )
     542  {
     543    //  Multi-line output
     544     
     545    G4cout << "Step taken was " << step_len 
     546           << " out of PhysicalStep = " <<  requestStep << G4endl;
     547    G4cout << "Final safety is: " << safety << G4endl;
     548    G4cout << "Chord length = " << (CurrentPosition-StartPosition).mag()
     549           << G4endl;
     550    G4cout << G4endl;
     551  }
    570552}
    571553
  • trunk/source/geometry/navigation/src/G4RegularNavigation.cc

    r1058 r1347  
    2525//
    2626//
    27 // $Id: G4RegularNavigation.cc,v 1.9 2009/01/27 09:31:29 gcosmo Exp $
     27// $Id: G4RegularNavigation.cc,v 1.15 2010/11/19 15:13:39 gcosmo Exp $
    2828// GEANT4 tag $ Name:$
    2929//
     
    4545//------------------------------------------------------------------
    4646G4RegularNavigation::G4RegularNavigation()
    47   : fVerbose(1), fCheck(true)
     47  : fverbose(false), fcheck(false), fnormalNav(0)
    4848{
    4949  kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
     
    122122//------------------------------------------------------------------
    123123G4double G4RegularNavigation::ComputeStepSkippingEqualMaterials(
    124                                 G4ThreeVector localPoint,
     124                                      G4ThreeVector& localPoint,
    125125                                const G4ThreeVector& localDirection,
    126126                                const G4double currentProposedStepLength,
     
    291291                                  const G4ThreeVector& globalPoint,
    292292                                  const G4ThreeVector* globalDirection,
    293                                   const G4bool pLocatedOnEdge,
     293                                  const G4bool, // pLocatedOnEdge,
    294294                                  G4ThreeVector& localPoint )
    295295{
    296   G4SmartVoxelHeader *motherVoxelHeader;
    297296  G4VPhysicalVolume *motherPhysical, *pPhysical;
    298297  G4PhantomParameterisation *pParam;
    299298  G4LogicalVolume *motherLogical;
    300   G4VSolid *pSolid;
    301299  G4ThreeVector localDir;
    302300  G4int replicaNo;
     
    304302  motherPhysical = history.GetTopVolume();
    305303  motherLogical = motherPhysical->GetLogicalVolume();
    306   motherVoxelHeader = motherLogical->GetVoxelHeader();
    307304 
    308305  pPhysical = motherLogical->GetDaughter(0);
    309306  pParam = (G4PhantomParameterisation*)(pPhysical->GetParameterisation());
    310307 
    311   pSolid = pParam->GetContainerSolid();
    312  
    313308  // Save parent history in touchable history
    314309  // ... for use as parent t-h in ComputeMaterial method of param
     
    327322  }
    328323
    329   // Check that track is not on the surface and check that track is not
    330   // exiting the voxel parent volume
    331   //
    332   if ( !G4AuxiliaryNavServices::CheckPointOnSurface(pSolid, localPoint,
    333           globalDirection, history.GetTopTransform(), pLocatedOnEdge)
    334      || G4AuxiliaryNavServices::CheckPointExiting(pSolid, localPoint,
    335           globalDirection, history.GetTopTransform() ) )
    336   {
    337   }
    338   else
    339   {
    340     // Enter this daughter
    341     //
    342     replicaNo = pParam->GetReplicaNo( localPoint, localDir );
    343 
    344     if( replicaNo < 0 || replicaNo >= G4int(pParam->GetNoVoxel()) )
    345     {
    346       return false;
    347     }
    348 
    349     // Set the correct copy number in physical
    350     //
    351     pPhysical->SetCopyNo(replicaNo);
    352     pParam->ComputeTransformation(replicaNo,pPhysical);
    353 
    354     history.NewLevel(pPhysical, kParameterised, replicaNo );
    355     localPoint = history.GetTopTransform().TransformPoint(globalPoint);
    356 
    357     // Set the correct solid and material in Logical Volume
    358     //
    359     G4LogicalVolume *pLogical = pPhysical->GetLogicalVolume();
     324  // Enter this daughter
     325  //
     326  replicaNo = pParam->GetReplicaNo( localPoint, localDir );
     327
     328  if( replicaNo < 0 || replicaNo >= G4int(pParam->GetNoVoxel()) )
     329  {
     330    return false;
     331  }
     332
     333  // Set the correct copy number in physical
     334  //
     335  pPhysical->SetCopyNo(replicaNo);
     336  pParam->ComputeTransformation(replicaNo,pPhysical);
     337
     338  history.NewLevel(pPhysical, kParameterised, replicaNo );
     339  localPoint = history.GetTopTransform().TransformPoint(globalPoint);
     340
     341  // Set the correct solid and material in Logical Volume
     342  //
     343  G4LogicalVolume *pLogical = pPhysical->GetLogicalVolume();
    360344     
    361     pLogical->UpdateMaterial(pParam->ComputeMaterial(replicaNo,
    362                              pPhysical, &parentTouchable) );
    363     return true;
    364   }
    365 
    366   return false;
    367 }
     345  pLogical->UpdateMaterial(pParam->ComputeMaterial(replicaNo,
     346                           pPhysical, &parentTouchable) );
     347  return true;
     348}
  • trunk/source/geometry/navigation/src/G4ReplicaNavigation.cc

    r1337 r1347  
    2525//
    2626//
    27 // $Id: G4ReplicaNavigation.cc,v 1.19 2008/04/28 15:39:55 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4ReplicaNavigation.cc,v 1.20 2010/07/13 15:59:42 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-04-ref-00 $
    2929//
    3030//
     
    10391039    G4Exception("G4ReplicaNavigation::BackLocate()", "InvalidSetup",
    10401040                FatalException, "The World volume must be a Placement!");
     1041    return kInside;
    10411042  }
    10421043
  • trunk/source/geometry/navigation/src/G4SimpleLocator.cc

    r1337 r1347  
    2424// ********************************************************************
    2525//
    26 // $Id: G4SimpleLocator.cc,v 1.5 2008/12/11 10:27:58 tnikitin Exp $
    27 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     26// $Id: G4SimpleLocator.cc,v 1.6 2010/07/13 15:59:42 gcosmo Exp $
     27// GEANT4 tag $Name: geant4-09-04-ref-00 $
    2828//
    2929// Class G4SimpleLocator implementation
     
    105105
    106106  G4int substep_no = 0;
     107
     108  G4int oldprc;  // cout/cerr precision settings
    107109
    108110  // Limits for substep number
     
    358360                  << GetEpsilonStepFor() << G4endl;
    359361         }
    360          G4cerr.precision(20);
     362         oldprc = G4cerr.precision(20);
    361363         G4cerr << " Point A (Curve start)   is " << CurveStartPointVelocity
    362364                << G4endl;
     
    373375         G4cerr << "        LocateIntersection parameters are : Substep no= "
    374376                << substep_no << G4endl;
     377         G4cerr.precision(oldprc);
    375378
    376379         G4Exception("G4SimpleLocator::EstimateIntersectionPoint()",
     
    452455                 -1.0, NewSafety, substep_no);
    453456    G4cout << G4endl;
    454     G4cout.precision( 10 );
     457    oldprc = G4cout.precision(10);
    455458    G4double done_len = CurrentA_PointVelocity.GetCurveLength();
    456459    G4double full_len = CurveEndPointVelocity.GetCurveLength();
     
    460463           << " out of " << full_len << " required." << G4endl;
    461464    G4cout << "        Remaining length = " << full_len - done_len << G4endl;
     465    G4cout.precision(oldprc);
    462466
    463467    G4Exception("G4SimpleLocator::EstimateIntersectionPoint()",
     
    467471  else if( substep_no >= warn_substeps )
    468472  { 
    469     G4int oldprc= G4cout.precision( 10 );
     473    oldprc= G4cout.precision(10);
    470474    G4cout << "WARNING - G4SimpleLocator::EstimateIntersectionPoint()"
    471475           << G4endl
     
    475479           << "          Warning level = " << warn_substeps
    476480           << " and maximum substeps = " << max_substeps << G4endl;
     481    G4cout.precision(oldprc);
    477482    G4Exception("G4SimpleLocator::EstimateIntersectionPoint()",
    478483                "DifficultyToLocateIntersection", JustWarning,
    479484                "Many substeps while trying to locate intersection.");
    480     G4cout.precision( oldprc );
    481485  }
    482486  return  !there_is_no_intersection; //  Success or failure
  • trunk/source/geometry/navigation/src/G4TransportationManager.cc

    r1337 r1347  
    2525//
    2626//
    27 // $Id: G4TransportationManager.cc,v 1.15 2007/04/12 11:51:48 vnivanch Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4TransportationManager.cc,v 1.16 2010/07/13 15:59:42 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-04-ref-00 $
    2929//
    3030//
     
    5656G4TransportationManager::G4TransportationManager()
    5757{
    58   if (!fTransportationManager)
    59   {
    60     // Create the navigator for tracking and activate it; add to collections
    61     //
    62     G4Navigator* trackingNavigator = new G4Navigator();
    63     trackingNavigator->Activate(true);
    64     fNavigators.push_back(trackingNavigator);
    65     fActiveNavigators.push_back(trackingNavigator);
    66     fWorlds.push_back(trackingNavigator->GetWorldVolume()); // NULL registered
    67 
    68     fGeomMessenger     = new G4GeometryMessenger(this);
    69     fFieldManager      = new G4FieldManager();
    70     fPropagatorInField = new G4PropagatorInField(trackingNavigator,
    71                                                  fFieldManager);
    72     fSafetyHelper      = new G4SafetyHelper();
    73   }
    74   else
     58  if (fTransportationManager)
    7559  {
    7660    G4cerr << "Only ONE instance of G4TransportationManager is allowed!"
     
    8064                "Only ONE instance of G4TransportationManager is allowed!");
    8165  }
     66
     67  // Create the navigator for tracking and activate it; add to collections
     68  //
     69  G4Navigator* trackingNavigator = new G4Navigator();
     70  trackingNavigator->Activate(true);
     71  fNavigators.push_back(trackingNavigator);
     72  fActiveNavigators.push_back(trackingNavigator);
     73  fWorlds.push_back(trackingNavigator->GetWorldVolume()); // NULL registered
     74
     75  fGeomMessenger    = new G4GeometryMessenger(this);
     76  fFieldManager     = new G4FieldManager();
     77  fPropagatorInField= new G4PropagatorInField(trackingNavigator,fFieldManager);
     78  fSafetyHelper     = new G4SafetyHelper();
    8279}
    8380
     
    329326   std::vector<G4Navigator*>::iterator pNav =
    330327     std::find(fNavigators.begin(), fNavigators.end(), aNavigator);
    331    if (pNav == fNavigators.end())
     328   if (pNav != fNavigators.end())
     329   {
     330      (*pNav)->Activate(false);
     331   }
     332   else
    332333   {
    333334      G4String message
     
    337338                  "NoEffect", JustWarning, message);
    338339   }
    339    else
    340    {
    341       (*pNav)->Activate(false);
    342    }
     340
    343341   std::vector<G4Navigator*>::iterator pActiveNav =
    344342     std::find(fActiveNavigators.begin(), fActiveNavigators.end(), aNavigator);
  • trunk/source/geometry/navigation/src/G4VIntersectionLocator.cc

    r1337 r1347  
    2424// ********************************************************************
    2525//
    26 // $Id: G4VIntersectionLocator.cc,v 1.7 2009/11/27 15:21:59 japost Exp $
    27 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     26// $Id: G4VIntersectionLocator.cc,v 1.8 2010/07/13 15:59:42 gcosmo Exp $
     27// GEANT4 tag $Name: geant4-09-04-ref-00 $
    2828//
    2929// Class G4VIntersectionLocator implementation
     
    8383
    8484  G4double step_len = CurrentFT.GetCurveLength() - StartFT.GetCurveLength();
    85      
     85  G4int oldprc;  // cout/cerr precision settings
     86
    8687  if( ((stepNo == 0) && (verboseLevel <3)) || (verboseLevel >= 3) )
    8788  {
    88     static G4int noPrecision= 4;
    89     G4cout.precision(noPrecision);
    90     // G4cout.setf(ios_base::fixed,ios_base::floatfield);
     89    oldprc = G4cout.precision(4);
    9190    G4cout << std::setw( 6)  << " "
    9291           << std::setw( 25) << " Current Position  and  Direction" << " "
     
    10099           << std::setw( 7) << " N_y " << " "
    101100           << std::setw( 7) << " N_z " << " " ;
    102     //            << G4endl;
    103     G4cout     // << " >>> "
    104            << std::setw( 7) << " Delta|N|" << " "
    105       //   << std::setw( 7) << " Delta(N_z) " << " "
     101    G4cout << std::setw( 7) << " Delta|N|" << " "
    106102           << std::setw( 9) << "StepLen" << " " 
    107103           << std::setw(12) << "StartSafety" << " " 
    108104           << std::setw( 9) << "PhsStep" << " "; 
    109  
    110105    G4cout << G4endl;
     106    G4cout.precision(oldprc);
    111107  }
    112108  if((stepNo == 0) && (verboseLevel <=3))
     
    126122       G4cout << std::setw( 5) << "Start" ;
    127123    }
    128     G4cout.precision(8);
     124    oldprc = G4cout.precision(8);
    129125    G4cout << std::setw(10) << CurrentFT.GetCurveLength() << " ";
    130     G4cout.precision(8);
    131126    G4cout << std::setw(10) << CurrentPosition.x() << " "
    132127           << std::setw(10) << CurrentPosition.y() << " "
     
    136131           << std::setw( 7) << CurrentUnitVelocity.y() << " "
    137132           << std::setw( 7) << CurrentUnitVelocity.z() << " ";
    138      //  G4cout << G4endl;
    139      //     G4cout << " >>> " ;
    140      G4cout.precision(3);
    141      G4cout << std::setw( 7)
    142             << CurrentFT.GetMomentum().mag()- StartFT.GetMomentum().mag()
    143             << " ";
    144      //   << std::setw( 7)
    145      //   << CurrentUnitVelocity.z() - InitialUnitVelocity.z() << " ";
    146      G4cout << std::setw( 9) << step_len << " ";
    147      G4cout << std::setw(12) << safety << " ";
    148      if( requestStep != -1.0 )
    149      {
    150        G4cout << std::setw( 9) << requestStep << " ";
    151      }
    152      else
    153      {
    154        G4cout << std::setw( 9) << "Init/NotKnown" << " ";
    155      }
    156      G4cout << G4endl;
    157    }
    158    else // if( verboseLevel > 3 )
    159    {
    160      //  Multi-line output
     133    G4cout.precision(3);
     134    G4cout << std::setw( 7)
     135           << CurrentFT.GetMomentum().mag()- StartFT.GetMomentum().mag()
     136           << " ";
     137    G4cout << std::setw( 9) << step_len << " ";
     138    G4cout << std::setw(12) << safety << " ";
     139    if( requestStep != -1.0 )
     140    {
     141      G4cout << std::setw( 9) << requestStep << " ";
     142    }
     143    else
     144    {
     145      G4cout << std::setw( 9) << "Init/NotKnown" << " ";
     146    }
     147    G4cout << G4endl;
     148    G4cout.precision(oldprc);
     149  }
     150  else // if( verboseLevel > 3 )
     151  {
     152    //  Multi-line output
    161153       
    162      G4cout << "Step taken was " << step_len 
    163             << " out of PhysicalStep= " <<  requestStep << G4endl;
    164      G4cout << "Final safety is: " << safety << G4endl;
    165 
    166      G4cout << "Chord length = " << (CurrentPosition-StartPosition).mag()
    167             << G4endl;
    168      G4cout << G4endl;
    169    }
     154    G4cout << "Step taken was " << step_len 
     155           << " out of PhysicalStep= " <<  requestStep << G4endl;
     156    G4cout << "Final safety is: " << safety << G4endl;
     157    G4cout << "Chord length = " << (CurrentPosition-StartPosition).mag()
     158           << G4endl;
     159    G4cout << G4endl;
     160  }
    170161}
    171162
  • trunk/source/geometry/navigation/src/G4VoxelNavigation.cc

    r1337 r1347  
    2525//
    2626//
    27 // $Id: G4VoxelNavigation.cc,v 1.9 2008/11/14 18:26:35 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     27// $Id: G4VoxelNavigation.cc,v 1.13 2010/11/04 18:18:00 japost Exp $
     28// GEANT4 tag $Name: geant4-09-04-ref-00 $
    2929//
    3030//
     
    3737#include "G4VoxelNavigation.hh"
    3838#include "G4GeometryTolerance.hh"
     39#include "G4VoxelSafety.hh"
    3940
    4041// ********************************************************************
     
    4344//
    4445G4VoxelNavigation::G4VoxelNavigation()
    45   : fVoxelDepth(-1),
     46  : fBList(), fVoxelDepth(-1),
    4647    fVoxelAxisStack(kNavigatorVoxelStackMax,kXAxis),
    4748    fVoxelNoSlicesStack(kNavigatorVoxelStackMax,0),
     
    4950    fVoxelNodeNoStack(kNavigatorVoxelStackMax,0),
    5051    fVoxelHeaderStack(kNavigatorVoxelStackMax,(G4SmartVoxelHeader*)0),
    51     fVoxelNode(0),
    52     fCheck(false),
    53     fVerbose(0)
     52    fVoxelNode(0), fpVoxelSafety(0), fCheck(false), fBestSafety(false)
    5453{
    55   kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
     54  fLogger = new G4NavigationLogger("G4VoxelNavigation");
     55  fpVoxelSafety = new G4VoxelSafety ();
    5656}
    5757
     
    6262G4VoxelNavigation::~G4VoxelNavigation()
    6363{
    64 #ifdef G4DEBUG_NAVIGATION
    65   G4cout << "G4VoxelNavigation::~G4VoxelNavigation() called." << G4endl;
    66 #endif
     64  delete fpVoxelSafety;
     65  delete fLogger;
    6766}
    6867
     
    110109  if ( fCheck )
    111110  {
    112     if(fVerbose == 1 )
    113     {
    114       G4cout << "*** G4VoxelNavigation::ComputeStep(): ***" << G4endl
    115              << "    Invoked DistanceToOut(p) for mother solid: "
    116              << motherSolid->GetName()
    117              << ". Solid replied: " << motherSafety << G4endl
    118              << "    For local point p: " << localPoint
    119              << ", to be considered as 'mother safety'." << G4endl;
    120     }
    121     if( motherSafety < 0.0 )
    122     {
    123       G4cout << "ERROR - G4VoxelNavigation::ComputeStep()" << G4endl
    124              << "        Current solid " << motherSolid->GetName()
    125              << " gave negative safety: " << motherSafety << G4endl
    126              << "        for the current (local) point " << localPoint
    127              << G4endl;
    128       motherSolid->DumpInfo();
    129       G4Exception("G4VoxelNavigation::ComputeStep()",
    130                   "NegativeSafetyMotherVol", FatalException,
    131                   "Negative Safety In Voxel Navigation !" );
    132     }
    133     if( motherSolid->Inside(localPoint)==kOutside )
    134     {
    135       G4cout << "WARNING - G4VoxelNavigation::ComputeStep()" << G4endl
    136              << "          Point " << localPoint
    137              << " is outside current volume " << motherPhysical->GetName()
    138              << G4endl;
    139       G4double  estDistToSolid= motherSolid->DistanceToIn(localPoint);
    140       G4cout << "          Estimated isotropic distance to solid (distToIn)= "
    141              << estDistToSolid << G4endl;
    142       if( estDistToSolid > 100.0 * kCarTolerance )
    143       {
    144         motherSolid->DumpInfo();
    145         G4Exception("G4VoxelNavigation::ComputeStep()",
    146                     "FarOutsideCurrentVolume", FatalException,
    147                     "Point is far outside Current Volume !");
    148       }
    149       else
    150         G4Exception("G4VoxelNavigation::ComputeStep()", "OutsideCurrentVolume",
    151                     JustWarning, "Point is a little outside Current Volume.");
    152     }
     111    fLogger->PreComputeStepLog (motherPhysical, motherSafety, localPoint);
    153112  }
    154113#endif
     
    204163                     sampleSolid->DistanceToIn(samplePoint);
    205164#ifdef G4VERBOSE
    206           if(( fCheck ) && ( fVerbose == 1 ))
     165          if( fCheck )
    207166          {
    208             G4cout << "*** G4VoxelNavigation::ComputeStep(): ***" << G4endl
    209                    << "    Invoked DistanceToIn(p) for daughter solid: "
    210                    << sampleSolid->GetName()
    211                    << ". Solid replied: " << sampleSafety << G4endl
    212                    << "    For local point p: " << samplePoint
    213                    << ", to be considered as 'daughter safety'." << G4endl;
     167            fLogger->PrintDaughterLog(sampleSolid,samplePoint,sampleSafety,0);
    214168          }
    215169#endif
     
    224178                     sampleSolid->DistanceToIn(samplePoint, sampleDirection);
    225179#ifdef G4VERBOSE
    226             if(( fCheck ) && ( fVerbose == 1 ))
     180            if( fCheck )
    227181            {
    228               G4cout << "*** G4VoxelNavigation::ComputeStep(): ***" << G4endl
    229                      << "    Invoked DistanceToIn(p,v) for daughter solid: "
    230                      << sampleSolid->GetName()
    231                      << ". Solid replied: " << sampleStep << G4endl
    232                      << "    For local point p: " << samplePoint << G4endl
    233                      << "    Direction v: " << sampleDirection
    234                      << ", to be considered as 'daughter step'." << G4endl;
     182              fLogger->PrintDaughterLog(sampleSolid, samplePoint,
     183                                        sampleSafety, sampleStep);
    235184            }
    236185#endif
     
    247196              // candidate.
    248197
    249               if ( ( fCheck ) && ( sampleStep < kInfinity ) )
     198              if ( fCheck )
    250199              {
    251                 G4ThreeVector intersectionPoint;
    252                 intersectionPoint= samplePoint + sampleStep * sampleDirection;
    253                 EInside insideIntPt= sampleSolid->Inside(intersectionPoint);
    254                 G4String solidResponse = "-kInside-";
    255                 if (insideIntPt == kOutside)
    256                   { solidResponse = "-kOutside-"; }
    257                 else if (insideIntPt == kSurface)
    258                   { solidResponse = "-kSurface-"; }
    259                 if( fVerbose == 1 )
    260                 {
    261                   G4cout << "*** G4VoxelNavigation::ComputeStep(): ***"<<G4endl
    262                          << "    Invoked Inside() for solid: "
    263                          << sampleSolid->GetName()
    264                          << ". Solid replied: " << solidResponse << G4endl
    265                          << "    For point p: " << intersectionPoint
    266                          << ", considered as 'intersection' point." << G4endl;
    267                 }
    268                 G4double safetyIn= -1, safetyOut= -1;  //  Set to invalid values
    269                 G4double newDistIn= -1,  newDistOut= -1;
    270                 if( insideIntPt != kInside )
    271                 {
    272                   safetyIn= sampleSolid->DistanceToIn(intersectionPoint);
    273                   newDistIn= sampleSolid->DistanceToIn(intersectionPoint,
    274                                                        sampleDirection);
    275                 }
    276                 if( insideIntPt != kOutside )
    277                 {
    278                   safetyOut= sampleSolid->DistanceToOut(intersectionPoint);
    279                   newDistOut= sampleSolid->DistanceToOut(intersectionPoint,
    280                                                          sampleDirection);
    281                 }
    282                 if( insideIntPt != kSurface )
    283                 {
    284                   G4int oldcoutPrec = G4cout.precision(16);
    285                   G4cout << "WARNING - G4VoxelNavigation::ComputeStep()"
    286                          << G4endl
    287                          << "          Inaccurate solid DistanceToIn"
    288                          << " for solid " << sampleSolid->GetName() << G4endl;
    289                   G4cout << "          Solid gave DistanceToIn = "
    290                          << sampleStep << " yet returns " << solidResponse
    291                          << " for this point !" << G4endl;
    292                   G4cout << "          Point = " << intersectionPoint << G4endl;
    293                   G4cout << "          Safety values: " << G4endl;
    294                   if ( insideIntPt != kInside )
    295                   {
    296                     G4cout << "          DistanceToIn(p)  = " << safetyIn
    297                            << G4endl;
    298                   }
    299                   if ( insideIntPt != kOutside )
    300                   {
    301                     G4cout << "          DistanceToOut(p) = " << safetyOut
    302                            << G4endl;
    303                   }
    304                   G4Exception("G4VoxelNavigation::ComputeStep()",
    305                               "InaccurateDistanceToIn", JustWarning,
    306                               "Conflicting response from Solid.");
    307                   G4cout.precision(oldcoutPrec);
    308                 }
    309                 else
    310                 { 
    311                   // If it is on the surface, *ensure* that either DistanceToIn
    312                   // or DistanceToOut returns a finite value ( >= Tolerance).
    313                   //
    314                   if( std::max( newDistIn, newDistOut ) <= kCarTolerance )
    315                   {
    316                     G4cout << "ERROR - G4VoxelNavigation::ComputeStep()"
    317                        << G4endl
    318                        << "  Identified point for which the solid "
    319                        << sampleSolid->GetName() << G4endl
    320                        << "  has MAJOR problem:  " << G4endl
    321                        << "  --> Both DistanceToIn(p,v) and DistanceToOut(p,v) "
    322                        << "return Zero, an equivalent value or negative value."
    323                        << G4endl;
    324                     G4cout << "    Solid: " << sampleSolid << G4endl;
    325                     G4cout << "    Point p= " << intersectionPoint << G4endl;
    326                     G4cout << "    Direction v= " << sampleDirection << G4endl;
    327                     G4cout << "    DistanceToIn(p,v)     = " << newDistIn
    328                            << G4endl;
    329                     G4cout << "    DistanceToOut(p,v,..) = " << newDistOut
    330                            << G4endl;
    331                     G4cout << "    Safety values: " << G4endl;
    332                     G4cout << "      DistanceToIn(p)  = " << safetyIn
    333                            << G4endl;
    334                     G4cout << "      DistanceToOut(p) = " << safetyOut
    335                            << G4endl;
    336                     G4Exception("G4VoxelNavigation::ComputeStep()",
    337                               "DistanceToInAndOutAreZero", FatalException,
    338                               "Zero from both Solid DistanceIn and Out(p,v).");
    339                   }
    340                 }
     200                fLogger->AlongComputeStepLog (sampleSolid, samplePoint,
     201                  sampleDirection, localDirection, sampleSafety, sampleStep);
    341202              }
    342203#endif
     
    378239          if ( fCheck )
    379240          {
    380             if(fVerbose == 1)
    381             {
    382               G4cout << "*** G4VoxelNavigation::ComputeStep(): ***" << G4endl
    383                      << "    Invoked DistanceToOut(p,v,...) for mother solid: "
    384                      << motherSolid->GetName()
    385                      << ". Solid replied: " << motherStep << G4endl
    386                      << "    For local point p: " << localPoint << G4endl
    387                      << "    Direction v: " << localDirection
    388                      << ", to be considered as 'mother step'." << G4endl;
    389             }
    390             if( ( motherStep < 0.0 ) || ( motherStep >= kInfinity) )
    391             {
    392               G4int oldPrOut= G4cout.precision(16);
    393               G4int oldPrErr= G4cerr.precision(16);
    394               G4cerr << "ERROR - G4VoxelNavigation::ComputeStep()" << G4endl
    395                      << "        Problem in Navigation"  << G4endl
    396                      << "        Point (local coordinates): "
    397                      << localPoint << G4endl
    398                      << "        Local Direction: " << localDirection << G4endl
    399                      << "        Solid: " << motherSolid->GetName() << G4endl;
    400               motherSolid->DumpInfo();
    401               G4Exception("G4VoxelNavigation::ComputeStep()",
    402                           "PointOutsideCurrentVolume", FatalException,
    403                           "Current point is outside the current solid !");
    404               G4cout.precision(oldPrOut);
    405               G4cerr.precision(oldPrErr);
    406             }
     241            fLogger->PostComputeStepLog(motherSolid, localPoint, localDirection,
     242                                        motherStep, motherSafety);
    407243          }
    408244#endif
     
    480316  }
    481317  else if (maxCurNodeNoDelta < minCurNodeNoDelta)
    482        {
    483          voxelSafety = maxCurNodeNoDelta*curNodeWidth;
    484          voxelSafety += maxCurCommonDelta;
    485         }
    486         else    // (maxCurNodeNoDelta == minCurNodeNoDelta)
    487         {
    488           voxelSafety = minCurNodeNoDelta*curNodeWidth;
    489           voxelSafety += std::min(minCurCommonDelta,maxCurCommonDelta);
    490         }
     318  {
     319    voxelSafety = maxCurNodeNoDelta*curNodeWidth;
     320    voxelSafety += maxCurCommonDelta;
     321  }
     322  else    // (maxCurNodeNoDelta == minCurNodeNoDelta)
     323  {
     324    voxelSafety = minCurNodeNoDelta*curNodeWidth;
     325    voxelSafety += std::min(minCurCommonDelta,maxCurCommonDelta);
     326  }
    491327
    492328  // Compute isotropic safety to boundaries of previous levels
     
    552388 
    553389  G4double currentDistance = currentStep;
     390  static const G4double sigma = 0.5*G4GeometryTolerance::GetInstance()
     391                                    ->GetSurfaceTolerance();
    554392
    555393  // Determine if end of Step within current voxel
     
    567405    minVal = workMinExtent+workNodeNo*workNodeWidth;
    568406
    569     if ( minVal<=workCoord+kCarTolerance*0.5 )
     407    if ( minVal<=workCoord+sigma )
    570408    {
    571409      maxVal = minVal+workNodeWidth;
    572       if ( maxVal<=workCoord-kCarTolerance*0.5 )
     410      if ( maxVal<=workCoord-sigma )
    573411      {
    574412        // Must consider next voxel
     
    607445    minVal = workMinExtent+fVoxelNode->GetMinEquivalentSliceNo()*workNodeWidth;
    608446
    609     if ( minVal<=workCoord+kCarTolerance*0.5 )
     447    if ( minVal<=workCoord+sigma )
    610448    {
    611449      maxVal = workMinExtent+(fVoxelNode->GetMaxEquivalentSliceNo()+1)
    612450                            *workNodeWidth;
    613       if ( maxVal<=workCoord-kCarTolerance*0.5 )
     451      if ( maxVal<=workCoord-sigma )
    614452      {
    615453        newNodeNo = fVoxelNode->GetMaxEquivalentSliceNo()+1;
     
    710548G4VoxelNavigation::ComputeSafety(const G4ThreeVector& localPoint,
    711549                                 const G4NavigationHistory& history,
    712                                  const G4double )
     550                                 const G4double       maxLength)
    713551{
    714552  G4VPhysicalVolume *motherPhysical, *samplePhysical;
     
    725563  motherSolid = motherLogical->GetSolid();
    726564
     565  if( fBestSafety )
     566  {
     567    return fpVoxelSafety->ComputeSafety( localPoint,*motherPhysical,maxLength );
     568  }
     569
    727570  //
    728571  // Compute mother safety
     
    733576
    734577#ifdef G4VERBOSE
    735   if(( fCheck ) && ( fVerbose == 1 ))
    736   {
    737     G4cout << "*** G4VoxelNavigation::ComputeSafety(): ***" << G4endl
    738            << "    Invoked DistanceToOut(p) for mother solid: "
    739            << motherSolid->GetName()
    740            << ". Solid replied: " << motherSafety << G4endl
    741            << "    For local point p: " << localPoint
    742            << ", to be considered as 'mother safety'." << G4endl;
     578  if( fCheck )
     579  {
     580    fLogger->ComputeSafetyLog (motherSolid, localPoint, motherSafety, true);
    743581  }
    744582#endif
     
    772610    }
    773611#ifdef G4VERBOSE
    774     if(( fCheck ) && ( fVerbose == 1 ))
    775     {
    776       G4cout << "*** G4VoxelNavigation::ComputeSafety(): ***" << G4endl
    777              << "    Invoked DistanceToIn(p) for daughter solid: "
    778              << sampleSolid->GetName()
    779              << ". Solid replied: " << sampleSafety << G4endl
    780              << "    For local point p: " << samplePoint
    781              << ", to be considered as 'daughter safety'." << G4endl;
     612    if( fCheck )
     613    {
     614      fLogger->ComputeSafetyLog (sampleSolid,samplePoint,sampleSafety,false);
    782615    }
    783616#endif
     
    790623  return ourSafety;
    791624}
     625
     626// ********************************************************************
     627// SetVerboseLevel
     628// ********************************************************************
     629//
     630void  G4VoxelNavigation::SetVerboseLevel(G4int level)
     631{
     632  if( fLogger )       fLogger->SetVerboseLevel(level);
     633  if( fpVoxelSafety)  fpVoxelSafety->SetVerboseLevel( level );
     634}
Note: See TracChangeset for help on using the changeset viewer.