Import Geant4 10.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 11:51:14 +02:00
parent e2d2f9810a
commit 286caacf06
12421 changed files with 730077 additions and 502383 deletions
@@ -25,7 +25,6 @@
//
//
// $Id: G4Transportation.cc 2011/06/10 16:19:46 japost Exp japost $
// GEANT4 tag $Name: not supported by cvs2svn $
//
// ------------------------------------------------------------
// GEANT 4 include file implementation
@@ -64,8 +63,10 @@
#include "G4SystemOfUnits.hh"
#include "G4ProductionCutsTable.hh"
#include "G4ParticleTable.hh"
#include "G4ChordFinder.hh"
#include "G4SafetyHelper.hh"
#include "G4ChargeState.hh"
#include "G4EquationOfMotion.hh"
#include "G4FieldManagerStore.hh"
class G4VSensitiveDetector;
@@ -81,19 +82,17 @@ G4Transportation::G4Transportation( G4int verbosity )
fTransportEndKineticEnergy( 0.0 ),
fTransportEndSpin( 0.0, 0.0, 0.0 ),
fMomentumChanged(true),
fEnergyChanged(false),
fEndGlobalTimeComputed(false),
fCandidateEndGlobalTime(0.0),
fParticleIsLooping( false ),
fGeometryLimitedStep(true),
fPreviousSftOrigin( 0.,0.,0. ),
fPreviousSafety( 0.0 ),
// fParticleChange(),
// fParticleChange(),
fEndPointDistance( -1.0 ),
fThreshold_Warning_Energy( 100 * MeV ),
fThreshold_Important_Energy( 250 * MeV ),
fThresholdTrials( 10 ),
fUnimportant_Energy( 1 * MeV ), // Not used
fNoLooperTrials( 0 ),
fSumEnergyKilled( 0.0 ), fMaxEnergyKilled( 0.0 ),
fShortStepOptimisation( false ), // Old default: true (=fast short steps)
@@ -101,7 +100,7 @@ G4Transportation::G4Transportation( G4int verbosity )
fVerboseLevel( verbosity )
{
// set Process Sub Type
SetProcessSubType(static_cast<int>(TRANSPORTATION));
SetProcessSubType(static_cast<G4int>(TRANSPORTATION));
G4TransportationManager* transportMgr ;
@@ -118,9 +117,10 @@ G4Transportation::G4Transportation( G4int verbosity )
// field and this process. That order is not guaranted.
// Instead later the method DoesGlobalFieldExist() is called
static G4TouchableHandle nullTouchableHandle; // Points to (G4VTouchable*) 0
fCurrentTouchableHandle = nullTouchableHandle;
static G4ThreadLocal G4TouchableHandle* pNullTouchableHandle = 0;
if ( !pNullTouchableHandle) { pNullTouchableHandle = new G4TouchableHandle; }
fCurrentTouchableHandle = *pNullTouchableHandle;
// Points to (G4VTouchable*) 0
#ifdef G4VERBOSE
if( fVerboseLevel > 0)
@@ -136,7 +136,8 @@ G4Transportation::G4Transportation( G4int verbosity )
G4Transportation::~G4Transportation()
{
if( (fVerboseLevel > 0) && (fSumEnergyKilled > 0.0 ) ){
if( (fVerboseLevel > 0) && (fSumEnergyKilled > 0.0 ) )
{
G4cout << " G4Transportation: Statistics for looping particles " << G4endl;
G4cout << " Sum of energy of loopers killed: " << fSumEnergyKilled << G4endl;
G4cout << " Max energy of loopers killed: " << fMaxEnergyKilled << G4endl;
@@ -233,7 +234,7 @@ AlongStepGetPhysicalInteractionLength( const G4Track& track,
gravityOn= ptrField->IsGravityActive();
if( (particleCharge != 0.0)
|| (fUseMagneticMoment && (magneticMoment != 0.0) )
|| (fUseMagneticMoment && (magneticMoment != 0.0) )
|| (gravityOn && (restMass != 0.0) )
)
{
@@ -302,11 +303,20 @@ AlongStepGetPhysicalInteractionLength( const G4Track& track,
G4double momentumMagnitude = pParticle->GetTotalMomentum() ;
G4ThreeVector EndUnitMomentum ;
G4double lengthAlongCurve ;
fFieldPropagator->SetChargeMomentumMass( particleCharge, // in e+ units
momentumMagnitude, // in Mev/c
restMass ) ;
G4ChargeState chargeState(particleCharge, // The charge can change (dynamic)
pParticleDef->GetPDGSpin(),
magneticMoment);
G4EquationOfMotion* equationOfMotion =
(fFieldPropagator->GetChordFinder()->GetIntegrationDriver()->GetStepper())
->GetEquationOfMotion();
// equationOfMotion->SetChargeMomentumMass( particleCharge,
equationOfMotion->SetChargeMomentumMass( chargeState,
momentumMagnitude,
restMass);
G4ThreeVector spin = track.GetPolarization() ;
G4FieldTrack aFieldTrack = G4FieldTrack( startPosition,
track.GetMomentumDirection(),
@@ -326,17 +336,20 @@ AlongStepGetPhysicalInteractionLength( const G4Track& track,
currentSafety,
track.GetVolume() ) ;
fGeometryLimitedStep= lengthAlongCurve < currentMinimumStep;
if( fGeometryLimitedStep ) {
if( fGeometryLimitedStep )
{
geometryStepLength = lengthAlongCurve ;
} else {
}
else
{
geometryStepLength = currentMinimumStep ;
}
// Remember last safety origin & value.
//
fPreviousSftOrigin = startPosition ;
fPreviousSafety = currentSafety ;
fpSafetyHelper->SetCurrentSafety( currentSafety, startPosition);
// Remember last safety origin & value.
//
fPreviousSftOrigin = startPosition ;
fPreviousSafety = currentSafety ;
fpSafetyHelper->SetCurrentSafety( currentSafety, startPosition);
}
else
{
@@ -378,7 +391,7 @@ AlongStepGetPhysicalInteractionLength( const G4Track& track,
G4double startEnergy= track.GetKineticEnergy();
G4double endEnergy= fTransportEndKineticEnergy;
static G4int no_inexact_steps=0, no_large_ediff;
static G4ThreadLocal G4int no_inexact_steps=0, no_large_ediff;
G4double absEdiff = std::fabs(startEnergy- endEnergy);
if( absEdiff > perMillion * endEnergy )
{
@@ -389,29 +402,31 @@ AlongStepGetPhysicalInteractionLength( const G4Track& track,
{
if( std::fabs(startEnergy- endEnergy) > perThousand * endEnergy )
{
static G4int no_warnings= 0, warnModulo=1, moduloFactor= 10;
static G4ThreadLocal G4int no_warnings= 0, warnModulo=1,
moduloFactor= 10;
no_large_ediff ++;
if( (no_large_ediff% warnModulo) == 0 )
{
no_warnings++;
G4cout << "WARNING - G4Transportation::AlongStepGetPIL() "
<< " Energy change in Step is above 1^-3 relative value. " << G4endl
<< " Relative change in 'tracking' step = "
<< std::setw(15) << (endEnergy-startEnergy)/startEnergy << G4endl
<< " Energy change in Step is above 1^-3 relative value. " << G4endl
<< " Relative change in 'tracking' step = "
<< std::setw(15) << (endEnergy-startEnergy)/startEnergy << G4endl
<< " Starting E= " << std::setw(12) << startEnergy / MeV << " MeV " << G4endl
<< " Ending E= " << std::setw(12) << endEnergy / MeV << " MeV " << G4endl;
G4cout << " Energy has been corrected -- however, review"
<< " field propagation parameters for accuracy." << G4endl;
if( (fVerboseLevel > 2 ) || (no_warnings<4) || (no_large_ediff == warnModulo * moduloFactor) ){
G4cout << " These include EpsilonStepMax(/Min) in G4FieldManager "
<< " which determine fractional error per step for integrated quantities. " << G4endl
<< " Note also the influence of the permitted number of integration steps."
<< G4endl;
}
if( (fVerboseLevel > 2 ) || (no_warnings<4) || (no_large_ediff == warnModulo * moduloFactor) )
{
G4cout << " These include EpsilonStepMax(/Min) in G4FieldManager "
<< " which determine fractional error per step for integrated quantities. " << G4endl
<< " Note also the influence of the permitted number of integration steps."
<< G4endl;
}
G4cerr << "ERROR - G4Transportation::AlongStepGetPIL()" << G4endl
<< " Bad 'endpoint'. Energy change detected"
<< " Bad 'endpoint'. Energy change detected"
<< " and corrected. "
<< " Has occurred already "
<< " Has occurred already "
<< no_large_ediff << " times." << G4endl;
if( no_large_ediff == warnModulo * moduloFactor )
{
@@ -437,7 +452,7 @@ AlongStepGetPhysicalInteractionLength( const G4Track& track,
//
if( currentMinimumStep == 0.0 )
{
if( currentSafety == 0.0 ) fGeometryLimitedStep = true ;
if( currentSafety == 0.0 ) { fGeometryLimitedStep = true; }
}
// Update the safety starting from the end-point,
@@ -447,30 +462,32 @@ AlongStepGetPhysicalInteractionLength( const G4Track& track,
{
if( particleCharge != 0.0 )
{
G4double endSafety =
G4double endSafety =
fLinearNavigator->ComputeSafety( fTransportEndPosition) ;
currentSafety = endSafety ;
fPreviousSftOrigin = fTransportEndPosition ;
fPreviousSafety = currentSafety ;
fpSafetyHelper->SetCurrentSafety( currentSafety, fTransportEndPosition);
currentSafety = endSafety ;
fPreviousSftOrigin = fTransportEndPosition ;
fPreviousSafety = currentSafety ;
fpSafetyHelper->SetCurrentSafety( currentSafety, fTransportEndPosition);
// Because the Stepping Manager assumes it is from the start point,
// add the StepLength
//
currentSafety += fEndPointDistance ;
// Because the Stepping Manager assumes it is from the start point,
// add the StepLength
//
currentSafety += fEndPointDistance ;
#ifdef G4DEBUG_TRANSPORT
G4cout.precision(12) ;
G4cout << "***G4Transportation::AlongStepGPIL ** " << G4endl ;
G4cout << " Called Navigator->ComputeSafety at " << fTransportEndPosition
<< " and it returned safety= " << endSafety << G4endl ;
G4cout << " Adding endpoint distance " << fEndPointDistance
<< " to obtain pseudo-safety= " << currentSafety << G4endl ;
}else{
G4cout << "***G4Transportation::AlongStepGPIL ** " << G4endl ;
G4cout.precision(12) ;
G4cout << "***G4Transportation::AlongStepGPIL ** " << G4endl ;
G4cout << " Called Navigator->ComputeSafety at " << fTransportEndPosition
<< " and it returned safety= " << endSafety << G4endl ;
G4cout << " Adding endpoint distance " << fEndPointDistance
<< " to obtain pseudo-safety= " << currentSafety << G4endl ;
}
else
{
G4cout << "***G4Transportation::AlongStepGPIL ** " << G4endl ;
G4cout << " Avoiding call to ComputeSafety : " << G4endl;
G4cout << " charge = " << particleCharge << G4endl;
G4cout << " mag moment = " << magneticMoment << G4endl;
G4cout << " charge = " << particleCharge << G4endl;
G4cout << " mag moment = " << magneticMoment << G4endl;
#endif
}
}
@@ -488,7 +505,7 @@ AlongStepGetPhysicalInteractionLength( const G4Track& track,
G4VParticleChange* G4Transportation::AlongStepDoIt( const G4Track& track,
const G4Step& stepData )
{
static G4int noCalls=0;
static G4ThreadLocal G4int noCalls=0;
noCalls++;
fParticleChange.Initialize(track) ;
@@ -518,7 +535,7 @@ G4VParticleChange* G4Transportation::AlongStepDoIt( const G4Track& track,
G4double stepLength = track.GetStepLength();
deltaTime= 0.0; // in case initialVelocity = 0
if ( initialVelocity > 0.0 ) deltaTime = stepLength/initialVelocity ;
if ( initialVelocity > 0.0 ) { deltaTime = stepLength/initialVelocity; }
fCandidateEndGlobalTime = startTime + deltaTime ;
fParticleChange.ProposeLocalTime( track.GetLocalTime() + deltaTime) ;
@@ -547,41 +564,47 @@ G4VParticleChange* G4Transportation::AlongStepDoIt( const G4Track& track,
G4double endEnergy= fTransportEndKineticEnergy;
if( (endEnergy < fThreshold_Important_Energy)
|| (fNoLooperTrials >= fThresholdTrials ) ){
// Kill the looping particle
//
fParticleChange.ProposeTrackStatus( fStopAndKill ) ;
|| (fNoLooperTrials >= fThresholdTrials ) )
{
// Kill the looping particle
//
fParticleChange.ProposeTrackStatus( fStopAndKill ) ;
// 'Bare' statistics
fSumEnergyKilled += endEnergy;
if( endEnergy > fMaxEnergyKilled) { fMaxEnergyKilled= endEnergy; }
if( endEnergy > fMaxEnergyKilled) { fMaxEnergyKilled= endEnergy; }
#ifdef G4VERBOSE
if( (fVerboseLevel > 1) ||
( endEnergy > fThreshold_Warning_Energy ) ) {
G4cout << " G4Transportation is killing track that is looping or stuck "
<< G4endl
<< " This track has " << track.GetKineticEnergy() / MeV
<< " MeV energy." << G4endl;
G4cout << " Number of trials = " << fNoLooperTrials
<< " No of calls to AlongStepDoIt = " << noCalls
<< G4endl;
}
if( (fVerboseLevel > 1) &&
( endEnergy > fThreshold_Warning_Energy ) )
{
G4cout << " G4Transportation is killing track that is looping or stuck "
<< G4endl
<< " This track has " << track.GetKineticEnergy() / MeV
<< " MeV energy." << G4endl;
G4cout << " Number of trials = " << fNoLooperTrials
<< " No of calls to AlongStepDoIt = " << noCalls
<< G4endl;
}
#endif
fNoLooperTrials=0;
fNoLooperTrials=0;
}
else{
fNoLooperTrials ++;
else
{
fNoLooperTrials ++;
#ifdef G4VERBOSE
if( (fVerboseLevel > 2) ){
G4cout << " G4Transportation::AlongStepDoIt(): Particle looping - "
<< " Number of trials = " << fNoLooperTrials
<< " No of calls to = " << noCalls
<< G4endl;
}
if( (fVerboseLevel > 2) )
{
G4cout << " G4Transportation::AlongStepDoIt(): Particle looping - "
<< " Number of trials = " << fNoLooperTrials
<< " No of calls to = " << noCalls
<< G4endl;
}
#endif
}
}else{
}
else
{
fNoLooperTrials=0;
}
@@ -657,13 +680,15 @@ G4VParticleChange* G4Transportation::PostStepDoIt( const G4Track& track,
#ifdef G4DEBUG_TRANSPORT
// Checking first implementation of flagging Last Step in Volume
//
G4bool exiting = fLinearNavigator->ExitedMotherVolume();
G4bool entering = fLinearNavigator->EnteredDaughterVolume();
if( ! (exiting || entering) ) {
G4cout << " Transport> : Proposed isLastStep= " << isLastStep
<< " Exiting " << fLinearNavigator->ExitedMotherVolume()
<< " Entering " << fLinearNavigator->EnteredDaughterVolume()
<< G4endl;
if( ! (exiting || entering) )
{
G4cout << " Transport> : Proposed isLastStep= " << isLastStep
<< " Exiting " << fLinearNavigator->ExitedMotherVolume()
<< " Entering " << fLinearNavigator->EnteredDaughterVolume()
<< G4endl;
}
#endif
}
@@ -682,10 +707,12 @@ G4VParticleChange* G4Transportation::PostStepDoIt( const G4Track& track,
retCurrentTouchable = track.GetTouchableHandle() ;
isLastStep= false;
#ifdef G4DEBUG_TRANSPORT
// Checking first implementation of flagging Last Step in Volume
//
G4cout << " Transport> Proposed isLastStep= " << isLastStep
<< " Geometry did not limit step. " << G4endl;
<< " Geometry did not limit step. " << G4endl;
#endif
} // endif ( fGeometryLimitedStep )
@@ -743,8 +770,8 @@ G4Transportation::StartTracking(G4Track* aTrack)
{
G4VProcess::StartTracking(aTrack);
// The actions here are those that were taken in AlongStepGPIL
// when track.GetCurrentStepNumber()==1
// The actions here are those that were taken in AlongStepGPIL
// when track.GetCurrentStepNumber()==1
// reset safety value and center
//
@@ -759,7 +786,8 @@ G4Transportation::StartTracking(G4Track* aTrack)
// ChordFinder reset internal state
//
if( DoesGlobalFieldExist() ) {
if( DoesGlobalFieldExist() )
{
fFieldPropagator->ClearPropagatorState();
// Resets all state of field propagator class (ONLY)
// including safety values (in case of overlaps and to wipe for first track).
@@ -769,11 +797,11 @@ G4Transportation::StartTracking(G4Track* aTrack)
}
// Make sure to clear the chord finders of all fields (ie managers)
static G4FieldManagerStore* fieldMgrStore= G4FieldManagerStore::GetInstance();
//
G4FieldManagerStore* fieldMgrStore = G4FieldManagerStore::GetInstance();
fieldMgrStore->ClearAllChordFindersState();
// Update the current touchable handle (from the track's)
//
fCurrentTouchableHandle = aTrack->GetTouchableHandle();
}