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
+36
View File
@@ -16,6 +16,42 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
Nov 1st 2019, J.Apostolakis transport-V10-05-02
----------------------------
- Optimisation in G4Transportation and G4CoupledTransportation:
Avoid calling user field manager's ConfigureForTrack method,
except if particle is charged, or forces from magnetic moment
or gravity are enabled.
* Introduces new common 'flag' in G4(Coupled)Transportation
to enable gravity fields.
The following static method must be called if the application uses
gravity fields:
G4Transportation::EnableGravity(G4bool useGravity)
- Added flag in G4Transportation/G4CoupledTransportation to
silence warning about looping tracks.
Aug 15th 2019, D.Sorokin transport-V10-05-01
------------------------
- Enable relaxing of delta chord condition (to reduce looping particle
issue) for tracks below 'important' energy threshold.
Aug 15th 2019, J.Apostolakis transport-V10-05-00
----------------------------
- G4Transportation and G4CoupledTransportation: fix issues related to
resetting of looper flag and other state for field propagation.
* Replaced check for 'Global' field with check for any field.
This is needed to ensure that propagator-in-field state is
reset when the setup inludes only local fields.
* Ensure that looping flag is reset (false) when a force is not exerted
in G4CoupledTransportation::AlongStepGetPhysicalInteractionLength
( Before it was overwritten afterwards. )
Addresses bugzilla Problem report 2144.
Thanks to Richard T. Jones (U. Conn) and Laurie Nevay (RHUL) of the
GlueX experiment team.
Nov 9th 2018, J.Apostolakis transport-V10-04-13
----------------------------
- G4Transportation and G4CoupledTransportation:
@@ -125,9 +125,16 @@ class G4CoupledTransportation : public G4VProcess
inline void ResetKilledStatistics( G4int report = 1);
// Statistics for tracks killed (currently due to looping in field)
static G4bool EnableUseMagneticMoment(G4bool useMoment=true);
static G4bool EnableMagneticMoment(G4bool useMoment=true);
// Whether to deflect particles with force due to magnetic moment
static G4bool EnableGravity(G4bool useGravity);
// Turn on the capability to deflect particles with a gravity field
static void SetSilenceLooperWarnings( G4bool val);
// Do not warn (or throw exception) about 'looping' particles
static G4bool GetSilenceLooperWarnings();
static void SetSignifyStepsInAnyVolume( G4bool anyVol )
{ fSignifyStepInAnyVolume = anyVol; }
static G4bool GetSignifyStepsInAnyVolume()
@@ -148,6 +155,10 @@ class G4CoupledTransportation : public G4VProcess
void StartTracking(G4Track* aTrack);
void EndTracking();
static G4bool EnableUseMagneticMoment(G4bool useMoment=true)
{ return EnableMagneticMoment(useMoment); }
// Old name ... obsolete
G4double AtRestGetPhysicalInteractionLength( const G4Track& ,
G4ForceCondition* )
@@ -160,8 +171,9 @@ class G4CoupledTransportation : public G4VProcess
protected:
G4bool DoesGlobalFieldExist();
// Checks whether a field exists for the "global" field manager
G4bool DoesAnyFieldExist();
// Check whether any field exists in the geometry
// - replaces method that checked only whether a field for the world volume
void ReportInexactEnergy(G4double startEnergy, G4double endEnergy);
// Issue warning
@@ -183,7 +195,7 @@ class G4CoupledTransportation : public G4VProcess
G4PropagatorInField* fFieldPropagator;
// Still required in order to find/set the fieldmanager
G4bool fGlobalFieldExists;
G4bool fAnyFieldExists;
// G4bool fStartedNewTrack; // True for first step or restarted tracking
// until first step's AlongStepGPIL
@@ -257,6 +269,8 @@ class G4CoupledTransportation : public G4VProcess
friend class G4Transportation;
static G4bool fUseMagneticMoment;
static G4bool fUseGravity;
static G4bool fSilenceLooperWarnings; // Flag to *Supress* all 'looper' warnings
private:
@@ -34,6 +34,7 @@
#include <CLHEP/Units/SystemOfUnits.h>
#include "G4TransportationLogger.hh"
#include "G4FieldManagerStore.hh"
inline void G4CoupledTransportation::
SetPropagatorInField( G4PropagatorInField* pFieldPropagator)
@@ -46,11 +47,10 @@ inline G4PropagatorInField* G4CoupledTransportation::GetPropagatorInField()
return fFieldPropagator;
}
inline G4bool G4CoupledTransportation::DoesGlobalFieldExist()
inline G4bool G4CoupledTransportation::DoesAnyFieldExist()
{
G4TransportationManager* transportMgr;
transportMgr= G4TransportationManager::GetTransportationManager();
return transportMgr->GetFieldManager()->DoesFieldExist();
G4FieldManagerStore* fieldMgrStore= G4FieldManagerStore::GetInstance();
return fieldMgrStore->size() > 0;
}
inline G4double G4CoupledTransportation::GetThresholdWarningEnergy() const
@@ -115,7 +115,7 @@ class G4Transportation : public G4VProcess
void SetLowLooperThresholds(); // Set low thresholds - for low-E applications
void PushThresholdsToLogger(); // Inform logger of current thresholds
void ReportLooperThresholds(); // Print values of looper thresholds
inline G4double GetMaxEnergyKilled() const;
inline G4double GetSumEnergyKilled() const;
inline void ResetKilledStatistics( G4int report = 1);
@@ -124,9 +124,20 @@ class G4Transportation : public G4VProcess
inline void EnableShortStepOptimisation(G4bool optimise=true);
// Whether short steps < safety will avoid to call Navigator (if field=0)
static G4bool EnableUseMagneticMoment(G4bool useMoment=true);
// Whether to deflect particles with force due to magnetic moment
static G4bool EnableMagneticMoment(G4bool useMoment=true);
// Whether to enable particles to be deflected with force due to magnetic moment
static G4bool EnableGravity(G4bool useGravity=true);
// Whether to enable particles to be deflected with force due to gravity
static void SetSilenceLooperWarnings( G4bool val);
// Do not warn (or throw exception) about 'looping' particles
static G4bool GetSilenceLooperWarnings();
public: // without description
static G4bool EnableUseMagneticMoment(G4bool useMoment=true)
{ return EnableMagneticMoment(useMoment); } // Old name - will be deprecated
public: // without description
G4double AtRestGetPhysicalInteractionLength( const G4Track&,
@@ -144,9 +155,10 @@ class G4Transportation : public G4VProcess
protected:
G4bool DoesGlobalFieldExist();
// Checks whether a field exists for the "global" field manager
G4bool DoesAnyFieldExist();
// Check whether any field exists in the geometry
// - replaces method that checked only whether a field for the world volume
void ReportMissingLogger(const char * methodName);
private:
@@ -164,6 +176,8 @@ class G4Transportation : public G4VProcess
G4double fCandidateEndGlobalTime= 0.0;
// The particle's state after this Step, Store for DoIt
G4bool fAnyFieldExists= false;
G4bool fParticleIsLooping = false;
G4bool fNewTrack= true; // Flag from StartTracking
G4bool fFirstStepInVolume= true;
@@ -194,7 +208,6 @@ class G4Transportation : public G4VProcess
// *NOT* be abandoned, except after fThresholdTrials attempts.
G4int fAbandonUnstableTrials = 0; // Number of trials after which to abandon
// unstable loopers ( 0 = never )
// Counter for steps in which particle reports 'looping',
// ( Used if it is above 'Important' Energy. )
G4int fNoLooperTrials= 0;
@@ -226,6 +239,9 @@ class G4Transportation : public G4VProcess
friend class G4CoupledTransportation;
static G4bool fUseMagneticMoment;
static G4bool fUseGravity;
static G4bool fSilenceLooperWarnings; // Flag to *Supress* all 'looper' warnings
};
#include "G4Transportation.icc"
@@ -35,6 +35,7 @@
#include <CLHEP/Units/SystemOfUnits.h>
#include "G4TransportationLogger.hh"
#include "G4FieldManagerStore.hh"
inline void
G4Transportation::SetPropagatorInField( G4PropagatorInField* pFieldPropagator)
@@ -47,14 +48,10 @@ inline G4PropagatorInField* G4Transportation::GetPropagatorInField()
return fFieldPropagator;
}
inline G4bool G4Transportation::DoesGlobalFieldExist()
inline G4bool G4Transportation::DoesAnyFieldExist()
{
G4TransportationManager* transportMgr;
transportMgr= G4TransportationManager::GetTransportationManager();
// fFieldExists= transportMgr->GetFieldManager()->DoesFieldExist();
// return fFieldExists;
return transportMgr->GetFieldManager()->DoesFieldExist();
G4FieldManagerStore* fieldMgrStore= G4FieldManagerStore::GetInstance();
return fieldMgrStore->size() > 0;
}
inline G4double G4Transportation::GetThresholdWarningEnergy() const
@@ -53,6 +53,8 @@ G4bool G4CoupledTransportation::fSignifyStepInAnyVolume= false;
// This mode must apply to all threads
G4bool G4CoupledTransportation::fUseMagneticMoment=false;
G4bool G4CoupledTransportation::fUseGravity= false;
G4bool G4CoupledTransportation::fSilenceLooperWarnings= false;
//////////////////////////////////////////////////////////////////////////
//
// Constructor
@@ -115,8 +117,7 @@ G4CoupledTransportation::G4CoupledTransportation( G4int verbosity )
fCurrentTouchableHandle = *pNullTouchableHandle;
// Points to (G4VTouchable*) 0
G4FieldManager *globalFieldMgr= transportMgr->GetFieldManager();
fGlobalFieldExists= globalFieldMgr ? globalFieldMgr->GetDetectorField() : 0 ;
fAnyFieldExists= DoesAnyFieldExist();
}
//////////////////////////////////////////////////////////////////////////
@@ -259,34 +260,32 @@ AlongStepGetPhysicalInteractionLength( const G4Track& track,
// Check if the particle has a force, EM or gravitational, exerted on it
//
G4FieldManager* fieldMgr=0;
G4FieldManager* fieldMgr= nullptr;
G4bool fieldExertsForce = false ;
G4bool gravityOn = false;
const G4Field* ptrField= 0;
const G4Field* ptrField= nullptr;
fieldMgr = fFieldPropagator->FindAndSetFieldManager( track.GetVolume() );
if( fieldMgr != 0 )
G4bool eligibleEM = (particleCharge != 0.0)
|| ( fUseMagneticMoment && (magneticMoment != 0.0) );
G4bool eligibleGrav = fUseGravity && (restMass != 0.0) ;
if( (fieldMgr!=nullptr) && (eligibleEM||eligibleGrav) )
{
// Message the field Manager, to configure it for this track
//
fieldMgr->ConfigureForTrack( &track );
// Here it can transition from a null field-ptr to a finite field.
// The above call can transition from a null field-ptr oto a finite field.
// If the field manager has no field ptr, the field is zero
// by definition ( = there is no field ! )
//
ptrField= fieldMgr->GetDetectorField();
if( ptrField != 0)
if( ptrField != nullptr)
{
gravityOn= ptrField->IsGravityActive();
if( (particleCharge != 0.0)
|| (fUseMagneticMoment && (magneticMoment != 0.0) )
|| (gravityOn && (restMass != 0.0)) )
{
fieldExertsForce = true;
}
fieldExertsForce = eligibleEM
|| ( eligibleGrav && ptrField->IsGravityActive() );
}
}
G4double momentumMagnitude = pParticle->GetTotalMomentum() ;
@@ -434,6 +433,7 @@ AlongStepGetPhysicalInteractionLength( const G4Track& track,
}
else
{
fParticleIsLooping = fFieldPropagator->IsParticleLooping() ;
#ifdef G4DEBUG_TRANSPORT
if( verboseLevel > 1 )
@@ -484,13 +484,11 @@ AlongStepGetPhysicalInteractionLength( const G4Track& track,
// Correct the energy for fields that conserve it
// This - hides the integration error
// - but gives a better physical answer
fTransportEndKineticEnergy= track.GetKineticEnergy();
fTransportEndKineticEnergy= track.GetKineticEnergy();
}
}
fEndpointDistance = (fTransportEndPosition - startPosition).mag() ;
fParticleIsLooping = fFieldPropagator->IsParticleLooping() ;
fTransportEndSpin = endTrackState.GetSpin();
// Calculate the safety
@@ -677,7 +675,7 @@ G4CoupledTransportation::AlongStepDoIt( const G4Track& track,
}
}
if( endEnergy > fThreshold_Warning_Energy )
if( endEnergy > fThreshold_Warning_Energy && ! fSilenceLooperWarnings )
{
fpLogger->ReportLoopingTrack( track, stepData, fNoLooperTrials,
noCallsCT_ASDI, methodName );
@@ -696,7 +694,7 @@ G4CoupledTransportation::AlongStepDoIt( const G4Track& track,
fSumEnergyUnstableSaved += endEnergy;
}
#ifdef G4VERBOSE
if( verboseLevel > 2 )
if( verboseLevel > 2 && ! fSilenceLooperWarnings )
{
G4cout << " ** G4CoupledTransportation::AlongStepDoIt():"
<< " Particle is looping but is saved ..." << G4endl
@@ -957,8 +955,8 @@ G4CoupledTransportation::StartTracking(G4Track* aTrack)
fPathFinder->PrepareNewTrack( position, direction);
// This implies a call to fPathFinder->Locate( position, direction );
// Global field, if any, must exist before tracking is started
fGlobalFieldExists= DoesGlobalFieldExist();
// Whether field exists should be determined at run level -- TODO
fAnyFieldExists= DoesAnyFieldExist();
// reset safety value and center
//
@@ -975,7 +973,7 @@ G4CoupledTransportation::StartTracking(G4Track* aTrack)
// ChordFinder reset internal state
//
if( fGlobalFieldExists )
if( fFieldPropagator && fAnyFieldExists )
{
fFieldPropagator->ClearPropagatorState();
// Resets safety values, in case of overlaps.
@@ -1064,7 +1062,7 @@ ReportInexactEnergy(G4double startEnergy, G4double endEnergy)
/////////////////////////////////////////////////////////////////////////////
G4bool G4CoupledTransportation::EnableUseMagneticMoment(G4bool useMoment)
G4bool G4CoupledTransportation::EnableMagneticMoment(G4bool useMoment)
{
G4bool lastValue= fUseMagneticMoment;
fUseMagneticMoment= useMoment;
@@ -1072,6 +1070,34 @@ G4bool G4CoupledTransportation::EnableUseMagneticMoment(G4bool useMoment)
return lastValue;
}
/////////////////////////////////////////////////////////////////////////////
//
G4bool G4CoupledTransportation::EnableGravity(G4bool useGravity)
{
G4bool lastValue= fUseGravity;
fUseGravity= useGravity;
G4Transportation::fUseGravity= useGravity;
return lastValue;
}
/////////////////////////////////////////////////////////////////////////////
//
// Supress (or not) warnings about 'looping' particles
void G4CoupledTransportation::SetSilenceLooperWarnings( G4bool val)
{
fSilenceLooperWarnings= val; // Flag to *Supress* all 'looper' warnings
// G4CoupledTransportation::fSilenceLooperWarnings= val;
}
/////////////////////////////////////////////////////////////////////////////
//
G4bool G4CoupledTransportation::GetSilenceLooperWarnings()
{
return fSilenceLooperWarnings;
}
/////////////////////////////////////////////////////////////////////////////
//
void G4CoupledTransportation::SetHighLooperThresholds()
@@ -59,6 +59,8 @@
class G4VSensitiveDetector;
G4bool G4Transportation::fUseMagneticMoment=false;
G4bool G4Transportation::fUseGravity= false;
G4bool G4Transportation::fSilenceLooperWarnings= false;
//////////////////////////////////////////////////////////////////////////
//
@@ -66,18 +68,6 @@ G4bool G4Transportation::fUseMagneticMoment=false;
G4Transportation::G4Transportation( G4int verbosity )
: G4VProcess( G4String("Transportation"), fTransportation ),
// fTransportEndPosition( 0.0, 0.0, 0.0 ),
// fTransportEndMomentumDir( 0.0, 0.0, 0.0 ),
// fTransportEndKineticEnergy( 0.0 ),
// fTransportEndSpin( 0.0, 0.0, 0.0 ),
// fMomentumChanged(true),
// fEndGlobalTimeComputed(false),
// fCandidateEndGlobalTime(0.0),
// fParticleIsLooping( false ),
// fNewTrack( true ),
// fFirstStepInVolume( true ),
// fLastStepInVolume( false ),
// fGeometryLimitedStep(true),
fFieldExertedForce( false ),
fPreviousSftOrigin( 0.,0.,0. ),
fPreviousSafety( 0.0 ),
@@ -109,8 +99,10 @@ G4Transportation::G4Transportation( G4int verbosity )
// Cannot determine whether a field exists here, as it would
// depend on the relative order of creating the detector's
// field and this process. That order is not guaranted.
// Instead later the method DoesGlobalFieldExist() is called
fAnyFieldExists= DoesAnyFieldExist();
// This value must be updated using DoesAnyFieldExist() at least at the
// start of each Run -- for now this is at the Start of every Track. TODO
static G4ThreadLocal G4TouchableHandle* pNullTouchableHandle = 0;
if ( !pNullTouchableHandle)
{
@@ -119,6 +111,7 @@ G4Transportation::G4Transportation( G4int verbosity )
fCurrentTouchableHandle = *pNullTouchableHandle;
// Points to (G4VTouchable*) 0
#ifdef G4VERBOSE
if( verboseLevel > 0)
{
@@ -251,34 +244,28 @@ AlongStepGetPhysicalInteractionLength( const G4Track& track,
G4FieldManager* fieldMgr=0;
G4bool fieldExertsForce = false ;
G4bool gravityOn = false;
G4bool fieldExists = false; // Field is not 0 (null pointer)
fieldMgr = fFieldPropagator->FindAndSetFieldManager( track.GetVolume() );
if( fieldMgr != 0 )
G4bool eligibleEM = (particleCharge != 0.0)
|| ( fUseMagneticMoment && (magneticMoment != 0.0) );
G4bool eligibleGrav = fUseGravity && (restMass != 0.0) ;
if( (fieldMgr!=nullptr) && (eligibleEM||eligibleGrav) )
{
// Message the field Manager, to configure it for this track
//
// User can configure the field Manager for this track
fieldMgr->ConfigureForTrack( &track );
// Is here to allow a transition from no-field pointer
// Called here to allow a transition from no-field pointer
// to finite field (non-zero pointer).
// If the field manager has no field ptr, the field is zero
// by definition ( = there is no field ! )
//
const G4Field* ptrField= fieldMgr->GetDetectorField();
fieldExists = (ptrField!=0) ;
if( fieldExists )
// by definition ( = there is no field ! )
const G4Field* ptrField= fieldMgr->GetDetectorField();
if( ptrField )
{
gravityOn= ptrField->IsGravityActive();
if( (particleCharge != 0.0)
|| (fUseMagneticMoment && (magneticMoment != 0.0) )
|| (gravityOn && (restMass != 0.0) ) )
{
fieldExertsForce = fieldExists;
}
fieldExertsForce = eligibleEM
|| ( eligibleGrav && ptrField->IsGravityActive() );
}
// || (gravityOn && (restMass != 0.0)) )
}
fFieldExertedForce = fieldExertsForce;
@@ -371,7 +358,8 @@ AlongStepGetPhysicalInteractionLength( const G4Track& track,
lengthAlongCurve = fFieldPropagator->ComputeStep( aFieldTrack,
currentMinimumStep,
currentSafety,
track.GetVolume() );
track.GetVolume(),
track.GetKineticEnergy() < fThreshold_Important_Energy );
fGeometryLimitedStep= fFieldPropagator->IsLastStepInVolume();
//
@@ -397,6 +385,10 @@ AlongStepGetPhysicalInteractionLength( const G4Track& track,
//
fTransportEndPosition = aFieldTrack.GetPosition() ;
fTransportEndSpin = aFieldTrack.GetSpin();
fParticleIsLooping = fFieldPropagator->IsParticleLooping() ;
fEndPointDistance = (fTransportEndPosition - startPosition).mag() ;
// Momentum: Magnitude and direction can be changed too now ...
//
fMomentumChanged = true ;
@@ -484,9 +476,6 @@ AlongStepGetPhysicalInteractionLength( const G4Track& track,
fTransportEndKineticEnergy= track.GetKineticEnergy();
}
fTransportEndSpin = aFieldTrack.GetSpin();
fParticleIsLooping = fFieldPropagator->IsParticleLooping() ;
fEndPointDistance = (fTransportEndPosition - startPosition).mag() ;
}
// If we are asked to go a step length of 0, and we are on a boundary
@@ -643,7 +632,7 @@ G4VParticleChange* G4Transportation::AlongStepDoIt( const G4Track& track,
}
}
if( endEnergy > fThreshold_Warning_Energy )
if( endEnergy > fThreshold_Warning_Energy && ! fSilenceLooperWarnings )
{
fpLogger->ReportLoopingTrack( track, stepData, fNoLooperTrials,
noCallsASDI, methodName );
@@ -659,7 +648,7 @@ G4VParticleChange* G4Transportation::AlongStepDoIt( const G4Track& track,
fSumEnergyUnstableSaved += endEnergy;
}
#ifdef G4VERBOSE
if( verboseLevel > 2 )
if( verboseLevel > 2 && ! fSilenceLooperWarnings )
{
G4cout << " " << methodName
<< " Particle is looping but is saved ..." << G4endl
@@ -828,6 +817,9 @@ G4Transportation::StartTracking(G4Track* aTrack)
// The actions here are those that were taken in AlongStepGPIL
// when track.GetCurrentStepNumber()==1
// Whether field exists should be determined at run level -- TODO
fAnyFieldExists= DoesAnyFieldExist();
// reset safety value and center
//
fPreviousSafety = 0.0 ;
@@ -841,7 +833,7 @@ G4Transportation::StartTracking(G4Track* aTrack)
// ChordFinder reset internal state
//
if( DoesGlobalFieldExist() )
if( fFieldPropagator && fAnyFieldExists )
{
fFieldPropagator->ClearPropagatorState();
// Resets all state of field propagator class (ONLY) including safety
@@ -865,7 +857,7 @@ G4Transportation::StartTracking(G4Track* aTrack)
/////////////////////////////////////////////////////////////////////////////
//
G4bool G4Transportation::EnableUseMagneticMoment(G4bool useMoment)
G4bool G4Transportation::EnableMagneticMoment(G4bool useMoment)
{
G4bool lastValue= fUseMagneticMoment;
fUseMagneticMoment= useMoment;
@@ -873,6 +865,35 @@ G4bool G4Transportation::EnableUseMagneticMoment(G4bool useMoment)
return lastValue;
}
/////////////////////////////////////////////////////////////////////////////
//
G4bool G4Transportation::EnableGravity(G4bool useGravity)
{
G4bool lastValue= fUseGravity;
fUseGravity= useGravity;
G4CoupledTransportation::fUseGravity= useGravity;
return lastValue;
}
/////////////////////////////////////////////////////////////////////////////
//
// Supress (or not) warnings about 'looping' particles
void G4Transportation::SetSilenceLooperWarnings( G4bool val)
{
fSilenceLooperWarnings= val; // Flag to *Supress* all 'looper' warnings
// G4CoupledTransportation::fSilenceLooperWarnings= val;
}
/////////////////////////////////////////////////////////////////////////////
//
G4bool G4Transportation::GetSilenceLooperWarnings()
{
return fSilenceLooperWarnings;
}
/////////////////////////////////////////////////////////////////////////////
//
void G4Transportation::SetHighLooperThresholds()