Import Geant4 4.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 16:18:25 +02:00
parent 36c080dca6
commit 921d3b1cda
3990 changed files with 185376 additions and 82884 deletions
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4BlockingList.cc,v 1.3.2.1 2001/06/28 19:09:42 gunter Exp $
// GEANT4 tag $Name: $
// $Id: G4BlockingList.cc,v 1.4 2001/07/11 10:00:32 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
//
// class G4BlockingList Implementation
+2 -2
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4GRSSolid.cc,v 1.3.4.1 2001/06/28 19:09:43 gunter Exp $
// GEANT4 tag $Name: $
// $Id: G4GRSSolid.cc,v 1.4 2001/07/11 10:00:32 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
//
// class G4GRSSolid Implementation
+2 -2
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4GRSVolume.cc,v 1.3.4.1 2001/06/28 19:09:43 gunter Exp $
// GEANT4 tag $Name: $
// $Id: G4GRSVolume.cc,v 1.4 2001/07/11 10:00:32 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
//
// class G4GRSVolume Implementation
@@ -0,0 +1,244 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4GeometryMessenger.cc,v 1.4 2001/11/01 19:00:11 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
// --------------------------------------------------------------------
// GEANT 4 class source file
//
// G4GeometryMessenger
//
// Author: G.Cosmo, CERN.
#include "g4std/iomanip"
#include "G4GeometryMessenger.hh"
#include "G4TransportationManager.hh"
#include "G4GeometryManager.hh"
#include "G4VPhysicalVolume.hh"
#include "G4Navigator.hh"
#include "G4UIdirectory.hh"
#include "G4UIcommand.hh"
#include "G4UIcmdWith3VectorAndUnit.hh"
#include "G4UIcmdWith3Vector.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIcmdWithABool.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4GeomTestStreamLogger.hh"
#include "G4GeomTestVolume.hh"
//
// Constructor
//
G4GeometryMessenger::G4GeometryMessenger(G4TransportationManager* tman)
: geometryOpened(true), x(0,0,0), p(0,0,1),
extra(false), newtol(false), tol(1E-4*mm),
tmanager(tman)
{
geodir = new G4UIdirectory( "/geometry/" );
geodir->SetGuidance( "Geometry control commands." );
//
// Geometry navigator commands
//
navdir = new G4UIdirectory( "/geometry/navigator/" );
navdir->SetGuidance( "Geometry navigator control setup." );
resCmd = new G4UIcmdWithoutParameter( "/geometry/navigator/reset", this );
resCmd->SetGuidance( "Reset navigator and navigation history." );
//
// Geometry verification test commands
//
testdir = new G4UIdirectory( "/geometry/test/" );
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." );
tolCmd->SetParameterName( "Tolerance", true, true );
tolCmd->SetDefaultUnit( "mm" );
tolCmd->SetUnitCategory( "Length" );
posCmd = new G4UIcmdWith3VectorAndUnit( "/geometry/test/position", this );
posCmd->SetGuidance( "Set starting position." );
posCmd->SetParameterName( "X", "Y", "Z", true, true );
posCmd->SetDefaultUnit( "cm" );
dirCmd = new G4UIcmdWith3VectorAndUnit( "/geometry/test/direction", this );
dirCmd->SetGuidance( "Set momentum direction." );
dirCmd->SetGuidance( "Direction needs not to be a unit vector." );
dirCmd->SetParameterName( "Px", "Py", "Pz", true, true );
dirCmd->SetRange( "Px != 0 || Py != 0 || Pz != 0" );
runCmd = new G4UIcmdWithoutParameter( "/geometry/test/run", this );
runCmd->SetGuidance( "Start running the test." );
}
//
// Destructor
//
G4GeometryMessenger::~G4GeometryMessenger()
{
delete addCmd;
delete posCmd;
delete dirCmd;
delete runCmd;
delete resCmd;
delete tolCmd;
delete geodir;
delete navdir;
delete testdir;
}
//
// SetNewValue
//
void
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 );
}
else if (command == dirCmd) {
p = dirCmd->GetNew3VectorValue( newValues );
if (p.mag() < DBL_MIN) {
G4cerr << "Please specify non-zero momentum" << G4endl;
p = G4ThreeVector(0,0,1);
}
}
else if (command == tolCmd) {
tol = tolCmd->GetNewDoubleValue( newValues );
newtol = true;
}
else if (command == runCmd) {
RunTest();
}
}
//
// GetCurrentValue
//
G4String
G4GeometryMessenger::GetCurrentValue(G4UIcommand* command )
{
G4String cv = "";
if (command == addCmd) {
cv = addCmd->ConvertToString( extra );
}
else if (command == posCmd) {
cv = posCmd->ConvertToString( x, "cm" );
}
else if (command == tolCmd) {
cv = tolCmd->ConvertToString( tol, "mm" );
}
else if (command == dirCmd) {
cv = dirCmd->ConvertToString( p, "GeV" );
}
return cv;
}
//
// ResetNavigator
//
void
G4GeometryMessenger::ResetNavigator()
{
// Close geometry if necessary
//
if (geometryOpened) {
G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
geomManager->OpenGeometry();
geomManager->CloseGeometry(true);
geometryOpened = false;
}
// Reset navigator's state
//
G4ThreeVector p(0,0,0);
tmanager->GetNavigatorForTracking()->LocateGlobalPointAndSetup(p,0,false);
}
//
// RunTest
//
void
G4GeometryMessenger::RunTest()
{
// Create a logger to send errors/output to cout
//
G4GeomTestStreamLogger logger(G4std::cout);
// Close geometry if necessary
//
if (geometryOpened) {
G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
geomManager->OpenGeometry();
geomManager->CloseGeometry(true);
geometryOpened = false;
}
// Get the world volume
//
G4VPhysicalVolume* world =
tmanager->GetNavigatorForTracking()->GetWorldVolume();
// Test the actual detector...
//
G4GeomTestVolume geomTest(world, &logger);
// Verify if error tolerance has changed
//
if (newtol) geomTest.SetTolerance(tol);
// Run the test
//
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();
// Print out any errors, if found
//
geomTest.ReportErrors();
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4LogicalBorderSurface.cc,v 1.6.2.1 2001/06/28 19:09:43 gunter Exp $
// GEANT4 tag $Name: $
// $Id: G4LogicalBorderSurface.cc,v 1.7 2001/07/11 10:00:32 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
////////////////////////////////////////////////////////////////////////
// G4LogicalBorderSurface Implementation
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4LogicalSkinSurface.cc,v 1.6.2.1 2001/06/28 19:09:43 gunter Exp $
// GEANT4 tag $Name: $
// $Id: G4LogicalSkinSurface.cc,v 1.7 2001/07/11 10:00:32 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
////////////////////////////////////////////////////////////////////////
// G4LogicalSkinSurface Implementation
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4NavigationHistory.cc,v 1.3.4.1 2001/06/28 19:09:43 gunter Exp $
// GEANT4 tag $Name: $
// $Id: G4NavigationHistory.cc,v 1.4 2001/07/11 10:00:32 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
//
// G4NavigationHistory Implementation P.Kent August 96
+81 -128
View File
@@ -21,9 +21,8 @@
// ********************************************************************
//
//
// $Id: G4Navigator.cc,v 1.11.4.1 2001/06/28 19:09:43 gunter Exp $
// GEANT4 tag $Name: $
//
// $Id: G4Navigator.cc,v 1.23 2001/12/11 17:46:49 gcosmo Exp $
// GEANT4 tag $ Name: $
//
// class G4Navigator Implementation Paul Kent July 95/96
@@ -42,26 +41,7 @@ G4Navigator::G4Navigator() :
G4Navigator::~G4Navigator()
{;}
// Set the world (`topmost') volume
void G4Navigator::SetWorldVolume(G4VPhysicalVolume* pWorld)
{
// Setup the volume
pWorld->Setup(0); // No mother since world volume
if (!(pWorld->GetTranslation()==G4ThreeVector(0,0,0)))
{
G4Exception ("G4Navigator::SetWorldVolume - Must be centred on origin");
}
const G4RotationMatrix* rm=pWorld->GetRotation();
if (rm&&(!rm->isIdentity()))
{
G4Exception ("G4Navigator::SetWorldVolume - Must not be rotated");
}
fTopPhysical=pWorld;
fHistory.SetFirstEntry(pWorld);
}
// define DEBUG_HIST 1
// define G4DEBUG_NAVIGATION 1
// Locate the point in the hierarchy return 0 if outside
//
@@ -71,16 +51,25 @@ void G4Navigator::SetWorldVolume(G4VPhysicalVolume* pWorld)
G4VPhysicalVolume*
G4Navigator::LocateGlobalPointAndSetup(const G4ThreeVector& globalPoint,
const G4ThreeVector* pGlobalDirection,
const G4bool relativeSearch)
const G4bool relativeSearch,
const G4bool ignoreDirection)
{
G4bool notKnownContained=true,noResult;
G4VPhysicalVolume *targetPhysical;
G4LogicalVolume *targetLogical;
G4VSolid *targetSolid;
G4ThreeVector localPoint;
G4VSolid *targetSolid=0;
G4ThreeVector localPoint, globalDirection;
EInside insideCode;
#ifdef DEBUG_HIST
G4bool considerDirection = (!ignoreDirection) || fLocatedOnEdge;
if( considerDirection && pGlobalDirection != 0 )
{
globalDirection=*pGlobalDirection;
}
#ifdef G4DEBUG_NAVIGATION
G4cerr << "Upon entering LocateGlobalPointAndSetup " << G4endl;
G4cerr << " History = " << G4endl << fHistory << G4endl << G4endl;
#endif
@@ -141,7 +130,9 @@ G4Navigator::LocateGlobalPointAndSetup(const G4ThreeVector& globalPoint,
{
case kNormal:
fBlockedPhysicalVolume->Setup(curPhysical);
fHistory.NewLevel(fBlockedPhysicalVolume);
fHistory.NewLevel(fBlockedPhysicalVolume,
kNormal,
fBlockedPhysicalVolume->GetCopyNo());
break;
case kReplica:
freplicaNav.ComputeTransformation(fBlockedReplicaNo,
@@ -237,26 +228,46 @@ G4Navigator::LocateGlobalPointAndSetup(const G4ThreeVector& globalPoint,
return 0;
}
}
else if (insideCode==kSurface&&fExiting)
{
if (fHistory.GetDepth())
{
fBlockedPhysicalVolume=fHistory.GetTopVolume();
fBlockedReplicaNo=fHistory.GetTopReplicaNo();
fHistory.BackLevel();
// Still on surface but exited volume not necessarily convex
fValidExitNormal=false;
}
else
{
// Have exited world volume
return 0;
}
}
else if (insideCode==kSurface)
{
G4bool isExiting= fExiting;
if((!fExiting)&&considerDirection){
// Figure out whether we are exiting this level's volume by using the direction
G4bool directionExiting= false;
G4ThreeVector localDirection;
localDirection=fHistory.GetTopTransform().TransformAxis(globalDirection);
if (fHistory.GetTopVolumeType()!=kReplica){
G4ThreeVector normal= targetSolid->SurfaceNormal(localPoint);
directionExiting= normal.dot(localDirection) > 0.0;
isExiting= isExiting || directionExiting;
}
}
if(isExiting)
{
if (fHistory.GetDepth())
{
fBlockedPhysicalVolume=fHistory.GetTopVolume();
fBlockedReplicaNo=fHistory.GetTopReplicaNo();
fHistory.BackLevel();
// Still on surface but exited volume not necessarily convex
fValidExitNormal=false;
}
else
{
// Have exited world volume
return 0;
}
}
else
{
notKnownContained=false;
}
}
else
{
notKnownContained=false;
}
{
notKnownContained=false;
}
}
//
@@ -272,7 +283,8 @@ G4Navigator::LocateGlobalPointAndSetup(const G4ThreeVector& globalPoint,
noResult=true; // noResult should be renamed to
// something like enteredLevel, as that is its meaning.
do
do
{
// Determine `type' of current mother volume
@@ -288,7 +300,7 @@ G4Navigator::LocateGlobalPointAndSetup(const G4ThreeVector& globalPoint,
fBlockedReplicaNo,
globalPoint,
pGlobalDirection,
fLocatedOnEdge,
considerDirection,
localPoint);
}
else
@@ -298,7 +310,7 @@ G4Navigator::LocateGlobalPointAndSetup(const G4ThreeVector& globalPoint,
fBlockedReplicaNo,
globalPoint,
pGlobalDirection,
fLocatedOnEdge,
considerDirection,
localPoint);
}
break;
@@ -308,7 +320,7 @@ G4Navigator::LocateGlobalPointAndSetup(const G4ThreeVector& globalPoint,
fBlockedReplicaNo,
globalPoint,
pGlobalDirection,
fLocatedOnEdge,
considerDirection,
localPoint);
break;
case kParameterised:
@@ -317,7 +329,7 @@ G4Navigator::LocateGlobalPointAndSetup(const G4ThreeVector& globalPoint,
fBlockedReplicaNo,
globalPoint,
pGlobalDirection,
fLocatedOnEdge,
considerDirection,
localPoint);
break;
}
@@ -350,7 +362,7 @@ G4Navigator::LocateGlobalPointAndSetup(const G4ThreeVector& globalPoint,
}
#endif
#ifdef DEBUG_HIST
#ifdef G4DEBUG_NAVIGATION
G4cerr << "Upon exiting LocateGlobalPointAndSetup " << G4endl;
G4cerr << " History = " << G4endl << fHistory << G4endl << G4endl;
#endif
@@ -611,6 +623,7 @@ G4double G4Navigator::ComputeStep(const G4ThreeVector &pGlobalpoint,
// We must calculate the normal anyway (in order to have it if requested)
G4ThreeVector FinalPoint= fLastLocatedPointLocal + localDirection*Step;
fExitNormal= motherLogical->GetSolid()->SurfaceNormal(FinalPoint);
}
#ifdef G4VERBOSE
@@ -624,48 +637,6 @@ G4double G4Navigator::ComputeStep(const G4ThreeVector &pGlobalpoint,
return Step;
}
G4VPhysicalVolume* G4Navigator::LocateGlobalPointAndSetup(const G4ThreeVector &p,
const G4TouchableHistory &h)
{
fHistory=*h.GetHistory();
SetupHierarchy();
return LocateGlobalPointAndSetup(p, 0);
}
G4ThreeVector G4Navigator::NetTranslation() const
{
G4AffineTransform tf(fHistory.GetTopTransform().Inverse());
return tf.NetTranslation();
}
G4RotationMatrix G4Navigator::NetRotation() const
{
G4AffineTransform tf(fHistory.GetTopTransform().Inverse());
return tf.NetRotation();
}
G4GRSVolume* G4Navigator::CreateGRSVolume() const
{
G4AffineTransform tf(fHistory.GetTopTransform().Inverse());
return new G4GRSVolume(fHistory.GetTopVolume(),
tf.NetRotation(),
tf.NetTranslation());
}
G4GRSSolid* G4Navigator::CreateGRSSolid() const
{
G4AffineTransform tf(fHistory.GetTopTransform().Inverse());
return new G4GRSSolid(fHistory.GetTopVolume()->GetLogicalVolume()->GetSolid(),
tf.NetRotation(),
tf.NetTranslation());
}
G4TouchableHistory* G4Navigator::CreateTouchableHistory() const
{
return new G4TouchableHistory(fHistory);
}
// Renavigate & reset hierarchy described by current history
// o Reset volumes
// o Recompute transforms and/or solids of replicated/parameterised vols
@@ -719,14 +690,6 @@ G4std::ostream& operator << (G4std::ostream &os,const G4Navigator &n)
return os;
}
// Return global to local transformation
const G4AffineTransform G4Navigator::GetLocalToGlobalTransform() const
{
G4AffineTransform tempTransform;
tempTransform= fHistory.GetTopTransform().Inverse();
return tempTransform;
}
// Obtain the Normal vector to a surface (in local coordinates)
// pointing out of previous volume and into current volume
//
@@ -842,23 +805,12 @@ G4double G4Navigator::ComputeSafety(const G4ThreeVector &pGlobalpoint,
return newSafety;
}
G4bool G4Navigator::EnteredDaughterVolume()
{
return fEnteredDaughter;
}
// G4bool G4Navigator::ExitedVolume()
// {
// return fExitedCurrent;
// }
void G4Navigator::PrintState()
{
if( fVerbose >= 4 )
{
G4cout.precision(3);
G4cout << " Upon exiting my state is: " << G4endl;
G4cout << "The current state of G4Navigator is: " << G4endl;
G4cout << " ValidExitNormal= " << fValidExitNormal << G4endl
<< " ExitNormal = " << fExitNormal << G4endl
<< " Exiting = " << fExiting << G4endl
@@ -876,7 +828,7 @@ void G4Navigator::PrintState()
if( ( 1 < fVerbose) && (fVerbose < 4) )
{
G4cout.precision(3);
G4cout << G4std::setw(18) << " ExitNormal " << " "
G4cout << G4std::setw(24) << " ExitNormal " << " "
<< G4std::setw( 5) << " Valid " << " "
<< G4std::setw( 9) << " Exiting " << " "
<< G4std::setw( 9) << " Entering" << " "
@@ -884,7 +836,7 @@ void G4Navigator::PrintState()
<< G4std::setw( 9) << " ReplicaNo" << " "
<< G4std::setw( 8) << " LastStepZero " << " "
<< G4endl;
G4cout << G4std::setw(18) << fExitNormal << " "
G4cout << G4std::setw(24) << fExitNormal << " "
<< G4std::setw( 5) << fValidExitNormal << " "
<< G4std::setw( 9) << fExiting << " "
<< G4std::setw( 9) << fEntering << " ";
@@ -954,6 +906,18 @@ void G4Navigator::LocateGlobalPointWithinVolume(const G4ThreeVector& pGlobalpoi
}
}
// Reset the state variables
// - which would have been affected
// by the 'equivalent' call to LocateGlobalPointAndSetup
// - who's values have been invalidated by the 'move'.
//fWasLimitedByGeometry= false;
//fBlockedPhysicalVolume=0;
//fBlockedReplicaNo= -1;
//fEntering=false;
//fEnteredDaughter=false; // Boundary not encountered, did not enter
//fExiting=false;
//fExitedMother=false; // Boundary not encountered, did not exit
#if 0
else
{
@@ -992,14 +956,3 @@ void G4Navigator::LocateGlobalPointWithinVolume(const G4ThreeVector& pGlobalpoi
#endif
}
G4int G4Navigator::GetVerboseLevel()
{
return fVerbose;
}
void G4Navigator::SetVerboseLevel(G4int level)
{
fVerbose=level;
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4NormalNavigation.cc,v 1.3.4.1 2001/06/28 19:09:44 gunter Exp $
// GEANT4 tag $Name: $
// $Id: G4NormalNavigation.cc,v 1.4 2001/07/11 10:00:33 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
//
// class G4NormalNavigation Implementation
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4ParameterisedNavigation.cc,v 1.3.4.1 2001/06/28 19:09:44 gunter Exp $
// GEANT4 tag $Name: $
// $Id: G4ParameterisedNavigation.cc,v 1.4 2001/07/11 10:00:33 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
//
// class G4ParameterisedNavigation Implementation
@@ -21,14 +21,13 @@
// ********************************************************************
//
//
// $Id: G4PropagatorInField.cc,v 1.19.2.1 2001/06/28 19:09:44 gunter Exp $
// GEANT4 tag $Name: $
//
// $Id: G4PropagatorInField.cc,v 1.28 2001/12/08 01:17:04 japost Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
//
// This routine implements an algorithm to track a particle in a //
// non-uniform magnetic field. It utilises an ODE solver (with //
// the Runge - Kutta method) to evolve the particle, and drives it //
// This class implements an algorithm to track a particle in a
// non-uniform magnetic field. It utilises an ODE solver (with
// the Runge - Kutta method) to evolve the particle, and drives it
// until the particle has traveled a set distance or it enters a new
// volume.
//
@@ -39,6 +38,8 @@
// 17.03.97 John Apostolakis, renaming new set functions being added
//
// #define G4DEBUG_FIELD 1
#include "G4PropagatorInField.hh"
#include "G4ios.hh"
#include "g4std/iomanip"
@@ -48,7 +49,8 @@
//const G4double G4PropagatorInField::fDefault_Delta_Intersection_Val= 0.1 * mm;
//const G4double G4PropagatorInField::fDefault_Delta_One_Step_Value = 0.25 * mm;
const G4double G4PropagatorInField::fEpsilonMinDefault = 1.0e-10 ;
const G4double G4PropagatorInField::fEpsilonMinDefault = 5.0e-7;
const G4double G4PropagatorInField::fEpsilonMaxDefault = 0.05;
///////////////////////////////////////////////////////////////////////////
//
@@ -84,53 +86,84 @@ G4double G4PropagatorInField::
G4FieldTrack CurrentState(pFieldTrack);
#if 0
CurrentState.SetVelocity( pFieldTrack.GetMomentumDir() );
// For now, must utilize unit "velocity" J.A. Nov 17, 98
// Problem in setting the energy in this case .... (and in E field)
#endif
G4FieldTrack OriginalState= CurrentState;
// If the Step length is "infinite", then an approximate-maximum Step lenght
// (used to calculate the relative accuracy) must be guessed.
//
if( CurrentProposedStepLength >= kInfinity )
if( CurrentProposedStepLength >= fLargestAcceptableStep )
{
G4ThreeVector StartPointA, VelocityUnit;
StartPointA = pFieldTrack.GetPosition();
VelocityUnit= pFieldTrack.GetMomentumDir();
CurrentProposedStepLength= 1.e3 * ( 10.0 * cm +
G4double trialProposedStep= 1.e2 * ( 10.0 * cm +
fNavigator->GetWorldVolume()->GetLogicalVolume()->
GetSolid()->DistanceToOut(StartPointA, VelocityUnit) ) ;
CurrentProposedStepLength= G4std::min( trialProposedStep, fLargestAcceptableStep);
}
epsilon = GetDeltaOneStep() / CurrentProposedStepLength ;
if( epsilon < fEpsilonMin ) epsilon = fEpsilonMin ;
if( epsilon > fEpsilonMax ) epsilon = fEpsilonMax ;
this->SetEpsilonStep( epsilon );
if( fNoZeroStep > fThresholdNo_ZeroSteps ) {
// Shorten the proposed step in case of earlier problems (zero steps)
//
if( fNoZeroStep > fActionThreshold_NoZeroSteps ) {
G4double stepTrial; // = fMidPoint_CurveLen_of_LastAttempt;
stepTrial= 0.5 * fFull_CurveLen_of_LastAttempt;
stepTrial= fFull_CurveLen_of_LastAttempt;
if( (stepTrial <= 0.0) && (fLast_ProposedStepLength>0.0) )
stepTrial=0.5 * fLast_ProposedStepLength;
if( fNoZeroStep > 2*fThresholdNo_ZeroSteps ){
stepTrial *= 0.5; // Ensure quicker convergence.
if( (stepTrial == 0.0)
|| ( fNoZeroStep > 5*fThresholdNo_ZeroSteps ) ) {
G4cerr << " G4PropagatorInField::ComputeStep "
<< " ERROR : attempting a zero step= " << stepTrial << G4endl
<< " and/or no progress after " << fNoZeroStep
<< " trial steps. ABORTING." << G4endl;
G4Exception("G4PropagatorInField::ComputeStep No progress - Looping with zero steps");
}
stepTrial= fLast_ProposedStepLength;
G4double decreaseFactor=0.9; // Unused default
// G4double thisTolerance= kCarTolerance;
if( (fNoZeroStep < fSevereActionThreshold_NoZeroSteps)
&& (stepTrial > 1000.0*kCarTolerance) ){
// Ensure quicker convergence.
decreaseFactor= 0.1;
} else {
// We are in significant difficulties, probably at a boundary
// that is either geometrically sharp
// or between very different materials.
//
// Careful decreases to cope with tolerance are required.
if(stepTrial > 1000.0*kCarTolerance)
decreaseFactor= 0.25; // Try slow decreases
else if(stepTrial > 100.0*kCarTolerance)
decreaseFactor= 0.5; // Try slower decreases
else if(stepTrial > 10.0*kCarTolerance)
decreaseFactor= 0.75; // Try even slower decreases
else
decreaseFactor= 0.9; // Try very slow decreases
}
CurrentProposedStepLength = stepTrial;
stepTrial *= decreaseFactor;
#ifdef G4DEBUG_FIELD
PrintStepLengthDiagnostic(CurrentProposedStepLength, decreaseFactor,
stepTrial, pFieldTrack);
#endif
if( (stepTrial == 0.0) ) {
// || ( fNoZeroStep > fAbandonThresholdNo_ZeroSteps ) ) {
G4cout << " G4PropagatorInField::ComputeStep "
<< " Particle abandoned due to lack of progress in field."
<< G4endl
<< " Properties : " << pFieldTrack << " "
<< G4endl;
G4cerr << " G4PropagatorInField::ComputeStep "
<< " ERROR : attempting a zero step= " << stepTrial << G4endl
<< " while attempting to progress after " << fNoZeroStep
<< " trial steps. Will abandon step." << G4endl;
// G4Exception("G4PropagatorInField::ComputeStep No progress - Looping with zero steps");
fParticleIsLooping= true;
return 0; // = stepTrial;
}
if( stepTrial < CurrentProposedStepLength)
CurrentProposedStepLength = stepTrial;
}
fLast_ProposedStepLength= CurrentProposedStepLength;
@@ -215,7 +248,7 @@ G4double G4PropagatorInField::
StepTaken =
TruePathLength= IntersectPointVelct_G.GetCurveLength()
- OriginalState.GetCurveLength(); // which is Zero now.
#ifdef G4VERBOSE
#ifdef G4DEBUG_FIELD
if( Verbose() > 0 )
G4cout << " Found intersection after Step of length " <<
StepTaken << G4endl;
@@ -232,21 +265,30 @@ G4double G4PropagatorInField::
StepTaken += s_length_taken;
}
first_substep= false;
#ifdef G4VERBOSE
if( Verbose() > 0 )
printStatus( SubStepStartState, // or OriginalState,
#ifdef G4DEBUG_FIELD
// if( fNoZeroStep )
if( fNoZeroStep > fActionThreshold_NoZeroSteps )
{
// if( Verbose() > 0 )
//if(do_loop_count==0)
// G4cout << "G4PiF: End of Step " << do_loop_count;
printStatus( SubStepStartState, // or OriginalState,
CurrentState,
CurrentProposedStepLength,
NewSafety,
do_loop_count,
pPhysVol);
// G4cout << " Step accepted taken =" << StepTaken << G4endl;
}
#endif
do_loop_count++;
}
while( (!intersects ) && (StepTaken + kCarTolerance < CurrentProposedStepLength)
&& ( do_loop_count < GetMaxLoopCount() ) );
#ifdef G4VERBOSE
if( do_loop_count >= GetMaxLoopCount() ){
@@ -294,6 +336,14 @@ G4double G4PropagatorInField::
}
#endif
#ifdef G4DEBUG_FIELD
if( fNoZeroStep ){
G4cout << " PiF: Step returning=" << StepTaken << G4endl;
G4cout << " ------------------------------------------------------- "
<< G4endl;
}
#endif
// In particular anomalous cases, we can get repeated zero steps
// In order to correct this efficiently, we identify these cases
// and only take corrective action when they occur.
@@ -303,6 +353,14 @@ G4double G4PropagatorInField::
else
fNoZeroStep= 0;
if( fNoZeroStep > fAbandonThreshold_NoZeroSteps ) {
G4cout << " G4PropagatorInField::ComputeStep : Warning :"
<< " no progress after " << fNoZeroStep << " trial steps. "
<< G4endl;
G4cout << " Particle will be abandoned." ;
fParticleIsLooping= true;
}
return TruePathLength;
}
@@ -512,7 +570,7 @@ G4PropagatorInField::LocateIntersectionPoint(
GetChordFinder()->GetIntegrationDriver()
->AccurateAdvance(newEndpoint, curveDist, GetEpsilonStep() );
CurrentB_PointVelocity= newEndpoint;
#ifdef G4DEBUG
#ifdef G4DEBUG_FIELD
static int noInaccuracyWarnings = 0;
const int maxNoWarnings = 10;
if( (noInaccuracyWarnings < maxNoWarnings )
@@ -528,6 +586,10 @@ G4PropagatorInField::LocateIntersectionPoint(
#endif
}
if( curveDist < 0.0 ) {
G4cerr << "G4PropagatorInField::LocateIntersectionPoint: "
<< "Error in advancing " << G4endl;
printStatus( CurrentA_PointVelocity, CurrentB_PointVelocity,
-1.0, NewSafety, substep_no, 0); // startVolume);
G4Exception("G4PropagatorInField::LocateIntersectionPoint : the final curve point is not further along than the original.");
}
@@ -584,13 +646,13 @@ void G4PropagatorInField::printStatus(
<< G4std::setw( 7) << " N_y " << " "
<< G4std::setw( 7) << " N_z " << " "
<< G4std::setw( 9) << "StepLen" << " "
<< G4std::setw( 9) << "PhsStep" << " "
<< G4std::setw(12) << "PhsStep" << " "
<< G4std::setw(12) << "StartSafety" << " "
<< G4std::setw(18) << "NextVolume" << " "
<< G4endl;
// Recurse to print the start values
printStatus( StartFT, StartFT, //
-1.0, safety, -1, 0); // startVolume);
-1.0, safety, -1, startVolume);
}
if( verboseLevel <= 3 )
@@ -608,9 +670,9 @@ void G4PropagatorInField::printStatus(
<< G4std::setw( 7) << CurrentUnitVelocity.z() << " ";
G4cout << G4std::setw( 9) << step_len << " ";
if( requestStep != -1.0 )
G4cout << G4std::setw( 9) << requestStep << " ";
G4cout << G4std::setw( 12) << requestStep << " ";
else
G4cout << G4std::setw( 9) << " InitialStep " << " ";
G4cout << G4std::setw( 12) << "InitialStep" << " ";
G4cout << G4std::setw(12) << safety << " ";
if( startVolume != 0) {
@@ -639,3 +701,22 @@ void G4PropagatorInField::printStatus(
G4cout << G4endl;
}
}
void
G4PropagatorInField::PrintStepLengthDiagnostic(G4double CurrentProposedStepLength,
G4double decreaseFactor,
G4double stepTrial,
const G4FieldTrack& aFieldTrack)
{
G4cout << " PiF: NoZeroStep= " << fNoZeroStep
<< " CurrentProposedStepLength= " << CurrentProposedStepLength
<< " Full_curvelen_last=" << fFull_CurveLen_of_LastAttempt
<< " last proposed step-length= " << fLast_ProposedStepLength
<< " decreate factor = " << decreaseFactor
<< " step trial = " << stepTrial
<< G4endl;
// printStatus( pFieldTrack, pFieldTrack, CurrentProposedStepLength,
// -1.0, 0, pPhysVol);
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4ReplicaNavigation.cc,v 1.9.2.1 2001/06/28 19:09:44 gunter Exp $
// GEANT4 tag $Name: $
// $Id: G4ReplicaNavigation.cc,v 1.10 2001/07/11 10:00:33 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
//
// class G4ReplicaNavigation Implementation
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4TouchableHistory.cc,v 1.4.4.1 2001/06/28 19:09:44 gunter Exp $
// GEANT4 tag $Name: $
// $Id: G4TouchableHistory.cc,v 1.5 2001/07/11 10:00:34 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
//
// class G4TouchableHistory Implementation
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4TransportationManager.cc,v 1.6.2.1 2001/06/28 19:09:45 gunter Exp $
// GEANT4 tag $Name: $
// $Id: G4TransportationManager.cc,v 1.9 2001/10/24 15:33:49 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
//
// G4TransportationManager
@@ -32,12 +32,14 @@
// The following inclusions should be left here, as only
// the constructor and destructor require them.
#include "G4GeometryMessenger.hh"
#include "G4PropagatorInField.hh"
#include "G4FieldManager.hh"
// This will ensure correct order of construction and destruption of
// static objects.
#include "G4NavigationLevel.hh"
G4Allocator<G4NavigationLevel> aNavigationLevelAllocator;
G4Allocator<G4NavigationLevelRep> aNavigLevelRepAllocator;
@@ -45,6 +47,9 @@ G4Allocator<G4NavigationLevelRep> aNavigLevelRepAllocator;
const G4double G4FieldManager::fDefault_Delta_Intersection_Val= 0.1 * mm;
const G4double G4FieldManager::fDefault_Delta_One_Step_Value = 0.25 * mm;
// const G4double G4PropagatorInField::fDefault_Delta_Intersection_Val= 0.1 * mm;
// const G4double G4PropagatorInField::fDefault_Delta_One_Step_Value = 0.25 * mm;
// const G4double G4PropagatorInField::fEpsilonMin = 1.0e-10 ;
G4TransportationManager* G4TransportationManager::fTransportationManager=0;
@@ -52,6 +57,7 @@ G4TransportationManager::G4TransportationManager()
{
if (!fTransportationManager)
{
fGeomMessenger= new G4GeometryMessenger(this);
fNavigatorForTracking= new G4Navigator() ;
fFieldManager= new G4FieldManager() ;
fPropagatorInField= new G4PropagatorInField( fNavigatorForTracking,
@@ -66,6 +72,7 @@ G4TransportationManager::G4TransportationManager()
G4TransportationManager::~G4TransportationManager()
{
delete fGeomMessenger;
delete fNavigatorForTracking;
delete fPropagatorInField;
delete fFieldManager;
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4VoxelNavigation.cc,v 1.7.2.1 2001/06/28 19:09:45 gunter Exp $
// GEANT4 tag $Name: $
// $Id: G4VoxelNavigation.cc,v 1.8 2001/07/11 10:00:34 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
//
// class G4VoxelNavigation Implementation