Import Geant4 9.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 15:37:50 +02:00
parent a8e9364cea
commit 96c8bcd0af
6923 changed files with 198390 additions and 41849 deletions
@@ -24,7 +24,7 @@
// ********************************************************************
//
// $Id: G4DummyModel.cc,v 1.3 2007/05/22 17:31:58 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-00 $
// GEANT4 tag $Name: geant4-09-01 $
//
// -------------------------------------------------------------------
//
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmCalculator.cc,v 1.36 2007/03/15 12:34:47 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-00 $
// $Id: G4EmCalculator.cc,v 1.37 2007/08/16 15:55:42 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
// -------------------------------------------------------------------
//
@@ -797,7 +797,12 @@ const G4Material* G4EmCalculator::FindMaterial(const G4String& name)
const G4Region* G4EmCalculator::FindRegion(const G4String& reg)
{
return G4RegionStore::GetInstance()->GetRegion(reg);
const G4Region* r = 0;
if(reg != "" || reg != "world")
r = G4RegionStore::GetInstance()->GetRegion(reg);
else
r = G4RegionStore::GetInstance()->GetRegion("DefaultRegionForTheWorld");
return r;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -24,7 +24,7 @@
// ********************************************************************
//
// $Id: G4EmCorrections.cc,v 1.22 2007/05/18 18:39:55 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-00 $
// GEANT4 tag $Name: geant4-09-01 $
//
// -------------------------------------------------------------------
//
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmModelManager.cc,v 1.39 2007/04/12 11:55:07 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-00 $
// $Id: G4EmModelManager.cc,v 1.40 2007/11/09 11:35:54 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
// -------------------------------------------------------------------
//
@@ -74,18 +74,6 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#include "G4EmModelManager.hh"
#include "G4LossTableManager.hh"
#include "G4Step.hh"
#include "G4ParticleDefinition.hh"
#include "G4DataVector.hh"
#include "G4PhysicsVector.hh"
#include "G4Gamma.hh"
#include "G4Positron.hh"
#include "G4MaterialCutsCouple.hh"
#include "G4ProductionCutsTable.hh"
#include "G4Region.hh"
#include "G4RegionStore.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -110,6 +98,21 @@ G4RegionModels::~G4RegionModels()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#include "G4LossTableManager.hh"
#include "G4Step.hh"
#include "G4ParticleDefinition.hh"
#include "G4PhysicsVector.hh"
#include "G4Gamma.hh"
#include "G4Positron.hh"
#include "G4MaterialCutsCouple.hh"
#include "G4ProductionCutsTable.hh"
#include "G4Region.hh"
#include "G4RegionStore.hh"
#include "G4Gamma.hh"
#include "G4Positron.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4EmModelManager::G4EmModelManager():
nEmModels(0),
nRegions(0),
@@ -127,6 +130,8 @@ G4EmModelManager::G4EmModelManager():
upperEkin.clear();
maxCutInRange = 12.*cm;
maxSubCutInRange = 0.7*mm;
theGamma = G4Gamma::Gamma();
thePositron = G4Positron::Positron();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -408,9 +413,9 @@ const G4DataVector* G4EmModelManager::Initialise(const G4ParticleDefinition* p,
G4double subcut = DBL_MAX;
if(secondaryParticle) {
size_t idx = 1;
if( secondaryParticle == G4Gamma::Gamma() ) idx = 0;
if( secondaryParticle == theGamma ) idx = 0;
cut = (*theCoupleTable->GetEnergyCutsVector(idx))[i];
if( secondaryParticle == G4Positron::Positron() && cut < DBL_MAX )
if( secondaryParticle == thePositron && cut < DBL_MAX )
cut += (*theCoupleTable->GetEnergyCutsVector(2))[i] +
2.0*electron_mass_c2;
@@ -24,7 +24,7 @@
// ********************************************************************
//
// $Id: G4EmMultiModel.cc,v 1.6 2007/05/22 17:31:58 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-00 $
// GEANT4 tag $Name: geant4-09-01 $
//
// -------------------------------------------------------------------
//
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmProcessOptions.cc,v 1.21 2007/05/18 18:39:55 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-00 $
// $Id: G4EmProcessOptions.cc,v 1.22 2007/11/07 18:38:49 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
// -------------------------------------------------------------------
//
@@ -76,6 +76,7 @@ G4EmProcessOptions::~G4EmProcessOptions()
void G4EmProcessOptions::SetLossFluctuations(G4bool val)
{
theManager->SetLossFluctuations(val);
const std::vector<G4VEnergyLossProcess*>& v =
theManager->GetEnergyLossProcessVector();
std::vector<G4VEnergyLossProcess*>::const_iterator itr;
@@ -89,6 +90,7 @@ void G4EmProcessOptions::SetLossFluctuations(G4bool val)
void G4EmProcessOptions::SetSubCutoff(G4bool val, const G4Region* r)
{
theManager->SetSubCutoff(val);
const std::vector<G4VEnergyLossProcess*>& v =
theManager->GetEnergyLossProcessVector();
std::vector<G4VEnergyLossProcess*>::const_iterator itr;
@@ -102,6 +104,7 @@ void G4EmProcessOptions::SetSubCutoff(G4bool val, const G4Region* r)
void G4EmProcessOptions::SetIntegral(G4bool val)
{
theManager->SetIntegral(val);
const std::vector<G4VEnergyLossProcess*>& v =
theManager->GetEnergyLossProcessVector();
std::vector<G4VEnergyLossProcess*>::const_iterator itr;
@@ -115,6 +118,7 @@ void G4EmProcessOptions::SetIntegral(G4bool val)
void G4EmProcessOptions::SetMinSubRange(G4double val)
{
theManager->SetMinSubRange(val);
const std::vector<G4VEnergyLossProcess*>& v =
theManager->GetEnergyLossProcessVector();
std::vector<G4VEnergyLossProcess*>::const_iterator itr;
@@ -128,6 +132,7 @@ void G4EmProcessOptions::SetMinSubRange(G4double val)
void G4EmProcessOptions::SetMinEnergy(G4double val)
{
theManager->SetMinEnergy(val);
const std::vector<G4VEnergyLossProcess*>& v =
theManager->GetEnergyLossProcessVector();
std::vector<G4VEnergyLossProcess*>::const_iterator itr;
@@ -155,6 +160,7 @@ void G4EmProcessOptions::SetMinEnergy(G4double val)
void G4EmProcessOptions::SetMaxEnergy(G4double val)
{
theManager->SetMaxEnergy(val);
const std::vector<G4VEnergyLossProcess*>& v =
theManager->GetEnergyLossProcessVector();
std::vector<G4VEnergyLossProcess*>::const_iterator itr;
@@ -182,6 +188,7 @@ void G4EmProcessOptions::SetMaxEnergy(G4double val)
void G4EmProcessOptions::SetMaxEnergyForCSDARange(G4double val)
{
theManager->SetMaxEnergyForCSDARange(val);
const std::vector<G4VEnergyLossProcess*>& v =
theManager->GetEnergyLossProcessVector();
std::vector<G4VEnergyLossProcess*>::const_iterator itr;
@@ -195,6 +202,7 @@ void G4EmProcessOptions::SetMaxEnergyForCSDARange(G4double val)
void G4EmProcessOptions::SetMaxEnergyForMuons(G4double val)
{
theManager->SetMaxEnergyForMuons(val);
const std::vector<G4VEnergyLossProcess*>& v =
theManager->GetEnergyLossProcessVector();
std::vector<G4VEnergyLossProcess*>::const_iterator itr;
@@ -227,13 +235,13 @@ void G4EmProcessOptions::SetMaxEnergyForMuons(G4double val)
}
}
*/
theManager->SetMaxEnergyForMuons(val);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4EmProcessOptions::SetDEDXBinning(G4int val)
{
theManager->SetDEDXBinning(val);
const std::vector<G4VEnergyLossProcess*>& v =
theManager->GetEnergyLossProcessVector();
std::vector<G4VEnergyLossProcess*>::const_iterator itr;
@@ -247,6 +255,7 @@ void G4EmProcessOptions::SetDEDXBinning(G4int val)
void G4EmProcessOptions::SetDEDXBinningForCSDARange(G4int val)
{
theManager->SetDEDXBinningForCSDARange(val);
const std::vector<G4VEnergyLossProcess*>& v =
theManager->GetEnergyLossProcessVector();
std::vector<G4VEnergyLossProcess*>::const_iterator itr;
@@ -260,6 +269,7 @@ void G4EmProcessOptions::SetDEDXBinningForCSDARange(G4int val)
void G4EmProcessOptions::SetLambdaBinning(G4int val)
{
theManager->SetLambdaBinning(val);
const std::vector<G4VEmProcess*>& w =
theManager->GetEmProcessVector();
std::vector<G4VEmProcess*>::const_iterator itp;
@@ -280,6 +290,7 @@ void G4EmProcessOptions::SetLambdaBinning(G4int val)
void G4EmProcessOptions::SetStepFunction(G4double v1, G4double v2)
{
theManager->SetStepFunction(v1, v2);
const std::vector<G4VEnergyLossProcess*>& v =
theManager->GetEnergyLossProcessVector();
std::vector<G4VEnergyLossProcess*>::const_iterator itr;
@@ -293,6 +304,7 @@ void G4EmProcessOptions::SetStepFunction(G4double v1, G4double v2)
void G4EmProcessOptions::SetRandomStep(G4bool val)
{
theManager->SetRandomStep(val);
const std::vector<G4VEnergyLossProcess*>& v =
theManager->GetEnergyLossProcessVector();
std::vector<G4VEnergyLossProcess*>::const_iterator itr;
@@ -25,7 +25,7 @@
//
//
// $Id: G4EnergyLossMessenger.cc,v 1.29 2007/06/11 14:56:51 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-00 $
// GEANT4 tag $Name: geant4-09-01 $
//
// -------------------------------------------------------------------
//
@@ -25,7 +25,7 @@
//
//
// $Id: G4EnergyLossTables.cc,v 1.33 2006/06/29 19:55:09 gunter Exp $
// GEANT4 tag $Name: geant4-09-00 $
// GEANT4 tag $Name: geant4-09-01 $
//
// -------------------------------------------------------------------
// first version created by P.Urban , 06/04/1998
@@ -24,7 +24,7 @@
// ********************************************************************
//
// $Id: G4LossTableBuilder.cc,v 1.24 2007/02/16 11:59:35 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-00 $
// GEANT4 tag $Name: geant4-09-01 $
//
// -------------------------------------------------------------------
//
@@ -24,7 +24,7 @@
// ********************************************************************
//
// $Id: G4LossTableManager.cc,v 1.84 2007/06/14 07:28:48 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-00 $
// GEANT4 tag $Name: geant4-09-01 $
//
// -------------------------------------------------------------------
//
@@ -24,7 +24,7 @@
// ********************************************************************
//
// $Id: G4VEmFluctuationModel.cc,v 1.2 2006/06/29 19:55:15 gunter Exp $
// GEANT4 tag $Name: geant4-09-00 $
// GEANT4 tag $Name: geant4-09-01 $
//
// -------------------------------------------------------------------
//
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VEmModel.cc,v 1.6 2006/06/29 19:55:17 gunter Exp $
// GEANT4 tag $Name: geant4-09-00 $
// $Id: G4VEmModel.cc,v 1.8 2007/09/25 10:19:07 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
// -------------------------------------------------------------------
//
@@ -94,7 +94,7 @@ G4double G4VEmModel::ComputeMeanFreePath(const G4ParticleDefinition* p,
{
G4double mfp = DBL_MAX;
G4double cross = CrossSectionPerVolume(material,p,ekin,emin,emax);
if (cross >0.) mfp = 1./cross;
if (cross > DBL_MIN) mfp = 1./cross;
return mfp;
}
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VEmProcess.cc,v 1.40 2007/05/23 08:43:46 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-00 $
// $Id: G4VEmProcess.cc,v 1.48 2007/10/29 08:38:58 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
// -------------------------------------------------------------------
//
@@ -50,6 +50,7 @@
// 11-01-06 add A to parameters of ComputeCrossSectionPerAtom (VI)
// 12-09-06 add SetModel() (mma)
// 12-04-07 remove double call to Clear model manager (V.Ivanchenko)
// 27-10-07 Virtual functions moved to source (V.Ivanchenko)
//
// Class Description:
//
@@ -118,7 +119,10 @@ G4VEmProcess::~G4VEmProcess()
G4cout << "G4VEmProcess destruct " << GetProcessName()
<< G4endl;
Clear();
if(theLambdaTable) theLambdaTable->clearAndDestroy();
if(theLambdaTable) {
theLambdaTable->clearAndDestroy();
delete theLambdaTable;
}
delete modelManager;
(G4LossTableManager::Instance())->DeRegister(this);
}
@@ -139,8 +143,7 @@ void G4VEmProcess::PreparePhysicsTable(const G4ParticleDefinition& part)
if(particle == &part) {
Clear();
InitialiseProcess(particle);
theCutsGamma =
modelManager->Initialise(particle,secondaryParticle,2.,verboseLevel);
theCuts = modelManager->Initialise(particle,secondaryParticle,2.,verboseLevel);
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
theCutsGamma = theCoupleTable->GetEnergyCutsVector(idxG4GammaCut);
@@ -229,11 +232,74 @@ void G4VEmProcess::BuildLambdaTable()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::AddEmModel(G4int order, G4VEmModel* p,
const G4Region* region)
G4double G4VEmProcess::PostStepGetPhysicalInteractionLength(
const G4Track& track,
G4double previousStepSize,
G4ForceCondition* condition)
{
modelManager->AddEmModel(order, p, 0, region);
if(p) p->SetParticleChange(pParticleChange);
// condition is set to "Not Forced"
*condition = NotForced;
G4double x = DBL_MAX;
if(previousStepSize <= DBL_MIN) theNumberOfInteractionLengthLeft = -1.0;
InitialiseStep(track);
if(preStepKinEnergy < mfpKinEnergy) {
if (integral) ComputeIntegralLambda(preStepKinEnergy);
else preStepLambda = GetCurrentLambda(preStepKinEnergy);
if(preStepLambda <= DBL_MIN) mfpKinEnergy = 0.0;
}
// non-zero cross section
if(preStepLambda > DBL_MIN) {
if (theNumberOfInteractionLengthLeft < 0.0) {
// beggining of tracking (or just after DoIt of this process)
ResetNumberOfInteractionLengthLeft();
} else if(currentInteractionLength < DBL_MAX) {
// subtract NumberOfInteractionLengthLeft
SubtractNumberOfInteractionLengthLeft(previousStepSize);
if(theNumberOfInteractionLengthLeft < 0.)
theNumberOfInteractionLengthLeft = perMillion;
}
// get mean free path and step limit
currentInteractionLength = 1.0/preStepLambda;
x = theNumberOfInteractionLengthLeft * currentInteractionLength;
#ifdef G4VERBOSE
if (verboseLevel>2){
G4cout << "G4VEmProcess::PostStepGetPhysicalInteractionLength ";
G4cout << "[ " << GetProcessName() << "]" << G4endl;
G4cout << " for " << particle->GetParticleName()
<< " in Material " << currentMaterial->GetName()
<< " Ekin(MeV)= " << preStepKinEnergy/MeV
<<G4endl;
G4cout << "MeanFreePath = " << currentInteractionLength/cm << "[cm]"
<< "InteractionLength= " << x/cm <<"[cm] " <<G4endl;
}
#endif
// zero cross section case
} else {
if(theNumberOfInteractionLengthLeft > DBL_MIN &&
currentInteractionLength < DBL_MAX) {
// subtract NumberOfInteractionLengthLeft
SubtractNumberOfInteractionLengthLeft(previousStepSize);
if(theNumberOfInteractionLengthLeft < 0.)
theNumberOfInteractionLengthLeft = perMillion;
}
currentInteractionLength = DBL_MAX;
}
return x;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4VEmProcess::GetMeanFreePath(const G4Track& track,
G4double,
G4ForceCondition* condition)
{
*condition = NotForced;
return G4VEmProcess::MeanFreePath(track);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -283,7 +349,8 @@ G4VParticleChange* G4VEmProcess::PostStepDoIt(const G4Track& track,
secParticles.clear();
currentModel->SampleSecondaries(&secParticles,
currentCouple,
track.GetDynamicParticle());
track.GetDynamicParticle(),
(*theCuts)[currentMaterialIndex]);
// save secondaries
G4int num = secParticles.size();
@@ -25,7 +25,7 @@
//
//
// $Id: G4VEnergyLoss.cc,v 1.46 2006/06/29 19:55:21 gunter Exp $
// GEANT4 tag $Name: geant4-09-00 $
// GEANT4 tag $Name: geant4-09-01 $
//
// --------------------------------------------------------------
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VEnergyLossProcess.cc,v 1.109 2007/06/20 12:43:55 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-00 $
// $Id: G4VEnergyLossProcess.cc,v 1.122 2007/11/07 18:38:49 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
// -------------------------------------------------------------------
//
@@ -105,6 +105,7 @@
// 10-04-07 use unique SafetyHelper (V.Ivanchenko)
// 12-04-07 Add verbosity at destruction (V.Ivanchenko)
// 25-04-07 move initialisation of safety helper to BuildPhysicsTable (VI)
// 27-10-07 Virtual functions moved to source (V.Ivanchenko)
//
// Class Description:
//
@@ -175,7 +176,6 @@ G4VEnergyLossProcess::G4VEnergyLossProcess(const G4String& name,
lambdaFactor(0.8),
mfpKinEnergy(0.0),
lossFluctuationFlag(true),
lossFluctuationArePossible(true),
rndmStepFlag(false),
tablesAreBuilt(false),
integral(true),
@@ -205,7 +205,6 @@ G4VEnergyLossProcess::G4VEnergyLossProcess(const G4String& name,
// initialise model
(G4LossTableManager::Instance())->Register(this);
emModel[0]=emModel[1]=emModel[2]=emModel[3]=emModel[4]=0;
fluctModel = 0;
scoffRegions.clear();
@@ -232,18 +231,48 @@ G4VEnergyLossProcess::~G4VEnergyLossProcess()
if ( !baseParticle ) {
if(theDEDXTable && theRangeTableForLoss) {
if(theIonisationTable == theDEDXTable) theIonisationTable = 0;
theDEDXTable->clearAndDestroy();
if(theDEDXSubTable) theDEDXSubTable->clearAndDestroy();
delete theDEDXTable;
if(theDEDXSubTable) {
if(theIonisationSubTable == theDEDXSubTable)
theIonisationSubTable = 0;
theDEDXSubTable->clearAndDestroy();
delete theDEDXSubTable;
}
}
if(theIonisationTable) theIonisationTable->clearAndDestroy();
if(theIonisationSubTable) theIonisationSubTable->clearAndDestroy();
if(theDEDXunRestrictedTable && theCSDARangeTable)
if(theIonisationTable) {
theIonisationTable->clearAndDestroy();
delete theIonisationTable;
}
if(theIonisationSubTable) {
theIonisationSubTable->clearAndDestroy();
delete theIonisationSubTable;
}
if(theDEDXunRestrictedTable && theCSDARangeTable) {
theDEDXunRestrictedTable->clearAndDestroy();
if(theCSDARangeTable) theCSDARangeTable->clearAndDestroy();
if(theRangeTableForLoss) theRangeTableForLoss->clearAndDestroy();
if(theInverseRangeTable) theInverseRangeTable->clearAndDestroy();
if(theLambdaTable) theLambdaTable->clearAndDestroy();
if(theSubLambdaTable) theSubLambdaTable->clearAndDestroy();
delete theDEDXunRestrictedTable;
}
if(theCSDARangeTable) {
theCSDARangeTable->clearAndDestroy();
delete theCSDARangeTable;
}
if(theRangeTableForLoss) {
theRangeTableForLoss->clearAndDestroy();
delete theRangeTableForLoss;
}
if(theInverseRangeTable) {
theInverseRangeTable->clearAndDestroy();
delete theInverseRangeTable;
}
if(theLambdaTable) {
theLambdaTable->clearAndDestroy();
delete theLambdaTable;
}
if(theSubLambdaTable) {
theSubLambdaTable->clearAndDestroy();
delete theSubLambdaTable;
}
}
delete modelManager;
@@ -585,6 +614,118 @@ G4PhysicsTable* G4VEnergyLossProcess::BuildLambdaTable(G4EmTableType tType)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4VEnergyLossProcess::GetContinuousStepLimit(
const G4Track&,
G4double, G4double, G4double&)
{
return DBL_MAX;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4VEnergyLossProcess::AlongStepGetPhysicalInteractionLength(
const G4Track&,
G4double,
G4double currentMinStep,
G4double&,
G4GPILSelection* selection)
{
G4double x = DBL_MAX;
*selection = aGPILSelection;
if(isIonisation) {
fRange = GetScaledRangeForScaledEnergy(preStepScaledEnergy)*reduceFactor;
x = fRange;
G4double y = x*dRoverRange;
if(x > finalRange && y < currentMinStep) {
x = y + finalRange*(1.0 - dRoverRange)*(2.0 - finalRange/fRange);
} else if (rndmStepFlag) x = SampleRange();
// G4cout<<GetProcessName()<<": e= "<<preStepKinEnergy
// <<" range= "<<fRange <<" cMinSt="<<currentMinStep
// <<" safety= " << safety<< " limit= " << x <<G4endl;
}
// G4cout<<GetProcessName()<<": e= "<<preStepKinEnergy
// <<" stepLimit= "<<x<<G4endl;
return x;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4VEnergyLossProcess::GetMeanFreePath(
const G4Track& track,
G4double,
G4ForceCondition* condition)
{
*condition = NotForced;
return MeanFreePath(track);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4VEnergyLossProcess::PostStepGetPhysicalInteractionLength(
const G4Track& track,
G4double previousStepSize,
G4ForceCondition* condition)
{
// condition is set to "Not Forced"
*condition = NotForced;
G4double x = DBL_MAX;
if(previousStepSize <= DBL_MIN) theNumberOfInteractionLengthLeft = -1.0;
InitialiseStep(track);
if(preStepScaledEnergy < mfpKinEnergy) {
if (integral) ComputeLambdaForScaledEnergy(preStepScaledEnergy);
else preStepLambda = GetLambdaForScaledEnergy(preStepScaledEnergy);
if(preStepLambda <= DBL_MIN) mfpKinEnergy = 0.0;
}
// non-zero cross section
if(preStepLambda > DBL_MIN) {
if (theNumberOfInteractionLengthLeft < 0.0) {
// beggining of tracking (or just after DoIt of this process)
ResetNumberOfInteractionLengthLeft();
} else if(currentInteractionLength < DBL_MAX) {
// subtract NumberOfInteractionLengthLeft
SubtractNumberOfInteractionLengthLeft(previousStepSize);
if(theNumberOfInteractionLengthLeft < 0.)
theNumberOfInteractionLengthLeft = perMillion;
}
// get mean free path and step limit
currentInteractionLength = 1.0/preStepLambda;
x = theNumberOfInteractionLengthLeft * currentInteractionLength;
#ifdef G4VERBOSE
if (verboseLevel>2){
G4cout << "G4VEnergyLossProcess::PostStepGetPhysicalInteractionLength ";
G4cout << "[ " << GetProcessName() << "]" << G4endl;
G4cout << " for " << particle->GetParticleName()
<< " in Material " << currentMaterial->GetName()
<< " Ekin(MeV)= " << preStepKinEnergy/MeV
<<G4endl;
G4cout << "MeanFreePath = " << currentInteractionLength/cm << "[cm]"
<< "InteractionLength= " << x/cm <<"[cm] " <<G4endl;
}
#endif
// zero cross section case
} else {
if(theNumberOfInteractionLengthLeft > DBL_MIN &&
currentInteractionLength < DBL_MAX) {
// subtract NumberOfInteractionLengthLeft
SubtractNumberOfInteractionLengthLeft(previousStepSize);
if(theNumberOfInteractionLengthLeft < 0.)
theNumberOfInteractionLengthLeft = perMillion;
}
currentInteractionLength = DBL_MAX;
}
return x;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VParticleChange* G4VEnergyLossProcess::AlongStepDoIt(const G4Track& track,
const G4Step& step)
{
@@ -597,7 +738,7 @@ G4VParticleChange* G4VEnergyLossProcess::AlongStepDoIt(const G4Track& track,
if(length <= DBL_MIN) return &fParticleChange;
G4double eloss = 0.0;
/*
/*
if(-1 < verboseLevel) {
const G4ParticleDefinition* d = track.GetDefinition();
G4cout << "AlongStepDoIt for "
@@ -623,19 +764,17 @@ G4VParticleChange* G4VEnergyLossProcess::AlongStepDoIt(const G4Track& track,
// Short step
eloss = GetDEDXForScaledEnergy(preStepScaledEnergy)*length;
// if( length <= linLossLimit * fRange ) {
// eloss = GetDEDXForScaledEnergy(preStepScaledEnergy)*length;
// Long step
//} else {
if(eloss > preStepKinEnergy*linLossLimit) {
G4double r = GetScaledRangeForScaledEnergy(preStepScaledEnergy);
G4double x = r - length/reduceFactor;
eloss = (ScaledKinEnergyForLoss(r) - ScaledKinEnergyForLoss(x))/massRatio;
G4double x =
GetScaledRangeForScaledEnergy(preStepScaledEnergy) - length/reduceFactor;
eloss = preStepKinEnergy - ScaledKinEnergyForLoss(x)/massRatio;
/*
if(-1 < verboseLevel)
G4cout << "Long STEP: rPre(mm)= " << r/mm
G4cout << "Long STEP: rPre(mm)= "
<< GetScaledRangeForScaledEnergy(preStepScaledEnergy)/mm
<< " rPost(mm)= " << x/mm
<< " ePre(MeV)= " << preStepScaledEnergy/MeV
<< " eloss(MeV)= " << eloss/MeV
@@ -647,7 +786,7 @@ G4VParticleChange* G4VEnergyLossProcess::AlongStepDoIt(const G4Track& track,
const G4DynamicParticle* dynParticle = track.GetDynamicParticle();
G4VEmModel* currentModel = SelectModel(preStepScaledEnergy);
/*
/*
G4double eloss0 = eloss;
if(-1 < verboseLevel ) {
G4cout << "Before fluct: eloss(MeV)= " << eloss/MeV
@@ -657,7 +796,7 @@ G4VParticleChange* G4VEnergyLossProcess::AlongStepDoIt(const G4Track& track,
<< " fluct= " << lossFluctuationFlag
<< G4endl;
}
*/
*/
G4double cut = (*theCuts)[currentMaterialIndex];
G4double esec = 0.0;
@@ -712,7 +851,6 @@ G4VParticleChange* G4VEnergyLossProcess::AlongStepDoIt(const G4Track& track,
cut = (*theSubCuts)[currentMaterialIndex];
eloss -= GetSubDEDXForScaledEnergy(preStepScaledEnergy)*length;
if(eloss < 0.0) eloss = 0.0;
scTracks.clear();
SampleSubCutSecondaries(scTracks, step,
currentModel,currentMaterialIndex,
@@ -749,15 +887,16 @@ G4VParticleChange* G4VEnergyLossProcess::AlongStepDoIt(const G4Track& track,
CorrectionsAlongStep(currentCouple, dynParticle, eloss, length);
// Sample fluctuations
if (lossFluctuationFlag &&
if (lossFluctuationFlag) {
G4VEmFluctuationModel* fluc = currentModel->GetModelOfFluctuations();
if(fluc &&
(eloss + esec + esecdep + lowestKinEnergy) < preStepKinEnergy) {
G4double tmax =
std::min(currentModel->MaxSecondaryKinEnergy(dynParticle),cut);
eloss = currentModel->GetModelOfFluctuations()->
SampleFluctuations(currentMaterial,dynParticle,tmax,length,eloss);
/*
G4double tmax =
std::min(currentModel->MaxSecondaryKinEnergy(dynParticle),cut);
eloss = fluc->SampleFluctuations(currentMaterial,dynParticle,
tmax,length,eloss);
/*
if(-1 < verboseLevel)
G4cout << "After fluct: eloss(MeV)= " << eloss/MeV
<< " fluc= " << (eloss-eloss0)/MeV
@@ -765,10 +904,12 @@ G4VParticleChange* G4VEnergyLossProcess::AlongStepDoIt(const G4Track& track,
<< " massRatio= " << massRatio
<< " tmax= " << tmax
<< G4endl;
*/
*/
}
}
// add low-energy subcutoff particles
eloss += esecdep;
if(eloss < 0.0) eloss = 0.0;
// Energy balanse
G4double finalT = preStepKinEnergy - eloss - esec;
@@ -780,7 +921,7 @@ G4VParticleChange* G4VEnergyLossProcess::AlongStepDoIt(const G4Track& track,
fParticleChange.SetProposedKineticEnergy(finalT);
fParticleChange.ProposeLocalEnergyDeposit(eloss);
/*
/*
if(-1 < verboseLevel) {
G4cout << "Final value eloss(MeV)= " << eloss/MeV
<< " preStepKinEnergy= " << preStepKinEnergy
@@ -831,7 +972,7 @@ void G4VEnergyLossProcess::SampleSubCutSecondaries(
G4ThreeVector prepoint = preStepPoint->GetPosition();
G4ThreeVector dr = step.GetPostStepPoint()->GetPosition() - prepoint;
G4double pretime = preStepPoint->GetGlobalTime();
G4double dt = length/preStepPoint->GetVelocity();
// G4double dt = length/preStepPoint->GetVelocity();
G4double fragment = 0.0;
do {
@@ -841,7 +982,8 @@ void G4VEnergyLossProcess::SampleSubCutSecondaries(
// sample secondaries
secParticles.clear();
model->SampleSecondaries(&secParticles,track->GetMaterialCutsCouple(),dp,subcut,cut);
model->SampleSecondaries(&secParticles,track->GetMaterialCutsCouple(),
dp,subcut,cut);
// position of subcutoff particles
G4ThreeVector r = prepoint + fragment*dr;
@@ -862,7 +1004,8 @@ void G4VEnergyLossProcess::SampleSubCutSecondaries(
}
}
if(addSec) {
G4Track* t = new G4Track((*it), pretime + fragment*dt, r);
// G4Track* t = new G4Track((*it), pretime + fragment*dt, r);
G4Track* t = new G4Track((*it), pretime, r);
t->SetTouchableHandle(track->GetTouchableHandle());
tracks.push_back(t);
@@ -969,6 +1112,7 @@ void G4VEnergyLossProcess::PrintInfoDefinition()
G4cout << " Step function: finalRange(mm)= " << finalRange/mm
<< ", dRoverRange= " << dRoverRange
<< ", integral: " << integral
<< ", fluct: " << lossFluctuationFlag
<< G4endl;
if(theCSDARangeTable && isIonisation)
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VMultipleScattering.cc,v 1.43 2007/05/18 18:39:55 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-00 $
// $Id: G4VMultipleScattering.cc,v 1.47 2007/11/09 11:35:54 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
// -------------------------------------------------------------------
//
@@ -53,6 +53,7 @@
// 15-04-05 remove boundary flag (V.Ivanchenko)
// 27-10-05 introduce virtual function MscStepLimitation() (V.Ivanchenko)
// 12-04-07 Add verbosity at destruction (V.Ivanchenko)
// 27-10-07 Virtual functions moved to source (V.Ivanchenko)
//
// Class Description:
//
@@ -79,6 +80,7 @@
#include "G4RegionStore.hh"
#include "G4PhysicsTableHelper.hh"
#include "G4GenericIon.hh"
#include "G4Electron.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -115,7 +117,10 @@ G4VMultipleScattering::~G4VMultipleScattering()
G4cout << "G4VMultipleScattering destruct " << GetProcessName()
<< G4endl;
delete modelManager;
if (theLambdaTable) theLambdaTable->clearAndDestroy();
if (theLambdaTable) {
theLambdaTable->clearAndDestroy();
delete theLambdaTable;
}
(G4LossTableManager::Instance())->DeRegister(this);
}
@@ -197,7 +202,9 @@ void G4VMultipleScattering::PreparePhysicsTable(const G4ParticleDefinition& part
if(buildLambdaTable)
theLambdaTable = G4PhysicsTableHelper::PreparePhysicsTable(theLambdaTable);
const G4DataVector* theCuts =
modelManager->Initialise(firstParticle, 0, 10.0, verboseLevel);
modelManager->Initialise(firstParticle,
G4Electron::Electron(),
10.0, verboseLevel);
if(2 < verboseLevel) G4cout << theCuts << G4endl;
@@ -206,16 +213,6 @@ void G4VMultipleScattering::PreparePhysicsTable(const G4ParticleDefinition& part
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VMultipleScattering::AddEmModel(G4int order, G4VEmModel* p,
const G4Region* region)
{
G4VEmFluctuationModel* fm = 0;
modelManager->AddEmModel(order, p, fm, region);
if(p)p->SetParticleChange(pParticleChange);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VMultipleScattering::PrintInfoDefinition()
{
if (0 < verboseLevel) {
@@ -240,6 +237,76 @@ void G4VMultipleScattering::PrintInfoDefinition()
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4VMultipleScattering::AlongStepGetPhysicalInteractionLength(
const G4Track& track,
G4double previousStepSize,
G4double currentMinimalStep,
G4double& currentSafety,
G4GPILSelection* selection)
{
// get Step limit proposed by the process
valueGPILSelectionMSC = NotCandidateForSelection;
G4double steplength = GetMscContinuousStepLimit(track,previousStepSize,
currentMinimalStep,currentSafety);
// G4cout << "StepLimit= " << steplength << G4endl;
// set return value for G4GPILSelection
*selection = valueGPILSelectionMSC;
return steplength;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4VMultipleScattering::PostStepGetPhysicalInteractionLength(
const G4Track&, G4double, G4ForceCondition* condition)
{
*condition = Forced;
return DBL_MAX;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4VMultipleScattering::GetContinuousStepLimit(
const G4Track& track,
G4double previousStepSize,
G4double currentMinimalStep,
G4double& currentSafety)
{
return GetMscContinuousStepLimit(track,previousStepSize,currentMinimalStep,
currentSafety);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4VMultipleScattering::GetMeanFreePath(
const G4Track&, G4double, G4ForceCondition* condition)
{
*condition = Forced;
return DBL_MAX;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VParticleChange* G4VMultipleScattering::AlongStepDoIt(const G4Track&,
const G4Step& step)
{
fParticleChange.ProposeTrueStepLength(
currentModel->ComputeTrueStepLength(step.GetStepLength()));
return &fParticleChange;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VParticleChange* G4VMultipleScattering::PostStepDoIt(const G4Track& track,
const G4Step& step)
{
fParticleChange.Initialize(track);
currentModel->SampleScattering(track.GetDynamicParticle(),
step.GetPostStepPoint()->GetSafety());
return &fParticleChange;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4PhysicsVector* G4VMultipleScattering::PhysicsVector(const G4MaterialCutsCouple* couple)
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4ionEffectiveCharge.cc,v 1.14 2006/08/15 16:21:39 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-00 $
// $Id: G4ionEffectiveCharge.cc,v 1.17 2007/09/27 17:08:58 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
// -------------------------------------------------------------------
//
@@ -43,6 +43,7 @@
// 28.04.2006 Set upper energy limit to 50 MeV (V.Ivanchenko)
// 23.05.2006 Set upper energy limit to Z*10 MeV (V.Ivanchenko)
// 15.08.2006 Add protection for not defined material (V.Ivanchenko)
// 27-09-2007 Use Fermi energy from material, optimazed formulas (V.Ivanchenko)
//
// -------------------------------------------------------------------
@@ -92,70 +93,10 @@ G4double G4ionEffectiveCharge::EffectiveCharge(const G4ParticleDefinition* p,
G4double reducedEnergy = kineticEnergy * proton_mass_c2/mass ;
if( reducedEnergy > Zi*energyHighLimit || Zi < 1.5 || !material) return charge;
static G4double vFermi[92] = {
1.0309, 0.15976, 0.59782, 1.0781, 1.0486, 1.0, 1.058, 0.93942, 0.74562, 0.3424,
0.45259, 0.71074, 0.90519, 0.97411, 0.97184, 0.89852, 0.70827, 0.39816, 0.36552, 0.62712,
0.81707, 0.9943, 1.1423, 1.2381, 1.1222, 0.92705, 1.0047, 1.2, 1.0661, 0.97411,
0.84912, 0.95, 1.0903, 1.0429, 0.49715, 0.37755, 0.35211, 0.57801, 0.77773, 1.0207,
1.029, 1.2542, 1.122, 1.1241, 1.0882, 1.2709, 1.2542, 0.90094, 0.74093, 0.86054,
0.93155, 1.0047, 0.55379, 0.43289, 0.32636, 0.5131, 0.695, 0.72591, 0.71202, 0.67413,
0.71418, 0.71453, 0.5911, 0.70263, 0.68049, 0.68203, 0.68121, 0.68532, 0.68715, 0.61884,
0.71801, 0.83048, 1.1222, 1.2381, 1.045, 1.0733, 1.0953, 1.2381, 1.2879, 0.78654,
0.66401, 0.84912, 0.88433, 0.80746, 0.43357, 0.41923, 0.43638, 0.51464, 0.73087, 0.81065,
1.9578, 1.0257} ;
static G4double lFactor[92] = {
1.0, 1.0, 1.1, 1.06, 1.01, 1.03, 1.04, 0.99, 0.95, 0.9,
0.82, 0.81, 0.83, 0.88, 1.0, 0.95, 0.97, 0.99, 0.98, 0.97,
0.98, 0.97, 0.96, 0.93, 0.91, 0.9, 0.88, 0.9, 0.9, 0.9,
0.9, 0.85, 0.9, 0.9, 0.91, 0.92, 0.9, 0.9, 0.9, 0.9,
0.9, 0.88, 0.9, 0.88, 0.88, 0.9, 0.9, 0.88, 0.9, 0.9,
0.9, 0.9, 0.96, 1.2, 0.9, 0.88, 0.88, 0.85, 0.9, 0.9,
0.92, 0.95, 0.99, 1.03, 1.05, 1.07, 1.08, 1.1, 1.08, 1.08,
1.08, 1.08, 1.09, 1.09, 1.1, 1.11, 1.12, 1.13, 1.14, 1.15,
1.17, 1.2, 1.18, 1.17, 1.17, 1.16, 1.16, 1.16, 1.16, 1.16,
1.16, 1.16} ;
static G4double c[6] = {0.2865, 0.1266, -0.001429,
0.02402,-0.01135, 0.001475} ;
// get elements in the actual material,
const G4ElementVector* theElementVector = material->GetElementVector() ;
const G4double* theAtomicNumDensityVector =
material->GetAtomicNumDensityVector() ;
const G4int NumberOfElements = material->GetNumberOfElements() ;
// loop for the elements in the material
// to find out average values Z, vF, lF
G4double z = 0.0, vF = 0.0, lF = 0.0, norm = 0.0 ;
if( 1 == NumberOfElements ) {
z = material->GetZ() ;
G4int iz = G4int(z) - 1 ;
if(iz < 0) iz = 0 ;
else if(iz > 91) iz = 91 ;
vF = vFermi[iz] ;
lF = lFactor[iz] ;
} else {
for (G4int iel=0; iel<NumberOfElements; iel++)
{
const G4Element* element = (*theElementVector)[iel] ;
G4double z2 = element->GetZ() ;
const G4double weight = theAtomicNumDensityVector[iel] ;
norm += weight ;
z += z2 * weight ;
G4int iz = G4int(z2) - 1 ;
if(iz < 0) iz = 0 ;
else if(iz > 91) iz =91 ;
vF += vFermi[iz] * weight ;
lF += lFactor[iz] * weight ;
}
z /= norm ;
vF /= norm ;
lF /= norm ;
}
G4double z = material->GetIonisation()->GetZeffective();
reducedEnergy = std::max(reducedEnergy,energyLowLimit);
G4double q;
@@ -169,28 +110,40 @@ G4double G4ionEffectiveCharge::EffectiveCharge(const G4ParticleDefinition* p,
y *= Q;
x += y * c[i] ;
}
G4double ex;
if(x < 0.2) ex = x * (1 - 0.5*x);
else ex = 1. - std::exp(-x);
G4double tq = 7.6 - Q;
q = (1.0 + ( 0.007 + 0.00005 * z ) * std::exp( -tq*tq )) * std::sqrt(1.0 - std::exp(-x)) ;
G4double tq2= tq*tq;
G4double tt = ( 0.007 + 0.00005 * z );
if(tq2 < 0.2) tt *= (1.0 - tq2 + 0.5*tq2*tq2);
else tt *= std::exp(-tq2);
q = (1.0 + tt) * std::sqrt(ex);
// Heavy ion case
} else {
G4double z23 = std::pow(z, 0.666667);
G4double zi13 = std::pow(Zi, 0.33333);
G4double z23 = std::pow(z, 0.666666);
G4double zi13 = std::pow(Zi, 0.333333);
G4double zi23 = zi13*zi13;
G4double e = std::max(reducedEnergy,energyBohr/z23);
// v1 is ion velocity in vF unit
G4double v1 = std::sqrt( e / energyBohr )/ vF ;
G4double eF = material->GetIonisation()->GetFermiEnergy();
G4double v1sq = e/eF;
G4double vFsq = eF/energyBohr;
G4double vF = std::sqrt(vFsq);
G4double y ;
// Faster than Fermi velocity
if ( v1 > 1.0 ) {
y = vF * v1 * ( 1.0 + 0.2 / (v1*v1) ) / zi23 ;
if ( v1sq > 1.0 ) {
y = vF * std::sqrt(v1sq) * ( 1.0 + 0.2/v1sq ) / zi23 ;
// Slower than Fermi velocity
} else {
y = 0.6923 * vF * (1.0 + 2.0*v1*v1/3.0 + v1*v1*v1*v1/15.0) / zi23 ;
y = 0.6923 * vF * (1.0 + 0.666666*v1sq + v1sq*v1sq/15.0) / zi23 ;
}
G4double y3 = std::pow(y, 0.3) ;
@@ -204,16 +157,28 @@ G4double G4ionEffectiveCharge::EffectiveCharge(const G4ParticleDefinition* p,
if(q < qmin) q = qmin;
G4double tq = 7.6 - std::log(reducedEnergy/keV);
G4double sq = 1.0 + ( 0.18 + 0.0015 * z ) * std::exp( -tq*tq )/ (Zi*Zi);
G4double tq2= tq*tq;
G4double sq = ( 0.18 + 0.0015 * z ) / (Zi*Zi);
if(tq2 < 0.2) sq *= (1.0 - tq2 + 0.5*tq2*tq2);
else sq *= std::exp(-tq2);
sq += 1.0;
// G4cout << "sq= " << sq << G4endl;
// Screen length according to
// J.F.Ziegler and J.M.Manoyan, The stopping of ions in compaunds,
// Nucl. Inst. & Meth. in Phys. Res. B35 (1988) 215-228.
G4double lambda = 10.0 * vF * std::pow(1.0-q, 0.6667) / (zi13 * (6.0 + q)) ;
chargeCorrection = sq * (1.0 + (0.5/q - 0.5)*std::log(1.0 + lambda*lambda)/(vF*vF) );
G4double lambda = 10.0 * vF / (zi13 * (6.0 + q));
if(q < 0.2) lambda *= (1.0 - 0.666666*q - 0.444444*q*q);
else lambda *= std::pow(1.0-q, 0.666666);
G4double lambda2 = lambda*lambda;
G4double xx = (0.5/q - 0.5)/vFsq;
if(lambda2 < 0.2) xx *= lambda2*(1.0 - 0.5*lambda2);
else xx *= std::log(1.0 + lambda2);
chargeCorrection = sq * (1.0 + xx);
}
// G4cout << "G4ionEffectiveCharge: charge= " << charge << " q= " << q
// << " chargeCor= " << chargeCorrection