Import Geant4 11.0.0 source tree
This commit is contained in:
committed by
Ben Morgan
parent
6399a014b6
commit
80e2389dd8
@@ -30,7 +30,7 @@
|
||||
//
|
||||
// Modifications: Zhuxin Li@CENBG
|
||||
// 11 March 2020
|
||||
// derives from G4PairProductionRelModel
|
||||
// derives from G4PairProductionRelModel
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
#include "G4LivermoreGammaConversionModel.hh"
|
||||
@@ -51,20 +51,19 @@ namespace { G4Mutex LivermoreGammaConversionModelMutex = G4MUTEX_INITIALIZER; }
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
const G4int G4LivermoreGammaConversionModel::maxZ;
|
||||
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)
|
||||
: G4PairProductionRelModel(p,nam),fParticleChange(nullptr),maxZ(100)
|
||||
{
|
||||
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 << "G4LivermoreGammaConversionModel is constructed " << G4endl;
|
||||
}
|
||||
@@ -75,10 +74,12 @@ G4LivermoreGammaConversionModel::G4LivermoreGammaConversionModel
|
||||
G4LivermoreGammaConversionModel::~G4LivermoreGammaConversionModel()
|
||||
{
|
||||
if(IsMaster()) {
|
||||
for(G4int i=0; i<maxZ; ++i) {
|
||||
if(data[i]) {
|
||||
delete data[i];
|
||||
data[i] = nullptr;
|
||||
for(G4int i = 0; i <= maxZ; ++i)
|
||||
{
|
||||
if(data[i])
|
||||
{
|
||||
delete data[i];
|
||||
data[i] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,44 +91,36 @@ void G4LivermoreGammaConversionModel::Initialise(
|
||||
const G4ParticleDefinition* particle,
|
||||
const G4DataVector& cuts)
|
||||
{ G4PairProductionRelModel::Initialise(particle, cuts);
|
||||
if (verboseLevel > 1)
|
||||
if (verboseLevel > 1)
|
||||
{
|
||||
G4cout << "Calling Initialise() of G4LivermoreGammaConversionModel."
|
||||
G4cout << "Calling Initialise() of G4LivermoreGammaConversionModel."
|
||||
<< G4endl
|
||||
<< "Energy range: "
|
||||
<< LowEnergyLimit() / MeV << " MeV - "
|
||||
<< HighEnergyLimit() / GeV << " GeV isMater: " << IsMaster()
|
||||
<< HighEnergyLimit() / GeV << " GeV isMater: " << IsMaster()
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
if(!fParticleChange) {
|
||||
if(fParticleChange == nullptr) {
|
||||
fParticleChange = GetParticleChangeForGamma();
|
||||
}
|
||||
|
||||
if(IsMaster())
|
||||
|
||||
if(IsMaster())
|
||||
{
|
||||
// Initialise element selector
|
||||
InitialiseElementSelectors(particle, cuts);
|
||||
|
||||
// Access to elements
|
||||
char* path = std::getenv("G4LEDATA");
|
||||
G4ProductionCutsTable* theCoupleTable =
|
||||
G4ProductionCutsTable::GetProductionCutsTable();
|
||||
|
||||
G4int numOfCouples = theCoupleTable->GetTableSize();
|
||||
|
||||
for(G4int i=0; i<numOfCouples; ++i)
|
||||
const G4ElementTable* elemTable = G4Element::GetElementTable();
|
||||
size_t numElems = (*elemTable).size();
|
||||
for(size_t ie = 0; ie < numElems; ++ie)
|
||||
{
|
||||
const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(i);
|
||||
SetCurrentCouple(couple);
|
||||
const G4Material* mat = couple->GetMaterial();
|
||||
const G4ElementVector* theElementVector = mat->GetElementVector();
|
||||
G4int nelm = mat->GetNumberOfElements();
|
||||
|
||||
for (G4int j=0; j<nelm; ++j)
|
||||
const G4Element* elem = (*elemTable)[ie];
|
||||
const G4int Z = std::min(maxZ, elem->GetZasInt());
|
||||
if(data[Z] == nullptr)
|
||||
{
|
||||
G4int Z = std::min((*theElementVector)[j]->GetZasInt(), maxZ);
|
||||
if(!data[Z]) { ReadData(Z, path); }
|
||||
ReadData(Z, path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,20 +131,20 @@ void G4LivermoreGammaConversionModel::Initialise(
|
||||
|
||||
void G4LivermoreGammaConversionModel::ReadData(size_t Z, const char* path)
|
||||
{
|
||||
if (verboseLevel > 1)
|
||||
if (verboseLevel > 1)
|
||||
{
|
||||
G4cout << "Calling ReadData() of G4LivermoreGammaConversionModel"
|
||||
G4cout << "Calling ReadData() of G4LivermoreGammaConversionModel"
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
if(data[Z]) { return; }
|
||||
|
||||
if(data[Z]!= nullptr) { return; }
|
||||
|
||||
const char* datadir = path;
|
||||
|
||||
if(!datadir)
|
||||
if(datadir == nullptr)
|
||||
{
|
||||
datadir = std::getenv("G4LEDATA");
|
||||
if(!datadir)
|
||||
if(datadir == nullptr)
|
||||
{
|
||||
G4Exception("G4LivermoreGammaConversionModel::ReadData()",
|
||||
"em0006",FatalException,
|
||||
@@ -161,10 +154,15 @@ void G4LivermoreGammaConversionModel::ReadData(size_t Z, const char* path)
|
||||
}
|
||||
data[Z] = new G4PhysicsFreeVector();
|
||||
std::ostringstream ost;
|
||||
ost << datadir << "/epics2017/pair/pp-cs-" << Z <<".dat";
|
||||
if(G4EmParameters::Instance()->LivermoreDataDir() == "livermore"){
|
||||
ost << datadir << "/livermore/pair/pp-cs-" << Z <<".dat";
|
||||
}else{
|
||||
ost << datadir << "/epics2017/pair/pp-cs-" << Z <<".dat";
|
||||
}
|
||||
|
||||
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()
|
||||
@@ -173,15 +171,15 @@ void G4LivermoreGammaConversionModel::ReadData(size_t Z, const char* path)
|
||||
"em0003",FatalException,
|
||||
ed,"G4LEDATA version should be G4EMLOW6.27 or later.");
|
||||
return;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if(verboseLevel > 1) { G4cout << "File " << ost.str()
|
||||
|
||||
if(verboseLevel > 1) { G4cout << "File " << ost.str()
|
||||
<< " is opened by G4LivermoreGammaConversionModel" << G4endl;}
|
||||
|
||||
|
||||
data[Z]->Retrieve(fin, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
@@ -190,34 +188,34 @@ G4double G4LivermoreGammaConversionModel::ComputeCrossSectionPerAtom(
|
||||
const G4ParticleDefinition* particle,
|
||||
G4double GammaEnergy, G4double Z, G4double, G4double, G4double)
|
||||
{
|
||||
if (verboseLevel > 1)
|
||||
if (verboseLevel > 1)
|
||||
{
|
||||
G4cout << "G4LivermoreGammaConversionModel::ComputeCrossSectionPerAtom() Z= "
|
||||
G4cout << "G4LivermoreGammaConversionModel::ComputeCrossSectionPerAtom() Z= "
|
||||
<< Z << G4endl;
|
||||
}
|
||||
|
||||
if (GammaEnergy < lowEnergyLimit) { return 0.0; }
|
||||
if (GammaEnergy < lowEnergyLimit) { return 0.0; }
|
||||
|
||||
G4double xs = 0.0;
|
||||
|
||||
|
||||
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 == nullptr)
|
||||
{
|
||||
InitialiseForElement(particle, intZ);
|
||||
pv = data[intZ];
|
||||
if(!pv) { return xs; }
|
||||
if(pv == nullptr) { return xs; }
|
||||
}
|
||||
// x-section is taken from the table
|
||||
xs = pv->Value(GammaEnergy);
|
||||
xs = pv->Value(GammaEnergy);
|
||||
|
||||
if(verboseLevel > 0)
|
||||
{
|
||||
G4cout << "*** Gamma conversion xs for Z=" << Z << " at energy E(MeV)="
|
||||
G4cout << "*** Gamma conversion xs for Z=" << Z << " at energy E(MeV)="
|
||||
<< GammaEnergy/MeV << " cs=" << xs/millibarn << " mb" << G4endl;
|
||||
}
|
||||
return xs;
|
||||
@@ -226,11 +224,11 @@ G4double G4LivermoreGammaConversionModel::ComputeCrossSectionPerAtom(
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void G4LivermoreGammaConversionModel::InitialiseForElement(
|
||||
const G4ParticleDefinition*,
|
||||
const G4ParticleDefinition*,
|
||||
G4int Z)
|
||||
{
|
||||
G4AutoLock l(&LivermoreGammaConversionModelMutex);
|
||||
if(!data[Z]) { ReadData(Z); }
|
||||
if(data[Z] == nullptr) { ReadData(Z); }
|
||||
l.unlock();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user