Import Geant4 9.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 16:25:56 +02:00
parent 74cad5e589
commit 89a9605df1
4440 changed files with 379508 additions and 189225 deletions
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4BrentLocator.cc,v 1.8 2009/05/15 12:55:48 tnikitin Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4BrentLocator.cc,v 1.9 2010/07/13 15:59:42 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// Class G4BrentLocator implementation
//
@@ -141,6 +141,7 @@ G4bool G4BrentLocator::EstimateIntersectionPoint(
G4bool restoredFullEndpoint = false;
G4int oldprc; // cout, cerr precision
G4int substep_no = 0;
// Limits for substep number
@@ -504,7 +505,7 @@ G4bool G4BrentLocator::EstimateIntersectionPoint(
G4cerr << "Recalculation of EndPoint was called with fEpsStep= "
<< GetEpsilonStepFor() << G4endl;
}
G4cerr.precision(20);
oldprc = G4cerr.precision(20);
G4cerr << " Point A (Curve start) is " << CurveStartPointVelocity
<< G4endl;
G4cerr << " Point B (Curve end) is " << CurveEndPointVelocity
@@ -528,6 +529,7 @@ G4bool G4BrentLocator::EstimateIntersectionPoint(
G4cerr << " Restarted no= "<< restartB << " Epsilon= "
<< GetEpsilonStepFor() <<" DeltaInters= "
<< GetDeltaIntersectionFor() << G4endl;
G4cerr.precision( oldprc );
G4Exception("G4BrentLocator::EstimateIntersectionPoint()",
"FatalError", FatalException,
@@ -727,7 +729,7 @@ G4bool G4BrentLocator::EstimateIntersectionPoint(
printStatus( CurrentA_PointVelocity, CurrentB_PointVelocity,
-1.0, NewSafety, substep_no);
G4cout << G4endl;
G4cout.precision( 10 );
oldprc = G4cout.precision( 10 );
G4double done_len = CurrentA_PointVelocity.GetCurveLength();
G4double full_len = CurveEndPointVelocity.GetCurveLength();
G4cout << "ERROR - G4BrentLocator::EstimateIntersectionPoint()"
@@ -735,6 +737,7 @@ G4bool G4BrentLocator::EstimateIntersectionPoint(
<< " Undertaken only length: " << done_len
<< " out of " << full_len << " required." << G4endl;
G4cout << " Remaining length = " << full_len - done_len << G4endl;
G4cout.precision( oldprc );
G4Exception("G4BrentLocator::EstimateIntersectionPoint()",
"UnableToLocateIntersection", FatalException,
@@ -742,7 +745,7 @@ G4bool G4BrentLocator::EstimateIntersectionPoint(
}
else if( substep_no >= warn_substeps )
{
G4int oldprc= G4cout.precision( 10 );
oldprc= G4cout.precision( 10 );
G4cout << "WARNING - G4BrentLocator::EstimateIntersectionPoint()"
<< G4endl
<< " Undertaken length: "
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4GeomTestSegment.cc,v 1.11 2007/11/16 09:39:14 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4GeomTestSegment.cc,v 1.13 2010/08/20 09:03:54 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// --------------------------------------------------------------------
// GEANT 4 class source file
@@ -274,38 +274,32 @@ void G4GeomTestSegment::FindSomePoints( G4GeomTestLogger *logger,
G4double s(0);
G4bool entering;
G4double vSurfN;
// G4cout<<"Entering Find Some Points vSearch="<<vSearch<<" p="<<p<<G4endl;
//
// Look for nearest intersection point in the specified
// direction and return if there isn't one
//
G4double dist;
switch(solid->Inside(p)) {
case kInside:
dist = solid->DistanceToOut(p,vSearch);
// G4cout<<"Inside DistToOut="<<dist<<G4endl;
dist = solid->DistanceToOut(p,vSearch);
if (dist >= kInfinity) {
logger->SolidProblem( solid,
"DistanceToOut(p,v) = kInfinity for point inside", p );
return;
}
s += sign*dist;
entering = false;
break;
case kOutside:
dist = solid->DistanceToIn(p,vSearch);
//G4cout<<"Outside DistToIn="<<dist<<G4endl;
if (dist >= kInfinity) return;
s += sign*dist;
entering = true;
break;
case kSurface:
vSurfN=vSearch.dot(solid->SurfaceNormal(p));
if(std::abs(vSurfN)<kCarTolerance)vSurfN=0;
vSurfN=v.dot(solid->SurfaceNormal(p));
if(std::fabs(vSurfN)<kCarTolerance)vSurfN=0;
entering = (vSurfN < 0);
//G4cout<<"Surface SurfN="<<solid->SurfaceNormal(p)<<" v.dotN="<<vSurfN<<" entering="<<entering<<G4endl;
break;
default:
logger->SolidProblem( solid,
@@ -360,7 +354,7 @@ void G4GeomTestSegment::FindSomePoints( G4GeomTestLogger *logger,
// Record point
//
points.push_back( G4GeomTestPoint( p, s, entering==forward ) );
//G4cout<<"Add point p"<<p<<" s="<<s<<" entering="<<entering<<G4endl;
}
//
@@ -368,7 +362,6 @@ void G4GeomTestSegment::FindSomePoints( G4GeomTestLogger *logger,
//
if (entering) {
dist = solid->DistanceToOut(p,vSearch);
//G4cout<<"if entering distToOut="<<dist<<G4endl;
if (dist >= kInfinity) {
logger->SolidProblem( solid,
"DistanceToOut(p,v) = kInfinity for point inside", p );
@@ -388,24 +381,11 @@ void G4GeomTestSegment::FindSomePoints( G4GeomTestLogger *logger,
"DistanceToOut(p,v) brings trajectory well outside solid",p);
return;
}
if(std::abs(dist)<=kCarTolerance){
G4double push = 1E-6;
s += sign*push;
p = p0 + s*v;
EInside inside = solid->Inside(p);
if (inside == kOutside) {
entering = false;
break;
}
}
entering = false;
}
else {
dist = solid->DistanceToIn(p,vSearch);
//G4cout<<"if exiting distToIn="<<dist<<G4endl;
if (dist >= kInfinity) return;
if ( (dist > kCarTolerance)
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4GeometryMessenger.cc,v 1.5 2006/06/29 18:36:57 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4GeometryMessenger.cc,v 1.6 2010/11/10 14:06:40 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// --------------------------------------------------------------------
// GEANT 4 class source file
@@ -105,6 +105,18 @@ G4GeometryMessenger::G4GeometryMessenger(G4TransportationManager* tman)
chkCmd->SetDefaultValue(false);
chkCmd->AvailableForStates(G4State_Idle);
pchkCmd = new G4UIcmdWithABool( "/geometry/navigator/push_notify", this );
pchkCmd->SetGuidance( "Set navigator verbosity push notifications." );
pchkCmd->SetGuidance( "This allows to disable/re-enable verbosity in" );
pchkCmd->SetGuidance( "navigation, when tracks may get stuck and require" );
pchkCmd->SetGuidance( "one artificial push along the direction by the" );
pchkCmd->SetGuidance( "navigator. Notification is active by default." );
pchkCmd->SetGuidance( "NOTE: this command has effect -only- if Geant4 has" );
pchkCmd->SetGuidance( " been installed with the G4VERBOSE flag set!" );
pchkCmd->SetParameterName("pushFlag",true);
pchkCmd->SetDefaultValue(true);
pchkCmd->AvailableForStates(G4State_Idle);
//
// Geometry verification test commands
//
@@ -243,7 +255,7 @@ G4GeometryMessenger::~G4GeometryMessenger()
delete rcsCmd; delete rcdCmd;
delete cyzCmd; delete cfzCmd; delete cfrCmd; delete cylCmd;
delete tolCmd;
delete resCmd; delete verbCmd; delete chkCmd;
delete resCmd; delete verbCmd; delete pchkCmd; delete chkCmd;
delete geodir; delete navdir; delete testdir;
delete tvolume; delete tlogger;
}
@@ -424,6 +436,17 @@ G4GeometryMessenger::SetCheckMode(G4String input)
navigator->CheckMode(mode);
}
//
// Set navigator verbosity for push notifications
//
void
G4GeometryMessenger::SetPushFlag(G4String input)
{
G4bool mode = pchkCmd->GetNewBoolValue(input);
G4Navigator* navigator = tmanager->GetNavigatorForTracking();
navigator->SetPushVerbosity(mode);
}
//
// LineTest
//
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4MultiLevelLocator.cc,v 1.5 2008/12/11 10:01:02 tnikitin Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4MultiLevelLocator.cc,v 1.6 2010/07/13 15:59:42 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// Class G4MultiLevelLocator implementation
//
@@ -119,7 +119,9 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
G4bool restoredFullEndpoint = false;
G4int substep_no = 0;
G4int oldprc; // cout/cerr precision settings
// Limits for substep number
//
const G4int max_substeps= 10000; // Test 120 (old value 100 )
@@ -155,9 +157,9 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
G4int depth=0; // Depth counts how many subdivisions of initial step made
#ifdef G4DEBUG_FIELD
static G4double tolerance= 1.0e-8;
static const G4double tolerance = 1.0e-8 * mm;
G4ThreeVector StartPosition= CurveStartPointVelocity.GetPosition();
if( (TrialPoint - StartPosition).mag() < tolerance * mm )
if( (TrialPoint - StartPosition).mag() < tolerance)
{
G4cerr << "WARNING - G4MultiLevelLocator::EstimateIntersectionPoint()"
<< G4endl
@@ -454,7 +456,7 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
G4cerr << "Recalculation of EndPoint was called with fEpsStep= "
<< GetEpsilonStepFor() << G4endl;
}
G4cerr.precision(20);
oldprc = G4cerr.precision(20);
G4cerr << " Point A (Curve start) is " << CurveStartPointVelocity
<< G4endl;
G4cerr << " Point B (Curve end) is " << CurveEndPointVelocity
@@ -473,6 +475,7 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
<< substep_no << G4endl;
G4cerr << " Substep depth no= "<< substep_no_p << " Depth= "
<< depth << G4endl;
G4cerr.precision(oldprc);
G4Exception("G4MultiLevelLocator::EstimateIntersectionPoint()",
"FatalError", FatalException,
@@ -690,7 +693,7 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
}
#endif
G4cout.precision( 10 );
oldprc = G4cout.precision( 10 );
G4double done_len = CurrentA_PointVelocity.GetCurveLength();
G4double full_len = CurveEndPointVelocity.GetCurveLength();
G4cout << "ERROR - G4MultiLevelLocator::EstimateIntersectionPoint()"
@@ -698,6 +701,7 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
<< " Undertaken only length: " << done_len
<< " out of " << full_len << " required." << G4endl;
G4cout << " Remaining length = " << full_len - done_len << G4endl;
G4cout.precision( oldprc );
G4Exception("G4MultiLevelLocator::EstimateIntersectionPoint()",
"UnableToLocateIntersection", FatalException,
@@ -705,7 +709,7 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
}
else if( substep_no >= warn_substeps )
{
G4int oldprc= G4cout.precision( 10 );
oldprc = G4cout.precision( 10 );
G4cout << "WARNING - G4MultiLevelLocator::EstimateIntersectionPoint()"
<< G4endl
<< " Undertaken length: "
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4MultiNavigator.cc,v 1.8 2008/10/24 14:00:03 gcosmo Exp $
// $Id: G4MultiNavigator.cc,v 1.11 2010/09/06 09:49:15 gcosmo Exp $
// GEANT4 tag $ Name: $
//
// class G4PathFinder Implementation
@@ -47,25 +47,25 @@ class G4FieldManager;
// ********************************************************************
//
G4MultiNavigator::G4MultiNavigator()
: G4Navigator()
: G4Navigator(), fLastMassWorld(0)
{
fNoActiveNavigators= 0;
G4ThreeVector Big3Vector( DBL_MAX, DBL_MAX, DBL_MAX );
G4ThreeVector Big3Vector( kInfinity, kInfinity, kInfinity );
fLastLocatedPosition = Big3Vector;
fSafetyLocation = Big3Vector;
fPreStepLocation = Big3Vector;
fMinSafety_PreStepPt= -1.0;
fMinSafety_atSafLocation= -1.0;
fMinSafety= -DBL_MAX;
fMinStep= -DBL_MAX;
fMinSafety= -kInfinity;
fTrueMinStep= fMinStep= -kInfinity;
for(register int num=0; num<= fMaxNav; ++num )
for(register int num=0; num< fMaxNav; ++num )
{
fpNavigator[num] = 0;
fLimitTruth[num] = false;
fLimitedStep[num] = kUndefLimited;
fCurrentStepSize[num] = -1.0;
fCurrentStepSize[num] = fNewSafety[num] = -1.0;
fLocatedVolume[num] = 0;
}
@@ -93,7 +93,7 @@ G4double G4MultiNavigator::ComputeStep(const G4ThreeVector &pGlobalPoint,
G4double &pNewSafety)
{
G4double safety= 0.0, step=0.0;
G4double minSafety= DBL_MAX, minStep= DBL_MAX;
G4double minSafety= kInfinity, minStep= kInfinity;
#ifdef G4DEBUG_NAVIGATION
if( fVerbose > 2 )
@@ -114,7 +114,7 @@ G4double G4MultiNavigator::ComputeStep(const G4ThreeVector &pGlobalPoint,
for( register int num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
{
safety= DBL_MAX;
safety= kInfinity;
step= (*pNavigatorIter)->ComputeStep( initialPosition,
initialDirection,
@@ -188,13 +188,7 @@ G4MultiNavigator::ObtainFinalStep( G4int navigatorId,
G4double &minStep,
ELimited &limitedStep)
{
G4int navigatorNo=-1;
if( navigatorId <= fNoActiveNavigators )
{
navigatorNo= navigatorId;
}
else
if( navigatorId > fNoActiveNavigators )
{
G4cerr << "ERROR - G4MultiNavigator::ObtainFinalStep()"
<< " Navigator Id = " << navigatorId
@@ -205,20 +199,23 @@ G4MultiNavigator::ObtainFinalStep( G4int navigatorId,
}
// Prepare the information to return
pNewSafety = fNewSafety[ navigatorNo ];
limitedStep = fLimitedStep[ navigatorNo ];
//
pNewSafety = fNewSafety[ navigatorId ];
limitedStep = fLimitedStep[ navigatorId ];
minStep= fMinStep;
// if( (minStep==kInfinity) || (fVerbose > 1) ){
#ifdef G4DEBUG_NAVIGATION
if( fVerbose > 1 ){
G4cout << " G4MultiNavigator::ComputeStep returns " << fCurrentStepSize[ navigatorNo ]
<< " for Navigator " << navigatorNo << " Limited step = " << limitedStep
if( fVerbose > 1 )
{
G4cout << " G4MultiNavigator::ComputeStep returns "
<< fCurrentStepSize[ navigatorId ]
<< " for Navigator " << navigatorId
<< " Limited step = " << limitedStep
<< " Safety(mm) = " << pNewSafety / mm << G4endl;
}
#endif
return fCurrentStepSize[ navigatorNo ];
return fCurrentStepSize[ navigatorId ];
}
// ----------------------------------------------------------------------
@@ -427,7 +424,7 @@ G4double G4MultiNavigator::ComputeSafety( const G4ThreeVector& position,
{
// Recompute safety for the relevant point
G4double minSafety = DBL_MAX, safety = DBL_MAX;
G4double minSafety = kInfinity, safety = kInfinity;
std::vector<G4Navigator*>::iterator pNavigatorIter;
pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
@@ -0,0 +1,332 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4NavigationLogger.cc,v 1.1 2010/11/04 08:57:56 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// class G4NavigationLogger Implementation
//
// Author: G.Cosmo, 2010
//
// --------------------------------------------------------------------
#include <iomanip>
#include "G4NavigationLogger.hh"
#include "G4GeometryTolerance.hh"
G4NavigationLogger::G4NavigationLogger(const G4String& id)
: fId(id), fVerbose(0)
{
}
G4NavigationLogger::~G4NavigationLogger()
{
}
void
G4NavigationLogger::PreComputeStepLog(const G4VPhysicalVolume* motherPhysical,
G4double motherSafety,
const G4ThreeVector& localPoint) const
{
G4VSolid* motherSolid = motherPhysical->GetLogicalVolume()->GetSolid();
G4String fType = fId + "::ComputeStep()";
if( fVerbose == 1 )
{
G4cout << "*************** " << fType << " *****************" << G4endl
<< " VolType "
<< std::setw(15) << "Safety/mm" << " "
<< std::setw(15) << "Distance/mm" << " "
<< std::setw(52) << "Position (local coordinates)"
<< " - Solid" << G4endl;
G4cout << " Mother "
<< std::setw(15) << motherSafety << " "
<< std::setw(15) << "N/C" << " " << localPoint << " - "
<< motherSolid->GetEntityType() << ": " << motherSolid->GetName()
<< G4endl;
}
if ( motherSafety < 0.0 )
{
G4cerr << "ERROR - " << fType << G4endl
<< " Current solid " << motherSolid->GetName()
<< " gave negative safety: " << motherSafety << G4endl
<< " for the current (local) point " << localPoint
<< G4endl;
motherSolid->DumpInfo();
G4Exception(fType, "NegativeSafetyMotherVol", FatalException,
"Negative Safety In Voxel Navigation !" );
}
if( motherSolid->Inside(localPoint)==kOutside )
{
G4cout << "WARNING - " << fType << G4endl
<< " Point " << localPoint
<< " is outside current volume " << motherPhysical->GetName()
<< G4endl;
G4double estDistToSolid= motherSolid->DistanceToIn(localPoint);
G4cout << " Estimated isotropic distance to solid (distToIn)= "
<< estDistToSolid << G4endl;
if( estDistToSolid > 100.0 * motherSolid->GetTolerance() )
{
motherSolid->DumpInfo();
G4Exception(fType, "FarOutsideCurrentVolume", FatalException,
"Point is far outside Current Volume !" );
}
else
G4Exception(fType, "OutsideCurrentVolume", JustWarning,
"Point is a little outside Current Volume.");
}
// Verification / verbosity
//
if ( fVerbose > 1 )
{
static G4int precVerf= 20; // Precision
G4int oldprec = G4cout.precision(precVerf);
G4cout << " - Information on mother / key daughters ..." << G4endl;
G4cout << " Type " << std::setw(12) << "Solid-Name" << " "
<< std::setw(3*(6+precVerf)) << " local point" << " "
<< std::setw(4+precVerf) << "solid-Safety" << " "
<< std::setw(4+precVerf) << "solid-Step" << " "
<< std::setw(17) << "distance Method "
<< std::setw(3*(6+precVerf)) << " local direction" << " "
<< G4endl;
G4cout << " Mother " << std::setw(12) << motherSolid->GetName() << " "
<< std::setw(4+precVerf) << localPoint << " "
<< std::setw(4+precVerf) << motherSafety << " "
<< G4endl;
G4cout.precision(oldprec);
}
}
void
G4NavigationLogger::AlongComputeStepLog(const G4VSolid* sampleSolid,
const G4ThreeVector& samplePoint,
const G4ThreeVector& sampleDirection,
const G4ThreeVector& localDirection,
G4double sampleSafety,
G4double sampleStep) const
{
// Check to see that the resulting point is indeed in/on volume.
// This check could eventually be made only for successful candidate.
if ( sampleStep < kInfinity )
{
G4ThreeVector intersectionPoint;
intersectionPoint= samplePoint + sampleStep * sampleDirection;
EInside insideIntPt= sampleSolid->Inside(intersectionPoint);
G4String fType = fId + "::ComputeStep()";
G4String solidResponse = "-kInside-";
if (insideIntPt == kOutside)
{ solidResponse = "-kOutside-"; }
else if (insideIntPt == kSurface)
{ solidResponse = "-kSurface-"; }
if ( fVerbose == 1 )
{
G4cout << " Invoked Inside() for solid: "
<< sampleSolid->GetName()
<< ". Solid replied: " << solidResponse << G4endl
<< " For point p: " << intersectionPoint
<< ", considered as 'intersection' point." << G4endl;
}
G4double safetyIn= -1, safetyOut= -1; // Set to invalid values
G4double newDistIn= -1, newDistOut= -1;
if( insideIntPt != kInside )
{
safetyIn= sampleSolid->DistanceToIn(intersectionPoint);
newDistIn= sampleSolid->DistanceToIn(intersectionPoint,
sampleDirection);
}
if( insideIntPt != kOutside )
{
safetyOut= sampleSolid->DistanceToOut(intersectionPoint);
newDistOut= sampleSolid->DistanceToOut(intersectionPoint,
sampleDirection);
}
if( insideIntPt != kSurface )
{
G4int oldcoutPrec = G4cout.precision(16);
G4cout << "WARNING - " << fType << G4endl
<< " Inaccurate solid DistanceToIn"
<< " for solid " << sampleSolid->GetName() << G4endl;
G4cout << " Solid gave DistanceToIn = "
<< sampleStep << " yet returns " << solidResponse
<< " for this point !" << G4endl;
G4cout << " Point = " << intersectionPoint << G4endl;
G4cout << " Safety values: " << G4endl;
if ( insideIntPt != kInside )
{
G4cout << " DistanceToIn(p) = " << safetyIn << G4endl;
}
if ( insideIntPt != kOutside )
{
G4cout << " DistanceToOut(p) = " << safetyOut << G4endl;
}
G4Exception(fType, "InaccurateDistanceToIn", JustWarning,
"Conflicting response from Solid.");
G4cout.precision(oldcoutPrec);
}
else
{
// If it is on the surface, *ensure* that either DistanceToIn
// or DistanceToOut returns a finite value ( >= Tolerance).
//
if( std::max( newDistIn, newDistOut ) <=
G4GeometryTolerance::GetInstance()->GetSurfaceTolerance() )
{
G4cout << "ERROR - " << fType << G4endl
<< " Identified point for which the solid "
<< sampleSolid->GetName() << G4endl
<< " has MAJOR problem: " << G4endl
<< " --> Both DistanceToIn(p,v) and DistanceToOut(p,v) "
<< "return Zero, an equivalent value or negative value."
<< G4endl;
G4cout << " Solid: " << sampleSolid << G4endl;
G4cout << " Point p= " << intersectionPoint << G4endl;
G4cout << " Direction v= " << sampleDirection << G4endl;
G4cout << " DistanceToIn(p,v) = " << newDistIn << G4endl;
G4cout << " DistanceToOut(p,v,..) = " << newDistOut << G4endl;
G4cout << " Safety values: " << G4endl;
G4cout << " DistanceToIn(p) = " << safetyIn << G4endl;
G4cout << " DistanceToOut(p) = " << safetyOut << G4endl;
G4Exception(fType, "DistanceToInAndOutAreZero", FatalException,
"Zero from both Solid DistanceIn and Out(p,v).");
}
}
// Verification / verbosity
//
if ( fVerbose > 1 )
{
static G4int precVerf= 20; // Precision
G4int oldprec = G4cout.precision(precVerf);
G4cout << "Daughter "
<< std::setw(12) << sampleSolid->GetName() << " "
<< std::setw(4+precVerf) << samplePoint << " "
<< std::setw(4+precVerf) << sampleSafety << " "
<< std::setw(4+precVerf) << sampleStep << " "
<< std::setw(16) << "distanceToIn" << " "
<< std::setw(4+precVerf) << localDirection << " "
<< G4endl;
G4cout.precision(oldprec);
}
}
}
void
G4NavigationLogger::PostComputeStepLog(const G4VSolid* motherSolid,
const G4ThreeVector& localPoint,
const G4ThreeVector& localDirection,
G4double motherStep,
G4double motherSafety) const
{
if( fVerbose == 1 )
{
G4cout << " Mother "
<< std::setw(15) << motherSafety << " "
<< std::setw(15) << motherStep << " " << localPoint << " - "
<< motherSolid->GetEntityType() << ": " << motherSolid->GetName()
<< G4endl;
}
if( ( motherStep < 0.0 ) || ( motherStep >= kInfinity) )
{
G4String fType = fId + "::ComputeStep()";
G4int oldPrOut= G4cout.precision(16);
G4int oldPrErr= G4cerr.precision(16);
G4cerr << "ERROR - " << fType << G4endl
<< " Problem in Navigation" << G4endl
<< " Point (local coordinates): "
<< localPoint << G4endl
<< " Local Direction: " << localDirection << G4endl
<< " Solid: " << motherSolid->GetName() << G4endl;
motherSolid->DumpInfo();
G4Exception(fType, "PointDistOutInvalid", FatalException,
"Current point is outside the current solid !");
G4cout.precision(oldPrOut);
G4cerr.precision(oldPrErr);
}
if ( fVerbose > 1 )
{
static G4int precVerf= 20; // Precision
G4int oldprec = G4cout.precision(precVerf);
G4cout << " Mother " << std::setw(12) << motherSolid->GetName() << " "
<< std::setw(4+precVerf) << localPoint << " "
<< std::setw(4+precVerf) << motherSafety << " "
<< std::setw(4+precVerf) << motherStep << " "
<< std::setw(16) << "distanceToOut" << " "
<< std::setw(4+precVerf) << localDirection << " "
<< G4endl;
G4cout.precision(oldprec);
}
}
void
G4NavigationLogger::ComputeSafetyLog(const G4VSolid* solid,
const G4ThreeVector& point,
G4double safety,
G4bool banner) const
{
G4String volumeType = "Daughter ";
if (banner)
{
G4cout << "************** " << fId << "::ComputeSafety() ****************" << G4endl;
G4cout << " VolType "
<< std::setw(15) << "Safety/mm" << " "
<< std::setw(52) << "Position (local coordinates)"
<< " - Solid" << G4endl;
volumeType = " Mother ";
}
G4cout << volumeType
<< std::setw(15) << safety << " " << point << " - "
<< solid->GetEntityType() << ": " << solid->GetName() << G4endl;
}
void
G4NavigationLogger::PrintDaughterLog (const G4VSolid* sampleSolid,
const G4ThreeVector& samplePoint,
G4double sampleSafety,
G4double sampleStep) const
{
if ( fVerbose == 1 )
{
G4cout << "Daughter "
<< std::setw(15) << sampleSafety << " ";
if (sampleStep)
{
G4cout << std::setw(15) << sampleStep << " ";
}
else
{
G4cout << std::setw(15) << "N/C" << " ";
}
G4cout << samplePoint << " - "
<< sampleSolid->GetEntityType() << ": " << sampleSolid->GetName()
<< G4endl;
}
}
+116 -110
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Navigator.cc,v 1.39 2009/05/08 06:47:32 tnikitin Exp $
// $Id: G4Navigator.cc,v 1.46 2010/11/15 14:03:27 gcosmo Exp $
// GEANT4 tag $ Name: $
//
// class G4Navigator Implementation
@@ -46,7 +46,7 @@
//
G4Navigator::G4Navigator()
: fWasLimitedByGeometry(false), fVerbose(0),
fTopPhysical(0), fCheck(false), fPushed(false)
fTopPhysical(0), fCheck(false), fPushed(false), fWarnPush(true)
{
fActive= false;
ResetStackAndState();
@@ -127,9 +127,9 @@ G4Navigator::LocateGlobalPointAndSetup( const G4ThreeVector& globalPoint,
#endif
#ifdef G4VERBOSE
G4int oldcoutPrec = G4cout.precision(8);
if( fVerbose > 2 )
{
G4int oldcoutPrec = G4cout.precision(8);
G4cout << "*** G4Navigator::LocateGlobalPointAndSetup: ***" << G4endl;
G4cout << " Called with arguments: " << G4endl
<< " Globalpoint = " << globalPoint << G4endl
@@ -139,6 +139,7 @@ G4Navigator::LocateGlobalPointAndSetup( const G4ThreeVector& globalPoint,
G4cout << " ----- Upon entering:" << G4endl;
PrintState();
}
G4cout.precision(oldcoutPrec);
}
#endif
@@ -194,7 +195,7 @@ G4Navigator::LocateGlobalPointAndSetup( const G4ThreeVector& globalPoint,
fBlockedPhysicalVolume->SetCopyNo(fBlockedReplicaNo);
break;
case kParameterised:
if( fBlockedPhysicalVolume->GetRegularStructureId() != 1 )
if( fBlockedPhysicalVolume->GetRegularStructureId() == 0 )
{
G4VSolid *pSolid;
G4VPVParameterisation *pParam;
@@ -359,6 +360,7 @@ G4Navigator::LocateGlobalPointAndSetup( const G4ThreeVector& globalPoint,
// Determine `type' of current mother volume
//
targetPhysical = fHistory.GetTopVolume();
if (!targetPhysical) { break; }
targetLogical = targetPhysical->GetLogicalVolume();
switch( CharacteriseDaughters(targetLogical) )
{
@@ -451,12 +453,9 @@ G4Navigator::LocateGlobalPointAndSetup( const G4ThreeVector& globalPoint,
#ifdef G4VERBOSE
if( fVerbose == 4 )
{
G4cout.precision(6);
G4int oldcoutPrec = G4cout.precision(8);
G4String curPhysVol_Name("None");
if (targetPhysical!=0)
{
curPhysVol_Name = targetPhysical->GetName();
}
if (targetPhysical) { curPhysVol_Name = targetPhysical->GetName(); }
G4cout << " Return value = new volume = " << curPhysVol_Name << G4endl;
G4cout << " ----- Upon exiting:" << G4endl;
PrintState();
@@ -464,8 +463,8 @@ G4Navigator::LocateGlobalPointAndSetup( const G4ThreeVector& globalPoint,
G4cout << "Upon exiting LocateGlobalPointAndSetup():" << G4endl;
G4cout << " History = " << G4endl << fHistory << G4endl << G4endl;
#endif
G4cout.precision(oldcoutPrec);
}
G4cout.precision(oldcoutPrec);
#endif
fLocatedOutsideWorld= false;
@@ -626,7 +625,7 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector &pGlobalpoint,
G4double &pNewSafety)
{
G4ThreeVector localDirection = ComputeLocalAxis(pDirection);
G4double Step = DBL_MAX;
G4double Step = kInfinity;
G4VPhysicalVolume *motherPhysical = fHistory.GetTopVolume();
G4LogicalVolume *motherLogical = motherPhysical->GetLogicalVolume();
@@ -634,8 +633,6 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector &pGlobalpoint,
sNavCScalls++;
#ifdef G4VERBOSE
G4int oldcoutPrec= G4cout.precision(8);
G4int oldcerrPrec= G4cerr.precision(10);
if( fVerbose > 0 )
{
G4cout << "*** G4Navigator::ComputeStep: ***" << G4endl;
@@ -653,9 +650,6 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector &pGlobalpoint,
}
#endif
}
static G4double fAccuracyForWarning = kCarTolerance,
fAccuracyForException = 1000*kCarTolerance;
#endif
G4ThreeVector newLocalPoint = ComputeLocalPoint(pGlobalpoint);
@@ -669,93 +663,8 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector &pGlobalpoint,
if ( moveLenSq >= kCarTolerance*kCarTolerance )
{
#ifdef G4VERBOSE
// The following checks only make sense if the move is larger
// than the tolerance.
//
G4ThreeVector OriginalGlobalpoint =
fHistory.GetTopTransform().Inverse().
TransformPoint(fLastLocatedPointLocal);
G4double shiftOriginSafSq = (fPreviousSftOrigin-pGlobalpoint).mag2();
// Check that the starting point of this step is
// within the isotropic safety sphere of the last point
// to a accuracy/precision given by fAccuracyForWarning.
// If so give warning.
// If it fails by more than fAccuracyForException exit with error.
//
if( shiftOriginSafSq >= sqr(fPreviousSafety) )
{
G4double shiftOrigin = std::sqrt(shiftOriginSafSq);
G4double diffShiftSaf = shiftOrigin - fPreviousSafety;
if( diffShiftSaf > fAccuracyForWarning )
{
G4Exception("G4Navigator::ComputeStep()",
"UnexpectedPositionShift", JustWarning,
"Accuracy ERROR or slightly inaccurate position shift.");
G4cerr << " The Step's starting point has moved "
<< std::sqrt(moveLenSq)/mm << " mm " << G4endl
<< " since the last call to a Locate method." << G4endl;
G4cerr << " This has resulted in moving "
<< shiftOrigin/mm << " mm "
<< " from the last point at which the safety "
<< " was calculated " << G4endl;
G4cerr << " which is more than the computed safety= "
<< fPreviousSafety/mm << " mm at that point." << G4endl;
G4cerr << " This difference is "
<< diffShiftSaf/mm << " mm." << G4endl
<< " The tolerated accuracy is "
<< fAccuracyForException/mm << " mm." << G4endl;
static G4int warnNow = 0;
if( ((++warnNow % 100) == 1) )
{
G4cerr << " This problem can be due to either " << G4endl;
G4cerr << " - a process that has proposed a displacement"
<< " larger than the current safety , or" << G4endl;
G4cerr << " - inaccuracy in the computation of the safety"
<< G4endl;
G4cerr << " We suggest that you " << G4endl
<< " - find i) what particle is being tracked, and "
<< " ii) through what part of your geometry " << G4endl
<< " for example by re-running this event with "
<< G4endl
<< " /tracking/verbose 1 " << G4endl
<< " - check which processes you declare for"
<< " this particle (and look at non-standard ones)"
<< G4endl
<< " - in case, create a detailed logfile"
<< " of this event using:" << G4endl
<< " /tracking/verbose 6 "
<< G4endl;
}
}
#ifdef G4DEBUG_NAVIGATION
else
{
G4cerr << "WARNING - G4Navigator::ComputeStep()" << G4endl
<< " The Step's starting point has moved "
<< std::sqrt(moveLenSq) << "," << G4endl
<< " which has taken it to the limit of"
<< " the current safety. " << G4endl;
}
ComputeStepLog(pGlobalpoint, moveLenSq);
#endif
}
G4double safetyPlus = fPreviousSafety + fAccuracyForException;
if ( shiftOriginSafSq > sqr(safetyPlus) )
{
G4cerr << "ERROR - G4Navigator::ComputeStep()" << G4endl
<< " Position has shifted considerably without"
<< " notifying the navigator !" << G4endl
<< " Tolerated safety: " << safetyPlus << G4endl
<< " Computed shift : " << shiftOriginSafSq << G4endl;
G4Exception("G4Navigator::ComputeStep()",
"SignificantPositionShift", JustWarning,
"May lead to a crash or unreliable results.");
}
#endif // end G4VERBOSE
// Relocate the point within the same volume
//
LocateGlobalPointWithinVolume( pGlobalpoint );
@@ -783,7 +692,7 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector &pGlobalpoint,
}
else
{
if( motherPhysical->GetRegularStructureId() != 1 )
if( motherPhysical->GetRegularStructureId() == 0 )
{
Step = fnormalNav.ComputeStep(fLastLocatedPointLocal,
localDirection,
@@ -810,7 +719,7 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector &pGlobalpoint,
// of the container volume). Then LocateGlobalPointAndSetup() has
// reset the history topvolume to world.
//
if(fHistory.GetTopVolume()->GetRegularStructureId() != 1 )
if(fHistory.GetTopVolume()->GetRegularStructureId() == 0 )
{
G4Exception("G4Navigator::ComputeStep()",
"Bad-location-of-point", JustWarning,
@@ -943,9 +852,9 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector &pGlobalpoint,
{
// Act to recover this stuck track. Pushing it along direction
//
Step += 0.9*kCarTolerance;
Step += 100*kCarTolerance;
#ifdef G4VERBOSE
if (!fPushed)
if ((!fPushed) && (fWarnPush))
{
G4cerr << "WARNING - G4Navigator::ComputeStep()" << G4endl
<< " Track stuck, not moving for "
@@ -1047,8 +956,6 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector &pGlobalpoint,
}
G4cout << " Safety = " << pNewSafety << G4endl;
}
G4cout.precision(oldcoutPrec);
G4cerr.precision(oldcerrPrec);
#endif
return Step;
@@ -1111,7 +1018,7 @@ void G4Navigator::ResetState()
fBlockedPhysicalVolume = 0;
fBlockedReplicaNo = -1;
fLastLocatedPointLocal = G4ThreeVector( DBL_MAX, -DBL_MAX, 0.0 );
fLastLocatedPointLocal = G4ThreeVector( kInfinity, -kInfinity, 0.0 );
fLocatedOutsideWorld = false;
}
@@ -1131,7 +1038,6 @@ void G4Navigator::SetupHierarchy()
G4VSolid *pSolid;
G4VPVParameterisation *pParam;
mother = fHistory.GetVolume(0);
for ( i=1; i<=cdepth; i++ )
{
current = fHistory.GetVolume(i);
@@ -1406,6 +1312,106 @@ void G4Navigator::PrintState() const
G4cout.precision(oldcoutPrec);
}
// ********************************************************************
// ComputeStepLog
// ********************************************************************
//
void G4Navigator::ComputeStepLog(const G4ThreeVector& pGlobalpoint,
G4double moveLenSq) const
{
// The following checks only make sense if the move is larger
// than the tolerance.
static const G4double fAccuracyForWarning = kCarTolerance,
fAccuracyForException = 1000*kCarTolerance;
G4ThreeVector OriginalGlobalpoint = fHistory.GetTopTransform().Inverse().
TransformPoint(fLastLocatedPointLocal);
G4double shiftOriginSafSq = (fPreviousSftOrigin-pGlobalpoint).mag2();
// Check that the starting point of this step is
// within the isotropic safety sphere of the last point
// to a accuracy/precision given by fAccuracyForWarning.
// If so give warning.
// If it fails by more than fAccuracyForException exit with error.
//
if( shiftOriginSafSq >= sqr(fPreviousSafety) )
{
G4double shiftOrigin = std::sqrt(shiftOriginSafSq);
G4double diffShiftSaf = shiftOrigin - fPreviousSafety;
if( diffShiftSaf > fAccuracyForWarning )
{
G4int oldcoutPrec= G4cout.precision(8);
G4int oldcerrPrec= G4cerr.precision(10);
G4Exception("G4Navigator::ComputeStep()",
"UnexpectedPositionShift", JustWarning,
"Accuracy error or slightly inaccurate position shift.");
G4cerr << " The Step's starting point has moved "
<< std::sqrt(moveLenSq)/mm << " mm " << G4endl
<< " since the last call to a Locate method." << G4endl;
G4cerr << " This has resulted in moving "
<< shiftOrigin/mm << " mm "
<< " from the last point at which the safety "
<< " was calculated " << G4endl;
G4cerr << " which is more than the computed safety= "
<< fPreviousSafety/mm << " mm at that point." << G4endl;
G4cerr << " This difference is "
<< diffShiftSaf/mm << " mm." << G4endl
<< " The tolerated accuracy is "
<< fAccuracyForException/mm << " mm." << G4endl;
static G4int warnNow = 0;
if( ((++warnNow % 100) == 1) )
{
G4cerr << " This problem can be due to either " << G4endl;
G4cerr << " - a process that has proposed a displacement"
<< " larger than the current safety , or" << G4endl;
G4cerr << " - inaccuracy in the computation of the safety"
<< G4endl;
G4cerr << " We suggest that you " << G4endl
<< " - find i) what particle is being tracked, and "
<< " ii) through what part of your geometry " << G4endl
<< " for example by re-running this event with "
<< G4endl
<< " /tracking/verbose 1 " << G4endl
<< " - check which processes you declare for"
<< " this particle (and look at non-standard ones)"
<< G4endl
<< " - in case, create a detailed logfile"
<< " of this event using:" << G4endl
<< " /tracking/verbose 6 "
<< G4endl;
}
G4cout.precision(oldcoutPrec);
G4cerr.precision(oldcerrPrec);
}
#ifdef G4DEBUG_NAVIGATION
else
{
G4cerr << "WARNING - G4Navigator::ComputeStep()" << G4endl
<< " The Step's starting point has moved "
<< std::sqrt(moveLenSq) << "," << G4endl
<< " which has taken it to the limit of"
<< " the current safety. " << G4endl;
}
#endif
}
G4double safetyPlus = fPreviousSafety + fAccuracyForException;
if ( shiftOriginSafSq > sqr(safetyPlus) )
{
G4cerr << "ERROR - G4Navigator::ComputeStep()" << G4endl
<< " Position has shifted considerably without"
<< " notifying the navigator !" << G4endl
<< " Tolerated safety: " << safetyPlus << G4endl
<< " Computed shift : " << shiftOriginSafSq << G4endl;
G4Exception("G4Navigator::ComputeStep()",
"SignificantPositionShift", JustWarning,
"May lead to a crash or unreliable results.");
}
}
// ********************************************************************
// Operator <<
// ********************************************************************
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4NormalNavigation.cc,v 1.9 2007/05/11 13:43:59 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4NormalNavigation.cc,v 1.11 2010/11/04 08:57:56 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// class G4NormalNavigation Implementation
@@ -37,15 +37,14 @@
#include "G4NormalNavigation.hh"
#include "G4AffineTransform.hh"
#include <iomanip>
// ********************************************************************
// Constructor
// ********************************************************************
//
G4NormalNavigation::G4NormalNavigation()
: fCheck(false), fVerbose(0)
: fCheck(false)
{
fLogger = new G4NavigationLogger("G4NormalNavigation");
}
// ********************************************************************
@@ -53,7 +52,9 @@ G4NormalNavigation::G4NormalNavigation()
// ********************************************************************
//
G4NormalNavigation::~G4NormalNavigation()
{;}
{
delete fLogger;
}
// ********************************************************************
// ComputeStep
@@ -89,72 +90,9 @@ G4NormalNavigation::ComputeStep(const G4ThreeVector &localPoint,
ourSafety = motherSafety; // Working isotropic safety
#ifdef G4VERBOSE
static G4int precVerf= 20; // Precision
if ( fCheck )
{
if( fVerbose == 1 )
{
G4cout << "*** G4NormalNavigation::ComputeStep(): ***" << G4endl
<< " Invoked DistanceToOut(p) for mother solid: "
<< motherSolid->GetName()
<< ". Solid replied: " << motherSafety << G4endl
<< " For local point p: " << localPoint << G4endl
<< " To be considered as 'mother safety'." << G4endl;
}
if ( motherSafety < 0.0 )
{
G4cerr << "ERROR - G4NormalNavigation::ComputeStep()" << G4endl
<< " Current solid " << motherSolid->GetName()
<< " gave negative safety: " << motherSafety << G4endl
<< " for the current (local) point " << localPoint
<< G4endl;
motherSolid->DumpInfo();
G4Exception("G4NormalNavigation::ComputeStep()",
"NegativeSafetyMotherVol", FatalException,
"Negative Safety In Voxel Navigation !" );
}
if( motherSolid->Inside(localPoint)==kOutside )
{
G4cout << "WARNING - G4NormalNavigation::ComputeStep()" << G4endl
<< " Point " << localPoint
<< " is outside current volume " << motherPhysical->GetName()
<< G4endl;
G4double estDistToSolid= motherSolid->DistanceToIn(localPoint);
G4cout << " Estimated isotropic distance to solid (distToIn)= "
<< estDistToSolid << G4endl;
if( estDistToSolid > 100.0 * motherSolid->GetTolerance() )
{
motherSolid->DumpInfo();
G4Exception("G4NormalNavigation::ComputeStep()",
"FarOutsideCurrentVolume", FatalException,
"Point is far outside Current Volume !" );
}
else
G4Exception("G4NormalNavigation::ComputeStep()", "OutsideCurrentVolume",
JustWarning, "Point is a little outside Current Volume.");
}
// Verification / verbosity
//
if ( fVerbose > 1 )
{
G4int oldprec = G4cout.precision(precVerf);
G4cout << " G4NormalNavigation::ComputeStep()"
<< " - Information on mother / key daughters ..." << G4endl;
G4cout << " Type " << std::setw(12) << "Solid-Name" << " "
<< std::setw(3*(6+precVerf)) << " local point" << " "
<< std::setw(4+precVerf) << "solid-Safety" << " "
<< std::setw(4+precVerf) << "solid-Step" << " "
<< std::setw(17) << "distance Method "
<< std::setw(3*(6+precVerf)) << " local direction" << " "
<< G4endl;
G4cout << " Mother " << std::setw(12) << motherSolid->GetName() << " "
<< std::setw(4+precVerf) << localPoint << " "
<< std::setw(4+precVerf) << motherSafety << " "
<< G4endl;
G4cout.precision(oldprec);
}
fLogger->PreComputeStepLog(motherPhysical, motherSafety, localPoint);
}
#endif
@@ -192,6 +130,12 @@ G4NormalNavigation::ComputeStep(const G4ThreeVector &localPoint,
samplePhysical->GetLogicalVolume()->GetSolid();
const G4double sampleSafety =
sampleSolid->DistanceToIn(samplePoint);
#ifdef G4VERBOSE
if( fCheck )
{
fLogger->PrintDaughterLog(sampleSolid, samplePoint, sampleSafety, 0);
}
#endif
if ( sampleSafety<ourSafety )
{
ourSafety=sampleSafety;
@@ -201,16 +145,12 @@ G4NormalNavigation::ComputeStep(const G4ThreeVector &localPoint,
sampleDirection = sampleTf.TransformAxis(localDirection);
const G4double sampleStep =
sampleSolid->DistanceToIn(samplePoint,sampleDirection);
#ifdef G4VERBOSE
if(( fCheck ) && ( fVerbose == 1 ))
if( fCheck )
{
G4cout << "*** G4NormalNavigation::ComputeStep(): ***" << G4endl
<< " Invoked DistanceToIn(p,v) for daughter solid: "
<< sampleSolid->GetName()
<< ". Solid replied: " << sampleStep << G4endl
<< " For local point p: " << samplePoint << G4endl
<< " Direction v: " << sampleDirection
<< ", to be considered as 'daughter step'." << G4endl;
fLogger->PrintDaughterLog(sampleSolid, samplePoint,
sampleSafety, sampleStep);
}
#endif
if ( sampleStep<=ourStep )
@@ -220,69 +160,11 @@ G4NormalNavigation::ComputeStep(const G4ThreeVector &localPoint,
exiting = false;
*pBlockedPhysical = samplePhysical;
blockedReplicaNo = -1;
#ifdef G4VERBOSE
// Check to see that the resulting point is indeed in/on volume.
// This check could eventually be made only for successful candidate.
if ( ( fCheck ) && ( sampleStep < kInfinity ) )
if( fCheck )
{
G4ThreeVector intersectionPoint;
intersectionPoint= samplePoint + sampleStep * sampleDirection;
EInside insideIntPt= sampleSolid->Inside(intersectionPoint);
G4String solidResponse = "-kInside-";
if (insideIntPt == kOutside)
solidResponse = "-kOutside-";
else if (insideIntPt == kSurface)
solidResponse = "-kSurface-";
if( fVerbose == 1 )
{
G4cout << "*** G4NormalNavigation::ComputeStep(): ***" << G4endl
<< " Invoked Inside() for solid: "
<< sampleSolid->GetName()
<< ". Solid replied: " << solidResponse << G4endl
<< " For point p: " << intersectionPoint
<< ", considered as 'intersection' point." << G4endl;
}
if ( insideIntPt != kSurface )
{
G4int oldcoutPrec = G4cout.precision(16);
G4cout << "WARNING - G4NormalNavigation::ComputeStep()" << G4endl
<< " Inaccurate DistanceToIn for solid "
<< sampleSolid->GetName() << G4endl;
G4cout << " Solid gave DistanceToIn = " << sampleStep
<< " yet returns " << solidResponse
<< " for this point !" << G4endl;
G4cout << " Point = " << intersectionPoint << G4endl;
if ( insideIntPt != kInside )
G4cout << " DistanceToIn(p) = "
<< sampleSolid->DistanceToIn(intersectionPoint)
<< G4endl;
if ( insideIntPt != kOutside )
G4cout << " DistanceToOut(p) = "
<< sampleSolid->DistanceToOut(intersectionPoint)
<< G4endl;
G4Exception("G4NormalNavigation::ComputeStep()",
"InaccurateDistanceToIn", JustWarning,
"Navigator gets conflicting response from Solid.");
G4cout.precision(oldcoutPrec);
}
}
// Verification / verbosity
//
if ( fVerbose > 1 )
{
G4int oldprec = G4cout.precision(precVerf);
G4cout << " Daught "
<< std::setw(12) << sampleSolid->GetName() << " "
<< std::setw(4+precVerf) << samplePoint << " "
<< std::setw(4+precVerf) << sampleSafety << " "
<< std::setw(4+precVerf) << sampleStep << " "
<< std::setw(16) << "distanceToIn" << " "
<< std::setw(4+precVerf) << localDirection << " "
<< G4endl;
G4cout.precision(oldprec);
fLogger->AlongComputeStepLog(sampleSolid, samplePoint,
sampleDirection, localDirection, sampleSafety, sampleStep);
}
#endif
}
@@ -312,41 +194,8 @@ G4NormalNavigation::ComputeStep(const G4ThreeVector &localPoint,
#ifdef G4VERBOSE
if ( fCheck )
{
if( fVerbose == 1 )
{
G4cout << "*** G4NormalNavigation::ComputeStep(): ***" << G4endl
<< " Invoked DistanceToOut(p,v,...) for mother solid: "
<< motherSolid->GetName()
<< ". Solid replied: " << motherStep << G4endl
<< " For local point p: " << localPoint << G4endl
<< " Direction v: " << localDirection
<< ", to be considered as 'mother step'." << G4endl;
}
if( ( motherStep < 0.0 ) || ( motherStep >= kInfinity) )
{
G4cerr << "ERROR - G4NormalNavigation::ComputeStep()" << G4endl
<< " Problem in Navigation" << G4endl
<< " Point (local coordinates): "
<< localPoint << G4endl
<< " Local Direction: " << localDirection << G4endl
<< " Solid: " << motherSolid->GetName() << G4endl;
motherSolid->DumpInfo();
G4Exception("G4NormalNavigation::ComputeStep()",
"PointDistOutInvalid", FatalException,
"Current point is outside the current solid !");
}
}
if ( fVerbose > 1 )
{
G4int oldprec = G4cout.precision(precVerf);
G4cout << " Mother " << std::setw(12) << motherSolid->GetName() << " "
<< std::setw(4+precVerf) << localPoint << " "
<< std::setw(4+precVerf) << motherSafety << " "
<< std::setw(4+precVerf) << motherStep << " "
<< std::setw(16) << "distanceToOut" << " "
<< std::setw(4+precVerf) << localDirection << " "
<< G4endl;
G4cout.precision(oldprec);
fLogger->PostComputeStepLog(motherSolid, localPoint, localDirection,
motherStep, motherSafety);
}
#endif
@@ -398,14 +247,9 @@ G4double G4NormalNavigation::ComputeSafety(const G4ThreeVector &localPoint,
ourSafety = motherSafety; // Working isotropic safety
#ifdef G4VERBOSE
if(( fCheck ) && ( fVerbose == 1 ))
if( fCheck )
{
G4cout << "*** G4NormalNavigation::ComputeSafety(): ***" << G4endl
<< " Invoked DistanceToOut(p) for mother solid: "
<< motherSolid->GetName()
<< ". Solid replied: " << motherSafety << G4endl
<< " For local point p: " << localPoint
<< ", to be considered as 'mother safety'." << G4endl;
fLogger->ComputeSafetyLog(motherSolid, localPoint, motherSafety, true);
}
#endif
@@ -429,14 +273,9 @@ G4double G4NormalNavigation::ComputeSafety(const G4ThreeVector &localPoint,
ourSafety = sampleSafety;
}
#ifdef G4VERBOSE
if(( fCheck ) && ( fVerbose == 1 ))
if(fCheck)
{
G4cout << "*** G4NormalNavigation::ComputeSafety(): ***" << G4endl
<< " Invoked DistanceToIn(p) for daughter solid: "
<< sampleSolid->GetName()
<< ". Solid replied: " << sampleSafety << G4endl
<< " For local point p: " << samplePoint
<< ", to be considered as 'daughter safety'." << G4endl;
fLogger->ComputeSafetyLog(sampleSolid, samplePoint, sampleSafety, false);
}
#endif
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4ParameterisedNavigation.cc,v 1.12 2007/11/09 16:06:02 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4ParameterisedNavigation.cc,v 1.13 2010/07/13 15:59:42 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// class G4ParameterisedNavigation Implementation
@@ -57,7 +57,8 @@
// ********************************************************************
//
G4ParameterisedNavigation::G4ParameterisedNavigation()
: fVoxelHeader(0)
: fVoxelAxis(kUndefined), fVoxelNoSlices(0), fVoxelSliceWidth(0.),
fVoxelNodeNo(0), fVoxelHeader(0)
{
}
@@ -0,0 +1,347 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4PartialPhantomParameterisation.cc,v 1.3 2010/12/15 07:39:00 gunter Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// class G4PartialPhantomParameterisation implementation
//
// May 2007 Pedro Arce (CIEMAT), first version
//
// --------------------------------------------------------------------
#include "G4PartialPhantomParameterisation.hh"
#include "globals.hh"
#include "G4Material.hh"
#include "G4VSolid.hh"
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4VVolumeMaterialScanner.hh"
#include "G4GeometryTolerance.hh"
#include <list>
//------------------------------------------------------------------
G4PartialPhantomParameterisation::G4PartialPhantomParameterisation()
: G4PhantomParameterisation()
{
}
//------------------------------------------------------------------
G4PartialPhantomParameterisation::~G4PartialPhantomParameterisation()
{
}
//------------------------------------------------------------------
void G4PartialPhantomParameterisation::
ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol ) const
{
// Voxels cannot be rotated, return translation
//
G4ThreeVector trans = GetTranslation( copyNo );
physVol->SetTranslation( trans );
}
//------------------------------------------------------------------
G4ThreeVector G4PartialPhantomParameterisation::
GetTranslation(const G4int copyNo ) const
{
CheckCopyNo( copyNo );
size_t nx;
size_t ny;
size_t nz;
ComputeVoxelIndices( copyNo, nx, ny, nz );
G4ThreeVector trans( (2*nx+1)*fVoxelHalfX - fContainerWallX,
(2*ny+1)*fVoxelHalfY - fContainerWallY,
(2*nz+1)*fVoxelHalfZ - fContainerWallZ);
return trans;
}
//------------------------------------------------------------------
G4Material* G4PartialPhantomParameterisation::
ComputeMaterial(const G4int copyNo, G4VPhysicalVolume *, const G4VTouchable *)
{
CheckCopyNo( copyNo );
size_t matIndex = GetMaterialIndex(copyNo);
return fMaterials[ matIndex ];
}
//------------------------------------------------------------------
size_t G4PartialPhantomParameterisation::
GetMaterialIndex( size_t copyNo ) const
{
CheckCopyNo( copyNo );
if( !fMaterialIndices ) { return 0; }
return *(fMaterialIndices+copyNo);
}
//------------------------------------------------------------------
size_t G4PartialPhantomParameterisation::
GetMaterialIndex( size_t nx, size_t ny, size_t nz ) const
{
size_t copyNo = nx + fNoVoxelX*ny + fNoVoxelXY*nz;
return GetMaterialIndex( copyNo );
}
//------------------------------------------------------------------
G4Material* G4PartialPhantomParameterisation::
GetMaterial( size_t nx, size_t ny, size_t nz) const
{
return fMaterials[GetMaterialIndex(nx,ny,nz)];
}
//------------------------------------------------------------------
G4Material* G4PartialPhantomParameterisation::
GetMaterial( size_t copyNo ) const
{
return fMaterials[GetMaterialIndex(copyNo)];
}
//------------------------------------------------------------------
void G4PartialPhantomParameterisation::
ComputeVoxelIndices(const G4int copyNo, size_t& nx,
size_t& ny, size_t& nz ) const
{
CheckCopyNo( copyNo );
std::multimap<G4int,G4int>::const_iterator ite =
fFilledIDs.lower_bound(size_t(copyNo));
G4int dist = std::distance( fFilledIDs.begin(), ite );
nz = size_t(dist/fNoVoxelY);
ny = size_t( dist%fNoVoxelY );
G4int ifmin = (*ite).second;
G4int nvoxXprev;
if( dist != 0 ) {
ite--;
nvoxXprev = (*ite).first;
} else {
nvoxXprev = -1;
}
nx = ifmin+copyNo-nvoxXprev-1;
}
//------------------------------------------------------------------
G4int G4PartialPhantomParameterisation::
GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
{
// Check the voxel numbers corresponding to localPoint
// When a particle is on a surface, it may be between -kCarTolerance and
// +kCartolerance. By a simple distance as:
// G4int nx = G4int( (localPoint.x()+)/fVoxelHalfX/2.);
// those between -kCartolerance and 0 will be placed on voxel N-1 and those
// between 0 and kCarTolerance on voxel N.
// To avoid precision problems place the tracks that are on the surface on
// voxel N-1 if they have negative direction and on voxel N if they have
// positive direction.
// Add +kCarTolerance so that they are first placed on voxel N, and then
// if the direction is negative substract 1
G4double fx = (localPoint.x()+fContainerWallX+kCarTolerance)/(fVoxelHalfX*2.);
G4int nx = G4int(fx);
G4double fy = (localPoint.y()+fContainerWallY+kCarTolerance)/(fVoxelHalfY*2.);
G4int ny = G4int(fy);
G4double fz = (localPoint.z()+fContainerWallZ+kCarTolerance)/(fVoxelHalfZ*2.);
G4int nz = G4int(fz);
// If it is on the surface side, check the direction: if direction is
// negative place it on the previous voxel (if direction is positive it is
// already in the next voxel...).
// Correct also cases where n = -1 or n = fNoVoxel. It is always traced to be
// due to multiple scattering: track is entering a voxel but multiple
// scattering changes the angle towards outside
//
if( fx - nx < kCarTolerance/fVoxelHalfX )
{
if( localDir.x() < 0 )
{
if( nx != 0 )
{
nx -= 1;
}
}
else
{
if( nx == G4int(fNoVoxelX) )
{
nx -= 1;
}
}
}
if( fy - ny < kCarTolerance/fVoxelHalfY )
{
if( localDir.y() < 0 )
{
if( ny != 0 )
{
ny -= 1;
}
}
else
{
if( ny == G4int(fNoVoxelY) )
{
ny -= 1;
}
}
}
if( fz - nz < kCarTolerance/fVoxelHalfZ )
{
if( localDir.z() < 0 )
{
if( nz != 0 )
{
nz -= 1;
}
}
else
{
if( nz == G4int(fNoVoxelZ) )
{
nz -= 1;
}
}
}
// Check if there are still errors
//
G4bool isOK = true;
if( nx < 0 )
{
nx = 0;
isOK = false;
}
else if( nx >= G4int(fNoVoxelX) )
{
nx = fNoVoxelX-1;
isOK = false;
}
if( ny < 0 )
{
ny = 0;
isOK = false;
}
else if( ny >= G4int(fNoVoxelY) )
{
ny = fNoVoxelY-1;
isOK = false;
}
if( nz < 0 )
{
nz = 0;
isOK = false;
}
else if( nz >= G4int(fNoVoxelZ) )
{
nz = fNoVoxelZ-1;
isOK = false;
}
if( !isOK )
{
G4cerr << "WARNING - G4PartialPhantomParameterisation::GetReplicaNo()"
<< G4endl
<< " LocalPoint: " << localPoint << G4endl
<< " LocalDir: " << localDir << G4endl
<< " Voxel container size: " << fContainerWallX
<< " " << fContainerWallY << " " << fContainerWallZ << G4endl
<< " LocalPoint - wall: "
<< localPoint.x()-fContainerWallX << " "
<< localPoint.y()-fContainerWallY << " "
<< localPoint.z()-fContainerWallZ << G4endl;
G4Exception("G4PartialPhantomParameterisation::GetReplicaNo()",
"Wrong-copy-number", JustWarning,
"Corrected the copy number! It was negative or too big");
}
G4int nyz = nz*fNoVoxelY+ny;
std::multimap<G4int,G4int>::iterator ite = fFilledIDs.begin();
/*
for( ite = fFilledIDs.begin(); ite != fFilledIDs.end(); ite++ )
{
G4cout << " G4PartialPhantomParameterisation::GetReplicaNo filled "
<< (*ite).first << " , " << (*ite).second << std::endl;
}
*/
ite = fFilledIDs.begin();
advance(ite,nyz);
std::multimap<G4int,G4int>::iterator iteant = ite; iteant--;
G4int copyNo = (*iteant).first + 1 + ( nx - (*ite).second );
/*
G4cout << " G4PartialPhantomParameterisation::GetReplicaNo getting copyNo "
<< copyNo << " nyz " << nyz << " (*iteant).first "
<< (*iteant).first << " (*ite).second " << (*ite).second << G4endl;
G4cout << " G4PartialPhantomParameterisation::GetReplicaNo " << copyNo
<< " nx " << nx << " ny " << ny << " nz " << nz
<< " localPoint " << localPoint << " localDir " << localDir << G4endl;
*/
return copyNo;
}
//------------------------------------------------------------------
void G4PartialPhantomParameterisation::CheckCopyNo( const G4int copyNo ) const
{
if( copyNo < 0 || copyNo >= G4int(fNoVoxel) )
{
G4cerr << "ERROR - G4PartialPhantomParameterisation::CheckCopyNo()"
<< G4endl
<< " Copy number: " << copyNo << G4endl
<< " Total number of voxels: " << fNoVoxel << G4endl;
G4Exception("G4PartialPhantomParameterisation::CheckCopyNo()",
"Wrong-copy-number", FatalErrorInArgument,
"Copy number is negative or too big!");
}
}
//------------------------------------------------------------------
void G4PartialPhantomParameterisation::BuildContainerWalls()
{
fContainerWallX = fNoVoxelX * fVoxelHalfX;
fContainerWallY = fNoVoxelY * fVoxelHalfY;
fContainerWallZ = fNoVoxelZ * fVoxelHalfZ;
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4PathFinder.cc,v 1.62 2009/05/13 23:20:54 japost Exp $
// $Id: G4PathFinder.cc,v 1.64 2010/07/13 15:59:42 gcosmo Exp $
// GEANT4 tag $ Name: $
//
// class G4PathFinder Implementation
@@ -68,8 +68,9 @@ G4PathFinder* G4PathFinder::GetInstance()
//
G4PathFinder::G4PathFinder()
: fEndState( G4ThreeVector(), G4ThreeVector(), 0., 0., 0., 0., 0.),
fFieldExertedForce(false),
fRelocatedPoint(true),
fLastStepNo(-1),
fLastStepNo(-1), fCurrentStepNo(-1),
fVerboseLevel(0)
{
fpMultiNavigator= new G4MultiNavigator();
@@ -90,10 +91,12 @@ G4PathFinder::G4PathFinder()
fMinSafety_PreStepPt= -1.0;
fMinSafety_atSafLocation= -1.0;
fMinStep= -1.0;
fTrueMinStep= -1.0;
fPreStepCenterRenewed= false;
fNewTrack= false;
fNoGeometriesLimiting= 0;
for( register int num=0; num<= fMaxNav; ++num )
for( register int num=0; num< fMaxNav; ++num )
{
fpNavigator[num] = 0;
fLimitTruth[num] = false;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4PhantomParameterisation.cc,v 1.6 2009/05/20 08:27:10 gcosmo Exp $
// $Id: G4PhantomParameterisation.cc,v 1.7 2010/07/13 15:59:42 gcosmo Exp $
// GEANT4 tag $ Name:$
//
// class G4PhantomParameterisation implementation
@@ -44,17 +44,13 @@
//------------------------------------------------------------------
G4PhantomParameterisation::G4PhantomParameterisation()
: fVoxelHalfX(0.), fVoxelHalfY(0.), fVoxelHalfZ(0.),
fNoVoxelX(0), fNoVoxelY(0), fNoVoxelZ(0), fNoVoxelXY(0), fNoVoxel(0),
fMaterialIndices(0), fContainerSolid(0),
fContainerWallX(0.), fContainerWallY(0.), fContainerWallZ(0.),
bSkipEqualMaterials(true)
{
// Initialise data
//
fMaterialIndices = 0;
fContainerWallX = 0.;
fContainerWallY = 0.;
fContainerWallZ = 0.;
kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
bSkipEqualMaterials = 1;
}
@@ -35,7 +35,7 @@
// 14.10.96 John Apostolakis, design and implementation
// 17.03.97 John Apostolakis, renaming new set functions being added
//
// $Id: G4PropagatorInField.cc,v 1.50 2009/12/10 08:41:54 japost Exp $
// $Id: G4PropagatorInField.cc,v 1.52 2010/07/13 15:59:42 gcosmo Exp $
// GEANT4 tag $ Name: $
// ---------------------------------------------------------------------------
@@ -128,9 +128,7 @@ G4PropagatorInField::ComputeStep(
G4double CurrentProposedStepLength,
G4double& currentSafety, // IN/OUT
G4VPhysicalVolume* pPhysVol)
{
const G4String MethodName("G4PropagatorInField::ComputeStep");
{
// If CurrentProposedStepLength is too small for finding Chords
// then return with no action (for now - TODO: some action)
//
@@ -237,8 +235,8 @@ G4PropagatorInField::ComputeStep(
stepTrial *= decreaseFactor;
#ifdef G4DEBUG_FIELD
G4cout << MethodName << ": "
<< " Decreasing step - "
G4cout << " G4PropagatorInField::ComputeStep(): " << G4endl
<< " Decreasing step - "
<< " decreaseFactor= " << std::setw(8) << decreaseFactor
<< " stepTrial = " << std::setw(18) << stepTrial << " "
<< " fZeroStepThreshold = " << fZeroStepThreshold << G4endl;
@@ -247,15 +245,15 @@ G4PropagatorInField::ComputeStep(
#endif
if( stepTrial == 0.0 ) // Change to make it < 0.1 * kCarTolerance ??
{
G4cout << " G4PropagatorInField::ComputeStep "
<< " Particle abandoned due to lack of progress in field."
G4cout << " G4PropagatorInField::ComputeStep(): " << G4endl
<< " Particle abandoned due to lack of progress in field."
<< G4endl
<< " Properties : " << pFieldTrack << " "
<< " Properties : " << pFieldTrack << " "
<< G4endl;
G4cerr << " G4PropagatorInField::ComputeStep "
<< " ERROR : attempting a zero step= " << stepTrial << G4endl
<< " while attempting to progress after " << fNoZeroStep
<< " trial steps. Will abandon step." << G4endl;
G4cerr << " G4PropagatorInField::ComputeStep() - ERROR " << G4endl
<< " Attempting a zero step = " << stepTrial << G4endl
<< " while attempting to progress after " << fNoZeroStep
<< " trial steps. Will abandon step." << G4endl;
fParticleIsLooping= true;
return 0; // = stepTrial;
}
@@ -350,8 +348,8 @@ G4PropagatorInField::ComputeStep(
#ifdef G4VERBOSE
if( (fVerboseLevel > 1) && (do_loop_count > fMax_loop_count-10 )) {
if( do_loop_count == fMax_loop_count-9 ){
G4cout << "G4PropagatorInField::ComputeStep "
<< " Difficult track - taking many sub steps." << G4endl;
G4cout << " G4PropagatorInField::ComputeStep(): " << G4endl
<< " Difficult track - taking many sub steps." << G4endl;
}
printStatus( SubStepStartState, CurrentState, CurrentProposedStepLength,
NewSafety, do_loop_count, pPhysVol );
@@ -368,13 +366,15 @@ G4PropagatorInField::ComputeStep(
{
fParticleIsLooping = true;
if ( fVerboseLevel > 0 ){
G4cout << "G4PropagateInField: Killing looping particle "
if ( fVerboseLevel > 0 )
{
G4cout << " G4PropagateInField::ComputeStep(): " << G4endl
<< " Killing looping particle "
// << " of " << energy << " energy "
<< " after " << do_loop_count << " field substeps "
<< " totaling " << StepTaken / mm << " mm " ;
if( pPhysVol )
G4cout << " in the volume " << pPhysVol->GetName() ;
G4cout << " in volume " << pPhysVol->GetName() ;
else
G4cout << " in unknown or null volume. " ;
G4cout << G4endl;
@@ -400,19 +400,19 @@ G4PropagatorInField::ComputeStep(
if( std::fabs(OriginalState.GetCurveLength() + TruePathLength
- End_PointAndTangent.GetCurveLength()) > 3.e-4 * TruePathLength )
{
G4cerr << " ERROR - G4PropagatorInField::ComputeStep():" << G4endl
<< " Curve length mis-match, is advancement wrong ? " << G4endl;
G4cerr << " The curve length of the endpoint should be: "
G4cerr << " G4PropagatorInField::ComputeStep() - ERROR" << G4endl
<< " Curve length mis-match, is advancement wrong ? " << G4endl;
G4cerr << " The curve length of the endpoint should be: "
<< OriginalState.GetCurveLength() + TruePathLength << G4endl
<< " and it is instead: "
<< " and it is instead: "
<< End_PointAndTangent.GetCurveLength() << "." << G4endl
<< " A difference of: "
<< " A difference of: "
<< OriginalState.GetCurveLength() + TruePathLength
- End_PointAndTangent.GetCurveLength() << G4endl;
G4cerr << " Original state= " << OriginalState << G4endl
<< " Proposed state= " << End_PointAndTangent << G4endl;
G4Exception("G4PropagatorInField::ComputeStep()", "IncorrectProposedEndPoint",
FatalException,
G4cerr << " Original state = " << OriginalState << G4endl
<< " Proposed state = " << End_PointAndTangent << G4endl;
G4Exception("G4PropagatorInField::ComputeStep()",
"IncorrectProposedEndPoint", FatalException,
"Curve length mis-match between original state and proposed endpoint of propagation.");
}
#endif
@@ -433,21 +433,24 @@ G4PropagatorInField::ComputeStep(
fNoZeroStep = 0;
}
if( fNoZeroStep > fAbandonThreshold_NoZeroSteps ) {
if( fNoZeroStep > fAbandonThreshold_NoZeroSteps )
{
fParticleIsLooping = true;
G4cout << " WARNING - G4PropagatorInField::ComputeStep():" << G4endl
<< " Zero progress for " << fNoZeroStep << " attempted steps."
G4cout << " G4PropagatorInField::ComputeStep() - WARNING" << G4endl
<< " Zero progress for " << fNoZeroStep << " attempted steps."
<< G4endl;
G4cout << "Proposed Step is "<<CurrentProposedStepLength <<" but Step Taken is "<< fFull_CurveLen_of_LastAttempt <<G4endl;
G4cout << "For Particle with Charge ="<<fCharge
<< " Momentum="<< fInitialMomentumModulus<<" Mass="<< fMass<<G4endl;
G4cout << " Proposed Step is " << CurrentProposedStepLength
<< " but Step Taken is "<< fFull_CurveLen_of_LastAttempt << G4endl;
G4cout << " For Particle with Charge = " << fCharge
<< " Momentum = "<< fInitialMomentumModulus
<< " Mass = " << fMass << G4endl;
if( pPhysVol )
G4cout << " in the volume " << pPhysVol->GetName() ;
G4cout << " in volume " << pPhysVol->GetName() ;
else
G4cout << " in unknown or null volume. " ;
G4cout << G4endl;
if ( fVerboseLevel > 2 )
G4cout << " Particle that is stuck will be killed." << G4endl;
G4cout << " Particle is stuck; it will be killed." << G4endl;
fNoZeroStep = 0;
}
@@ -466,20 +469,19 @@ G4PropagatorInField::printStatus( const G4FieldTrack& StartFT,
G4int stepNo,
G4VPhysicalVolume* startVolume)
{
const G4int verboseLevel= fVerboseLevel;
const G4int verboseLevel=fVerboseLevel;
const G4ThreeVector StartPosition = StartFT.GetPosition();
const G4ThreeVector StartUnitVelocity = StartFT.GetMomentumDir();
const G4ThreeVector CurrentPosition = CurrentFT.GetPosition();
const G4ThreeVector CurrentUnitVelocity = CurrentFT.GetMomentumDir();
G4double step_len = CurrentFT.GetCurveLength() - StartFT.GetCurveLength();
G4int oldprec; // cout/cerr precision settings
if( ((stepNo == 0) && (verboseLevel <3))
|| (verboseLevel >= 3) )
if( ((stepNo == 0) && (verboseLevel <3)) || (verboseLevel >= 3) )
{
static G4int noPrecision= 4;
G4cout.precision(noPrecision);
// G4cout.setf(ios_base::fixed,ios_base::floatfield);
oldprec = G4cout.precision(4);
G4cout << std::setw( 6) << " "
<< std::setw( 25) << " Current Position and Direction" << " "
<< G4endl;
@@ -491,79 +493,62 @@ G4PropagatorInField::printStatus( const G4FieldTrack& StartFT,
<< std::setw( 7) << " N_x " << " "
<< std::setw( 7) << " N_y " << " "
<< std::setw( 7) << " N_z " << " " ;
// << G4endl;
G4cout // << " >>> "
<< std::setw( 7) << " Delta|N|" << " "
// << std::setw( 7) << " Delta(N_z) " << " "
G4cout << std::setw( 7) << " Delta|N|" << " "
<< std::setw( 9) << "StepLen" << " "
<< std::setw(12) << "StartSafety" << " "
<< std::setw( 9) << "PhsStep" << " ";
if( startVolume ) {
G4cout << std::setw(18) << "NextVolume" << " ";
}
if( startVolume )
{ G4cout << std::setw(18) << "NextVolume" << " "; }
G4cout.precision(oldprec);
G4cout << G4endl;
}
if((stepNo == 0) && (verboseLevel <=3)){
// Recurse to print the start values
//
printStatus( StartFT, StartFT, -1.0, safety, -1, startVolume);
}
if( verboseLevel <= 3 )
{
if( stepNo >= 0)
G4cout << std::setw( 4) << stepNo << " ";
else
G4cout << std::setw( 5) << "Start" ;
G4cout.precision(8);
G4cout << std::setw(10) << CurrentFT.GetCurveLength() << " ";
G4cout.precision(8);
G4cout << std::setw(10) << CurrentPosition.x() << " "
<< std::setw(10) << CurrentPosition.y() << " "
<< std::setw(10) << CurrentPosition.z() << " ";
G4cout.precision(4);
G4cout << std::setw( 7) << CurrentUnitVelocity.x() << " "
<< std::setw( 7) << CurrentUnitVelocity.y() << " "
<< std::setw( 7) << CurrentUnitVelocity.z() << " ";
// G4cout << G4endl;
// G4cout << " >>> " ;
G4cout.precision(3);
G4cout << std::setw( 7) << CurrentFT.GetMomentum().mag()- StartFT.GetMomentum().mag() << " ";
// << std::setw( 7) << CurrentUnitVelocity.z() - InitialUnitVelocity.z() << " ";
G4cout << std::setw( 9) << step_len << " ";
G4cout << std::setw(12) << safety << " ";
if( requestStep != -1.0 )
G4cout << std::setw( 9) << requestStep << " ";
else
G4cout << std::setw( 9) << "Init/NotKnown" << " ";
if( startVolume != 0)
{
G4cout << std::setw(12) << startVolume->GetName() << " ";
}
#if 0
else
{
if( step_len != -1 )
G4cout << std::setw(12) << "OutOfWorld" << " ";
else
G4cout << std::setw(12) << "NotGiven" << " ";
}
#endif
G4cout << G4endl;
}
else // if( verboseLevel > 3 )
{
// Multi-line output
G4cout << "Step taken was " << step_len
<< " out of PhysicalStep= " << requestStep << G4endl;
G4cout << "Final safety is: " << safety << G4endl;
G4cout << "Chord length = " << (CurrentPosition-StartPosition).mag()
<< G4endl;
G4cout << G4endl;
}
if((stepNo == 0) && (verboseLevel <=3))
{
// Recurse to print the start values
//
printStatus( StartFT, StartFT, -1.0, safety, -1, startVolume);
}
if( verboseLevel <= 3 )
{
if( stepNo >= 0)
{ G4cout << std::setw( 4) << stepNo << " "; }
else
{ G4cout << std::setw( 5) << "Start" ; }
oldprec = G4cout.precision(8);
G4cout << std::setw(10) << CurrentFT.GetCurveLength() << " ";
G4cout.precision(8);
G4cout << std::setw(10) << CurrentPosition.x() << " "
<< std::setw(10) << CurrentPosition.y() << " "
<< std::setw(10) << CurrentPosition.z() << " ";
G4cout.precision(4);
G4cout << std::setw( 7) << CurrentUnitVelocity.x() << " "
<< std::setw( 7) << CurrentUnitVelocity.y() << " "
<< std::setw( 7) << CurrentUnitVelocity.z() << " ";
G4cout.precision(3);
G4cout << std::setw( 7)
<< CurrentFT.GetMomentum().mag()-StartFT.GetMomentum().mag() << " ";
G4cout << std::setw( 9) << step_len << " ";
G4cout << std::setw(12) << safety << " ";
if( requestStep != -1.0 )
{ G4cout << std::setw( 9) << requestStep << " "; }
else
{ G4cout << std::setw( 9) << "Init/NotKnown" << " "; }
if( startVolume != 0)
{ G4cout << std::setw(12) << startVolume->GetName() << " "; }
G4cout.precision(oldprec);
G4cout << G4endl;
}
else // if( verboseLevel > 3 )
{
// Multi-line output
G4cout << "Step taken was " << step_len
<< " out of PhysicalStep = " << requestStep << G4endl;
G4cout << "Final safety is: " << safety << G4endl;
G4cout << "Chord length = " << (CurrentPosition-StartPosition).mag()
<< G4endl;
G4cout << G4endl;
}
}
///////////////////////////////////////////////////////////////////////////
@@ -578,10 +563,10 @@ G4PropagatorInField::PrintStepLengthDiagnostic(
const G4FieldTrack& )
{
#if 0
G4cout << " PiF: NoZeroStep= " << fNoZeroStep
<< " CurrentProposedStepLength= " << CurrentProposedStepLength
<< " Full_curvelen_last=" << fFull_CurveLen_of_LastAttempt
<< " last proposed step-length= " << fLast_ProposedStepLength
G4cout << " PiF: NoZeroStep = " << fNoZeroStep
<< " CurrentProposedStepLength = " << CurrentProposedStepLength
<< " Full_curvelen_last =" << fFull_CurveLen_of_LastAttempt
<< " last proposed step-length = " << fLast_ProposedStepLength
<< " decrease factor = " << decreaseFactor
<< " step trial = " << stepTrial
<< G4endl;
@@ -697,7 +682,7 @@ G4int G4PropagatorInField::SetVerboseLevel( G4int level )
// MagIntegratorDriver ... ?
//
G4MagInt_Driver* integrDriver= GetChordFinder()->GetIntegrationDriver();
integrDriver->SetVerboseLevel( fVerboseLevel - 2 );
integrDriver->SetVerboseLevel( fVerboseLevel - 2 );
G4cout << "Set Driver verbosity to " << fVerboseLevel - 2 << G4endl;
return oldval;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4RegularNavigation.cc,v 1.9 2009/01/27 09:31:29 gcosmo Exp $
// $Id: G4RegularNavigation.cc,v 1.15 2010/11/19 15:13:39 gcosmo Exp $
// GEANT4 tag $ Name:$
//
// class G4RegularNavigation implementation
@@ -44,7 +44,7 @@
//------------------------------------------------------------------
G4RegularNavigation::G4RegularNavigation()
: fVerbose(1), fCheck(true)
: fverbose(false), fcheck(false), fnormalNav(0)
{
kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
}
@@ -121,7 +121,7 @@ G4double G4RegularNavigation::
//------------------------------------------------------------------
G4double G4RegularNavigation::ComputeStepSkippingEqualMaterials(
G4ThreeVector localPoint,
G4ThreeVector& localPoint,
const G4ThreeVector& localDirection,
const G4double currentProposedStepLength,
G4double& newSafety,
@@ -290,26 +290,21 @@ G4RegularNavigation::LevelLocate( G4NavigationHistory& history,
const G4int ,
const G4ThreeVector& globalPoint,
const G4ThreeVector* globalDirection,
const G4bool pLocatedOnEdge,
const G4bool, // pLocatedOnEdge,
G4ThreeVector& localPoint )
{
G4SmartVoxelHeader *motherVoxelHeader;
G4VPhysicalVolume *motherPhysical, *pPhysical;
G4PhantomParameterisation *pParam;
G4LogicalVolume *motherLogical;
G4VSolid *pSolid;
G4ThreeVector localDir;
G4int replicaNo;
motherPhysical = history.GetTopVolume();
motherLogical = motherPhysical->GetLogicalVolume();
motherVoxelHeader = motherLogical->GetVoxelHeader();
pPhysical = motherLogical->GetDaughter(0);
pParam = (G4PhantomParameterisation*)(pPhysical->GetParameterisation());
pSolid = pParam->GetContainerSolid();
// Save parent history in touchable history
// ... for use as parent t-h in ComputeMaterial method of param
//
@@ -326,42 +321,28 @@ G4RegularNavigation::LevelLocate( G4NavigationHistory& history,
localDir = G4ThreeVector(0.,0.,0.);
}
// Check that track is not on the surface and check that track is not
// exiting the voxel parent volume
// Enter this daughter
//
if ( !G4AuxiliaryNavServices::CheckPointOnSurface(pSolid, localPoint,
globalDirection, history.GetTopTransform(), pLocatedOnEdge)
|| G4AuxiliaryNavServices::CheckPointExiting(pSolid, localPoint,
globalDirection, history.GetTopTransform() ) )
replicaNo = pParam->GetReplicaNo( localPoint, localDir );
if( replicaNo < 0 || replicaNo >= G4int(pParam->GetNoVoxel()) )
{
return false;
}
else
{
// Enter this daughter
//
replicaNo = pParam->GetReplicaNo( localPoint, localDir );
if( replicaNo < 0 || replicaNo >= G4int(pParam->GetNoVoxel()) )
{
return false;
}
// Set the correct copy number in physical
//
pPhysical->SetCopyNo(replicaNo);
pParam->ComputeTransformation(replicaNo,pPhysical);
// Set the correct copy number in physical
//
pPhysical->SetCopyNo(replicaNo);
pParam->ComputeTransformation(replicaNo,pPhysical);
history.NewLevel(pPhysical, kParameterised, replicaNo );
localPoint = history.GetTopTransform().TransformPoint(globalPoint);
history.NewLevel(pPhysical, kParameterised, replicaNo );
localPoint = history.GetTopTransform().TransformPoint(globalPoint);
// Set the correct solid and material in Logical Volume
//
G4LogicalVolume *pLogical = pPhysical->GetLogicalVolume();
// Set the correct solid and material in Logical Volume
//
G4LogicalVolume *pLogical = pPhysical->GetLogicalVolume();
pLogical->UpdateMaterial(pParam->ComputeMaterial(replicaNo,
pPhysical, &parentTouchable) );
return true;
}
return false;
pLogical->UpdateMaterial(pParam->ComputeMaterial(replicaNo,
pPhysical, &parentTouchable) );
return true;
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4ReplicaNavigation.cc,v 1.19 2008/04/28 15:39:55 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4ReplicaNavigation.cc,v 1.20 2010/07/13 15:59:42 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// class G4ReplicaNavigation Implementation
@@ -1038,6 +1038,7 @@ G4ReplicaNavigation::BackLocate(G4NavigationHistory &history,
G4cerr << "The World volume must be a Placement!" << G4endl;
G4Exception("G4ReplicaNavigation::BackLocate()", "InvalidSetup",
FatalException, "The World volume must be a Placement!");
return kInside;
}
motherSolid = pNRMother->GetLogicalVolume()->GetSolid();
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4SimpleLocator.cc,v 1.5 2008/12/11 10:27:58 tnikitin Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4SimpleLocator.cc,v 1.6 2010/07/13 15:59:42 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// Class G4SimpleLocator implementation
//
@@ -105,6 +105,8 @@ G4bool G4SimpleLocator::EstimateIntersectionPoint(
G4int substep_no = 0;
G4int oldprc; // cout/cerr precision settings
// Limits for substep number
//
const G4int max_substeps = 100000000; // Test 120 (old value 100 )
@@ -357,7 +359,7 @@ G4bool G4SimpleLocator::EstimateIntersectionPoint(
G4cerr << "Recalculation of EndPoint was called with fEpsStep= "
<< GetEpsilonStepFor() << G4endl;
}
G4cerr.precision(20);
oldprc = G4cerr.precision(20);
G4cerr << " Point A (Curve start) is " << CurveStartPointVelocity
<< G4endl;
G4cerr << " Point B (Curve end) is " << CurveEndPointVelocity
@@ -372,6 +374,7 @@ G4bool G4SimpleLocator::EstimateIntersectionPoint(
<< G4endl;
G4cerr << " LocateIntersection parameters are : Substep no= "
<< substep_no << G4endl;
G4cerr.precision(oldprc);
G4Exception("G4SimpleLocator::EstimateIntersectionPoint()",
"FatalError", FatalException,
@@ -451,7 +454,7 @@ G4bool G4SimpleLocator::EstimateIntersectionPoint(
printStatus( CurrentA_PointVelocity, CurrentB_PointVelocity,
-1.0, NewSafety, substep_no);
G4cout << G4endl;
G4cout.precision( 10 );
oldprc = G4cout.precision(10);
G4double done_len = CurrentA_PointVelocity.GetCurveLength();
G4double full_len = CurveEndPointVelocity.GetCurveLength();
G4cout << "ERROR - G4SimpleLocator::EstimateIntersectionPoint()"
@@ -459,6 +462,7 @@ G4bool G4SimpleLocator::EstimateIntersectionPoint(
<< " Undertaken only length: " << done_len
<< " out of " << full_len << " required." << G4endl;
G4cout << " Remaining length = " << full_len - done_len << G4endl;
G4cout.precision(oldprc);
G4Exception("G4SimpleLocator::EstimateIntersectionPoint()",
"UnableToLocateIntersection", FatalException,
@@ -466,7 +470,7 @@ G4bool G4SimpleLocator::EstimateIntersectionPoint(
}
else if( substep_no >= warn_substeps )
{
G4int oldprc= G4cout.precision( 10 );
oldprc= G4cout.precision(10);
G4cout << "WARNING - G4SimpleLocator::EstimateIntersectionPoint()"
<< G4endl
<< " Undertaken length: "
@@ -474,10 +478,10 @@ G4bool G4SimpleLocator::EstimateIntersectionPoint(
G4cout << " - Needed: " << substep_no << " substeps." << G4endl
<< " Warning level = " << warn_substeps
<< " and maximum substeps = " << max_substeps << G4endl;
G4cout.precision(oldprc);
G4Exception("G4SimpleLocator::EstimateIntersectionPoint()",
"DifficultyToLocateIntersection", JustWarning,
"Many substeps while trying to locate intersection.");
G4cout.precision( oldprc );
}
return !there_is_no_intersection; // Success or failure
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4TransportationManager.cc,v 1.15 2007/04/12 11:51:48 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4TransportationManager.cc,v 1.16 2010/07/13 15:59:42 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// G4TransportationManager
@@ -55,23 +55,7 @@ G4TransportationManager* G4TransportationManager::fTransportationManager=0;
//
G4TransportationManager::G4TransportationManager()
{
if (!fTransportationManager)
{
// Create the navigator for tracking and activate it; add to collections
//
G4Navigator* trackingNavigator = new G4Navigator();
trackingNavigator->Activate(true);
fNavigators.push_back(trackingNavigator);
fActiveNavigators.push_back(trackingNavigator);
fWorlds.push_back(trackingNavigator->GetWorldVolume()); // NULL registered
fGeomMessenger = new G4GeometryMessenger(this);
fFieldManager = new G4FieldManager();
fPropagatorInField = new G4PropagatorInField(trackingNavigator,
fFieldManager);
fSafetyHelper = new G4SafetyHelper();
}
else
if (fTransportationManager)
{
G4cerr << "Only ONE instance of G4TransportationManager is allowed!"
<< G4endl;
@@ -79,6 +63,19 @@ G4TransportationManager::G4TransportationManager()
"InvalidSetup", FatalException,
"Only ONE instance of G4TransportationManager is allowed!");
}
// Create the navigator for tracking and activate it; add to collections
//
G4Navigator* trackingNavigator = new G4Navigator();
trackingNavigator->Activate(true);
fNavigators.push_back(trackingNavigator);
fActiveNavigators.push_back(trackingNavigator);
fWorlds.push_back(trackingNavigator->GetWorldVolume()); // NULL registered
fGeomMessenger = new G4GeometryMessenger(this);
fFieldManager = new G4FieldManager();
fPropagatorInField= new G4PropagatorInField(trackingNavigator,fFieldManager);
fSafetyHelper = new G4SafetyHelper();
}
// ----------------------------------------------------------------------------
@@ -328,7 +325,11 @@ void G4TransportationManager::DeActivateNavigator( G4Navigator* aNavigator )
{
std::vector<G4Navigator*>::iterator pNav =
std::find(fNavigators.begin(), fNavigators.end(), aNavigator);
if (pNav == fNavigators.end())
if (pNav != fNavigators.end())
{
(*pNav)->Activate(false);
}
else
{
G4String message
= "Navigator for volume -" + aNavigator->GetWorldVolume()->GetName()
@@ -336,10 +337,7 @@ void G4TransportationManager::DeActivateNavigator( G4Navigator* aNavigator )
G4Exception("G4TransportationManager::DeActivateNavigator()",
"NoEffect", JustWarning, message);
}
else
{
(*pNav)->Activate(false);
}
std::vector<G4Navigator*>::iterator pActiveNav =
std::find(fActiveNavigators.begin(), fActiveNavigators.end(), aNavigator);
if (pActiveNav != fActiveNavigators.end())
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VIntersectionLocator.cc,v 1.7 2009/11/27 15:21:59 japost Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4VIntersectionLocator.cc,v 1.8 2010/07/13 15:59:42 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// Class G4VIntersectionLocator implementation
//
@@ -82,12 +82,11 @@ G4VIntersectionLocator::printStatus( const G4FieldTrack& StartFT,
const G4ThreeVector CurrentUnitVelocity = CurrentFT.GetMomentumDir();
G4double step_len = CurrentFT.GetCurveLength() - StartFT.GetCurveLength();
G4int oldprc; // cout/cerr precision settings
if( ((stepNo == 0) && (verboseLevel <3)) || (verboseLevel >= 3) )
{
static G4int noPrecision= 4;
G4cout.precision(noPrecision);
// G4cout.setf(ios_base::fixed,ios_base::floatfield);
oldprc = G4cout.precision(4);
G4cout << std::setw( 6) << " "
<< std::setw( 25) << " Current Position and Direction" << " "
<< G4endl;
@@ -99,15 +98,12 @@ G4VIntersectionLocator::printStatus( const G4FieldTrack& StartFT,
<< std::setw( 7) << " N_x " << " "
<< std::setw( 7) << " N_y " << " "
<< std::setw( 7) << " N_z " << " " ;
// << G4endl;
G4cout // << " >>> "
<< std::setw( 7) << " Delta|N|" << " "
// << std::setw( 7) << " Delta(N_z) " << " "
G4cout << std::setw( 7) << " Delta|N|" << " "
<< std::setw( 9) << "StepLen" << " "
<< std::setw(12) << "StartSafety" << " "
<< std::setw( 9) << "PhsStep" << " ";
G4cout << G4endl;
G4cout.precision(oldprc);
}
if((stepNo == 0) && (verboseLevel <=3))
{
@@ -125,9 +121,8 @@ G4VIntersectionLocator::printStatus( const G4FieldTrack& StartFT,
{
G4cout << std::setw( 5) << "Start" ;
}
G4cout.precision(8);
oldprc = G4cout.precision(8);
G4cout << std::setw(10) << CurrentFT.GetCurveLength() << " ";
G4cout.precision(8);
G4cout << std::setw(10) << CurrentPosition.x() << " "
<< std::setw(10) << CurrentPosition.y() << " "
<< std::setw(10) << CurrentPosition.z() << " ";
@@ -135,38 +130,34 @@ G4VIntersectionLocator::printStatus( const G4FieldTrack& StartFT,
G4cout << std::setw( 7) << CurrentUnitVelocity.x() << " "
<< std::setw( 7) << CurrentUnitVelocity.y() << " "
<< std::setw( 7) << CurrentUnitVelocity.z() << " ";
// G4cout << G4endl;
// G4cout << " >>> " ;
G4cout.precision(3);
G4cout << std::setw( 7)
<< CurrentFT.GetMomentum().mag()- StartFT.GetMomentum().mag()
<< " ";
// << std::setw( 7)
// << CurrentUnitVelocity.z() - InitialUnitVelocity.z() << " ";
G4cout << std::setw( 9) << step_len << " ";
G4cout << std::setw(12) << safety << " ";
if( requestStep != -1.0 )
{
G4cout << std::setw( 9) << requestStep << " ";
}
else
{
G4cout << std::setw( 9) << "Init/NotKnown" << " ";
}
G4cout << G4endl;
}
else // if( verboseLevel > 3 )
{
// Multi-line output
G4cout.precision(3);
G4cout << std::setw( 7)
<< CurrentFT.GetMomentum().mag()- StartFT.GetMomentum().mag()
<< " ";
G4cout << std::setw( 9) << step_len << " ";
G4cout << std::setw(12) << safety << " ";
if( requestStep != -1.0 )
{
G4cout << std::setw( 9) << requestStep << " ";
}
else
{
G4cout << std::setw( 9) << "Init/NotKnown" << " ";
}
G4cout << G4endl;
G4cout.precision(oldprc);
}
else // if( verboseLevel > 3 )
{
// Multi-line output
G4cout << "Step taken was " << step_len
<< " out of PhysicalStep= " << requestStep << G4endl;
G4cout << "Final safety is: " << safety << G4endl;
G4cout << "Chord length = " << (CurrentPosition-StartPosition).mag()
<< G4endl;
G4cout << G4endl;
}
G4cout << "Step taken was " << step_len
<< " out of PhysicalStep= " << requestStep << G4endl;
G4cout << "Final safety is: " << safety << G4endl;
G4cout << "Chord length = " << (CurrentPosition-StartPosition).mag()
<< G4endl;
G4cout << G4endl;
}
}
///////////////////////////////////////////////////////////////////////////
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4VoxelNavigation.cc,v 1.9 2008/11/14 18:26:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4VoxelNavigation.cc,v 1.13 2010/11/04 18:18:00 japost Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// class G4VoxelNavigation Implementation
@@ -36,23 +36,23 @@
#include "G4VoxelNavigation.hh"
#include "G4GeometryTolerance.hh"
#include "G4VoxelSafety.hh"
// ********************************************************************
// Constructor
// ********************************************************************
//
G4VoxelNavigation::G4VoxelNavigation()
: fVoxelDepth(-1),
: fBList(), fVoxelDepth(-1),
fVoxelAxisStack(kNavigatorVoxelStackMax,kXAxis),
fVoxelNoSlicesStack(kNavigatorVoxelStackMax,0),
fVoxelSliceWidthStack(kNavigatorVoxelStackMax,0.),
fVoxelNodeNoStack(kNavigatorVoxelStackMax,0),
fVoxelHeaderStack(kNavigatorVoxelStackMax,(G4SmartVoxelHeader*)0),
fVoxelNode(0),
fCheck(false),
fVerbose(0)
fVoxelNode(0), fpVoxelSafety(0), fCheck(false), fBestSafety(false)
{
kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
fLogger = new G4NavigationLogger("G4VoxelNavigation");
fpVoxelSafety = new G4VoxelSafety ();
}
// ********************************************************************
@@ -61,9 +61,8 @@ G4VoxelNavigation::G4VoxelNavigation()
//
G4VoxelNavigation::~G4VoxelNavigation()
{
#ifdef G4DEBUG_NAVIGATION
G4cout << "G4VoxelNavigation::~G4VoxelNavigation() called." << G4endl;
#endif
delete fpVoxelSafety;
delete fLogger;
}
// ********************************************************************
@@ -109,47 +108,7 @@ G4VoxelNavigation::ComputeStep( const G4ThreeVector& localPoint,
#ifdef G4VERBOSE
if ( fCheck )
{
if(fVerbose == 1 )
{
G4cout << "*** G4VoxelNavigation::ComputeStep(): ***" << G4endl
<< " Invoked DistanceToOut(p) for mother solid: "
<< motherSolid->GetName()
<< ". Solid replied: " << motherSafety << G4endl
<< " For local point p: " << localPoint
<< ", to be considered as 'mother safety'." << G4endl;
}
if( motherSafety < 0.0 )
{
G4cout << "ERROR - G4VoxelNavigation::ComputeStep()" << G4endl
<< " Current solid " << motherSolid->GetName()
<< " gave negative safety: " << motherSafety << G4endl
<< " for the current (local) point " << localPoint
<< G4endl;
motherSolid->DumpInfo();
G4Exception("G4VoxelNavigation::ComputeStep()",
"NegativeSafetyMotherVol", FatalException,
"Negative Safety In Voxel Navigation !" );
}
if( motherSolid->Inside(localPoint)==kOutside )
{
G4cout << "WARNING - G4VoxelNavigation::ComputeStep()" << G4endl
<< " Point " << localPoint
<< " is outside current volume " << motherPhysical->GetName()
<< G4endl;
G4double estDistToSolid= motherSolid->DistanceToIn(localPoint);
G4cout << " Estimated isotropic distance to solid (distToIn)= "
<< estDistToSolid << G4endl;
if( estDistToSolid > 100.0 * kCarTolerance )
{
motherSolid->DumpInfo();
G4Exception("G4VoxelNavigation::ComputeStep()",
"FarOutsideCurrentVolume", FatalException,
"Point is far outside Current Volume !");
}
else
G4Exception("G4VoxelNavigation::ComputeStep()", "OutsideCurrentVolume",
JustWarning, "Point is a little outside Current Volume.");
}
fLogger->PreComputeStepLog (motherPhysical, motherSafety, localPoint);
}
#endif
@@ -203,14 +162,9 @@ G4VoxelNavigation::ComputeStep( const G4ThreeVector& localPoint,
const G4double sampleSafety =
sampleSolid->DistanceToIn(samplePoint);
#ifdef G4VERBOSE
if(( fCheck ) && ( fVerbose == 1 ))
if( fCheck )
{
G4cout << "*** G4VoxelNavigation::ComputeStep(): ***" << G4endl
<< " Invoked DistanceToIn(p) for daughter solid: "
<< sampleSolid->GetName()
<< ". Solid replied: " << sampleSafety << G4endl
<< " For local point p: " << samplePoint
<< ", to be considered as 'daughter safety'." << G4endl;
fLogger->PrintDaughterLog(sampleSolid,samplePoint,sampleSafety,0);
}
#endif
if ( sampleSafety<ourSafety )
@@ -223,15 +177,10 @@ G4VoxelNavigation::ComputeStep( const G4ThreeVector& localPoint,
G4double sampleStep =
sampleSolid->DistanceToIn(samplePoint, sampleDirection);
#ifdef G4VERBOSE
if(( fCheck ) && ( fVerbose == 1 ))
if( fCheck )
{
G4cout << "*** G4VoxelNavigation::ComputeStep(): ***" << G4endl
<< " Invoked DistanceToIn(p,v) for daughter solid: "
<< sampleSolid->GetName()
<< ". Solid replied: " << sampleStep << G4endl
<< " For local point p: " << samplePoint << G4endl
<< " Direction v: " << sampleDirection
<< ", to be considered as 'daughter step'." << G4endl;
fLogger->PrintDaughterLog(sampleSolid, samplePoint,
sampleSafety, sampleStep);
}
#endif
if ( sampleStep<=ourStep )
@@ -246,98 +195,10 @@ G4VoxelNavigation::ComputeStep( const G4ThreeVector& localPoint,
// This check could eventually be made only for successful
// candidate.
if ( ( fCheck ) && ( sampleStep < kInfinity ) )
if ( fCheck )
{
G4ThreeVector intersectionPoint;
intersectionPoint= samplePoint + sampleStep * sampleDirection;
EInside insideIntPt= sampleSolid->Inside(intersectionPoint);
G4String solidResponse = "-kInside-";
if (insideIntPt == kOutside)
{ solidResponse = "-kOutside-"; }
else if (insideIntPt == kSurface)
{ solidResponse = "-kSurface-"; }
if( fVerbose == 1 )
{
G4cout << "*** G4VoxelNavigation::ComputeStep(): ***"<<G4endl
<< " Invoked Inside() for solid: "
<< sampleSolid->GetName()
<< ". Solid replied: " << solidResponse << G4endl
<< " For point p: " << intersectionPoint
<< ", considered as 'intersection' point." << G4endl;
}
G4double safetyIn= -1, safetyOut= -1; // Set to invalid values
G4double newDistIn= -1, newDistOut= -1;
if( insideIntPt != kInside )
{
safetyIn= sampleSolid->DistanceToIn(intersectionPoint);
newDistIn= sampleSolid->DistanceToIn(intersectionPoint,
sampleDirection);
}
if( insideIntPt != kOutside )
{
safetyOut= sampleSolid->DistanceToOut(intersectionPoint);
newDistOut= sampleSolid->DistanceToOut(intersectionPoint,
sampleDirection);
}
if( insideIntPt != kSurface )
{
G4int oldcoutPrec = G4cout.precision(16);
G4cout << "WARNING - G4VoxelNavigation::ComputeStep()"
<< G4endl
<< " Inaccurate solid DistanceToIn"
<< " for solid " << sampleSolid->GetName() << G4endl;
G4cout << " Solid gave DistanceToIn = "
<< sampleStep << " yet returns " << solidResponse
<< " for this point !" << G4endl;
G4cout << " Point = " << intersectionPoint << G4endl;
G4cout << " Safety values: " << G4endl;
if ( insideIntPt != kInside )
{
G4cout << " DistanceToIn(p) = " << safetyIn
<< G4endl;
}
if ( insideIntPt != kOutside )
{
G4cout << " DistanceToOut(p) = " << safetyOut
<< G4endl;
}
G4Exception("G4VoxelNavigation::ComputeStep()",
"InaccurateDistanceToIn", JustWarning,
"Conflicting response from Solid.");
G4cout.precision(oldcoutPrec);
}
else
{
// If it is on the surface, *ensure* that either DistanceToIn
// or DistanceToOut returns a finite value ( >= Tolerance).
//
if( std::max( newDistIn, newDistOut ) <= kCarTolerance )
{
G4cout << "ERROR - G4VoxelNavigation::ComputeStep()"
<< G4endl
<< " Identified point for which the solid "
<< sampleSolid->GetName() << G4endl
<< " has MAJOR problem: " << G4endl
<< " --> Both DistanceToIn(p,v) and DistanceToOut(p,v) "
<< "return Zero, an equivalent value or negative value."
<< G4endl;
G4cout << " Solid: " << sampleSolid << G4endl;
G4cout << " Point p= " << intersectionPoint << G4endl;
G4cout << " Direction v= " << sampleDirection << G4endl;
G4cout << " DistanceToIn(p,v) = " << newDistIn
<< G4endl;
G4cout << " DistanceToOut(p,v,..) = " << newDistOut
<< G4endl;
G4cout << " Safety values: " << G4endl;
G4cout << " DistanceToIn(p) = " << safetyIn
<< G4endl;
G4cout << " DistanceToOut(p) = " << safetyOut
<< G4endl;
G4Exception("G4VoxelNavigation::ComputeStep()",
"DistanceToInAndOutAreZero", FatalException,
"Zero from both Solid DistanceIn and Out(p,v).");
}
}
fLogger->AlongComputeStepLog (sampleSolid, samplePoint,
sampleDirection, localDirection, sampleSafety, sampleStep);
}
#endif
}
@@ -377,33 +238,8 @@ G4VoxelNavigation::ComputeStep( const G4ThreeVector& localPoint,
#ifdef G4VERBOSE
if ( fCheck )
{
if(fVerbose == 1)
{
G4cout << "*** G4VoxelNavigation::ComputeStep(): ***" << G4endl
<< " Invoked DistanceToOut(p,v,...) for mother solid: "
<< motherSolid->GetName()
<< ". Solid replied: " << motherStep << G4endl
<< " For local point p: " << localPoint << G4endl
<< " Direction v: " << localDirection
<< ", to be considered as 'mother step'." << G4endl;
}
if( ( motherStep < 0.0 ) || ( motherStep >= kInfinity) )
{
G4int oldPrOut= G4cout.precision(16);
G4int oldPrErr= G4cerr.precision(16);
G4cerr << "ERROR - G4VoxelNavigation::ComputeStep()" << G4endl
<< " Problem in Navigation" << G4endl
<< " Point (local coordinates): "
<< localPoint << G4endl
<< " Local Direction: " << localDirection << G4endl
<< " Solid: " << motherSolid->GetName() << G4endl;
motherSolid->DumpInfo();
G4Exception("G4VoxelNavigation::ComputeStep()",
"PointOutsideCurrentVolume", FatalException,
"Current point is outside the current solid !");
G4cout.precision(oldPrOut);
G4cerr.precision(oldPrErr);
}
fLogger->PostComputeStepLog(motherSolid, localPoint, localDirection,
motherStep, motherSafety);
}
#endif
if ( motherStep<=ourStep )
@@ -479,15 +315,15 @@ G4VoxelNavigation::ComputeVoxelSafety(const G4ThreeVector& localPoint) const
voxelSafety += minCurCommonDelta;
}
else if (maxCurNodeNoDelta < minCurNodeNoDelta)
{
voxelSafety = maxCurNodeNoDelta*curNodeWidth;
voxelSafety += maxCurCommonDelta;
}
else // (maxCurNodeNoDelta == minCurNodeNoDelta)
{
voxelSafety = minCurNodeNoDelta*curNodeWidth;
voxelSafety += std::min(minCurCommonDelta,maxCurCommonDelta);
}
{
voxelSafety = maxCurNodeNoDelta*curNodeWidth;
voxelSafety += maxCurCommonDelta;
}
else // (maxCurNodeNoDelta == minCurNodeNoDelta)
{
voxelSafety = minCurNodeNoDelta*curNodeWidth;
voxelSafety += std::min(minCurCommonDelta,maxCurCommonDelta);
}
// Compute isotropic safety to boundaries of previous levels
// [NOT to collected boundaries]
@@ -551,6 +387,8 @@ G4VoxelNavigation::LocateNextVoxel(const G4ThreeVector& localPoint,
G4bool isNewVoxel=false;
G4double currentDistance = currentStep;
static const G4double sigma = 0.5*G4GeometryTolerance::GetInstance()
->GetSurfaceTolerance();
// Determine if end of Step within current voxel
//
@@ -566,10 +404,10 @@ G4VoxelNavigation::LocateNextVoxel(const G4ThreeVector& localPoint,
workCoord = targetPoint(workHeaderAxis);
minVal = workMinExtent+workNodeNo*workNodeWidth;
if ( minVal<=workCoord+kCarTolerance*0.5 )
if ( minVal<=workCoord+sigma )
{
maxVal = minVal+workNodeWidth;
if ( maxVal<=workCoord-kCarTolerance*0.5 )
if ( maxVal<=workCoord-sigma )
{
// Must consider next voxel
//
@@ -606,11 +444,11 @@ G4VoxelNavigation::LocateNextVoxel(const G4ThreeVector& localPoint,
workCoord = targetPoint(workHeaderAxis);
minVal = workMinExtent+fVoxelNode->GetMinEquivalentSliceNo()*workNodeWidth;
if ( minVal<=workCoord+kCarTolerance*0.5 )
if ( minVal<=workCoord+sigma )
{
maxVal = workMinExtent+(fVoxelNode->GetMaxEquivalentSliceNo()+1)
*workNodeWidth;
if ( maxVal<=workCoord-kCarTolerance*0.5 )
if ( maxVal<=workCoord-sigma )
{
newNodeNo = fVoxelNode->GetMaxEquivalentSliceNo()+1;
newHeader = workHeader;
@@ -709,7 +547,7 @@ G4VoxelNavigation::LocateNextVoxel(const G4ThreeVector& localPoint,
G4double
G4VoxelNavigation::ComputeSafety(const G4ThreeVector& localPoint,
const G4NavigationHistory& history,
const G4double )
const G4double maxLength)
{
G4VPhysicalVolume *motherPhysical, *samplePhysical;
G4LogicalVolume *motherLogical;
@@ -724,6 +562,11 @@ G4VoxelNavigation::ComputeSafety(const G4ThreeVector& localPoint,
motherLogical = motherPhysical->GetLogicalVolume();
motherSolid = motherLogical->GetSolid();
if( fBestSafety )
{
return fpVoxelSafety->ComputeSafety( localPoint,*motherPhysical,maxLength );
}
//
// Compute mother safety
//
@@ -732,14 +575,9 @@ G4VoxelNavigation::ComputeSafety(const G4ThreeVector& localPoint,
ourSafety = motherSafety; // Working isotropic safety
#ifdef G4VERBOSE
if(( fCheck ) && ( fVerbose == 1 ))
if( fCheck )
{
G4cout << "*** G4VoxelNavigation::ComputeSafety(): ***" << G4endl
<< " Invoked DistanceToOut(p) for mother solid: "
<< motherSolid->GetName()
<< ". Solid replied: " << motherSafety << G4endl
<< " For local point p: " << localPoint
<< ", to be considered as 'mother safety'." << G4endl;
fLogger->ComputeSafetyLog (motherSolid, localPoint, motherSafety, true);
}
#endif
//
@@ -771,14 +609,9 @@ G4VoxelNavigation::ComputeSafety(const G4ThreeVector& localPoint,
ourSafety = sampleSafety;
}
#ifdef G4VERBOSE
if(( fCheck ) && ( fVerbose == 1 ))
if( fCheck )
{
G4cout << "*** G4VoxelNavigation::ComputeSafety(): ***" << G4endl
<< " Invoked DistanceToIn(p) for daughter solid: "
<< sampleSolid->GetName()
<< ". Solid replied: " << sampleSafety << G4endl
<< " For local point p: " << samplePoint
<< ", to be considered as 'daughter safety'." << G4endl;
fLogger->ComputeSafetyLog (sampleSolid,samplePoint,sampleSafety,false);
}
#endif
}
@@ -789,3 +622,13 @@ G4VoxelNavigation::ComputeSafety(const G4ThreeVector& localPoint,
}
return ourSafety;
}
// ********************************************************************
// SetVerboseLevel
// ********************************************************************
//
void G4VoxelNavigation::SetVerboseLevel(G4int level)
{
if( fLogger ) fLogger->SetVerboseLevel(level);
if( fpVoxelSafety) fpVoxelSafety->SetVerboseLevel( level );
}
@@ -0,0 +1,367 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4VoxelSafety.cc,v 1.9 2010/11/11 16:15:00 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// Author: John Apostolakis
// First version: 31 May 2010
//
#include "G4VoxelSafety.hh"
#include "G4GeometryTolerance.hh"
#include "G4SmartVoxelProxy.hh"
#include "G4SmartVoxelNode.hh"
#include "G4SmartVoxelHeader.hh"
// State
// - values used during computation of Safety
//
// Constructor
// - copied from G4VoxelNavigation (1st version)
G4VoxelSafety::G4VoxelSafety()
: fBlockList(),
fpMotherLogical(0),
fVoxelDepth(-1),
fVoxelAxisStack(kNavigatorVoxelStackMax,kXAxis),
fVoxelNoSlicesStack(kNavigatorVoxelStackMax,0),
fVoxelSliceWidthStack(kNavigatorVoxelStackMax,0.),
fVoxelNodeNoStack(kNavigatorVoxelStackMax,0),
fVoxelHeaderStack(kNavigatorVoxelStackMax,(G4SmartVoxelHeader*)0),
fVoxelNode(0),
fCheck(false),
fVerbose(0)
{
kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
}
G4VoxelSafety::~G4VoxelSafety()
{
}
// ********************************************************************
// ComputeSafety
//
// Calculates the isotropic distance to the nearest boundary from the
// specified point in the local coordinate system.
// The localpoint utilised must be within the current volume.
// ********************************************************************
//
G4double
G4VoxelSafety::ComputeSafety(const G4ThreeVector& localPoint,
const G4VPhysicalVolume& currentPhysical,
G4double ) // maxLength)
{
// G4VPhysicalVolume *samplePhysical;
G4LogicalVolume *motherLogical;
G4VSolid *motherSolid;
G4SmartVoxelHeader *motherVoxelHeader;
G4double motherSafety, ourSafety;
G4int localNoDaughters; // , sampleNo;
// G4SmartVoxelNode *curVoxelNode;
// G4int curNoVolumes, contentNo;
G4double daughterSafety;
motherLogical = currentPhysical.GetLogicalVolume();
fpMotherLogical= motherLogical; // For use by the other methods
motherSolid = motherLogical->GetSolid();
motherVoxelHeader= motherLogical->GetVoxelHeader();
#ifdef G4VERBOSE
if( fVerbose > 0 ){
G4cout << "*** G4VoxelSafety::ComputeSafety(): ***" << G4endl;
}
#endif
// Check that point is inside mother volume
EInside insideMother= motherSolid->Inside(localPoint);
if( insideMother != kInside ) {
if( insideMother == kOutside ) {
G4cerr << " G4VoxelSafety> Location for safety is Outside current volume. " << G4endl;
G4cerr << " The approximate distance to the solid (safety from outside ) is "
<< motherSolid->DistanceToIn( localPoint ) << G4endl;
G4Exception("G4VoxelSafety::ComputeSafety()",
"IllegalLocationForSafetyCall", FatalException,
"Method called for location outside current Volume.");
}
return 0.0;
}
// First limit: mother safety - distance to outer boundaries
motherSafety = motherSolid->DistanceToOut(localPoint);
ourSafety = motherSafety; // Working isotropic safety
#ifdef G4VERBOSE
if(( fCheck ) && ( fVerbose == 1 ))
{
G4cout << "*** G4VoxelSafety::ComputeSafety(): ***" << G4endl
<< " Invoked DistanceToOut(p) for mother solid: "
<< motherSolid->GetName()
<< ". Solid replied: " << motherSafety << G4endl
<< " For local point p: " << localPoint
<< ", to be considered as 'mother safety'." << G4endl;
}
#endif
localNoDaughters = motherLogical->GetNoDaughters();
fBlockList.Enlarge(localNoDaughters);
fBlockList.Reset();
fVoxelDepth = -1; // Resets the depth -- must be done for next method
daughterSafety= SafetyForVoxelHeader( motherVoxelHeader, localPoint );
ourSafety= std::min( motherSafety, daughterSafety );
return ourSafety;
}
// Calculate the safety for volumes included in current Voxel Node
//
G4double
G4VoxelSafety::
SafetyForVoxelNode( G4SmartVoxelNode *curVoxelNode,
const G4ThreeVector& localPoint )
{
G4double ourSafety= DBL_MAX;
G4int curNoVolumes, contentNo, sampleNo;
G4VPhysicalVolume *samplePhysical;
G4double sampleSafety=0.0;
G4ThreeVector samplePoint;
G4VSolid* ptrSolid=0;
curNoVolumes = curVoxelNode->GetNoContained();
for ( contentNo=curNoVolumes-1; contentNo>=0; contentNo-- )
{
sampleNo = curVoxelNode->GetVolume(contentNo);
if ( !fBlockList.IsBlocked(sampleNo) )
{
fBlockList.BlockVolume(sampleNo);
samplePhysical = fpMotherLogical->GetDaughter(sampleNo);
G4AffineTransform sampleTf(samplePhysical->GetRotation(),
samplePhysical->GetTranslation());
sampleTf.Invert();
samplePoint = sampleTf.TransformPoint(localPoint);
ptrSolid = samplePhysical->GetLogicalVolume()->GetSolid();
sampleSafety = ptrSolid->DistanceToIn(samplePoint);
ourSafety = std::min( sampleSafety, ourSafety );
#ifdef G4VERBOSE
if(( fCheck ) && ( fVerbose == 1 ))
{
// ReportSolidSafetyToIn( MethodName, solid, value, point );
G4cout << "*** G4VoxelSafety::SafetyForVoxelNode(): ***" << G4endl
<< " Invoked DistanceToIn(p) for daughter solid: "
<< ptrSolid->GetName()
<< ". Solid replied: " << sampleSafety << G4endl
<< " For local point p: " << samplePoint
<< ", to be considered as 'daughter safety'." << G4endl;
}
#endif
}
} // end for contentNo
return ourSafety;
}
//
// Pseudo-code for Compute Safety
//
// for each (potential) dimension of depth
// iterate through VoxelProxies (Header, Node)
// until distanceToVoxel > estimatedSafety
//
// Better:
// iterate through/down the three of VoxelProxies
// while distanceToVoxel <= estimatedSafety
// Examine one Nodes for which this condition holds.
// (version 0 can examine all nodes)
// How to step through voxels ?? Thu 29 April 2010 @ 17:00
// ********************************************************************
// SafetyForVoxelHeader method
// - which cycles through levels of headers to process each node level
// - Obtained by modifying VoxelLocate (to cycle through Node Headers)
// *********************************************************************
//
G4double
G4VoxelSafety::SafetyForVoxelHeader( G4SmartVoxelHeader* pHeader,
const G4ThreeVector& localPoint )
{
const G4SmartVoxelHeader *targetVoxelHeader=pHeader;
G4SmartVoxelNode *targetVoxelNode=0;
G4SmartVoxelProxy *sampleProxy;
EAxis targetHeaderAxis;
G4double targetHeaderMin, targetHeaderNodeWidth;
G4int targetHeaderNoSlices;
G4int targetNodeNo; // , pointNodeNo;
// G4int minCurNodeNoDelta, maxCurNodeNoDelta;
G4double minSafety= DBL_MAX;
fVoxelDepth++;
// fVoxelDepth set by ComputeSafety or previous level call
targetHeaderAxis = targetVoxelHeader->GetAxis();
targetHeaderNoSlices = targetVoxelHeader->GetNoSlices();
targetHeaderMin = targetVoxelHeader->GetMinExtent();
targetHeaderNodeWidth = (targetVoxelHeader->GetMaxExtent()-targetHeaderMin)
/ targetHeaderNoSlices;
const G4int pointNodeNo = G4int( (localPoint(targetHeaderAxis)-targetHeaderMin)
/ targetHeaderNodeWidth);
// Ensure that it is between 0 and targetHeader->GetMaxExtent() - 1
G4cout << " Calculated pointNodeNo= " << pointNodeNo
<< " from position= " << localPoint(targetHeaderAxis)
<< " min= " << targetHeaderMin
<< " max= " << targetVoxelHeader->GetMaxExtent()
<< " width= " << targetHeaderNodeWidth
<< " no-slices= " << targetHeaderNoSlices
<< " axis= " << targetHeaderAxis
<< G4endl;
// Stack info for stepping
//
fVoxelAxisStack[fVoxelDepth] = targetHeaderAxis;
fVoxelNoSlicesStack[fVoxelDepth] = targetHeaderNoSlices;
fVoxelSliceWidthStack[fVoxelDepth] = targetHeaderNodeWidth;
fVoxelHeaderStack[fVoxelDepth] = pHeader;
#ifdef G4VERBOSE
if( fVerbose > 2 ){
G4cout << G4endl;
G4cout << "**** G4VoxelSafety::SafetyForVoxelHeader " << G4endl;
G4cout << " Depth = " << fVoxelDepth ; // << G4endl;
G4cout << " Number of Slices = " << targetHeaderNoSlices ; // << G4endl;
G4cout << " Header (address) = " << targetVoxelHeader << G4endl;
}
#endif
// G4int numSlicesCheck= targetHeaderNoSlices;
// G4cout << "---> Current Voxel Header has " << *targetVoxelHeader << G4endl;
// targetVoxelHeader->GetMaxEquivalentSliceNo()+1;
// targetVoxelHeader->GetMinEquivalentSliceNo()-1;
G4int nextUp= pointNodeNo+1;
G4int nextDown= pointNodeNo-1;
// Ignore equivalents for now
G4int nextNode= pointNodeNo;
for( targetNodeNo= pointNodeNo;
// (targetNodeNo<targetHeaderNoSlices) &&
(targetNodeNo>=0);
targetNodeNo= nextNode
)
{
G4double nodeSafety= DBL_MAX, levelSafety= DBL_MAX;
fVoxelNodeNoStack[fVoxelDepth] = targetNodeNo;
sampleProxy = targetVoxelHeader->GetSlice(targetNodeNo);
G4cout << " -Checking node " << targetNodeNo
<< " is proxy with address " << sampleProxy; // << G4endl;
if ( sampleProxy->IsNode() )
{
targetVoxelNode = sampleProxy->GetNode();
G4cout << " -- It is a Node " << G4endl;
// Deal with the node here [ i.e. the last level ]
nodeSafety= SafetyForVoxelNode( targetVoxelNode, localPoint);
// if( targetHeaderNoSlices != numSlicesCheck )
// G4cerr << "Number of slices changed - to " << targetHeaderNoSlices << G4endl;
minSafety= std::min( minSafety, nodeSafety );
}
else
{
G4SmartVoxelHeader *pNewVoxelHeader = sampleProxy->GetHeader();
// fVoxelDepth++;
G4cout << " -- It is a Header " << G4endl;
G4cout << " Recurse to deal with next level, fVoxelDepth= "
<< fVoxelDepth+1 << G4endl;
// Recurse to deal with lower levels
levelSafety= SafetyForVoxelHeader( pNewVoxelHeader, localPoint);
// fVoxelDepth--;
// G4cout << " Returned from SafetyForVoxelHeader. Depth= "
// << fVoxelDepth << G4endl;
//--G4cout << " Decreased fVoxelDepth to " << fVoxelDepth << G4endl;
//--G4cout << " Header (address)= " << targetVoxelHeader << G4endl;
G4cout << " Level safety = " << levelSafety << G4endl;
minSafety= std::min( minSafety, levelSafety );
}
// Find next closest Voxel
// - first try: by simple subtraction
// - later: using distance (TODO - tbc)
G4cout << " Next: up " << nextUp << " d= " << nextUp - pointNodeNo
<< " down " << nextDown << " d= " << pointNodeNo - nextDown
<< " cond " << ( nextUp < targetHeaderNoSlices )
<< " pointNodeNo= " << pointNodeNo
<< G4endl;
if( ((nextUp - pointNodeNo) < (pointNodeNo - nextDown))
&& (nextUp < targetHeaderNoSlices) )
{
nextNode=nextUp;
++nextUp;
G4cout << " Chose Up: next= " << nextNode << " new= " << nextUp << G4endl;
}else{
nextNode=nextDown;
--nextDown;
G4cout << " Chose Down: next= " << nextNode << " new= " << nextDown << G4endl;
}
}
#ifdef G4VERBOSE
if( fVerbose > 0 ) {
G4cout << " Ended for targetNodeNo -- checked "
<< targetHeaderNoSlices << " slices" << G4endl;
G4cout << " ===== Returning from SafetyForVoxelHeader "
<< " Depth= " << fVoxelDepth << G4endl
<< G4endl;
}
#endif
// Go back one level
fVoxelDepth--;
return minSafety;
}