Import Geant4 4.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 16:39:52 +02:00
parent 921d3b1cda
commit 330b82b769
4524 changed files with 178689 additions and 43575 deletions
+12 -2
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4BlockingList.cc,v 1.4 2001/07/11 10:00:32 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// $Id: G4BlockingList.cc,v 1.5 2002/04/19 08:22:08 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
//
// class G4BlockingList Implementation
@@ -30,6 +30,16 @@
#include "G4BlockingList.hh"
G4BlockingList::G4BlockingList(G4int maxDefault,G4int stride)
: fStride(stride), fBlockingList(maxDefault,0)
{
}
// Do nothing destructor
G4BlockingList::~G4BlockingList()
{
}
// Clear List and reset tag
// Fix: Out of line for HP-CC
void G4BlockingList::FullyReset()
+1 -1
View File
@@ -22,7 +22,7 @@
//
//
// $Id: G4GRSSolid.cc,v 1.4 2001/07/11 10:00:32 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// GEANT4 tag $Name: geant4-04-01 $
//
//
// class G4GRSSolid Implementation
+1 -1
View File
@@ -22,7 +22,7 @@
//
//
// $Id: G4GRSVolume.cc,v 1.4 2001/07/11 10:00:32 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// GEANT4 tag $Name: geant4-04-01 $
//
//
// class G4GRSVolume Implementation
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4GeometryMessenger.cc,v 1.4 2001/11/01 19:00:11 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-00 $
// $Id: G4GeometryMessenger.cc,v 1.6 2002/04/03 11:51:29 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
// --------------------------------------------------------------------
// GEANT 4 class source file
@@ -44,7 +44,6 @@
#include "G4UIcmdWith3VectorAndUnit.hh"
#include "G4UIcmdWith3Vector.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIcmdWithABool.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4GeomTestStreamLogger.hh"
@@ -55,8 +54,8 @@
//
G4GeometryMessenger::G4GeometryMessenger(G4TransportationManager* tman)
: geometryOpened(true), x(0,0,0), p(0,0,1),
extra(false), newtol(false), tol(1E-4*mm),
tmanager(tman)
newtol(false), tol(1E-4*mm), tmanager(tman),
tlogger(0), tvolume(0)
{
geodir = new G4UIdirectory( "/geometry/" );
geodir->SetGuidance( "Geometry control commands." );
@@ -77,12 +76,6 @@ G4GeometryMessenger::G4GeometryMessenger(G4TransportationManager* tman)
testdir->SetGuidance( "Geometry verification control setup." );
testdir->SetGuidance( "Helps in detecting possible overlapping regions." );
addCmd = new G4UIcmdWithABool( "/geometry/test/line_test",this );
addCmd->SetGuidance( "Test along a single specified direction/position?" );
addCmd->SetGuidance( "Use position and direction commands to change default." );
addCmd->SetGuidance( "Default: position(0,0,0), direction(0,0,1)." );
addCmd->SetParameterName( "Extra", true, true );
tolCmd = new G4UIcmdWithADoubleAndUnit( "/geometry/test/tolerance",this );
tolCmd->SetGuidance( "Set error tolerance value." );
tolCmd->SetGuidance( "Default: 1E-4*mm." );
@@ -101,8 +94,30 @@ G4GeometryMessenger::G4GeometryMessenger(G4TransportationManager* tman)
dirCmd->SetParameterName( "Px", "Py", "Pz", true, true );
dirCmd->SetRange( "Px != 0 || Py != 0 || Pz != 0" );
linCmd = new G4UIcmdWithoutParameter( "/geometry/test/line_test", this );
linCmd->SetGuidance( "Performs test along a single specified direction/position." );
linCmd->SetGuidance( "Use position and direction commands to change default." );
linCmd->SetGuidance( "Default: position(0,0,0), direction(0,0,1)." );
grdCmd = new G4UIcmdWithoutParameter( "/geometry/test/grid_test", this );
grdCmd->SetGuidance( "Start running the default grid test." );
grdCmd->SetGuidance( "A grid of lines parallel to a cartesian axis is used;" );
grdCmd->SetGuidance( "Only direct daughters of the mother volumes are checked." );
recCmd = new G4UIcmdWithoutParameter( "/geometry/test/recursive_test", this );
recCmd->SetGuidance( "Start running the recursive grid test." );
recCmd->SetGuidance( "A grid of lines along a cartesian axis is recursively" );
recCmd->SetGuidance( "to all daughters and daughters of daughters, etc." );
recCmd->SetGuidance( "WARNING: it may take a very long time, depending on geometry complexity !");
cylCmd = new G4UIcmdWithoutParameter( "/geometry/test/cylinder_test", this );
cylCmd->SetGuidance( "Start running the cylinder test." );
cylCmd->SetGuidance( "A set of lines in a cylindrical pattern of gradually" );
cylCmd->SetGuidance( "increasing mesh size." );
runCmd = new G4UIcmdWithoutParameter( "/geometry/test/run", this );
runCmd->SetGuidance( "Start running the test." );
runCmd->SetGuidance( "Start running the default grid test." );
runCmd->SetGuidance( "Same as the grid_test command." );
}
@@ -111,18 +126,48 @@ G4GeometryMessenger::G4GeometryMessenger(G4TransportationManager* tman)
//
G4GeometryMessenger::~G4GeometryMessenger()
{
delete addCmd;
delete linCmd;
delete posCmd;
delete dirCmd;
delete grdCmd;
delete recCmd;
delete cylCmd;
delete runCmd;
delete resCmd;
delete tolCmd;
delete geodir;
delete navdir;
delete testdir;
delete tvolume;
delete tlogger;
}
//
// Init
//
void
G4GeometryMessenger::Init()
{
// Clean old allocated loggers...
//
if (tlogger) delete tlogger;
if (tvolume) delete tvolume;
// Create a logger to send errors/output to cout
//
tlogger = new G4GeomTestStreamLogger(G4std::cout);
// Get the world volume
//
G4VPhysicalVolume* world =
tmanager->GetNavigatorForTracking()->GetWorldVolume();
// Test the actual detector...
//
tvolume = new G4GeomTestVolume(world, tlogger);
}
//
// SetNewValue
//
@@ -132,9 +177,6 @@ G4GeometryMessenger::SetNewValue( G4UIcommand* command, G4String newValues )
if (command == resCmd) {
ResetNavigator();
}
else if (command == addCmd) {
extra = addCmd->GetNewBoolValue( newValues );
}
else if (command == posCmd) {
x = posCmd->GetNew3VectorValue( newValues );
}
@@ -149,8 +191,21 @@ G4GeometryMessenger::SetNewValue( G4UIcommand* command, G4String newValues )
tol = tolCmd->GetNewDoubleValue( newValues );
newtol = true;
}
else if (command == runCmd) {
RunTest();
else if (command == linCmd) {
Init();
LineTest();
}
else if ((command == grdCmd) || (command == runCmd)){
Init();
GridTest();
}
else if (command == recCmd) {
Init();
RecursiveGridTest();
}
else if (command == cylCmd) {
Init();
CylinderTest();
}
}
@@ -162,10 +217,7 @@ G4String
G4GeometryMessenger::GetCurrentValue(G4UIcommand* command )
{
G4String cv = "";
if (command == addCmd) {
cv = addCmd->ConvertToString( extra );
}
else if (command == posCmd) {
if (command == posCmd) {
cv = posCmd->ConvertToString( x, "cm" );
}
else if (command == tolCmd) {
@@ -194,20 +246,16 @@ G4GeometryMessenger::ResetNavigator()
// Reset navigator's state
//
G4ThreeVector p(0,0,0);
tmanager->GetNavigatorForTracking()->LocateGlobalPointAndSetup(p,0,false);
G4ThreeVector pt(0,0,0);
tmanager->GetNavigatorForTracking()->LocateGlobalPointAndSetup(pt,0,false);
}
//
// RunTest
// LineTest
//
void
G4GeometryMessenger::RunTest()
G4GeometryMessenger::LineTest()
{
// Create a logger to send errors/output to cout
//
G4GeomTestStreamLogger logger(G4std::cout);
// Close geometry if necessary
//
if (geometryOpened) {
@@ -217,28 +265,101 @@ G4GeometryMessenger::RunTest()
geometryOpened = false;
}
// Get the world volume
// Verify if error tolerance has changed
//
G4VPhysicalVolume* world =
tmanager->GetNavigatorForTracking()->GetWorldVolume();
if (newtol) tvolume->SetTolerance(tol);
// Test the actual detector...
// Make test on single line supplied by user
//
G4GeomTestVolume geomTest(world, &logger);
tvolume->TestOneLine( x, p );
// Print out any errors, if found
//
tvolume->ReportErrors();
}
//
// GridTest
//
void
G4GeometryMessenger::GridTest()
{
// Close geometry if necessary
//
if (geometryOpened) {
G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
geomManager->OpenGeometry();
geomManager->CloseGeometry(true);
geometryOpened = false;
}
// Verify if error tolerance has changed
//
if (newtol) geomTest.SetTolerance(tol);
if (newtol) tvolume->SetTolerance(tol);
// Run the test
// Apply default set of trajectories in a 3D grid pattern
//
if (extra) // Make test on single line supplied by user
geomTest.TestOneLine( x, p );
else // Apply default set of trajectories in a 3D grid pattern
geomTest.TestCartGridXYZ();
tvolume->TestCartGridXYZ();
// Print out any errors, if found
//
geomTest.ReportErrors();
tvolume->ReportErrors();
}
//
// RecursiveGridTest
//
void
G4GeometryMessenger::RecursiveGridTest()
{
// Close geometry if necessary
//
if (geometryOpened) {
G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
geomManager->OpenGeometry();
geomManager->CloseGeometry(true);
geometryOpened = false;
}
// Verify if error tolerance has changed
//
if (newtol) tvolume->SetTolerance(tol);
// Apply default set of trajectories in a 3D grid pattern recursively
//
tvolume->TestRecursiveCartGrid();
// Print out any errors, if found
//
tvolume->ReportErrors();
}
//
// CylinderTest
//
void
G4GeometryMessenger::CylinderTest()
{
// Close geometry if necessary
//
if (geometryOpened) {
G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
geomManager->OpenGeometry();
geomManager->CloseGeometry(true);
geometryOpened = false;
}
// Verify if error tolerance has changed
//
if (newtol) tvolume->SetTolerance(tol);
// Apply default set of lines in a cylindrical pattern of gradually
// increasing mesh size of trajectories in a 3D grid pattern recursively
//
tvolume->TestCylinder();
// Print out any errors, if found
//
tvolume->ReportErrors();
}
@@ -22,7 +22,7 @@
//
//
// $Id: G4LogicalBorderSurface.cc,v 1.7 2001/07/11 10:00:32 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// GEANT4 tag $Name: geant4-04-01 $
//
////////////////////////////////////////////////////////////////////////
// G4LogicalBorderSurface Implementation
@@ -22,7 +22,7 @@
//
//
// $Id: G4LogicalSkinSurface.cc,v 1.7 2001/07/11 10:00:32 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// GEANT4 tag $Name: geant4-04-01 $
//
////////////////////////////////////////////////////////////////////////
// G4LogicalSkinSurface Implementation
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4NavigationHistory.cc,v 1.4 2001/07/11 10:00:32 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// $Id: G4NavigationHistory.cc,v 1.5 2002/04/19 08:22:09 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
//
// G4NavigationHistory Implementation P.Kent August 96
@@ -30,6 +30,24 @@
#include "G4NavigationHistory.hh"
#include "G4ios.hh"
G4NavigationHistory::G4NavigationHistory()
: fNavHistory(kHistoryMax), fStackDepth(0)
{
Reset(); // Reset depth
Clear();
}
G4NavigationHistory::G4NavigationHistory(const G4NavigationHistory &h)
: fNavHistory(h.fNavHistory), fStackDepth(h.fStackDepth)
{
}
G4NavigationHistory::~G4NavigationHistory()
{
Reset(); // To delete all but one current entries!
// delete fNavHistory(0);
}
G4std::ostream&
operator << (G4std::ostream& os, const G4NavigationHistory& nav)
{
File diff suppressed because it is too large Load Diff
@@ -22,7 +22,7 @@
//
//
// $Id: G4NormalNavigation.cc,v 1.4 2001/07/11 10:00:33 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// GEANT4 tag $Name: geant4-04-01 $
//
//
// class G4NormalNavigation Implementation
@@ -21,323 +21,413 @@
// ********************************************************************
//
//
// $Id: G4ParameterisedNavigation.cc,v 1.4 2001/07/11 10:00:33 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// $Id: G4ParameterisedNavigation.cc,v 1.6 2002/05/15 10:23:41 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
//
// class G4ParameterisedNavigation Implementation
//
// ********************************************************************
#include "G4ParameterisedNavigation.hh"
// ********************************************************************
// Constructor
// ********************************************************************
//
G4ParameterisedNavigation::G4ParameterisedNavigation()
: fVoxelHeader(0)
{
}
// ***************************************************************************
// Destructor
// ***************************************************************************
//
G4ParameterisedNavigation::~G4ParameterisedNavigation()
{
#ifdef G4DEBUG_NAVIGATION
cout << "G4ParameterisedNavigation::~G4ParameterisedNavigation() called."
<< G4endl;
G4cout << "G4ParameterisedNavigation::~G4ParameterisedNavigation() called."
<< G4endl;
#endif
}
G4double G4ParameterisedNavigation::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)
// ***************************************************************************
// ComputeStep
// ***************************************************************************
//
G4double G4ParameterisedNavigation::
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)
{
G4VPhysicalVolume *motherPhysical, *samplePhysical;
G4VPVParameterisation *sampleParam;
G4LogicalVolume *motherLogical;
G4VSolid *motherSolid, *sampleSolid;
G4ThreeVector sampleDirection;
G4double ourStep=currentProposedStepLength, motherSafety, ourSafety;
G4int sampleNo;
G4VPhysicalVolume *motherPhysical,*samplePhysical;
G4VPVParameterisation *sampleParam;
G4LogicalVolume *motherLogical;
G4VSolid *motherSolid,*sampleSolid;
G4ThreeVector sampleDirection;
G4double ourStep=currentProposedStepLength,motherSafety,ourSafety;
G4int sampleNo;
G4bool initialNode, noStep;
G4SmartVoxelNode *curVoxelNode;
G4int curNoVolumes, contentNo;
G4double voxelSafety;
G4bool initialNode,noStep;
G4SmartVoxelNode *curVoxelNode;
G4int curNoVolumes,contentNo;
G4double voxelSafety;
// Replication data
//
EAxis axis;
G4int nReplicas;
G4double width, offset;
G4bool consuming;
// Replication data
EAxis axis;
G4int nReplicas;
G4double width,offset;
G4bool consuming;
motherPhysical = history.GetTopVolume();
motherLogical = motherPhysical->GetLogicalVolume();
motherSolid = motherLogical->GetSolid();
motherPhysical=history.GetTopVolume();
motherLogical=motherPhysical->GetLogicalVolume();
//
// Compute mother safety
//
motherSolid=motherLogical->GetSolid();
motherSafety = motherSolid->DistanceToOut(localPoint);
ourSafety = motherSafety; // Working isotropic safety
//
// Compute daughter safeties & intersections
//
//
// Compute mother safety
//
motherSafety=motherSolid->DistanceToOut(localPoint);
ourSafety=motherSafety; // Working isotropic safety
//
// Compute daughter safeties & intersections
//
initialNode = true;
noStep = true;
initialNode=true;
noStep=true;
// By definition, parameterised volumes exist as first
// daughter of the mother volume
//
samplePhysical = motherLogical->GetDaughter(0);
samplePhysical->GetReplicationData(axis,nReplicas,width,offset,consuming);
fBList.Enlarge(nReplicas);
fBList.Reset();
// By definition, parameterised volumes exist as first
// daughter of mother volume
samplePhysical=motherLogical->GetDaughter(0);
samplePhysical->GetReplicationData(axis,nReplicas,width,offset,consuming);
fBList.Enlarge(nReplicas);
fBList.Reset();
// Exiting normal optimisation
//
if (exiting && (*pBlockedPhysical==samplePhysical) && validExitNormal)
{
if (localDirection.dot(exitNormal)>=kMinExitingNormalCosine)
{
assert( (0 <= blockedReplicaNo)&&(blockedReplicaNo<nReplicas) );
//
// Block exited daughter replica; Must be on boundary => zero safety
//
fBList.BlockVolume(blockedReplicaNo);
ourSafety = 0;
}
}
exiting = false;
entering = false;
sampleParam = samplePhysical->GetParameterisation();
// Exiting normal optimisation
if (exiting && (*pBlockedPhysical==samplePhysical) && validExitNormal)
{
if (localDirection.dot(exitNormal)>=kMinExitingNormalCosine)
{
assert( (0 <= blockedReplicaNo)
&&(blockedReplicaNo<nReplicas));
// Block exited daughter replica; Must be on boundary => zero safety
fBList.BlockVolume(blockedReplicaNo);
ourSafety=0;
}
}
do
{
curVoxelNode = fVoxelNode;
curNoVolumes = curVoxelNode->GetNoContained();
exiting=false;
entering=false;
for ( contentNo=curNoVolumes-1; contentNo>=0; contentNo-- )
{
sampleNo = curVoxelNode->GetVolume(contentNo);
if ( !fBList.IsBlocked(sampleNo) )
{
fBList.BlockVolume(sampleNo);
sampleSolid = sampleParam->ComputeSolid(sampleNo, samplePhysical);
sampleSolid->ComputeDimensions(sampleParam, sampleNo, samplePhysical);
sampleParam->ComputeTransformation(sampleNo, samplePhysical);
samplePhysical->Setup(motherPhysical);
G4AffineTransform sampleTf(samplePhysical->GetRotation(),
samplePhysical->GetTranslation());
sampleTf.Invert();
const G4ThreeVector samplePoint = sampleTf.TransformPoint(localPoint);
const G4double sampleSafety = sampleSolid->DistanceToIn(samplePoint);
if ( sampleSafety<ourSafety )
{
ourSafety = sampleSafety;
}
if ( sampleSafety<=ourStep )
{
sampleDirection = sampleTf.TransformAxis(localDirection);
G4double sampleStep =
sampleSolid->DistanceToIn(samplePoint, sampleDirection);
if ( sampleStep<=ourStep )
{
ourStep = sampleStep;
entering = true;
exiting = false;
*pBlockedPhysical = samplePhysical;
blockedReplicaNo = sampleNo;
}
}
}
}
// sampleSolid=samplePhysical ->GetLogicalVolume() ->GetSolid();
if ( initialNode )
{
initialNode = false;
voxelSafety = ComputeVoxelSafety(localPoint,axis);
if ( voxelSafety<ourSafety )
{
ourSafety = voxelSafety;
}
if ( currentProposedStepLength<ourSafety )
{
// Guaranteed physics limited
//
noStep = false;
entering = false;
exiting = false;
*pBlockedPhysical = 0;
ourStep = kInfinity;
}
else
{
// Compute mother intersection if required
//
if ( motherSafety<=ourStep )
{
G4double motherStep = motherSolid->DistanceToOut(localPoint,
localDirection,
true,
&validExitNormal,
&exitNormal);
if ( motherStep<=ourStep )
{
ourStep = motherStep;
exiting = true;
entering = false;
if ( validExitNormal )
{
const G4RotationMatrix *rot = motherPhysical->GetRotation();
if (rot)
{
exitNormal *= rot->inverse();
}
}
}
else
{
validExitNormal = false;
}
}
}
newSafety=ourSafety;
}
if (noStep)
{
noStep = LocateNextVoxel(localPoint, localDirection, ourStep, axis);
}
} while (noStep);
sampleParam=samplePhysical->GetParameterisation();
do {
curVoxelNode=fVoxelNode;
curNoVolumes=curVoxelNode->GetNoContained();
for (contentNo=curNoVolumes-1;contentNo>=0;contentNo--)
{
sampleNo=curVoxelNode->GetVolume(contentNo);
if (!fBList.IsBlocked(sampleNo))
{
fBList.BlockVolume(sampleNo);
sampleSolid=sampleParam->ComputeSolid(sampleNo,
samplePhysical);
sampleSolid->ComputeDimensions(sampleParam,
sampleNo,
samplePhysical);
sampleParam->ComputeTransformation(sampleNo,
samplePhysical);
samplePhysical->Setup(motherPhysical);
G4AffineTransform sampleTf(samplePhysical->GetRotation(),
samplePhysical->GetTranslation());
sampleTf.Invert();
const G4ThreeVector samplePoint=sampleTf.TransformPoint(localPoint);
const G4double sampleSafety=sampleSolid
->DistanceToIn(samplePoint);
if (sampleSafety<ourSafety)
{
ourSafety=sampleSafety;
}
if (sampleSafety<=ourStep)
{
sampleDirection=sampleTf.TransformAxis(localDirection);
const G4double sampleStep=sampleSolid
->DistanceToIn(samplePoint,
sampleDirection);
if (sampleStep<=ourStep)
{
ourStep=sampleStep;
entering=true;
exiting=false;
*pBlockedPhysical=samplePhysical;
blockedReplicaNo=sampleNo;
}
}
}
}
if (initialNode)
{
initialNode=false;
voxelSafety=ComputeVoxelSafety(localPoint);
if (voxelSafety<ourSafety)
{
ourSafety=voxelSafety;
}
if (currentProposedStepLength<ourSafety)
{
//
// Guaranteed physics limited
//
noStep=false;
entering=false;
exiting=false;
*pBlockedPhysical=0;
ourStep=kInfinity;
}
else
{
//
// Compute mother intersection if required
//
if (motherSafety<=ourStep)
{
G4double motherStep=motherSolid
->DistanceToOut(localPoint,
localDirection,
true,
&validExitNormal,
&exitNormal);
if (motherStep<=ourStep)
{
ourStep=motherStep;
exiting=true;
entering=false;
if (validExitNormal)
{
const G4RotationMatrix *rot=motherPhysical->GetRotation();
if (rot)
{
exitNormal*=rot->inverse();
}
}
}
else
{
validExitNormal=false;
}
}
}
newSafety=ourSafety;
}
if (noStep)
{
noStep=LocateNextVoxel(localPoint,
localDirection,
ourStep);
}
} while (noStep);
return ourStep;
return ourStep;
}
G4double G4ParameterisedNavigation::ComputeSafety(const G4ThreeVector &localPoint,
const G4NavigationHistory &history,
const G4double pProposedMaxLength )
// ***************************************************************************
// ComputeSafety
// ***************************************************************************
//
G4double
G4ParameterisedNavigation::ComputeSafety(const G4ThreeVector& localPoint,
const G4NavigationHistory& history,
const G4double pProposedMaxLength )
{
G4VPhysicalVolume *motherPhysical, *samplePhysical;
G4VPVParameterisation *sampleParam;
G4LogicalVolume *motherLogical;
G4VSolid *motherSolid, *sampleSolid;
G4double motherSafety, ourSafety;
G4int sampleNo, curVoxelNodeNo;
G4VPhysicalVolume *motherPhysical,*samplePhysical;
G4VPVParameterisation *sampleParam;
G4LogicalVolume *motherLogical;
G4VSolid *motherSolid,*sampleSolid;
G4double motherSafety,ourSafety;
G4int sampleNo, curVoxelNodeNo;
G4SmartVoxelNode *curVoxelNode;
G4int curNoVolumes,contentNo;
G4double voxelSafety;
G4SmartVoxelNode *curVoxelNode;
G4int curNoVolumes, contentNo;
G4double voxelSafety;
// Replication data
EAxis axis;
G4int nReplicas;
G4double width,offset;
G4bool consuming;
// Replication data
//
EAxis axis;
G4int nReplicas;
G4double width, offset;
G4bool consuming;
motherPhysical=history.GetTopVolume();
motherLogical=motherPhysical->GetLogicalVolume();
motherPhysical = history.GetTopVolume();
motherLogical = motherPhysical->GetLogicalVolume();
motherSolid = motherLogical->GetSolid();
motherSolid=motherLogical->GetSolid();
//
// Compute mother safety
//
motherSafety=motherSolid->DistanceToOut(localPoint);
ourSafety=motherSafety; // Working isotropic safety
//
// Compute daughter safeties
//
//
// Compute mother safety
//
// By definition, parameterised volumes exist as first
// daughter of mother volume
samplePhysical=motherLogical->GetDaughter(0);
samplePhysical->GetReplicationData(axis,nReplicas,width,offset,consuming);
sampleParam=samplePhysical->GetParameterisation();
motherSafety = motherSolid->DistanceToOut(localPoint);
ourSafety = motherSafety; // Working isotropic safety
//
// Compute daughter safeties
//
// Calculate new VoxelNode of current point
curVoxelNodeNo= G4int (
(localPoint(fVoxelAxis) -fVoxelHeader->GetMinExtent())
/ fVoxelSliceWidth
);
curVoxelNode = fVoxelHeader->GetSlice(curVoxelNodeNo)->GetNode();
// By definition, parameterised volumes exist as first
// daughter of the mother volume
//
samplePhysical = motherLogical->GetDaughter(0);
samplePhysical->GetReplicationData(axis, nReplicas, width, offset, consuming);
sampleParam = samplePhysical->GetParameterisation();
curNoVolumes=curVoxelNode->GetNoContained();
// Look inside the current Voxel only at the current point
//
if ( axis==kUndefined ) // 3D case: current voxel node is retrieved
{ // from G4VoxelNavigation.
curVoxelNode = fVoxelNode;
}
else // 1D case: current voxel node is computed here.
{
curVoxelNodeNo = G4int((localPoint(fVoxelAxis)-fVoxelHeader->GetMinExtent())
/ fVoxelSliceWidth );
curVoxelNode = fVoxelHeader->GetSlice(curVoxelNodeNo)->GetNode();
fVoxelNodeNo = curVoxelNodeNo;
fVoxelNode = curVoxelNode;
}
curNoVolumes = curVoxelNode->GetNoContained();
for (contentNo=curNoVolumes-1;contentNo>=0;contentNo--)
{
sampleNo=curVoxelNode->GetVolume(contentNo);
sampleSolid=sampleParam->ComputeSolid(sampleNo,
samplePhysical);
sampleSolid->ComputeDimensions(sampleParam,
sampleNo,
samplePhysical);
sampleParam->ComputeTransformation(sampleNo,
samplePhysical);
G4AffineTransform sampleTf(samplePhysical->GetRotation(),
samplePhysical->GetTranslation());
sampleTf.Invert();
const G4ThreeVector samplePoint=sampleTf.TransformPoint(localPoint);
const G4double sampleSafety=sampleSolid
->DistanceToIn(samplePoint);
if (sampleSafety<ourSafety)
{
ourSafety=sampleSafety;
}
}
for ( contentNo=curNoVolumes-1; contentNo>=0; contentNo-- )
{
sampleNo = curVoxelNode->GetVolume(contentNo);
sampleSolid = sampleParam->ComputeSolid(sampleNo, samplePhysical);
sampleSolid->ComputeDimensions(sampleParam, sampleNo, samplePhysical);
sampleParam->ComputeTransformation(sampleNo, samplePhysical);
G4AffineTransform sampleTf(samplePhysical->GetRotation(),
samplePhysical->GetTranslation());
sampleTf.Invert();
const G4ThreeVector samplePoint = sampleTf.TransformPoint(localPoint);
G4double sampleSafety = sampleSolid->DistanceToIn(samplePoint);
if ( sampleSafety<ourSafety )
{
ourSafety = sampleSafety;
}
}
// These must be current for ComputeVoxelSafety
fVoxelNodeNo= curVoxelNodeNo;
fVoxelNode = curVoxelNode;
voxelSafety=ComputeVoxelSafety(localPoint);
if (voxelSafety<ourSafety)
{
ourSafety=voxelSafety;
}
return ourSafety;
voxelSafety = ComputeVoxelSafety(localPoint,axis);
if ( voxelSafety<ourSafety )
{
ourSafety=voxelSafety;
}
return ourSafety;
}
// ********************************************************************
// ComputeVoxelSafety
//
// Computes safety from specified point to collected voxel boundaries
// using already located point.
// ********************************************************************
//
G4double G4ParameterisedNavigation::
ComputeVoxelSafety(const G4ThreeVector& localPoint,
const EAxis pAxis) const
{
// 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;
G4int minCurNodeNoDelta, maxCurNodeNoDelta;
// Compute linear intersection distance to boundaries of max/min
// to collected nodes at current level
//
curNodeOffset = fVoxelNodeNo*fVoxelSliceWidth;
minCurCommonDelta = localPoint(fVoxelAxis)
- fVoxelHeader->GetMinExtent()-curNodeOffset;
maxCurNodeNoDelta = fVoxelNode->GetMaxEquivalentSliceNo()-fVoxelNodeNo;
minCurNodeNoDelta = fVoxelNodeNo-fVoxelNode->GetMinEquivalentSliceNo();
maxCurCommonDelta = fVoxelSliceWidth-minCurCommonDelta;
plusVoxelSafety = minCurNodeNoDelta*fVoxelSliceWidth+minCurCommonDelta;
minusVoxelSafety = maxCurNodeNoDelta*fVoxelSliceWidth+maxCurCommonDelta;
voxelSafety = G4std::min(plusVoxelSafety,minusVoxelSafety);
if ( voxelSafety<0 )
{
voxelSafety = 0;
}
return voxelSafety;
}
// ********************************************************************
// LocateNextVoxel
//
// Finds the next voxel from the current voxel and point
// in the specified direction.
//
// Returns false if all voxels considered
// true otherwise
// [current Step ends inside same voxel or leaves all voxels]
// ********************************************************************
//
G4bool G4ParameterisedNavigation::
LocateNextVoxel( const G4ThreeVector& localPoint,
const G4ThreeVector& localDirection,
const G4double currentStep,
const EAxis pAxis)
{
// If no best axis is specified, adopt default
// location strategy as for placements
//
if ( pAxis==kUndefined )
return G4VoxelNavigation::LocateNextVoxel(localPoint,
localDirection,
currentStep);
G4bool isNewVoxel;
G4int newNodeNo;
G4double minVal, maxVal, curMinExtent, curCoord;
curMinExtent = fVoxelHeader->GetMinExtent();
curCoord = localPoint(fVoxelAxis)+currentStep*localDirection(fVoxelAxis);
minVal = curMinExtent+fVoxelNode->GetMinEquivalentSliceNo()*fVoxelSliceWidth;
isNewVoxel = false;
if ( minVal<=curCoord )
{
maxVal = curMinExtent
+ (fVoxelNode->GetMaxEquivalentSliceNo()+1)*fVoxelSliceWidth;
if ( maxVal<curCoord )
{
newNodeNo = fVoxelNode->GetMaxEquivalentSliceNo()+1;
if ( newNodeNo<fVoxelHeader->GetNoSlices() )
{
fVoxelNodeNo = newNodeNo;
fVoxelNode = fVoxelHeader->GetSlice(newNodeNo)->GetNode();
isNewVoxel = true;
}
}
}
else
{
newNodeNo = fVoxelNode->GetMinEquivalentSliceNo()-1;
// Must locate from newNodeNo no and down to setup stack and fVoxelNode
// Repeat or earlier code...
//
if ( newNodeNo>=0 )
{
fVoxelNodeNo = newNodeNo;
fVoxelNode = fVoxelHeader->GetSlice(newNodeNo)->GetNode();
isNewVoxel = true;
}
}
return isNewVoxel;
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4PropagatorInField.cc,v 1.28 2001/12/08 01:17:04 japost Exp $
// GEANT4 tag $Name: geant4-04-00 $
// $Id: G4PropagatorInField.cc,v 1.30 2002/04/19 08:22:09 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
//
// This class implements an algorithm to track a particle in a
@@ -52,6 +52,40 @@
const G4double G4PropagatorInField::fEpsilonMinDefault = 5.0e-7;
const G4double G4PropagatorInField::fEpsilonMaxDefault = 0.05;
///////////////////////////////////////////////////////////////////////////
//
// Constructors and destructor
G4PropagatorInField::G4PropagatorInField(G4Navigator *theNavigator,
G4FieldManager *detectorFieldMgr)
: fDetectorFieldMgr(detectorFieldMgr),
fCurrentFieldMgr(detectorFieldMgr),
fNavigator(theNavigator),
End_PointAndTangent(G4ThreeVector(0.,0.,0.),
G4ThreeVector(0.,0.,0.),0.0,0.0,0.0,0.0,0.0),
fVerboseLevel(0),
fEpsilonMin(fEpsilonMinDefault),
fEpsilonMax(fEpsilonMaxDefault),
fmax_loop_count(10000),
fNoZeroStep(0)
{
// this->fChordFinder = new G4ChordFinder( (G4MagneticField*)0, 1e-6 );
fActionThreshold_NoZeroSteps= 2;
fSevereActionThreshold_NoZeroSteps= 10;
fAbandonThreshold_NoZeroSteps= 50;
// fMidPoint_CurveLen_of_LastAttempt= -1;
fFull_CurveLen_of_LastAttempt= -1;
fLast_ProposedStepLength= -1;
fLargestAcceptableStep= 1000.0 * meter;
}
G4PropagatorInField::~G4PropagatorInField()
{
}
///////////////////////////////////////////////////////////////////////////
//
// Compute the next geometric Step
@@ -288,20 +322,18 @@ G4double G4PropagatorInField::
while( (!intersects ) && (StepTaken + kCarTolerance < CurrentProposedStepLength)
&& ( do_loop_count < GetMaxLoopCount() ) );
#ifdef G4VERBOSE
if( do_loop_count >= GetMaxLoopCount() ){
G4cerr << "G4PropagateInField: Warning: Particle is looping - "
G4cout << "G4PropagateInField: Warning: Particle is looping - "
<< " tracking in field will be stopped. " << G4endl;
G4cerr << " It has performed " << do_loop_count << " steps in Field "
#ifdef G4VERBOSE
G4cout << " It has performed " << do_loop_count << " steps in Field "
<< " while a maximum of " << GetMaxLoopCount() << " are allowed. "
<< G4endl;
#endif
G4cerr << "G4PropagateInField: Warning: Looping particle. " << G4endl;
//G4cerr << " In future this will be treated better/quicker. " << G4endl;
fParticleIsLooping= true;
}
#endif
if( ! intersects )
{
@@ -354,10 +386,14 @@ G4double G4PropagatorInField::
fNoZeroStep= 0;
if( fNoZeroStep > fAbandonThreshold_NoZeroSteps ) {
#ifdef G4VERBOSE
G4cout << " G4PropagatorInField::ComputeStep : Warning :"
<< " no progress after " << fNoZeroStep << " trial steps. "
<< G4endl;
G4cout << " Particle will be abandoned." ;
G4cout << " Particle will be killed." << G4endl ;
#else
G4cout << " G4PropagatorInField: Particle that is stuck will be killed." << G4endl;
#endif
fParticleIsLooping= true;
}
@@ -22,7 +22,7 @@
//
//
// $Id: G4ReplicaNavigation.cc,v 1.10 2001/07/11 10:00:33 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// GEANT4 tag $Name: geant4-04-01 $
//
//
// class G4ReplicaNavigation Implementation
@@ -22,7 +22,7 @@
//
//
// $Id: G4TouchableHistory.cc,v 1.5 2001/07/11 10:00:34 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// GEANT4 tag $Name: geant4-04-01 $
//
//
// class G4TouchableHistory Implementation
@@ -22,7 +22,7 @@
//
//
// $Id: G4TransportationManager.cc,v 1.9 2001/10/24 15:33:49 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-00 $
// GEANT4 tag $Name: geant4-04-01 $
//
//
// G4TransportationManager
File diff suppressed because it is too large Load Diff