Import Geant4 11.2.0 source tree
This commit is contained in:
@@ -38,7 +38,7 @@
|
||||
#include "G4VVisManager.hh"
|
||||
#include "G4Colour.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4TouchableHistoryHandle.hh"
|
||||
#include "G4TouchableHandle.hh"
|
||||
|
||||
#define voxel_width 0
|
||||
|
||||
@@ -203,7 +203,7 @@ void G4DrawVoxels::DrawVoxels(const G4LogicalVolume* lv) const
|
||||
// (the drawing is directly in the world volume while the axis
|
||||
// are relative to the mother volume of lv's daughter.)
|
||||
|
||||
G4TouchableHistoryHandle aTouchable =
|
||||
G4TouchableHandle aTouchable =
|
||||
G4TransportationManager::GetTransportationManager()->
|
||||
GetNavigatorForTracking()->CreateTouchableHistoryHandle();
|
||||
G4AffineTransform globTransform =
|
||||
|
||||
@@ -179,8 +179,8 @@ G4GeometryMessenger::G4GeometryMessenger(G4TransportationManager* tman)
|
||||
G4GeometryMessenger::~G4GeometryMessenger()
|
||||
{
|
||||
delete verCmd; delete recCmd; delete rslCmd;
|
||||
delete resCmd; delete rcsCmd; delete rcdCmd; delete errCmd;
|
||||
delete tolCmd;
|
||||
delete resCmd; delete rcsCmd; delete rcdCmd;
|
||||
delete errCmd; delete parCmd; delete tolCmd;
|
||||
delete verbCmd; delete pchkCmd; delete chkCmd;
|
||||
delete geodir; delete navdir; delete testdir;
|
||||
for(auto* tvolume: tvolumes) {
|
||||
@@ -258,6 +258,9 @@ G4GeometryMessenger::SetNewValue( G4UIcommand* command, G4String newValues )
|
||||
else if (command == rcdCmd) {
|
||||
recDepth = rcdCmd->GetNewIntValue( newValues );
|
||||
}
|
||||
else if (command == parCmd) {
|
||||
checkParallelWorlds = parCmd->GetNewBoolValue( newValues );
|
||||
}
|
||||
else if (command == errCmd) {
|
||||
Init();
|
||||
for(auto* tvolume: tvolumes)
|
||||
|
||||
@@ -442,8 +442,7 @@ G4double G4MultiNavigator::ComputeSafety( const G4ThreeVector& position,
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
G4TouchableHistoryHandle
|
||||
G4MultiNavigator::CreateTouchableHistoryHandle() const
|
||||
G4TouchableHandle G4MultiNavigator::CreateTouchableHistoryHandle() const
|
||||
{
|
||||
G4Exception( "G4MultiNavigator::CreateTouchableHistoryHandle()",
|
||||
"GeomNav0001", FatalException,
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// class G4Navigator Implementation
|
||||
// G4Navigator class Implementation
|
||||
//
|
||||
// Original author: Paul Kent, July 95/96
|
||||
// Responsible 1996-present: John Apostolakis, Gabriele Cosmo
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
|
||||
#include "G4VoxelSafety.hh"
|
||||
#include "G4SafetyCalculator.hh"
|
||||
|
||||
// Constant determining how precise normals should be (how close to unit
|
||||
// vectors). If exceeded, warnings will be issued.
|
||||
@@ -76,9 +77,9 @@ G4Navigator::G4Navigator()
|
||||
fLastStepEndPointLocal = G4ThreeVector( kInfinity, kInfinity, kInfinity );
|
||||
|
||||
fpVoxelSafety = new G4VoxelSafety();
|
||||
#ifdef ALTERNATIVE_VOXEL_NAV
|
||||
fpvoxelNav = new G4VoxelNavigation();
|
||||
#endif
|
||||
fpSafetyCalculator = new G4SafetyCalculator( *this, fHistory );
|
||||
fpSafetyCalculator->SetExternalNavigation(fpExternalNav);
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
@@ -89,9 +90,8 @@ G4Navigator::~G4Navigator()
|
||||
{
|
||||
delete fpVoxelSafety;
|
||||
delete fpExternalNav;
|
||||
#ifdef ALTERNATIVE_VOXEL_NAV
|
||||
delete fpvoxelNav;
|
||||
#endif
|
||||
delete fpSafetyCalculator;
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
@@ -619,23 +619,14 @@ G4Navigator::LocateGlobalPointWithinVolume(const G4ThreeVector& pGlobalpoint)
|
||||
//
|
||||
G4VPhysicalVolume* motherPhysical = fHistory.GetTopVolume();
|
||||
G4LogicalVolume* motherLogical = motherPhysical->GetLogicalVolume();
|
||||
G4SmartVoxelHeader* pVoxelHeader = motherLogical->GetVoxelHeader();
|
||||
|
||||
switch( CharacteriseDaughters(motherLogical) )
|
||||
{
|
||||
case kNormal:
|
||||
if ( pVoxelHeader != nullptr )
|
||||
{
|
||||
GetVoxelNavigator().VoxelLocate( pVoxelHeader, fLastLocatedPointLocal );
|
||||
}
|
||||
GetVoxelNavigator().RelocateWithinVolume( motherPhysical, fLastLocatedPointLocal );
|
||||
break;
|
||||
case kParameterised:
|
||||
if( GetDaughtersRegularStructureId(motherLogical) != 1 )
|
||||
{
|
||||
// Resets state & returns voxel node
|
||||
//
|
||||
fparamNav.ParamVoxelLocate( pVoxelHeader, fLastLocatedPointLocal );
|
||||
}
|
||||
fparamNav.RelocateWithinVolume( motherPhysical, fLastLocatedPointLocal );
|
||||
break;
|
||||
case kReplica:
|
||||
// Nothing to do
|
||||
@@ -1605,7 +1596,6 @@ G4Navigator::GetLocalExitNormalAndCheck(
|
||||
return GetLocalExitNormal( pValid );
|
||||
}
|
||||
|
||||
|
||||
// ********************************************************************
|
||||
// GetGlobalExitNormal
|
||||
//
|
||||
@@ -1787,151 +1777,38 @@ G4Navigator::GetGlobalExitNormal(const G4ThreeVector& IntersectPointGlobal,
|
||||
//
|
||||
G4double G4Navigator::ComputeSafety( const G4ThreeVector& pGlobalpoint,
|
||||
const G4double pMaxLength,
|
||||
const G4bool keepState)
|
||||
const G4bool )
|
||||
{
|
||||
#ifdef G4DEBUG_NAVIGATION
|
||||
G4int oldcoutPrec = G4cout.precision(8);
|
||||
if( fVerbose > 0 )
|
||||
{
|
||||
G4cout << "*** G4Navigator::ComputeSafety: ***" << G4endl
|
||||
<< " Called at point: " << pGlobalpoint << G4endl;
|
||||
|
||||
G4VPhysicalVolume *motherPhysical = fHistory.GetTopVolume();
|
||||
G4cout << " Volume = " << motherPhysical->GetName()
|
||||
<< " - Maximum length = " << pMaxLength << G4endl;
|
||||
if( fVerbose >= 4 )
|
||||
{
|
||||
G4cout << " ----- Upon entering Compute Safety:" << G4endl;
|
||||
PrintState();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
G4VPhysicalVolume *motherPhysical = fHistory.GetTopVolume();
|
||||
G4double safety = 0.0;
|
||||
|
||||
G4double distEndpointSq = (pGlobalpoint-fStepEndPoint).mag2();
|
||||
G4bool stayedOnEndpoint = distEndpointSq < sqr(kCarTolerance);
|
||||
G4bool endpointOnSurface = fEnteredDaughter || fExitedMother;
|
||||
|
||||
if( endpointOnSurface && stayedOnEndpoint )
|
||||
G4bool onSurface = endpointOnSurface && stayedOnEndpoint;
|
||||
if( ! onSurface )
|
||||
{
|
||||
#ifdef G4DEBUG_NAVIGATION
|
||||
if( fVerbose >= 2 )
|
||||
{
|
||||
G4cout << " G4Navigator::ComputeSafety() finds that point - "
|
||||
<< pGlobalpoint << " - is on surface " << G4endl;
|
||||
if( fEnteredDaughter ) { G4cout << " entered new daughter volume"; }
|
||||
if( fExitedMother ) { G4cout << " and exited previous volume."; }
|
||||
G4cout << G4endl;
|
||||
G4cout << " EndPoint was = " << fStepEndPoint << G4endl;
|
||||
G4cout << " ---- Exiting ComputeSafety " << G4endl;
|
||||
PrintState();
|
||||
G4cout << " Returned value of Safety is zero " << G4endl;
|
||||
G4cout.precision(oldcoutPrec);
|
||||
}
|
||||
#endif
|
||||
return 0.0;
|
||||
}
|
||||
safety= fpSafetyCalculator->SafetyInCurrentVolume(pGlobalpoint, motherPhysical, pMaxLength);
|
||||
// offload to G4SafetyCalculator - avoids need to save / reload state
|
||||
|
||||
G4double newSafety = 0.0;
|
||||
|
||||
if (keepState) { SetSavedState(); }
|
||||
|
||||
// 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 << " 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 )
|
||||
{
|
||||
switch(CharacteriseDaughters(motherLogical))
|
||||
{
|
||||
case kNormal:
|
||||
if ( pVoxelHeader != nullptr )
|
||||
{
|
||||
newSafety = fpVoxelSafety->ComputeSafety(localPoint,
|
||||
*motherPhysical, pMaxLength);
|
||||
// = VoxelNav().ComputeSafety(localPoint,fHistory,pMaxLength); // - Old method
|
||||
}
|
||||
else
|
||||
{
|
||||
newSafety=fnormalNav.ComputeSafety(localPoint,fHistory,pMaxLength);
|
||||
}
|
||||
break;
|
||||
case kParameterised:
|
||||
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()", "GeomNav0001",
|
||||
FatalException, "Not applicable for replicated volumes.");
|
||||
break;
|
||||
case kExternal:
|
||||
newSafety = fpExternalNav->ComputeSafety(localPoint, fHistory,
|
||||
pMaxLength);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newSafety = freplicaNav.ComputeSafety(pGlobalpoint, localPoint,
|
||||
fHistory, pMaxLength);
|
||||
}
|
||||
|
||||
if (keepState)
|
||||
{
|
||||
RestoreSavedState();
|
||||
// This now overwrites the values of the Safety 'sphere' (correction)
|
||||
}
|
||||
|
||||
// Remember last safety origin & value
|
||||
//
|
||||
// We overwrite the Safety 'sphere' - keeping old behaviour
|
||||
fPreviousSftOrigin = pGlobalpoint;
|
||||
fPreviousSafety = newSafety;
|
||||
|
||||
#ifdef G4DEBUG_NAVIGATION
|
||||
if( fVerbose > 1 )
|
||||
{
|
||||
G4cout << " ---- Exiting ComputeSafety " << G4endl;
|
||||
if( fVerbose > 2 ) { PrintState(); }
|
||||
G4cout << " Returned value of Safety = " << newSafety << G4endl;
|
||||
fPreviousSafety = safety;
|
||||
// We overwrite the Safety 'sphere' - keeping old behaviour
|
||||
}
|
||||
G4cout.precision(oldcoutPrec);
|
||||
#endif
|
||||
|
||||
return newSafety;
|
||||
return safety;
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
// CreateTouchableHistoryHandle
|
||||
// ********************************************************************
|
||||
//
|
||||
G4TouchableHistoryHandle G4Navigator::CreateTouchableHistoryHandle() const
|
||||
G4TouchableHandle G4Navigator::CreateTouchableHistoryHandle() const
|
||||
{
|
||||
return { CreateTouchableHistory() };
|
||||
return G4TouchableHandle( CreateTouchableHistory() );
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
@@ -2202,9 +2079,8 @@ std::ostream& operator << (std::ostream &os,const G4Navigator &n)
|
||||
return os;
|
||||
}
|
||||
|
||||
#ifdef ALTERNATIVE_VOXEL_NAV
|
||||
// ********************************************************************
|
||||
// SetVoxelNavigation -- alternative navigator for Voxel geom
|
||||
// SetVoxelNavigation: alternative navigator for voxelised geometry
|
||||
// ********************************************************************
|
||||
//
|
||||
void G4Navigator::SetVoxelNavigation(G4VoxelNavigation* voxelNav)
|
||||
@@ -2212,13 +2088,13 @@ void G4Navigator::SetVoxelNavigation(G4VoxelNavigation* voxelNav)
|
||||
delete fpvoxelNav;
|
||||
fpvoxelNav = voxelNav;
|
||||
}
|
||||
#endif
|
||||
|
||||
// ********************************************************************
|
||||
// InformLastStep: Derived navigators can inform of its step
|
||||
// - used to update fLastStepWasZero
|
||||
// InformLastStep: derived navigators can inform of its step
|
||||
// used to update fLastStepWasZero
|
||||
// ********************************************************************
|
||||
void G4Navigator::InformLastStep(G4double lastStep, G4bool entersDaughtVol, G4bool exitsMotherVol )
|
||||
void G4Navigator::InformLastStep(G4double lastStep, G4bool entersDaughtVol,
|
||||
G4bool exitsMotherVol)
|
||||
{
|
||||
G4bool zeroStep = ( lastStep == 0.0 );
|
||||
fLocatedOnEdge = fLastStepWasZero && zeroStep;
|
||||
@@ -2227,3 +2103,13 @@ void G4Navigator::InformLastStep(G4double lastStep, G4bool entersDaughtVol, G4b
|
||||
fExiting = exitsMotherVol;
|
||||
fEntering = entersDaughtVol;
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
// SetExternalNavigation
|
||||
// ********************************************************************
|
||||
//
|
||||
void G4Navigator::SetExternalNavigation(G4VExternalNavigation* externalNav)
|
||||
{
|
||||
fpExternalNav = externalNav;
|
||||
fpSafetyCalculator->SetExternalNavigation(externalNav);
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@
|
||||
|
||||
#include "G4AuxiliaryNavServices.hh"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
// ********************************************************************
|
||||
// Constructor
|
||||
// ********************************************************************
|
||||
@@ -683,3 +685,16 @@ G4ParameterisedNavigation::LevelLocate( G4NavigationHistory& history,
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void G4ParameterisedNavigation::RelocateWithinVolume( G4VPhysicalVolume* motherPhysical,
|
||||
const G4ThreeVector& localPoint )
|
||||
{
|
||||
auto motherLogical = motherPhysical->GetLogicalVolume();
|
||||
|
||||
/* this should only be called on parameterized volumes, which always satisfy the conditions below */
|
||||
assert(motherPhysical->GetRegularStructureId() != 1);
|
||||
assert(motherLogical->GetNoDaughters() == 1);
|
||||
|
||||
if ( auto pVoxelHeader = motherLogical->GetVoxelHeader() )
|
||||
ParamVoxelLocate( pVoxelHeader, localPoint );
|
||||
}
|
||||
|
||||
@@ -1154,8 +1154,8 @@ G4ReplicaNavigation::ComputeStep(const G4ThreeVector& globalPoint,
|
||||
G4double
|
||||
G4ReplicaNavigation::ComputeSafety(const G4ThreeVector& globalPoint,
|
||||
const G4ThreeVector& localPoint,
|
||||
G4NavigationHistory& history,
|
||||
const G4double )
|
||||
const G4NavigationHistory& history,
|
||||
const G4double ) const
|
||||
{
|
||||
G4VPhysicalVolume *repPhysical, *motherPhysical;
|
||||
G4VPhysicalVolume *samplePhysical, *blockedExitedVol = nullptr;
|
||||
|
||||
@@ -0,0 +1,284 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4SafetyCalculator class Implementation
|
||||
//
|
||||
// Author: John Apostolakis, CERN - February 2023
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4SafetyCalculator.hh"
|
||||
|
||||
#include "G4Navigator.hh"
|
||||
#include "G4GeometryTolerance.hh"
|
||||
|
||||
G4SafetyCalculator::
|
||||
G4SafetyCalculator( const G4Navigator& navigator,
|
||||
const G4NavigationHistory& navHistory )
|
||||
: fNavigator(navigator), fNavHistory(navHistory)
|
||||
{
|
||||
fkCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
// ComputeSafety
|
||||
//
|
||||
// It assumes that it will be
|
||||
// i) called at the Point in the same volume as the EndPoint of the
|
||||
// ComputeStep.
|
||||
// ii) after (or at the end of) ComputeStep OR after the relocation.
|
||||
// ********************************************************************
|
||||
//
|
||||
G4double G4SafetyCalculator::
|
||||
SafetyInCurrentVolume( const G4ThreeVector& pGlobalpoint,
|
||||
G4VPhysicalVolume* physicalVolume,
|
||||
const G4double pMaxLength,
|
||||
G4bool /* verbose */ )
|
||||
{
|
||||
G4double safety = 0.0;
|
||||
G4ThreeVector stepEndPoint = fNavigator.GetLastStepEndPoint();
|
||||
|
||||
G4ThreeVector localPoint = ComputeLocalPoint(pGlobalpoint);
|
||||
|
||||
G4double distEndpointSq = (pGlobalpoint-stepEndPoint).mag2();
|
||||
G4bool stayedOnEndpoint = distEndpointSq < sqr(fkCarTolerance);
|
||||
G4bool endpointOnSurface = fNavigator.EnteredDaughterVolume()
|
||||
|| fNavigator.ExitedMotherVolume();
|
||||
|
||||
G4VPhysicalVolume* motherPhysical = fNavHistory.GetTopVolume();
|
||||
if( motherPhysical != physicalVolume )
|
||||
{
|
||||
std::ostringstream msg;
|
||||
msg << " Current (navigation) phys-volume: " << motherPhysical
|
||||
<< " name= " << motherPhysical->GetName() << G4endl
|
||||
<< " Request made for phys-volume: " << physicalVolume
|
||||
<< " name= " << physicalVolume->GetName() << G4endl;
|
||||
G4Exception("G4SafetyCalculator::SafetyInCurrentVolume", "GeomNav0001",
|
||||
FatalException, msg,
|
||||
"This method must be called only in the Current volume.");
|
||||
}
|
||||
|
||||
if( !(endpointOnSurface && stayedOnEndpoint) )
|
||||
{
|
||||
G4LogicalVolume* motherLogical = motherPhysical->GetLogicalVolume();
|
||||
G4SmartVoxelHeader* pVoxelHeader = motherLogical->GetVoxelHeader();
|
||||
|
||||
// Pseudo-relocate to this point (updates voxel information only)
|
||||
//
|
||||
QuickLocateWithinVolume( localPoint, motherPhysical );
|
||||
//*********************
|
||||
|
||||
// switch(CharacteriseDaughters(motherLogical))
|
||||
auto dtype= CharacteriseDaughters(motherLogical);
|
||||
switch(dtype)
|
||||
{
|
||||
case kNormal:
|
||||
if ( pVoxelHeader )
|
||||
{
|
||||
// New way: best safety
|
||||
safety = fVoxelSafety.ComputeSafety(localPoint,
|
||||
*motherPhysical, pMaxLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
safety=fnormalNav.ComputeSafety(localPoint,fNavHistory,pMaxLength);
|
||||
}
|
||||
break;
|
||||
case kParameterised:
|
||||
if( GetDaughtersRegularStructureId(motherLogical) != 1 )
|
||||
{
|
||||
safety=fparamNav.ComputeSafety(localPoint,fNavHistory,pMaxLength);
|
||||
}
|
||||
else // Regular structure
|
||||
{
|
||||
safety=fregularNav.ComputeSafety(localPoint,fNavHistory,pMaxLength);
|
||||
}
|
||||
break;
|
||||
case kReplica:
|
||||
safety = freplicaNav.ComputeSafety(pGlobalpoint, localPoint,
|
||||
fNavHistory, pMaxLength);
|
||||
break;
|
||||
case kExternal:
|
||||
safety = fpExternalNav->ComputeSafety(localPoint, fNavHistory,
|
||||
pMaxLength);
|
||||
break;
|
||||
}
|
||||
|
||||
// Remember last safety origin & value
|
||||
//
|
||||
fPreviousSftOrigin = pGlobalpoint;
|
||||
fPreviousSafety = safety;
|
||||
}
|
||||
|
||||
return safety;
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
// QuickLocateWithinVolume
|
||||
//
|
||||
// -> the state information of this Navigator and its subNavigators
|
||||
// is updated in order to start the next step at pGlobalpoint
|
||||
// -> no check is performed whether pGlobalpoint is inside the
|
||||
// original volume (this must be the case).
|
||||
//
|
||||
// Note: a direction could be added to the arguments, to aid in future
|
||||
// optional checking (via the old code below, flagged by OLD_LOCATE).
|
||||
// [ This would be done only in verbose mode ]
|
||||
//
|
||||
// Adapted simplied from G4Navigator::LocateGlobalPointWithinVolume()
|
||||
// ********************************************************************
|
||||
//
|
||||
void G4SafetyCalculator::
|
||||
QuickLocateWithinVolume( const G4ThreeVector& pointLocal,
|
||||
G4VPhysicalVolume* motherPhysical )
|
||||
{
|
||||
// For the case of Voxel (or Parameterised) volume the respective
|
||||
// sub-navigator must be messaged to update its voxel information etc
|
||||
|
||||
// Update the state of the Sub Navigators
|
||||
// - in particular any voxel information they store/cache
|
||||
//
|
||||
G4LogicalVolume* motherLogical = motherPhysical->GetLogicalVolume();
|
||||
G4SmartVoxelHeader* pVoxelHeader = motherLogical->GetVoxelHeader();
|
||||
|
||||
switch( CharacteriseDaughters(motherLogical) )
|
||||
{
|
||||
case kNormal:
|
||||
if ( pVoxelHeader )
|
||||
{
|
||||
fvoxelNav.VoxelLocate( pVoxelHeader, pointLocal );
|
||||
}
|
||||
break;
|
||||
case kParameterised:
|
||||
if( GetDaughtersRegularStructureId(motherLogical) != 1 )
|
||||
{
|
||||
// Resets state & returns voxel node
|
||||
//
|
||||
fparamNav.ParamVoxelLocate( pVoxelHeader, pointLocal );
|
||||
}
|
||||
break;
|
||||
case kReplica:
|
||||
// Nothing to do
|
||||
break;
|
||||
case kExternal:
|
||||
fpExternalNav->RelocateWithinVolume( motherPhysical,
|
||||
pointLocal );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
// Accessor for custom external navigation.
|
||||
// ********************************************************************
|
||||
G4VExternalNavigation* G4SafetyCalculator::GetExternalNavigation() const
|
||||
{
|
||||
return fpExternalNav;
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
// Modifier for custom external navigation.
|
||||
// ********************************************************************
|
||||
void G4SafetyCalculator::SetExternalNavigation(G4VExternalNavigation* eNav)
|
||||
{
|
||||
fpExternalNav = eNav;
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
// CompareSafetyValues
|
||||
// ********************************************************************
|
||||
void G4SafetyCalculator::
|
||||
CompareSafetyValues( G4double oldSafety,
|
||||
G4double newValue,
|
||||
G4VPhysicalVolume* motherPhysical,
|
||||
const G4ThreeVector& globalPoint,
|
||||
G4bool keepState,
|
||||
G4double maxLength,
|
||||
G4bool enteredDaughterVol,
|
||||
G4bool exitedMotherVol )
|
||||
{
|
||||
constexpr G4double reportThreshold= 3.0e-14;
|
||||
// At least warn if rel-error exceeds it
|
||||
constexpr G4double errorThreshold= 1.0e-08;
|
||||
// Fatal if relative error is larger
|
||||
constexpr G4double epsilonLen= 1.0e-20;
|
||||
// Baseline minimal value for divisor
|
||||
|
||||
const G4double oldSafetyPlus = std::fabs(oldSafety)+epsilonLen;
|
||||
if( std::fabs( newValue - oldSafety) > reportThreshold * oldSafetyPlus )
|
||||
{
|
||||
G4ExceptionSeverity severity= FatalException;
|
||||
std::ostringstream msg;
|
||||
G4double diff= (newValue-oldSafety);
|
||||
G4double relativeDiff= diff / oldSafetyPlus;
|
||||
|
||||
msg << " New (G4SafetyCalculator) value *disagrees* by relative diff " << relativeDiff
|
||||
<< " in physical volume '" << motherPhysical->GetName() << "' "
|
||||
<< "copy-no = " << motherPhysical->GetCopyNo();
|
||||
if( enteredDaughterVol ) { msg << " ( Just Entered new daughter volume. ) "; }
|
||||
if( exitedMotherVol ) { msg << " ( Just Exited previous volume. ) "; }
|
||||
msg << G4endl;
|
||||
msg << " Safeties: old= " << std::setprecision(12) << oldSafety
|
||||
<< " trial " << newValue
|
||||
<< " new-old= " << std::setprecision(7) << diff << G4endl;
|
||||
|
||||
if( std::fabs(diff) < errorThreshold * ( std::fabs(oldSafety)+1.0e-20 ) )
|
||||
{
|
||||
msg << " (tiny difference) ";
|
||||
severity= JustWarning;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg << " (real difference) ";
|
||||
severity= FatalException;
|
||||
|
||||
// Extra information -- for big errors
|
||||
msg << " NOTE: keepState = " << keepState << G4endl;
|
||||
msg << " Location - Global coordinates: " << globalPoint
|
||||
<< " volume= '" << motherPhysical->GetName() << "'"
|
||||
<< " copy-no= " << motherPhysical->GetCopyNo() << G4endl;
|
||||
msg << " Argument maxLength= " << maxLength << G4endl;
|
||||
|
||||
std::size_t depth= fNavHistory.GetDepth();
|
||||
msg << " Navigation History: depth = " << depth << G4endl;
|
||||
for( G4int i=1; i<(G4int)depth; ++i )
|
||||
{
|
||||
msg << " d= " << i << " " << std::setw(32)
|
||||
<< fNavHistory.GetVolume(i)->GetName()
|
||||
<< " copyNo= " << fNavHistory.GetReplicaNo(i);
|
||||
msg << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef G4DEBUG_NAVIGATION
|
||||
G4double redo= SafetyInCurrentVolume(globalPoint, motherPhysical,
|
||||
maxLength, true);
|
||||
msg << " Redoing estimator: value = " << std::setprecision(16) << redo
|
||||
<< " diff/last= " << std::setprecision(7) << redo - newValue
|
||||
<< " diff/old= " << redo - oldSafety << G4endl;
|
||||
#endif
|
||||
|
||||
G4Exception("G4SafetyCalculator::CompareSafetyValues()", "GeomNav1007",
|
||||
severity, msg);
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "G4AutoDelete.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4VIntersectionLocator.hh"
|
||||
#include "G4TouchableHandle.hh"
|
||||
#include "G4GeometryTolerance.hh"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -686,7 +687,7 @@ LocateGlobalPointWithinVolumeAndCheck( const G4ThreeVector& position )
|
||||
|
||||
// Identify the current volume
|
||||
|
||||
G4TouchableHistoryHandle startTH= nav->CreateTouchableHistoryHandle();
|
||||
G4TouchableHandle startTH= nav->CreateTouchableHistoryHandle();
|
||||
G4VPhysicalVolume* motherPhys = startTH->GetVolume();
|
||||
G4VSolid* motherSolid = startTH->GetSolid();
|
||||
G4AffineTransform transform = nav->GetGlobalToLocalTransform();
|
||||
|
||||
@@ -28,14 +28,15 @@
|
||||
// Author: P.Kent, 1996
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
#include <ostream>
|
||||
|
||||
#include "G4VoxelNavigation.hh"
|
||||
#include "G4GeometryTolerance.hh"
|
||||
#include "G4VoxelSafety.hh"
|
||||
|
||||
#include "G4AuxiliaryNavServices.hh"
|
||||
|
||||
#include <cassert>
|
||||
#include <ostream>
|
||||
|
||||
// ********************************************************************
|
||||
// Constructor
|
||||
// ********************************************************************
|
||||
@@ -761,6 +762,17 @@ G4VoxelNavigation::ComputeSafety(const G4ThreeVector& localPoint,
|
||||
return ourSafety;
|
||||
}
|
||||
|
||||
void G4VoxelNavigation::RelocateWithinVolume( G4VPhysicalVolume* motherPhysical,
|
||||
const G4ThreeVector& localPoint )
|
||||
{
|
||||
auto motherLogical = motherPhysical->GetLogicalVolume();
|
||||
|
||||
assert(motherLogical != nullptr);
|
||||
|
||||
if ( auto pVoxelHeader = motherLogical->GetVoxelHeader() )
|
||||
VoxelLocate( pVoxelHeader, localPoint );
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
// SetVerboseLevel
|
||||
// ********************************************************************
|
||||
|
||||
Reference in New Issue
Block a user