Import Geant4 10.6.0 source tree

This commit is contained in:
Gabriele Cosmo
2019-12-06 15:12:28 +01:00
parent b2a62ae692
commit 5baee230e9
2997 changed files with 141580 additions and 98673 deletions
@@ -23,6 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// class G4AuxiliaryNavServices implementation
//
// --------------------------------------------------------------------
@@ -37,13 +38,16 @@
void G4AuxiliaryNavServices::ReportTolerances()
{
G4int oldPrec= G4cout.precision(16);
G4int oldPrec = G4cout.precision(16);
G4cout << " Cartesian Tolerance (kCarTolerance): " << G4GeometryTolerance::GetInstance()->GetSurfaceTolerance()
G4cout << " Cartesian Tolerance (kCarTolerance): "
<< G4GeometryTolerance::GetInstance()->GetSurfaceTolerance()
<< " (global) " << G4endl;
G4cout << " Radial Tolerance (kRadTolerance): " << G4GeometryTolerance::GetInstance()->GetRadialTolerance()
G4cout << " Radial Tolerance (kRadTolerance): "
<< G4GeometryTolerance::GetInstance()->GetRadialTolerance()
<< " (global) " << G4endl;
G4cout << " Angular Tolerance (kAngTolerance): " << G4GeometryTolerance::GetInstance()->GetAngularTolerance()
G4cout << " Angular Tolerance (kAngTolerance): "
<< G4GeometryTolerance::GetInstance()->GetAngularTolerance()
<< " (global) " << G4endl;
G4cout.precision(oldPrec);
}
@@ -23,59 +23,37 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// Class G4BrentLocator implementation
// class G4BrentLocator implementation
//
// 27.10.08 - Tatiana Nikitina.
// 04.10.11 - John Apostolakis, revised convergence to use Surface Normal
// ---------------------------------------------------------------------------
#include "G4BrentLocator.hh"
#include "G4ios.hh"
#include <iomanip>
#include "G4BrentLocator.hh"
#include "G4ios.hh"
G4BrentLocator::G4BrentLocator(G4Navigator *theNavigator)
: G4VIntersectionLocator(theNavigator)
: G4VIntersectionLocator(theNavigator)
{
// In case of too slow progress in finding Intersection Point
// intermediates Points on the Track must be stored.
// Initialise the array of Pointers [max_depth+1] to do this
G4ThreeVector zeroV(0.0,0.0,0.0);
for (G4int idepth=0; idepth<max_depth+1; idepth++ )
for (auto idepth=0; idepth<max_depth+1; ++idepth )
{
ptrInterMedFT[ idepth ] = new G4FieldTrack( zeroV, zeroV, 0., 0., 0., 0.);
}
// Counters for Locator
// Counter for Maximum Number Of Trial before Intersection Found
//
maxNumberOfStepsForIntersection=0;
// Counter for Number Of Calls to ReIntegrationEndPoint Method
//
maxNumberOfCallsToReIntegration=0;
maxNumberOfCallsToReIntegration_depth=0;
}
G4BrentLocator::~G4BrentLocator()
{
for ( G4int idepth=0; idepth<max_depth+1; idepth++)
for ( auto idepth=0; idepth<max_depth+1; ++idepth )
{
delete ptrInterMedFT[idepth];
}
#ifdef G4DEBUG_FIELD
if(fVerboseLevel>0)
{
G4cout << "G4BrentLocator::Location with Max Number of Steps="
<< maxNumberOfStepsForIntersection<<G4endl;
G4cout << "G4BrentLocator::ReIntegrateEndPoint was called "
<< maxNumberOfCallsToReIntegration
<< " times and for depth algorithm "
<< maxNumberOfCallsToReIntegration_depth << " times." << G4endl;
}
#endif
}
// --------------------------------------------------------------------------
@@ -169,9 +147,9 @@ G4bool G4BrentLocator::EstimateIntersectionPoint(
// until 'max_depth'.
//--------------------------------------------------------------------------
const G4int param_substeps=50; // Test value for the maximum number
// of substeps
const G4double fraction_done=0.3;
const G4int param_substeps = 50; // Test value for the maximum number
// of substeps
const G4double fraction_done = 0.3;
G4bool Second_half = false; // First half or second half of divided step
@@ -183,11 +161,11 @@ G4bool G4BrentLocator::EstimateIntersectionPoint(
// and it becomes false only if we are in the first-half of level
// depthness or if we are in the first section
G4int depth=0; // Depth counts how many subdivisions of initial step made
G4int depth = 0; // Depth counts how many subdivisions of initial step made
#ifdef G4DEBUG_FIELD
const G4double tolerance= 1.0e-8;
G4ThreeVector StartPosition= CurveStartPointVelocity.GetPosition();
const G4double tolerance = 1.0e-8;
G4ThreeVector StartPosition = CurveStartPointVelocity.GetPosition();
if( (TrialPoint - StartPosition).mag() < tolerance * CLHEP::mm )
{
G4Exception("G4BrentLocator::EstimateIntersectionPoint()",
@@ -201,16 +179,16 @@ G4bool G4BrentLocator::EstimateIntersectionPoint(
// Important is 'ptrInterMedFT[0]', it saves the 'EndCurvePoint'
//
*ptrInterMedFT[0] = CurveEndPointVelocity;
for (G4int idepth=1; idepth<max_depth+1; idepth++ )
for (auto idepth=1; idepth<max_depth+1; ++idepth )
{
*ptrInterMedFT[idepth]=CurveStartPointVelocity;
*ptrInterMedFT[idepth] = CurveStartPointVelocity;
}
//Final_section boolean store
G4bool fin_section_depth[max_depth];
for (G4int idepth=0; idepth<max_depth; idepth++ )
for (auto idepth=0; idepth<max_depth; ++idepth )
{
fin_section_depth[idepth]=true;
fin_section_depth[idepth] = true;
}
// 'SubStartPoint' is needed to calculate the length of the divided step
@@ -251,14 +229,14 @@ G4bool G4BrentLocator::EstimateIntersectionPoint(
}
#endif
G4ThreeVector CurrentF_Point= ApproxIntersecPointV.GetPosition();
G4ThreeVector CurrentF_Point = ApproxIntersecPointV.GetPosition();
// First check whether EF is small - then F is a good approx. point
// Calculate the length and direction of the chord AF
//
G4ThreeVector ChordEF_Vector = CurrentF_Point - CurrentE_Point;
G4ThreeVector NewMomentumDir= ApproxIntersecPointV.GetMomentumDir();
G4double MomDir_dot_Norm= NewMomentumDir.dot( NormalAtEntry ) ;
G4ThreeVector NewMomentumDir = ApproxIntersecPointV.GetMomentumDir();
G4double MomDir_dot_Norm = NewMomentumDir.dot( NormalAtEntry ) ;
#ifdef G4DEBUG_FIELD
G4ThreeVector ChordAB = Point_B - Point_A;
@@ -397,7 +375,7 @@ G4bool G4BrentLocator::EstimateIntersectionPoint(
// A <- F
// E <- H
//
G4FieldTrack InterMed=ApproxIntersecPointV;
G4FieldTrack InterMed = ApproxIntersecPointV;
ApproxIntersecPointV = GetChordFinderFor()->ApproxCurvePointS(
CurrentA_PointVelocity,CurrentB_PointVelocity,
InterMed,CurrentE_Point,CurrentF_Point,PointH,
@@ -409,7 +387,7 @@ G4bool G4BrentLocator::EstimateIntersectionPoint(
//
G4bool validNormalLast;
NormalAtEntry = GetSurfaceNormal( PointH, validNormalLast );
validNormalAtE= validNormalLast;
validNormalAtE = validNormalLast;
}
else // not Intersects_FB
{
@@ -445,7 +423,7 @@ G4bool G4BrentLocator::EstimateIntersectionPoint(
}
else
{
if(depth==0)
if( depth==0 )
{
// We must restore the original endpoint
//
@@ -459,7 +437,7 @@ G4bool G4BrentLocator::EstimateIntersectionPoint(
GetEpsilonStepFor());
restoredFullEndpoint = true;
restartB++; // counter
++restartB; // counter
}
else
{
@@ -474,7 +452,7 @@ G4bool G4BrentLocator::EstimateIntersectionPoint(
CurrentE_Point,
GetEpsilonStepFor());
restoredFullEndpoint = true;
restartB++; // counter
++restartB; // counter
}
}
} // Endif (Intersects_FB)
@@ -563,7 +541,7 @@ G4bool G4BrentLocator::EstimateIntersectionPoint(
"GeomNav0003", FatalException, message);
}
if(restoredFullEndpoint)
if( restoredFullEndpoint )
{
fin_section_depth[depth] = restoredFullEndpoint;
restoredFullEndpoint = false;
@@ -593,8 +571,8 @@ G4bool G4BrentLocator::EstimateIntersectionPoint(
-1.0, NewSafety, substep_no);
}
#endif
substep_no++;
substep_no_p++;
++substep_no;
++substep_no_p;
} while ( ( ! found_approximate_intersection )
&& ( ! there_is_no_intersection )
@@ -616,10 +594,10 @@ G4bool G4BrentLocator::EstimateIntersectionPoint(
// then halve the step if so
//
if ( ( did_len < fraction_done*all_len )
&& (depth<max_depth) && (!sub_final_section) )
&& (depth < max_depth) && (!sub_final_section) )
{
Second_half=false;
depth++;
++depth;
G4double Sub_len = (all_len-did_len)/(2.);
G4FieldTrack start = CurrentA_PointVelocity;
@@ -647,13 +625,13 @@ G4bool G4BrentLocator::EstimateIntersectionPoint(
{
last_AF_intersection = Intersects_AB;
CurrentE_Point = PointGe;
fin_section_depth[depth]=true;
fin_section_depth[depth] = true;
// Need to recalculate the Exit Normal at the new PointG
//
G4bool validNormalAB;
NormalAtEntry = GetSurfaceNormal( PointGe, validNormalAB );
validNormalAtE= validNormalAB;
validNormalAtE = validNormalAB;
}
else
{
@@ -688,14 +666,14 @@ G4bool G4BrentLocator::EstimateIntersectionPoint(
{
// Re-integrate to obtain a new B
//
G4FieldTrack newEndPointFT=
G4FieldTrack newEndPointFT =
ReEstimateEndpoint( CurrentA_PointVelocity,
CurrentB_PointVelocity,
linDistSq, // to avoid recalculation
curveDist );
G4FieldTrack oldPointVelB = CurrentB_PointVelocity;
CurrentB_PointVelocity = newEndPointFT;
if (depth==1)
if ( depth==1 )
{
recalculatedEndPoint = true;
IntersectedOrRecalculatedFT = newEndPointFT;
+31 -37
View File
@@ -23,18 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4DrawVoxels
//
// Implementation
// class G4DrawVoxels implementation
//
// Define G4DrawVoxelsDebug for debugging information on G4cout
//
// History:
// 03/08/1999 The G4VisAttributes have been made member data for
// lifetime reasons / visualisation L.G
// 29/07/1999 first comitted version L.G.
// --------------------------------------------------------------------
@@ -72,17 +64,17 @@ void G4DrawVoxels::SetVoxelsVisAttributes(G4VisAttributes& VA_voxelX,
G4VisAttributes& VA_voxelY,
G4VisAttributes& VA_voxelZ)
{
fVoxelsVisAttributes[0]=VA_voxelX;
fVoxelsVisAttributes[1]=VA_voxelY;
fVoxelsVisAttributes[2]=VA_voxelZ;
fVoxelsVisAttributes[0] = VA_voxelX;
fVoxelsVisAttributes[1] = VA_voxelY;
fVoxelsVisAttributes[2] = VA_voxelZ;
}
void G4DrawVoxels::SetBoundingBoxVisAttributes(G4VisAttributes& VA_boundingbox)
{
fBoundingBoxVisAttributes=VA_boundingbox;
fBoundingBoxVisAttributes = VA_boundingbox;
}
// ***************************************************************
// --------------------------------------------------------------------
void
G4DrawVoxels::ComputeVoxelPolyhedra(const G4LogicalVolume* lv,
@@ -92,10 +84,10 @@ G4DrawVoxels::ComputeVoxelPolyhedra(const G4LogicalVolume* lv,
{
// Let's draw the selected voxelisation now !
G4VSolid* solid=lv->GetSolid();
G4VSolid* solid = lv->GetSolid();
G4double dx=kInfinity,dy=kInfinity,dz=kInfinity;
G4double xmax=0,xmin=0,ymax=0,ymin=0,zmax=0,zmin=0;
G4double dx=kInfinity, dy=kInfinity, dz=kInfinity;
G4double xmax=0, xmin=0, ymax=0, ymin=0, zmax=0, zmin=0;
if (lv->GetNoDaughters()<=0)
{
@@ -109,9 +101,9 @@ G4DrawVoxels::ComputeVoxelPolyhedra(const G4LogicalVolume* lv,
solid->CalculateExtent(kYAxis,limit,G4AffineTransform(),ymin,ymax);
// extents according to the axis of the local frame
solid->CalculateExtent(kZAxis,limit,G4AffineTransform(),zmin,zmax);
dx=xmax-xmin;
dy=ymax-ymin;
dz=zmax-zmin;
dx = xmax-xmin;
dy = ymax-ymin;
dz = zmax-zmin;
// Preparing the colored bounding polyhedronBox for the pVolume
//
@@ -125,7 +117,7 @@ G4DrawVoxels::ComputeVoxelPolyhedra(const G4LogicalVolume* lv,
G4Translate3D(t_centerofBoundingBox)));
G4ThreeVector t_FirstCenterofVoxelPlane;
const G4VisAttributes* voxelsVisAttributes=0;
const G4VisAttributes* voxelsVisAttributes = nullptr;
G4ThreeVector unit_translation_vector;
G4ThreeVector current_translation_vector;
@@ -160,44 +152,46 @@ G4DrawVoxels::ComputeVoxelPolyhedra(const G4LogicalVolume* lv,
G4PolyhedronBox voxel_plane(dx*0.5,dy*0.5,dz*0.5);
voxel_plane.SetVisAttributes(voxelsVisAttributes);
G4SmartVoxelProxy* slice=header->GetSlice(0);
G4int slice_no=0,no_slices=header->GetNoSlices();
G4double beginning=header->GetMinExtent(),
step=(header->GetMaxExtent()-beginning)/no_slices;
G4SmartVoxelProxy* slice = header->GetSlice(0);
G4int slice_no = 0, no_slices = header->GetNoSlices();
G4double beginning = header->GetMinExtent(),
step = (header->GetMaxExtent()-beginning)/no_slices;
while (slice_no<no_slices)
{
if (slice->IsHeader())
{
G4VoxelLimits newlimit(limit);
newlimit.AddLimit(header->GetAxis(),beginning+step*slice_no,
beginning+step*(slice->GetHeader()->GetMaxEquivalentSliceNo()+1));
ComputeVoxelPolyhedra(lv,slice->GetHeader(),newlimit,ppl);
newlimit.AddLimit(header->GetAxis(), beginning+step*slice_no,
beginning+step*(slice->GetHeader()->GetMaxEquivalentSliceNo()+1));
ComputeVoxelPolyhedra(lv,slice->GetHeader(), newlimit, ppl);
}
current_translation_vector=unit_translation_vector;
current_translation_vector*=step*slice_no;
current_translation_vector = unit_translation_vector;
current_translation_vector *= step*slice_no;
ppl->push_back(G4PlacedPolyhedron(voxel_plane,
G4Translate3D(current_translation_vector
+t_FirstCenterofVoxelPlane)));
slice_no=(slice->IsHeader()
+ t_FirstCenterofVoxelPlane)));
slice_no = (slice->IsHeader()
? slice->GetHeader()->GetMaxEquivalentSliceNo()+1
: slice->GetNode()->GetMaxEquivalentSliceNo()+1);
if (slice_no<no_slices) { slice=header->GetSlice(slice_no); }
}
}
// ########################################################################
// --------------------------------------------------------------------
G4PlacedPolyhedronList*
G4DrawVoxels::CreatePlacedPolyhedra(const G4LogicalVolume* lv) const
{
G4PlacedPolyhedronList* pplist=new G4PlacedPolyhedronList;
G4PlacedPolyhedronList* pplist = new G4PlacedPolyhedronList;
G4VoxelLimits limits; // Working object for recursive call.
ComputeVoxelPolyhedra(lv,lv->GetVoxelHeader(),limits,pplist);
return pplist; //it s up to the calling program to destroy it then!
}
// --------------------------------------------------------------------
void G4DrawVoxels::DrawVoxels(const G4LogicalVolume* lv) const
{
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
@@ -219,12 +213,12 @@ void G4DrawVoxels::DrawVoxels(const G4LogicalVolume* lv) const
G4Transform3D transf3D(globTransform.NetRotation(),
globTransform.NetTranslation());
G4PlacedPolyhedronList* pplist=CreatePlacedPolyhedra(lv);
if(pVVisManager)
G4PlacedPolyhedronList* pplist = CreatePlacedPolyhedra(lv);
if(pVVisManager != nullptr)
{
// Drawing the bounding and voxel polyhedra for the pVolume
//
for (size_t i=0;i<pplist->size();i++)
for (size_t i=0; i<pplist->size(); ++i)
{
pVVisManager->Draw((*pplist)[i].GetPolyhedron(),
(*pplist)[i].GetTransform()*transf3D);
@@ -23,11 +23,9 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// class G4ErrorPropagationNavigator implementation
//
//
//
// --------------------------------------------------------------------
// GEANT 4 class implementation file
// Author: Pedro Arce, CIEMAT
// --------------------------------------------------------------------
#include "G4ErrorPropagationNavigator.hh"
@@ -62,24 +60,24 @@ ComputeStep ( const G4ThreeVector &pGlobalPoint,
const G4double pCurrentProposedStepLength,
G4double &pNewSafety )
{
G4double safetyGeom= DBL_MAX;
G4double safetyGeom = DBL_MAX;
G4double Step = G4Navigator::ComputeStep(pGlobalPoint, pDirection,
pCurrentProposedStepLength,
safetyGeom);
G4ErrorPropagatorData * g4edata
G4ErrorPropagatorData* g4edata
= G4ErrorPropagatorData::GetErrorPropagatorData();
if (g4edata !=0)
if ( g4edata != nullptr )
{
const G4ErrorTarget* target = g4edata->GetTarget();
if( target != 0 )
if( target != nullptr )
{
G4double StepPlane= target->GetDistanceFromPoint(pGlobalPoint,pDirection);
G4double StepPlane=target->GetDistanceFromPoint(pGlobalPoint,pDirection);
if( StepPlane < 0. ) // Negative means target is crossed, will not be found
{
if( StepPlane < 0. ) // Negative means target is crossed,
{ // will not be found
StepPlane = DBL_MAX;
}
#ifdef G4VERBOSE
@@ -92,7 +90,7 @@ ComputeStep ( const G4ThreeVector &pGlobalPoint,
}
#endif
if(StepPlane<Step)
if( StepPlane < Step )
{
#ifdef G4VERBOSE
if( G4ErrorPropagatorData::verbose() >= 2 )
@@ -112,8 +110,10 @@ ComputeStep ( const G4ThreeVector &pGlobalPoint,
}
}
G4double safetyTarget = TargetSafetyFromPoint(pGlobalPoint);
// Avoid call to G4Navigator::ComputeSafety - which could have side effects
pNewSafety= std::min(safetyGeom, safetyTarget);
// Avoid call to G4Navigator::ComputeSafety - which could have side effects
//
pNewSafety = std::min(safetyGeom, safetyTarget);
#ifdef G4VERBOSE
if( G4ErrorPropagatorData::verbose() >= 3 )
@@ -130,17 +130,17 @@ ComputeStep ( const G4ThreeVector &pGlobalPoint,
//-------------------------------------------------------------------
G4double G4ErrorPropagationNavigator::
TargetSafetyFromPoint( const G4ThreeVector &pGlobalpoint )
TargetSafetyFromPoint( const G4ThreeVector& pGlobalpoint )
{
G4double safety= DBL_MAX;
G4double safety = DBL_MAX;
G4ErrorPropagatorData *g4edata
G4ErrorPropagatorData* g4edata
= G4ErrorPropagatorData::GetErrorPropagatorData();
if (g4edata !=0)
if ( g4edata != nullptr )
{
const G4ErrorTarget* target = g4edata->GetTarget();
if( target != 0 )
if( target != nullptr )
{
safety = target->GetDistanceFromPoint(pGlobalpoint);
}
@@ -166,30 +166,30 @@ ComputeSafety( const G4ThreeVector &pGlobalPoint,
//-------------------------------------------------------------------
G4ThreeVector G4ErrorPropagationNavigator::
GetGlobalExitNormal(const G4ThreeVector& point, G4bool* valid)
GetGlobalExitNormal( const G4ThreeVector& point, G4bool* valid )
{
G4ErrorPropagatorData *g4edata
G4ErrorPropagatorData* g4edata
= G4ErrorPropagatorData::GetErrorPropagatorData();
const G4ErrorTarget* target = 0;
const G4ErrorTarget* target = nullptr;
G4ThreeVector normal(0.0, 0.0, 0.0);
G4double distance= 0;
// Determine which 'geometry' limited the step
if (g4edata)
if ( g4edata != nullptr )
{
target = g4edata->GetTarget();
if(target)
if( target != nullptr )
{
distance = target->GetDistanceFromPoint(point);
}
}
if( distance > kCarTolerance // Not reached the target.
|| (!target) )
// If a target does not exist, this seems the best we can do
if( distance > kCarTolerance || (target == nullptr) )
// Not reached the target or if a target does not exist,
// this seems the best we can do
{
normal= G4Navigator::GetGlobalExitNormal(point, valid);
normal = G4Navigator::GetGlobalExitNormal(point, valid);
}
else
{
@@ -197,11 +197,11 @@ GetGlobalExitNormal(const G4ThreeVector& point, G4bool* valid)
{
case G4ErrorTarget_GeomVolume:
// The volume is in the 'real' mass geometry
normal= G4Navigator::GetGlobalExitNormal(point, valid);
normal = G4Navigator::GetGlobalExitNormal(point, valid);
break;
case G4ErrorTarget_TrkL:
normal= G4ThreeVector( 0.0, 0.0, 0.0);
*valid= false;
normal = G4ThreeVector( 0.0, 0.0, 0.0);
*valid = false;
G4Exception("G4ErrorPropagationNavigator::GetGlobalExitNormal",
"Geometry1003",
JustWarning, "Unexpected value of Target type");
@@ -210,17 +210,16 @@ GetGlobalExitNormal(const G4ThreeVector& point, G4bool* valid)
case G4ErrorTarget_CylindricalSurface:
const G4ErrorSurfaceTarget* surfaceTarget=
static_cast<const G4ErrorSurfaceTarget*>(target);
normal= surfaceTarget->GetTangentPlane(point).normal().unit();
*valid= true;
normal = surfaceTarget->GetTangentPlane(point).normal().unit();
*valid = true;
break;
// default:
// normal= G4ThreeVector( 0.0, 0.0, 0.0);
// *valid= false;
// normal= G4ThreeVector( 0.0, 0.0, 0.0 );
// *valid = false;
// G4Exception("G4ErrorPropagationNavigator::GetGlobalExitNormal",
// "Geometry:003",
// FatalException, "Impossible value of Target type");
// exit(1);
// break;
}
}
@@ -23,12 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// --------------------------------------------------------------------
// GEANT 4 class source file
//
// G4GeomTestVolume
// class G4GeomTestVolume implementation
//
// Author: G.Cosmo, CERN
// --------------------------------------------------------------------
@@ -36,7 +31,6 @@
#include <set>
#include "G4GeomTestVolume.hh"
#include "G4PhysicalConstants.hh"
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
@@ -50,7 +44,7 @@ G4GeomTestVolume::G4GeomTestVolume( G4VPhysicalVolume *theTarget,
G4int numberOfPoints,
G4bool theVerbosity )
: target(theTarget), tolerance(theTolerance),
resolution(numberOfPoints), maxErr(1), verbosity(theVerbosity)
resolution(numberOfPoints), verbosity(theVerbosity)
{;}
//
@@ -151,8 +145,7 @@ void G4GeomTestVolume::TestRecursiveOverlap( G4int slevel, G4int depth )
const G4LogicalVolume *logical = target->GetLogicalVolume();
G4int nDaughter = logical->GetNoDaughters();
G4int iDaughter;
for( iDaughter=0; iDaughter<nDaughter; ++iDaughter )
for( auto iDaughter=0; iDaughter<nDaughter; ++iDaughter )
{
G4VPhysicalVolume *daughter = logical->GetDaughter(iDaughter);
@@ -23,15 +23,9 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// class G4GeometryMessenger implementation
//
//
// --------------------------------------------------------------------
// GEANT 4 class source file
//
// G4GeometryMessenger
//
// Author: G.Cosmo, CERN.
//
// Author: G.Cosmo, CERN
// --------------------------------------------------------------------
#include <iomanip>
@@ -56,7 +50,7 @@
// Constructor
//
G4GeometryMessenger::G4GeometryMessenger(G4TransportationManager* tman)
: tol(0.0), recLevel(0), recDepth(-1), tmanager(tman), tvolume(0)
: tmanager(tman)
{
geodir = new G4UIdirectory( "/geometry/" );
geodir->SetGuidance( "Geometry control commands." );
@@ -193,7 +187,7 @@ G4GeometryMessenger::Init()
{
// Create checker...
//
if (!tvolume)
if (tvolume == nullptr)
{
// Get the world volume
//
@@ -221,6 +215,9 @@ G4GeometryMessenger::SetNewValue( G4UIcommand* command, G4String newValues )
else if (command == chkCmd) {
SetCheckMode( newValues );
}
else if (command == pchkCmd) {
SetPushFlag( newValues );
}
else if (command == tolCmd) {
Init();
tol = tolCmd->GetNewDoubleValue( newValues )
@@ -257,10 +254,11 @@ G4GeometryMessenger::SetNewValue( G4UIcommand* command, G4String newValues )
// GetCurrentValue
//
G4String
G4GeometryMessenger::GetCurrentValue(G4UIcommand* command )
G4GeometryMessenger::GetCurrentValue( G4UIcommand* command )
{
G4String cv = "";
if (command == tolCmd) {
if (command == tolCmd)
{
cv = tolCmd->ConvertToString( tol, "mm" );
}
return cv;
@@ -275,7 +273,8 @@ G4GeometryMessenger::CheckGeometry()
// Verify that the geometry is closed
//
G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
if (!geomManager->IsGeometryClosed()) {
if (!geomManager->IsGeometryClosed())
{
geomManager->OpenGeometry();
geomManager->CloseGeometry(true);
}
@@ -23,11 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// class G4GlobalMagFieldMessenger
//
// Implementation
//
// Implementation of the G4GlobalMagFieldMessenger class
//
// Author: Ivana Hrivnacova, 28/08/2013 (ivana@ipno.in2p3.fr)
@@ -46,12 +43,7 @@
//______________________________________________________________________________
G4GlobalMagFieldMessenger::G4GlobalMagFieldMessenger(const G4ThreeVector& value)
: G4UImessenger(),
fMagField(0),
fVerboseLevel(0),
fDirectory(0),
fSetValueCmd(0),
fSetVerboseCmd(0)
: G4UImessenger()
{
fDirectory = new G4UIdirectory("/globalField/");
fDirectory->SetGuidance("Global uniform magnetic field UI commands");
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// Class G4MultiLevelLocator implementation
//
// 27.10.08 - Tatiana Nikitina.
@@ -35,20 +34,15 @@
#include "G4ios.hh"
#include "G4MultiLevelLocator.hh"
G4MultiLevelLocator::G4MultiLevelLocator(G4Navigator *theNavigator)
: G4VIntersectionLocator(theNavigator),
fMaxSteps(10000), // Very loose - allows many steps (looping will be rare)
fWarnSteps(1000), //
fNumCalls(0),
fNumAdvanceFull(0.), fNumAdvanceGood(0), fNumAdvanceTrials(0)
: G4VIntersectionLocator(theNavigator)
{
// In case of too slow progress in finding Intersection Point
// intermediates Points on the Track must be stored.
// Initialise the array of Pointers [max_depth+1] to do this
G4ThreeVector zeroV(0.0,0.0,0.0);
for (G4int idepth=0; idepth<max_depth+1; idepth++ )
for ( auto idepth=0; idepth<max_depth+1; ++idepth )
{
ptrInterMedFT[ idepth ] = new G4FieldTrack( zeroV, zeroV, 0., 0., 0., 0.);
}
@@ -63,7 +57,7 @@ G4MultiLevelLocator::G4MultiLevelLocator(G4Navigator *theNavigator)
G4MultiLevelLocator::~G4MultiLevelLocator()
{
for ( G4int idepth=0; idepth<max_depth+1; idepth++)
for ( auto idepth=0; idepth<max_depth+1; ++idepth )
{
delete ptrInterMedFT[idepth];
}
@@ -137,17 +131,17 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
G4ThreeVector NormalAtEntry;
G4FieldTrack ApproxIntersecPointV(CurveEndPointVelocity); // FT-Def-Construct
// G4bool validApproxIntPV= false; // Is it current: valid and up-to-date?
G4bool validIntersectP= true; // Is it current ?
G4double NewSafety = 0.0;
G4bool last_AF_intersection = false;
auto integrDriver = GetChordFinderFor()->GetIntegrationDriver();
G4bool driverReIntegrates = integrDriver->DoesReIntegrate();
// G4bool final_section= true; // Shows whether current section is last
// (i.e. B=full end)
G4bool first_section = true;
recalculatedEndPoint = false;
G4bool restoredFullEndpoint = false;
unsigned int substep_no = 0;
@@ -166,9 +160,9 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
// until 'max_depth'.
//--------------------------------------------------------------------------
const G4int param_substeps=5; // Test value for the maximum number
// of substeps
const G4double fraction_done=0.3;
const G4int param_substeps = 5; // Test value for the maximum number
// of substeps
const G4double fraction_done = 0.3;
G4bool Second_half = false; // First half or second half of divided step
@@ -178,17 +172,17 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
// and it becomes false only if we are in the first-half of level
// depthness or if we are in the first section
unsigned int depth=0; // Depth counts subdivisions of initial step made
fNumCalls++;
unsigned int depth = 0; // Depth counts subdivisions of initial step made
++fNumCalls;
#ifdef G4DEBUG_FIELD
unsigned int trigger_substepno_print=0;
unsigned int trigger_substepno_print = 0;
const G4double tolerance = 1.0e-8 * CLHEP::mm;
unsigned int biggest_depth= 0;
unsigned int biggest_depth = 0;
#if (G4DEBUG_FIELD>1)
G4ThreeVector StartPosition= CurveStartPointVelocity.GetPosition();
if( (TrialPoint - StartPosition).mag2() < tolerance*tolerance)
G4ThreeVector StartPosition = CurveStartPointVelocity.GetPosition();
if( (TrialPoint - StartPosition).mag2() < sqr(tolerance))
{
ReportImmediateHit( MethodName, StartPosition, TrialPoint,
tolerance, fNumCalls);
@@ -203,17 +197,17 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
// Important is 'ptrInterMedFT[0]', it saves the 'EndCurvePoint'
//
*ptrInterMedFT[0] = CurveEndPointVelocity;
for (G4int idepth=1; idepth<max_depth+1; idepth++ )
for ( auto idepth=1; idepth<max_depth+1; ++idepth )
{
*ptrInterMedFT[idepth]=CurveStartPointVelocity;
*ptrInterMedFT[idepth] = CurveStartPointVelocity;
}
// Final_section boolean store
//
G4bool fin_section_depth[max_depth];
for (G4int idepth=0; idepth<max_depth; idepth++ )
for ( auto idepth=0; idepth<max_depth; ++idepth )
{
fin_section_depth[idepth]=true;
fin_section_depth[idepth] = true;
}
// 'SubStartPoint' is needed to calculate the length of the divided step
//
@@ -241,8 +235,6 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
GetEpsilonStepFor());
// The above method is the key & most intuitive part ...
// validApproxIntPV = true;
#ifdef G4DEBUG_FIELD
if( ApproxIntersecPointV.GetCurveLength() >
CurrentB_PointVelocity.GetCurveLength() * (1.0 + tolerance) )
@@ -259,8 +251,8 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
//
G4ThreeVector ChordEF_Vector = CurrentF_Point - CurrentE_Point;
G4ThreeVector NewMomentumDir= ApproxIntersecPointV.GetMomentumDir();
G4double MomDir_dot_Norm= NewMomentumDir.dot( NormalAtEntry ) ;
G4ThreeVector NewMomentumDir = ApproxIntersecPointV.GetMomentumDir();
G4double MomDir_dot_Norm = NewMomentumDir.dot( NormalAtEntry );
#ifdef G4DEBUG_FIELD
if( fVerboseLevel > 3 )
@@ -341,8 +333,7 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
CurrentB_PointVelocity = ApproxIntersecPointV;
CurrentE_Point = PointG;
validIntersectP= true; // 'E' has been updated.
// validApproxIntPV= false; // 'F' is no longer valid, as B changed
validIntersectP = true; // 'E' has been updated.
G4bool validNormalLast;
NormalAtEntry = GetSurfaceNormal( PointG, validNormalLast );
@@ -351,7 +342,7 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
// By moving point B, must take care if current
// AF has no intersection to try current FB!!
//
fin_section_depth[depth]=false;
fin_section_depth[depth] = false;
#ifdef G4VERBOSE
if( fVerboseLevel > 3 )
@@ -400,7 +391,6 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
CurrentE_Point = PointH;
validIntersectP = true; // 'E' has been updated.
// validApproxIntPV = false; // 'F' is no longer valid, as A changed
G4bool validNormalH;
NormalAtEntry = GetSurfaceNormal( PointH, validNormalH );
@@ -408,7 +398,7 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
}
else // not Intersects_FB
{
if(fin_section_depth[depth])
if( fin_section_depth[depth] )
{
// If B is the original endpoint, this means that whatever
// volume(s) intersected the original chord, none touch the
@@ -442,43 +432,50 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
SubStart_PointVelocity = CurrentA_PointVelocity;
restoredFullEndpoint = true;
validIntersectP= false; // 'E' has NOT been updated.
// validApproxIntPV= false; // 'F' is no longer valid, A changed
validIntersectP = false; // 'E' has NOT been updated.
}
} // Endif (Intersects_FB)
} // Endif (Intersects_AF)
G4FieldTrack RevisedB_FT= CurrentB_PointVelocity;
G4int errorEndPt;
G4bool recalculatedB= CheckAndReEstimateEndpoint(CurrentA_PointVelocity,
CurrentB_PointVelocity,
RevisedB_FT,
errorEndPt );
if( recalculatedB )
G4int errorEndPt = 0; // Default: no error (if not calling CheckAnd...
G4bool recalculatedB= false;
if( driverReIntegrates )
{
CurrentB_PointVelocity= RevisedB_FT; // Use it !
// Do not invalidate intersection F -- it is still roughly OK.
//
// The best course would be to invalidate (reset validIntersectP)
// BUT if we invalidate it, we must re-estimate it somewhere!
// validApproxIntPV= false; // 'F' is no longer valid, as B changed
// validIntersectP= false; // 'E' has NOT been updated.
if ( (fin_section_depth[depth]) // real final section
&&( first_section || ((Second_half)&&(depth==0)) ) )
G4FieldTrack RevisedB_FT = CurrentB_PointVelocity;
recalculatedB= CheckAndReEstimateEndpoint(CurrentA_PointVelocity,
CurrentB_PointVelocity,
RevisedB_FT,
errorEndPt );
if( recalculatedB )
{
recalculatedEndPoint = true;
IntersectedOrRecalculatedFT = RevisedB_FT;
CurrentB_PointVelocity = RevisedB_FT; // Use it !
// Do not invalidate intersection F -- it is still roughly OK.
//
// The best course would be to invalidate (reset validIntersectP)
// BUT if we invalidate it, we must re-estimate it somewhere! E.g.
// validIntersectP = false; // 'E' has NOT been updated.
if ( (fin_section_depth[depth]) // real final section
&&( first_section || ((Second_half)&&(depth==0)) ) )
{
recalculatedEndPoint = true;
IntersectedOrRecalculatedFT = RevisedB_FT;
// So that we can return it, if it is the endpoint!
}
// else
// Move forward the other points
// - or better flag it, so that they are re-computed when next used
// [ Implementation: a counter for # of recomputations
// => avoids extra work]
}
// else
// Move forward the other points
// - or better flag it, so that they are re-computed when next used
// [ Implementation: a counter for # of recomputations
// => avoids extra work]
}
else
{
if( CurrentB_PointVelocity.GetCurveLength() < CurrentA_PointVelocity.GetCurveLength() )
errorEndPt = 2;
}
if( errorEndPt > 1 ) // errorEndPt = 1 is milder, just: len(B)=len(A)
{
std::ostringstream errmsg;
@@ -514,18 +511,18 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
if( substep_no == trigger_substepno_print )
{
printStatus( CurveStartPointVelocity, CurveEndPointVelocity,
-1.0, NewSafety, 0);
-1.0, NewSafety, 0 );
}
G4cout << " State of point A: ";
printStatus( CurrentA_PointVelocity, CurrentA_PointVelocity,
-1.0, NewSafety, substep_no-1);
-1.0, NewSafety, substep_no-1 );
G4cout << " State of point B: ";
printStatus( CurrentA_PointVelocity, CurrentB_PointVelocity,
-1.0, NewSafety, substep_no);
-1.0, NewSafety, substep_no );
}
#endif
substep_no++;
substep_no_p++;
++substep_no;
++substep_no_p;
} while ( ( ! found_approximate_intersection )
&& ( ! there_is_no_intersection )
@@ -539,7 +536,7 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
G4double all_len = std::abs( CurrentB_PointVelocity.GetCurveLength()
- SubStart_PointVelocity.GetCurveLength());
G4double distAB= -1;
G4double distAB = -1;
G4ThreeVector PointGe;
//
// Is progress is too slow, and is it possible to go deeper?
@@ -550,29 +547,27 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
{
#ifdef G4DEBUG_FIELD
static G4ThreadLocal unsigned int numSplits=0; // For debugging only
biggest_depth= std::max(depth, biggest_depth);
numSplits++;
biggest_depth = std::max(depth, biggest_depth);
++numSplits;
#endif
Second_half=false;
depth++;
Second_half = false;
++depth;
first_section = false;
G4double Sub_len = (all_len-did_len)/(2.);
G4FieldTrack midPoint = CurrentA_PointVelocity;
auto integrDriver
= GetChordFinderFor()->GetIntegrationDriver();
G4bool fullAdvance=
integrDriver->AccurateAdvance(midPoint, Sub_len, fiEpsilonStep);
fNumAdvanceTrials++;
if( fullAdvance ) { fNumAdvanceFull++; }
++fNumAdvanceTrials;
if( fullAdvance ) { ++fNumAdvanceFull; }
G4double lenAchieved=
midPoint.GetCurveLength()-CurrentA_PointVelocity.GetCurveLength();
const G4double adequateFraction = (1.0-CLHEP::perThousand);
G4bool goodAdvance = (lenAchieved >= adequateFraction * Sub_len);
if ( goodAdvance ) { fNumAdvanceGood++; }
if ( goodAdvance ) { ++fNumAdvanceGood; }
#ifdef G4DEBUG_FIELD
else // !goodAdvance
@@ -628,10 +623,9 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
{
last_AF_intersection = Intersects_AB;
CurrentE_Point = PointGe;
fin_section_depth[depth]=true;
fin_section_depth[depth] = true;
validIntersectP= true; // 'E' has been updated.
// validApproxIntPV= false; // 'F' is no longer valid, as E changed
validIntersectP = true; // 'E' has been updated.
G4bool validNormalAB;
NormalAtEntry = GetSurfaceNormal( PointGe, validNormalAB );
@@ -645,19 +639,18 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
Second_half = true;
validIntersectP= false; // No new 'E' chord intersection found
// validApproxIntPV= false; // So also 'F' is invalid
}
} // if did_len
unsigned int levelPops=0;
unsigned int levelPops = 0;
G4bool unfinished = Second_half;
while ( unfinished && (depth>0) ) // Loop checking, 07.10.2016, J. Apostolakis
while ( unfinished && (depth>0) ) // Loop checking, 07.10.2016, JA
{
// Second part of curve (InterMed[depth],Intermed[depth-1]))
// On the depth-1 level normally we are on the 'second_half'
levelPops++;
++levelPops;
// Find new trial intersection point needed at start of the loop
//
@@ -665,25 +658,35 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
CurrentA_PointVelocity = *ptrInterMedFT[depth];
CurrentB_PointVelocity = *ptrInterMedFT[depth-1];
// Ensure that the new endpoints are not further apart in space
// than on the curve due to different errors in the integration
//
G4FieldTrack RevisedEndPointFT= CurrentB_PointVelocity;
G4int errorEndPt;
G4bool recalculatedB=
CheckAndReEstimateEndpoint( CurrentA_PointVelocity,
CurrentB_PointVelocity,
RevisedEndPointFT,
errorEndPt );
if( recalculatedB )
{
CurrentB_PointVelocity= RevisedEndPointFT; // Use it !
G4int errorEndPt = 0; // Default: no error (if not calling CheckAnd...
if (depth==1)
G4bool recalculatedB= false;
if( driverReIntegrates )
{
// Ensure that the new endpoints are not further apart in space
// than on the curve due to different errors in the integration
//
G4FieldTrack RevisedEndPointFT = CurrentB_PointVelocity;
recalculatedB =
CheckAndReEstimateEndpoint( CurrentA_PointVelocity,
CurrentB_PointVelocity,
RevisedEndPointFT,
errorEndPt );
if( recalculatedB )
{
recalculatedEndPoint = true;
IntersectedOrRecalculatedFT = RevisedEndPointFT;
// So that we can return it, if it is the endpoint!
CurrentB_PointVelocity = RevisedEndPointFT; // Use it !
if ( depth == 1 )
{
recalculatedEndPoint = true;
IntersectedOrRecalculatedFT = RevisedEndPointFT;
// So that we can return it, if it is the endpoint!
}
}
else
{
if( CurrentB_PointVelocity.GetCurveLength() < CurrentA_PointVelocity.GetCurveLength() )
errorEndPt = 2;
}
}
if( errorEndPt > 1 ) // errorEndPt = 1 is milder, just: len(B)=len(A)
@@ -710,8 +713,7 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
last_AF_intersection = Intersects_AB;
CurrentE_Point = PointGe;
validIntersectP= true; // 'E' has been updated.
// validApproxIntPV= false; // 'F' is no longer valid, as E changed
validIntersectP = true; // 'E' has been updated.
G4bool validNormalAB;
NormalAtEntry = GetSurfaceNormal( PointGe, validNormalAB );
@@ -719,15 +721,14 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
}
else
{
validIntersectP= false; // No new 'E' chord intersection found
// validApproxIntPV= false; // So also 'F' is invalid
validIntersectP = false; // No new 'E' chord intersection found
if( depth == 1)
{
there_is_no_intersection = true;
}
}
depth--;
fin_section_depth[depth]=true;
fin_section_depth[depth] = true;
unfinished = !validIntersectP;
}
#ifdef G4DEBUG_FIELD
@@ -753,7 +754,7 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
} // if(!found_aproximate_intersection)
assert( validIntersectP || there_is_no_intersection
|| found_approximate_intersection);
|| found_approximate_intersection);
} while ( ( ! found_approximate_intersection )
&& ( ! there_is_no_intersection )
@@ -820,14 +821,6 @@ G4bool G4MultiLevelLocator::EstimateIntersectionPoint(
G4Exception(MethodName, "GeomNav1002", JustWarning, message);
}
}
#ifdef G4DEBUG_FIELD
if( found_approximate_intersection )
{
assert( validApproxIntPV &&
"Approximate Intersection must not have been invalidated." );
}
#endif
return (!there_is_no_intersection) && found_approximate_intersection;
// Success or failure
@@ -848,15 +841,15 @@ void G4MultiLevelLocator::ReportFieldValue( const G4FieldTrack& locationPV,
const char* nameLoc,
const G4EquationOfMotion* equation )
{
enum { maxNumFieldComp= 24 };
enum { maxNumFieldComp = 24 };
G4ThreeVector position = locationPV.GetPosition();
G4double startPoint[4] = { position.x(), position.y(), position.z(),
locationPV.GetLabTimeOfFlight() };
G4double FieldVec[maxNumFieldComp]; // 24 ;
for (unsigned int i=0; i<maxNumFieldComp; ++i )
for (auto i=0; i<maxNumFieldComp; ++i )
{
FieldVec[i]= 0.0;
FieldVec[i] = 0.0;
}
equation->GetFieldValue( startPoint, FieldVec);
G4cout << " B-field value (" << nameLoc << ")= "
+107 -107
View File
@@ -22,11 +22,8 @@
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// GEANT4 tag $ Name: $
//
// class G4PathFinder Implementation
// class G4MultiNavigator Implementation
//
// Author: John Apostolakis, November 2006
// --------------------------------------------------------------------
@@ -47,26 +44,20 @@ class G4FieldManager;
// ********************************************************************
//
G4MultiNavigator::G4MultiNavigator()
: G4Navigator(), fLastMassWorld(0)
: G4Navigator()
{
fNoActiveNavigators= 0;
G4ThreeVector Big3Vector( kInfinity, kInfinity, kInfinity );
fLastLocatedPosition = Big3Vector;
fSafetyLocation = Big3Vector;
fPreStepLocation = Big3Vector;
fMinSafety_PreStepPt= -1.0;
fMinSafety_atSafLocation= -1.0;
fMinSafety= -kInfinity;
fTrueMinStep= fMinStep= -kInfinity;
for(G4int num=0; num< fMaxNav; ++num )
for(auto num=0; num< fMaxNav; ++num )
{
fpNavigator[num] = 0;
fpNavigator[num] = nullptr;
fLimitTruth[num] = false;
fLimitedStep[num] = kUndefLimited;
fCurrentStepSize[num] = fNewSafety[num] = -1.0;
fLocatedVolume[num] = 0;
fLocatedVolume[num] = nullptr;
}
pTransportManager= G4TransportationManager::GetTransportationManager();
@@ -81,19 +72,16 @@ G4MultiNavigator::G4MultiNavigator()
fLastMassWorld = pWorld;
}
}
fNoLimitingStep= -1;
fIdNavLimiting= -1;
}
G4MultiNavigator::~G4MultiNavigator()
{
}
G4double G4MultiNavigator::ComputeStep(const G4ThreeVector &pGlobalPoint,
const G4ThreeVector &pDirection,
G4double G4MultiNavigator::ComputeStep(const G4ThreeVector& pGlobalPoint,
const G4ThreeVector& pDirection,
const G4double proposedStepLength,
G4double &pNewSafety)
G4double& pNewSafety)
{
G4double safety= 0.0, step=0.0;
G4double minSafety= kInfinity, minStep= kInfinity;
@@ -118,7 +106,7 @@ G4double G4MultiNavigator::ComputeStep(const G4ThreeVector &pGlobalPoint,
G4ThreeVector initialPosition = pGlobalPoint;
G4ThreeVector initialDirection= pDirection;
for( G4int num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
for( auto num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
{
safety= kInfinity;
@@ -190,9 +178,9 @@ G4double G4MultiNavigator::ComputeStep(const G4ThreeVector &pGlobalPoint,
G4double
G4MultiNavigator::ObtainFinalStep( G4int navigatorId,
G4double &pNewSafety, // for this geometry
G4double &minStep,
ELimited &limitedStep)
G4double& pNewSafety, // for this geometry
G4double& minStep,
ELimited& limitedStep)
{
if( navigatorId > fNoActiveNavigators )
{
@@ -277,14 +265,14 @@ void G4MultiNavigator::PrepareNavigators()
FatalException, message);
}
pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
for( G4int num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
pNavigatorIter= pTransportManager->GetActiveNavigatorsIterator();
for( auto num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
{
fpNavigator[num] = *pNavigatorIter;
fpNavigator[num] = *pNavigatorIter;
fLimitTruth[num] = false;
fLimitedStep[num] = kDoNot;
fCurrentStepSize[num] = 0.0;
fLocatedVolume[num] = 0;
fLocatedVolume[num] = nullptr;
}
fWasLimitedByGeometry = false;
@@ -341,7 +329,7 @@ G4MultiNavigator::LocateGlobalPointAndSetup(const G4ThreeVector& position,
}
#endif
for ( G4int num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
for ( auto num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
{
if( fWasLimitedByGeometry && fLimitTruth[num] )
{
@@ -383,7 +371,7 @@ G4MultiNavigator::LocateGlobalPointAndSetup(const G4ThreeVector& position,
}
fWasLimitedByGeometry = false; // Clear on locating
G4VPhysicalVolume* volMassLocated= fLocatedVolume[0];
G4VPhysicalVolume* volMassLocated = fLocatedVolume[0];
return volMassLocated;
}
@@ -406,7 +394,7 @@ G4MultiNavigator::LocateGlobalPointWithinVolume(const G4ThreeVector& position)
}
#endif
for ( G4int num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
for ( auto num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
{
// ... none limited the step
@@ -436,7 +424,7 @@ G4double G4MultiNavigator::ComputeSafety( const G4ThreeVector& position,
std::vector<G4Navigator*>::iterator pNavigatorIter;
pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
for( G4int num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
for( auto num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
{
safety = (*pNavigatorIter)->ComputeSafety( position, maxDistance, state);
if( safety < minSafety ) { minSafety = safety; }
@@ -468,7 +456,7 @@ G4MultiNavigator::CreateTouchableHistoryHandle() const
touchHist= fpNavigator[0] -> CreateTouchableHistory();
G4VPhysicalVolume* locatedVolume= fLocatedVolume[0];
if( locatedVolume == 0 )
if( locatedVolume == nullptr )
{
// Workaround to ensure that the touchable is fixed !! // TODO: fix
//
@@ -502,21 +490,21 @@ void G4MultiNavigator::WhichLimited()
&& ( fMinStep!= kInfinity);
if( transportLimited )
{
shared= kSharedTransport;
shared = kSharedTransport;
}
for ( G4int num= 0; num < fNoActiveNavigators; num++ )
for ( auto num = 0; num < fNoActiveNavigators; ++num )
{
G4bool limitedStep;
G4double step= fCurrentStepSize[num];
G4double step = fCurrentStepSize[num];
limitedStep = ( step == fMinStep ) && ( step != kInfinity);
fLimitTruth[ num ] = limitedStep;
if( limitedStep )
{
noLimited++;
++noLimited;
fLimitedStep[num] = shared;
last= num;
}
@@ -531,7 +519,7 @@ void G4MultiNavigator::WhichLimited()
fIdNavLimiting = last;
}
fNoLimitingStep= noLimited;
fNoLimitingStep = noLimited;
return;
}
@@ -564,7 +552,7 @@ G4MultiNavigator::PrintLimited()
}
#endif
for ( G4int num= 0; num < fNoActiveNavigators; num++ )
for ( auto num = 0; num < fNoActiveNavigators; ++num )
{
G4double rawStep = fCurrentStepSize[num];
G4double stepLen = fCurrentStepSize[num];
@@ -572,7 +560,7 @@ G4MultiNavigator::PrintLimited()
{
stepLen = fTrueMinStep; // did not limit (went as far as asked)
}
G4int oldPrec= G4cout.precision(9);
G4int oldPrec = G4cout.precision(9);
G4cout << std::setw(5) << num << " "
<< std::setw(12) << stepLen << " "
@@ -582,20 +570,20 @@ G4MultiNavigator::PrintLimited()
G4String limitedStr;
switch ( fLimitedStep[num] )
{
case kDoNot : limitedStr= StrDoNot; break;
case kDoNot : limitedStr = StrDoNot; break;
case kUnique : limitedStr = StrUnique; break;
case kSharedTransport: limitedStr= StrSharedTransport; break;
case kSharedTransport: limitedStr = StrSharedTransport; break;
case kSharedOther : limitedStr = StrSharedOther; break;
default : limitedStr = StrUndefined; break;
}
G4cout << " " << std::setw(15) << limitedStr << " ";
G4cout.precision(oldPrec);
G4Navigator *pNav= fpNavigator[ num ];
G4Navigator *pNav = fpNavigator[ num ];
G4String WorldName( "Not-Set" );
if (pNav)
if (pNav != nullptr)
{
G4VPhysicalVolume *pWorld= pNav->GetWorldVolume();
G4VPhysicalVolume *pWorld = pNav->GetWorldVolume();
if( pWorld )
{
WorldName = pWorld->GetName();
@@ -611,18 +599,19 @@ G4MultiNavigator::PrintLimited()
void G4MultiNavigator::ResetState()
{
fWasLimitedByGeometry= false;
fWasLimitedByGeometry = false;
G4Exception("G4MultiNavigator::ResetState()", "GeomNav0001",
FatalException,
"Cannot reset state for navigators of G4MultiNavigator.");
/*
std::vector<G4Navigator*>::iterator pNavigatorIter;
pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
for( G4int num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
pNavigatorIter = pTransportManager->GetActiveNavigatorsIterator();
for( auto num = 0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
{
// (*pNavigatorIter)->ResetState(); // KEEP THIS comment !!!
}
}
*/
}
// -----------------------------------------------------------------------
@@ -638,7 +627,7 @@ void G4MultiNavigator::SetupHierarchy()
void G4MultiNavigator::CheckMassWorld()
{
G4VPhysicalVolume* navTrackWorld=
G4VPhysicalVolume* navTrackWorld =
pTransportManager->GetNavigatorForTracking()->GetWorldVolume();
if( navTrackWorld != fLastMassWorld )
@@ -652,16 +641,16 @@ void G4MultiNavigator::CheckMassWorld()
// -----------------------------------------------------------------------
G4VPhysicalVolume*
G4MultiNavigator::ResetHierarchyAndLocate(const G4ThreeVector &point,
const G4ThreeVector &direction,
const G4TouchableHistory &MassHistory)
G4MultiNavigator::ResetHierarchyAndLocate(const G4ThreeVector& point,
const G4ThreeVector& direction,
const G4TouchableHistory& MassHistory)
{
// Reset geometry for all -- and use the touchable for the mass history
G4VPhysicalVolume* massVolume=0;
G4Navigator* pMassNavigator= fpNavigator[0];
G4VPhysicalVolume* massVolume = nullptr;
G4Navigator* pMassNavigator = fpNavigator[0];
if( pMassNavigator )
if( pMassNavigator != nullptr )
{
massVolume= pMassNavigator->ResetHierarchyAndLocate( point, direction,
MassHistory);
@@ -676,7 +665,7 @@ G4MultiNavigator::ResetHierarchyAndLocate(const G4ThreeVector &point,
std::vector<G4Navigator*>::iterator pNavIter=
pTransportManager->GetActiveNavigatorsIterator();
for ( G4int num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
for ( auto num = 0; num < fNoActiveNavigators ; ++pNavIter,++num )
{
G4bool relativeSearch, ignoreDirection;
@@ -688,23 +677,24 @@ G4MultiNavigator::ResetHierarchyAndLocate(const G4ThreeVector &point,
return massVolume;
}
// ----------------- ooooooOOOOOOOOOOOOOOOoooooo -------------------------------------
// -----------------------------------------------------------------------
G4ThreeVector
G4MultiNavigator::GetGlobalExitNormal(const G4ThreeVector &argPoint,
G4MultiNavigator::GetGlobalExitNormal(const G4ThreeVector& argPoint,
G4bool* argpObtained) // obtained valid
{
G4ThreeVector normalGlobalCrd(0.0, 0.0, 0.0);
G4bool isObtained= false;
G4bool isObtained = false;
// These default values will be used if fNoLimitingStep== 0
G4int firstNavigatorId= -1;
G4bool oneObtained= false;
G4int firstNavigatorId = -1;
G4bool oneObtained = false;
if( fNoLimitingStep==1 )
if( fNoLimitingStep == 1 )
{
// Only message the Navigator which limited the step!
normalGlobalCrd= fpNavigator[ fIdNavLimiting ]->GetGlobalExitNormal( argPoint, &isObtained);
*argpObtained= isObtained;
normalGlobalCrd = fpNavigator[ fIdNavLimiting ]
->GetGlobalExitNormal( argPoint, &isObtained );
*argpObtained = isObtained;
}
else
{
@@ -713,43 +703,51 @@ G4MultiNavigator::GetGlobalExitNormal(const G4ThreeVector &argPoint,
std::vector<G4Navigator*>::iterator pNavIter=
pTransportManager->GetActiveNavigatorsIterator();
for ( G4int num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
for ( auto num = 0; num < fNoActiveNavigators ; ++pNavIter, ++num )
{
G4ThreeVector oneNormal;
if( fLimitTruth[ num ] ) // Did this geometry limit the step ?
{
G4ThreeVector newNormal= (*pNavIter)-> GetGlobalExitNormal( argPoint, &oneObtained );
G4ThreeVector newNormal =
(*pNavIter)->GetGlobalExitNormal( argPoint, &oneObtained );
if( oneObtained )
{
// Keep first one - only if it is valid (ie not null)
if( !isObtained && (newNormal.mag2() != 0.0) )
{
normalGlobalCrd= newNormal;
isObtained = oneObtained;
firstNavigatorId= num;
}else{
normalGlobalCrd = newNormal;
isObtained = oneObtained;
firstNavigatorId = num;
}
else
{
// Check for clash
G4double dotNewPrevious= newNormal.dot( normalGlobalCrd );
G4double productMagSq= normalGlobalCrd.mag2() * newNormal.mag2();
G4double dotNewPrevious = newNormal.dot( normalGlobalCrd );
G4double productMagSq = normalGlobalCrd.mag2()*newNormal.mag2();
if( productMagSq > 0.0 )
{
G4double productMag= std::sqrt( productMagSq );
G4double productMag = std::sqrt( productMagSq );
dotNewPrevious /= productMag; // Normalise
if( dotNewPrevious < (1 - perThousand) )
{
*argpObtained= false;
*argpObtained = false;
if( fVerbose > 2 ) // dotNewPrevious <= 0.0 )
{
std::ostringstream message;
message << "Clash of Normal from different Navigators!" << G4endl
<< " Previous Navigator Id = " << firstNavigatorId << G4endl
<< " Current Navigator Id = " << num << G4endl;
message << " Dot product of 2 normals = " << dotNewPrevious << G4endl;
message << " Normal (previous) = " << normalGlobalCrd << G4endl;
message << "Clash of Normal from different Navigators!"
<< G4endl
<< " Previous Navigator Id = "
<< firstNavigatorId << G4endl
<< " Current Navigator Id = "
<< num << G4endl;
message << " Dot product of 2 normals = "
<< dotNewPrevious << G4endl;
message << " Normal (previous) = "
<< normalGlobalCrd << G4endl;
message << " Normal (current) = " << newNormal << G4endl;
G4Exception("G4MultiNavigator::GetGlobalExitNormal()", "GeomNav0002",
JustWarning, message);
G4Exception("G4MultiNavigator::GetGlobalExitNormal()",
"GeomNav0002", JustWarning, message);
}
}
else
@@ -775,59 +773,61 @@ G4MultiNavigator::GetGlobalExitNormal(const G4ThreeVector &argPoint,
} // end if ( fNoLimiting > 1 )
} // end else
*argpObtained= isObtained;
*argpObtained = isObtained;
return normalGlobalCrd;
}
// ----------------- ooooooOOOOOOOOOOOOOOOoooooo -------------------------------------
// -----------------------------------------------------------------------
G4ThreeVector
G4MultiNavigator::GetLocalExitNormal(G4bool* argpObtained)
{
// If it is the mass navigator, then expect
G4ThreeVector normalGlobalCrd(0.0, 0.0, 0.0);
G4bool isObtained= false;
G4bool isObtained = false;
// These default values will be used if fNoLimitingStep== 0
if( fNoLimitingStep==1 )
if( fNoLimitingStep == 1 )
{
// Only message the Navigator which limited the step!
normalGlobalCrd= fpNavigator[ fIdNavLimiting ]->GetLocalExitNormal( &isObtained);
*argpObtained= isObtained;
normalGlobalCrd = fpNavigator[ fIdNavLimiting ]
->GetLocalExitNormal( &isObtained );
*argpObtained = isObtained;
static G4ThreadLocal G4int numberWarnings= 0;
G4int noWarningsStart= 10, noModuloWarnings=100;
numberWarnings++;
if( (numberWarnings < noWarningsStart ) || (numberWarnings%noModuloWarnings==0) )
static G4ThreadLocal G4int numberWarnings = 0;
G4int noWarningsStart = 10, noModuloWarnings = 100;
++numberWarnings;
if( (numberWarnings < noWarningsStart )
|| (numberWarnings%noModuloWarnings == 0) )
{
std::ostringstream message;
message << "Cannot obtain normal in local coordinates of two or more coordinate systems." << G4endl;
G4Exception("G4MultiNavigator::GetGlobalExitNormal()", "GeomNav0002",
JustWarning, message);
std::ostringstream message;
message << "Cannot obtain normal in local coordinates of two or more "
<< "coordinate systems." << G4endl;
G4Exception("G4MultiNavigator::GetGlobalExitNormal()", "GeomNav0002",
JustWarning, message);
}
}
else
{
if( fNoLimitingStep > 1 )
{
// Does not make sense - cannot obtain *local* normal in several coordinate systems
std::ostringstream message;
message << "Cannot obtain normal in local coordinates of two or more coordinate systems." << G4endl;
G4Exception("G4MultiNavigator::GetGlobalExitNormal()", "GeomNav0002",
FatalException, message);
std::ostringstream message;
message << "Cannot obtain normal in local coordinates of two or more "
<< "coordinate systems." << G4endl;
G4Exception("G4MultiNavigator::GetGlobalExitNormal()", "GeomNav0002",
FatalException, message);
}
}
*argpObtained= isObtained;
*argpObtained = isObtained;
return normalGlobalCrd;
}
// ----------------- ooooooOOOOOOOOOOOOOOOoooooo -------------------------------------
// -----------------------------------------------------------------------
G4ThreeVector
G4MultiNavigator::GetLocalExitNormalAndCheck(const G4ThreeVector &, // point,
G4MultiNavigator::GetLocalExitNormalAndCheck(const G4ThreeVector&, // point,
G4bool* obtained)
{
return G4MultiNavigator::GetLocalExitNormal( obtained);
return G4MultiNavigator::GetLocalExitNormal( obtained );
}
@@ -23,13 +23,9 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4NavigationLogger Implementation
//
// Author: G.Cosmo, 2010
//
// --------------------------------------------------------------------
#include <iomanip>
@@ -38,11 +34,10 @@
#include "G4NavigationLogger.hh"
#include "G4GeometryTolerance.hh"
// const double millimeter = CLHEP::Units::millimeter;
using CLHEP::millimeter;
G4NavigationLogger::G4NavigationLogger(const G4String& id)
: fId(id), fVerbose(0), fMinTriggerDistance( DBL_MAX ), fReportSoftWarnings( false )
: fId(id)
{
}
@@ -61,7 +56,6 @@ G4NavigationLogger::PreComputeStepLog(const G4VPhysicalVolume* motherPhysical,
{
G4VSolid* motherSolid = motherPhysical->GetLogicalVolume()->GetSolid();
G4String fType = fId + "::ComputeStep()";
// const double millimeter = CLHEP::millimeter;
if ( fVerbose == 1 || fVerbose > 4 )
{
@@ -114,7 +108,7 @@ G4NavigationLogger::PreComputeStepLog(const G4VPhysicalVolume* motherPhysical,
//
if ( fVerbose > 1 )
{
static const G4int precVerf= 16; // Precision
static const G4int precVerf = 16; // Precision
G4int oldprec = G4cout.precision(precVerf);
G4cout << " - Information on mother / key daughters ..." << G4endl;
G4cout << " Type " << std::setw(12) << "Solid-Name" << " "
@@ -150,8 +144,8 @@ G4NavigationLogger::AlongComputeStepLog(const G4VSolid* sampleSolid,
if ( sampleStep < kInfinity )
{
G4ThreeVector intersectionPoint;
intersectionPoint= samplePoint + sampleStep * sampleDirection;
EInside insideIntPt= sampleSolid->Inside(intersectionPoint);
intersectionPoint = samplePoint + sampleStep * sampleDirection;
EInside insideIntPt = sampleSolid->Inside(intersectionPoint);
G4String fType = fId + "::ComputeStep()";
G4String solidResponse = "-kInside-";
@@ -169,19 +163,19 @@ G4NavigationLogger::AlongComputeStepLog(const G4VSolid* sampleSolid,
<< ", considered as 'intersection' point." << G4endl;
}
G4double safetyIn= -1, safetyOut= -1; // Set to invalid values
G4double newDistIn= -1, newDistOut= -1;
G4double safetyIn = -1, safetyOut = -1; // Set to invalid values
G4double newDistIn = -1, newDistOut = -1;
if( insideIntPt != kInside )
{
safetyIn= sampleSolid->DistanceToIn(intersectionPoint);
newDistIn= sampleSolid->DistanceToIn(intersectionPoint,
sampleDirection);
safetyIn = sampleSolid->DistanceToIn(intersectionPoint);
newDistIn = sampleSolid->DistanceToIn(intersectionPoint,
sampleDirection);
}
if( insideIntPt != kOutside )
{
safetyOut= sampleSolid->DistanceToOut(intersectionPoint);
newDistOut= sampleSolid->DistanceToOut(intersectionPoint,
sampleDirection);
safetyOut = sampleSolid->DistanceToOut(intersectionPoint);
newDistOut = sampleSolid->DistanceToOut(intersectionPoint,
sampleDirection);
}
if( insideIntPt != kSurface )
{
@@ -302,14 +296,14 @@ G4NavigationLogger::CheckDaughterEntryPoint(const G4VSolid* sampleSolid,
// Check #1) whether the track will re-enter the current mother
// in the extension past its current exit point
G4ThreeVector localExitMotherPos= localPoint+motherStep*localDirection;
G4double distExitToReEntry= motherSolid->DistanceToIn(localExitMotherPos,
localDirection);
G4ThreeVector localExitMotherPos = localPoint+motherStep*localDirection;
G4double distExitToReEntry = motherSolid->DistanceToIn(localExitMotherPos,
localDirection);
// Check #2) whether the 'entry' point in the daughter is inside the mother
//
G4ThreeVector localEntryInDaughter = localPoint+sampleStep*localDirection;
EInside insideMother= motherSolid->Inside( localEntryInDaughter );
EInside insideMother = motherSolid->Inside( localEntryInDaughter );
G4String solidResponse = "-kInside-";
if (insideMother == kOutside) { solidResponse = "-kOutside-"; }
@@ -324,11 +318,11 @@ G4NavigationLogger::CheckDaughterEntryPoint(const G4VSolid* sampleSolid,
G4bool EntryIsMotherExit = std::fabs(sampleStep-motherStep) < kCarTolerance;
// Check for more subtle error - is exit point of daughter correct ?
G4ThreeVector sampleEntryPoint= samplePoint+sampleStep*sampleDirection;
G4double sampleCrossingDist= sampleSolid->DistanceToOut( sampleEntryPoint,
sampleDirection );
G4ThreeVector sampleEntryPoint = samplePoint+sampleStep*sampleDirection;
G4double sampleCrossingDist = sampleSolid->DistanceToOut( sampleEntryPoint,
sampleDirection );
G4double sampleExitDist = sampleStep+sampleCrossingDist;
G4ThreeVector sampleExitPoint= samplePoint+sampleExitDist*sampleDirection;
G4ThreeVector sampleExitPoint = samplePoint+sampleExitDist*sampleDirection;
G4bool TransitProblem = ( (sampleStep < motherStep)
&& (sampleExitDist > motherStep + kCarTolerance) )
@@ -456,8 +450,8 @@ G4NavigationLogger::PostComputeStepLog(const G4VSolid* motherSolid,
if( ( motherStep < 0.0 ) || ( motherStep >= kInfinity) )
{
G4String fType = fId + "::ComputeStep()";
G4int oldPrOut= G4cout.precision(16);
G4int oldPrErr= G4cerr.precision(16);
G4int oldPrOut = G4cout.precision(16);
G4int oldPrErr = G4cerr.precision(16);
std::ostringstream message;
message << "Current point is outside the current solid !" << G4endl
<< " Problem in Navigation" << G4endl
@@ -472,7 +466,7 @@ G4NavigationLogger::PostComputeStepLog(const G4VSolid* motherSolid,
}
if ( fVerbose > 1 )
{
static const G4int precVerf= 20; // Precision
static const G4int precVerf = 20; // Precision
G4int oldprec = G4cout.precision(precVerf);
G4cout << " Mother " << std::setw(12) << motherSolid->GetName() << " "
<< std::setw(4+precVerf) << localPoint << " "
@@ -531,7 +525,7 @@ G4NavigationLogger::PrintDaughterLog (const G4VSolid* sampleSolid,
{
if ( fVerbose >= 1 )
{
G4int oldPrec= G4cout.precision(8);
G4int oldPrec = G4cout.precision(8);
G4cout << "Daughter "
<< std::setw(15) << sampleSafety << " ";
if (withStep) // (sampleStep != -1.0 )
@@ -566,12 +560,12 @@ CheckAndReportBadNormal(const G4ThreeVector& unitNormal,
const G4VSolid* solid,
const char* msg ) const
{
G4double normMag2 = unitNormal.mag2();
G4double normMag2 = unitNormal.mag2();
G4bool badLength = ( std::fabs ( normMag2 - 1.0 ) > CLHEP::perMillion );
if( badLength )
{
G4double normMag= std::sqrt(normMag2);
G4double normMag = std::sqrt(normMag2);
G4ExceptionDescription message;
message.precision(10);
message << "============================================================"
@@ -621,7 +615,7 @@ CheckAndReportBadNormal(const G4ThreeVector& rotatedNormal,
if( badLength )
{
G4double normMag= std::sqrt(normMag2);
G4double normMag = std::sqrt(normMag2);
G4ExceptionDescription message;
message.precision(10);
message << "============================================================"
@@ -669,13 +663,13 @@ G4NavigationLogger::ReportOutsideMother(const G4ThreeVector& localPoint,
G4double triggerDist) const
{
const G4LogicalVolume* logicalVol = physical
? physical->GetLogicalVolume() : 0;
? physical->GetLogicalVolume() : nullptr;
const G4VSolid* solid = logicalVol
? logicalVol->GetSolid() : 0;
? logicalVol->GetSolid() : nullptr;
G4String fMethod = fId + "::ComputeStep()";
if( solid == 0 )
if( solid == nullptr )
{
G4Exception(fMethod, "GeomNav0003", FatalException,
"Erroneous call to ReportOutsideMother: no Solid is available");
@@ -684,15 +678,12 @@ G4NavigationLogger::ReportOutsideMother(const G4ThreeVector& localPoint,
const G4double kCarTolerance = solid->GetTolerance();
// Double check reply - it should be kInfinity
const G4double distToOut = solid->DistanceToOut(localPoint, localDirection);
// const G4double distToOutNeg = solid->DistanceToOut(localPoint, -localDirection);
const G4double distToOut = solid->DistanceToOut(localPoint, localDirection);
const EInside inSolid = solid->Inside(localPoint);
const G4double safetyToIn = solid->DistanceToIn(localPoint);
const G4double safetyToOut = solid->DistanceToOut(localPoint);
const G4double distToInPos = solid->DistanceToIn(localPoint, localDirection);
// const G4double distToInNeg = solid->DistanceToIn(localPoint, -localDirection);
// const G4double distToInPos =
// solid->DistanceToIn(localPoint, localDirection);
// 1. Check consistency between Safety obtained and report from distance
// We must ensure that (mother)Safety <= 0.0
@@ -720,16 +711,15 @@ G4NavigationLogger::ReportOutsideMother(const G4ThreeVector& localPoint,
// 2. Inconsistency - Too many distances are zero (or will be rounded to zero)
G4ExceptionDescription msg2;
if( std::fabs(distToOut) < kCarTolerance && std::fabs(distToInPos) < kCarTolerance )
{
// If both distanceToIn and distanceToOut (p,v) are zero for one direction,
// the particle could get stuck!
}
// if( std::fabs(distToOut) < kCarTolerance
// && std::fabs(distToInPos) < kCarTolerance )
// {
// If both distanceToIn and distanceToOut (p,v) are zero for
// one direction, the particle could get stuck!
// }
G4ExceptionDescription msg;
msg.precision(10);
// G4bool reportIssue= true;
if( std::fabs(distToOut) < kCarTolerance )
{
@@ -737,10 +727,11 @@ G4NavigationLogger::ReportOutsideMother(const G4ThreeVector& localPoint,
// Report nothing - except in 'loud' mode
if( fReportSoftWarnings )
{
// reportIssue= true;
msg << " Warning> DistanceToOut(p,v): Distance from surface is not rounded to zero" << G4endl;
} else {
// reportIssue= false;
msg << " Warning> DistanceToOut(p,v): "
<< "Distance from surface is not rounded to zero" << G4endl;
}
else
{
return;
}
}
@@ -749,23 +740,25 @@ G4NavigationLogger::ReportOutsideMother(const G4ThreeVector& localPoint,
// 4. General message - complain that the point is outside!
// and provide all information about the current location,
// direction and the answers of the solid
msg << "============================================================" << G4endl;
msg << " WARNING> Current Point appears to be Outside mother volume !! " << G4endl;
msg << " Response of DistanceToOut was negative or kInfinity when called in "
<< fMethod << G4endl;
msg << "============================================================"
<< G4endl;
msg << " WARNING> Current Point appears to be Outside mother volume !! "
<< G4endl;
msg << " Response of DistanceToOut was negative or kInfinity"
<< " when called in " << fMethod << G4endl;
}
// Generate and 'print'/stream all the information needed
this->ReportVolumeAndIntersection( msg, localPoint, localDirection, physical );
this->ReportVolumeAndIntersection(msg, localPoint, localDirection, physical);
// Default for distance of 'major' error
if( triggerDist <= 0.0 ) {
// triggerDist = 1.e+6 * kCarTolerance; // Well beyond tolerance
if( triggerDist <= 0.0 )
{
triggerDist = std::max ( 1.0e+6 * kCarTolerance, // Well beyond tolerance
fMinTriggerDistance );
}
G4bool majorError = inSolid==kOutside
G4bool majorError = inSolid == kOutside
? ( safetyToIn > triggerDist )
: ( safetyToOut > triggerDist );
@@ -778,32 +771,34 @@ G4NavigationLogger::ReportOutsideMother(const G4ThreeVector& localPoint,
G4Exception( fMethod, "GeomNav0003", exceptionType, msg);
}
namespace G4NavigationLogger_Namespace {
namespace G4NavigationLogger_Namespace
{
const G4String EInsideNames[3] = { "kOutside", "kSurface", "kInside" };
}
void
G4NavigationLogger::ReportVolumeAndIntersection( std::ostream& os,
const G4ThreeVector& localPoint,
const G4ThreeVector& localDirection,
const G4VPhysicalVolume* physical ) const
void G4NavigationLogger::
ReportVolumeAndIntersection( std::ostream& os,
const G4ThreeVector& localPoint,
const G4ThreeVector& localDirection,
const G4VPhysicalVolume* physical ) const
{
G4String fMethod = fId + "::ComputeStep()";
const G4LogicalVolume* logicalVol = physical
? physical->GetLogicalVolume() : 0;
? physical->GetLogicalVolume() : nullptr;
const G4VSolid* solid = logicalVol
? logicalVol->GetSolid() : 0;
if( solid == 0 )
? logicalVol->GetSolid() : nullptr;
if( solid == nullptr )
{
os << " ERROR> Solid is not available. Logical Volume = " << logicalVol << std::endl;
os << " ERROR> Solid is not available. Logical Volume = "
<< logicalVol << std::endl;
return;
}
const G4double kCarTolerance = solid->GetTolerance();
// Double check reply - it should be kInfinity
const G4double distToOut = solid->DistanceToOut(localPoint, localDirection);
const G4double distToOutNeg = solid->DistanceToOut(localPoint, -localDirection);
const G4double distToOutNeg = solid->DistanceToOut(localPoint,
-localDirection);
const EInside inSolid = solid->Inside(localPoint);
const G4double safetyToIn = solid->DistanceToIn(localPoint);
const G4double safetyToOut = solid->DistanceToOut(localPoint);
@@ -815,30 +810,35 @@ G4NavigationLogger::ReportVolumeAndIntersection( std::ostream& os,
// Double check whether points nearby are in/surface/out
const G4double epsilonDist = 1000.0 * kCarTolerance;
const G4ThreeVector PointPlusDir = localPoint + epsilonDist * localDirection;
const G4ThreeVector PointPlusDir = localPoint + epsilonDist * localDirection;
const G4ThreeVector PointMinusDir = localPoint - epsilonDist * localDirection;
const G4ThreeVector PointPlusNorm = localPoint + epsilonDist * exitNormal;
const G4ThreeVector PointPlusNorm = localPoint + epsilonDist * exitNormal;
const G4ThreeVector PointMinusNorm = localPoint - epsilonDist * exitNormal;
const EInside inPlusDir= solid->Inside(PointPlusDir);
const EInside inMinusDir= solid->Inside(PointMinusDir);
const EInside inPlusNorm= solid->Inside(PointPlusNorm);
const EInside inMinusNorm= solid->Inside(PointMinusNorm);
const EInside inPlusDir = solid->Inside(PointPlusDir);
const EInside inMinusDir = solid->Inside(PointMinusDir);
const EInside inPlusNorm = solid->Inside(PointPlusNorm);
const EInside inMinusNorm = solid->Inside(PointMinusNorm);
// Basic information
os << " Current physical volume = " << physical->GetName() << G4endl;
os << " Position (loc) = " << localPoint << G4endl
<< " Direction (dir) = " << localDirection << G4endl;
<< " Direction (dir) = " << localDirection << G4endl;
os << " For confirmation:" << G4endl;
os << " Response of DistanceToOut (loc, +dir)= " << distToOut << G4endl;
os << " Response of DistanceToOut (loc, -dir)= " << distToOutNeg << G4endl;
os << " Inside responds = " << inSolid << " , ie: ";
if( inSolid == kOutside ) {
if( inSolid == kOutside )
{
os << " Outside -- a problem, as observed in " << fMethod << G4endl;
} else if( inSolid == kSurface ) {
}
else if( inSolid == kSurface )
{
os << " Surface -- unexpected / inconsistent response ! " << G4endl;
} else {
}
else
{
os << " Inside -- unexpected / inconsistent response ! " << G4endl;
}
os << " Obtain safety(ToIn) = " << safetyToIn << G4endl;
@@ -850,11 +850,16 @@ G4NavigationLogger::ReportVolumeAndIntersection( std::ostream& os,
os << " Dir . Normal = " << exitNormal.dot( localDirection );
os << G4endl;
os << " Checking points moved from position by distance/dir. Solid responses: " << G4endl
<< " +eps in direction : " << G4NavigationLogger_Namespace::EInsideNames[inPlusDir]
<< " +eps in Normal : " << G4NavigationLogger_Namespace::EInsideNames[inPlusNorm] << G4endl
<< " -eps in direction : " << G4NavigationLogger_Namespace::EInsideNames[inMinusDir]
<< " -eps in Normal : " << G4NavigationLogger_Namespace::EInsideNames[inMinusNorm] << G4endl;
os << " Checking points moved from position by distance/direction." << G4endl
<< " Solid responses: " << G4endl
<< " +eps in direction : "
<< G4NavigationLogger_Namespace::EInsideNames[inPlusDir]
<< " +eps in Normal : "
<< G4NavigationLogger_Namespace::EInsideNames[inPlusNorm] << G4endl
<< " -eps in direction : "
<< G4NavigationLogger_Namespace::EInsideNames[inMinusDir]
<< " -eps in Normal : "
<< G4NavigationLogger_Namespace::EInsideNames[inMinusNorm] << G4endl;
os << " Parameters of solid: " << G4endl;
os << *solid;
File diff suppressed because it is too large Load Diff
@@ -23,9 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4NormalNavigation Implementation
//
// Author: P.Kent, 1996
@@ -41,7 +38,6 @@
// ********************************************************************
//
G4NormalNavigation::G4NormalNavigation()
: fCheck(false)
{
fLogger = new G4NavigationLogger("G4NormalNavigation");
}
@@ -65,26 +61,27 @@ G4NormalNavigation::~G4NormalNavigation()
// On exit
// exitNormal, validExitNormal: for mother, if exiting it (else unchanged)
G4double
G4NormalNavigation::ComputeStep(const G4ThreeVector &localPoint,
const G4ThreeVector &localDirection,
G4NormalNavigation::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)
G4double& newSafety,
G4NavigationHistory& history,
G4bool& validExitNormal,
G4ThreeVector& exitNormal,
G4bool& exiting,
G4bool& entering,
G4VPhysicalVolume* (*pBlockedPhysical),
G4int& blockedReplicaNo)
{
G4VPhysicalVolume *motherPhysical, *samplePhysical, *blockedExitedVol=0;
G4VPhysicalVolume *motherPhysical, *samplePhysical,
*blockedExitedVol = nullptr;
G4LogicalVolume *motherLogical;
G4VSolid *motherSolid;
G4ThreeVector sampleDirection;
G4double ourStep=currentProposedStepLength, ourSafety;
G4double motherSafety, motherStep=DBL_MAX;
G4double ourStep = currentProposedStepLength, ourSafety;
G4double motherSafety, motherStep = DBL_MAX;
G4int localNoDaughters, sampleNo;
G4bool motherValidExitNormal=false;
G4bool motherValidExitNormal = false;
G4ThreeVector motherExitNormal;
motherPhysical = history.GetTopVolume();
@@ -109,7 +106,7 @@ G4NormalNavigation::ComputeStep(const G4ThreeVector &localPoint,
// Exiting normal optimisation
//
if ( exiting&&validExitNormal )
if ( exiting && validExitNormal )
{
if ( localDirection.dot(exitNormal)>=kMinExitingNormalCosine )
{
@@ -143,17 +140,17 @@ G4NormalNavigation::ComputeStep(const G4ThreeVector &localPoint,
ourStep = motherStep = 0.0;
exiting= true;
entering= false;
exiting = true;
entering = false;
// If we are outside the solid does the normal make sense?
validExitNormal= motherValidExitNormal;
exitNormal= motherExitNormal;
validExitNormal = motherValidExitNormal;
exitNormal = motherExitNormal;
*pBlockedPhysical= 0; // or motherPhysical ?
blockedReplicaNo= 0; // or motherReplicaNumber ?
*pBlockedPhysical = nullptr; // or motherPhysical ?
blockedReplicaNo = 0; // or motherReplicaNumber ?
newSafety= 0.0;
newSafety = 0.0;
return ourStep;
}
}
@@ -202,7 +199,8 @@ G4NormalNavigation::ComputeStep(const G4ThreeVector &localPoint,
if( fCheck )
{
fLogger->AlongComputeStepLog(sampleSolid, samplePoint,
sampleDirection, localDirection, sampleSafety, sampleStep);
sampleDirection, localDirection,
sampleSafety, sampleStep);
}
#endif
}
@@ -215,15 +213,15 @@ G4NormalNavigation::ComputeStep(const G4ThreeVector &localPoint,
fLogger->CheckDaughterEntryPoint(sampleSolid,
samplePoint, sampleDirection,
motherSolid,
localPoint, localDirection,
motherStep, sampleStep);
localPoint, localDirection,
motherStep, sampleStep);
}
#endif
} // end of if ( sampleSafety <= ourStep )
#ifdef G4VERBOSE
else if( fCheck )
else if ( fCheck )
{
fLogger->PrintDaughterLog(sampleSolid, samplePoint,
fLogger->PrintDaughterLog(sampleSolid, samplePoint,
sampleSafety, false,
G4ThreeVector(0.,0.,0.), -1.0 );
}
@@ -236,7 +234,7 @@ G4NormalNavigation::ComputeStep(const G4ThreeVector &localPoint,
//
entering = false;
exiting = false;
*pBlockedPhysical = 0;
*pBlockedPhysical = nullptr;
ourStep = kInfinity;
}
else
@@ -287,8 +285,8 @@ G4NormalNavigation::ComputeStep(const G4ThreeVector &localPoint,
// The normal could be useful - but only if near the mother
// But it could be unreliable!
validExitNormal = false;
*pBlockedPhysical= 0; // or motherPhysical ?
blockedReplicaNo= 0; // or motherReplicaNumber ?
*pBlockedPhysical = nullptr; // or motherPhysical ?
blockedReplicaNo = 0; // or motherReplicaNumber ?
newSafety= 0.0;
return ourStep;
}
@@ -298,8 +296,8 @@ G4NormalNavigation::ComputeStep(const G4ThreeVector &localPoint,
ourStep = motherStep;
exiting = true;
entering = false;
validExitNormal= motherValidExitNormal;
exitNormal= motherExitNormal;
validExitNormal = motherValidExitNormal;
exitNormal = motherExitNormal;
if ( motherValidExitNormal )
{
@@ -331,8 +329,8 @@ G4NormalNavigation::ComputeStep(const G4ThreeVector &localPoint,
// ComputeSafety
// ********************************************************************
//
G4double G4NormalNavigation::ComputeSafety(const G4ThreeVector &localPoint,
const G4NavigationHistory &history,
G4double G4NormalNavigation::ComputeSafety(const G4ThreeVector& localPoint,
const G4NavigationHistory& history,
const G4double)
{
G4VPhysicalVolume *motherPhysical, *samplePhysical;
@@ -379,8 +377,8 @@ G4double G4NormalNavigation::ComputeSafety(const G4ThreeVector &localPoint,
#ifdef G4VERBOSE
if(fCheck)
{
fLogger->ComputeSafetyLog(sampleSolid,samplePoint,
sampleSafety,false,false);
fLogger->ComputeSafetyLog(sampleSolid, samplePoint,
sampleSafety, false, false);
// Not mother, no banner
}
#endif
@@ -389,8 +387,8 @@ G4double G4NormalNavigation::ComputeSafety(const G4ThreeVector &localPoint,
}
// The following methods have been imported to this source file
// in order to avoid dependency of the header file on the
// header implementation of G4NavigationLogger.
// in order to avoid dependency of the header file on the
// header implementation of G4NavigationLogger.
// ********************************************************************
// GetVerboseLevel
@@ -409,4 +407,3 @@ void G4NormalNavigation::SetVerboseLevel(G4int level)
{
fLogger->SetVerboseLevel(level);
}
@@ -23,9 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4ParameterisedNavigation Implementation
//
// Initial Author: P.Kent, 1996
@@ -57,8 +54,6 @@
// ********************************************************************
//
G4ParameterisedNavigation::G4ParameterisedNavigation()
: fVoxelAxis(kUndefined), fVoxelNoSlices(0), fVoxelSliceWidth(0.),
fVoxelNodeNo(0), fVoxelHeader(0)
{
}
@@ -93,8 +88,8 @@ G4double G4ParameterisedNavigation::
G4VSolid *motherSolid, *sampleSolid;
G4ThreeVector sampleDirection;
G4double ourStep=currentProposedStepLength, ourSafety;
G4double motherSafety, motherStep=DBL_MAX;
G4bool motherValidExitNormal=false;
G4double motherSafety, motherStep = DBL_MAX;
G4bool motherValidExitNormal = false;
G4ThreeVector motherExitNormal;
G4int sampleNo;
@@ -136,14 +131,14 @@ G4double G4ParameterisedNavigation::
G4Exception("G4ParameterisedNavigation::ComputeStep()",
"GeomNav0003", FatalException, message);
}
if( motherSolid->Inside(localPoint)==kOutside )
if( motherSolid->Inside(localPoint) == kOutside )
{
std::ostringstream message;
message << "Point is outside Current Volume !" << G4endl
<< " Point " << localPoint
<< " is outside current volume " << motherPhysical->GetName()
<< G4endl;
G4double estDistToSolid= motherSolid->DistanceToIn(localPoint);
G4double estDistToSolid = motherSolid->DistanceToIn(localPoint);
G4cout << " Estimated isotropic distance to solid (distToIn)= "
<< estDistToSolid;
if( estDistToSolid > 100.0 * motherSolid->GetTolerance() )
@@ -154,9 +149,11 @@ G4double G4ParameterisedNavigation::
"Point is far outside Current Volume !");
}
else
{
G4Exception("G4ParameterisedNavigation::ComputeStep()",
"GeomNav1002", JustWarning, message,
"Point is a little outside Current Volume.");
"Point is a little outside Current Volume.");
}
}
// Compute early:
@@ -184,10 +181,10 @@ G4double G4ParameterisedNavigation::
validExitNormal = motherValidExitNormal;
exitNormal = motherExitNormal;
*pBlockedPhysical= 0; // or motherPhysical ?
blockedReplicaNo= 0; // or motherReplicaNumber ?
*pBlockedPhysical = nullptr; // or motherPhysical ?
blockedReplicaNo = 0; // or motherReplicaNumber ?
newSafety= 0.0;
newSafety = 0.0;
return ourStep;
}
}
@@ -269,8 +266,8 @@ G4double G4ParameterisedNavigation::
if ( ( fCheck ) && ( sampleStep < kInfinity ) )
{
G4ThreeVector intersectionPoint;
intersectionPoint= samplePoint + sampleStep * sampleDirection;
EInside insideIntPt= sampleSolid->Inside(intersectionPoint);
intersectionPoint = samplePoint + sampleStep * sampleDirection;
EInside insideIntPt = sampleSolid->Inside(intersectionPoint);
if( insideIntPt != kSurface )
{
G4int oldcoutPrec = G4cout.precision(16);
@@ -322,7 +319,7 @@ G4double G4ParameterisedNavigation::
noStep = false;
entering = false;
exiting = false;
*pBlockedPhysical = 0;
*pBlockedPhysical = nullptr;
ourStep = kInfinity;
}
else
@@ -343,7 +340,8 @@ G4double G4ParameterisedNavigation::
if( ( motherStep < 0.0 ) || ( motherStep >= kInfinity) )
{
#ifdef G4VERBOSE
fLogger->ReportOutsideMother(localPoint, localDirection, motherPhysical);
fLogger->ReportOutsideMother(localPoint, localDirection,
motherPhysical);
#endif
ourStep = motherStep = 0.0;
// Rely on the code below to set the remaining state, i.e.
@@ -366,7 +364,7 @@ G4double G4ParameterisedNavigation::
entering = false;
if ( validExitNormal )
{
const G4RotationMatrix *rot = motherPhysical->GetRotation();
const G4RotationMatrix* rot = motherPhysical->GetRotation();
if (rot)
{
exitNormal *= rot->inverse();
@@ -379,7 +377,7 @@ G4double G4ParameterisedNavigation::
}
}
}
newSafety=ourSafety;
newSafety = ourSafety;
}
if (noStep)
{
@@ -571,7 +569,7 @@ LocateNextVoxel( const G4ThreeVector& localPoint,
if ( maxVal<curCoord )
{
newNodeNo = fVoxelNode->GetMaxEquivalentSliceNo()+1;
if ( newNodeNo<fVoxelHeader->GetNoSlices() )
if ( newNodeNo<G4int(fVoxelHeader->GetNoSlices()) )
{
fVoxelNodeNo = newNodeNo;
fVoxelNode = fVoxelHeader->GetSlice(newNodeNo)->GetNode();
@@ -639,7 +637,7 @@ G4ParameterisedNavigation::LevelLocate( G4NavigationHistory& history,
// Search replicated daughter volume
//
for ( G4int sampleNo=voxelNoDaughters-1; sampleNo>=0; sampleNo-- )
for ( auto sampleNo=voxelNoDaughters-1; sampleNo>=0; sampleNo-- )
{
replicaNo = motherVoxelNode->GetVolume(sampleNo);
if ( (replicaNo!=blockedNum) || (pPhysical!=blockedVol) )
+16 -21
View File
@@ -23,13 +23,9 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4PartialPhantomParameterisation implementation
//
// May 2007 Pedro Arce (CIEMAT), first version
//
// --------------------------------------------------------------------
#include "G4PartialPhantomParameterisation.hh"
@@ -58,7 +54,7 @@ G4PartialPhantomParameterisation::~G4PartialPhantomParameterisation()
//------------------------------------------------------------------
void G4PartialPhantomParameterisation::
ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol ) const
ComputeTransformation( const G4int copyNo, G4VPhysicalVolume *physVol ) const
{
// Voxels cannot be rotated, return translation
//
@@ -73,9 +69,7 @@ GetTranslation(const G4int copyNo ) const
{
CheckCopyNo( copyNo );
size_t nx;
size_t ny;
size_t nz;
size_t nx, ny, nz;
ComputeVoxelIndices( copyNo, nx, ny, nz );
G4ThreeVector trans( (2*nx+1)*fVoxelHalfX - fContainerWallX,
@@ -87,10 +81,10 @@ GetTranslation(const G4int copyNo ) const
//------------------------------------------------------------------
G4Material* G4PartialPhantomParameterisation::
ComputeMaterial(const G4int copyNo, G4VPhysicalVolume *, const G4VTouchable *)
ComputeMaterial( const G4int copyNo, G4VPhysicalVolume*, const G4VTouchable* )
{
CheckCopyNo( copyNo );
size_t matIndex = GetMaterialIndex(copyNo);
auto matIndex = GetMaterialIndex(copyNo);
return fMaterials[ matIndex ];
}
@@ -102,7 +96,7 @@ GetMaterialIndex( size_t copyNo ) const
{
CheckCopyNo( copyNo );
if( !fMaterialIndices ) { return 0; }
if( fMaterialIndices == nullptr ) { return 0; }
return *(fMaterialIndices+copyNo);
}
@@ -140,18 +134,20 @@ ComputeVoxelIndices(const G4int copyNo, size_t& nx,
{
CheckCopyNo( copyNo );
std::multimap<G4int,G4int>::const_iterator ite =
fFilledIDs.lower_bound(size_t(copyNo));
G4int dist = std::distance( fFilledIDs.begin(), ite );
nz = size_t(dist/fNoVoxelY);
auto ite = fFilledIDs.lower_bound(size_t(copyNo));
G4int dist = std::distance( fFilledIDs.cbegin(), ite );
nz = size_t( dist/fNoVoxelY );
ny = size_t( dist%fNoVoxelY );
G4int ifmin = (*ite).second;
G4int nvoxXprev;
if( dist != 0 ) {
if( dist != 0 )
{
ite--;
nvoxXprev = (*ite).first;
} else {
}
else
{
nvoxXprev = -1;
}
@@ -294,18 +290,17 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
}
G4int nyz = nz*fNoVoxelY+ny;
std::multimap<G4int,G4int>::iterator ite = fFilledIDs.begin();
auto ite = fFilledIDs.cbegin();
/*
for( ite = fFilledIDs.begin(); ite != fFilledIDs.end(); ite++ )
for( ite = fFilledIDs.cbegin(); ite != fFilledIDs.cend(); ++ite )
{
G4cout << " G4PartialPhantomParameterisation::GetReplicaNo filled "
<< (*ite).first << " , " << (*ite).second << std::endl;
}
*/
ite = fFilledIDs.begin();
advance(ite,nyz);
std::multimap<G4int,G4int>::iterator iteant = ite; iteant--;
auto iteant = ite; iteant--;
G4int copyNo = (*iteant).first + 1 + ( nx - (*ite).second );
/*
G4cout << " G4PartialPhantomParameterisation::GetReplicaNo getting copyNo "
File diff suppressed because it is too large Load Diff
+13 -25
View File
@@ -23,12 +23,9 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// GEANT4 tag $ Name:$
//
// class G4PhantomParameterisation implementation
//
// May 2007 Pedro Arce, first version
// May 2007 Pedro Arce, first version
//
// --------------------------------------------------------------------
@@ -43,11 +40,6 @@
//------------------------------------------------------------------
G4PhantomParameterisation::G4PhantomParameterisation()
: fVoxelHalfX(0.), fVoxelHalfY(0.), fVoxelHalfZ(0.),
fNoVoxelX(0), fNoVoxelY(0), fNoVoxelZ(0), fNoVoxelXY(0), fNoVoxel(0),
fMaterialIndices(0), fContainerSolid(0),
fContainerWallX(0.), fContainerWallY(0.), fContainerWallZ(0.),
bSkipEqualMaterials(true)
{
kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
}
@@ -61,7 +53,7 @@ G4PhantomParameterisation::~G4PhantomParameterisation()
//------------------------------------------------------------------
void G4PhantomParameterisation::
BuildContainerSolid( G4VPhysicalVolume *pMotherPhysical )
BuildContainerSolid( G4VPhysicalVolume* pMotherPhysical )
{
fContainerSolid = pMotherPhysical->GetLogicalVolume()->GetSolid();
fContainerWallX = fNoVoxelX * fVoxelHalfX;
@@ -73,7 +65,7 @@ BuildContainerSolid( G4VPhysicalVolume *pMotherPhysical )
//------------------------------------------------------------------
void G4PhantomParameterisation::
BuildContainerSolid( G4VSolid *pMotherSolid )
BuildContainerSolid( G4VSolid* pMotherSolid )
{
fContainerSolid = pMotherSolid;
fContainerWallX = fNoVoxelX * fVoxelHalfX;
@@ -86,7 +78,7 @@ BuildContainerSolid( G4VSolid *pMotherSolid )
//------------------------------------------------------------------
void G4PhantomParameterisation::
ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol ) const
ComputeTransformation(const G4int copyNo, G4VPhysicalVolume* physVol ) const
{
// Voxels cannot be rotated, return translation
//
@@ -117,7 +109,7 @@ GetTranslation(const G4int copyNo ) const
//------------------------------------------------------------------
G4VSolid* G4PhantomParameterisation::
ComputeSolid(const G4int, G4VPhysicalVolume *pPhysicalVol)
ComputeSolid(const G4int, G4VPhysicalVolume* pPhysicalVol)
{
return pPhysicalVol->GetLogicalVolume()->GetSolid();
}
@@ -140,7 +132,7 @@ GetMaterialIndex( size_t copyNo ) const
{
CheckCopyNo( copyNo );
if( !fMaterialIndices ) { return 0; }
if( fMaterialIndices == nullptr ) { return 0; }
return *(fMaterialIndices+copyNo);
}
@@ -245,7 +237,7 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
<< " Y: " << std::fabs(localPoint.y()) - fContainerWallY
<< " Z: " << std::fabs(localPoint.z()) - fContainerWallZ;
G4Exception("G4PhantomParameterisation::GetReplicaNo()", "GeomNav0003",
JustWarning, message);
FatalErrorInArgument, message);
}
// Check the voxel numbers corresponding to localPoint
@@ -260,13 +252,13 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
// Add +kCarTolerance so that they are first placed on voxel N, and then
// if the direction is negative substract 1
G4double fx = (localPoint.x()+fContainerWallX)/(fVoxelHalfX*2.);
G4double fx = (localPoint.x()+fContainerWallX+kCarTolerance)/(fVoxelHalfX*2.);
G4int nx = G4int(fx);
G4double fy = (localPoint.y()+fContainerWallY)/(fVoxelHalfY*2.);
G4double fy = (localPoint.y()+fContainerWallY+kCarTolerance)/(fVoxelHalfY*2.);
G4int ny = G4int(fy);
G4double fz = (localPoint.z()+fContainerWallZ)/(fVoxelHalfZ*2.);
G4double fz = (localPoint.z()+fContainerWallZ+kCarTolerance)/(fVoxelHalfZ*2.);
G4int nz = G4int(fz);
// If it is on the surface side, check the direction: if direction is
@@ -276,7 +268,7 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
// due to multiple scattering: track is entering a voxel but multiple
// scattering changes the angle towards outside
//
if( fx - nx < kCarTolerance*fContainerWallX )
if( fx - nx < kCarTolerance*fVoxelHalfX )
{
if( localDir.x() < 0 )
{
@@ -293,7 +285,7 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
}
}
}
if( fy - ny < kCarTolerance*fContainerWallY )
if( fy - ny < kCarTolerance*fVoxelHalfY )
{
if( localDir.y() < 0 )
{
@@ -310,7 +302,7 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
}
}
}
if( fz - nz < kCarTolerance*fContainerWallZ )
if( fz - nz < kCarTolerance*fVoxelHalfZ )
{
if( localDir.z() < 0 )
{
@@ -380,10 +372,6 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
copyNo = nx + fNoVoxelX*ny + fNoVoxelXY*nz;
}
// CheckCopyNo( copyNo ); // not needed, just for debugging code
// G4cout << " COPYNO " << copyNo << " " << nx << " " << ny << " " << nz
// << G4endl; //GDEB
return copyNo;
}
@@ -23,9 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// GEANT4 tag $ Name: $
//
// class G4PropagatorInField Implementation
//
// This class implements an algorithm to track a particle in a
@@ -34,9 +31,8 @@
// until the particle has traveled a set distance or it enters a new
// volume.
//
// 14.10.96 John Apostolakis, design and implementation
// 17.03.97 John Apostolakis, renaming new set functions being added
//
// 14.10.96 John Apostolakis, design and implementation
// 17.03.97 John Apostolakis, renaming new set functions being added
// ---------------------------------------------------------------------------
#include <iomanip>
@@ -45,6 +41,7 @@
#include "G4ios.hh"
#include "G4SystemOfUnits.hh"
#include "G4ThreeVector.hh"
#include "G4Material.hh"
#include "G4VPhysicalVolume.hh"
#include "G4Navigator.hh"
#include "G4GeometryTolerance.hh"
@@ -52,83 +49,62 @@
#include "G4ChordFinder.hh"
#include "G4MultiLevelLocator.hh"
///////////////////////////////////////////////////////////////////////////
//
// ---------------------------------------------------------------------------
// Constructors and destructor
G4PropagatorInField::G4PropagatorInField( G4Navigator *theNavigator,
G4FieldManager *detectorFieldMgr,
G4VIntersectionLocator *vLocator )
:
fMax_loop_count(1000),
fUseSafetyForOptimisation(true), // (false) is less sensitive to incorrect safety
fZeroStepThreshold( 0.0 ), // length of what is recognised as 'zero' step
fDetectorFieldMgr(detectorFieldMgr),
fpTrajectoryFilter( 0 ),
//
G4PropagatorInField::G4PropagatorInField( G4Navigator* theNavigator,
G4FieldManager* detectorFieldMgr,
G4VIntersectionLocator* vLocator )
: fDetectorFieldMgr(detectorFieldMgr),
fNavigator(theNavigator),
fCurrentFieldMgr(detectorFieldMgr),
fSetFieldMgr(false),
End_PointAndTangent(G4ThreeVector(0.,0.,0.),
G4ThreeVector(0.,0.,0.),0.0,0.0,0.0,0.0,0.0),
fParticleIsLooping(false),
fNoZeroStep(0),
fVerboseLevel(0),
fVerbTracePiF(false),
fFirstStepInVolume(true),
fLastStepInVolume(true),
fNewTrack(true)
G4ThreeVector(0.,0.,0.),0.0,0.0,0.0,0.0,0.0)
{
if(fDetectorFieldMgr) { fEpsilonStep = fDetectorFieldMgr->GetMaximumEpsilonStep();}
else { fEpsilonStep= 1.0e-5; }
fActionThreshold_NoZeroSteps = 2;
fSevereActionThreshold_NoZeroSteps = 10;
fAbandonThreshold_NoZeroSteps = 50;
fFull_CurveLen_of_LastAttempt = -1;
fLast_ProposedStepLength = -1;
fEpsilonStep = (fDetectorFieldMgr != nullptr)
? fDetectorFieldMgr->GetMaximumEpsilonStep() : 1.0e-5;
fLargestAcceptableStep = 1000.0 * meter;
fPreviousSftOrigin= G4ThreeVector(0.,0.,0.);
fPreviousSafety= 0.0;
fPreviousSftOrigin = G4ThreeVector(0.,0.,0.);
kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
fZeroStepThreshold= std::max( 1.0e5 * kCarTolerance, 1.0e-1 * micrometer );
fZeroStepThreshold = std::max( 1.0e5 * kCarTolerance, 1.0e-1 * micrometer );
#ifdef G4DEBUG_FIELD
G4cout << " PiF: Zero Step Threshold set to "
<< fZeroStepThreshold / millimeter
<< " mm." << G4endl;
<< " mm." << G4endl;
G4cout << " PiF: Value of kCarTolerance = "
<< kCarTolerance / millimeter
<< " mm. " << G4endl;
<< " mm. " << G4endl;
fVerboseLevel = 2;
fVerbTracePiF = true;
#endif
// Defining Intersection Locator and his parameters
if (vLocator==0)
if ( vLocator == nullptr )
{
fIntersectionLocator= new G4MultiLevelLocator(theNavigator);
fAllocatedLocator= true;
fIntersectionLocator = new G4MultiLevelLocator(theNavigator);
fAllocatedLocator = true;
}
else
{
fIntersectionLocator= vLocator;
fAllocatedLocator= false;
fIntersectionLocator = vLocator;
fAllocatedLocator = false;
}
RefreshIntersectionLocator(); // Copy all relevant parameters
}
///////////////////////////////////////////////////////////////////////////
// ---------------------------------------------------------------------------
//
G4PropagatorInField::~G4PropagatorInField()
{
if(fAllocatedLocator) { delete fIntersectionLocator; }
}
///////////////////////////////////////////////////////////////////////////
//
// ---------------------------------------------------------------------------
// Update the IntersectionLocator with current parameters
void
G4PropagatorInField::RefreshIntersectionLocator()
//
void G4PropagatorInField::RefreshIntersectionLocator()
{
fIntersectionLocator->SetEpsilonStepFor(fEpsilonStep);
fIntersectionLocator->SetDeltaIntersectionFor(fCurrentFieldMgr->GetDeltaIntersection());
@@ -136,24 +112,24 @@ G4PropagatorInField::RefreshIntersectionLocator()
fIntersectionLocator->SetSafetyParametersFor( fUseSafetyForOptimisation);
}
///////////////////////////////////////////////////////////////////////////
//
// ---------------------------------------------------------------------------
// Compute the next geometric Step
G4double
G4PropagatorInField::ComputeStep(
//
G4double G4PropagatorInField::ComputeStep(
G4FieldTrack& pFieldTrack,
G4double CurrentProposedStepLength,
G4double& currentSafety, // IN/OUT
G4VPhysicalVolume* pPhysVol)
G4VPhysicalVolume* pPhysVol,
G4bool canRelaxDeltaChord)
{
GetChordFinder()->OnComputeStep();
const G4double deltaChord = GetChordFinder()->GetDeltaChord();
// If CurrentProposedStepLength is too small for finding Chords
// then return with no action (for now - TODO: some action)
//
const char* methodName="G4PropagatorInField::ComputeStep";
if(CurrentProposedStepLength<kCarTolerance)
const char* methodName = "G4PropagatorInField::ComputeStep";
if (CurrentProposedStepLength<kCarTolerance)
{
return kInfinity;
}
@@ -166,8 +142,8 @@ G4PropagatorInField::ComputeStep(
}
fFirstStepInVolume = fNewTrack ? true : fLastStepInVolume;
fLastStepInVolume= false;
fNewTrack= false;
fLastStepInVolume = false;
fNewTrack = false;
if( fVerboseLevel > 2 )
{
@@ -184,29 +160,31 @@ G4PropagatorInField::ComputeStep(
// Parameters for adaptive Runge-Kutta integration
G4double h_TrialStepSize; // 1st Step Size
G4double TruePathLength = CurrentProposedStepLength;
G4double StepTaken = 0.0;
G4double s_length_taken, epsilon ;
G4bool intersects;
G4bool first_substep = true;
G4double h_TrialStepSize; // 1st Step Size
G4double TruePathLength = CurrentProposedStepLength;
G4double StepTaken = 0.0;
G4double s_length_taken, epsilon;
G4bool intersects;
G4bool first_substep = true;
G4double NewSafety;
G4double NewSafety;
fParticleIsLooping = false;
// If not yet done,
// Set the field manager to the local one if the volume has one,
// or to the global one if not
//
if( !fSetFieldMgr ) fCurrentFieldMgr= FindAndSetFieldManager( pPhysVol );
// For the next call, the field manager must again be set
fSetFieldMgr= false;
if( !fSetFieldMgr )
{
fCurrentFieldMgr = FindAndSetFieldManager( pPhysVol );
}
fSetFieldMgr = false; // For next call, the field manager must be set again
G4FieldTrack CurrentState(pFieldTrack);
G4FieldTrack OriginalState = CurrentState;
G4FieldTrack CurrentState(pFieldTrack);
G4FieldTrack OriginalState = CurrentState;
// If the Step length is "infinite", then an approximate-maximum Step
// length (used to calculate the relative accuracy) must be guessed.
// length (used to calculate the relative accuracy) must be guessed
//
if( CurrentProposedStepLength >= fLargestAcceptableStep )
{
@@ -217,35 +195,31 @@ G4PropagatorInField::ComputeStep(
G4double trialProposedStep = 1.e2 * ( 10.0 * cm +
fNavigator->GetWorldVolume()->GetLogicalVolume()->
GetSolid()->DistanceToOut(StartPointA, VelocityUnit) );
CurrentProposedStepLength= std::min( trialProposedStep,
fLargestAcceptableStep );
CurrentProposedStepLength = std::min( trialProposedStep,
fLargestAcceptableStep );
}
epsilon = fCurrentFieldMgr->GetDeltaOneStep() / CurrentProposedStepLength;
// G4double raw_epsilon= epsilon;
G4double epsilonMin= fCurrentFieldMgr->GetMinimumEpsilonStep();
G4double epsilonMax= fCurrentFieldMgr->GetMaximumEpsilonStep();
if( epsilon < epsilonMin ) epsilon = epsilonMin;
if( epsilon > epsilonMax ) epsilon = epsilonMax;
if( epsilon < epsilonMin ) { epsilon = epsilonMin; }
if( epsilon > epsilonMax ) { epsilon = epsilonMax; }
SetEpsilonStep( epsilon );
// Values for Intersection Locator has to be updated on each call for the
// case that CurrentFieldManager has changed from the one of previous step
//
RefreshIntersectionLocator();
// G4cout << "G4PiF: Epsilon of current step - raw= " << raw_epsilon
// << " final= " << epsilon << G4endl;
// Shorten the proposed step in case of earlier problems (zero steps)
// Shorten the proposed step in case of earlier problems (zero steps)
//
if( fNoZeroStep > fActionThreshold_NoZeroSteps )
{
G4double stepTrial;
stepTrial= fFull_CurveLen_of_LastAttempt;
stepTrial = fFull_CurveLen_of_LastAttempt;
if( (stepTrial <= 0.0) && (fLast_ProposedStepLength > 0.0) )
{
stepTrial= fLast_ProposedStepLength;
stepTrial = fLast_ProposedStepLength;
}
G4double decreaseFactor = 0.9; // Unused default
@@ -260,7 +234,7 @@ G4PropagatorInField::ComputeStep(
{
// 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.
// Careful decreases to cope with tolerance are required
//
if( stepTrial > 100.0*fZeroStepThreshold )
decreaseFactor = 0.35; // Try decreasing slower
@@ -275,8 +249,7 @@ G4PropagatorInField::ComputeStep(
#ifdef G4DEBUG_FIELD
if( fVerboseLevel > 2
|| (fNoZeroStep >= fSevereActionThreshold_NoZeroSteps)
)
|| (fNoZeroStep >= fSevereActionThreshold_NoZeroSteps) )
{
G4cerr << " " << methodName
<< " Decreasing step after " << fNoZeroStep << " zero steps "
@@ -300,7 +273,7 @@ G4PropagatorInField::ComputeStep(
<< " while attempting to progress after " << fNoZeroStep
<< " trial steps. Will abandon step.";
G4Exception(methodName, "GeomNav1002", JustWarning, message);
fParticleIsLooping= true;
fParticleIsLooping = true;
return 0; // = stepTrial;
}
if( stepTrial < CurrentProposedStepLength )
@@ -311,7 +284,7 @@ G4PropagatorInField::ComputeStep(
fLast_ProposedStepLength = CurrentProposedStepLength;
G4int do_loop_count = 0;
do // Loop checking, 07.10.2016, J.Apostolakis
do // Loop checking, 07.10.2016, JA
{
G4FieldTrack SubStepStartState = CurrentState;
G4ThreeVector SubStartPoint = CurrentState.GetPosition();
@@ -330,6 +303,16 @@ G4PropagatorInField::ComputeStep(
//
h_TrialStepSize = CurrentProposedStepLength - StepTaken;
if (canRelaxDeltaChord &&
fIncreaseChordDistanceThreshold > 0 &&
do_loop_count > fIncreaseChordDistanceThreshold &&
do_loop_count % fIncreaseChordDistanceThreshold == 0)
{
GetChordFinder()->SetDeltaChord(
GetChordFinder()->GetDeltaChord() * 2.0
);
}
// Integrate as far as "chord miss" rule allows.
//
s_length_taken = GetChordFinder()->AdvanceChordLimited(
@@ -337,22 +320,22 @@ G4PropagatorInField::ComputeStep(
h_TrialStepSize,
fEpsilonStep,
fPreviousSftOrigin,
fPreviousSafety
);
// CurrentState is now updated with the final position and velocity.
fPreviousSafety );
// CurrentState is now updated with the final position and velocity
fFull_CurveLen_of_LastAttempt = s_length_taken;
G4ThreeVector EndPointB = CurrentState.GetPosition();
G4ThreeVector InterSectionPointE;
G4double LinearStepLength;
G4ThreeVector EndPointB = CurrentState.GetPosition();
G4ThreeVector InterSectionPointE;
G4double LinearStepLength;
// Intersect chord AB with geometry
//
intersects= IntersectChord( SubStartPoint, EndPointB,
NewSafety, LinearStepLength,
NewSafety, LinearStepLength,
InterSectionPointE );
// E <- Intersection Point of chord AB and either volume A's surface
// or a daughter volume's surface ..
// E <- Intersection Point of chord AB and either volume A's surface
// or a daughter volume's surface ..
if( first_substep )
{
@@ -365,7 +348,7 @@ G4PropagatorInField::ComputeStep(
// Find the intersection point of AB true path with the surface
// of vol(A), if it exists. Start with point E as first "estimate".
G4bool recalculatedEndPt= false;
G4bool recalculatedEndPt = false;
G4bool found_intersection = fIntersectionLocator->
EstimateIntersectionPoint( SubStepStartState, CurrentState,
@@ -377,7 +360,7 @@ G4PropagatorInField::ComputeStep(
{
End_PointAndTangent= IntersectPointVelct_G; // G is our EndPoint ...
StepTaken = TruePathLength = IntersectPointVelct_G.GetCurveLength()
- OriginalState.GetCurveLength();
- OriginalState.GetCurveLength();
}
else
{
@@ -399,7 +382,7 @@ G4PropagatorInField::ComputeStep(
// Update remaining state - must work for 'full' step or
// abandonned intersection
//
CurrentState= IntersectPointVelct_G;
CurrentState = IntersectPointVelct_G;
s_length_taken = stepAchieved;
if( shortEnd )
{
@@ -428,8 +411,8 @@ G4PropagatorInField::ComputeStep(
G4cout << " Above 'action' threshold -- for Zero steps. ";
G4cout << " Number of zero steps = " << fNoZeroStep << G4endl;
printStatus( SubStepStartState, // or OriginalState,
CurrentState, CurrentProposedStepLength,
NewSafety, do_loop_count, pPhysVol );
CurrentState, CurrentProposedStepLength,
NewSafety, do_loop_count, pPhysVol );
}
if( (fVerboseLevel > 1) && (do_loop_count > fMax_loop_count-10 ))
{
@@ -445,7 +428,7 @@ G4PropagatorInField::ComputeStep(
}
#endif
do_loop_count++;
++do_loop_count;
} while( (!intersects )
&& (!fParticleIsLooping)
@@ -453,8 +436,7 @@ G4PropagatorInField::ComputeStep(
&& ( do_loop_count < fMax_loop_count ) );
if( do_loop_count >= fMax_loop_count
&& (StepTaken + kCarTolerance < CurrentProposedStepLength)
)
&& (StepTaken + kCarTolerance < CurrentProposedStepLength) )
{
fParticleIsLooping = true;
}
@@ -472,6 +454,7 @@ G4PropagatorInField::ComputeStep(
//
End_PointAndTangent = CurrentState;
TruePathLength = StepTaken; // Original code
// Tried the following to avoid potential issue with round-off error
// - but has issues... Suppressing this change JA 2015/05/02
// TruePathLength = CurrentProposedStepLength;
@@ -515,7 +498,7 @@ G4PropagatorInField::ComputeStep(
//
if( TruePathLength < std::max( fZeroStepThreshold, 0.5*kCarTolerance ) )
{
fNoZeroStep++;
++fNoZeroStep;
}
else
{
@@ -525,27 +508,27 @@ G4PropagatorInField::ComputeStep(
if( fNoZeroStep > fAbandonThreshold_NoZeroSteps )
{
fParticleIsLooping = true;
ReportStuckParticle( fNoZeroStep, CurrentProposedStepLength, fFull_CurveLen_of_LastAttempt,
pPhysVol );
ReportStuckParticle( fNoZeroStep, CurrentProposedStepLength,
fFull_CurveLen_of_LastAttempt, pPhysVol );
fNoZeroStep = 0;
}
GetChordFinder()->SetDeltaChord(deltaChord);
return TruePathLength;
}
///////////////////////////////////////////////////////////////////////////
// ---------------------------------------------------------------------------
// Dumps status of propagator
//
// Dumps status of propagator.
void
G4PropagatorInField::printStatus( const G4FieldTrack& StartFT,
const G4FieldTrack& CurrentFT,
G4double requestStep,
G4double safety,
G4int stepNo,
G4VPhysicalVolume* startVolume)
G4PropagatorInField::printStatus( const G4FieldTrack& StartFT,
const G4FieldTrack& CurrentFT,
G4double requestStep,
G4double safety,
G4int stepNo,
G4VPhysicalVolume* startVolume)
{
const G4int verboseLevel=fVerboseLevel;
const G4int verboseLevel = fVerboseLevel;
const G4ThreeVector StartPosition = StartFT.GetPosition();
const G4ThreeVector StartUnitVelocity = StartFT.GetMomentumDir();
const G4ThreeVector CurrentPosition = CurrentFT.GetPosition();
@@ -558,9 +541,6 @@ G4PropagatorInField::printStatus( const G4FieldTrack& StartFT,
if( ((stepNo == 0) && (verboseLevel <3)) || (verboseLevel >= 3) )
{
oldprec = G4cout.precision(4);
// G4cout << std::setw( 6) << " "
// << std::setw( 25) << " Current Position and Direction" << " "
// << G4endl;
G4cout << std::setw( 5) << "Step#"
<< std::setw(10) << " s " << " "
<< std::setw(10) << "X(mm)" << " "
@@ -573,7 +553,7 @@ G4PropagatorInField::printStatus( const G4FieldTrack& StartFT,
<< std::setw( 9) << "StepLen" << " "
<< std::setw(12) << "StartSafety" << " "
<< std::setw( 9) << "PhsStep" << " ";
if( startVolume )
if( startVolume != nullptr )
{ G4cout << std::setw(18) << "NextVolume" << " "; }
G4cout.precision(oldprec);
G4cout << G4endl;
@@ -627,10 +607,9 @@ G4PropagatorInField::printStatus( const G4FieldTrack& StartFT,
}
}
///////////////////////////////////////////////////////////////////////////
//
// ---------------------------------------------------------------------------
// Prints Step diagnostics
//
void
G4PropagatorInField::PrintStepLengthDiagnostic(
G4double CurrentProposedStepLength,
@@ -654,8 +633,7 @@ G4PropagatorInField::PrintStepLengthDiagnostic(
<< " " << std::setw(18) << decreaseFactor
<< " " << std::setw(15) << stepTrial
<< G4endl;
G4cout.precision( iprec );
G4cout.precision( iprec );
}
// Access the points which have passed through the filter. The
@@ -673,17 +651,17 @@ G4PropagatorInField::GimmeTrajectoryVectorAndForgetIt() const
// NB, GimmeThePointsAndForgetThem really forgets them, so it can
// only be called (exactly) once for each step.
if (fpTrajectoryFilter)
if (fpTrajectoryFilter != nullptr)
{
return fpTrajectoryFilter->GimmeThePointsAndForgetThem();
}
else
{
return 0;
return nullptr;
}
}
///////////////////////////////////////////////////////////////////////////
// ---------------------------------------------------------------------------
//
void
G4PropagatorInField::SetTrajectoryFilter(G4VCurvedTrajectoryFilter* filter)
@@ -691,12 +669,14 @@ G4PropagatorInField::SetTrajectoryFilter(G4VCurvedTrajectoryFilter* filter)
fpTrajectoryFilter = filter;
}
// ---------------------------------------------------------------------------
//
void G4PropagatorInField::ClearPropagatorState()
{
// Goal: Clear all memory of previous steps, cached information
fParticleIsLooping= false;
fNoZeroStep= 0;
fParticleIsLooping = false;
fNoZeroStep = 0;
End_PointAndTangent= G4FieldTrack( G4ThreeVector(0.,0.,0.),
G4ThreeVector(0.,0.,0.),
@@ -708,91 +688,106 @@ void G4PropagatorInField::ClearPropagatorState()
fPreviousSafety= 0.0;
}
// ---------------------------------------------------------------------------
//
G4FieldManager* G4PropagatorInField::
FindAndSetFieldManager( G4VPhysicalVolume* pCurrentPhysicalVolume)
FindAndSetFieldManager( G4VPhysicalVolume* pCurrentPhysicalVolume )
{
G4FieldManager* currentFieldMgr;
currentFieldMgr = fDetectorFieldMgr;
if( pCurrentPhysicalVolume)
if( pCurrentPhysicalVolume != nullptr )
{
G4FieldManager *pRegionFieldMgr= 0, *localFieldMgr = 0;
G4LogicalVolume* pLogicalVol= pCurrentPhysicalVolume->GetLogicalVolume();
G4FieldManager *pRegionFieldMgr = nullptr, *localFieldMgr = nullptr;
G4LogicalVolume* pLogicalVol = pCurrentPhysicalVolume->GetLogicalVolume();
if( pLogicalVol ) {
// Value for Region, if any, Overrides
G4Region* pRegion= pLogicalVol->GetRegion();
if( pRegion ) {
pRegionFieldMgr= pRegion->GetFieldManager();
if( pRegionFieldMgr )
currentFieldMgr= pRegionFieldMgr;
}
if( pLogicalVol != nullptr )
{
// Value for Region, if any, overrides
//
G4Region* pRegion = pLogicalVol->GetRegion();
if( pRegion != nullptr )
{
pRegionFieldMgr = pRegion->GetFieldManager();
if( pRegionFieldMgr != nullptr )
{
currentFieldMgr= pRegionFieldMgr;
}
}
// 'Local' Value from logical volume, if any, Overrides
localFieldMgr= pLogicalVol->GetFieldManager();
if ( localFieldMgr )
currentFieldMgr = localFieldMgr;
// 'Local' Value from logical volume, if any, overrides
//
localFieldMgr = pLogicalVol->GetFieldManager();
if ( localFieldMgr != nullptr )
{
currentFieldMgr = localFieldMgr;
}
}
}
fCurrentFieldMgr= currentFieldMgr;
fCurrentFieldMgr = currentFieldMgr;
// Flag that field manager has been set
//
fSetFieldMgr= true;
fSetFieldMgr = true;
return currentFieldMgr;
}
// ---------------------------------------------------------------------------
//
G4int G4PropagatorInField::SetVerboseLevel( G4int level )
{
G4int oldval= fVerboseLevel;
fVerboseLevel= level;
G4int oldval = fVerboseLevel;
fVerboseLevel = level;
// Forward the verbose level 'reduced' to ChordFinder,
// MagIntegratorDriver ... ?
//
auto integrDriver= GetChordFinder()->GetIntegrationDriver();
auto integrDriver = GetChordFinder()->GetIntegrationDriver();
integrDriver->SetVerboseLevel( fVerboseLevel - 2 );
G4cout << "Set Driver verbosity to " << fVerboseLevel - 2 << G4endl;
return oldval;
}
#include "G4Material.hh"
void G4PropagatorInField::ReportLoopingParticle( G4int count,
G4double StepTaken,
G4double StepRequested,
const char* methodName,
G4ThreeVector momentumVec,
G4VPhysicalVolume* pPhysVol)
// ---------------------------------------------------------------------------
//
void G4PropagatorInField::ReportLoopingParticle( G4int count,
G4double StepTaken,
G4double StepRequested,
const char* methodName,
G4ThreeVector momentumVec,
G4VPhysicalVolume* pPhysVol )
{
std::ostringstream message;
G4double fraction = StepTaken / StepRequested;
message << " Unfinished integration of track (likely looping particle) "
<< " of momentum " << momentumVec << " ( magnitude = " << momentumVec.mag() << " ) "
<< G4endl
<< " of momentum " << momentumVec << " ( magnitude = "
<< momentumVec.mag() << " ) " << G4endl
<< " after " << count << " field substeps "
<< " totaling " << std::setprecision(12) << StepTaken / mm << " mm "
<< " out of requested step " << std::setprecision(12) << StepRequested / mm << " mm ";
<< " out of requested step " << std::setprecision(12)
<< StepRequested / mm << " mm ";
message << " a fraction of ";
int prec= 4;
if( fraction > 0.99 )
prec= 7;
G4int prec = 4;
if( fraction > 0.99 )
{
prec = 7;
}
else
if (fraction > 0.97 )
prec= 5;
{
if (fraction > 0.97 ) { prec = 5; }
}
message << std::setprecision(prec)
<< 100. * StepTaken / StepRequested << " % " << G4endl ;
if( pPhysVol )
{
message << " in volume " << pPhysVol->GetName() ;
auto material= pPhysVol->GetLogicalVolume()->GetMaterial();
if( material )
auto material = pPhysVol->GetLogicalVolume()->GetMaterial();
if( material != nullptr )
message << " with material " << material->GetName()
<< " ( density = "
<< material->GetDensity() / ( gram / ( centimeter * centimeter * centimeter ) )
<< " g / cm^3 ) ";
<< material->GetDensity() / ( g/(cm*cm*cm) ) << " g / cm^3 ) ";
}
else
{
@@ -801,18 +796,20 @@ void G4PropagatorInField::ReportLoopingParticle( G4int count,
G4Exception(methodName, "GeomNav1002", JustWarning, message);
}
void G4PropagatorInField::ReportStuckParticle( G4int noZeroSteps,
G4double proposedStep,
G4double lastTriedStep,
// ---------------------------------------------------------------------------
//
void G4PropagatorInField::ReportStuckParticle( G4int noZeroSteps,
G4double proposedStep,
G4double lastTriedStep,
G4VPhysicalVolume* physVol )
{
std::ostringstream message;
message << "Particle is stuck; it will be killed." << G4endl
<< " Zero progress for " << noZeroSteps << " attempted steps."
<< " Zero progress for " << noZeroSteps << " attempted steps."
<< G4endl
<< " Proposed Step is " << proposedStep
<< " but Step Taken is "<< lastTriedStep << G4endl;
if( physVol )
if( physVol != nullptr )
message << " in volume " << physVol->GetName() ;
else
message << " in unknown or null volume. " ;
+6 -11
View File
@@ -23,13 +23,9 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// GEANT4 tag $ Name:$
//
// class G4RegularNavigation implementation
//
// Author: Pedro Arce, May 2007
//
// --------------------------------------------------------------------
#include "G4RegularNavigation.hh"
@@ -43,7 +39,6 @@
//------------------------------------------------------------------
G4RegularNavigation::G4RegularNavigation()
: fverbose(false), fcheck(false), fnormalNav(0)
{
kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
}
@@ -160,8 +155,8 @@ G4double G4RegularNavigation::ComputeStepSkippingEqualMaterials(
// param container volume
//
G4int ide = history.GetDepth();
G4ThreeVector containerPoint = history.GetTransform(ide).InverseTransformPoint(localPoint);
G4ThreeVector containerPoint = history.GetTransform(ide)
.InverseTransformPoint(localPoint);
// Point in global frame
//
containerPoint = history.GetTransform(ide).InverseTransformPoint(localPoint);
@@ -185,7 +180,7 @@ G4double G4RegularNavigation::ComputeStepSkippingEqualMaterials(
G4int copyNo = param->GetReplicaNo(containerPoint,localDirection);
G4Material* currentMate = param->ComputeMaterial( copyNo, 0, 0 );
G4Material* currentMate = param->ComputeMaterial( copyNo, nullptr, nullptr );
G4VSolid* voxelBox = pCurrentPhysical->GetLogicalVolume()->GetSolid();
G4VSolid* containerSolid = param->GetContainerSolid();
@@ -238,10 +233,9 @@ G4double G4RegularNavigation::ComputeStepSkippingEqualMaterials(
// Get copyNo and translation of new voxel
//
copyNo = param->GetReplicaNo(containerPoint,localDirection);
copyNo = param->GetReplicaNo(containerPoint, localDirection);
G4ThreeVector voxelTranslation = param->GetTranslation( copyNo );
// G4cout << " copyNo " << copyNo << " = " << pCurrentPhysical->GetCopyNo() << G4endl;
// Move local point until wall of voxel and then put it in the new voxel
// local coordinates
//
@@ -251,7 +245,8 @@ G4double G4RegularNavigation::ComputeStepSkippingEqualMaterials(
prevVoxelTranslation = voxelTranslation;
// Check if material of next voxel is the same as that of the current voxel
nextMate = param->ComputeMaterial( copyNo, 0, 0 );
//
nextMate = param->ComputeMaterial( copyNo, nullptr, nullptr );
if( currentMate != nextMate ) { break; }
}
@@ -23,27 +23,17 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// GEANT4 tag $ Name:$
//
// class G4RegularNavigationHelper implementation
//
// Author: Pedro Arce, November 2008
//
// --------------------------------------------------------------------
#include "G4RegularNavigationHelper.hh"
G4ThreadLocal G4RegularNavigationHelper*
G4RegularNavigationHelper::theInstance = 0;
G4RegularNavigationHelper* G4RegularNavigationHelper::Instance()
{
if(!theInstance)
{
theInstance = new G4RegularNavigationHelper;
}
return theInstance;
static G4ThreadLocalSingleton<G4RegularNavigationHelper> theInstance;
return theInstance.Instance();
}
// --------------------------------------------------------------------
@@ -56,7 +46,6 @@ G4RegularNavigationHelper::G4RegularNavigationHelper()
//
G4RegularNavigationHelper::~G4RegularNavigationHelper()
{
if (theInstance) { delete theInstance; theInstance=0; }
}
// --------------------------------------------------------------------
@@ -75,7 +64,8 @@ void G4RegularNavigationHelper::AddStepLength( G4int copyNo, G4double slen )
// --------------------------------------------------------------------
//
const std::vector< std::pair<G4int,G4double> > & G4RegularNavigationHelper::GetStepLengths()
const std::vector< std::pair<G4int,G4double> > &
G4RegularNavigationHelper::GetStepLengths()
{
return theStepLengths;
}
@@ -22,9 +22,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4ReplicaNavigation Implementation
//
// Author: P.Kent, 1996
@@ -54,7 +51,6 @@ namespace
// ********************************************************************
//
G4ReplicaNavigation::G4ReplicaNavigation()
: fCheck(false), fVerbose(0)
{
kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
kRadTolerance = G4GeometryTolerance::GetInstance()->GetRadialTolerance();
@@ -78,9 +74,9 @@ G4ReplicaNavigation::~G4ReplicaNavigation()
// ********************************************************************
//
EInside
G4ReplicaNavigation::Inside(const G4VPhysicalVolume *pVol,
G4ReplicaNavigation::Inside(const G4VPhysicalVolume* pVol,
const G4int replicaNo,
const G4ThreeVector &localPoint) const
const G4ThreeVector& localPoint) const
{
EInside in = kOutside;
@@ -184,9 +180,9 @@ G4ReplicaNavigation::Inside(const G4VPhysicalVolume *pVol,
// ********************************************************************
//
G4double
G4ReplicaNavigation::DistanceToOut(const G4VPhysicalVolume *pVol,
G4ReplicaNavigation::DistanceToOut(const G4VPhysicalVolume* pVol,
const G4int replicaNo,
const G4ThreeVector &localPoint) const
const G4ThreeVector& localPoint) const
{
// Replication data
//
@@ -195,7 +191,7 @@ G4ReplicaNavigation::DistanceToOut(const G4VPhysicalVolume *pVol,
G4double width,offset;
G4bool consuming;
G4double safety=0.;
G4double safety = 0.;
G4double safe1,safe2;
G4double coord, rho, rmin, rmax;
@@ -250,10 +246,10 @@ G4ReplicaNavigation::DistanceToOut(const G4VPhysicalVolume *pVol,
// ********************************************************************
//
G4double
G4ReplicaNavigation::DistanceToOut(const G4VPhysicalVolume *pVol,
G4ReplicaNavigation::DistanceToOut(const G4VPhysicalVolume* pVol,
const G4int replicaNo,
const G4ThreeVector &localPoint,
const G4ThreeVector &localDirection,
const G4ThreeVector& localPoint,
const G4ThreeVector& localDirection,
G4ExitNormal& arExitNormal ) const
{
// Replication data
@@ -324,17 +320,17 @@ G4ReplicaNavigation::DistanceToOut(const G4VPhysicalVolume *pVol,
// ********************************************************************
//
G4double
G4ReplicaNavigation::DistanceToOutPhi(const G4ThreeVector &localPoint,
const G4ThreeVector &localDirection,
G4ReplicaNavigation::DistanceToOutPhi(const G4ThreeVector& localPoint,
const G4ThreeVector& localDirection,
const G4double width,
G4ExitNormal& foundNormal ) const
{
// Phi Intersection
// NOTE: width<=pi by definition
//
G4double sinSPhi= -2.0, cosSPhi= -2.0;
G4double sinSPhi = -2.0, cosSPhi = -2.0;
G4double pDistS, pDistE, compS, compE, Dist, dist2, yi;
G4ExitNormal::ESide sidePhi= G4ExitNormal::kNull;
G4ExitNormal::ESide sidePhi = G4ExitNormal::kNull;
G4ThreeVector candidateNormal;
if ( (localPoint.x()!=0.0) || (localPoint.y()!=0.0) )
@@ -455,8 +451,8 @@ G4ReplicaNavigation::DistanceToOutPhi(const G4ThreeVector &localPoint,
{
// Leaving immediately by ending phi
//
Dist = 0;
sidePhi= G4ExitNormal::kEPhi;
Dist = 0.;
sidePhi = G4ExitNormal::kEPhi;
}
}
}
@@ -466,12 +462,12 @@ G4ReplicaNavigation::DistanceToOutPhi(const G4ThreeVector &localPoint,
//
if( (std::fabs(localDirection.phi())<=width*0.5) )
{
Dist= kInfinity;
Dist = kInfinity;
}
else
{
Dist= 0;
sidePhi= G4ExitNormal::kMY;
Dist = 0.;
sidePhi = G4ExitNormal::kMY;
}
}
@@ -498,8 +494,8 @@ G4ReplicaNavigation::DistanceToOutPhi(const G4ThreeVector &localPoint,
// ********************************************************************
//
G4double
G4ReplicaNavigation::DistanceToOutRad(const G4ThreeVector &localPoint,
const G4ThreeVector &localDirection,
G4ReplicaNavigation::DistanceToOutRad(const G4ThreeVector& localPoint,
const G4ThreeVector& localDirection,
const G4double width,
const G4double offset,
const G4int replicaNo,
@@ -550,7 +546,7 @@ G4ReplicaNavigation::DistanceToOutRad(const G4ThreeVector &localPoint,
b = t2/t1;
c = deltaR/t1;
srd = -b+std::sqrt(b*b-c);
sideR= G4ExitNormal::kRMax;
sideR = G4ExitNormal::kRMax;
}
else
{
@@ -558,7 +554,7 @@ G4ReplicaNavigation::DistanceToOutRad(const G4ThreeVector &localPoint,
// perpendicular to) outer radial surface -> leaving immediately
//
srd = 0;
sideR= G4ExitNormal::kRMax;
sideR = G4ExitNormal::kRMax;
}
}
else
@@ -580,7 +576,7 @@ G4ReplicaNavigation::DistanceToOutRad(const G4ThreeVector &localPoint,
srd = (deltaR>halfkRadTolerance) ? -b-std::sqrt(d2) : 0.0;
// Is the following more accurate ?
// srd = (deltaR>halfkRadTolerance) ? c/( -b - std::sqrt(d2)) : 0.0;
sideR= G4ExitNormal::kRMin;
sideR = G4ExitNormal::kRMin;
}
else
{
@@ -590,7 +586,7 @@ G4ReplicaNavigation::DistanceToOutRad(const G4ThreeVector &localPoint,
c = deltaR/t1;
d2 = b*b-c;
srd = (d2 < 0.) ? 0.0 : -b+std::sqrt(d2);
sideR= G4ExitNormal::kRMax;
sideR = G4ExitNormal::kRMax;
}
}
else
@@ -608,8 +604,8 @@ G4ReplicaNavigation::DistanceToOutRad(const G4ThreeVector &localPoint,
}
else
{
srd=kInfinity;
sideR= G4ExitNormal::kNull;
srd =kInfinity;
sideR = G4ExitNormal::kNull;
}
if( sideR != G4ExitNormal::kNull ) // if ((side == kRMax) || (side==kRMin))
@@ -624,7 +620,7 @@ G4ReplicaNavigation::DistanceToOutRad(const G4ThreeVector &localPoint,
if( sideR == G4ExitNormal::kRMax )
{
normalR *= 1.0/rmax;
normalR *= 1.0/rmax;
}
else
{
@@ -637,7 +633,7 @@ G4ReplicaNavigation::DistanceToOutRad(const G4ThreeVector &localPoint,
}
else
{
foundNormal.calculated= false;
foundNormal.calculated = false;
}
return srd;
@@ -750,24 +746,24 @@ G4ReplicaNavigation::ComputeTransformation(const G4int replicaNo,
// ********************************************************************
//
G4double
G4ReplicaNavigation::ComputeStep(const G4ThreeVector &globalPoint,
const G4ThreeVector &globalDirection,
const G4ThreeVector &localPoint,
const G4ThreeVector &localDirection,
G4ReplicaNavigation::ComputeStep(const G4ThreeVector& globalPoint,
const G4ThreeVector& globalDirection,
const G4ThreeVector& localPoint,
const G4ThreeVector& localDirection,
const G4double currentProposedStepLength,
G4double &newSafety,
G4double& newSafety,
G4NavigationHistory &history,
// std::pair<G4bool,G4bool> &validAndCalculated
G4bool &validExitNormal,
G4bool &calculatedExitNormal,
G4ThreeVector &exitNormalVector,
G4bool &exiting,
G4bool &entering,
G4VPhysicalVolume *(*pBlockedPhysical),
G4int &blockedReplicaNo )
// std::pair<G4bool,G4bool>& validAndCalculated
G4bool& validExitNormal,
G4bool& calculatedExitNormal,
G4ThreeVector& exitNormalVector,
G4bool& exiting,
G4bool& entering,
G4VPhysicalVolume* (*pBlockedPhysical),
G4int& blockedReplicaNo )
{
G4VPhysicalVolume *repPhysical, *motherPhysical;
G4VPhysicalVolume *samplePhysical, *blockedExitedVol=0;
G4VPhysicalVolume *samplePhysical, *blockedExitedVol = nullptr;
G4LogicalVolume *repLogical;
G4VSolid *motherSolid;
G4ThreeVector repPoint, repDirection, sampleDirection;
@@ -828,17 +824,17 @@ G4ReplicaNavigation::ComputeStep(const G4ThreeVector &globalPoint,
exitNormalStc = normalOutStc;
exitNormalStc.exitNormal =
history.GetTopTransform().InverseTransformAxis(normalOutStc.exitNormal);
calculatedExitNormal= true;
calculatedExitNormal = true;
}
}
const G4int secondDepth= topDepth;
const G4int secondDepth = topDepth;
depth = secondDepth;
// Loop checking, 07.10.2016, J.Apostolakis -- Need to add: assert(depth>0)
// Loop checking, 07.10.2016, JA -- Need to add: assert(depth>0)
while ( history.GetVolumeType(depth)==kReplica )
{
const G4AffineTransform& GlobalToLocal= history.GetTransform(depth);
repPoint = GlobalToLocal.TransformPoint(globalPoint);
const G4AffineTransform& GlobalToLocal = history.GetTransform(depth);
repPoint = GlobalToLocal.TransformPoint(globalPoint);
// repPoint = history.GetTransform(depth).TransformPoint(globalPoint);
sampleSafety = DistanceToOut(history.GetVolume(depth),
@@ -868,9 +864,9 @@ G4ReplicaNavigation::ComputeStep(const G4ThreeVector &globalPoint,
G4ThreeVector globalExitNorm =
GlobalToLocal.InverseTransformAxis(localExitNorm);
exitNormalStc= normalOutStc; // Normal, convex, calculated, side
exitNormalStc.exitNormal= globalExitNorm;
calculatedExitNormal= true;
exitNormalStc = normalOutStc; // Normal, convex, calculated, side
exitNormalStc.exitNormal = globalExitNorm;
calculatedExitNormal = true;
}
}
depth--;
@@ -879,8 +875,8 @@ G4ReplicaNavigation::ComputeStep(const G4ThreeVector &globalPoint,
// Compute mother safety & intersection
//
G4ThreeVector exitVectorMother;
G4bool exitConvex= false; // Value obtained in DistanceToOut(p,v) call
G4ExitNormal motherNormalStc;
G4bool exitConvex = false; // Value obtained in DistanceToOut(p,v) call
G4ExitNormal motherNormalStc;
repPoint = history.GetTransform(depth).TransformPoint(globalPoint);
motherPhysical = history.GetVolume(depth);
@@ -894,30 +890,30 @@ G4ReplicaNavigation::ComputeStep(const G4ThreeVector &globalPoint,
{
motherNormalStc = G4ExitNormal( exitVectorMother, true, false,
G4ExitNormal::kMother);
calculatedExitNormal= true;
calculatedExitNormal = true;
}
const G4AffineTransform& globalToLocalTop = history.GetTopTransform();
G4bool motherDeterminedStep= (motherStep<ourStep);
G4bool motherDeterminedStep = (motherStep<ourStep);
if( (!exitConvex) && motherDeterminedStep )
{
exitVectorMother= motherSolid->SurfaceNormal( repPoint );
motherNormalStc= G4ExitNormal( exitVectorMother, true, false,
G4ExitNormal::kMother);
exitVectorMother = motherSolid->SurfaceNormal( repPoint );
motherNormalStc = G4ExitNormal( exitVectorMother, true, false,
G4ExitNormal::kMother);
// CalculatedExitNormal -> true;
// Convex -> false: do not know value
// ExitSide -> kMother (or kNull)
calculatedExitNormal= true;
calculatedExitNormal = true;
}
if( motherDeterminedStep)
if( motherDeterminedStep )
{
G4ThreeVector globalExitNormalTop =
globalToLocalTop.InverseTransformAxis(exitVectorMother);
exitNormalStc= motherNormalStc;
exitNormalStc.exitNormal= globalExitNormalTop;
exitNormalStc = motherNormalStc;
exitNormalStc.exitNormal = globalExitNormalTop;
}
// Push in principle no longer necessary. G4Navigator now takes care of ...
@@ -969,7 +965,7 @@ G4ReplicaNavigation::ComputeStep(const G4ThreeVector &globalPoint,
// Comparison of steps may need precision protection
//
#if 1
if( motherDeterminedStep)
if( motherDeterminedStep )
{
ourStep = motherStep;
exiting = true;
@@ -981,12 +977,12 @@ G4ReplicaNavigation::ComputeStep(const G4ThreeVector &globalPoint,
{
if ( motherDeterminedStep )
{
exitNormalVector= motherNormalStc.exitNormal;
exitNormalVector = motherNormalStc.exitNormal;
}
else
{
G4ThreeVector exitNormalGlobal= exitNormalStc.exitNormal;
exitNormalVector= globalToLocalTop.TransformAxis(exitNormalGlobal);
G4ThreeVector exitNormalGlobal = exitNormalStc.exitNormal;
exitNormalVector = globalToLocalTop.TransformAxis(exitNormalGlobal);
// exitNormalVector= globalToLocal2nd.TransformAxis(exitNormalGlobal);
// Alt Make it in one go to Grand-Mother, avoiding transform below
}
@@ -1028,7 +1024,7 @@ G4ReplicaNavigation::ComputeStep(const G4ThreeVector &globalPoint,
#endif
G4bool daughterDeterminedStep=false;
G4bool daughterDeterminedStep = false;
G4ThreeVector daughtNormRepCrd;
// Exit normal of daughter transformed to
// the coordinate system of Replica (i.e. last depth)
@@ -1065,7 +1061,7 @@ G4ReplicaNavigation::ComputeStep(const G4ThreeVector &globalPoint,
sampleSolid->DistanceToIn(samplePoint,sampleDirection);
if ( sampleStepDistance<=ourStep )
{
daughterDeterminedStep= true;
daughterDeterminedStep = true;
ourStep = sampleStepDistance;
entering = true;
@@ -1086,9 +1082,9 @@ G4ReplicaNavigation::ComputeStep(const G4ThreeVector &globalPoint,
if ( ( fCheck ) && ( sampleStepDistance < kInfinity ) )
{
G4ThreeVector intersectionPoint;
intersectionPoint= samplePoint
+ sampleStepDistance * sampleDirection;
EInside insideIntPt= sampleSolid->Inside(intersectionPoint);
intersectionPoint = samplePoint
+ sampleStepDistance * sampleDirection;
EInside insideIntPt = sampleSolid->Inside(intersectionPoint);
if ( insideIntPt != kSurface )
{
G4int oldcoutPrec = G4cout.precision(16);
@@ -1137,7 +1133,7 @@ G4ReplicaNavigation::ComputeStep(const G4ThreeVector &globalPoint,
exitNormalVector = globalToLocalTop.InverseTransformAxis(daughtNormGlobal);
validExitNormal = false; // Entering daughter - never convex for parent
calculatedExitNormal= true;
calculatedExitNormal = true;
}
// calculatedExitNormal= true; // Force it to true -- dubious
#endif
@@ -1154,17 +1150,17 @@ G4ReplicaNavigation::ComputeStep(const G4ThreeVector &globalPoint,
// ********************************************************************
//
G4double
G4ReplicaNavigation::ComputeSafety(const G4ThreeVector &globalPoint,
const G4ThreeVector &localPoint,
G4NavigationHistory &history,
G4ReplicaNavigation::ComputeSafety(const G4ThreeVector& globalPoint,
const G4ThreeVector& localPoint,
G4NavigationHistory& history,
const G4double )
{
G4VPhysicalVolume *repPhysical, *motherPhysical;
G4VPhysicalVolume *samplePhysical, *blockedExitedVol=0;
G4VPhysicalVolume *samplePhysical, *blockedExitedVol = nullptr;
G4LogicalVolume *repLogical;
G4VSolid *motherSolid;
G4ThreeVector repPoint;
G4double ourSafety=kInfinity;
G4double ourSafety = kInfinity;
G4double sampleSafety;
G4int localNoDaughters, sampleNo;
G4int depth;
@@ -1186,7 +1182,7 @@ G4ReplicaNavigation::ComputeSafety(const G4ThreeVector &globalPoint,
depth = history.GetDepth()-1;
// Loop checking, 07.10.2016, J.Apostolakis -- need to add: assert(depth>0)
// Loop checking, 07.10.2016, JA -- need to add: assert(depth>0)
while ( history.GetVolumeType(depth)==kReplica )
{
repPoint = history.GetTransform(depth).TransformPoint(globalPoint);
@@ -1243,13 +1239,13 @@ G4ReplicaNavigation::ComputeSafety(const G4ThreeVector &globalPoint,
// ********************************************************************
//
EInside
G4ReplicaNavigation::BackLocate(G4NavigationHistory &history,
const G4ThreeVector &globalPoint,
G4ThreeVector &localPoint,
const G4bool &exiting,
G4bool &notKnownInside ) const
G4ReplicaNavigation::BackLocate(G4NavigationHistory& history,
const G4ThreeVector& globalPoint,
G4ThreeVector& localPoint,
const G4bool& exiting,
G4bool& notKnownInside ) const
{
G4VPhysicalVolume *pNRMother=0;
G4VPhysicalVolume *pNRMother = nullptr;
G4VSolid *motherSolid;
G4ThreeVector repPoint, goodPoint;
G4int mdepth, depth, cdepth;
@@ -1268,7 +1264,7 @@ G4ReplicaNavigation::BackLocate(G4NavigationHistory &history,
}
}
if( pNRMother==0 )
if( pNRMother == nullptr )
{
// All the tree of mother volumes were Replicas.
// This is an error, as the World volume must be a Placement
@@ -1297,7 +1293,7 @@ G4ReplicaNavigation::BackLocate(G4NavigationHistory &history,
// Still within replications
// Check down: if on outside stop at this level
//
for ( depth=mdepth+1; depth<cdepth; depth++)
for ( depth=mdepth+1; depth<cdepth; ++depth)
{
repPoint = history.GetTransform(depth).TransformPoint(globalPoint);
insideCode = Inside(history.GetVolume(depth),
@@ -23,12 +23,9 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// GEANT4 tag $ Name: $
//
// class G4SafetyHelper Implementation
//
// Original author: John Apostolakis, 2006
//
// --------------------------------------------------------------------
#include "G4SafetyHelper.hh"
@@ -39,25 +36,13 @@
#include "globals.hh"
G4SafetyHelper::G4SafetyHelper()
: fUseParallelGeometries(false), // By default, one geometry only
fFirstCall(true),
fVerbose(0),
fLastSafetyPosition(0.0,0.0,0.0),
fLastSafety(0.0)
// fRecomputeFactor(0.0)
: fLastSafetyPosition(0.0,0.0,0.0)
{
fpPathFinder= 0; // Cannot initialise this yet - a loop results
// Initialization of the Navigator pointer is postponed, and must
// be undertaken by another class calling InitialiseHelper()
//
fpMassNavigator= 0;
fMassNavigatorId= -1;
}
void G4SafetyHelper::InitialiseNavigator()
{
fpPathFinder= G4PathFinder::GetInstance();
fpPathFinder = G4PathFinder::GetInstance();
G4TransportationManager* pTransportMgr=
G4TransportationManager::GetTransportationManager();
@@ -67,10 +52,10 @@ void G4SafetyHelper::InitialiseNavigator()
// Check
//
G4VPhysicalVolume* worldPV = fpMassNavigator->GetWorldVolume();
if( worldPV == 0 )
if( worldPV == nullptr )
{
G4Exception("G4SafetyHelper::InitialiseNavigator",
"InvalidNavigatorWorld", FatalException,
"GeomNav0003", FatalException,
"Found that existing tracking Navigator has NULL world");
}
@@ -90,8 +75,8 @@ G4SafetyHelper::~G4SafetyHelper()
}
G4double
G4SafetyHelper::CheckNextStep(const G4ThreeVector &position,
const G4ThreeVector &direction,
G4SafetyHelper::CheckNextStep(const G4ThreeVector& position,
const G4ThreeVector& direction,
const G4double currentMaxStep,
G4double& newSafety )
{
@@ -110,7 +95,8 @@ G4SafetyHelper::CheckNextStep(const G4ThreeVector &position,
return linstep;
}
G4double G4SafetyHelper::ComputeSafety( const G4ThreeVector& position, G4double maxLength )
G4double G4SafetyHelper::ComputeSafety( const G4ThreeVector& position,
G4double maxLength )
{
G4double newSafety;
@@ -154,23 +140,26 @@ G4double G4SafetyHelper::ComputeSafety( const G4ThreeVector& position, G4double
return newSafety;
}
void G4SafetyHelper::ReLocateWithinVolume( const G4ThreeVector &newPosition )
void G4SafetyHelper::ReLocateWithinVolume( const G4ThreeVector& newPosition )
{
// G4cout << " G4SafetyHelper::ReLocateWithinVolume called at " << newPosition << G4endl;
#ifdef G4VERBOSE
if( fVerbose > 0 ) {
// There is an opportunity - and need - to check whether the proposed move is safe
G4ThreeVector moveVec= newPosition - fLastSafetyPosition;
if( fVerbose > 0 )
{
// There is an opportunity - and need - to check whether
// the proposed move is safe
G4ThreeVector moveVec = newPosition - fLastSafetyPosition;
if( moveVec.mag2() > sqr(fLastSafety) )
{
// A problem exists - we are proposing to move outside 'Safety Sphere'
G4ExceptionDescription ed;
ed << "Unsafe Move> Asked to relocate beyond 'Safety sphere'. Details: " << G4endl;
ed << "Unsafe Move> Asked to relocate beyond 'Safety sphere'. Details: "
<< G4endl;
ed << " Safety Sphere: Radius = " << fLastSafety;
ed << " Center = " << fLastSafetyPosition << G4endl;
ed << " New Location : Move = " << moveVec.mag();
ed << " Position = " << newPosition << G4endl;
G4Exception("G4SafetyHelper::ReLocateWithinVolume", "GeomNav999", JustWarning, ed);
G4Exception("G4SafetyHelper::ReLocateWithinVolume",
"GeomNav1001", JustWarning, ed);
}
}
#endif
@@ -188,7 +177,7 @@ void G4SafetyHelper::ReLocateWithinVolume( const G4ThreeVector &newPosition )
void G4SafetyHelper::Locate( const G4ThreeVector& newPosition,
const G4ThreeVector& newDirection)
{
if( !fUseParallelGeometries)
if( !fUseParallelGeometries )
{
fpMassNavigator->LocateGlobalPointAndSetup(newPosition, &newDirection,
true, false);
@@ -200,33 +189,28 @@ void G4SafetyHelper::Locate( const G4ThreeVector& newPosition,
}
G4bool G4SafetyHelper::RecheckDistanceToCurrentBoundary(
const G4ThreeVector &pGlobalPoint,
const G4ThreeVector &pDirection,
const G4ThreeVector& pGlobalPoint,
const G4ThreeVector& pDirection,
const G4double aProposedMove,
G4double *prDistance,
G4double *prNewSafety) const
G4double* prDistance,
G4double* prNewSafety) const
{
G4bool retval;
if( !fUseParallelGeometries)
if( !fUseParallelGeometries )
{
retval= fpMassNavigator->RecheckDistanceToCurrentBoundary(
pGlobalPoint,
pDirection,
aProposedMove,
prDistance,
prNewSafety);
retval = fpMassNavigator->RecheckDistanceToCurrentBoundary(pGlobalPoint,
pDirection,
aProposedMove,
prDistance,
prNewSafety);
}
else
{
//G4Exception("G4Navigator::RecheckDistanceToCurrentBoundary()", "GeomNav0001",
// JustWarning, "Method NOT Available (yet) in case of Multiple Geometries (where PathFinder is involved.).");
retval= fpPathFinder->RecheckDistanceToCurrentBoundary(
pGlobalPoint,
pDirection,
aProposedMove,
prDistance,
prNewSafety);
retval = fpPathFinder->RecheckDistanceToCurrentBoundary(pGlobalPoint,
pDirection,
aProposedMove,
prDistance,
prNewSafety);
}
return retval;
}
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// Class G4SimpleLocator implementation
//
// 27.10.08 - Tatiana Nikitina, extracted from G4PropagatorInField class
@@ -154,22 +153,22 @@ G4bool G4SimpleLocator::EstimateIntersectionPoint(
}
#endif
G4ThreeVector CurrentF_Point= ApproxIntersecPointV.GetPosition();
G4ThreeVector CurrentF_Point = ApproxIntersecPointV.GetPosition();
// First check whether EF is small - then F is a good approx. point
// Calculate the length and direction of the chord AF
//
G4ThreeVector ChordEF_Vector = CurrentF_Point - CurrentE_Point;
G4ThreeVector ChordEF_Vector = CurrentF_Point - CurrentE_Point;
G4ThreeVector NewMomentumDir= ApproxIntersecPointV.GetMomentumDir();
G4double MomDir_dot_Norm= NewMomentumDir.dot( NormalAtEntry ) ;
G4ThreeVector NewMomentumDir = ApproxIntersecPointV.GetMomentumDir();
G4double MomDir_dot_Norm = NewMomentumDir.dot( NormalAtEntry ) ;
G4ThreeVector ChordAB = Point_B - Point_A;
G4ThreeVector ChordAB = Point_B - Point_A;
#ifdef G4DEBUG_FIELD
G4VIntersectionLocator::
ReportTrialStep( substep_no, ChordAB, ChordEF_Vector,
NewMomentumDir, NormalAtEntry, validNormalAtE );
NewMomentumDir, NormalAtEntry, validNormalAtE );
#endif
// Check Sign is always exiting !! TODO
// Could ( > -epsilon) be used instead?
@@ -198,7 +197,7 @@ G4bool G4SimpleLocator::EstimateIntersectionPoint(
last_AF_intersection, IP, NewSafety,
fPreviousSafety, fPreviousSftOrigin );
if(goodCorrection)
if ( goodCorrection )
{
IntersectedOrRecalculatedFT = ApproxIntersecPointV;
IntersectedOrRecalculatedFT.SetPosition(IP);
@@ -257,7 +256,7 @@ G4bool G4SimpleLocator::EstimateIntersectionPoint(
// By moving point B, must take care if current
// AF has no intersection to try current FB!!
//
final_section= false;
final_section = false;
#ifdef G4VERBOSE
if( fVerboseLevel > 3 )
@@ -279,7 +278,7 @@ G4bool G4SimpleLocator::EstimateIntersectionPoint(
G4double stepLengthFB;
G4ThreeVector PointH;
G4bool usedNavigatorFB=false;
G4bool usedNavigatorFB = false;
// Check whether any volumes are encountered by the chord FB
// ---------------------------------------------------------
@@ -412,7 +411,7 @@ G4bool G4SimpleLocator::EstimateIntersectionPoint(
"GeomNav0003", FatalException, message);
}
if(restoredFullEndpoint)
if ( restoredFullEndpoint )
{
final_section = restoredFullEndpoint;
restoredFullEndpoint = false;
@@ -442,7 +441,7 @@ G4bool G4SimpleLocator::EstimateIntersectionPoint(
-1.0, NewSafety, substep_no);
}
#endif
substep_no++;
++substep_no;
} while ( ( ! found_approximate_intersection )
&& ( ! there_is_no_intersection )
@@ -23,15 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// G4TransportationManager
// Class G4TransportationManager implementation
//
// Created : J.Apostolakis, 1997
// Reviewed: G.Cosmo, 2006
// 10.04.07 V.Ivanchenko Use unique G4SafetyHelper
//
// --------------------------------------------------------------------
#include "G4TransportationManager.hh"
@@ -47,7 +42,11 @@
// Initialise the static instance of the singleton
//
G4ThreadLocal G4TransportationManager*
G4TransportationManager::fTransportationManager=0;
G4TransportationManager::fTransportationManager = nullptr;
// The first registered navigator -- expect this to be the master thread's navigator
// If it has an external sub-navigator, it will be cloned for each worker thread.
G4Navigator* G4TransportationManager::fFirstTrackingNavigator= nullptr;
// ----------------------------------------------------------------------------
// Constructor
@@ -63,7 +62,17 @@ G4TransportationManager::G4TransportationManager()
// Create the navigator for tracking and activate it; add to collections
//
G4Navigator* trackingNavigator = new G4Navigator();
G4Navigator* trackingNavigator= nullptr;
if( fFirstTrackingNavigator && fFirstTrackingNavigator->GetExternalNavigation() )
{
trackingNavigator = fFirstTrackingNavigator->Clone();
}
else
{
trackingNavigator = new G4Navigator();
if( fFirstTrackingNavigator == nullptr )
fFirstTrackingNavigator = trackingNavigator;
}
trackingNavigator->Activate(true);
fNavigators.push_back(trackingNavigator);
fActiveNavigators.push_back(trackingNavigator);
@@ -84,7 +93,7 @@ G4TransportationManager::~G4TransportationManager()
delete fPropagatorInField;
delete fGeomMessenger;
ClearNavigators();
fTransportationManager = 0;
fTransportationManager = nullptr;
}
// ----------------------------------------------------------------------------
@@ -92,9 +101,9 @@ G4TransportationManager::~G4TransportationManager()
//
// Retrieve the static instance of the singleton and create it if not existing
//
G4TransportationManager* G4TransportationManager::GetTransportationManager()
G4TransportationManager* G4TransportationManager::GetTransportationManager()
{
if (!fTransportationManager)
if (fTransportationManager == nullptr)
{
fTransportationManager = new G4TransportationManager;
}
@@ -150,8 +159,7 @@ void G4TransportationManager::SetNavigatorForTracking(G4Navigator* newNavigator)
//
void G4TransportationManager::ClearNavigators()
{
std::vector<G4Navigator*>::iterator pNav;
for (pNav=fNavigators.begin(); pNav!=fNavigators.end(); pNav++)
for (auto pNav=fNavigators.cbegin(); pNav!=fNavigators.cend(); ++pNav)
{
delete *pNav;
}
@@ -170,15 +178,15 @@ G4VPhysicalVolume*
G4TransportationManager::GetParallelWorld( const G4String& worldName )
{
G4VPhysicalVolume* wPV = IsWorldExisting(worldName);
if (!wPV)
if (wPV == nullptr)
{
wPV = GetNavigatorForTracking()->GetWorldVolume();
G4LogicalVolume* wLV = wPV->GetLogicalVolume();
wLV = new G4LogicalVolume(wLV->GetSolid(), 0,
wLV = new G4LogicalVolume(wLV->GetSolid(), nullptr,
worldName);
wPV = new G4PVPlacement (wPV->GetRotation(),
wPV->GetTranslation(),
wLV, worldName, 0, false, 0);
wLV, worldName, nullptr, false, 0);
RegisterWorld(wPV);
}
return wPV;
@@ -195,8 +203,7 @@ G4Navigator* G4TransportationManager::GetNavigator( const G4String& worldName )
{
// If already existing, return the stored pointer to the navigator
//
std::vector<G4Navigator*>::iterator pNav;
for (pNav=fNavigators.begin(); pNav!=fNavigators.end(); pNav++)
for (auto pNav=fNavigators.cbegin(); pNav!=fNavigators.cend(); ++pNav)
{
if ((*pNav)->GetWorldVolume()->GetName() == worldName) { return *pNav; }
}
@@ -204,9 +211,9 @@ G4Navigator* G4TransportationManager::GetNavigator( const G4String& worldName )
// Check if world of that name already exists,
// create a navigator and register it
//
G4Navigator* aNavigator = 0;
G4Navigator* aNavigator = nullptr;
G4VPhysicalVolume* aWorld = IsWorldExisting(worldName);
if(aWorld)
if(aWorld != nullptr)
{
aNavigator = new G4Navigator();
aNavigator->SetWorldVolume(aWorld);
@@ -233,15 +240,13 @@ G4Navigator* G4TransportationManager::GetNavigator( const G4String& worldName )
//
G4Navigator* G4TransportationManager::GetNavigator( G4VPhysicalVolume* aWorld )
{
std::vector<G4Navigator*>::iterator pNav;
for (pNav=fNavigators.begin(); pNav!=fNavigators.end(); pNav++)
for (auto pNav=fNavigators.cbegin(); pNav!=fNavigators.cend(); ++pNav)
{
if ((*pNav)->GetWorldVolume() == aWorld) { return *pNav; }
}
G4Navigator* aNavigator = 0;
std::vector<G4VPhysicalVolume*>::iterator pWorld =
std::find(fWorlds.begin(), fWorlds.end(), aWorld);
if (pWorld != fWorlds.end())
G4Navigator* aNavigator = nullptr;
auto pWorld = std::find(fWorlds.cbegin(), fWorlds.cend(), aWorld);
if (pWorld != fWorlds.cend())
{
aNavigator = new G4Navigator();
aNavigator->SetWorldVolume(aWorld);
@@ -275,9 +280,8 @@ void G4TransportationManager::DeRegisterNavigator( G4Navigator* aNavigator )
"GeomNav0003", FatalException,
"The navigator for tracking CANNOT be deregistered!");
}
std::vector<G4Navigator*>::iterator pNav =
std::find(fNavigators.begin(), fNavigators.end(), aNavigator);
if (pNav != fNavigators.end())
auto pNav = std::find(fNavigators.cbegin(), fNavigators.cend(), aNavigator);
if (pNav != fNavigators.cend())
{
// Deregister associated world volume
//
@@ -308,9 +312,8 @@ void G4TransportationManager::DeRegisterNavigator( G4Navigator* aNavigator )
//
G4int G4TransportationManager::ActivateNavigator( G4Navigator* aNavigator )
{
std::vector<G4Navigator*>::iterator pNav =
std::find(fNavigators.begin(), fNavigators.end(), aNavigator);
if (pNav == fNavigators.end())
auto pNav = std::find(fNavigators.cbegin(), fNavigators.cend(), aNavigator);
if (pNav == fNavigators.cend())
{
G4String message
= "Navigator for volume -" + aNavigator->GetWorldVolume()->GetName()
@@ -322,12 +325,11 @@ G4int G4TransportationManager::ActivateNavigator( G4Navigator* aNavigator )
aNavigator->Activate(true);
G4int id = 0;
std::vector<G4Navigator*>::iterator pActiveNav;
for(pActiveNav=fActiveNavigators.begin();
pActiveNav!=fActiveNavigators.end(); pActiveNav++)
for(auto pActiveNav=fActiveNavigators.cbegin();
pActiveNav!=fActiveNavigators.cend(); ++pActiveNav)
{
if (*pActiveNav == aNavigator) { return id; }
id++;
++id;
}
fActiveNavigators.push_back(aNavigator);
@@ -343,9 +345,8 @@ G4int G4TransportationManager::ActivateNavigator( G4Navigator* aNavigator )
//
void G4TransportationManager::DeActivateNavigator( G4Navigator* aNavigator )
{
std::vector<G4Navigator*>::iterator pNav =
std::find(fNavigators.begin(), fNavigators.end(), aNavigator);
if (pNav != fNavigators.end())
auto pNav = std::find(fNavigators.cbegin(), fNavigators.cend(), aNavigator);
if (pNav != fNavigators.cend())
{
(*pNav)->Activate(false);
}
@@ -358,9 +359,9 @@ void G4TransportationManager::DeActivateNavigator( G4Navigator* aNavigator )
"GeomNav1002", JustWarning, message);
}
std::vector<G4Navigator*>::iterator pActiveNav =
std::find(fActiveNavigators.begin(), fActiveNavigators.end(), aNavigator);
if (pActiveNav != fActiveNavigators.end())
auto pActiveNav = std::find(fActiveNavigators.cbegin(),
fActiveNavigators.cend(), aNavigator);
if (pActiveNav != fActiveNavigators.cend())
{
fActiveNavigators.erase(pActiveNav);
}
@@ -374,8 +375,8 @@ void G4TransportationManager::DeActivateNavigator( G4Navigator* aNavigator )
//
void G4TransportationManager::InactivateAll( )
{
std::vector<G4Navigator*>::iterator pNav;
for (pNav=fActiveNavigators.begin(); pNav!=fActiveNavigators.end(); pNav++)
for (auto pNav=fActiveNavigators.cbegin();
pNav!=fActiveNavigators.cend(); ++pNav)
{
(*pNav)->Activate(false);
}
@@ -396,12 +397,12 @@ void G4TransportationManager::InactivateAll( )
G4VPhysicalVolume*
G4TransportationManager::IsWorldExisting ( const G4String& name )
{
std::vector<G4VPhysicalVolume*>::iterator pWorld = fWorlds.begin();
if (*pWorld==0) { *pWorld=fNavigators[0]->GetWorldVolume(); }
auto pWorld = fWorlds.begin();
if ( *pWorld==nullptr ) { *pWorld=fNavigators[0]->GetWorldVolume(); }
for (pWorld=fWorlds.begin(); pWorld!=fWorlds.end(); pWorld++)
for (auto cpWorld=fWorlds.cbegin(); cpWorld!=fWorlds.cend(); ++cpWorld)
{
if ((*pWorld)->GetName() == name ) { return *pWorld; }
if ((*cpWorld)->GetName() == name ) { return *cpWorld; }
}
return 0;
}
@@ -417,9 +418,8 @@ G4bool G4TransportationManager::RegisterWorld( G4VPhysicalVolume* aWorld )
{
G4bool done = false;
std::vector<G4VPhysicalVolume*>::iterator pWorld =
std::find(fWorlds.begin(), fWorlds.end(), aWorld);
if (pWorld == fWorlds.end())
auto pWorld = std::find(fWorlds.cbegin(), fWorlds.cend(), aWorld);
if (pWorld == fWorlds.cend())
{
fWorlds.push_back(aWorld);
done = true;
@@ -436,9 +436,8 @@ G4bool G4TransportationManager::RegisterWorld( G4VPhysicalVolume* aWorld )
//
void G4TransportationManager::DeRegisterWorld( G4VPhysicalVolume* aWorld )
{
std::vector<G4VPhysicalVolume*>::iterator pWorld =
std::find(fWorlds.begin(), fWorlds.end(), aWorld);
if (pWorld != fWorlds.end())
auto pWorld = std::find(fWorlds.cbegin(), fWorlds.cend(), aWorld);
if (pWorld != fWorlds.cend())
{
fWorlds.erase(pWorld);
}
@@ -461,9 +460,9 @@ void G4TransportationManager::DeRegisterWorld( G4VPhysicalVolume* aWorld )
//
void G4TransportationManager::ClearParallelWorlds()
{
std::vector<G4Navigator*>::iterator pNav = fNavigators.begin();
auto pNav = fNavigators.cbegin();
G4Navigator* trackingNavigator = *pNav;
for (pNav=fNavigators.begin(); pNav!=fNavigators.end(); pNav++)
for (pNav=fNavigators.cbegin(); pNav!=fNavigators.cend(); ++pNav)
{
if (*pNav != trackingNavigator) { delete *pNav; }
}
@@ -471,10 +470,27 @@ void G4TransportationManager::ClearParallelWorlds()
fActiveNavigators.clear();
fWorlds.clear();
// trackingNavigator->SetWorldVolume(0);
fNavigators.push_back(trackingNavigator);
fActiveNavigators.push_back(trackingNavigator);
// fWorlds.push_back(trackingNavigator->GetWorldVolume()); // NULL registered
fWorlds.push_back(0); // NULL registered
}
// ----------------------------------------------------------------------------
// GetFirstTrackingNavigator()
//
// Get pointer to the first tracking Navigator created
//
G4Navigator* G4TransportationManager::GetFirstTrackingNavigator()
{
return fFirstTrackingNavigator;
}
// ----------------------------------------------------------------------------
// GetFirstTrackingNavigator()
//
// Get pointer to the first tracking Navigator created
void G4TransportationManager::SetFirstTrackingNavigator(G4Navigator *nav)
{
fFirstTrackingNavigator= nav;
}
@@ -0,0 +1,74 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4VExternalNavigation Implementation
//
// Authors: V.Vlachoudis, G.Cosmo - CERN, 2019
// --------------------------------------------------------------------
#include "G4VExternalNavigation.hh"
// ********************************************************************
// Constructor
// *********V***********************************************************
//
G4VExternalNavigation::G4VExternalNavigation()
{
}
// ********************************************************************
// Destructor
// ********************************************************************
//
G4VExternalNavigation::~G4VExternalNavigation()
{
}
// ********************************************************************
// Inside call Inside() of a solid
// ********************************************************************
//
EInside G4VExternalNavigation::Inside( const G4VSolid* solid,
const G4ThreeVector& pos,
const G4ThreeVector& )
{
return solid->Inside(pos);
}
// ********************************************************************
// Inside call Inside() of a solid
void G4VExternalNavigation::RelocateWithinVolume( G4VPhysicalVolume* , // motherPhysical,
const G4ThreeVector& ) // localPoint )
{
// Default action is do-nothing
// A concrete external navigation class must update any relevant
// internal state to take account that
// - the location has been moved to 'localPoint'
// - which remains in the current (mother) physical volume motherPhysical
// ( provided for fast access and/or checking. )
}
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// Class G4VIntersectionLocator implementation
//
// 27.10.08 - John Apostolakis, Tatiana Nikitina.
@@ -43,19 +42,19 @@
//
// Constructor
//
G4VIntersectionLocator:: G4VIntersectionLocator(G4Navigator *theNavigator)
: fVerboseLevel(0),
fUseNormalCorrection(false),
fCheckMode(false),
fiNavigator(theNavigator),
fiChordFinder(0), // Not set - overridden at each step
fiEpsilonStep(-1.0), // Out of range - overridden at each step
fiDeltaIntersection(-1.0), // Out of range - overridden at each step
fiUseSafety(false), // Default - overridden at each step
fpTouchable(0)
G4VIntersectionLocator::G4VIntersectionLocator(G4Navigator* theNavigator)
: fiNavigator(theNavigator)
{
kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
fHelpingNavigator = new G4Navigator();
if( fiNavigator->GetExternalNavigation() == nullptr )
{
fHelpingNavigator = new G4Navigator();
}
else // Must clone the navigator, together with External Navigation
{
fHelpingNavigator = fiNavigator->Clone();
}
}
///////////////////////////////////////////////////////////////////////////
@@ -73,11 +72,11 @@ G4VIntersectionLocator::~G4VIntersectionLocator()
// Dump status of propagator to cout (old method)
//
void
G4VIntersectionLocator::printStatus( const G4FieldTrack& StartFT,
const G4FieldTrack& CurrentFT,
G4double requestStep,
G4double safety,
G4int stepNo)
G4VIntersectionLocator::printStatus( const G4FieldTrack& StartFT,
const G4FieldTrack& CurrentFT,
G4double requestStep,
G4double safety,
G4int stepNo)
{
std::ostringstream os;
printStatus( StartFT,CurrentFT,requestStep,safety,stepNo,os,fVerboseLevel);
@@ -89,13 +88,13 @@ G4VIntersectionLocator::printStatus( const G4FieldTrack& StartFT,
// Dumps status of propagator.
//
void
G4VIntersectionLocator::printStatus( const G4FieldTrack& StartFT,
const G4FieldTrack& CurrentFT,
G4double requestStep,
G4double safety,
G4int stepNo,
std::ostream& os,
int verboseLevel)
G4VIntersectionLocator::printStatus( const G4FieldTrack& StartFT,
const G4FieldTrack& CurrentFT,
G4double requestStep,
G4double safety,
G4int stepNo,
std::ostream& os,
G4int verboseLevel)
{
// const G4int verboseLevel= fVerboseLevel;
const G4ThreeVector StartPosition = StartFT.GetPosition();
@@ -189,34 +188,37 @@ G4VIntersectionLocator::printStatus( const G4FieldTrack& StartFT,
G4FieldTrack G4VIntersectionLocator::
ReEstimateEndpoint( const G4FieldTrack& CurrentStateA,
const G4FieldTrack& EstimatedEndStateB,
// bool & recalculated)
G4double , // linearDistSq, // NOT used
G4double ) // curveDist ) // NOT used
G4double
#ifdef G4DEBUG_FIELD
curveDist
#endif
)
{
G4FieldTrack newEndPoint( CurrentStateA );
auto integrDriver = GetChordFinderFor()->GetIntegrationDriver();
G4FieldTrack retEndPoint( CurrentStateA );
G4bool goodAdvance;
G4int itrial=0;
const G4int no_trials=20;
G4int itrial = 0;
const G4int no_trials = 20;
G4double endCurveLen= EstimatedEndStateB.GetCurveLength();
do // Loop checking, 07.10.2016, J.Apostolakis
do // Loop checking, 07.10.2016, JA
{
G4double currentCurveLen= newEndPoint.GetCurveLength();
G4double advanceLength= endCurveLen - currentCurveLen ;
G4double currentCurveLen = newEndPoint.GetCurveLength();
G4double advanceLength = endCurveLen - currentCurveLen ;
if (std::abs(advanceLength)<kCarTolerance)
{
goodAdvance=true;
}
else
{
goodAdvance= integrDriver->AccurateAdvance(newEndPoint, advanceLength,
GetEpsilonStepFor());
}
goodAdvance = integrDriver->AccurateAdvance(newEndPoint, advanceLength,
GetEpsilonStepFor());
}
}
while( !goodAdvance && (++itrial < no_trials) );
@@ -249,7 +251,7 @@ ReEstimateEndpoint( const G4FieldTrack& CurrentStateA,
}
else
{
latest_good_trials++;
++latest_good_trials;
}
#endif
@@ -297,9 +299,9 @@ ReEstimateEndpoint( const G4FieldTrack& CurrentStateA,
#else
// Statistics on the RMS value of the corrections
static G4ThreadLocal G4int noCorrections=0;
static G4ThreadLocal G4int noCorrections = 0;
static G4ThreadLocal G4double sumCorrectionsSq = 0;
noCorrections++;
++noCorrections;
if( goodAdvance )
{
sumCorrectionsSq += (EstimatedEndStateB.GetPosition() -
@@ -326,36 +328,35 @@ G4bool G4VIntersectionLocator::
CheckAndReEstimateEndpoint( const G4FieldTrack& CurrentStartA,
const G4FieldTrack& EstimatedEndB,
G4FieldTrack& RevisedEndPoint,
G4int & curveError)
G4int& curveError)
{
G4double linDistSq, curveDist;
G4bool recalculated= false;
G4bool recalculated = false;
curveError= 0;
linDistSq = ( EstimatedEndB.GetPosition()
- CurrentStartA.GetPosition() ).mag2();
- CurrentStartA.GetPosition() ).mag2();
curveDist = EstimatedEndB.GetCurveLength()
- CurrentStartA.GetCurveLength();
- CurrentStartA.GetCurveLength();
if( (curveDist>=0.0)
&& (curveDist*curveDist *(1.0+2.0*fiEpsilonStep ) < linDistSq ) )
{
// G4FieldTrack oldPointVelB = EstimatedEndB;
G4FieldTrack newEndPointFT= EstimatedEndB; // Unused
G4FieldTrack newEndPointFT = EstimatedEndB; // Unused
if (curveDist>0.0)
{
// Re-integrate to obtain a new B
RevisedEndPoint= ReEstimateEndpoint( CurrentStartA,
EstimatedEndB,
linDistSq,
curveDist );
RevisedEndPoint = ReEstimateEndpoint( CurrentStartA,
EstimatedEndB,
linDistSq,
curveDist );
recalculated = true;
}
else
{
// Zero length -> no advance!
newEndPointFT= CurrentStartA;
newEndPointFT = CurrentStartA;
recalculated = true;
curveError = 1; // Unexpected co-incidence - milder mixup
@@ -369,7 +370,6 @@ CheckAndReEstimateEndpoint( const G4FieldTrack& CurrentStartA,
//
if( curveDist < 0.0 )
{
// clean = false;
curveError = 2; // Real mixup
}
return recalculated;
@@ -406,13 +406,10 @@ GetLocalSurfaceNormal(const G4ThreeVector& CurrentE_Point, G4bool& validNormal)
G4LogicalVolume* pLogical= located->GetLogicalVolume();
G4VSolid* pSolid;
if( (pLogical != 0) && ( (pSolid=pLogical->GetSolid()) !=0 ) )
if( (pLogical != nullptr) && ( (pSolid=pLogical->GetSolid()) != nullptr ) )
{
// G4bool goodPoint, nearbyPoint;
// G4int numGoodPoints, numNearbyPoints; // --> use for stats
if ( ( pSolid->Inside(localPosition)==kSurface )
|| ( pSolid->DistanceToOut(localPosition) < 1000.0 * kCarTolerance )
)
|| ( pSolid->DistanceToOut(localPosition) < 1000.0 * kCarTolerance ) )
{
Normal = pSolid->SurfaceNormal(localPosition);
validNormal = true;
@@ -450,7 +447,7 @@ AdjustmentOfFoundIntersection( const G4ThreeVector& CurrentA_Point,
{
G4double dist,lambda;
G4ThreeVector Normal, NewPoint, Point_G;
G4bool goodAdjust=false, Intersects_FP=false, validNormal=false;
G4bool goodAdjust = false, Intersects_FP = false, validNormal = false;
// Get SurfaceNormal of Intersecting Solid
//
@@ -518,7 +515,7 @@ AdjustmentOfFoundIntersection( const G4ThreeVector& CurrentA_Point,
//
G4ThreeVector G4VIntersectionLocator::
GetSurfaceNormal(const G4ThreeVector& CurrentInt_Point,
G4bool& validNormal) // const
G4bool& validNormal)
{
G4ThreeVector NormalAtEntry; // ( -10. , -10., -10. );
@@ -550,9 +547,9 @@ GetSurfaceNormal(const G4ThreeVector& CurrentInt_Point,
if( validNormalLast )
{
NormalAtEntry=NormalAtEntryLast;
NormalAtEntry = NormalAtEntryLast;
}
validNormal = validNormalLast;
validNormal = validNormalLast;
return NormalAtEntry;
}
@@ -565,12 +562,10 @@ G4ThreeVector G4VIntersectionLocator::
GetGlobalSurfaceNormal(const G4ThreeVector& CurrentE_Point,
G4bool& validNormal)
{
G4ThreeVector localNormal=
GetLocalSurfaceNormal( CurrentE_Point, validNormal );
G4AffineTransform localToGlobal= // Must use the same Navigator !!
G4ThreeVector localNormal = GetLocalSurfaceNormal(CurrentE_Point,validNormal);
G4AffineTransform localToGlobal = // Must use the same Navigator !!
fHelpingNavigator->GetLocalToGlobalTransform();
G4ThreeVector globalNormal =
localToGlobal.TransformAxis( localNormal );
G4ThreeVector globalNormal = localToGlobal.TransformAxis( localNormal );
#ifdef G4DEBUG_FIELD
if( validNormal && ( std::fabs(globalNormal.mag2() - 1.0) > perThousand ) )
@@ -607,9 +602,9 @@ GetLastSurfaceNormal( const G4ThreeVector& intersectPoint,
G4bool& normalIsValid) const
{
G4ThreeVector normalVec;
G4bool validNorm;
G4bool validNorm;
normalVec = fiNavigator->GetGlobalExitNormal( intersectPoint, &validNorm );
normalIsValid= validNorm;
normalIsValid = validNorm;
return normalVec;
}
@@ -625,14 +620,13 @@ void G4VIntersectionLocator::ReportTrialStep( G4int step_no,
const G4ThreeVector& NormalAtEntry,
G4bool validNormal )
{
G4double ABchord_length = ChordAB_v.mag();
G4double MomDir_dot_Norm = NewMomentumDir.dot( NormalAtEntry ) ;
G4double MomDir_dot_ABchord;
MomDir_dot_ABchord= (1.0 / ABchord_length) * NewMomentumDir.dot( ChordAB_v );
G4double ABchord_length = ChordAB_v.mag();
G4double MomDir_dot_Norm = NewMomentumDir.dot( NormalAtEntry );
G4double MomDir_dot_ABchord;
MomDir_dot_ABchord = (1.0 / ABchord_length) * NewMomentumDir.dot( ChordAB_v );
std::ostringstream outStream;
outStream // G4cout
<< std::setw(6) << " Step# "
outStream << std::setw(6) << " Step# "
<< std::setw(17) << " |ChordEF|(mag)" << " "
<< std::setw(18) << " uMomentum.Normal" << " "
<< std::setw(18) << " uMomentum.ABdir " << " "
@@ -640,20 +634,18 @@ void G4VIntersectionLocator::ReportTrialStep( G4int step_no,
<< " Chord Vector (EF) "
<< G4endl;
outStream.precision(7);
outStream // G4cout
<< " " << std::setw(5) << step_no
outStream << " " << std::setw(5) << step_no
<< " " << std::setw(18) << ChordEF_v.mag()
<< " " << std::setw(18) << MomDir_dot_Norm
<< " " << std::setw(18) << MomDir_dot_ABchord
<< " " << std::setw(12) << ABchord_length
<< " " << ChordEF_v
<< G4endl;
outStream // G4cout
<< " MomentumDir= " << " " << NewMomentumDir
outStream << " MomentumDir= " << " " << NewMomentumDir
<< " Normal at Entry E= " << NormalAtEntry
<< " AB chord = " << ChordAB_v
<< G4endl;
G4cout << outStream.str(); // ostr_verbose;
G4cout << outStream.str();
if( ( std::fabs(NormalAtEntry.mag2() - 1.0) > perThousand ) )
{
@@ -680,8 +672,8 @@ void G4VIntersectionLocator::ReportTrialStep( G4int step_no,
G4bool G4VIntersectionLocator::
LocateGlobalPointWithinVolumeAndCheck( const G4ThreeVector& position )
{
G4bool good= true;
G4Navigator* nav= GetNavigatorFor();
G4bool good = true;
G4Navigator* nav = GetNavigatorFor();
const G4String
MethodName("G4VIntersectionLocator::LocateGlobalPointWithinVolumeAndCheck()");
@@ -693,15 +685,14 @@ LocateGlobalPointWithinVolumeAndCheck( const G4ThreeVector& position )
// Identify the current volume
G4TouchableHistoryHandle startTH= nav->CreateTouchableHistoryHandle();
G4VPhysicalVolume* motherPhys= startTH->GetVolume();
G4VSolid* motherSolid= startTH->GetSolid();
G4VPhysicalVolume* motherPhys = startTH->GetVolume();
G4VSolid* motherSolid = startTH->GetSolid();
G4AffineTransform transform = nav->GetGlobalToLocalTransform();
// GetLocalToGlobalTransform();
G4int motherCopyNo= motherPhys->GetCopyNo();
G4int motherCopyNo = motherPhys->GetCopyNo();
// Let's check that the point is inside the current solid
G4ThreeVector localPosition = transform.TransformPoint(position);
EInside inMother= motherSolid->Inside( localPosition );
EInside inMother = motherSolid->Inside( localPosition );
if( inMother != kInside )
{
std::ostringstream message;
@@ -746,9 +737,9 @@ LocateGlobalPointWithinVolumeCheckAndReport( const G4ThreeVector& position,
G4int /* CheckMode */)
{
// Save value of Check mode first
G4bool oldCheck= GetCheckMode();
G4bool oldCheck = GetCheckMode();
G4bool ok= LocateGlobalPointWithinVolumeAndCheck( position );
G4bool ok = LocateGlobalPointWithinVolumeAndCheck( position );
if( !ok )
{
std::ostringstream message;
@@ -756,12 +747,6 @@ LocateGlobalPointWithinVolumeCheckAndReport( const G4ThreeVector& position,
<< " Code Location info: " << CodeLocationInfo;
G4Exception("G4VIntersectionLocator::LocateGlobalPointWithinVolumeCheckAndReport()",
"GeomNav1002", JustWarning, message);
/*
if( CheckMode > 1 )
{
// Additional information
}
*/
}
SetCheckMode( oldCheck );
@@ -833,8 +818,6 @@ void G4VIntersectionLocator::ReportProgress( std::ostream& oss,
if( depth > 0 ) oss << " Depth= " << depth;
oss << " Substep no = " << substep_no << G4endl;
G4int verboseLevel = 5;
// printStatus args: (FT0, FT1, dRequestStep, dSafety, iStepNum, os, iVerb);
G4double safetyPrev = -1.0; // Add as argument ?
printStatus( StartPointVel, EndPointVel, -1.0, -1.0, -1,
@@ -860,8 +843,8 @@ G4VIntersectionLocator::ReportImmediateHit( const char* MethodName,
unsigned long int numCalls )
{
static G4ThreadLocal unsigned int occurredOnTop= 0;
static G4ThreadLocal G4ThreeVector *ptrLast= 0;
if( !ptrLast )
static G4ThreadLocal G4ThreeVector* ptrLast = nullptr;
if( ptrLast == nullptr )
{
ptrLast= new G4ThreeVector( DBL_MAX, DBL_MAX, DBL_MAX );
G4AutoDelete::Register(ptrLast);
@@ -870,13 +853,12 @@ G4VIntersectionLocator::ReportImmediateHit( const char* MethodName,
if( (TrialPoint - StartPosition).mag2() < tolerance*tolerance)
{
static G4ThreadLocal unsigned int numUnmoved= 0;
static G4ThreadLocal unsigned int numStill= 0; // Still at same point
static G4ThreadLocal unsigned int numUnmoved = 0;
static G4ThreadLocal unsigned int numStill = 0; // Still at same point
G4cout << "Intersection F == start A in " << MethodName;
G4cout << "Start Point: " << StartPosition << G4endl;
// G4cout << "Trial Point: " << TrialPoint << G4endl;
G4cout << " Start-Trial: " << TrialPoint - StartPosition; // << G4endl;
G4cout << " Start-Trial: " << TrialPoint - StartPosition;
G4cout << " Start-last: " << StartPosition - lastStart;
if( (StartPosition - lastStart).mag() < tolerance )
@@ -23,9 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4VoxelNavigation Implementation
//
// Author: P.Kent, 1996
@@ -44,13 +41,12 @@
// ********************************************************************
//
G4VoxelNavigation::G4VoxelNavigation()
: fBList(), fVoxelDepth(-1),
: fBList(),
fVoxelAxisStack(kNavigatorVoxelStackMax,kXAxis),
fVoxelNoSlicesStack(kNavigatorVoxelStackMax,0),
fVoxelSliceWidthStack(kNavigatorVoxelStackMax,0.),
fVoxelNodeNoStack(kNavigatorVoxelStackMax,0),
fVoxelHeaderStack(kNavigatorVoxelStackMax,(G4SmartVoxelHeader*)0),
fVoxelNode(0), fpVoxelSafety(0), fCheck(false), fBestSafety(false)
fVoxelHeaderStack(kNavigatorVoxelStackMax,(G4SmartVoxelHeader*)nullptr)
{
fLogger= new G4NavigationLogger("G4VoxelNavigation");
fpVoxelSafety= new G4VoxelSafety();
@@ -85,15 +81,15 @@ G4VoxelNavigation::ComputeStep( const G4ThreeVector& localPoint,
G4ThreeVector& exitNormal,
G4bool& exiting,
G4bool& entering,
G4VPhysicalVolume *(*pBlockedPhysical),
G4VPhysicalVolume* (*pBlockedPhysical),
G4int& blockedReplicaNo )
{
G4VPhysicalVolume *motherPhysical, *samplePhysical, *blockedExitedVol=0;
G4VPhysicalVolume *motherPhysical, *samplePhysical, *blockedExitedVol=nullptr;
G4LogicalVolume *motherLogical;
G4VSolid *motherSolid;
G4ThreeVector sampleDirection;
G4double ourStep=currentProposedStepLength, ourSafety;
G4double motherSafety, motherStep=DBL_MAX;
G4double motherSafety, motherStep = DBL_MAX;
G4int localNoDaughters, sampleNo;
G4bool initialNode, noStep;
@@ -139,7 +135,7 @@ G4VoxelNavigation::ComputeStep( const G4ThreeVector& localPoint,
entering = false;
// For extra checking, get the distance to Mother early !!
G4bool motherValidExitNormal= false;
G4bool motherValidExitNormal = false;
G4ThreeVector motherExitNormal(0.0, 0.0, 0.0);
#ifdef G4VERBOSE
@@ -164,20 +160,20 @@ G4VoxelNavigation::ComputeStep( const G4ThreeVector& localPoint,
ourStep = 0.0;
exiting= true;
entering= false;
exiting = true;
entering = false;
// validExitNormal= motherValidExitNormal;
// exitNormal= motherExitNormal;
// Makes sense and is useful only if the point is very close ...
// Alternatives: i) validExitNormal= false;
// ii) Check safety from outside and choose !!
validExitNormal= false;
validExitNormal = false;
*pBlockedPhysical= 0; // or motherPhysical ?
blockedReplicaNo= 0; // or motherReplicaNumber ?
*pBlockedPhysical = nullptr; // or motherPhysical ?
blockedReplicaNo = 0; // or motherReplicaNumber ?
newSafety= 0.0;
newSafety = 0.0;
return ourStep;
}
}
@@ -291,7 +287,7 @@ G4VoxelNavigation::ComputeStep( const G4ThreeVector& localPoint,
noStep = false;
entering = false;
exiting = false;
*pBlockedPhysical = 0;
*pBlockedPhysical = nullptr;
ourStep = kInfinity;
}
else
@@ -343,10 +339,10 @@ G4VoxelNavigation::ComputeStep( const G4ThreeVector& localPoint,
// => but it would need to be rotated to grand-mother ref frame !
validExitNormal= false;
*pBlockedPhysical= 0; // or motherPhysical ?
blockedReplicaNo= 0; // or motherReplicaNumber ?
*pBlockedPhysical = nullptr; // or motherPhysical ?
blockedReplicaNo = 0; // or motherReplicaNumber ?
newSafety= 0.0;
newSafety = 0.0;
return ourStep;
}
@@ -358,8 +354,8 @@ G4VoxelNavigation::ComputeStep( const G4ThreeVector& localPoint,
// Exit normal: Natural location to set these;confirmed short step
//
validExitNormal= motherValidExitNormal;
exitNormal= motherExitNormal;
validExitNormal = motherValidExitNormal;
exitNormal = motherExitNormal;
if ( validExitNormal )
{
@@ -372,7 +368,6 @@ G4VoxelNavigation::ComputeStep( const G4ThreeVector& localPoint,
fLogger->CheckAndReportBadNormal(exitNormal, // rotated
motherExitNormal, // original
*rot,
// motherPhysical,
"From RotationMatrix" );
#endif
}
@@ -450,7 +445,7 @@ G4VoxelNavigation::ComputeVoxelSafety(const G4ThreeVector& localPoint) const
// Compute isotropic safety to boundaries of previous levels
// [NOT to collected boundaries]
// Loop checking, 07.10.2016, J.Apostolakis
// Loop checking, 07.10.2016, JA
while ( (localVoxelDepth>0) && (voxelSafety>0) )
{
localVoxelDepth--;
@@ -498,22 +493,22 @@ G4VoxelNavigation::LocateNextVoxel(const G4ThreeVector& localPoint,
const G4ThreeVector& localDirection,
const G4double currentStep)
{
G4SmartVoxelHeader *workHeader=0, *newHeader=0;
G4SmartVoxelProxy *newProxy=0;
G4SmartVoxelNode *newVoxelNode=0;
G4SmartVoxelHeader *workHeader=nullptr, *newHeader=nullptr;
G4SmartVoxelProxy *newProxy=nullptr;
G4SmartVoxelNode *newVoxelNode=nullptr;
G4ThreeVector targetPoint, voxelPoint;
G4double workNodeWidth, workMinExtent, workCoord;
G4double minVal, maxVal, newDistance=0.;
G4double newHeaderMin, newHeaderNodeWidth;
G4int depth=0, newDepth=0, workNodeNo=0, newNodeNo=0, newHeaderNoSlices=0;
EAxis workHeaderAxis, newHeaderAxis;
G4bool isNewVoxel=false;
G4bool isNewVoxel = false;
G4double currentDistance = currentStep;
// Determine if end of Step within current voxel
//
for (depth=0; depth<fVoxelDepth; depth++)
for (depth=0; depth<fVoxelDepth; ++depth)
{
targetPoint = localPoint+localDirection*currentDistance;
newDistance = currentDistance;
@@ -599,7 +594,7 @@ G4VoxelNavigation::LocateNextVoxel(const G4ThreeVector& localPoint,
// newHeader=Header for crossed voxel
// newDistance=distance to crossed voxel boundary (along the track)
//
if ( (newNodeNo<0) || (newNodeNo>=newHeader->GetNoSlices()))
if ( (newNodeNo<0) || (newNodeNo>=G4int(newHeader->GetNoSlices())))
{
// Leaving mother volume
//
@@ -623,7 +618,7 @@ G4VoxelNavigation::LocateNextVoxel(const G4ThreeVector& localPoint,
}
else
{
fVoxelDepth++;
++fVoxelDepth;
newHeader = newProxy->GetHeader();
newHeaderAxis = newHeader->GetAxis();
newHeaderNoSlices = newHeader->GetNoSlices();
@@ -639,9 +634,9 @@ G4VoxelNavigation::LocateNextVoxel(const G4ThreeVector& localPoint,
newNodeNo=0;
}
else if ( newNodeNo>=newHeaderNoSlices )
{
newNodeNo = newHeaderNoSlices-1;
}
{
newNodeNo = newHeaderNoSlices-1;
}
// Stack info for stepping
//
fVoxelAxisStack[fVoxelDepth] = newHeaderAxis;
@@ -668,7 +663,7 @@ G4VoxelNavigation::LocateNextVoxel(const G4ThreeVector& localPoint,
G4double
G4VoxelNavigation::ComputeSafety(const G4ThreeVector& localPoint,
const G4NavigationHistory& history,
const G4double maxLength)
const G4double maxLength)
{
G4VPhysicalVolume *motherPhysical, *samplePhysical;
G4LogicalVolume *motherLogical;
@@ -699,7 +694,7 @@ G4VoxelNavigation::ComputeSafety(const G4ThreeVector& localPoint,
{
#ifdef G4DEBUG_NAVIGATION
// Check that point is inside mother volume
EInside insideMother= motherSolid->Inside(localPoint);
EInside insideMother = motherSolid->Inside(localPoint);
if( insideMother == kOutside )
{
@@ -716,8 +711,7 @@ G4VoxelNavigation::ComputeSafety(const G4ThreeVector& localPoint,
message << " Description of solid: " << G4endl
<< *motherSolid << G4endl;
G4Exception("G4VoxelNavigation::ComputeSafety()", "GeomNav0003",
JustWarning, // FatalException,
message);
JustWarning, message);
}
// Following check is NOT for an issue - it is only for information
@@ -763,10 +757,8 @@ G4VoxelNavigation::ComputeSafety(const G4ThreeVector& localPoint,
G4AffineTransform sampleTf(samplePhysical->GetRotation(),
samplePhysical->GetTranslation());
sampleTf.Invert();
const G4ThreeVector samplePoint =
sampleTf.TransformPoint(localPoint);
const G4VSolid *sampleSolid =
samplePhysical->GetLogicalVolume()->GetSolid();
const G4ThreeVector samplePoint = sampleTf.TransformPoint(localPoint);
const G4VSolid* sampleSolid= samplePhysical->GetLogicalVolume()->GetSolid();
G4double sampleSafety = sampleSolid->DistanceToIn(samplePoint);
if ( sampleSafety<ourSafety )
{
@@ -775,7 +767,8 @@ G4VoxelNavigation::ComputeSafety(const G4ThreeVector& localPoint,
#ifdef G4VERBOSE
if( fCheck )
{
fLogger->ComputeSafetyLog(sampleSolid,samplePoint,sampleSafety,false,false);
fLogger->ComputeSafetyLog(sampleSolid, samplePoint,
sampleSafety, false, false);
}
#endif
}
@@ -793,6 +786,6 @@ G4VoxelNavigation::ComputeSafety(const G4ThreeVector& localPoint,
//
void G4VoxelNavigation::SetVerboseLevel(G4int level)
{
if( fLogger ) fLogger->SetVerboseLevel(level);
if( fpVoxelSafety) fpVoxelSafety->SetVerboseLevel( level );
if( fLogger ) fLogger->SetVerboseLevel(level);
if( fpVoxelSafety) fpVoxelSafety->SetVerboseLevel(level);
}
+48 -54
View File
@@ -43,16 +43,11 @@
//
G4VoxelSafety::G4VoxelSafety()
: fBlockList(),
fpMotherLogical(0),
fVoxelDepth(-1),
fVoxelAxisStack(kNavigatorVoxelStackMax,kXAxis),
fVoxelNoSlicesStack(kNavigatorVoxelStackMax,0),
fVoxelSliceWidthStack(kNavigatorVoxelStackMax,0.),
fVoxelNodeNoStack(kNavigatorVoxelStackMax,0),
fVoxelHeaderStack(kNavigatorVoxelStackMax,(G4SmartVoxelHeader*)0),
fVoxelNode(0),
fCheck(false),
fVerbose(0)
fVoxelHeaderStack(kNavigatorVoxelStackMax,(G4SmartVoxelHeader*)nullptr)
{
kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
}
@@ -74,9 +69,9 @@ G4VoxelSafety::~G4VoxelSafety()
// ********************************************************************
//
G4double
G4VoxelSafety::ComputeSafety(const G4ThreeVector& localPoint,
G4VoxelSafety::ComputeSafety(const G4ThreeVector& localPoint,
const G4VPhysicalVolume& currentPhysical,
G4double maxLength)
G4double maxLength)
{
G4LogicalVolume *motherLogical;
G4VSolid *motherSolid;
@@ -88,7 +83,7 @@ G4VoxelSafety::ComputeSafety(const G4ThreeVector& localPoint,
motherLogical = currentPhysical.GetLogicalVolume();
fpMotherLogical= motherLogical; // For use by the other methods
motherSolid = motherLogical->GetSolid();
motherVoxelHeader= motherLogical->GetVoxelHeader();
motherVoxelHeader = motherLogical->GetVoxelHeader();
#ifdef G4VERBOSE
if( fVerbose > 0 )
@@ -99,7 +94,7 @@ G4VoxelSafety::ComputeSafety(const G4ThreeVector& localPoint,
// Check that point is inside mother volume
//
EInside insideMother= motherSolid->Inside(localPoint);
EInside insideMother = motherSolid->Inside(localPoint);
if( insideMother != kInside )
{
#ifdef G4DEBUG_NAVIGATION
@@ -147,7 +142,7 @@ G4VoxelSafety::ComputeSafety(const G4ThreeVector& localPoint,
fVoxelDepth = -1; // Resets the depth -- must be done for next method
daughterSafety= SafetyForVoxelHeader(motherVoxelHeader, localPoint, maxLength,
currentPhysical, 0, ourSafety);
currentPhysical, 0.0, ourSafety);
ourSafety= std::min( motherSafety, daughterSafety );
return ourSafety;
@@ -160,17 +155,17 @@ G4VoxelSafety::ComputeSafety(const G4ThreeVector& localPoint,
// ********************************************************************
//
G4double
G4VoxelSafety::SafetyForVoxelNode( const G4SmartVoxelNode *curVoxelNode,
const G4ThreeVector& localPoint )
G4VoxelSafety::SafetyForVoxelNode( const G4SmartVoxelNode* curVoxelNode,
const G4ThreeVector& localPoint )
{
G4double ourSafety= DBL_MAX;
G4double ourSafety = DBL_MAX;
G4int curNoVolumes, contentNo, sampleNo;
G4VPhysicalVolume *samplePhysical;
G4int curNoVolumes, contentNo, sampleNo;
G4VPhysicalVolume* samplePhysical;
G4double sampleSafety=0.0;
G4double sampleSafety = 0.0;
G4ThreeVector samplePoint;
G4VSolid* ptrSolid=0;
G4VSolid* ptrSolid = nullptr;
curNoVolumes = curVoxelNode->GetNoContained();
@@ -185,15 +180,14 @@ G4VoxelSafety::SafetyForVoxelNode( const G4SmartVoxelNode *curVoxelNode,
G4AffineTransform sampleTf(samplePhysical->GetRotation(),
samplePhysical->GetTranslation());
sampleTf.Invert();
samplePoint = sampleTf.TransformPoint(localPoint);
ptrSolid = samplePhysical->GetLogicalVolume()->GetSolid();
samplePoint = sampleTf.TransformPoint(localPoint);
ptrSolid = samplePhysical->GetLogicalVolume()->GetSolid();
sampleSafety = ptrSolid->DistanceToIn(samplePoint);
ourSafety = std::min( sampleSafety, ourSafety );
ourSafety = std::min( sampleSafety, ourSafety );
#ifdef G4VERBOSE
if(( fCheck ) && ( fVerbose == 1 ))
{
// ReportSolidSafetyToIn( MethodName, solid, value, point );
G4cout << "*** G4VoxelSafety::SafetyForVoxelNode(): ***" << G4endl
<< " Invoked DistanceToIn(p) for daughter solid: "
<< ptrSolid->GetName()
@@ -217,27 +211,27 @@ G4VoxelSafety::SafetyForVoxelNode( const G4SmartVoxelNode *curVoxelNode,
//
G4double
G4VoxelSafety::SafetyForVoxelHeader( const G4SmartVoxelHeader* pHeader,
const G4ThreeVector& localPoint,
G4double maxLength,
const G4ThreeVector& localPoint,
G4double maxLength,
const G4VPhysicalVolume& currentPhysical, //Debug
G4double distUpperDepth_Sq,
G4double previousMinSafety
G4double distUpperDepth_Sq,
G4double previousMinSafety
)
{
const G4SmartVoxelHeader * const targetVoxelHeader=pHeader;
G4SmartVoxelNode *targetVoxelNode=0;
const G4SmartVoxelHeader* const targetVoxelHeader = pHeader;
G4SmartVoxelNode* targetVoxelNode = nullptr;
const G4SmartVoxelProxy *sampleProxy;
const G4SmartVoxelProxy* sampleProxy;
EAxis targetHeaderAxis;
G4double targetHeaderMin, targetHeaderMax, targetHeaderNodeWidth;
G4int targetHeaderNoSlices;
G4int targetNodeNo;
G4double minSafety= previousMinSafety;
G4double ourSafety= DBL_MAX;
G4double minSafety = previousMinSafety;
G4double ourSafety = DBL_MAX;
unsigned int checkedNum= 0;
fVoxelDepth++;
++fVoxelDepth;
// fVoxelDepth set by ComputeSafety or previous level call
targetHeaderAxis = targetVoxelHeader->GetAxis();
@@ -248,10 +242,10 @@ G4VoxelSafety::SafetyForVoxelHeader( const G4SmartVoxelHeader* pHeader,
targetHeaderNodeWidth = (targetHeaderMax-targetHeaderMin)
/ targetHeaderNoSlices;
G4double localCrd= localPoint(targetHeaderAxis);
G4double localCrd = localPoint(targetHeaderAxis);
const G4int candNodeNo= G4int( (localCrd-targetHeaderMin)
/ targetHeaderNodeWidth );
const G4int candNodeNo = G4int( (localCrd-targetHeaderMin)
/ targetHeaderNodeWidth );
// Ensure that it is between 0 and targetHeader->GetMaxExtent() - 1
#ifdef G4DEBUG_VOXELISATION
@@ -314,32 +308,32 @@ G4VoxelSafety::SafetyForVoxelHeader( const G4SmartVoxelHeader* pHeader,
fVoxelHeaderStack[fVoxelDepth] = pHeader;
G4int trialUp= -1, trialDown= -1;
G4double distUp= DBL_MAX, distDown= DBL_MAX;
G4int trialUp = -1, trialDown = -1;
G4double distUp = DBL_MAX, distDown = DBL_MAX;
// Using Equivalent voxels - this is pre-initialisation only
//
G4int nextUp= pointNodeNo+1;
G4int nextDown= pointNodeNo-1;
G4int nextUp = pointNodeNo+1;
G4int nextDown = pointNodeNo-1;
G4int nextNodeNo= pointNodeNo;
G4int nextNodeNo = pointNodeNo;
G4double distAxis; // Distance in current Axis
distAxis= 0.0; // Starting in node containing local Coordinate
distAxis = 0.0; // Starting in node containing local Coordinate
G4bool nextIsInside= false;
G4bool nextIsInside = false;
G4double distMaxInterest= std::min( previousMinSafety, maxLength);
// We will not look beyond this distance.
// This distance will be updated to reflect the
// max ( minSafety, maxLength ) at each step
targetNodeNo= pointNodeNo;
targetNodeNo = pointNodeNo;
do
{
G4double nodeSafety= DBL_MAX, headerSafety= DBL_MAX;
G4double nodeSafety = DBL_MAX, headerSafety = DBL_MAX;
fVoxelNodeNoStack[fVoxelDepth] = targetNodeNo;
checkedNum++;
++checkedNum;
sampleProxy = targetVoxelHeader->GetSlice(targetNodeNo);
@@ -380,12 +374,12 @@ G4VoxelSafety::SafetyForVoxelHeader( const G4SmartVoxelHeader* pHeader,
#endif
ourSafety= std::min( ourSafety, nodeSafety );
trialUp = targetVoxelNode->GetMaxEquivalentSliceNo()+1;
trialUp = targetVoxelNode->GetMaxEquivalentSliceNo()+1;
trialDown = targetVoxelNode->GetMinEquivalentSliceNo()-1;
}
else
{
const G4SmartVoxelHeader *pNewVoxelHeader = sampleProxy->GetHeader();
const G4SmartVoxelHeader* pNewVoxelHeader = sampleProxy->GetHeader();
G4double distCombined_Sq;
distCombined_Sq = distUpperDepth_Sq + distAxis*distAxis;
@@ -409,7 +403,7 @@ G4VoxelSafety::SafetyForVoxelHeader( const G4SmartVoxelHeader* pHeader,
headerSafety= SafetyForVoxelHeader( pNewVoxelHeader, localPoint,
maxLength, currentPhysical,
distCombined_Sq, minSafety);
ourSafety= std::min( ourSafety, headerSafety );
ourSafety = std::min( ourSafety, headerSafety );
#ifdef G4DEBUG_NAVIGATION
if( fVerbose > 2 )
@@ -421,7 +415,7 @@ G4VoxelSafety::SafetyForVoxelHeader( const G4SmartVoxelHeader* pHeader,
trialUp = pNewVoxelHeader->GetMaxEquivalentSliceNo()+1;
trialDown = pNewVoxelHeader->GetMinEquivalentSliceNo()-1;
}
minSafety= std::min( minSafety, ourSafety );
minSafety = std::min( minSafety, ourSafety );
// Find next closest Voxel
// - first try: by simple subtraction
@@ -429,7 +423,7 @@ G4VoxelSafety::SafetyForVoxelHeader( const G4SmartVoxelHeader* pHeader,
//
if( targetNodeNo >= pointNodeNo )
{
nextUp = trialUp;
nextUp = trialUp;
// distUp = std::max( targetHeaderMax-localCrd, 0.0 );
G4double lowerEdgeOfNext = targetHeaderMin
+ nextUp * targetHeaderNodeWidth;
@@ -483,12 +477,12 @@ G4VoxelSafety::SafetyForVoxelHeader( const G4SmartVoxelHeader* pHeader,
#endif
G4bool UpIsClosest;
UpIsClosest= distUp < distDown;
UpIsClosest = distUp < distDown;
if( (nextUp < targetHeaderNoSlices)
&& (UpIsClosest || (nextDown < 0)) )
{
nextNodeNo=nextUp;
nextNodeNo = nextUp;
distAxis = distUp;
++nextUp; // Default
#ifdef G4VERBOSE
@@ -503,7 +497,7 @@ G4VoxelSafety::SafetyForVoxelHeader( const G4SmartVoxelHeader* pHeader,
}
else
{
nextNodeNo=nextDown;
nextNodeNo = nextDown;
distAxis = distDown;
--nextDown; // A default value
#ifdef G4VERBOSE
@@ -524,7 +518,7 @@ G4VoxelSafety::SafetyForVoxelHeader( const G4SmartVoxelHeader* pHeader,
#ifdef G4DEBUG_NAVIGATION
assert( targetVoxelHeader->GetSlice(nextNodeNo) != 0 );
G4bool bContinue= (distAxis<minSafety);
G4bool bContinue = (distAxis<minSafety);
if( !bContinue )
{
if( fVerbose > 2 )