Import Geant4 7.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 11:11:55 +02:00
parent e083ffb441
commit 516dbf1a58
5914 changed files with 202605 additions and 71141 deletions
@@ -20,8 +20,8 @@
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: G4VEmProcess.cc,v 1.5 2004/05/17 09:46:57 vnivanch Exp $
// GEANT4 tag $Name: geant4-06-02 $
// $Id: G4VEmProcess.cc,v 1.15 2004/11/10 14:37:25 vnivanch Exp $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
//
// -------------------------------------------------------------------
//
@@ -35,6 +35,9 @@
// Creation date: 01.10.2003
//
// Modifications:
// 30-06-04 make it to be pure discrete process (V.Ivanchenko)
// 30-09-08 optimise integral option (V.Ivanchenko)
// 08-11-04 Migration to new interface of Store/Retrieve tables (V.Ivantchenko)
//
//
// Class Description:
@@ -51,40 +54,41 @@
#include "G4Step.hh"
#include "G4ParticleDefinition.hh"
#include "G4VEmModel.hh"
#include "G4VEmFluctuationModel.hh"
#include "G4DataVector.hh"
#include "G4PhysicsTable.hh"
#include "G4PhysicsVector.hh"
#include "G4PhysicsLogVector.hh"
#include "G4VParticleChange.hh"
#include "G4Gamma.hh"
#include "G4Electron.hh"
#include "G4Positron.hh"
#include "G4ProcessManager.hh"
#include "G4UnitsTable.hh"
#include "G4ProductionCutsTable.hh"
#include "G4Region.hh"
#include "G4RegionStore.hh"
#include "G4Gamma.hh"
#include "G4Electron.hh"
#include "G4Positron.hh"
#include "G4PhysicsTableHelper.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VEmProcess::G4VEmProcess(const G4String& name, G4ProcessType type):
G4VRestDiscreteProcess(name, type),
G4VDiscreteProcess(name, type),
theLambdaTable(0),
theEnergyOfCrossSectionMax(0),
theCrossSectionMax(0),
particle(0),
secondaryParticle(0),
currentCouple(0),
nLambdaBins(90),
lambdaFactor(0.1),
mfpKinEnergy(0.0),
integral(true),
meanFreePath(true)
currentCouple(0),
integral(false),
meanFreePath(true),
aboveCSmax(true),
buildLambdaTable(true)
{
minKinEnergy = 0.1*keV;
maxKinEnergy = 100.0*GeV;
minKinEnergy = 0.1*keV;
maxKinEnergy = 100.0*GeV;
pParticleChange = &fParticleChange;
modelManager = new G4EmModelManager();
(G4LossTableManager::Instance())->Register(this);
@@ -94,33 +98,50 @@ G4VEmProcess::G4VEmProcess(const G4String& name, G4ProcessType type):
G4VEmProcess::~G4VEmProcess()
{
if(theLambdaTable) theLambdaTable->clearAndDestroy();
if(theEnergyOfCrossSectionMax) delete [] theEnergyOfCrossSectionMax;
if(theCrossSectionMax) delete [] theCrossSectionMax;
modelManager->Clear();
Clear();
delete modelManager;
(G4LossTableManager::Instance())->DeRegister(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::Initialise()
void G4VEmProcess::PreparePhysicsTable(const G4ParticleDefinition& part)
{
if(!particle) particle = ∂
if(particle == &part) {
Clear();
theCutsGamma =
modelManager->Initialise(particle,secondaryParticle,2.,verboseLevel);
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
theCutsGamma = theCoupleTable->GetEnergyCutsVector(idxG4GammaCut);
theCutsElectron = theCoupleTable->GetEnergyCutsVector(idxG4ElectronCut);
theCutsPositron = theCoupleTable->GetEnergyCutsVector(idxG4PositronCut);
if(buildLambdaTable)
theLambdaTable = G4PhysicsTableHelper::PreparePhysicsTable(theLambdaTable);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::Clear()
{
if(theLambdaTable) theLambdaTable->clearAndDestroy();
if(theEnergyOfCrossSectionMax) delete [] theEnergyOfCrossSectionMax;
if(theCrossSectionMax) delete [] theCrossSectionMax;
theLambdaTable = 0;
theEnergyOfCrossSectionMax = 0;
theCrossSectionMax = 0;
modelManager->Clear();
theCuts = modelManager->Initialise(particle,secondaryParticle,2.,verboseLevel);
currentCouple = 0;
preStepLambda = 0.0;
mfpKinEnergy = DBL_MAX;
preStepMFP = DBL_MAX;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::BuildPhysicsTable(const G4ParticleDefinition& part)
{
if( !particle ) particle = ∂
currentCouple = 0;
preStepLambda = 0.0;
if(0 < verboseLevel) {
G4cout << "G4VEmProcess::BuildPhysicsTable() for "
<< GetProcessName()
@@ -128,23 +149,13 @@ void G4VEmProcess::BuildPhysicsTable(const G4ParticleDefinition& part)
<< G4endl;
}
G4bool cutsWasModified = false;
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
for (size_t j=0; j<numOfCouples; j++){
if (theCoupleTable->GetMaterialCutsCouple(j)->IsRecalcNeeded()) {
cutsWasModified = true;
break;
}
if(buildLambdaTable) {
BuildLambdaTable();
FindLambdaMax();
}
if( !cutsWasModified ) return;
if(-1 < verboseLevel) PrintInfoDefinition();
Initialise();
theLambdaTable = BuildLambdaTable();
PrintInfoDefinition();
if(0 < verboseLevel && theCuts) {
if(0 < verboseLevel) {
G4cout << "G4VEmProcess::BuildPhysicsTable() done for "
<< GetProcessName()
<< " and particle " << part.GetParticleName()
@@ -154,9 +165,8 @@ void G4VEmProcess::BuildPhysicsTable(const G4ParticleDefinition& part)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4PhysicsTable* G4VEmProcess::BuildLambdaTable()
void G4VEmProcess::BuildLambdaTable()
{
if(0 < verboseLevel) {
G4cout << "G4VEnergyLossSTD::BuildLambdaTable() for process "
<< GetProcessName() << " and particle "
@@ -169,33 +179,16 @@ G4PhysicsTable* G4VEmProcess::BuildLambdaTable()
G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
G4PhysicsTable* theTable = new G4PhysicsTable(numOfCouples);
theEnergyOfCrossSectionMax = new G4double [numOfCouples];
theCrossSectionMax = new G4double [numOfCouples];
for(size_t i=0; i<numOfCouples; i++) {
// create physics vector and fill it
const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(i);
G4PhysicsVector* aVector = LambdaPhysicsVector(couple);
modelManager->FillLambdaVector(aVector, couple);
if (theLambdaTable->GetFlag(i)) {
G4double e, s, emax = 0.0;
G4bool b;
G4double smax = 0.0;
for (G4int j=0; j<nLambdaBins; j++) {
e = aVector->GetLowEdgeEnergy(j);
s = aVector->GetValue(e,b);
if(s > smax) {
smax = s;
emax = e;
}
// create physics vector and fill it
const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(i);
G4PhysicsVector* aVector = LambdaPhysicsVector(couple);
modelManager->FillLambdaVector(aVector, couple);
G4PhysicsTableHelper::SetPhysicsVector(theLambdaTable, i, aVector);
}
theEnergyOfCrossSectionMax[i] = emax;
theCrossSectionMax[i] = smax;
// Insert vector for this material into the table
theTable->insert(aVector) ;
}
if(0 < verboseLevel) {
@@ -203,11 +196,9 @@ G4PhysicsTable* G4VEmProcess::BuildLambdaTable()
<< particle->GetParticleName()
<< G4endl;
if(2 < verboseLevel) {
G4cout << *theTable << G4endl;
G4cout << *theLambdaTable << G4endl;
}
}
return theTable;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -226,17 +217,14 @@ void G4VEmProcess::SetSecondaryParticle(const G4ParticleDefinition* p)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::AddEmModel(G4int order, G4VEmModel* p,
G4VEmFluctuationModel*,
const G4Region* region)
void G4VEmProcess::AddEmModel(G4int order, G4VEmModel* p, const G4Region* region)
{
modelManager->AddEmModel(order, p, 0, region);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::UpdateEmModel(const G4String& nam, G4double emin,
G4double emax)
void G4VEmProcess::UpdateEmModel(const G4String& nam, G4double emin, G4double emax)
{
modelManager->UpdateEmModel(nam, emin, emax);
}
@@ -246,17 +234,30 @@ void G4VEmProcess::UpdateEmModel(const G4String& nam, G4double emin,
G4VParticleChange* G4VEmProcess::PostStepDoIt(const G4Track& track,
const G4Step& step)
{
aParticleChange.Initialize(track);
fParticleChange.InitializeForPostStep(track);
// Do not make anything if particle is stopped, the annihilation then
// should be performed by the AtRestDoIt!
if (track.GetTrackStatus() == fStopButAlive) return &fParticleChange;
G4double finalT = track.GetKineticEnergy();
// Integral approach
if (integral) {
if(preStepLambda*G4UniformRand() > GetLambda(finalT))
return G4VRestDiscreteProcess::PostStepDoIt(track,step);
G4double lx = GetLambda(finalT, currentCouple);
if(preStepLambda<lx && 0 < verboseLevel) {
G4cout << "WARING: for " << particle->GetParticleName()
<< " and " << GetProcessName()
<< " E(MeV)= " << finalT/MeV
<< " preLambda= " << preStepLambda << " < " << lx << " (postLambda) "
<< G4endl;
}
if(preStepLambda*G4UniformRand() > lx)
return G4VDiscreteProcess::PostStepDoIt(track,step);
}
G4VEmModel* currentModel = SelectModel(finalT);
G4double tcut = (*theCuts)[currentMaterialIndex];
const G4DynamicParticle* dynParticle = track.GetDynamicParticle();
/*
@@ -270,8 +271,47 @@ G4VParticleChange* G4VEmProcess::PostStepDoIt(const G4Track& track,
}
*/
SecondariesPostStep(currentModel,currentCouple,dynParticle,tcut,finalT);
return &aParticleChange;
std::vector<G4DynamicParticle*>* newp = SecondariesPostStep(currentModel,
currentCouple,
dynParticle);
G4double edep = fParticleChange.GetLocalEnergyDeposit();
if (newp) {
G4int num = newp->size();
if(num > 0) {
fParticleChange.SetNumberOfSecondaries(num);
G4double gcut = (*theCutsGamma)[currentMaterialIndex];
G4double ecut = (*theCutsElectron)[currentMaterialIndex];
G4double pcut = (*theCutsPositron)[currentMaterialIndex];
for (G4int i=0; i<num; i++) {
G4DynamicParticle* dp = (*newp)[i];
const G4ParticleDefinition* p = dp->GetDefinition();
G4double e = dp->GetKineticEnergy();
G4bool good = true;
if (p == G4Gamma::Gamma()) {
if (e < gcut) {
good = false;
edep += e;
}
} else if (p == G4Electron::Electron()) {
if (e < ecut) {
good = false;
edep += e;
}
} else if (p == G4Positron::Positron()) {
if (e < pcut) {
good = false;
edep += e + electron_mass_c2;
}
}
if (good) fParticleChange.AddSecondary(dp);
else delete dp;
}
}
delete newp;
}
fParticleChange.ProposeLocalEnergyDeposit(edep);
return &fParticleChange;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -283,17 +323,9 @@ void G4VEmProcess::PrintInfoDefinition()
<< G4BestUnit(maxKinEnergy,"Energy")
<< " in " << nLambdaBins << " bins."
<< G4endl;
/*
G4cout << "DEDXTable address= " << theDEDXTable << G4endl;
if(theDEDXTable) G4cout << (*theDEDXTable) << G4endl;
G4cout << "RangeTable address= " << theRangeTable << G4endl;
if(theRangeTable) G4cout << (*theRangeTable) << G4endl;
G4cout << "InverseRangeTable address= " << theInverseRangeTable << G4endl;
if(theInverseRangeTable) G4cout << (*theInverseRangeTable) << G4endl;
*/
if(0 < verboseLevel) {
G4cout << "Tables are built for " << particle->GetParticleName()
<< " IntegralFlag= " << integral
<< G4endl;
if(2 < verboseLevel) {
@@ -305,18 +337,6 @@ void G4VEmProcess::PrintInfoDefinition()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4PhysicsVector* G4VEmProcess::LambdaPhysicsVector(const G4MaterialCutsCouple* couple)
{
G4double cut = (*theCuts)[couple->GetIndex()];
G4double tmin = std::max(MinPrimaryEnergy(particle, couple->GetMaterial(), cut),
minKinEnergy);
if(tmin >= maxKinEnergy) tmin = 0.5*maxKinEnergy;
G4PhysicsVector* v = new G4PhysicsLogVector(tmin, maxKinEnergy, nLambdaBins);
return v;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4VEmProcess::MicroscopicCrossSection(G4double kineticEnergy,
const G4MaterialCutsCouple* couple)
{
@@ -345,39 +365,37 @@ G4double G4VEmProcess::MeanFreePath(const G4Track& track,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4bool G4VEmProcess::StorePhysicsTable(G4ParticleDefinition* part,
const G4String& directory,
G4bool ascii)
G4bool G4VEmProcess::StorePhysicsTable(const G4ParticleDefinition* part,
const G4String& directory,
G4bool ascii)
{
G4bool yes = true;
if ( theLambdaTable ) {
if ( theLambdaTable && part == particle) {
const G4String name = GetPhysicsTableFileName(part,directory,"Lambda",ascii);
yes = theLambdaTable->StorePhysicsTable(name,ascii);
}
if ( yes ) {
G4cout << "Physics tables are stored for " << particle->GetParticleName()
<< " and process " << GetProcessName()
<< " in the directory <" << directory
<< "> " << G4endl;
} else {
G4cout << "Fail to store Physics Tables for " << particle->GetParticleName()
<< " and process " << GetProcessName()
<< " in the directory <" << directory
<< "> " << G4endl;
if ( yes ) {
G4cout << "Physics tables are stored for " << particle->GetParticleName()
<< " and process " << GetProcessName()
<< " in the directory <" << directory
<< "> " << G4endl;
} else {
G4cout << "Fail to store Physics Tables for " << particle->GetParticleName()
<< " and process " << GetProcessName()
<< " in the directory <" << directory
<< "> " << G4endl;
}
}
return yes;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool G4VEmProcess::RetrievePhysicsTable(G4ParticleDefinition* part,
const G4String& directory,
G4bool ascii)
G4bool G4VEmProcess::RetrievePhysicsTable(const G4ParticleDefinition* part,
const G4String& directory,
G4bool ascii)
{
currentCouple = 0;
preStepLambda = 0.0;
if(0 < verboseLevel) {
G4cout << "G4VEmProcess::RetrievePhysicsTable() for "
<< part->GetParticleName() << " and process "
@@ -385,39 +403,67 @@ G4bool G4VEmProcess::RetrievePhysicsTable(G4ParticleDefinition* part,
}
G4bool yes = true;
if(!buildLambdaTable || particle != part) return yes;
const G4String particleName = part->GetParticleName();
if( !particle ) particle = part;
Initialise();
G4String filename;
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
filename = GetPhysicsTableFileName(part,directory,"Lambda",ascii);
theLambdaTable = new G4PhysicsTable(numOfCouples);
yes = theLambdaTable->RetrievePhysicsTable(filename,ascii);
yes = G4PhysicsTableHelper::RetrievePhysicsTable(theLambdaTable,filename,ascii);
if ( yes ) {
if (-1 < verboseLevel) {
G4cout << "Lambda table for " << particleName << " is retrieved from <"
<< filename << ">"
<< G4endl;
}
PrintInfoDefinition();
if (-1 < verboseLevel) {
G4cout << "Lambda table for " << particleName << " is Retrieved from <"
<< filename << ">"
<< G4endl;
}
} else {
theLambdaTable->clearAndDestroy();
theLambdaTable = 0;
if (-1 < verboseLevel) {
G4cout << "Lambda table for " << particleName << " in file <"
<< filename << "> is not exist"
<< G4endl;
}
if (-1 < verboseLevel) {
G4cout << "Lambda table for " << particleName << " in file <"
<< filename << "> is not exist"
<< G4endl;
}
}
return yes;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::FindLambdaMax()
{
if(1 < verboseLevel) {
G4cout << "### FindLambdaMax: " << particle->GetParticleName()
<< " and process " << GetProcessName() << G4endl;
}
size_t n = theLambdaTable->length();
G4PhysicsVector* pv = (*theLambdaTable)[0];
size_t nb = pv->GetVectorLength();
G4double emax = pv->GetLowEdgeEnergy(nb);
G4double e, s, smax = 0.0;
theEnergyOfCrossSectionMax = new G4double [n];
theCrossSectionMax = new G4double [n];
G4bool b;
for (size_t i=0; i<n; i++) {
pv = (*theLambdaTable)[i];
smax = 0.0;
for (size_t j=0; j<nb; j++) {
e = pv->GetLowEdgeEnergy(j);
s = pv->GetValue(e,b);
if(s > smax) {
smax = s;
emax = e;
}
}
theEnergyOfCrossSectionMax[i] = emax;
theCrossSectionMax[i] = smax;
if(2 < verboseLevel) {
G4cout << "For " << particle->GetParticleName()
<< " Max CS at i= " << i << " emax(MeV)= " << emax/MeV
<< " lambda= " << smax << G4endl;
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -428,6 +474,13 @@ void G4VEmProcess::SetLambdaBinning(G4int nbins)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4int G4VEmProcess::LambdaBinning() const
{
return nLambdaBins;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::SetMinKinEnergy(G4double e)
{
minKinEnergy = e;
@@ -462,14 +515,27 @@ void G4VEmProcess::ActivateFluorescence(G4bool, const G4Region*)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::ActivateAugerElectronProduction(G4bool, const G4Region*)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::SetLambdaFactor(G4double val)
const G4PhysicsTable* G4VEmProcess::LambdaTable() const
{
if(val > 0.0 && val <= 1.0) lambdaFactor = val;
return theLambdaTable;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::SetIntegral(G4bool val)
{
integral = val;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4bool G4VEmProcess::IsIntegral() const
{
return integral;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....