Import Geant4 11.2.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2023-06-30 09:09:57 +02:00
parent aef78ca386
commit dd1f179cda
3780 changed files with 212808 additions and 142780 deletions
File diff suppressed because it is too large Load Diff
@@ -25,43 +25,44 @@
//
// Author: Zhuxin Li@CENBG
// 11 March 2020
// on the base of G4LivermoreGammaConversionModel
// derives from G4BetheHeitler5DModel
// on the base of G4LivermoreGammaConversionModel
// derives from G4BetheHeitler5DModel
// -------------------------------------------------------------------
#include "G4LivermoreGammaConversion5DModel.hh"
#include "G4Electron.hh"
#include "G4Positron.hh"
#include "G4EmParameters.hh"
#include "G4ParticleChangeForGamma.hh"
#include "G4PhysicsFreeVector.hh"
#include "G4PhysicsLogVector.hh"
#include "G4ProductionCutsTable.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include "G4Exp.hh"
#include "G4AutoLock.hh"
#include "G4Electron.hh"
#include "G4EmParameters.hh"
#include "G4Exp.hh"
#include "G4ParticleChangeForGamma.hh"
#include "G4PhysicalConstants.hh"
#include "G4PhysicsFreeVector.hh"
#include "G4SystemOfUnits.hh"
namespace { G4Mutex LivermoreGammaConversion5DModelMutex = G4MUTEX_INITIALIZER; }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
const G4int G4LivermoreGammaConversion5DModel::maxZ;
G4double G4LivermoreGammaConversion5DModel::lowEnergyLimit = 2.*CLHEP::electron_mass_c2;
G4PhysicsFreeVector* G4LivermoreGammaConversion5DModel::data[] = {nullptr};
G4LivermoreGammaConversion5DModel::G4LivermoreGammaConversion5DModel(const G4ParticleDefinition* p,
const G4String& nam)
: G4BetheHeitler5DModel(p, nam), fParticleChange(nullptr)
namespace
{
G4Mutex LivermoreGammaConversion5DModelMutex = G4MUTEX_INITIALIZER;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4PhysicsFreeVector* G4LivermoreGammaConversion5DModel::data[] = {nullptr};
G4String G4LivermoreGammaConversion5DModel::gDataDirectory = "";
G4LivermoreGammaConversion5DModel::G4LivermoreGammaConversion5DModel(const G4ParticleDefinition* p,
const G4String& nam)
: G4BetheHeitler5DModel(p, nam)
{
fParticleChange = nullptr;
lowEnergyLimit = 2. * CLHEP::electron_mass_c2;
verboseLevel = 0;
// Verbosity scale for debugging purposes:
// 0 = nothing
// 0 = nothing
// 1 = calculation of cross sections, file openings...
// 2 = entering in methods
if(verboseLevel > 0)
{
if (verboseLevel > 0) {
G4cout << "G4LivermoreGammaConversion5DModel is constructed " << G4endl;
}
}
@@ -70,11 +71,11 @@ G4LivermoreGammaConversion5DModel::G4LivermoreGammaConversion5DModel(const G4Par
G4LivermoreGammaConversion5DModel::~G4LivermoreGammaConversion5DModel()
{
if(IsMaster()) {
for(G4int i=0; i<maxZ; ++i) {
if(data[i]) {
delete data[i];
data[i] = nullptr;
if (IsMaster()) {
for (G4int i = 0; i < maxZ; ++i) {
if (data[i]) {
delete data[i];
data[i] = nullptr;
}
}
}
@@ -82,146 +83,140 @@ G4LivermoreGammaConversion5DModel::~G4LivermoreGammaConversion5DModel()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void
G4LivermoreGammaConversion5DModel::Initialise( const G4ParticleDefinition* particle,
const G4DataVector& cuts)
void G4LivermoreGammaConversion5DModel::Initialise(const G4ParticleDefinition* particle,
const G4DataVector& cuts)
{
G4BetheHeitler5DModel::Initialise(particle, cuts);
if (verboseLevel > 1)
{
G4cout << "Calling Initialise() of G4LivermoreGammaConversion5DModel."
<< G4endl
<< "Energy range: "
<< LowEnergyLimit() / MeV << " MeV - "
<< HighEnergyLimit() / GeV << " GeV isMater: " << IsMaster()
<< G4endl;
}
if(!fParticleChange) {
fParticleChange = GetParticleChangeForGamma();
G4BetheHeitler5DModel::Initialise(particle, cuts);
if (verboseLevel > 1) {
G4cout << "Calling Initialise() of G4LivermoreGammaConversion5DModel." << G4endl
<< "Energy range: " << LowEnergyLimit() / MeV << " MeV - " << HighEnergyLimit() / GeV
<< " GeV isMater: " << IsMaster() << G4endl;
}
if(IsMaster())
{
// Initialise element selector
InitialiseElementSelectors(particle, cuts);
// Access to elements
const char* path = G4FindDataDir("G4LEDATA");
G4ProductionCutsTable* theCoupleTable =
G4ProductionCutsTable::GetProductionCutsTable();
G4int numOfCouples = G4int(theCoupleTable->GetTableSize());
for(G4int i=0; i<numOfCouples; ++i)
{
const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(i);
SetCurrentCouple(couple);
const G4Material* mat = couple->GetMaterial();
const G4ElementVector* theElementVector = mat->GetElementVector();
std::size_t nelm = mat->GetNumberOfElements();
for (std::size_t j=0; j<nelm; ++j)
{
G4int Z = std::max(1, std::min((*theElementVector)[j]->GetZasInt(), maxZ));
if(!data[Z]) { ReadData(Z, path); }
}
}
}
if (IsMaster()) {
// Initialise element selector
InitialiseElementSelectors(particle, cuts);
// Access to elements
const G4ElementTable* elemTable = G4Element::GetElementTable();
std::size_t numElems = (*elemTable).size();
for (std::size_t ie = 0; ie < numElems; ++ie) {
const G4Element* elem = (*elemTable)[ie];
const G4int Z = std::min(maxZ, elem->GetZasInt());
if (data[Z] == nullptr) {
ReadData(Z);
}
}
}
if (isInitialised) {
return;
}
fParticleChange = GetParticleChangeForGamma();
isInitialised = true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4LivermoreGammaConversion5DModel::ReadData(size_t Z, const char* path)
const G4String& G4LivermoreGammaConversion5DModel::FindDirectoryPath()
{
if (verboseLevel > 1)
{
G4cout << "Calling ReadData() of G4LivermoreGammaConversion5DModel"
<< G4endl;
// no check in this method - environment variable is check by utility
if (gDataDirectory.empty()) {
auto param = G4EmParameters::Instance();
std::ostringstream ost;
if (param->LivermoreDataDir() == "livermore") {
ost << param->GetDirLEDATA() << "/livermore/pair/";
useSpline = true;
}
if(data[Z]) { return; }
const char* datadir = path;
if(!datadir)
{
datadir = G4FindDataDir("G4LEDATA");
if(!datadir)
{
G4Exception("G4LivermoreGammaConversion5DModel::ReadData()",
"em0006",FatalException,
"Environment variable G4LEDATA not defined");
return;
else {
ost << param->GetDirLEDATA() << "/epics2017/pair/";
}
gDataDirectory = ost.str();
}
return gDataDirectory;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4LivermoreGammaConversion5DModel::ReadData(const G4int Z)
{
if (verboseLevel > 1) {
G4cout << "Calling ReadData() of G4LivermoreGammaConversion5DModel" << G4endl;
}
if (data[Z]) {
return;
}
std::ostringstream ost;
if(G4EmParameters::Instance()->LivermoreDataDir() == "livermore"){
data[Z] = new G4PhysicsFreeVector(true);
ost << datadir << "/livermore/pair/pp-cs-" << Z <<".dat";
}else{
data[Z] = new G4PhysicsFreeVector();
ost << datadir << "/epics2017/pair/pp-cs-" << Z <<".dat";
}
ost << FindDirectoryPath() << "pp-cs-" << Z << ".dat";
data[Z] = new G4PhysicsFreeVector(useSpline);
std::ifstream fin(ost.str().c_str());
if( !fin.is_open())
{
if (!fin.is_open()) {
G4ExceptionDescription ed;
ed << "G4LivermoreGammaConversion5DModel data file <" << ost.str().c_str()
<< "> is not opened!" << G4endl;
G4Exception("G4LivermoreGammaConversion5DModel::ReadData()",
"em0003",FatalException,
ed,"G4LEDATA version should be G4EMLOW8.0 or later.");
ed << "G4LivermoreGammaConversion5DModel data file <" << ost.str().c_str() << "> is not opened!"
<< G4endl;
G4Exception("G4LivermoreGammaConversion5DModel::ReadData()", "em0003", FatalException, ed,
"G4LEDATA version should be G4EMLOW8.0 or later.");
return;
}
else
{
if(verboseLevel > 1) { G4cout << "File " << ost.str()
<< " is opened by G4LivermoreGammaConversion5DModel" << G4endl;}
data[Z]->Retrieve(fin, true);
}
}
else {
if (verboseLevel > 1) {
G4cout << "File " << ost.str() << " is opened by G4LivermoreGammaConversion5DModel" << G4endl;
}
data[Z]->Retrieve(fin, true);
}
// Activation of spline interpolation
if (useSpline) data[Z]->FillSecondDerivatives();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double
G4LivermoreGammaConversion5DModel::ComputeCrossSectionPerAtom(
const G4ParticleDefinition* particle, G4double GammaEnergy, G4double Z,
G4double, G4double, G4double)
G4double
G4LivermoreGammaConversion5DModel::ComputeCrossSectionPerAtom(const G4ParticleDefinition* particle,
G4double GammaEnergy, G4double Z,
G4double, G4double, G4double)
{
if (verboseLevel > 1)
{
G4cout << "G4LivermoreGammaConversion5DModel::ComputeCrossSectionPerAtom() Z= "
<< Z << G4endl;
if (verboseLevel > 1) {
G4cout << "G4LivermoreGammaConversion5DModel::ComputeCrossSectionPerAtom() Z= " << Z << G4endl;
}
G4double xs = 0.0;
if (GammaEnergy < lowEnergyLimit) { return xs; }
if (GammaEnergy < lowEnergyLimit) {
return xs;
}
G4int intZ = std::max(1, std::min(G4lrint(Z), maxZ));
G4PhysicsFreeVector* pv = data[intZ];
// if element was not initialised
// do initialisation safely for MT mode
if(!pv)
{
if (!pv) {
InitialiseForElement(particle, intZ);
pv = data[intZ];
if(!pv) { return xs; }
if (!pv) {
return xs;
}
}
// x-section is taken from the table
xs = pv->Value(GammaEnergy);
if(verboseLevel > 0)
{
G4cout << "*** Gamma conversion xs for Z=" << Z << " at energy E(MeV)="
<< GammaEnergy/MeV << " cs=" << xs/millibarn << " mb" << G4endl;
xs = pv->Value(GammaEnergy);
if (verboseLevel > 0) {
G4cout << "*** Gamma conversion xs for Z=" << Z << " at energy E(MeV)=" << GammaEnergy / MeV
<< " cs=" << xs / millibarn << " mb" << G4endl;
}
return xs;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4LivermoreGammaConversion5DModel::InitialiseForElement(
const G4ParticleDefinition*,
G4int Z)
void G4LivermoreGammaConversion5DModel::InitialiseForElement(const G4ParticleDefinition*, G4int Z)
{
G4AutoLock l(&LivermoreGammaConversion5DModelMutex);
if(!data[Z]) { ReadData(Z); }
if (!data[Z]) {
ReadData(Z);
}
l.unlock();
}
@@ -34,37 +34,39 @@
// -------------------------------------------------------------------
#include "G4LivermoreGammaConversionModel.hh"
#include "G4Electron.hh"
#include "G4Positron.hh"
#include "G4AutoLock.hh"
#include "G4Electron.hh"
#include "G4EmParameters.hh"
#include "G4ParticleChangeForGamma.hh"
#include "G4PhysicsFreeVector.hh"
#include "G4PhysicsLogVector.hh"
#include "G4ProductionCutsTable.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include "G4Exp.hh"
#include "G4ParticleChangeForGamma.hh"
#include "G4PhysicalConstants.hh"
#include "G4PhysicsFreeVector.hh"
#include "G4SystemOfUnits.hh"
namespace { G4Mutex LivermoreGammaConversionModelMutex = G4MUTEX_INITIALIZER; }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4LivermoreGammaConversionModel::lowEnergyLimit = 2.*CLHEP::electron_mass_c2;
G4PhysicsFreeVector* G4LivermoreGammaConversionModel::data[] = {nullptr};
G4LivermoreGammaConversionModel::G4LivermoreGammaConversionModel
(const G4ParticleDefinition* p, const G4String& nam)
: G4PairProductionRelModel(p,nam),fParticleChange(nullptr),maxZ(100)
namespace
{
G4Mutex LivermoreGammaConversionModelMutex = G4MUTEX_INITIALIZER;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4PhysicsFreeVector* G4LivermoreGammaConversionModel::data[] = {nullptr};
G4String G4LivermoreGammaConversionModel::gDataDirectory = "";
G4LivermoreGammaConversionModel::G4LivermoreGammaConversionModel(const G4ParticleDefinition* p,
const G4String& nam)
: G4PairProductionRelModel(p, nam)
{
fParticleChange = nullptr;
lowEnergyLimit = 2. * CLHEP::electron_mass_c2;
verboseLevel = 0;
// Verbosity scale for debugging purposes:
// 0 = nothing
// 1 = calculation of cross sections, file openings...
// 2 = entering in methods
if(verboseLevel > 0)
{
if (verboseLevel > 0) {
G4cout << "G4LivermoreGammaConversionModel is constructed " << G4endl;
}
}
@@ -73,11 +75,9 @@ G4LivermoreGammaConversionModel::G4LivermoreGammaConversionModel
G4LivermoreGammaConversionModel::~G4LivermoreGammaConversionModel()
{
if(IsMaster()) {
for(G4int i = 0; i <= maxZ; ++i)
{
if(data[i])
{
if (IsMaster()) {
for (G4int i = 0; i <= maxZ; ++i) {
if (data[i]) {
delete data[i];
data[i] = nullptr;
}
@@ -87,116 +87,110 @@ G4LivermoreGammaConversionModel::~G4LivermoreGammaConversionModel()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4LivermoreGammaConversionModel::Initialise(
const G4ParticleDefinition* particle,
const G4DataVector& cuts)
{ G4PairProductionRelModel::Initialise(particle, cuts);
if (verboseLevel > 1)
{
G4cout << "Calling Initialise() of G4LivermoreGammaConversionModel."
<< G4endl
<< "Energy range: "
<< LowEnergyLimit() / MeV << " MeV - "
<< HighEnergyLimit() / GeV << " GeV isMater: " << IsMaster()
<< G4endl;
void G4LivermoreGammaConversionModel::Initialise(const G4ParticleDefinition* particle,
const G4DataVector& cuts)
{
G4PairProductionRelModel::Initialise(particle, cuts);
if (verboseLevel > 1) {
G4cout << "Calling Initialise() of G4LivermoreGammaConversionModel." << G4endl
<< "Energy range: " << LowEnergyLimit() / MeV << " MeV - " << HighEnergyLimit() / GeV
<< " GeV isMater: " << IsMaster() << G4endl;
}
if(fParticleChange == nullptr) {
fParticleChange = GetParticleChangeForGamma();
}
if(IsMaster())
{
if (IsMaster()) {
// Initialise element selector
InitialiseElementSelectors(particle, cuts);
// Access to elements
const char* path = G4FindDataDir("G4LEDATA");
const G4ElementTable* elemTable = G4Element::GetElementTable();
size_t numElems = (*elemTable).size();
for(size_t ie = 0; ie < numElems; ++ie)
{
std::size_t numElems = (*elemTable).size();
for (std::size_t ie = 0; ie < numElems; ++ie) {
const G4Element* elem = (*elemTable)[ie];
const G4int Z = std::min(maxZ, elem->GetZasInt());
if(data[Z] == nullptr)
{
ReadData(Z, path);
const G4int Z = std::min(maxZ, elem->GetZasInt());
if (data[Z] == nullptr) {
ReadData(Z);
}
}
}
if (isInitialised) {
return;
}
fParticleChange = GetParticleChangeForGamma();
isInitialised = true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4LivermoreGammaConversionModel::ReadData(size_t Z, const char* path)
const G4String& G4LivermoreGammaConversionModel::FindDirectoryPath()
{
if (verboseLevel > 1)
{
G4cout << "Calling ReadData() of G4LivermoreGammaConversionModel"
<< G4endl;
// no check in this method - environment variable is check by utility
if (gDataDirectory.empty()) {
auto param = G4EmParameters::Instance();
std::ostringstream ost;
if (param->LivermoreDataDir() == "livermore") {
ost << param->GetDirLEDATA() << "/livermore/pair/";
useSpline = true;
}
else {
ost << param->GetDirLEDATA() << "/epics2017/pair/";
}
gDataDirectory = ost.str();
}
return gDataDirectory;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4LivermoreGammaConversionModel::ReadData(const G4int Z)
{
if (verboseLevel > 1) {
G4cout << "Calling ReadData() of G4LivermoreGammaConversionModel" << G4endl;
}
if(data[Z]!= nullptr) { return; }
const char* datadir = path;
if(datadir == nullptr)
{
datadir = G4FindDataDir("G4LEDATA");
if(datadir == nullptr)
{
G4Exception("G4LivermoreGammaConversionModel::ReadData()",
"em0006",FatalException,
"Environment variable G4LEDATA not defined");
return;
}
if (data[Z] != nullptr) {
return;
}
std::ostringstream ost;
if(G4EmParameters::Instance()->LivermoreDataDir() == "livermore"){
data[Z] = new G4PhysicsFreeVector(true);
ost << datadir << "/livermore/pair/pp-cs-" << Z <<".dat";
}else{
data[Z] = new G4PhysicsFreeVector();
ost << datadir << "/epics2017/pair/pp-cs-" << Z <<".dat";
}
ost << FindDirectoryPath() << "pp-cs-" << Z << ".dat";
data[Z] = new G4PhysicsFreeVector(useSpline);
std::ifstream fin(ost.str().c_str());
if( !fin.is_open())
{
if (!fin.is_open()) {
G4ExceptionDescription ed;
ed << "G4LivermoreGammaConversionModel data file <" << ost.str().c_str()
<< "> is not opened!" << G4endl;
G4Exception("G4LivermoreGammaConversionModel::ReadData()",
"em0003",FatalException,
ed,"G4LEDATA version should be G4EMLOW8.0 or later.");
ed << "G4LivermoreGammaConversionModel data file <" << ost.str().c_str() << "> is not opened!"
<< G4endl;
G4Exception("G4LivermoreGammaConversionModel::ReadData()", "em0003", FatalException, ed,
"G4LEDATA version should be G4EMLOW8.0 or later.");
return;
}
else
{
if(verboseLevel > 1) { G4cout << "File " << ost.str()
<< " is opened by G4LivermoreGammaConversionModel" << G4endl;}
else {
if (verboseLevel > 1) {
G4cout << "File " << ost.str() << " is opened by G4LivermoreGammaConversionModel" << G4endl;
}
data[Z]->Retrieve(fin, true);
}
// Activation of spline interpolation
if (useSpline) data[Z]->FillSecondDerivatives();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4LivermoreGammaConversionModel::ComputeCrossSectionPerAtom(
const G4ParticleDefinition* particle,
G4double GammaEnergy, G4double Z, G4double, G4double, G4double)
G4double
G4LivermoreGammaConversionModel::ComputeCrossSectionPerAtom(const G4ParticleDefinition* particle,
G4double GammaEnergy, G4double Z,
G4double, G4double, G4double)
{
if (verboseLevel > 1)
{
G4cout << "G4LivermoreGammaConversionModel::ComputeCrossSectionPerAtom() Z= "
<< Z << G4endl;
if (verboseLevel > 1) {
G4cout << "G4LivermoreGammaConversionModel::ComputeCrossSectionPerAtom() Z= " << Z << G4endl;
}
if (GammaEnergy < lowEnergyLimit) { return 0.0; }
if (GammaEnergy < lowEnergyLimit) {
return 0.0;
}
G4double xs = 0.0;
@@ -206,31 +200,31 @@ G4double G4LivermoreGammaConversionModel::ComputeCrossSectionPerAtom(
// if element was not initialised
// do initialisation safely for MT mode
if(pv == nullptr)
{
if (pv == nullptr) {
InitialiseForElement(particle, intZ);
pv = data[intZ];
if(pv == nullptr) { return xs; }
if (pv == nullptr) {
return xs;
}
}
// x-section is taken from the table
xs = pv->Value(GammaEnergy);
if(verboseLevel > 0)
{
G4cout << "*** Gamma conversion xs for Z=" << Z << " at energy E(MeV)="
<< GammaEnergy/MeV << " cs=" << xs/millibarn << " mb" << G4endl;
}
if (verboseLevel > 0) {
G4cout << "*** Gamma conversion xs for Z=" << Z << " at energy E(MeV)=" << GammaEnergy / MeV
<< " cs=" << xs / millibarn << " mb" << G4endl;
}
return xs;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4LivermoreGammaConversionModel::InitialiseForElement(
const G4ParticleDefinition*,
G4int Z)
void G4LivermoreGammaConversionModel::InitialiseForElement(const G4ParticleDefinition*, G4int Z)
{
G4AutoLock l(&LivermoreGammaConversionModelMutex);
if(data[Z] == nullptr) { ReadData(Z); }
if (data[Z] == nullptr) {
ReadData(Z);
}
l.unlock();
}
File diff suppressed because it is too large Load Diff
@@ -29,51 +29,49 @@
//
#include "G4LivermoreRayleighModel.hh"
#include "G4SystemOfUnits.hh"
#include "G4RayleighAngularGenerator.hh"
#include "G4EmParameters.hh"
#include "G4AutoLock.hh"
#include "G4EmParameters.hh"
#include "G4RayleighAngularGenerator.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
using namespace std;
namespace { G4Mutex LivermoreRayleighModelMutex = G4MUTEX_INITIALIZER; }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
namespace
{
G4Mutex LivermoreRayleighModelMutex = G4MUTEX_INITIALIZER;
}
G4PhysicsFreeVector* G4LivermoreRayleighModel::dataCS[] = {nullptr};
G4String G4LivermoreRayleighModel::gDataDirectory = "";
G4LivermoreRayleighModel::G4LivermoreRayleighModel()
:G4VEmModel("LivermoreRayleigh"),maxZ(100),isInitialised(false)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4LivermoreRayleighModel::G4LivermoreRayleighModel() : G4VEmModel("LivermoreRayleigh")
{
fParticleChange = nullptr;
lowEnergyLimit = 10 * CLHEP::eV;
lowEnergyLimit = 10 * CLHEP::eV;
SetAngularDistribution(new G4RayleighAngularGenerator());
verboseLevel= 0;
verboseLevel = 0;
// Verbosity scale for debugging purposes:
// 0 = nothing
// 0 = nothing
// 1 = calculation of cross sections, file openings...
// 2 = entering in methods
if(verboseLevel > 0)
{
if (verboseLevel > 0) {
G4cout << "G4LivermoreRayleighModel is constructed " << G4endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4LivermoreRayleighModel::~G4LivermoreRayleighModel()
{
if(IsMaster())
{
for(G4int i = 0; i <= maxZ; ++i)
{
if(dataCS[i])
{
if (IsMaster()) {
for (G4int i = 0; i <= maxZ; ++i) {
if (nullptr != dataCS[i]) {
delete dataCS[i];
dataCS[i] = nullptr;
}
@@ -84,191 +82,183 @@ G4LivermoreRayleighModel::~G4LivermoreRayleighModel()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4LivermoreRayleighModel::Initialise(const G4ParticleDefinition* particle,
const G4DataVector& cuts)
const G4DataVector& cuts)
{
if (verboseLevel > 1)
{
if (verboseLevel > 1) {
G4cout << "Calling Initialise() of G4LivermoreRayleighModel." << G4endl
<< "Energy range: "
<< LowEnergyLimit() / eV << " eV - "
<< HighEnergyLimit() / GeV << " GeV"
<< G4endl;
<< "Energy range: " << LowEnergyLimit() / eV << " eV - " << HighEnergyLimit() / GeV
<< " GeV" << G4endl;
}
if(IsMaster()) {
if (IsMaster()) {
// Initialise element selector
InitialiseElementSelectors(particle, cuts);
// Access to elements
const char* path = G4FindDataDir("G4LEDATA");
const G4ElementTable* elemTable = G4Element::GetElementTable();
std::size_t numElems = (*elemTable).size();
for(std::size_t ie = 0; ie < numElems; ++ie)
{
std::size_t numElems = (*elemTable).size();
for (std::size_t ie = 0; ie < numElems; ++ie) {
const G4Element* elem = (*elemTable)[ie];
const G4int Z = std::min(maxZ, elem->GetZasInt());
if(dataCS[Z] == nullptr)
{
ReadData(Z, path);
const G4int Z = std::min(maxZ, elem->GetZasInt());
if (dataCS[Z] == nullptr) {
ReadData(Z);
}
}
}
if(isInitialised) { return; }
if (isInitialised) {
return;
}
fParticleChange = GetParticleChangeForGamma();
isInitialised = true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4LivermoreRayleighModel::InitialiseLocal(const G4ParticleDefinition*,
G4VEmModel* masterModel)
void G4LivermoreRayleighModel::InitialiseLocal(const G4ParticleDefinition*, G4VEmModel* masterModel)
{
SetElementSelectors(masterModel->GetElementSelectors());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4LivermoreRayleighModel::ReadData(std::size_t Z, const char* path)
const G4String& G4LivermoreRayleighModel::FindDirectoryPath()
{
if (verboseLevel > 1)
{
G4cout << "Calling ReadData() of G4LivermoreRayleighModel"
<< G4endl;
}
if(nullptr != dataCS[Z]) { return; }
const char* datadir = path;
if(datadir == nullptr)
{
datadir = G4FindDataDir("G4LEDATA");
if(datadir == nullptr)
{
G4Exception("G4LivermoreRayleighModelModel::ReadData()","em0006",
FatalException,
"Environment variable G4LEDATA not defined");
return;
// no check in this method - environment variable is check by utility
if (gDataDirectory.empty()) {
auto param = G4EmParameters::Instance();
std::ostringstream ost;
if (param->LivermoreDataDir() == "livermore") {
ost << param->GetDirLEDATA() << "/livermore/rayl/";
}
}
dataCS[Z] = new G4PhysicsFreeVector();
std::ostringstream ostCS;
if(G4EmParameters::Instance()->LivermoreDataDir() == "livermore"){
ostCS << datadir << "/livermore/rayl/re-cs-" << Z <<".dat";
}else{
ostCS << datadir << "/epics2017/rayl/re-cs-" << Z <<".dat";
}
std::ifstream finCS(ostCS.str().c_str());
if( !finCS .is_open() )
{
G4ExceptionDescription ed;
ed << "G4LivermoreRayleighModel data file <" << ostCS.str().c_str()
<< "> is not opened!" << G4endl;
G4Exception("G4LivermoreRayleighModel::ReadData()","em0003",FatalException,
ed,"G4LEDATA version should be G4EMLOW8.0 or later.");
return;
}
else
{
if(verboseLevel > 3) {
G4cout << "File " << ostCS.str()
<< " is opened by G4LivermoreRayleighModel" << G4endl;
else {
ost << param->GetDirLEDATA() << "/epics2017/rayl/";
}
dataCS[Z]->Retrieve(finCS, true);
}
gDataDirectory = ost.str();
}
return gDataDirectory;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4LivermoreRayleighModel::ComputeCrossSectionPerAtom(
const G4ParticleDefinition*,
G4double GammaEnergy,
G4double Z, G4double,
G4double, G4double)
void G4LivermoreRayleighModel::ReadData(const G4int ZZ)
{
if (verboseLevel > 1)
{
G4cout << "G4LivermoreRayleighModel::ComputeCrossSectionPerAtom()"
<< G4endl;
if (verboseLevel > 1) {
G4cout << "Calling ReadData() of G4LivermoreRayleighModel for Z=" << ZZ << G4endl;
}
const G4int Z = std::min(ZZ, maxZ);
if (nullptr != dataCS[Z]) {
return;
}
dataCS[Z] = new G4PhysicsFreeVector();
std::ostringstream ostCS;
ostCS << FindDirectoryPath() << "re-cs-" << Z << ".dat";
std::ifstream finCS(ostCS.str().c_str());
if (!finCS.is_open()) {
G4ExceptionDescription ed;
ed << "G4LivermoreRayleighModel data file <" << ostCS.str().c_str() << "> is not opened!"
<< G4endl;
G4Exception("G4LivermoreRayleighModel::ReadData()", "em0003", FatalException, ed,
"G4LEDATA version should be G4EMLOW8.0 or later.");
return;
}
else {
if (verboseLevel > 3) {
G4cout << "File " << ostCS.str() << " is opened by G4LivermoreRayleighModel" << G4endl;
}
dataCS[Z]->Retrieve(finCS, true);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4LivermoreRayleighModel::ComputeCrossSectionPerAtom(const G4ParticleDefinition*,
G4double GammaEnergy, G4double Z,
G4double, G4double, G4double)
{
if (verboseLevel > 1) {
G4cout << "G4LivermoreRayleighModel::ComputeCrossSectionPerAtom()" << G4endl;
}
if (GammaEnergy < lowEnergyLimit) {
return 0.0;
}
if(GammaEnergy < lowEnergyLimit) { return 0.0; }
G4double xs = 0.0;
G4int intZ = G4lrint(Z);
if(intZ < 1 || intZ > maxZ) { return xs; }
if (intZ < 1 || intZ > maxZ) {
return xs;
}
G4PhysicsFreeVector* pv = dataCS[intZ];
// if element was not initialised
// do initialisation safely for MT mode
if(nullptr == pv) {
InitialiseForElement(0, intZ);
if (nullptr == pv) {
InitialiseForElement(nullptr, intZ);
pv = dataCS[intZ];
if(nullptr == pv) { return xs; }
if (nullptr == pv) {
return xs;
}
}
G4int n = G4int(pv->GetVectorLength() - 1);
G4double e = GammaEnergy/MeV;
if(e >= pv->Energy(n)) {
xs = (*pv)[n]/(e*e);
} else if(e >= pv->Energy(0)) {
xs = pv->Value(e)/(e*e);
auto n = G4int(pv->GetVectorLength() - 1);
G4double e = GammaEnergy / MeV;
if (e >= pv->Energy(n)) {
xs = (*pv)[n] / (e * e);
}
else if (e >= pv->Energy(0)) {
xs = pv->Value(e) / (e * e);
}
if(verboseLevel > 1)
{
G4cout << "****** DEBUG: tcs value for Z=" << Z << " at energy (MeV)="
<< e << G4endl;
G4cout << " cs (Geant4 internal unit)=" << xs << G4endl;
G4cout << " -> first E*E*cs value in CS data file (iu) =" << (*pv)[0]
<< G4endl;
G4cout << " -> last E*E*cs value in CS data file (iu) =" << (*pv)[n]
<< G4endl;
G4cout << "*********************************************************"
<< G4endl;
if (verboseLevel > 1) {
G4cout << "****** DEBUG: tcs value for Z=" << Z << " at energy (MeV)=" << e << G4endl;
G4cout << " cs (Geant4 internal unit)=" << xs << G4endl;
G4cout << " -> first E*E*cs value in CS data file (iu) =" << (*pv)[0] << G4endl;
G4cout << " -> last E*E*cs value in CS data file (iu) =" << (*pv)[n] << G4endl;
G4cout << "*********************************************************" << G4endl;
}
return xs;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4LivermoreRayleighModel::SampleSecondaries(
std::vector<G4DynamicParticle*>*,
const G4MaterialCutsCouple* couple,
const G4DynamicParticle* aDynamicGamma,
G4double, G4double)
void G4LivermoreRayleighModel::SampleSecondaries(std::vector<G4DynamicParticle*>*,
const G4MaterialCutsCouple* couple,
const G4DynamicParticle* aDynamicGamma, G4double,
G4double)
{
if (verboseLevel > 1) {
G4cout << "Calling SampleSecondaries() of G4LivermoreRayleighModel"
<< G4endl;
G4cout << "Calling SampleSecondaries() of G4LivermoreRayleighModel" << G4endl;
}
G4double photonEnergy0 = aDynamicGamma->GetKineticEnergy();
// Select randomly one element in the current material
const G4ParticleDefinition* particle = aDynamicGamma->GetDefinition();
const G4Element* elm = SelectRandomAtom(couple,particle,photonEnergy0);
G4int Z = G4lrint(elm->GetZ());
// Sample the angle of the scattered photon
G4ThreeVector photonDirection =
GetAngularDistribution()->SampleDirection(aDynamicGamma,
photonEnergy0,
Z, couple->GetMaterial());
// Select randomly one element in the current material
const G4ParticleDefinition* particle = aDynamicGamma->GetDefinition();
const G4Element* elm = SelectRandomAtom(couple, particle, photonEnergy0);
G4int Z = elm->GetZasInt();
// Sample the angle of the scattered photon
G4ThreeVector photonDirection = GetAngularDistribution()->SampleDirection(
aDynamicGamma, photonEnergy0, Z, couple->GetMaterial());
fParticleChange->ProposeMomentumDirection(photonDirection);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void
G4LivermoreRayleighModel::InitialiseForElement(const G4ParticleDefinition*,
G4int Z)
void G4LivermoreRayleighModel::InitialiseForElement(const G4ParticleDefinition*, G4int Z)
{
if (nullptr != dataCS[Z]) {
return;
}
G4AutoLock l(&LivermoreRayleighModelMutex);
if(nullptr == dataCS[Z]) { ReadData(Z); }
if (nullptr == dataCS[Z]) {
ReadData(Z);
}
l.unlock();
}
@@ -52,21 +52,14 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
using namespace std;
G4LowEWentzelVIModel::G4LowEWentzelVIModel() :
G4WentzelVIModel(false,"LowEnWentzelVI")
G4WentzelVIModel(true, "LowEnWentzelVI")
{
SetSingleScatteringFactor(0.5);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4LowEWentzelVIModel::~G4LowEWentzelVIModel()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4LowEWentzelVIModel::ComputeTruePathLengthLimit(
const G4Track& track,
G4double& currentMinimalStep)