Import Geant4 0.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 15:09:25 +02:00
parent b97f8d0df7
commit aaa409b6ee
2922 changed files with 55107 additions and 81674 deletions
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4BlockingList.cc,v 2.1 1998/07/12 02:58:25 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4BlockingList.cc,v 1.1 1999/01/07 16:08:47 gunter Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
//
// class G4BlockingList Implementation
+2 -2
View File
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4GRSSolid.cc,v 2.0 1998/07/02 17:06:27 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4GRSSolid.cc,v 1.1 1999/01/07 16:08:47 gunter Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
//
// class G4GRSSolid Implementation
+2 -2
View File
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4GRSVolume.cc,v 2.0 1998/07/02 17:06:28 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4GRSVolume.cc,v 1.1 1999/01/07 16:08:47 gunter Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
//
// class G4GRSVolume Implementation
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4LogicalBorderSurface.cc,v 2.1 1998/07/13 16:55:04 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4LogicalBorderSurface.cc,v 1.1 1999/01/07 16:08:47 gunter Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
////////////////////////////////////////////////////////////////////////
// G4LogicalBorderSurface Implementation
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4LogicalSkinSurface.cc,v 2.1 1998/07/13 16:55:06 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4LogicalSkinSurface.cc,v 1.1 1999/01/07 16:08:48 gunter Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
////////////////////////////////////////////////////////////////////////
// G4LogicalSkinSurface Implementation
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4NavigationHistory.cc,v 2.1 1998/07/13 16:55:07 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4NavigationHistory.cc,v 1.1 1999/01/07 16:08:48 gunter Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
//
// G4NavigationHistory Implementation P.Kent August 96
@@ -1,14 +0,0 @@
// This code implementation is the intellectual property of
// the RD44 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: G4NavigationLevel.cc,v 2.0 1998/07/02 17:06:33 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4NavigationLevel.hh"
G4Allocator<G4NavigationLevel> aNavigationLevelAllocator;
G4Allocator<G4NavigationLevelRep> aNavigLevelRepAllocator;
+115 -48
View File
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4Navigator.cc,v 2.6 1998/11/25 17:57:23 japost Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4Navigator.cc,v 1.6 1999/05/17 14:19:09 stesting Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
//
// class G4Navigator Implementation Paul Kent July 95/96
@@ -71,13 +71,13 @@ G4Navigator::LocateGlobalPointAndSetup(const G4ThreeVector& globalPoint,
#ifdef G4VERBOSE
if( fVerbose > 0 )
{
cout << "G4Navigator::LocateGlobalPointAndSetup: " << endl;
cout.precision(8);
cout << " I was called with the following arguments: " << endl
<< " Globalpoint = " << globalPoint << endl
<< " relativeSearch = " << relativeSearch << endl;
G4cout << "*** G4Navigator::LocateGlobalPointAndSetup: ***" << endl;
G4cout.precision(8);
G4cout << " I was called with the following arguments: " << endl
<< " Globalpoint = " << globalPoint << endl
<< " relativeSearch = " << relativeSearch << endl;
// << " = " << << endl
cout << " Upon entering my state is: " << endl;
G4cout << " Upon entering my state is: " << endl;
PrintState();
}
#endif
@@ -109,8 +109,11 @@ G4Navigator::LocateGlobalPointAndSetup(const G4ThreeVector& globalPoint,
// A fix for the case where a volume is "entered" at an edge
// and a coincident surface exists outside it.
// This stops it from exiting further volumes and cycling
if( fLastStepWasZero )
// - This stops it from exiting further volumes and cycling
// - However ReplicaNavigator treats this case itself
if( fLocatedOnEdge
&& (VolumeType(fBlockedPhysicalVolume) != kReplica ))
// ( fLastStepWasZero )
{
fExiting= false;
}
@@ -321,11 +324,13 @@ G4Navigator::LocateGlobalPointAndSetup(const G4ThreeVector& globalPoint,
if( fVerbose > 1 )
{
cout.precision(6);
G4cout.precision(6);
cout << " Return value = new volume = "
<< (targetPhysical==0 ? G4String("None") :
targetPhysical->GetName() ) << endl;
G4String curPhysVol_Name("None");
if (targetPhysical!=0)
curPhysVol_Name= targetPhysical->GetName();
G4cout << " Return value = new volume = "
<< curPhysVol_Name << endl;
}
#endif
@@ -393,6 +398,9 @@ G4double G4Navigator::ComputeStep(const G4ThreeVector &pGlobalpoint,
}
#endif
static G4double fAccuracyForWarning= kCarTolerance,
fAccuracyForException= 1000*kCarTolerance;
G4ThreeVector newLocalPoint =ComputeLocalPoint(pGlobalpoint);
if( newLocalPoint != fLastLocatedPointLocal )
{
@@ -432,17 +440,62 @@ G4double G4Navigator::ComputeStep(const G4ThreeVector &pGlobalpoint,
G4double safetyPlus = safety + kCarTolerance;
assert( moveLenSq <= sqr(safetyPlus) );
#endif
// Check that the starting point of this step is
// within the isotropic safety sphere of the last point
// to a accuracy/precision given by
// fAccuracyForWarning
// If so give warning. If it fails by more than
// fAccuracyForException
// exit with error.
if( shiftOriginSafSq >= sqr(fPreviousSafety) ){
G4double shiftOrigin=sqrt(shiftOriginSafSq);
if( shiftOrigin > fPreviousSafety + kCarTolerance ){
G4cerr << " ERROR in G4Navigator::ComputeStep: " << endl
<< "The Step's starting point has moved " << sqrt(moveLenSq)
<< " since the last call to one of the Locate methods " << endl
<< " This has resulted in moving " << shiftOrigin
<< " from the last point at which the safety was calculated "
<< endl
<< " which is more than the computed safety= "
<< fPreviousSafety << "at that point." << endl;
G4double diffShiftSaf= shiftOrigin - fPreviousSafety;
G4bool isError;
if( diffShiftSaf > fAccuracyForWarning ){
isError = ( diffShiftSaf >= fAccuracyForException );
G4cerr.precision(10);
if ( isError )
G4cerr << "Accuracy ERROR found in G4Navigator::ComputeStep: " << endl;
else
G4cerr << "Warning G4Navigator::ComputeStep found slightly inaccurate position:" << endl;
G4cerr << " The Step's starting point has moved "
<< sqrt(moveLenSq)/mm << " mm " << endl
<< " since the last call to a Locate method." << endl;
G4cerr << " This has resulted in moving "
<< shiftOrigin/mm << " mm "
<< " from the last point at which the safety "
<< " was calculated " << endl;
G4cerr << " which is more than the computed safety= "
<< fPreviousSafety/mm << " mm at that point." << endl;
G4cerr << " This difference is "
<< diffShiftSaf /mm << " mm." << endl;
#ifdef G4VERBOSE
static G4int warnNow= 0;
if( ((++warnNow % 100) == 1) ) { // || (warnNow < 4) ){
G4cerr << " This problem can be due to either " << endl;
G4cerr << " - a process that has proposed a displacement"
<< " larger than the current safety , or" << endl;
G4cerr << " - inaccuracy in the computation of the safety" << endl;
G4cerr << " - if you are using a magnetic field, a known conflict about the safety exists in this case."
<< endl;
G4cerr << " We suggest that you " << endl
<< " - find i) what particle is being tracked, and "
<< " ii) through what part of your geometry " << endl
<< " for example by reruning this event with " << endl
<< " /tracking/verbose 1 " << endl
<< " - check which processes you declare for this particle"
<< " (and look at non-standard ones) " << endl
<< " - if possible create a detailed logfile "
<< " of this event using:" << endl
<< " /tracking/verbose 6 "
<< endl;
}
// G4cerr << " - ." << endl;
#endif
}
#ifdef DEBUG
else
@@ -454,7 +507,7 @@ G4double G4Navigator::ComputeStep(const G4ThreeVector &pGlobalpoint,
}
#endif
}
G4double safetyPlus = fPreviousSafety+ kCarTolerance;
G4double safetyPlus = fPreviousSafety+ fAccuracyForException;
assert( shiftOriginSafSq <= sqr(safetyPlus) );
// Relocate the point within the same volume
@@ -518,6 +571,9 @@ G4double G4Navigator::ComputeStep(const G4ThreeVector &pGlobalpoint,
}
else
{
// In the case of a replica,
// it must handles the exiting edge/corner problem by itself
G4bool exitingReplica= fExitedMother;
Step=freplicaNav.ComputeStep(pGlobalpoint,
pDirection,
fLastLocatedPointLocal,
@@ -527,10 +583,12 @@ G4double G4Navigator::ComputeStep(const G4ThreeVector &pGlobalpoint,
fHistory,
fValidExitNormal,
fExitNormal,
fExiting,
exitingReplica,
fEntering,
&fBlockedPhysicalVolume,
fBlockedReplicaNo);
// still ok to set it ??
fExiting= exitingReplica;
}
if( (Step == pCurrentProposedStepLength) && (!fExiting) && (!fEntering) )
@@ -698,7 +756,7 @@ G4ThreeVector G4Navigator::GetLocalExitNormal(G4bool* valid)
}
// It assumes that it assumes that it will be
// i) called with the Point equal to the EndPoint of the ComputeStep.
// 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 G4Navigator::ComputeSafety(const G4ThreeVector &pGlobalpoint,
@@ -710,17 +768,20 @@ G4double G4Navigator::ComputeSafety(const G4ThreeVector &pGlobalpoint,
#ifdef G4VERBOSE
if( fVerbose > 0 )
{
cout << "*** G4Navigator::ComputeSafety: ***" << endl;
cout.precision(8);
cout << " I was called with the following arguments: " << endl
G4cout << "*** G4Navigator::ComputeSafety: ***" << endl;
G4cout.precision(8);
G4cout << " I was called with the following arguments: " << endl
<< " Globalpoint = " << pGlobalpoint << endl;
// cout << " pMaxLength = " << pMaxLength << endl;
cout << " Upon entering my state is: " << endl;
G4cout << " Upon entering my state is: " << endl;
PrintState();
}
#endif
// Pseudo-relocate to this point (updates voxel information only).
LocateGlobalPointWithinVolume( pGlobalpoint );
if( ! (fEnteredDaughter || fExitedMother ) )
{
G4VPhysicalVolume *motherPhysical=fHistory.GetTopVolume();
@@ -800,45 +861,51 @@ void G4Navigator::PrintState()
{
if( fVerbose >= 4 )
{
cout.precision(3);
cout << " Upon exiting my state is: " << endl;
cout << " ValidExitNormal= " << fValidExitNormal << endl
G4cout.precision(3);
G4cout << " Upon exiting my state is: " << endl;
G4cout << " ValidExitNormal= " << fValidExitNormal << endl
<< " ExitNormal = " << fExitNormal << endl
<< " Exiting = " << fExiting << endl
<< " Entering = " << fEntering << endl
<< " BlockedPhysicalVolume= " << (fBlockedPhysicalVolume==0 ? G4String("None") :
fBlockedPhysicalVolume->GetName() ) << endl
<< " BlockedPhysicalVolume= " ;
if (fBlockedPhysicalVolume==0 )
G4cout << "None";
else
G4cout << fBlockedPhysicalVolume->GetName();
G4cout << endl
<< " BlockedReplicaNo = " << fBlockedReplicaNo << endl
<< " LastStepWasZero = " << fLastStepWasZero << endl
<< endl;
}
if( ( 1 < fVerbose) && (fVerbose < 4) )
{
cout.precision(3);
cout << setw(18) << " ExitNormal " << " "
<< setw( 9) << " Valid " << " "
G4cout.precision(3);
G4cout << setw(18) << " ExitNormal " << " "
<< setw( 5) << " Valid " << " "
<< setw( 9) << " Exiting " << " "
<< setw( 9) << " Entering" << " "
<< setw(15) << " Blocked:Volume " << " "
<< setw( 9) << " ReplicaNo" << " "
<< setw( 8) << " LastStepZero " << " "
<< endl;
cout << setw(24) << fExitNormal << " "
<< setw( 3) << fValidExitNormal << " "
G4cout << setw(18) << fExitNormal << " "
<< setw( 5) << fValidExitNormal << " "
<< setw( 9) << fExiting << " "
<< setw( 9) << fEntering << " "
<< setw(15) << (fBlockedPhysicalVolume==0 ? G4String("None") :
fBlockedPhysicalVolume->GetName() ) << " "
<< setw( 9) << fBlockedReplicaNo << " "
<< setw( 9) << fEntering << " ";
if (fBlockedPhysicalVolume==0 )
G4cout << setw(15) << "None";
else
G4cout << setw(15)<< fBlockedPhysicalVolume->GetName();
G4cout << setw( 9) << fBlockedReplicaNo << " "
<< setw( 8) << fLastStepWasZero << " "
<< endl;
}
if( fVerbose > 2 )
{
cout.precision(8);
cout << " Current Localpoint = " << fLastLocatedPointLocal << endl;
cout << " PreviousSftOrigin = " << fPreviousSftOrigin << endl;
cout << " PreviousSafety = " << fPreviousSafety << endl;
G4cout.precision(8);
G4cout << " Current Localpoint = " << fLastLocatedPointLocal << endl;
G4cout << " PreviousSftOrigin = " << fPreviousSftOrigin << endl;
G4cout << " PreviousSafety = " << fPreviousSafety << endl;
}
}
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4NormalNavigation.cc,v 2.0 1998/07/02 17:06:37 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4NormalNavigation.cc,v 1.1 1999/01/07 16:08:49 gunter Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
//
// class G4NormalNavigation Implementation
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4ParameterisedNavigation.cc,v 2.4 1998/09/15 13:57:33 japost Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4ParameterisedNavigation.cc,v 1.1 1999/01/07 16:08:49 gunter Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
//
// class G4ParameterisedNavigation Implementation
@@ -0,0 +1,594 @@
// This code implementation is the intellectual property of
// the RD44 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: G4PropagatorInField.cc,v 1.2 1999/07/01 17:56:22 japost Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
//
//
// 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 //
// until the particle has traveled a set distance or it enters a new
// volume.
//
// Caveat: tracking is not exact - volumes can be missed!
//
//
// 14.10.96 John Apostolakis, design and implementation
// 17.03.97 John Apostolakis, renaming new set functions being added
//
#include "G4PropagatorInField.hh"
#include "G4ios.hh"
#include <iomanip.h>
const G4double G4PropagatorInField::delta_intersection_val= 0.1 * mm;
const G4double G4PropagatorInField::delta_one_step_val = 0.25 * mm;
G4double
G4PropagatorInField::
ComputeStep(const G4ThreeVector & StartPointA,
const G4ThreeVector & Velocity, // Unit or non
G4double CurrentProposedStepLength,
G4double &currentSafety, // In/Out
G4VPhysicalVolume *pPhysVol )
// Compute the next geometric Step for simple magnetic field
{
G4FieldTrack aFieldTrack =
G4FieldTrack( StartPointA,
Velocity,
0.0, // length of path
0.0, // energy
0.0, // lab tof
0.0, // proper tof
0 );
// Do the Transport in the field (non recti-linear)
return this->ComputeStep( aFieldTrack,
CurrentProposedStepLength,
currentSafety );
}
G4double
G4PropagatorInField::
ComputeStep(G4FieldTrack& pFieldTrack,
G4double CurrentProposedStepLength,
G4double& currentSafety, // IN/OUT
G4VPhysicalVolume *pPhysVol)
// Compute the next geometric Step
{
// Parameters for adaptive Runge-Kutta integration
//
G4double h_TrialStepSize; // 1st Step Size
G4double TruePathLength;
G4double StepTaken= 0.0;
G4double s_length_taken;
G4bool intersects;
G4bool first_substep= true;
G4double NewSafety;
fParticleIsLooping= false;
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 ){
G4ThreeVector StartPointA, VelocityUnit;
StartPointA = pFieldTrack.GetPosition();
VelocityUnit= pFieldTrack.GetMomentumDir();
CurrentProposedStepLength= 1.e3 * ( 10.0 * cm +
fNavigator->GetWorldVolume()->GetLogicalVolume()->
GetSolid()->DistanceToOut(StartPointA, VelocityUnit) ) ;
}
this->SetEpsilonStep( DeltaOneStep() / CurrentProposedStepLength);
G4int do_loop_count=0;
do
{
do_loop_count++;
G4FieldTrack SubStepStartState= CurrentState;
G4ThreeVector SubStartPoint= CurrentState.GetPosition();
// WAS = G4Navigator::Locate...
if( !first_substep)
{
fNavigator->LocateGlobalPointWithinVolume( SubStartPoint );
}
// First figure out how far to evolve the particle !
// -------------------------------------------------
// and (later) with what accuracy to calculate this path.
//
h_TrialStepSize= CurrentProposedStepLength - StepTaken ;
// Next evolve it as far as this allows.
// ---------------------------------------
//
// B <- Integrator - limited by the "chord miss" rule.
//
s_length_taken= GetChordFinder()->AdvanceChordLimited(
CurrentState, // Position & velocity
h_TrialStepSize,
GetEpsilonStep() );
// On Exit:
// CurrentState is updated with the final position and velocity.
G4ThreeVector EndPointB= CurrentState.Position();
// Calculate the direction and length of the chord AB
G4ThreeVector ChordAB_Vector= EndPointB - SubStartPoint;
G4double ChordAB_Length= ChordAB_Vector.mag(); // Magnitude (norm)
G4ThreeVector ChordAB_Dir= ChordAB_Vector.unit();
// Check whether any volumes are encountered by the chord AB
G4double LinearStepLength =
fNavigator->ComputeStep( SubStartPoint, ChordAB_Dir,
ChordAB_Length, NewSafety);
if( first_substep )
{
currentSafety= NewSafety;
}
// It might also be possible to update safety in other steps, but
// it must be Done with care. J.Apostolakis August 5th, 1997
intersects= (LinearStepLength <= ChordAB_Length);
// G4Navigator contracts to return k_infinity if len==asked
// and it did not find a surface boundary at that length
LinearStepLength = min( LinearStepLength, ChordAB_Length);
if( intersects )
{
// E <- Intersection Point of chord AB and either volume A's surface
// or a daughter volume's surface ..
G4ThreeVector pointE= SubStartPoint + LinearStepLength * ChordAB_Dir;
G4FieldTrack IntersectPointVelct_G(CurrentState); // FT-Def-Construct
// Find the intersection point of AB true path with the surface
// of vol(A) given our current "estimate" point E.
G4bool found_intersection=
LocateIntersectionPoint( SubStepStartState, CurrentState,
pointE, IntersectPointVelct_G );
if( found_intersection )
{
// G is our EndPoint ...
G4ThreeVector IntersectPoint_G = IntersectPointVelct_G.Position();
End_PointAndTangent= IntersectPointVelct_G;
G4ThreeVector NewChord= IntersectPoint_G - SubStartPoint;
// LinearStepLength= NewChord.mag();
StepTaken =
TruePathLength= IntersectPointVelct_G.CurveS()
- OriginalState.CurveS(); // which is Zero now.
#ifdef G4VERBOSE
if( Verbose() > 0 ){
G4cout << " Found an intersection after a Step of length " <<
StepTaken << endl;
}
#endif
// TruePathLength= StepTaken;
}
else
{
// "Minor" chords do not intersect
intersects= false;
}
}
if( ! intersects )
{
StepTaken += s_length_taken;
}
first_substep= false;
#ifdef G4VERBOSE
if( Verbose() > 0 )
printStatus( SubStepStartState, // or OriginalState,
CurrentState,
CurrentProposedStepLength,
NewSafety,
do_loop_count,
pPhysVol);
#endif
}
while( (!intersects ) && (StepTaken < CurrentProposedStepLength)
&& ( do_loop_count < GetMaxLoopCount() ) );
#ifdef G4VERBOSE
if( do_loop_count >= GetMaxLoopCount() ){
G4cerr << "G4PropagateInField: Warning: Particle is looping - "
<< " tracking in field will be stopped. " << endl;
G4cerr << " It has performed " << do_loop_count << " steps in Field "
<< " while a maximum of " << GetMaxLoopCount() << " are allowed. "
<< endl;
//G4cerr << " In future this will be treated better/quicker. " << endl;
fParticleIsLooping= true;
}
#endif
if( ! intersects )
{
// Chord AB or "minor chords" do not intersect
// B is the endpoint Step of the current Step.
// [ But if we were angle limited we could use B
// as a new starting point ? ]
// On return we specify the endpoint, point B
End_PointAndTangent= CurrentState;
// LinearStepLength= ChordAB_Length;
TruePathLength= StepTaken;
} // end if(!intersects)
// Set pFieldTrack to the return value
pFieldTrack =End_PointAndTangent;
#ifdef G4VERBOSE
// Check that "s" is correct
if( fabs(OriginalState.CurveS() + TruePathLength
- End_PointAndTangent.CurveS()) > 3.e-4 * TruePathLength )
{
G4cerr << " Error in G4PropagatorInField: Curve lenght mis-match, is advancement wrong ? ";
G4cerr << " The curve length of the endpoint should be "
<< OriginalState.CurveS() + TruePathLength
<< " and is " << End_PointAndTangent.CurveS()
<< " a difference of "
<< OriginalState.CurveS() + TruePathLength
- End_PointAndTangent.CurveS() << endl;
}
#endif
return TruePathLength;
}
// --------------------------------------------------------------------------
// G4bool
// G4PropagatorInField::LocateIntersectionPoint(
// const G4FieldTrack& CurveStartPointVelocity, // A
// const G4FieldTrack& CurveEndPointVelocity, // B
// const G4ThreeVector& TrialPoint, // E
// G4FieldTrack& IntersectPointVelocity) // Output
// --------------------------------------------------------------------------
//
// Function that returns the intersection of the true path with the surface
// of the current volume (either the external one or the inner one with one
// of the daughters
//
// A = Initial point
// B = another point
//
// Both A and B are assumed to be on the true path.
//
// E is the first point of intersection of the chord AB with
// a volume other than A (on the surface of A or of a daughter)
//
// First Version: October 16th, 1996 John Apostolakis, CERN CN/ASD
// Modified: January 22nd, 1997 J.A. IT/ASD
//
// Convention of Use :
// i) If it returns "true", then IntersectionPointVelocity is set
// to the approximate intersection point.
// ii) If it returns "false", no intersection was found and
// IntersectionPointVelocity is invalid.
// --------------------------------------------------------------------------
G4bool
G4PropagatorInField::LocateIntersectionPoint(
const G4FieldTrack& CurveStartPointVelocity, // A
const G4FieldTrack& CurveEndPointVelocity, // B
const G4ThreeVector& TrialPoint, // E
G4FieldTrack& IntersectPointVelocity) // Output
{
// Find Intersection Point ( A, B, E ) of true path AB - start at E.
G4bool found_approximate_intersection = false;
G4bool there_is_no_intersection = false;
G4FieldTrack CurrentA_PointVelocity= CurveStartPointVelocity;
G4FieldTrack CurrentB_PointVelocity= CurveEndPointVelocity;
G4ThreeVector CurrentE_Point= TrialPoint;
G4FieldTrack ApproxIntersecPointV(CurveEndPointVelocity); // FT-Def-Construct
G4double NewSafety;
G4bool first_step= true;
G4int substep_no= 0;
G4VPhysicalVolume *pPhysVol;
do{ // REPEAT
G4ThreeVector Point_A= CurrentA_PointVelocity.Position();
G4ThreeVector Point_B= CurrentB_PointVelocity.Position();
// F = a point on true AB path close to point E (the closest if possible)
//
ApproxIntersecPointV= GetChordFinder()->ApproxCurvePointV(
CurrentA_PointVelocity,
CurrentB_PointVelocity,
CurrentE_Point,
this->GetEpsilonStep() );
// The above function is the most difficult part ...
//
// Another approach would be for the curved true path
// to be an object and this should be a member function.
// -> The Curve Start and End point would not be needed as arguments.
//
G4ThreeVector CurrentF_Point= ApproxIntersecPointV.Position();
// First check whether EF is small - then F is a good approx. point
//
// Calculate the length and direction of the chord AF
// ChordEF_Vector= Chord_Vector(CurrentE_Point, CurrentF_Point);
// ------------
G4ThreeVector ChordEF_Vector = CurrentF_Point - CurrentE_Point;
if ( ChordEF_Vector.mag2() <= sqr(DeltaIntersection()) ){
found_approximate_intersection = true;
// Create the "point" return value
// IntersectPointVelocity.SetCurvePnt(
// CurrentE_Point,
// ApproxIntersecPointV.GetVelocity(),
// ApproxIntersecPointV.CurveS() );
IntersectPointVelocity = ApproxIntersecPointV;
IntersectPointVelocity.SetPosition( CurrentE_Point );
// Note: in order to return a point on the boundary,
// we must return E. But it is F on the curve.
// So we must "cheat": we are using the position at point E and
// the velocity at point F !!!
//
// This must limit the length we can allow for displacement!
}else{ // E is NOT close enough to the curve (ie point F).
if( !first_step){
// Check whether any volumes are encountered by the chord AF
//----------------------------------------------------------
fNavigator->LocateGlobalPointWithinVolume( Point_A );
// This locate is needed in all cases except for the
// original point A, because - presumably - that was
// called at the start of the physical Step
}
first_step= false;
// Calculate the length and direction of the chord AF
G4ThreeVector ChordAF_Vector= CurrentF_Point - Point_A;
G4double ChordAF_Length= ChordAF_Vector.mag();
G4ThreeVector ChordAF_Dir= ChordAF_Vector.unit();
G4double stepLength =
fNavigator->ComputeStep( Point_A, ChordAF_Dir,
ChordAF_Length, NewSafety);
G4bool Intersects_AF = (stepLength <= ChordAF_Length);
stepLength = min(stepLength, ChordAF_Length);
if( Intersects_AF ){
// There is an intersection of AF with a volume boundary
// G <- First Intersection of Chord AF
//
G4ThreeVector PointG= Point_A + stepLength * ChordAF_Dir;
// G is our new Candidate for the intersection point.
// It replaces "E" and we will repeat the test to see if
// it is a good enough approximate point for us.
// B <- F
// E <- G
CurrentB_PointVelocity= ApproxIntersecPointV;
CurrentE_Point= PointG;
// Else (not Intersects_AF)
}else{
// In this case:
// There is NO intersection of AF with a volume boundary.
// We must continue the search in the segment FB!
// Check whether any volumes are encountered by the chord FB
//----------------------------------------------------------
// Calculate the length and direction of the chord AF
G4ThreeVector ChordFB_Vector= Point_B - CurrentF_Point;
G4double ChordFB_Length= ChordFB_Vector.mag();
G4ThreeVector ChordFB_Dir= ChordFB_Vector.unit();
fNavigator->LocateGlobalPointWithinVolume( CurrentF_Point );
G4double stepLength =
fNavigator->ComputeStep( CurrentF_Point, ChordFB_Dir,
ChordFB_Length, NewSafety);
G4bool Intersects_FB = stepLength <= ChordFB_Length;
stepLength = min(stepLength, ChordFB_Length);
if( Intersects_FB ) {
// There is an intersection of FB with a volume boundary
// H <- First Intersection of Chord FB
//
G4ThreeVector PointH= CurrentF_Point + stepLength * ChordFB_Dir;
// H is our new Candidate for the intersection point.
// It replaces "E" and we will repeat the test to see if
// it is a good enough approximate point for us.
// Note that F must be in volume volA (the same as A)
// (otherwise AF would meet a volume boundary!)
// A <- F
// E <- H
CurrentA_PointVelocity= ApproxIntersecPointV;
CurrentE_Point= PointH;
}else{ // (not Intersects_FB)
//
// There is NO intersection of FB with a volume boundary
// This means that somehow a volume intersected the original
// chord but misses the chord (or series of chords)
// we have used.
//
there_is_no_intersection= true;
//
// the value of IntersectPointVelocity returned is not valid
} // Endif (Intersects_FB)
} // Endif (Intersects_AF)
// Ensure that the new endpoints are not further apart in space than on the curve
// due to different errors in the integration
G4double linDistSq, curveDist;
linDistSq= ( CurrentB_PointVelocity.Position()
- CurrentA_PointVelocity.Position() ).mag2();
curveDist= CurrentB_PointVelocity.CurveS() -
CurrentA_PointVelocity.CurveS();
if( curveDist*(curveDist+2*perMillion ) < linDistSq ){
// Re-integrate to obtain a new B
G4FieldTrack newEndpoint= CurrentA_PointVelocity;
GetChordFinder()->GetIntegrationDriver()
->AccurateAdvance(newEndpoint, curveDist, GetEpsilonStep() );
CurrentB_PointVelocity= newEndpoint;
G4cerr << "G4PropagatorInField::LocateIntersectionPoint: "
<< " Warning: Integration inaccuracy requires an adjustment in the step's endpoint "
<< " Two mid-points are further apart than their curve length difference"
<< endl
<< " Dist = " << sqrt(linDistSq)
<< " curve length = " << curveDist
<< endl;
}
if( curveDist < 0.0 ) {
G4Exception("G4PropagatorInField::LocateIntersectionPoint : the final curve point is not further along than the original.");
}
} // EndIf ( E is close enough to the curve, ie point F. )
// tests ChordAF_Vector.mag() <= maximum_lateral_displacement
#ifdef G4VERBOSE
if( Verbose() > 1 )
// printStatus( CurveStartPointVelocity, CurveEndPointVelocity,
printStatus( CurrentA_PointVelocity, CurrentB_PointVelocity,
-1.0, NewSafety, substep_no, 0); // startVolume);
#endif
substep_no++;
} while ( ( ! found_approximate_intersection ) &&
( ! there_is_no_intersection ) ); // UNTIL found or failed
return !there_is_no_intersection ; // Success or failure
}
void G4PropagatorInField::printStatus(
const G4FieldTrack& StartFT,
const G4FieldTrack& CurrentFT,
G4double requestStep,
G4double safety,
G4int Step,
G4VPhysicalVolume* startVolume)
// G4VPhysicalVolume* endVolume)
{
const G4int verboseLevel=1;
const G4ThreeVector StartPosition= StartFT.GetPosition();
const G4ThreeVector StartUnitVelocity= StartFT.GetMomentumDir();
const G4ThreeVector CurrentPosition= CurrentFT.GetPosition();
const G4ThreeVector CurrentUnitVelocity= CurrentFT.GetMomentumDir();
G4double step_len= CurrentFT.GetCurveLength()
- StartFT.GetCurveLength();
if( (Step == 0) && (verboseLevel <= 3) )
{
G4cout.precision(3);
// G4cout.setf(ios_base::fixed,ios_base::floatfield);
G4cout << setw( 6) << " "
<< setw( 25) << " Current Position and Direction" << " "
<< endl;
G4cout << setw( 5) << "Step#" << " "
<< setw( 9) << "X(mm)" << " "
<< setw( 9) << "Y(mm)" << " "
<< setw( 9) << "Z(mm)" << " "
<< setw( 7) << " N_x " << " "
<< setw( 7) << " N_y " << " "
<< setw( 7) << " N_z " << " "
// << setw( 9) << "KinE(MeV)" << " "
// << setw( 9) << "dE(MeV)" << " "
<< setw( 9) << "StepLen" << " "
<< setw( 9) << "PhsStep" << " "
<< setw(12) << "StartSafety" << " "
<< setw(18) << "NextVolume" << " "
<< endl;
}
//
if( verboseLevel > 3 )
{
// G4cout << "Current Position is " << CurrentPosition << endl
// << " and UnitVelocity is " << CurrentUnitVelocity << endl;
G4cout << "Step taken was " << step_len
<< " out of PhysicalStep= " << requestStep << endl;
G4cout << "Final safety is: " << safety << endl;
G4cout << "Chord length = " << (CurrentPosition-StartPosition).mag() << endl;
G4cout << endl;
}
else // if( verboseLevel > 0 )
{
G4cout.precision(3);
G4cout << setw( 5) << Step << " "
<< setw( 9) << CurrentPosition.x() << " "
<< setw( 9) << CurrentPosition.y() << " "
<< setw( 9) << CurrentPosition.z() << " "
<< setw( 7) << CurrentUnitVelocity.x() << " "
<< setw( 7) << CurrentUnitVelocity.y() << " "
<< setw( 7) << CurrentUnitVelocity.z() << " "
// << setw( 9) << KineticEnergy << " "
// << setw( 9) << EnergyDifference << " "
<< setw( 9) << step_len << " "
<< setw( 9) << requestStep << " "
<< setw(12) << safety << " ";
if( startVolume != 0) {
G4cout << setw(12) << startVolume->GetName() << " ";
} else {
G4cout << setw(12) << "OutOfWorld" << " ";
}
#if 0
if( CurrentVolume != 0)
{
G4cout << setw(12) << CurrentVolume()->GetName() << " ";
}
else
{
G4cout << setw(12) << "OutOfWorld or Unknown" << " ";
}
#endif
G4cout << endl;
}
}
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4ReplicaNavigation.cc,v 2.1 1998/07/12 02:58:28 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4ReplicaNavigation.cc,v 1.1 1999/01/07 16:08:49 gunter Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
//
// class G4REplicaNavigation Implementation
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4TouchableHistory.cc,v 2.1 1998/11/02 12:12:18 japost Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4TouchableHistory.cc,v 1.1 1999/01/07 16:08:49 gunter Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
//
// class G4TouchableHistory Implementation
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4TransportationManager.cc,v 2.0 1998/07/02 17:06:47 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4TransportationManager.cc,v 1.2 1999/07/02 15:47:28 gunter Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
//
// G4TransportationManager
@@ -19,6 +19,12 @@
#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;
G4TransportationManager G4TransportationManager::fTransportationManager;
G4TransportationManager::G4TransportationManager()
@@ -5,13 +5,12 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4VoxelNavigation.cc,v 2.6 1998/11/02 12:12:19 japost Exp $
// GEANT4 tag $Name: geant4-00 $
// $Id: G4VoxelNavigation.cc,v 1.3 1999/02/17 17:29:24 japost Exp $
// GEANT4 tag $Name: geant4-00-01 $
//
//
// class G4VoxelNavigation Implementation
//
// $ Id: $
//
// Modified by:
// J. Apostolakis, 29 Apr 98 Fixed error in LocateNextVoxel that