Import Geant4 9.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 15:37:50 +02:00
parent a8e9364cea
commit 96c8bcd0af
6923 changed files with 198390 additions and 41849 deletions
@@ -24,7 +24,7 @@
// ********************************************************************
//
// $Id: G4AuxiliaryNavServices.cc,v 1.3 2006/06/29 18:36:32 gunter Exp $
// GEANT4 tag $Name: geant4-09-00 $
// GEANT4 tag $Name: geant4-09-01 $
//
// --------------------------------------------------------------------
@@ -25,7 +25,7 @@
//
//
// $Id: G4DrawVoxels.cc,v 1.4 2006/06/29 18:36:34 gunter Exp $
// GEANT4 tag $Name: geant4-09-00 $
// GEANT4 tag $Name: geant4-09-01 $
//
//
// class G4DrawVoxels
@@ -25,7 +25,7 @@
//
//
// $Id: G4ErrorPropagationNavigator.cc,v 1.1 2007/05/16 12:49:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-00 $
// GEANT4 tag $Name: geant4-09-01 $
//
//
// --------------------------------------------------------------------
@@ -25,7 +25,7 @@
//
//
// $Id: G4GeomTestErrorList.cc,v 1.3 2006/06/29 18:36:36 gunter Exp $
// GEANT4 tag $Name: geant4-09-00 $
// GEANT4 tag $Name: geant4-09-01 $
//
// --------------------------------------------------------------------
// GEANT 4 class source file
@@ -25,7 +25,7 @@
//
//
// $Id: G4GeomTestOverlapList.cc,v 1.3 2006/06/29 18:36:39 gunter Exp $
// GEANT4 tag $Name: geant4-09-00 $
// GEANT4 tag $Name: geant4-09-01 $
//
// --------------------------------------------------------------------
// GEANT 4 class source file
@@ -25,7 +25,7 @@
//
//
// $Id: G4GeomTestOvershootList.cc,v 1.3 2006/06/29 18:36:41 gunter Exp $
// GEANT4 tag $Name: geant4-09-00 $
// GEANT4 tag $Name: geant4-09-01 $
//
// --------------------------------------------------------------------
// GEANT 4 class source file
@@ -25,7 +25,7 @@
//
//
// $Id: G4GeomTestPoint.cc,v 1.3 2006/06/29 18:36:44 gunter Exp $
// GEANT4 tag $Name: geant4-09-00 $
// GEANT4 tag $Name: geant4-09-01 $
//
// --------------------------------------------------------------------
// GEANT 4 class source file
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4GeomTestSegment.cc,v 1.10 2007/05/18 07:30:47 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-00 $
// $Id: G4GeomTestSegment.cc,v 1.11 2007/11/16 09:39:14 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
// --------------------------------------------------------------------
// GEANT 4 class source file
@@ -366,7 +366,6 @@ void G4GeomTestSegment::FindSomePoints( G4GeomTestLogger *logger,
//
// Find next intersection
//
G4double dist;
if (entering) {
dist = solid->DistanceToOut(p,vSearch);
//G4cout<<"if entering distToOut="<<dist<<G4endl;
@@ -25,7 +25,7 @@
//
//
// $Id: G4GeomTestStreamLogger.cc,v 1.3 2006/06/29 18:36:49 gunter Exp $
// GEANT4 tag $Name: geant4-09-00 $
// GEANT4 tag $Name: geant4-09-01 $
//
// --------------------------------------------------------------------
// GEANT 4 class source file
@@ -25,7 +25,7 @@
//
//
// $Id: G4GeomTestVolPoint.cc,v 1.3 2006/06/29 18:36:52 gunter Exp $
// GEANT4 tag $Name: geant4-09-00 $
// GEANT4 tag $Name: geant4-09-01 $
//
// --------------------------------------------------------------------
// GEANT 4 class source file
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4GeomTestVolume.cc,v 1.5 2006/06/29 18:36:55 gunter Exp $
// GEANT4 tag $Name: geant4-09-00 $
// $Id: G4GeomTestVolume.cc,v 1.6 2007/11/16 09:39:14 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
// --------------------------------------------------------------------
// GEANT 4 class source file
@@ -274,7 +274,8 @@ void G4GeomTestVolume::TestCylinder( G4int nPhi, G4int nZ, G4int nRho,
{
G4double cosPhi = std::cos(phi);
G4double sinPhi = std::sin(phi);
G4ThreeVector vPhi1(sinPhi,-cosPhi,0);
//
// Loop over rho
//
@@ -292,16 +293,14 @@ void G4GeomTestVolume::TestCylinder( G4int nPhi, G4int nZ, G4int nRho,
//
// Loop over z
//
G4ThreeVector v(sinPhi,-cosPhi,0);
G4double zScale = 1.0;
G4int iZ=nZ;
do
{
p.setZ( z0 + zScale*zHalfLength );
TestOneLine(p,v);
TestOneLine(p,vPhi1);
p.setZ( z0 - zScale*zHalfLength );
TestOneLine(p,v);
TestOneLine(p,vPhi1);
} while( zScale *= fracZ, --iZ );
}
} while( rho *= fracRho, --iRho );
@@ -310,7 +309,7 @@ void G4GeomTestVolume::TestCylinder( G4int nPhi, G4int nZ, G4int nRho,
// Loop over z
//
G4ThreeVector p(0,0,0);
G4ThreeVector v(cosPhi,sinPhi,0);
G4ThreeVector vPhi2(cosPhi,sinPhi,0);
G4double zScale = 1.0;
G4int iZ=nZ;
@@ -318,11 +317,11 @@ void G4GeomTestVolume::TestCylinder( G4int nPhi, G4int nZ, G4int nRho,
{
p.setZ( z0 + zScale*zHalfLength );
TestOneLine(p,v);
TestOneLine(p,vPhi2);
p.setZ( z0 - zScale*zHalfLength );
TestOneLine(p,v);
TestOneLine(p,vPhi2);
} while( zScale *= fracZ, --iZ );
} while( phi += deltaPhi, --iPhi );
@@ -499,8 +498,7 @@ void G4GeomTestVolume::TestOneLine( const G4ThreeVector &p,
//
// Add them to the list
//
G4int n = daughterSegment.GetNumberPoints();
G4int i;
n = daughterSegment.GetNumberPoints();
for(i=0;i<n;++i)
{
points.push_back( G4GeomTestVolPoint( daughterSegment.GetPoint(i),
@@ -25,7 +25,7 @@
//
//
// $Id: G4GeometryMessenger.cc,v 1.5 2006/06/29 18:36:57 gunter Exp $
// GEANT4 tag $Name: geant4-09-00 $
// GEANT4 tag $Name: geant4-09-01 $
//
// --------------------------------------------------------------------
// GEANT 4 class source file
+336 -357
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4MultiNavigator.cc,v 1.4 2006/11/14 15:41:56 japost Exp $
// $Id: G4MultiNavigator.cc,v 1.7 2007/11/02 13:48:43 japost Exp $
// GEANT4 tag $ Name: $
//
// class G4PathFinder Implementation
@@ -47,83 +47,73 @@ class G4FieldManager;
// ********************************************************************
//
G4MultiNavigator::G4MultiNavigator()
// : fpActiveNavigators()
: G4Navigator(),
fVerboseLevel(1)
: G4Navigator()
{
fNoActiveNavigators= 0;
G4ThreeVector Big3Vector( DBL_MAX, DBL_MAX, DBL_MAX );
fLastLocatedPosition= Big3Vector;
fSafetyLocation= Big3Vector;
fPreStepLocation= Big3Vector;
fNoActiveNavigators= 0;
G4ThreeVector Big3Vector( DBL_MAX, DBL_MAX, DBL_MAX );
fLastLocatedPosition = Big3Vector;
fSafetyLocation = Big3Vector;
fPreStepLocation = Big3Vector;
fMinSafety_PreStepPt= -1.0;
fMinSafety_atSafLocation= -1.0;
fMinSafety= -DBL_MAX;
fMinStep= -DBL_MAX;
// fNewTrack= false;
fMinSafety_PreStepPt= -1.0;
fMinSafety_atSafLocation= -1.0;
fMinSafety= -DBL_MAX;
fMinStep= -DBL_MAX;
G4int num;
for( num=0; num<= fMaxNav; ++num ) {
fpNavigator[num] = 0;
fLimitTruth[num] = false;
fLimitedStep[num] = kUndefLimited;
fCurrentStepSize[num] = -1.0;
fLocatedVolume[num] = 0;
}
// fpNavigator= new[MaxNav] (G4Navigator*);
for(register int num=0; num<= fMaxNav; ++num )
{
fpNavigator[num] = 0;
fLimitTruth[num] = false;
fLimitedStep[num] = kUndefLimited;
fCurrentStepSize[num] = -1.0;
fLocatedVolume[num] = 0;
}
pTransportManager= G4TransportationManager::GetTransportationManager();
pTransportManager= G4TransportationManager::GetTransportationManager();
// EndState = G4FieldTrack( G4ThreeVector(), G4ThreeVector(), 0., 0., 0., 0., 0.) );
// fRelocatedPoint(
// fLastStepNo= -1;
G4Navigator* massNav= pTransportManager->GetNavigatorForTracking();
if( massNav ) {
G4VPhysicalVolume* pWorld= massNav->GetWorldVolume();
if( pWorld ) {
this->SetWorldVolume( pWorld );
fLastMassWorld= pWorld;
}
}
G4Navigator* massNav= pTransportManager->GetNavigatorForTracking();
if( massNav )
{
G4VPhysicalVolume* pWorld= massNav->GetWorldVolume();
if( pWorld )
{
SetWorldVolume( pWorld );
fLastMassWorld = pWorld;
}
}
}
G4MultiNavigator::~G4MultiNavigator()
{
// delete[] fpNavigator;
}
// static G4int lastStepNo= -1;
// To find the field do not forget to call
// G4FieldManager* FindAndSetFieldManager(G4VPhysicalVolume* pCurrentPhysVol);
// which sets and returns the correct field manager (global or local), if any.
// Need to call it before PropagatorInField::ComputeStep is called.
G4double G4MultiNavigator::ComputeStep(const G4ThreeVector &pGlobalPoint,
const G4ThreeVector &pDirection,
const G4double proposedStepLength,
G4double &pNewSafety)
const G4ThreeVector &pDirection,
const G4double proposedStepLength,
G4double &pNewSafety)
{
G4double safety= 0.0, step=0.0;
G4double minSafety= DBL_MAX, minStep= DBL_MAX;
if( fVerboseLevel > 2 ){
#ifdef G4DEBUG_NAVIGATION
if( fVerbose > 2 )
{
G4cout << " G4MultiNavigator::ComputeStep : entered " << G4endl;
G4cout << " Input position= " << pGlobalPoint
<< " direction= " << pDirection << G4endl;
G4cout << " Requested step= " << proposedStepLength << G4endl;
}
#endif
std::vector<G4Navigator*>::iterator pNavigatorIter;
pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
G4ThreeVector initialPosition= pGlobalPoint;
G4ThreeVector initialPosition = pGlobalPoint;
G4ThreeVector initialDirection= pDirection;
G4int num=0;
for( num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num ) {
for( register int num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
{
safety= DBL_MAX;
step= (*pNavigatorIter)->ComputeStep( initialPosition,
@@ -132,191 +122,191 @@ G4double G4MultiNavigator::ComputeStep(const G4ThreeVector &pGlobalPoint,
safety );
if( safety < minSafety ){ minSafety = safety; }
if( step < minStep ) { minStep= step; }
// Later could reduce the proposed step to the latest minStep value ?
// if( step == kInfinity ) { step = proposedStepLength; }
fCurrentStepSize[num] = step;
fNewSafety[num]= safety;
// This is currently the safety from the last sub-step
if( fVerboseLevel > 2 ){
G4cout << "G4MultiNavigator::ComputeStep : Navigator [" << num << "] -- step size " << step << " safety= " << safety << G4endl;
#ifdef G4DEBUG_NAVIGATION
if( fVerbose > 2 )
{
G4cout << "G4MultiNavigator::ComputeStep : Navigator ["
<< num << "] -- step size " << step
<< " safety= " << safety << G4endl;
}
#endif
}
// fWasLimitedByGeometry= false; // <----- Could reset(?), but navigator leaves it as is
// Whether any geometry limited the step
// G4bool StepLimited = ( minStep <= proposedStepLength);
// G4cout << "G4MultiNavigator::ComputeStep - StepLimited is " << StepLimited
// << " given minStep= " << minStep << " and proposed Step= " << proposedStepLength << G4endl;
// Save safety value, related position
fPreStepLocation= initialPosition;
fMinSafety_PreStepPt= minSafety;
//
fPreStepLocation = initialPosition;
fMinSafety_PreStepPt = minSafety;
fMinStep = minStep;
fMinStep= minStep;
G4double trueMinStep= minStep;
if( fMinStep == kInfinity ){
trueMinStep = proposedStepLength; // Use this below for endpoint !!
if( fMinStep == kInfinity )
{
fTrueMinStep = proposedStepLength; // Use this below for endpoint !!
}
else
{
fTrueMinStep = minStep;
}
fTrueMinStep = trueMinStep;
if( fVerboseLevel > 1 ){
G4ThreeVector endPosition;
endPosition= initialPosition + trueMinStep * initialDirection ;
#ifdef G4DEBUG_NAVIGATION
if( fVerbose > 1 )
{
G4ThreeVector endPosition = initialPosition+fTrueMinStep*initialDirection;
int oldPrec= G4cout.precision(8);
G4int oldPrec = G4cout.precision(8);
G4cout << "G4MultiNavigator::ComputeStep : "
<< " initialPosition = " << initialPosition
<< " and endPosition = " << endPosition<< G4endl;
<< " and endPosition = " << endPosition << G4endl;
G4cout.precision( oldPrec );
}
#endif
pNewSafety= minSafety;
// Set the EndState
// fEndState= initialState;
// fEndState.SetPosition( endPosition );
// fEndState.SetProperTimeOfFlight( -1.000 ); // Not defined YET
// fEndState.SetMomentum( initialState.GetMomentum );
pNewSafety = minSafety;
this->WhichLimited();
if( fVerboseLevel > 2 ){
G4cout << " G4MultiNavigator::ComputeStep : exits returning " << minStep << G4endl;
#ifdef G4DEBUG_NAVIGATION
if( fVerbose > 2 )
{
G4cout << " G4MultiNavigator::ComputeStep : exits returning "
<< minStep << G4endl;
}
#endif
return minStep; // must return kInfinity if do not limit step
}
// ----------------------------------------------------------------------
G4double
G4MultiNavigator::ObtainFinalStep( G4int navigatorId,
G4double &pNewSafety, // for this geom
G4double &minStep,
ELimited &limitedStep)
G4MultiNavigator::ObtainFinalStep( G4int navigatorId,
G4double &pNewSafety, // for this geometry
G4double &minStep,
ELimited &limitedStep)
{
G4int navigatorNo=-1;
if( navigatorId <= fNoActiveNavigators ){
if( navigatorId <= fNoActiveNavigators )
{
navigatorNo= navigatorId;
} else {
G4cerr << " Navigator Id = " << navigatorId
<< " No Active = " << fNoActiveNavigators << " . " << G4endl;
G4Exception( "G4MultiNavigator::ObtainFinalStep : Bad Navigator Id" );
}
// if( ! ){ G4Exception( "G4MultiNavigator::ObtainFinalStep Called without call to ComputeStep"); }
else
{
G4cerr << "ERROR - G4MultiNavigator::ObtainFinalStep()"
<< " Navigator Id = " << navigatorId
<< " No Active = " << fNoActiveNavigators << " . "
<< G4endl;
G4Exception("G4MultiNavigator::ObtainFinalStep()", "InvalidSetup",
FatalException, "Bad Navigator Id" );
}
// Prepare the information to return
pNewSafety = fNewSafety[ navigatorNo ];
limitedStep = fLimitedStep[ navigatorNo ];
minStep= fMinStep;
// if( (minStep==kInfinity) || (fVerboseLevel > 1) ){
if( fVerboseLevel > 1 ){
// if( (minStep==kInfinity) || (fVerbose > 1) ){
#ifdef G4DEBUG_NAVIGATION
if( fVerbose > 1 ){
G4cout << " G4MultiNavigator::ComputeStep returns " << fCurrentStepSize[ navigatorNo ]
<< " for Navigator " << navigatorNo << " Limited step = " << limitedStep
<< " Safety(mm) = " << pNewSafety / mm << G4endl;
}
#endif
return fCurrentStepSize[ navigatorNo ];
}
// ----------------------------------------------------------------------
void
G4MultiNavigator::PrepareNewTrack( const G4ThreeVector position,
const G4ThreeVector direction )
void G4MultiNavigator::PrepareNewTrack( const G4ThreeVector position,
const G4ThreeVector direction )
{
if( fVerboseLevel > 1 )
#ifdef G4DEBUG_NAVIGATION
if( fVerbose > 1 )
{
G4cout << " Entered G4MultiNavigator::PrepareNewTrack() " << G4endl;
}
#endif
G4MultiNavigator::PrepareNavigators();
//***********************************
if( fVerboseLevel > 1 ) {
G4cout << " Calling MultiNavigator::Locate() from G4MultiNavigator::PrepareNewTrack() "
<< G4endl;
}
this->LocateGlobalPointAndSetup( position, &direction, false, false );
// =========================
LocateGlobalPointAndSetup( position, &direction, false, false );
//
// The first location for each Navigator must be non-relative
// or else call ResetStackAndState() for each Navigator
// or else call ResetStackAndState() for each Navigator
// Use direction to get correct side of boundary (ignore dir= false)
// fRelocatedPoint= false;
if( fVerboseLevel > 0 ) {
G4cout << " G4MultiNavigator::PrepareNewTrack : exiting. " << G4endl;
}
}
void
G4MultiNavigator::PrepareNavigators()
// ----------------------------------------------------------------------
void G4MultiNavigator::PrepareNavigators()
{
// Key purposes:
// - Check and cache set of active navigators
// - Reset state for new track
G4int num=0;
if( fVerboseLevel > 1 )
G4cout << " G4MultiNavigator::PrepareNavigators - entered " << G4endl;
// static G4TransportationManager* pTransportManager=
// G4TransportationManager::GetTransportationManager();
#ifdef G4DEBUG_NAVIGATION
if( fVerbose > 1 )
{
G4cout << " Entered G4MultiNavigator::PrepareNavigators() " << G4endl;
}
#endif
// fNavigators= true;
// this->MovePoint(); // Signal further that the last status is wiped
// Message the transportation-manager to find active navigators
// Message the G4NavigatorPanel / Dispatcher to find active navigators
std::vector<G4Navigator*>::iterator pNavigatorIter;
fNoActiveNavigators= pTransportManager-> GetNoActiveNavigators();
if( fNoActiveNavigators > fMaxNav ){
G4cerr << "Too many active Navigators (worlds). G4MultiNavigator fails."
<< G4endl;
G4cout << " Fatal error: Transportation Manager reports " << fNoActiveNavigators
<< " which is more than the number allowed = " << fMaxNav << G4endl;
G4Exception("G4MultiNavigator::PrepareNavigators()", "TooManyNavigators",
FatalException, "Too many active Navigators / worlds");
if( fNoActiveNavigators > fMaxNav )
{
G4cerr << "ERROR - G4MultiNavigator::PrepareNavigators()"
<< " Too many active Navigators (worlds): "
<< fNoActiveNavigators << G4endl
<< " which is more than the number allowed: "
<< fMaxNav << " !" << G4endl;
G4Exception("G4MultiNavigator::PrepareNavigators()", "InvalidSetup",
FatalException, "Too many active Navigators / worlds !");
}
pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
for( num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num ) {
// Keep information in carray ... for returning information stored
for( register int num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
{
fpNavigator[num] = *pNavigatorIter;
fLimitTruth[num] = false;
fLimitedStep[num] = kDoNot;
fCurrentStepSize[num] = 0.0;
fLocatedVolume[num] = 0;
}
fWasLimitedByGeometry= false;
fWasLimitedByGeometry = false;
// Check the world volume of the mass navigator (in case a SetWorldVolume changed it)
G4VPhysicalVolume* massWorld = this-> GetWorldVolume();
// fpNavigator[0] -> GetWorldVolume();
if( (massWorld != fLastMassWorld) && (massWorld!=0) ) {
// Check the world volume of the mass navigator
// in case a call to SetWorldVolume() changed it
G4VPhysicalVolume* massWorld = GetWorldVolume();
if( (massWorld != fLastMassWorld) && (massWorld!=0) )
{
// Pass along change to Mass Navigator
fpNavigator[0] -> SetWorldVolume( massWorld );
if( fVerboseLevel > 0 ) {
G4cout << "G4MultiNavigator::PrepareNavigators changed world volume "
fpNavigator[0] -> SetWorldVolume( massWorld );
#ifdef G4DEBUG_NAVIGATION
if( fVerbose > 0 )
{
G4cout << " G4MultiNavigator::PrepareNavigators() changed world volume "
<< " for mass geometry to " << massWorld->GetName() << G4endl;
}
fLastMassWorld= massWorld;
}else{
if( fVerboseLevel > 2 ) {
G4cout << "G4MultiNavigator::PrepareNavigators retained world volume "
<< " Pointer= " << massWorld << G4endl;
if( massWorld )
G4cout << " Name= " << massWorld->GetName() << G4endl;
}
}
#endif
if( fVerboseLevel > 2 ) {
G4cout << " G4MultiNavigator::PrepareNavigators : exiting. " << G4endl;
fLastMassWorld = massWorld;
}
}
// ----------------------------------------------------------------------
G4VPhysicalVolume*
G4MultiNavigator::LocateGlobalPointAndSetup(const G4ThreeVector& position,
@@ -327,368 +317,357 @@ G4MultiNavigator::LocateGlobalPointAndSetup(const G4ThreeVector& position,
// Locate the point in each geometry
G4ThreeVector direction(0.0, 0.0, 0.0);
G4bool relative= pRelativeSearch;
std::vector<G4Navigator*>::iterator pNavIter= pTransportManager->GetActiveNavigatorsIterator();
G4int num=0;
G4bool relative = pRelativeSearch;
std::vector<G4Navigator*>::iterator pNavIter
= pTransportManager->GetActiveNavigatorsIterator();
if( pDirection ) direction = *pDirection;
if( pDirection ) { direction = *pDirection; }
#if 0
G4ThreeVector lastEndPosition= fEndState.GetPosition();
G4ThreeVector moveVec = (position - lastEndPosition );
G4double moveLenSq= moveVec.mag2();
if( (!fNewTrack) && (!fRelocatedPoint) && ( moveLenSq> 0.0) ){
ReportMove( position, lastEndPosition, "Position" );
G4Exception( "G4MultiNavigator::LocateGlobalPointAndSetup",
"211-LocateUnexpectedPoint",
JustWarning,
// FatalException,
"Location is not where last ComputeStep ended.");
#ifdef G4DEBUG_NAVIGATION
if( fVerbose > 2 )
{
G4cout << " Entered G4MultiNavigator::LocateGlobalPointAndSetup() "
<< G4endl;
G4cout << " Locating at position: " << position
<< ", with direction: " << direction << G4endl
<< " Relative: " << relative
<< ", ignore direction: " << ignoreDirection << G4endl;
G4cout << " Number of active navigators: " << fNoActiveNavigators
<< G4endl;
}
fLastLocatedPosition= position;
#endif
if( fVerboseLevel > 2 ){
G4cout << " G4MultiNavigator::LocateGlobalPointAndSetup : entered " << " ---------------" << G4endl;
G4cout << " Locating at position " << position << " with direction " << direction
<< " relative= " << relative << " ignore direction= " << ignoreDirection<< G4endl;
G4cout << " Number of active navigators= " << fNoActiveNavigators << G4endl;
}
for ( num=0; num< fNoActiveNavigators ; ++pNavIter,++num ) {
// ... who limited the step ....
// G4cout << " -- Navigator id= " << num << " NavigatorPtr " << *pNavIter << G4endl;
// G4VPhysicalVolume* world= (*pNavIter)->GetWorldVolume();
// if( world ) { G4cout << " Navigator world= " << world->GetName() << G4endl; }
// else{ G4cout << " No world set in Navigator. " << G4endl; }
if( fWasLimitedByGeometry && fLimitTruth[num] ) {
for ( register int num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
{
if( fWasLimitedByGeometry && fLimitTruth[num] )
{
(*pNavIter)->SetGeometricallyLimitedStep();
}
G4VPhysicalVolume *pLocated=
(*pNavIter)->LocateGlobalPointAndSetup( position, &direction,
//*************************************//
relative,
ignoreDirection);
G4VPhysicalVolume *pLocated
= (*pNavIter)->LocateGlobalPointAndSetup( position, &direction,
relative, ignoreDirection );
// Set the state related to the location
//
fLocatedVolume[num] = pLocated;
// Clear state related to the step
//
fLimitedStep[num] = kDoNot;
fCurrentStepSize[num] = 0.0;
fLimitTruth[ num ] = false; // Always clear on locating (see Navigator)
if( fVerboseLevel > 2 ){
G4cout << " Located in world " << num << " at " << position
<< " used geomLimStp " << fLimitTruth[num]
<< " - found in volume " << pLocated ;
G4cout << " name = '" ;
if( pLocated ){
#ifdef G4DEBUG_NAVIGATION
if( fVerbose > 2 )
{
G4cout << " Located in world: " << num << ", at: " << position << G4endl
<< " Used geomLimStp: " << fLimitTruth[num]
<< ", found in volume: " << pLocated << G4endl;
G4cout << " Name = '" ;
if( pLocated )
{
G4cout << pLocated->GetName() << "'";
G4cout << " - CopyNo= " << pLocated->GetCopyNo();
} else {
}
else
{
G4cout << "Null' Id: Not-Set ";
}
G4cout << G4endl;
G4cout << G4endl;
}
} // ending for (num= ....
fWasLimitedByGeometry= false; // Clear on locating
if( fVerboseLevel > 2 ){
G4cout << " G4MultiNavigator::Locate : exiting. " << G4endl << G4endl;
#endif
}
// fRelocatedPoint= false;
fWasLimitedByGeometry = false; // Clear on locating
G4VPhysicalVolume* volMassLocated= fLocatedVolume[0];
return volMassLocated;
}
// ----------------------------------------------------------------------
void
G4MultiNavigator::LocateGlobalPointWithinVolume(const G4ThreeVector& position)
{
// Relocate the point in each geometry
std::vector<G4Navigator*>::iterator pNavIter= pTransportManager->GetActiveNavigatorsIterator();
// const G4double cErrorTolerance=1e-12;
// Maximum relative error from roundoff of arithmetic
G4int num=0;
if( fVerboseLevel > 2 ){
G4cout << G4endl;
G4cout << " G4MultiNavigator::ReLocate : entered " << G4endl;
G4cout << " ---------------------- -------" << G4endl;
G4cout << " *Re*Locating at position " << position << G4endl;
std::vector<G4Navigator*>::iterator pNavIter
= pTransportManager->GetActiveNavigatorsIterator();
#ifdef G4DEBUG_NAVIGATION
if( fVerbose > 2 )
{
G4cout << " Entered G4MultiNavigator::ReLocate() " << G4endl
<< " Re-locating at position: " << position << G4endl;
}
#endif
for ( num=0; num< fNoActiveNavigators ; ++pNavIter,++num ) {
for ( register int num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
{
// ... none limited the step
// G4VPhysicalVolume physVolume=
(*pNavIter)->LocateGlobalPointWithinVolume( position );
//*************************************//
// Clear state related to the step
fLimitedStep[num] = kDoNot;
//
fLimitedStep[num] = kDoNot;
fCurrentStepSize[num] = 0.0;
fLimitTruth[ num ] = false; // Always clear on locating (see Navigator)
// fLocatedVolume[num]= physVolume;
// G4cout << " ReLocated in world " << num << " at " << position << G4endl;
}
fWasLimitedByGeometry= false; // Clear on locating
fLastLocatedPosition= position;
// fRelocatedPoint= false;
if( fVerboseLevel > 2 ){
G4cout << " G4MultiNavigator::LocateGlobalPointWithinVolume : exiting "
<< " at position " << position << G4endl;
G4cout << G4endl;
}
fWasLimitedByGeometry = false; // Clear on locating
fLastLocatedPosition = position;
}
// -----------------------------------------------------------------------------
// ----------------------------------------------------------------------
G4double G4MultiNavigator::ComputeSafety( const G4ThreeVector& position,
G4double maxDistance)
// Recompute safety for the relevant point
G4double G4MultiNavigator::ComputeSafety( const G4ThreeVector& position,
G4double maxDistance)
{
G4double minSafety= DBL_MAX;
// G4cout << " G4MultiNavigator::ComputeSafety - called at " << position << G4endl;
// Recompute safety for the relevant point
G4double minSafety = DBL_MAX, safety = DBL_MAX;
std::vector<G4Navigator*>::iterator pNavigatorIter;
pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
G4int num=0;
for( num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num ) {
G4double safety;
safety= (*pNavigatorIter)->ComputeSafety( position, maxDistance );
if( safety < minSafety ){ minSafety = safety; }
// fNewSafety[num]= safety;
for( register int num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
{
safety = (*pNavigatorIter)->ComputeSafety( position, maxDistance );
if( safety < minSafety ) { minSafety = safety; }
}
fSafetyLocation= position;
fSafetyLocation = position;
fMinSafety_atSafLocation = minSafety;
if( fVerboseLevel > 1 ) {
G4cout << " G4MultiNavigator::ComputeSafety - returns "
<< minSafety << " at location " << position
<< G4endl;
#ifdef G4DEBUG_NAVIGATION
if( fVerbose > 1 )
{
G4cout << " G4MultiNavigator::ComputeSafety - returns: "
<< minSafety << ", at location: " << position << G4endl;
}
#endif
return minSafety;
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------
G4TouchableHistoryHandle
G4MultiNavigator::CreateTouchableHistoryHandle() const
{
G4Exception( "G4MultiNavigator::CreateTouchableHistoryHandle",
"215-TouchableFromWrongNavigator",
FatalException,
G4Exception( "G4MultiNavigator::CreateTouchableHistoryHandle()",
"215-TouchableFromWrongNavigator", FatalException,
"Getting a touchable from G4MultiNavigator is not defined.");
if( fVerboseLevel > 2 ){
G4cout << "G4MultiNavigator::CreateTouchableHandle : navId = " << 0 ;
// << " -- " << GetNavigator(navId) << G4endl;
}
G4TouchableHistory* touchHist;
touchHist= fpNavigator[0] -> CreateTouchableHistory();
// G4TouchableHistory* touchHist= new G4TouchableHistory();
G4VPhysicalVolume* locatedVolume= fLocatedVolume[0];
if( locatedVolume == 0 )
{
// Workaround to ensure that the touchable is fixed !! // TODO: fix
touchHist->UpdateYourself( locatedVolume,
touchHist->GetHistory() );
}
{
// Workaround to ensure that the touchable is fixed !! // TODO: fix
//
touchHist->UpdateYourself( locatedVolume, touchHist->GetHistory() );
}
return G4TouchableHistoryHandle(touchHist);
}
void
G4MultiNavigator::WhichLimited() // Flag which processes limited the step
// -----------------------------------------------------------------------
void G4MultiNavigator::WhichLimited()
{
G4int num=-1, last=-1;
const G4int IdTransport= 0; // Id of Mass Navigator !!
// Flag which processes limited the step
G4int last=-1;
const G4int IdTransport= 0; // Id of Mass Navigator !!
G4int noLimited=0;
ELimited shared= kSharedOther;
if( fVerboseLevel > 2 )
G4cout << " G4MultiNavigator::WhichLimited - entered " << G4endl;
#ifdef G4DEBUG_NAVIGATION
if( fVerbose > 2 )
{
G4cout << " Entered G4MultiNavigator::WhichLimited() " << G4endl;
}
#endif
// Assume that [IdTransport] is Mass / Transport
// G4bool transportLimited = (fCurrentStepSize[IdTransport] == fMinStep);
//
G4bool transportLimited = (fCurrentStepSize[IdTransport] == fMinStep)
&& ( fMinStep!= kInfinity) ;
if( transportLimited ){
&& ( fMinStep!= kInfinity);
if( transportLimited )
{
shared= kSharedTransport;
}
for ( num= 0; num < fNoActiveNavigators; num++ ) {
for ( register int num= 0; num < fNoActiveNavigators; num++ )
{
G4bool limitedStep;
G4double step= fCurrentStepSize[num];
limitedStep = ( step == fMinStep ) && ( step != kInfinity);
// if( step == kInfinity ) { fCurrentStepSize[num] = proposedStepLength; }
fLimitTruth[ num ] = limitedStep;
if( limitedStep ) {
if( limitedStep )
{
noLimited++;
fLimitedStep[num] = shared;
last= num;
}else{
}
else
{
fLimitedStep[num] = kDoNot;
}
}
if( (last > -1) && (noLimited == 1 ) ){
if( (last > -1) && (noLimited == 1 ) )
{
fLimitedStep[ last ] = kUnique;
}
#ifndef G4NO_VERBOSE
if( fVerboseLevel > 1 ){
this->PrintLimited(); // --> for tracing
G4cout << " G4MultiNavigator::WhichLimited - exiting. " << G4endl;
}
#endif
}
// -----------------------------------------------------------------------
void
G4MultiNavigator::PrintLimited()
{
static G4String StrDoNot("DoNot"), StrUnique("Unique"), StrUndefined("Undefined"),
StrSharedTransport("SharedTransport"), StrSharedOther("SharedOther");
// Report results -- for checking
G4cout << "G4MultiNavigator::PrintLimited reports: " ;
G4cout << " Minimum step (true)= " << fTrueMinStep
<< " reported min = " << fMinStep
<< G4endl;
if( // (fCurrentStepNo <= 2) ||
(fVerboseLevel>=2) ) {
G4cout // << std::setw(5) << " Step#" << " "
<< std::setw(5) << " NavId" << " "
<< std::setw(12) << " step-size " << " "
<< std::setw(12) << " raw-size " << " "
<< std::setw(12) << " pre-safety " << " "
<< std::setw(15) << " Limited / flag" << " "
<< std::setw(15) << " World " << " "
<< G4endl;
static G4String StrDoNot("DoNot"), StrUnique("Unique"),
StrUndefined("Undefined"),
StrSharedTransport("SharedTransport"),
StrSharedOther("SharedOther");
G4cout << "### G4MultiNavigator::PrintLimited() reports: " << G4endl;
G4cout << " Minimum step (true): " << fTrueMinStep
<< ", reported min: " << fMinStep << G4endl;
#ifdef G4DEBUG_NAVIGATION
if(fVerbose>=2)
{
G4cout << std::setw(5) << " NavId" << " "
<< std::setw(12) << " step-size " << " "
<< std::setw(12) << " raw-size " << " "
<< std::setw(12) << " pre-safety " << " "
<< std::setw(15) << " Limited / flag" << " "
<< std::setw(15) << " World " << " "
<< G4endl;
}
int num;
for ( num= 0; num < fNoActiveNavigators; num++ ) {
#endif
for ( register int num= 0; num < fNoActiveNavigators; num++ )
{
G4double rawStep = fCurrentStepSize[num];
G4double stepLen = fCurrentStepSize[num];
if( stepLen > fTrueMinStep ) {
if( stepLen > fTrueMinStep )
{
stepLen = fTrueMinStep; // did not limit (went as far as asked)
}
G4int oldPrec= G4cout.precision(9);
// const char *BooleanValue[2] = { " NO", "YES" } ;
G4cout // << std::setw(5) << fCurrentStepNo << " "
<< std::setw(5) << num << " "
G4cout << std::setw(5) << num << " "
<< std::setw(12) << stepLen << " "
<< std::setw(12) << rawStep << " "
<< std::setw(12) << fNewSafety[num] << " "
<< std::setw(5) << (fLimitTruth[num] ? "YES" : " NO") << " ";
G4String limitedStr;
switch ( fLimitedStep[num] ) {
case kDoNot: limitedStr= StrDoNot; break;
case kUnique: limitedStr = StrUnique; break;
case kSharedTransport: limitedStr= StrSharedTransport; break;
case kSharedOther: limitedStr = StrSharedOther; break;
default: limitedStr = StrUndefined; break;
switch ( fLimitedStep[num] )
{
case kDoNot : limitedStr= StrDoNot; break;
case kUnique : limitedStr = StrUnique; break;
case kSharedTransport: limitedStr= StrSharedTransport; break;
case kSharedOther : limitedStr = StrSharedOther; break;
default : limitedStr = StrUndefined; break;
}
G4cout << " " << std::setw(15) << limitedStr << " ";
G4cout.precision(oldPrec);
G4Navigator *pNav= fpNavigator[ num ];
G4String WorldName( "Not-Set" );
if (pNav) {
if (pNav)
{
G4VPhysicalVolume *pWorld= pNav->GetWorldVolume();
if( pWorld ) {
if( pWorld )
{
WorldName = pWorld->GetName();
}
}
G4cout << " " << WorldName ;
G4cout << G4endl;
}
if( fVerboseLevel > 2 )
G4cout << " G4MultiNavigator::PrintLimited - exiting. " << G4endl;
}
void
G4MultiNavigator::ResetState()
// -----------------------------------------------------------------------
void G4MultiNavigator::ResetState()
{
G4int num;
fWasLimitedByGeometry= false;
G4Exception( "G4MultiNavigator::ResetState",
"217-CannotImplement",
G4Exception("G4MultiNavigator::ResetState()", "217-NotImplemented",
FatalException,
"Cannot call ResetState for active navigators of G4MultiNavigator.");
"Cannot call ResetState() for navigators of G4MultiNavigator.");
std::vector<G4Navigator*>::iterator pNavigatorIter;
pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
for( num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num ) {
for( register int num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
{
// (*pNavigatorIter)->ResetState(); // KEEP THIS comment !!!
}
}
void
G4MultiNavigator::SetupHierarchy()
// -----------------------------------------------------------------------
void G4MultiNavigator::SetupHierarchy()
{
// G4Navigator::SetupHierarchy();
G4Exception( "G4MultiNavigator::SetupHierarchy",
"217-CannotImplement",
FatalException,
"Cannot call SetupHierarchy for active navigators of G4MultiNavigator.");
G4Exception( "G4MultiNavigator::SetupHierarchy()",
"217-NotImplemented", FatalException,
"Cannot call SetupHierarchy() for navigators of G4MultiNavigator.");
}
void
G4MultiNavigator::CheckMassWorld()
// -----------------------------------------------------------------------
void G4MultiNavigator::CheckMassWorld()
{
//
G4VPhysicalVolume* navTrackWorld= pTransportManager->GetNavigatorForTracking()
->GetWorldVolume();
if( navTrackWorld != fLastMassWorld ) {
G4Exception( "G4MultiNavigator::CheckMassWorld", "MultiNav-220", FatalException,
G4VPhysicalVolume* navTrackWorld=
pTransportManager->GetNavigatorForTracking()->GetWorldVolume();
if( navTrackWorld != fLastMassWorld )
{
G4Exception( "G4MultiNavigator::CheckMassWorld()",
"220-InvalidSetup", FatalException,
"Mass world pointer has been changed." );
}
}
}
G4VPhysicalVolume* G4MultiNavigator::ResetHierarchyAndLocate(const G4ThreeVector &point,
const G4ThreeVector &direction,
const G4TouchableHistory &MassHistory)
// Reset geometry for all -- and use the touchable for the mass history
// -----------------------------------------------------------------------
G4VPhysicalVolume*
G4MultiNavigator::ResetHierarchyAndLocate(const G4ThreeVector &point,
const G4ThreeVector &direction,
const G4TouchableHistory &MassHistory)
{
// Reset geometry for all -- and use the touchable for the mass history
G4VPhysicalVolume* massVolume=0;
G4int num;
G4Navigator* pMassNavigator= fpNavigator[0];
if( pMassNavigator ){
massVolume= pMassNavigator->ResetHierarchyAndLocate( point, direction, MassHistory);
}else{
G4Exception("G4MultiNavigator::ResetHierarchyAndLocate",
"218-TooEarlyToReset",
FatalException,
"Cannot reset hierarchy before object is initialised with valid navigators, including a mass Navigator" );
if( pMassNavigator )
{
massVolume= pMassNavigator->ResetHierarchyAndLocate( point, direction,
MassHistory);
}
else
{
G4Exception("G4MultiNavigator::ResetHierarchyAndLocate()",
"218-TooEarlyToReset", FatalException,
"Cannot reset hierarchy before navigators are initialised.");
}
std::vector<G4Navigator*>::iterator pNavIter=
pTransportManager->GetActiveNavigatorsIterator();
for ( num=0; num< fNoActiveNavigators ; ++pNavIter,++num ) {
for ( register int num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
{
G4bool relativeSearch, ignoreDirection;
(*pNavIter)-> LocateGlobalPointAndSetup( point,
+231 -112
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Navigator.cc,v 1.31 2007/05/11 13:43:59 gcosmo Exp $
// $Id: G4Navigator.cc,v 1.37 2007/10/18 14:18:36 gcosmo Exp $
// GEANT4 tag $ Name: $
//
// class G4Navigator Implementation
@@ -45,8 +45,8 @@
// ********************************************************************
//
G4Navigator::G4Navigator()
: fWasLimitedByGeometry(false), fTopPhysical(0),
fCheck(false), fPushed(false), fVerbose(0)
: fWasLimitedByGeometry(false), fVerbose(0),
fTopPhysical(0), fCheck(false), fPushed(false)
{
fActive= false;
ResetStackAndState();
@@ -55,6 +55,9 @@ G4Navigator::G4Navigator()
fAbandonThreshold_NoZeroSteps = 25;
kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
fregularNav.SetNormalNavigation( &fnormalNav );
fStepEndPoint = G4ThreeVector( kInfinity, kInfinity, kInfinity );
}
// ********************************************************************
@@ -116,8 +119,11 @@ G4Navigator::LocateGlobalPointAndSetup( const G4ThreeVector& globalPoint,
}
#ifdef G4DEBUG_NAVIGATION
G4cerr << "Upon entering LocateGlobalPointAndSetup():" << G4endl;
G4cerr << " History = " << G4endl << fHistory << G4endl << G4endl;
if( fVerbose > 2 )
{
G4cout << "Upon entering LocateGlobalPointAndSetup():" << G4endl;
G4cout << " History = " << G4endl << fHistory << G4endl << G4endl;
}
#endif
#ifdef G4VERBOSE
@@ -188,29 +194,32 @@ G4Navigator::LocateGlobalPointAndSetup( const G4ThreeVector& globalPoint,
fBlockedPhysicalVolume->SetCopyNo(fBlockedReplicaNo);
break;
case kParameterised:
G4VSolid *pSolid;
G4VPVParameterisation *pParam;
G4TouchableHistory parentTouchable( fHistory );
pParam = fBlockedPhysicalVolume->GetParameterisation();
pSolid = pParam->ComputeSolid(fBlockedReplicaNo,
fBlockedPhysicalVolume);
pSolid->ComputeDimensions(pParam, fBlockedReplicaNo,
fBlockedPhysicalVolume);
pParam->ComputeTransformation(fBlockedReplicaNo,
fBlockedPhysicalVolume);
fHistory.NewLevel(fBlockedPhysicalVolume, kParameterised,
fBlockedReplicaNo);
fBlockedPhysicalVolume->SetCopyNo(fBlockedReplicaNo);
//
// Set the correct solid and material in Logical Volume
//
G4LogicalVolume *pLogical;
pLogical = fBlockedPhysicalVolume->GetLogicalVolume();
pLogical->SetSolid( pSolid );
pLogical->UpdateMaterial(pParam ->
ComputeMaterial(fBlockedReplicaNo,
fBlockedPhysicalVolume,
&parentTouchable));
if( fBlockedPhysicalVolume->GetRegularStructureId() != 1 )
{
G4VSolid *pSolid;
G4VPVParameterisation *pParam;
G4TouchableHistory parentTouchable( fHistory );
pParam = fBlockedPhysicalVolume->GetParameterisation();
pSolid = pParam->ComputeSolid(fBlockedReplicaNo,
fBlockedPhysicalVolume);
pSolid->ComputeDimensions(pParam, fBlockedReplicaNo,
fBlockedPhysicalVolume);
pParam->ComputeTransformation(fBlockedReplicaNo,
fBlockedPhysicalVolume);
fHistory.NewLevel(fBlockedPhysicalVolume, kParameterised,
fBlockedReplicaNo);
fBlockedPhysicalVolume->SetCopyNo(fBlockedReplicaNo);
//
// Set the correct solid and material in Logical Volume
//
G4LogicalVolume *pLogical;
pLogical = fBlockedPhysicalVolume->GetLogicalVolume();
pLogical->SetSolid( pSolid );
pLogical->UpdateMaterial(pParam ->
ComputeMaterial(fBlockedReplicaNo,
fBlockedPhysicalVolume,
&parentTouchable));
}
break;
}
fEntering = false;
@@ -385,13 +394,26 @@ G4Navigator::LocateGlobalPointAndSetup( const G4ThreeVector& globalPoint,
localPoint);
break;
case kParameterised:
noResult = fparamNav.LevelLocate(fHistory,
fBlockedPhysicalVolume,
fBlockedReplicaNo,
globalPoint,
pGlobalDirection,
considerDirection,
localPoint);
if( GetDaughtersRegularStructureId(targetLogical) != 1 )
{
noResult = fparamNav.LevelLocate(fHistory,
fBlockedPhysicalVolume,
fBlockedReplicaNo,
globalPoint,
pGlobalDirection,
considerDirection,
localPoint);
}
else // Regular structure
{
noResult = fregularNav.LevelLocate(fHistory,
fBlockedPhysicalVolume,
fBlockedReplicaNo,
globalPoint,
pGlobalDirection,
considerDirection,
localPoint);
}
break;
}
@@ -412,11 +434,11 @@ G4Navigator::LocateGlobalPointAndSetup( const G4ThreeVector& globalPoint,
//
fEntering = false;
fEnteredDaughter = true;
#ifdef G4VERBOSE
if( fVerbose > 1 )
#ifdef G4DEBUG_NAVIGATION
if( fVerbose > 2 )
{
G4VPhysicalVolume* enteredPhysical = fHistory.GetTopVolume();
G4cout << "*** G4Navigator::LocateGlobalPointAndSetup: ***" << G4endl;
G4cout << "*** G4Navigator::LocateGlobalPointAndSetup() ***" << G4endl;
G4cout << " Entering volume: " << enteredPhysical->GetName()
<< G4endl;
}
@@ -432,13 +454,15 @@ G4Navigator::LocateGlobalPointAndSetup( const G4ThreeVector& globalPoint,
G4cout.precision(6);
G4String curPhysVol_Name("None");
if (targetPhysical!=0)
{
curPhysVol_Name = targetPhysical->GetName();
}
G4cout << " Return value = new volume = " << curPhysVol_Name << G4endl;
G4cout << " ----- Upon exiting:" << G4endl;
PrintState();
#ifdef G4DEBUG_NAVIGATION
G4cerr << "Upon exiting LocateGlobalPointAndSetup():" << G4endl;
G4cerr << " History = " << G4endl << fHistory << G4endl << G4endl;
G4cout << "Upon exiting LocateGlobalPointAndSetup():" << G4endl;
G4cout << " History = " << G4endl << fHistory << G4endl << G4endl;
#endif
}
G4cout.precision(oldcoutPrec);
@@ -467,6 +491,14 @@ G4Navigator::LocateGlobalPointWithinVolume(const G4ThreeVector& pGlobalpoint)
{
fLastLocatedPointLocal = ComputeLocalPoint(pGlobalpoint);
#ifdef G4DEBUG_NAVIGATION
if( fVerbose > 2 )
{
G4cout << "Entering LocateGlobalWithinVolume(): History = " << G4endl;
G4cout << fHistory << G4endl;
}
#endif
// For the case of Voxel (or Parameterised) volume the respective
// Navigator must be messaged to update its voxel information etc
@@ -486,15 +518,15 @@ G4Navigator::LocateGlobalPointWithinVolume(const G4ThreeVector& pGlobalpoint)
{
fvoxelNav.VoxelLocate( pVoxelHeader, fLastLocatedPointLocal );
}
// else { fnormalNav. nothing !? }
break;
case kParameterised:
// Resets state & returns voxel node
//
fparamNav.ParamVoxelLocate( pVoxelHeader, fLastLocatedPointLocal );
if( GetDaughtersRegularStructureId(motherLogical) != 1 )
{
// Resets state & returns voxel node
//
fparamNav.ParamVoxelLocate( pVoxelHeader, fLastLocatedPointLocal );
}
break;
case kReplica:
G4Exception("G4Navigator::LocateGlobalPointWithinVolume()",
"NotApplicable", FatalException,
@@ -610,16 +642,16 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector &pGlobalpoint,
G4cout << " Volume = " << motherPhysical->GetName()
<< " - Proposed step length = " << pCurrentProposedStepLength
<< G4endl;
if( fVerbose == 4 )
#ifdef G4DEBUG_NAVIGATION
if( fVerbose >= 4 )
{
G4cout << " Called with the arguments: " << G4endl
<< " Globalpoint = " << std::setw(25) << pGlobalpoint
<< G4endl
<< " Direction = " << std::setw(25) << pDirection
<< G4endl;
G4cout << " ----- Upon entering :" << G4endl;
G4cout << " Called with the arguments: " << G4endl
<< " Globalpoint = " << std::setw(25) << pGlobalpoint << G4endl
<< " Direction = " << std::setw(25) << pDirection << G4endl;
G4cout << " ---- Upon entering :" << G4endl;
PrintState();
}
#endif
}
static G4double fAccuracyForWarning = kCarTolerance,
@@ -751,31 +783,98 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector &pGlobalpoint,
}
else
{
Step = fnormalNav.ComputeStep(fLastLocatedPointLocal,
localDirection,
pCurrentProposedStepLength,
pNewSafety,
fHistory,
fValidExitNormal,
fExitNormal,
fExiting,
fEntering,
&fBlockedPhysicalVolume,
fBlockedReplicaNo);
if( motherPhysical->GetRegularStructureId() != 1 )
{
Step = fnormalNav.ComputeStep(fLastLocatedPointLocal,
localDirection,
pCurrentProposedStepLength,
pNewSafety,
fHistory,
fValidExitNormal,
fExitNormal,
fExiting,
fEntering,
&fBlockedPhysicalVolume,
fBlockedReplicaNo);
}
else // Regular (non-voxelised) structure
{
LocateGlobalPointAndSetup( pGlobalpoint, &pDirection, true, true );
//
// if physical process limits the step, the voxel will not be the
// one given by ComputeStepSkippingEqualMaterials() and the local
// point will be wrongly calculated.
// There is a problem: when msc limits the step and the point is
// assigned wrongly to phantom in previous step (while it is out
// of the container volume). Then LocateGlobalPointAndSetup() has
// reset the history topvolume to world.
//
if(fHistory.GetTopVolume()->GetRegularStructureId() != 1 )
{
G4Exception("G4Navigator::ComputeStep()",
"Bad-location-of-point", JustWarning,
"Point is relocated in voxels, while it should be outside!");
Step = fnormalNav.ComputeStep(fLastLocatedPointLocal,
localDirection,
pCurrentProposedStepLength,
pNewSafety,
fHistory,
fValidExitNormal,
fExitNormal,
fExiting,
fEntering,
&fBlockedPhysicalVolume,
fBlockedReplicaNo);
}
else
{
Step = fregularNav.
ComputeStepSkippingEqualMaterials(fLastLocatedPointLocal,
localDirection,
pCurrentProposedStepLength,
pNewSafety,
fHistory,
fValidExitNormal,
fExitNormal,
fExiting,
fEntering,
&fBlockedPhysicalVolume,
fBlockedReplicaNo,
motherPhysical);
}
}
}
break;
case kParameterised:
Step = fparamNav.ComputeStep(fLastLocatedPointLocal,
localDirection,
pCurrentProposedStepLength,
pNewSafety,
fHistory,
fValidExitNormal,
fExitNormal,
fExiting,
fEntering,
&fBlockedPhysicalVolume,
fBlockedReplicaNo);
if( GetDaughtersRegularStructureId(motherLogical) != 1 )
{
Step = fparamNav.ComputeStep(fLastLocatedPointLocal,
localDirection,
pCurrentProposedStepLength,
pNewSafety,
fHistory,
fValidExitNormal,
fExitNormal,
fExiting,
fEntering,
&fBlockedPhysicalVolume,
fBlockedReplicaNo);
}
else // Regular structure
{
Step = fregularNav.ComputeStep(fLastLocatedPointLocal,
localDirection,
pCurrentProposedStepLength,
pNewSafety,
fHistory,
fValidExitNormal,
fExitNormal,
fExiting,
fEntering,
&fBlockedPhysicalVolume,
fBlockedReplicaNo);
}
break;
case kReplica:
G4Exception("G4Navigator::ComputeStep()", "NotApplicable",
@@ -832,7 +931,8 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector &pGlobalpoint,
#ifdef G4DEBUG_NAVIGATION
if( fNumberZeroSteps > 1 )
{
G4cout << "G4Nav - CompStep: another zero step, # " << fNumberZeroSteps
G4cout << "G4Navigator::ComputeStep(): another zero step, # "
<< fNumberZeroSteps
<< " at " << pGlobalpoint
<< " in volume " << motherPhysical->GetName()
<< " nav-comp-step calls # " << sNavCScalls
@@ -888,9 +988,12 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector &pGlobalpoint,
if( fExiting )
{
#ifdef G4DEBUG_NAVIGATION
G4cout << " At G4Nav CompStep End - if(exiting) - fExiting= " << fExiting
<< " fValidExitNormal = " << fValidExitNormal << G4endl;
G4cout << " fExitNormal= " << fExitNormal << G4endl;
if( fVerbose > 2 )
{
G4cout << " At G4Nav CompStep End - if(exiting) - fExiting= " << fExiting
<< " fValidExitNormal = " << fValidExitNormal << G4endl;
G4cout << " fExitNormal= " << fExitNormal << G4endl;
}
#endif
if(fValidExitNormal)
@@ -917,10 +1020,8 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector &pGlobalpoint,
fGrandMotherExitNormal *= (*mRot);
}
}
#ifdef G4DEBUG_NAVIGATION
G4cout << " fGrandMotherExitNormal= " << fGrandMotherExitNormal << G4endl;
#endif
}
fStepEndPoint= pGlobalpoint+Step*pDirection;
if( (Step == pCurrentProposedStepLength) && (!fExiting) && (!fEntering) )
{
@@ -931,15 +1032,19 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector &pGlobalpoint,
}
#ifdef G4VERBOSE
if( fVerbose > 1 ) {
if( fVerbose >= 4 ) {
if( fVerbose > 1 )
{
if( fVerbose >= 4 )
{
G4cout << " ----- Upon exiting :" << G4endl;
PrintState();
}
G4cout <<" Returned step = " << Step << G4endl;
if( Step == kInfinity )
{
G4cout << " Original proposed step = "
<< pCurrentProposedStepLength << G4endl;
}
G4cout << " Safety = " << pNewSafety << G4endl;
}
G4cout.precision(oldcoutPrec);
@@ -1112,42 +1217,51 @@ G4double G4Navigator::ComputeSafety( const G4ThreeVector &pGlobalpoint,
{
G4double newSafety = 0.0;
#ifdef G4VERBOSE
#ifdef G4DEBUG_NAVIGATION
G4int oldcoutPrec = G4cout.precision(8);
if( fVerbose > 0 )
{
G4cout << "*** G4Navigator::ComputeSafety: ***" << G4endl
<< " Called at point: "
<< pGlobalpoint << G4endl
<< " for Navigator: " << this << G4endl;
<< " Called at point: " << pGlobalpoint << G4endl;
G4VPhysicalVolume *motherPhysical = fHistory.GetTopVolume();
G4cout << " Volume = " << motherPhysical->GetName()
<< " - Maximum length = " << pMaxLength << G4endl;
if( fVerbose == 4 )
if( fVerbose >= 4 )
{
G4cout << " Called with the arguments: " << G4endl
<< " Globalpoint = " << pGlobalpoint << G4endl;
G4cout << " ----- Upon entering :" << G4endl;
PrintState();
G4cout << " ----- Upon entering Compute Safety:" << G4endl;
PrintState();
}
}
#endif
if( !(fEnteredDaughter || fExitedMother) )
G4double distEndpointSq = (pGlobalpoint-fStepEndPoint).mag2();
G4bool stayedOnEndpoint = distEndpointSq < kCarTolerance*kCarTolerance;
G4bool endpointOnSurface = fEnteredDaughter || fExitedMother;
if( !(endpointOnSurface && stayedOnEndpoint) )
{
// Pseudo-relocate to this point (updates voxel information only)
//
LocateGlobalPointWithinVolume( pGlobalpoint );
// --->> Danger: Side effects on sub-navigator voxel information <<---
// Could be replaced again by 'granular' calls to sub-navigator
// locates (similar side-effects, but faster.
// Solutions:
// 1) Re-locate (to where?)
// 2) Insure that the methods using (G4ComputeStep?)
// does a relocation (if information is disturbed only ?)
#ifdef G4DEBUG_NAVIGATION
if( fVerbose >= 2 )
{
G4cout << " ComputeSafety() relocates-in-volume to point: "
G4cout << " G4Navigator::ComputeSafety() relocates-in-volume to point: "
<< pGlobalpoint << G4endl;
}
#endif
G4VPhysicalVolume *motherPhysical = fHistory.GetTopVolume();
G4LogicalVolume *motherLogical = motherPhysical->GetLogicalVolume();
G4SmartVoxelHeader* pVoxelHeader = motherLogical->GetVoxelHeader();
G4ThreeVector localPoint = ComputeLocalPoint(pGlobalpoint);
if ( fHistory.GetTopVolumeType()!=kReplica )
@@ -1155,7 +1269,7 @@ G4double G4Navigator::ComputeSafety( const G4ThreeVector &pGlobalpoint,
switch(CharacteriseDaughters(motherLogical))
{
case kNormal:
if ( motherLogical->GetVoxelHeader() )
if ( pVoxelHeader )
{
newSafety=fvoxelNav.ComputeSafety(localPoint,fHistory,pMaxLength);
}
@@ -1165,7 +1279,14 @@ G4double G4Navigator::ComputeSafety( const G4ThreeVector &pGlobalpoint,
}
break;
case kParameterised:
newSafety = fparamNav.ComputeSafety(localPoint,fHistory,pMaxLength);
if( GetDaughtersRegularStructureId(motherLogical) != 1 )
{
newSafety = fparamNav.ComputeSafety(localPoint,fHistory,pMaxLength);
}
else // Regular structure
{
newSafety = fregularNav.ComputeSafety(localPoint,fHistory,pMaxLength);
}
break;
case kReplica:
G4Exception("G4Navigator::ComputeSafety()", "NotApplicable",
@@ -1179,22 +1300,20 @@ G4double G4Navigator::ComputeSafety( const G4ThreeVector &pGlobalpoint,
fHistory, pMaxLength);
}
}
else
else // if( endpointOnSurface && stayedOnEndpoint )
{
#ifdef G4DEBUG_NAVIGATION
if( fVerbose >= 2 )
{
G4cout << " ComputeSafety() finds that point - "
G4cout << " G4Navigator::ComputeSafety() finds that point - "
<< pGlobalpoint << " - is on surface " << G4endl;
if( fEnteredDaughter )
{
G4cout << " entered new daughter volume" << G4endl;
}
if( fExitedMother )
{
G4cout << " and exited previous volume.";
}
if( fEnteredDaughter ) { G4cout << " entered new daughter volume"; }
if( fExitedMother ) { G4cout << " and exited previous volume."; }
G4cout << G4endl;
G4cout << " EndPoint was = " << fStepEndPoint << G4endl;
}
#endif
newSafety = 0.0;
}
// Remember last safety origin & value
@@ -1202,11 +1321,11 @@ G4double G4Navigator::ComputeSafety( const G4ThreeVector &pGlobalpoint,
fPreviousSftOrigin = pGlobalpoint;
fPreviousSafety = newSafety;
#ifdef G4VERBOSE
if( fVerbose > 1 )
#ifdef G4DEBUG_NAVIGATION
if( fVerbose > 1 )
{
G4cout << " ----- Upon exiting :" << G4endl;
PrintState();
G4cout << " ---- Exiting ComputeSafety " << G4endl;
if( fVerbose > 2 ) { PrintState(); }
G4cout << " Returned value of Safety = " << newSafety << G4endl;
}
G4cout.precision(oldcoutPrec);
@@ -25,7 +25,7 @@
//
//
// $Id: G4NormalNavigation.cc,v 1.9 2007/05/11 13:43:59 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-00 $
// GEANT4 tag $Name: geant4-09-01 $
//
//
// class G4NormalNavigation Implementation
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4ParameterisedNavigation.cc,v 1.11 2007/05/11 13:43:59 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-00 $
// $Id: G4ParameterisedNavigation.cc,v 1.12 2007/11/09 16:06:02 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
//
// class G4ParameterisedNavigation Implementation
@@ -34,20 +34,19 @@
// Revisions:
// J. Apostolakis 24 Nov 2005, Revised/fixed treatment of nested params
// J. Apostolakis 4 Feb 2005, Reintroducting multi-level parameterisation
// for materials only - see note 1 below
// for materials only - see note 1 below
// G. Cosmo 11 Mar 2004, Added Check mode
// G. Cosmo 15 May 2002, Extended to 3-d voxelisation, made subclass
// J. Apostolakis 5 Mar 1998, Enabled parameterisation of material & solid type
// J. Apostolakis 5 Mar 1998, Enabled parameterisation of mat & solid type
// --------------------------------------------------------------------
// Note 1: Design/implementation note for extensions
// J. Apostolakis, March 1st, 2005
// We cannot make the solid, dimensions and transformation dependant on parent
// because the voxelisation will not have access to this.
// Note 1: Design/implementation note for extensions - JAp, March 1st, 2005
// We cannot make the solid, dimensions and transformation dependent on
// parent because the voxelisation will not have access to this.
// So the following can NOT be done:
// sampleSolid = curParam->ComputeSolid(num, curPhysical, pParentTouch);
// sampleSolid->ComputeDimensions(curParam, num, curPhysical, pParentTouch);
// curParam->ComputeTransformation(num, curPhysical, pParentTouch);
// sampleSolid = curParam->ComputeSolid(num, curPhysical, pParentTouch);
// sampleSolid->ComputeDimensions(curParam, num, curPhysical, pParentTouch);
// curParam->ComputeTransformation(num, curPhysical, pParentTouch);
#include "G4ParameterisedNavigation.hh"
#include "G4TouchableHistory.hh"
@@ -68,28 +67,6 @@ G4ParameterisedNavigation::G4ParameterisedNavigation()
//
G4ParameterisedNavigation::~G4ParameterisedNavigation()
{
#ifdef G4DEBUG_NAVIGATION
G4cout << "G4ParameterisedNavigation::~G4ParameterisedNavigation() called."
<< G4endl;
#endif
}
// ***************************************************************************
// IdentifyAndPlaceSolid
// ***************************************************************************
//
G4VSolid* G4ParameterisedNavigation::
IdentifyAndPlaceSolid( G4int num,
G4VPhysicalVolume *apparentPhys, // PhysV or PhysT
G4VPVParameterisation *curParam )
{
G4VSolid *sampleSolid;
sampleSolid = curParam->ComputeSolid(num, apparentPhys);
sampleSolid->ComputeDimensions(curParam, num, apparentPhys);
curParam->ComputeTransformation(num, apparentPhys);
return sampleSolid;
}
// ***************************************************************************
@@ -140,9 +117,6 @@ G4double G4ParameterisedNavigation::
motherSafety = motherSolid->DistanceToOut(localPoint);
ourSafety = motherSafety; // Working isotropic safety
// G4cout << "DebugLOG - G4ParameterisedNavigation::ComputeStep()" << G4endl
// << " Current solid " << motherSolid->GetName() << G4endl;
#ifdef G4VERBOSE
if ( fCheck )
{
@@ -204,7 +178,7 @@ G4double G4ParameterisedNavigation::
if (localDirection.dot(exitNormal)>=kMinExitingNormalCosine)
{
assert( (0 <= blockedReplicaNo)&&(blockedReplicaNo<nReplicas) );
//
// Block exited daughter replica; Must be on boundary => zero safety
//
fBList.BlockVolume(blockedReplicaNo);
@@ -216,8 +190,6 @@ G4double G4ParameterisedNavigation::
sampleParam = samplePhysical->GetParameterisation();
// G4cerr << " Attaching parent touchable information to Phys Volume " << G4endl;
do
{
curVoxelNode = fVoxelNode;
@@ -229,12 +201,11 @@ G4double G4ParameterisedNavigation::
if ( !fBList.IsBlocked(sampleNo) )
{
fBList.BlockVolume(sampleNo);
// sampleSolid = sampleParam->ComputeSolid(sampleNo, samplePhysical);
// sampleSolid->ComputeDimensions(sampleParam, sampleNo, samplePhysical);
// sampleParam->ComputeTransformation(sampleNo, samplePhysical);
// Call virtual methods, and copy information if needed
sampleSolid= IdentifyAndPlaceSolid( sampleNo, samplePhysical, sampleParam );
//
sampleSolid = IdentifyAndPlaceSolid( sampleNo, samplePhysical,
sampleParam );
G4AffineTransform sampleTf(samplePhysical->GetRotation(),
samplePhysical->GetTranslation());
@@ -345,7 +316,8 @@ G4double G4ParameterisedNavigation::
<< " Problem in Navigation" << G4endl
<< " Point (local coordinates): "
<< localPoint << G4endl
<< " Local Direction: " << localDirection << G4endl
<< " Local Direction: "
<< localDirection << G4endl
<< " Solid: " << motherSolid->GetName() << G4endl;
motherSolid->DumpInfo();
G4Exception("G4ParameterisedNavigation::ComputeStep()",
@@ -432,13 +404,10 @@ G4ParameterisedNavigation::ComputeSafety(const G4ThreeVector& localPoint,
// daughter of the mother volume
//
samplePhysical = motherLogical->GetDaughter(0);
samplePhysical->GetReplicationData(axis, nReplicas, width, offset, consuming);
samplePhysical->GetReplicationData(axis, nReplicas,
width, offset, consuming);
sampleParam = samplePhysical->GetParameterisation();
// Check development
// G4cerr << "DebugLOG - G4ParameterisedNavigation::ComputeSafety()" << G4endl
// << " Current solid " << motherSolid->GetName() << G4endl;
// Look inside the current Voxel only at the current point
//
if ( axis==kUndefined ) // 3D case: current voxel node is retrieved
@@ -447,8 +416,8 @@ G4ParameterisedNavigation::ComputeSafety(const G4ThreeVector& localPoint,
}
else // 1D case: current voxel node is computed here.
{
curVoxelNodeNo = G4int((localPoint(fVoxelAxis)-fVoxelHeader->GetMinExtent())
/ fVoxelSliceWidth );
curVoxelNodeNo = G4int((localPoint(fVoxelAxis)
-fVoxelHeader->GetMinExtent()) / fVoxelSliceWidth );
curVoxelNode = fVoxelHeader->GetSlice(curVoxelNodeNo)->GetNode();
fVoxelNodeNo = curVoxelNodeNo;
fVoxelNode = curVoxelNode;
@@ -460,10 +429,8 @@ G4ParameterisedNavigation::ComputeSafety(const G4ThreeVector& localPoint,
sampleNo = curVoxelNode->GetVolume(contentNo);
// Call virtual methods, and copy information if needed
sampleSolid= IdentifyAndPlaceSolid( sampleNo, samplePhysical, sampleParam );
// sampleSolid = sampleParam->ComputeSolid(sampleNo, samplePhysical);
// sampleSolid->ComputeDimensions(sampleParam, sampleNo, samplePhysical);
// sampleParam->ComputeTransformation(sampleNo, samplePhysical);
//
sampleSolid= IdentifyAndPlaceSolid( sampleNo,samplePhysical,sampleParam );
G4AffineTransform sampleTf(samplePhysical->GetRotation(),
samplePhysical->GetTranslation());
@@ -496,14 +463,13 @@ G4double G4ParameterisedNavigation::
ComputeVoxelSafety(const G4ThreeVector& localPoint,
const EAxis pAxis) const
{
// Check development
// G4cout << "DebugLOG - G4ParameterisedNavigation::ComputeVoxelSafety()" << G4endl;
// If no best axis is specified, adopt default
// strategy as for placements
//
if ( pAxis==kUndefined )
{
return G4VoxelNavigation::ComputeVoxelSafety(localPoint);
}
G4double voxelSafety, plusVoxelSafety, minusVoxelSafety;
G4double curNodeOffset, minCurCommonDelta, maxCurCommonDelta;
@@ -551,9 +517,12 @@ LocateNextVoxel( const G4ThreeVector& localPoint,
// location strategy as for placements
//
if ( pAxis==kUndefined )
{
return G4VoxelNavigation::LocateNextVoxel(localPoint,
localDirection,
currentStep);
}
G4bool isNewVoxel;
G4int newNodeNo;
G4double minVal, maxVal, curMinExtent, curCoord;
@@ -626,20 +595,14 @@ G4ParameterisedNavigation::LevelLocate( G4NavigationHistory& history,
motherVoxelNode = ParamVoxelLocate(motherVoxelHeader,localPoint);
voxelNoDaughters = motherVoxelNode->GetNoContained();
if ( voxelNoDaughters==0 ) return false;
if ( voxelNoDaughters==0 ) { return false; }
pPhysical = motherLogical->GetDaughter(0);
pParam = pPhysical->GetParameterisation();
// Check development
// G4cerr << "DebugLOG - G4ParameterisedNavigation::LevelLocate() "
// << " Current solid "
// << motherLogical->GetSolid()->GetName() << G4endl;
// G4cerr << " Attaching parent touchable information to Phys Volume "
// << G4endl;
// Save parent history in touchable history
// ... for use as parent t-h in ComputeMaterial method of param
//
G4TouchableHistory parentTouchable( history );
// Search replicated daughter volume
@@ -651,21 +614,14 @@ G4ParameterisedNavigation::LevelLocate( G4NavigationHistory& history,
{
// Obtain solid (as it can vary) and obtain its parameters
//
// pSolid = pParam->ComputeSolid(replicaNo, pPhysical);
// pSolid->ComputeDimensions(pParam, replicaNo, pPhysical);
// pParam->ComputeTransformation(replicaNo, pPhysical);
// Call virtual methods, and copy information if needed
pSolid= IdentifyAndPlaceSolid( replicaNo, pPhysical, pParam );
pSolid = IdentifyAndPlaceSolid( replicaNo, pPhysical, pParam );
// Setup history
//
history.NewLevel(pPhysical, kParameterised, replicaNo);
samplePoint = history.GetTopTransform().TransformPoint(globalPoint);
if ( !G4AuxiliaryNavServices::CheckPointOnSurface(pSolid,
samplePoint, globalDirection,
history.GetTopTransform(), pLocatedOnEdge) )
if ( !G4AuxiliaryNavServices::CheckPointOnSurface( pSolid, samplePoint,
globalDirection, history.GetTopTransform(), pLocatedOnEdge) )
{
history.BackLevel();
}
@@ -683,14 +639,11 @@ G4ParameterisedNavigation::LevelLocate( G4NavigationHistory& history,
//
G4LogicalVolume *pLogical = pPhysical->GetLogicalVolume();
pLogical->SetSolid(pSolid);
pLogical->UpdateMaterial(
pParam->ComputeMaterial(replicaNo, pPhysical, &parentTouchable) );
pLogical->UpdateMaterial(pParam->ComputeMaterial(replicaNo,
pPhysical, &parentTouchable) );
return true;
}
}
}
return false;
}
File diff suppressed because it is too large Load Diff
+378
View File
@@ -0,0 +1,378 @@
//
// ********************************************************************
// * 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: G4PhantomParameterisation.cc,v 1.2 2007/12/10 16:29:59 gunter Exp $
// GEANT4 tag $ Name:$
//
// class G4PhantomParameterisation implementation
//
// Author: Pedro Arce, May 2007
//
// --------------------------------------------------------------------
#include "G4PhantomParameterisation.hh"
#include "globals.hh"
#include "G4VSolid.hh"
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4VVolumeMaterialScanner.hh"
#include "G4GeometryTolerance.hh"
//------------------------------------------------------------------
G4PhantomParameterisation::G4PhantomParameterisation()
{
// Initialise data
//
fMaterialIndices = 0;
fContainerWallX = 0.;
fContainerWallY = 0.;
fContainerWallZ = 0.;
kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
bSkipEqualMaterials = 1;
}
//------------------------------------------------------------------
G4PhantomParameterisation::~G4PhantomParameterisation()
{
}
//------------------------------------------------------------------
void G4PhantomParameterisation::
BuildContainerSolid( G4VPhysicalVolume *pMotherPhysical )
{
fContainerSolid = pMotherPhysical->GetLogicalVolume()->GetSolid();
fContainerWallX = fNoVoxelX * fVoxelHalfX;
fContainerWallY = fNoVoxelY * fVoxelHalfY;
fContainerWallZ = fNoVoxelZ * fVoxelHalfZ;
// CheckVoxelsFillContainer();
}
//------------------------------------------------------------------
void G4PhantomParameterisation::
ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol ) const
{
// Voxels cannot be rotated, return translation
//
G4ThreeVector trans = GetTranslation( copyNo );
physVol->SetTranslation( trans );
}
//------------------------------------------------------------------
G4ThreeVector G4PhantomParameterisation::
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;
}
//------------------------------------------------------------------
G4VSolid* G4PhantomParameterisation::
ComputeSolid(const G4int, G4VPhysicalVolume *pPhysicalVol)
{
return pPhysicalVol->GetLogicalVolume()->GetSolid();
}
//------------------------------------------------------------------
G4Material* G4PhantomParameterisation::
ComputeMaterial(const G4int copyNo, G4VPhysicalVolume *, const G4VTouchable *)
{
CheckCopyNo( copyNo );
size_t matIndex = GetMaterialIndex(copyNo);
return fMaterials[ matIndex ];
}
//------------------------------------------------------------------
size_t G4PhantomParameterisation::
GetMaterialIndex( size_t copyNo ) const
{
CheckCopyNo( copyNo );
return *(fMaterialIndices+copyNo);
}
//------------------------------------------------------------------
size_t G4PhantomParameterisation::
GetMaterialIndex( size_t nx, size_t ny, size_t nz ) const
{
size_t copyNo = nx + fNoVoxelX*ny + fNoVoxelXY*nz;
return GetMaterialIndex( copyNo );
}
//------------------------------------------------------------------
G4Material* G4PhantomParameterisation::GetMaterial( size_t nx, size_t ny, size_t nz) const
{
return fMaterials[GetMaterialIndex(nx,ny,nz)];
}
//------------------------------------------------------------------
G4Material* G4PhantomParameterisation::GetMaterial( size_t copyNo ) const
{
return fMaterials[GetMaterialIndex(copyNo)];
}
//------------------------------------------------------------------
void G4PhantomParameterisation::
ComputeVoxelIndices(const G4int copyNo, size_t& nx,
size_t& ny, size_t& nz ) const
{
CheckCopyNo( copyNo );
nx = size_t(copyNo%fNoVoxelX);
ny = size_t( (copyNo/fNoVoxelX)%fNoVoxelY );
nz = size_t(copyNo/fNoVoxelXY);
}
//------------------------------------------------------------------
void G4PhantomParameterisation::
CheckVoxelsFillContainer( G4double contX, G4double contY, G4double contZ ) const
{
G4double toleranceForWarning = 0.25*kCarTolerance;
// Any bigger value than 0.25*kCarTolerance will give a warning in
// G4NormalNavigation::ComputeStep(), because the Inverse of a container
// translation that is Z+epsilon gives -Z+epsilon (and the maximum tolerance
// in G4Box::Inside is 0.5*kCarTolerance
//
G4double toleranceForError = 1.*kCarTolerance;
// Any bigger value than kCarTolerance will give an error in GetReplicaNo()
//
if( std::fabs(contX-fNoVoxelX*fVoxelHalfX) >= toleranceForError
|| std::fabs(contY-fNoVoxelY*fVoxelHalfY) >= toleranceForError
|| std::fabs(contZ-fNoVoxelZ*fVoxelHalfZ) >= toleranceForError )
{
G4cerr << "ERROR - G4PhantomParameterisation::CheckVoxelsFillContainer()"
<< G4endl
<< " Voxels do not fully fill the container: "
<< fContainerSolid->GetName() << G4endl
<< " DiffX= " << contX-fNoVoxelX*fVoxelHalfX << G4endl
<< " DiffY= " << contY-fNoVoxelY*fVoxelHalfY << G4endl
<< " DiffZ= " << contZ-fNoVoxelZ*fVoxelHalfZ << G4endl
<< " Maximum difference is: " << toleranceForError << G4endl;
G4Exception("G4PhantomParameterisation::CheckVoxelsFillContainer()",
"InvalidSetup", FatalException,
"Voxels do not fully fill the container!");
}
else if( std::fabs(contX-fNoVoxelX*fVoxelHalfX) >= toleranceForWarning
|| std::fabs(contY-fNoVoxelY*fVoxelHalfY) >= toleranceForWarning
|| std::fabs(contZ-fNoVoxelZ*fVoxelHalfZ) >= toleranceForWarning )
{
G4cerr << "WARNING - G4PhantomParameterisation::CheckVoxelsFillContainer()"
<< G4endl
<< " Voxels do not fully fill the container: "
<< fContainerSolid->GetName() << G4endl
<< " DiffX= " << contX-fNoVoxelX*fVoxelHalfX << G4endl
<< " DiffY= " << contY-fNoVoxelY*fVoxelHalfY << G4endl
<< " DiffZ= " << contZ-fNoVoxelZ*fVoxelHalfZ << G4endl
<< " Maximum difference is: " << toleranceForWarning
<< G4endl;
G4Exception("G4PhantomParameterisation::CheckVoxelsFillContainer()",
"InvalidSetup", JustWarning,
"Voxels do not fully fill the container!");
}
}
//------------------------------------------------------------------
G4int G4PhantomParameterisation::
GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
{
// Check first that point is really inside voxels
//
if( fContainerSolid->Inside( localPoint ) == kOutside )
{
G4cerr << "ERROR - G4PhantomParameterisation::GetReplicaNo()" << G4endl
<< " localPoint - " << localPoint
<< " - is outside container solid: "
<< fContainerSolid->GetName() << G4endl;
G4Exception("G4PhantomParameterisation::GetReplicaNo()", "InvalidSetup",
FatalErrorInArgument, "Point outside voxels!");
}
// 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...).
// NOTE: Sometimes this algorithm gives nx = -1, 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( fy - ny < kCarTolerance/fVoxelHalfY )
{
if( localDir.y() < 0 )
{
if( ny != 0 )
{
ny -= 1;
}
else
{
}
}
}
if( fz - nz < kCarTolerance/fVoxelHalfZ )
{
if( localDir.z() < 0 )
{
if( nz != 0 )
{
nz -= 1;
}
else
{
}
}
}
G4int copyNo = nx + fNoVoxelX*ny + fNoVoxelXY*nz;
// Correct precision problems
//
if( copyNo < 0 || copyNo >= G4int(fNoVoxel) )
{
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 - G4PhantomParameterisation::GetReplicaNo()" << G4endl
<< " LocalPoint: " << localPoint << G4endl
<< " Voxel container size: " << fContainerWallX
<< " " << fContainerWallY << " " << fContainerWallZ << G4endl;
G4Exception("G4PhantomParameterisation::GetReplicaNo()",
"Wrong-copy-number", JustWarning,
"Corrected the copy numbe! It was negative or too big");
copyNo = nx + fNoVoxelX*ny + fNoVoxelXY*nz;
}
}
CheckCopyNo( copyNo ); // not needed, just for debugging code
return copyNo;
}
//------------------------------------------------------------------
void G4PhantomParameterisation::CheckCopyNo( const G4int copyNo ) const
{
if( copyNo < 0 || copyNo >= G4int(fNoVoxel) )
{
G4cerr << "ERROR - G4PhantomParameterisation::CheckCopyNo()" << G4endl
<< " Copy number: " << copyNo << G4endl
<< " Total number of voxels: " << fNoVoxel << G4endl;
G4Exception("G4PhantomParameterisation::CheckCopyNo()",
"Wrong-copy-number", FatalErrorInArgument,
"Copy number is negative or too big!");
}
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PropagatorInField.cc,v 1.35 2007/06/08 10:05:46 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-00 $
// $Id: G4PropagatorInField.cc,v 1.40 2007/11/16 09:39:14 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
//
// This class implements an algorithm to track a particle in a
@@ -506,6 +506,21 @@ G4PropagatorInField::LocateIntersectionPoint(
G4int depth=0; // Depth counts how many subdivisions of initial step made
#ifdef G4DEBUG_FIELD
static G4double tolerance= 1.0e-8;
G4ThreeVector StartPosition= CurveStartPointVelocity.GetPosition();
if( (TrialPoint - StartPosition).mag() < tolerance * mm )
{
G4cerr << "WARNING - G4PropagatorInField::LocateIntersectionPoint()"
<< G4endl
<< " Intermediate F point is on top of starting point A."
<< G4endl;
G4Exception("G4PropagatorInField::LocateIntersectionPoint()",
"IntersectionPointIsAtStart", JustWarning,
"Intersection point F is exactly at start point A." );
}
#endif
// Intermediates Points on the Track = Subdivided Points must be stored.
// Give the initial values to 'InterMedFt'
// Important is 'ptrInterMedFT[0]', it saves the 'EndCurvePoint'
@@ -520,7 +535,6 @@ G4PropagatorInField::LocateIntersectionPoint(
//
G4FieldTrack SubStart_PointVelocity = CurveStartPointVelocity;
do
{
G4int substep_no_p = 0;
@@ -542,11 +556,13 @@ G4PropagatorInField::LocateIntersectionPoint(
// The above method is the key & most intuitive part ...
#ifdef G4DEBUG_FIELD
`` if( ApproxIntersecPointV.GetCurveLength() >
CurrentB_PointVelocity.GetCurveLength() * (1.0 + kAngTolerance) )
if( ApproxIntersecPointV.GetCurveLength() >
CurrentB_PointVelocity.GetCurveLength() * (1.0 + tolerance) )
{
G4cerr << "Error - Intermediate F point is more advanced than endpoint B."
<< G4endl;
G4cerr << "ERROR - G4PropagatorInField::LocateIntersectionPoint()"
<< G4endl
<< " Intermediate F point is more advanced than"
<< " endpoint B." << G4endl;
G4Exception("G4PropagatorInField::LocateIntersectionPoint()",
"IntermediatePointConfusion", FatalException,
"Intermediate F point is past end B point" );
@@ -723,14 +739,17 @@ G4PropagatorInField::LocateIntersectionPoint(
}
if( curveDist < 0.0 )
{
G4cerr << "G4PropagatorInField::LocateIntersectionPoint():" << G4endl
<< "Error in advancing propagation." << G4endl;
G4cerr << "ERROR - G4PropagatorInField::LocateIntersectionPoint()"
<< G4endl
<< " Error in advancing propagation." << G4endl;
fVerboseLevel = 5; // Print out a maximum of information
printStatus( CurrentA_PointVelocity, CurrentB_PointVelocity,
-1.0, NewSafety, substep_no, 0 );
G4cerr << " Point A (start) is " << CurrentA_PointVelocity << G4endl;
G4cerr << " Point B (end) is " << CurrentB_PointVelocity << G4endl;
G4cerr << " curveDist is " << curveDist << G4endl;
G4cerr << " Point A (start) is " << CurrentA_PointVelocity
<< G4endl;
G4cerr << " Point B (end) is " << CurrentB_PointVelocity
<< G4endl;
G4cerr << " Curve distance is " << curveDist << G4endl;
G4cerr << G4endl
<< "The final curve point is not further along"
<< " than the original!" << G4endl;
@@ -1248,15 +1267,15 @@ ReEstimateEndpoint( const G4FieldTrack &CurrentStateA,
#endif
#ifdef G4DEBUG_FIELD
G4double lengthDone= newEndPoint.GetCurveLength()
- CurrentStateA.GetCurveLength();
G4double lengthDone = newEndPoint.GetCurveLength()
- CurrentStateA.GetCurveLength();
if( !goodAdvance )
{
if( fVerboseLevel >= 3 )
{
G4cout << MethodName << "> AccurateAdvance failed " ;
G4cout << " in " << itrial << " integration trials/steps. " << G4endl
G4cout << " It went only " << lengthDone << " instead of " << curveDist
G4cout << " in " << itrial << " integration trials/steps. " << G4endl;
G4cout << " It went only " << lengthDone << " instead of " << curveDist
<< " -- a difference of " << curveDist - lengthDone << G4endl;
G4cout << " ReEstimateEndpoint> Reset endPoint to original value!"
<< G4endl;
@@ -1366,17 +1385,17 @@ FindAndSetFieldManager( G4VPhysicalVolume* pCurrentPhysicalVolume)
return currentFieldMgr;
}
G4int G4PropagatorInField::SetVerboseLevel( G4int Verbose )
G4int G4PropagatorInField::SetVerboseLevel( G4int level )
{
G4int oldval= fVerboseLevel;
fVerboseLevel= Verbose;
fVerboseLevel= level;
// Forward the verbose level 'reduced' to ChordFinder,
// MagIntegratorDriver ... ?
//
G4MagInt_Driver* integrDriver= GetChordFinder()->GetIntegrationDriver();
integrDriver->SetVerboseLevel( Verbose - 2 );
G4cout << "Set Driver verbosity to " << Verbose - 2 << G4endl;
integrDriver->SetVerboseLevel( fVerboseLevel - 2 );
G4cout << "Set Driver verbosity to " << fVerboseLevel - 2 << G4endl;
return oldval;
}
+350
View File
@@ -0,0 +1,350 @@
//
// ********************************************************************
// * 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: G4RegularNavigation.cc,v 1.7 2007/12/10 16:30:01 gunter Exp $
// GEANT4 tag $ Name:$
//
// class G4RegularNavigation implementation
//
// Author: Pedro Arce, May 2007
//
// --------------------------------------------------------------------
#include "G4RegularNavigation.hh"
#include "G4TouchableHistory.hh"
#include "G4PhantomParameterisation.hh"
#include "G4Material.hh"
#include "G4NormalNavigation.hh"
#include "G4Navigator.hh"
#include "G4GeometryTolerance.hh"
//------------------------------------------------------------------
G4RegularNavigation::G4RegularNavigation()
: fVerbose(1), fCheck(true)
{
kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
}
//------------------------------------------------------------------
G4RegularNavigation::~G4RegularNavigation()
{
}
//------------------------------------------------------------------
G4double G4RegularNavigation::
ComputeStep(const G4ThreeVector& localPoint,
const G4ThreeVector& localDirection,
const G4double currentProposedStepLength,
G4double& newSafety,
G4NavigationHistory& history,
G4bool& validExitNormal,
G4ThreeVector& exitNormal,
G4bool& exiting,
G4bool& entering,
G4VPhysicalVolume *(*pBlockedPhysical),
G4int& blockedReplicaNo)
{
// This method is never called because to be called the daughter has to be
// a regular structure. This would only happen if the track is in the mother
// of voxels volume. But the voxels fill completely their mother, so when a
// track enters the mother it automatically enters a voxel. Only precision
// problems would make this method to be called
G4ThreeVector globalPoint =
history.GetTopTransform().Inverse().TransformPoint(localPoint);
G4ThreeVector globalDirection =
history.GetTopTransform().Inverse().TransformAxis(localDirection);
G4ThreeVector localPoint2 = localPoint; // take away constantness
LevelLocate( history, *pBlockedPhysical, blockedReplicaNo,
globalPoint, &globalDirection, true, localPoint2 );
// Get in which voxel it is
//
G4VPhysicalVolume *motherPhysical, *daughterPhysical;
G4LogicalVolume *motherLogical;
motherPhysical = history.GetTopVolume();
motherLogical = motherPhysical->GetLogicalVolume();
daughterPhysical = motherLogical->GetDaughter(0);
G4PhantomParameterisation * daughterParam =
(G4PhantomParameterisation*)(daughterPhysical->GetParameterisation());
G4int copyNo = daughterParam ->GetReplicaNo(localPoint,localDirection);
G4ThreeVector voxelTranslation = daughterParam->GetTranslation( copyNo );
G4ThreeVector daughterPoint = localPoint - voxelTranslation;
// Compute step in voxel
//
return fnormalNav->ComputeStep(daughterPoint,
localDirection,
currentProposedStepLength,
newSafety,
history,
validExitNormal,
exitNormal,
exiting,
entering,
pBlockedPhysical,
blockedReplicaNo);
}
//------------------------------------------------------------------
G4double G4RegularNavigation::ComputeStepSkippingEqualMaterials(
G4ThreeVector localPoint,
const G4ThreeVector& localDirection,
const G4double currentProposedStepLength,
G4double& newSafety,
G4NavigationHistory& history,
G4bool& validExitNormal,
G4ThreeVector& exitNormal,
G4bool& exiting,
G4bool& entering,
G4VPhysicalVolume *(*pBlockedPhysical),
G4int& blockedReplicaNo,
G4VPhysicalVolume* pCurrentPhysical)
{
G4PhantomParameterisation *param =
(G4PhantomParameterisation*)(pCurrentPhysical->GetParameterisation());
if( !param->SkipEqualMaterials() ) {
return fnormalNav->ComputeStep(localPoint,
localDirection,
currentProposedStepLength,
newSafety,
history,
validExitNormal,
exitNormal,
exiting,
entering,
pBlockedPhysical,
blockedReplicaNo);
}
G4double ourStep = 0.;
// To get replica No: transform local point to the reference system of the
// param container volume
//
G4int ide = history.GetDepth();
G4ThreeVector containerPoint = history.GetTransform(ide).Inverse().TransformPoint(localPoint);
// Point in global frame
//
containerPoint = history.GetTransform(ide).Inverse().TransformPoint(localPoint);
// Point in voxel parent volume frame
//
containerPoint = history.GetTransform(ide-1).TransformPoint(containerPoint);
// Store previous voxel translation to move localPoint by the difference
// with the new one
//
G4ThreeVector prevVoxelTranslation = containerPoint - localPoint;
// Do not use the expression below: There are cases where the
// fLastLocatedPointLocal does not give the correct answer
// (particle reaching a wall and bounced back, particle travelling through
// the wall that is deviated in an step, ...; these are pathological cases
// that give wrong answers in G4PhantomParameterisation::GetReplicaNo()
//
// G4ThreeVector prevVoxelTranslation = param->GetTranslation( copyNo );
G4int copyNo = param->GetReplicaNo(containerPoint,localDirection);
G4Material* currentMate = param->ComputeMaterial( copyNo, 0, 0 );
G4VSolid* voxelBox = pCurrentPhysical->GetLogicalVolume()->GetSolid();
G4VSolid* containerSolid = param->GetContainerSolid();
G4Material* nextMate;
G4bool bLocatedOnEdge = false;
G4bool bFirstStep = true;
G4double newStep;
G4double totalNewStep = 0.;
// Loop while same material is found
//
for( ;; )
{
newStep = voxelBox->DistanceToOut( localPoint, localDirection );
if( (bFirstStep) && (newStep < currentProposedStepLength) )
{
exiting = true;
}
bFirstStep = false;
newStep += kCarTolerance; // Avoid precision problems
ourStep += newStep;
totalNewStep += newStep;
// Physical process is limiting the step, don't continue
//
if(std::fabs(totalNewStep-currentProposedStepLength) < kCarTolerance)
{
return currentProposedStepLength;
}
// Move container point until wall of voxel
//
containerPoint += newStep*localDirection;
if( containerSolid->Inside( containerPoint ) != kInside )
{
bLocatedOnEdge = true; // NEEDED??
break;
}
// Get copyNo and translation of new voxel
//
copyNo = param->GetReplicaNo(containerPoint,localDirection);
G4ThreeVector voxelTranslation = param->GetTranslation( copyNo );
// Move local point until wall of voxel and then put it in the new voxel
// local coordinates
//
localPoint += newStep*localDirection;
localPoint += prevVoxelTranslation - voxelTranslation;
prevVoxelTranslation = voxelTranslation;
// Check if material of next voxel is the same as that of the current voxel
nextMate = param->ComputeMaterial( copyNo, 0, 0 );
if( currentMate != nextMate ) { break; }
}
return ourStep;
}
//------------------------------------------------------------------
G4double
G4RegularNavigation::ComputeSafety(const G4ThreeVector& localPoint,
const G4NavigationHistory& history,
const G4double pMaxLength)
{
// This method is never called because to be called the daughter has to be a
// regular structure. This would only happen if the track is in the mother of
// voxels volume. But the voxels fill completely their mother, so when a
// track enters the mother it automatically enters a voxel. Only precision
// problems would make this method to be called
// Compute step in voxel
//
return fnormalNav->ComputeSafety(localPoint,
history,
pMaxLength );
}
//------------------------------------------------------------------
G4bool
G4RegularNavigation::LevelLocate( G4NavigationHistory& history,
const G4VPhysicalVolume* ,
const G4int ,
const G4ThreeVector& globalPoint,
const G4ThreeVector* globalDirection,
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
//
G4TouchableHistory parentTouchable( history );
// Get local direction
//
if( globalDirection )
{
localDir = history.GetTopTransform().TransformAxis(*globalDirection);
}
else
{
localDir = G4ThreeVector(0.,0.,0.);
}
// Check that track is not on the surface and check that track is not
// exiting the voxel parent volume
//
if ( !G4AuxiliaryNavServices::CheckPointOnSurface(pSolid, localPoint,
globalDirection, history.GetTopTransform(), pLocatedOnEdge)
|| G4AuxiliaryNavServices::CheckPointExiting(pSolid, localPoint,
globalDirection, history.GetTopTransform() ) )
{
}
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);
history.NewLevel(pPhysical, kParameterised, replicaNo );
localPoint = history.GetTopTransform().TransformPoint(globalPoint);
// Set the correct solid and material in Logical Volume
//
G4LogicalVolume *pLogical = pPhysical->GetLogicalVolume();
pLogical->UpdateMaterial(pParam->ComputeMaterial(replicaNo,
pPhysical, &parentTouchable) );
return true;
}
return false;
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4ReplicaNavigation.cc,v 1.13 2007/05/18 07:31:03 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-00 $
// $Id: G4ReplicaNavigation.cc,v 1.17 2007/11/16 09:39:14 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
//
// class G4ReplicaNavigation Implementation
@@ -206,11 +206,13 @@ G4ReplicaNavigation::DistanceToOut(const G4VPhysicalVolume *pVol,
case kPhi:
if ( localPoint.y()<=0 )
{
safety = localPoint.x()*std::sin(width*0.5)+localPoint.y()*std::cos(width*0.5);
safety = localPoint.x()*std::sin(width*0.5)
+ localPoint.y()*std::cos(width*0.5);
}
else
{
safety = localPoint.x()*std::sin(width*0.5)-localPoint.y()*std::cos(width*0.5);
safety = localPoint.x()*std::sin(width*0.5)
- localPoint.y()*std::cos(width*0.5);
}
break;
case kRho:
@@ -268,12 +270,12 @@ G4ReplicaNavigation::DistanceToOut(const G4VPhysicalVolume *pVol,
if ( Comp>0 )
{
lindist = width*0.5-coord;
Dist = (lindist>kCarTolerance*0.5) ? lindist/Comp : 0;
Dist = (lindist>0) ? lindist/Comp : 0;
}
else if ( Comp<0 )
{
lindist = width*0.5+coord;
Dist = (lindist>kCarTolerance*0.5) ? -lindist/Comp : 0;
Dist = (lindist>0) ? -lindist/Comp : 0;
}
else
{
@@ -757,6 +759,13 @@ G4ReplicaNavigation::ComputeStep(const G4ThreeVector &globalPoint,
motherStep = motherSolid->DistanceToOut(repPoint,repDirection,true,
&validExitNormal,&exitNormal);
// Push in principle no longer necessary. G4Navigator now takes care of ...
// Removing this will however generate warnings for pushed particles from
// G4Navigator, particularly for the case of 3D replicas (Cartesian or
// combined Radial/Phi cases).
// Requires further investigation and eventually reimplementation of
// LevelLocate() to take into account point and direction ...
//
if ( ( !ourStep && (sampleSafety<0.5*kCarTolerance) )
&& ( repLogical->GetSolid()->Inside(localPoint)==kSurface ) )
{
@@ -833,20 +842,20 @@ G4ReplicaNavigation::ComputeStep(const G4ThreeVector &globalPoint,
sampleTf.TransformPoint(localPoint);
const G4VSolid* sampleSolid =
samplePhysical->GetLogicalVolume()->GetSolid();
const G4double sampleSafety =
const G4double sampleSafetyDistance =
sampleSolid->DistanceToIn(samplePoint);
if ( sampleSafety<ourSafety )
if ( sampleSafetyDistance<ourSafety )
{
ourSafety = sampleSafety;
ourSafety = sampleSafetyDistance;
}
if ( sampleSafety<=ourStep )
if ( sampleSafetyDistance<=ourStep )
{
sampleDirection = sampleTf.TransformAxis(localDirection);
const G4double sampleStep =
const G4double sampleStepDistance =
sampleSolid->DistanceToIn(samplePoint,sampleDirection);
if ( sampleStep<=ourStep )
if ( sampleStepDistance<=ourStep )
{
ourStep = sampleStep;
ourStep = sampleStepDistance;
entering = true;
exiting = false;
*pBlockedPhysical = samplePhysical;
@@ -855,10 +864,11 @@ G4ReplicaNavigation::ComputeStep(const G4ThreeVector &globalPoint,
// 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 ) && ( sampleStepDistance < kInfinity ) )
{
G4ThreeVector intersectionPoint;
intersectionPoint= samplePoint + sampleStep * sampleDirection;
intersectionPoint= samplePoint
+ sampleStepDistance * sampleDirection;
EInside insideIntPt= sampleSolid->Inside(intersectionPoint);
if ( insideIntPt != kSurface )
{
@@ -867,8 +877,8 @@ G4ReplicaNavigation::ComputeStep(const G4ThreeVector &globalPoint,
<< G4endl
<< " Inaccurate DistanceToIn for solid "
<< sampleSolid->GetName() << G4endl;
G4cout << " Solid gave DistanceToIn = " << sampleStep
<< " yet returns " ;
G4cout << " Solid gave DistanceToIn = "
<< sampleStepDistance << " yet returns " ;
if ( insideIntPt == kInside )
G4cout << "-kInside-";
else if ( insideIntPt == kOutside )
@@ -979,11 +989,11 @@ G4ReplicaNavigation::ComputeSafety(const G4ThreeVector &globalPoint,
sampleTf.TransformPoint(localPoint);
const G4VSolid *sampleSolid =
samplePhysical->GetLogicalVolume()->GetSolid();
const G4double sampleSafety =
const G4double sampleSafetyDistance =
sampleSolid->DistanceToIn(samplePoint);
if ( sampleSafety<ourSafety )
if ( sampleSafetyDistance<ourSafety )
{
ourSafety = sampleSafety;
ourSafety = sampleSafetyDistance;
}
}
}
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4SafetyHelper.cc,v 1.12 2007/05/09 12:57:31 japost Exp $
// $Id: G4SafetyHelper.cc,v 1.15 2007/11/14 10:04:21 gcosmo Exp $
// GEANT4 tag $ Name: $
//
// class G4SafetyHelper Implementation
@@ -39,17 +39,18 @@
#include "globals.hh"
G4SafetyHelper::G4SafetyHelper() :
fUseParallelGeometries(false), // By default, one geometry only
fFirstCall(true),
fLastSafetyPosition(0.0,0.0,0.0),
fLastSafety(0.0),
fRecomputeFactor(0.2)
G4SafetyHelper::G4SafetyHelper()
: fUseParallelGeometries(false), // By default, one geometry only
fFirstCall(true),
fLastSafetyPosition(0.0,0.0,0.0),
fLastSafety(0.0),
fRecomputeFactor(0.0)
{
fpPathFinder= 0; // Cannot initialise this yet - a loop results
// Initialization of the Navigator pointer is postponed, and must
// be undertaken by another class calling InitialiseHelper()
// be undertaken by another class calling InitialiseHelper()
//
fpMassNavigator= 0;
fMassNavigatorId= -1;
}
@@ -64,6 +65,7 @@ void G4SafetyHelper::InitialiseNavigator()
fpMassNavigator = pTransportMgr->GetNavigatorForTracking();
// Check
//
G4VPhysicalVolume* worldPV = fpMassNavigator->GetWorldVolume();
if( worldPV == 0 )
{
@@ -84,7 +86,8 @@ void G4SafetyHelper::InitialiseHelper()
}
G4SafetyHelper::~G4SafetyHelper()
{}
{
}
G4double
G4SafetyHelper::CheckNextStep(const G4ThreeVector &position,
@@ -103,6 +106,7 @@ G4SafetyHelper::CheckNextStep(const G4ThreeVector &position,
// TO-DO: Can replace this with a call to PathFinder
// giving id of Mass Geometry --> this avoid doing the work twice
return linstep;
}
@@ -110,10 +114,13 @@ G4double G4SafetyHelper::ComputeSafety( const G4ThreeVector& position )
{
G4double newSafety;
// return last value if position is not significantly changed
// Only recompute (calling Navigator/PathFinder) if 'position'
// is *not* the safety location and has moved 'significantly'
//
G4double moveLen = (position-fLastSafetyPosition).mag();
if(moveLen >= fRecomputeFactor*fLastSafety)
G4double moveLengthSq = (position-fLastSafetyPosition).mag2();
G4double safeDistance = fRecomputeFactor*fLastSafety;
if( (moveLengthSq > 0.0 )
&& (moveLengthSq >= safeDistance*safeDistance))
{
fLastSafetyPosition = position;
@@ -131,7 +138,14 @@ G4double G4SafetyHelper::ComputeSafety( const G4ThreeVector& position )
}
else
{
newSafety = fLastSafety-moveLen;
// return last value if position is not significantly changed
//
G4double moveLength = 0;
if( moveLengthSq > 0.0 )
{
moveLength= std::sqrt(moveLengthSq);
}
newSafety = fLastSafety-moveLength;
}
return newSafety;
}
@@ -25,7 +25,7 @@
//
//
// $Id: G4TransportationManager.cc,v 1.15 2007/04/12 11:51:48 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-00 $
// GEANT4 tag $Name: geant4-09-01 $
//
//
// G4TransportationManager
@@ -25,7 +25,7 @@
//
//
// $Id: G4VoxelNavigation.cc,v 1.7 2007/05/11 13:43:59 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-00 $
// GEANT4 tag $Name: geant4-09-01 $
//
//
// class G4VoxelNavigation Implementation