Import Geant4 11.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2021-12-10 16:15:15 +00:00
committed by Ben Morgan
parent 6399a014b6
commit 80e2389dd8
3932 changed files with 202519 additions and 246221 deletions
@@ -31,6 +31,7 @@
#include "G4LivermoreRayleighModel.hh"
#include "G4SystemOfUnits.hh"
#include "G4RayleighAngularGenerator.hh"
#include "G4EmParameters.hh"
#include "G4AutoLock.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -43,10 +44,10 @@ namespace { G4Mutex LivermoreRayleighModelMutex = G4MUTEX_INITIALIZER; }
G4PhysicsFreeVector* G4LivermoreRayleighModel::dataCS[] = {nullptr};
G4LivermoreRayleighModel::G4LivermoreRayleighModel()
:G4VEmModel("LivermoreRayleigh"),isInitialised(false)
:G4VEmModel("LivermoreRayleigh"),maxZ(100),isInitialised(false)
{
fParticleChange = nullptr;
lowEnergyLimit = 10 * eV;
lowEnergyLimit = 10 * CLHEP::eV;
SetAngularDistribution(new G4RayleighAngularGenerator());
@@ -67,11 +68,14 @@ G4LivermoreRayleighModel::G4LivermoreRayleighModel()
G4LivermoreRayleighModel::~G4LivermoreRayleighModel()
{
if(IsMaster()) {
for(G4int i=0; i<maxZ; ++i) {
if(dataCS[i]) {
delete dataCS[i];
dataCS[i] = nullptr;
if(IsMaster())
{
for(G4int i = 0; i <= maxZ; ++i)
{
if(dataCS[i])
{
delete dataCS[i];
dataCS[i] = nullptr;
}
}
}
@@ -97,26 +101,17 @@ void G4LivermoreRayleighModel::Initialise(const G4ParticleDefinition* particle,
// 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 G4Element* elem = (*elemTable)[ie];
const G4int Z = std::min(maxZ, elem->GetZasInt());
if(dataCS[Z] == nullptr)
{
const G4MaterialCutsCouple* couple =
theCoupleTable->GetMaterialCutsCouple(i);
const G4Material* material = couple->GetMaterial();
const G4ElementVector* theElementVector = material->GetElementVector();
G4int nelm = material->GetNumberOfElements();
for (G4int j=0; j<nelm; ++j)
{
G4int Z = (*theElementVector)[j]->GetZasInt();
if(Z < 1) { Z = 1; }
else if(Z > maxZ) { Z = maxZ; }
if( (!dataCS[Z]) ) { ReadData(Z, path); }
}
ReadData(Z, path);
}
}
}
if(isInitialised) { return; }
fParticleChange = GetParticleChangeForGamma();
@@ -141,14 +136,14 @@ void G4LivermoreRayleighModel::ReadData(size_t Z, const char* path)
<< G4endl;
}
if(dataCS[Z]) { return; }
if(nullptr != dataCS[Z]) { return; }
const char* datadir = path;
if(!datadir)
if(datadir == nullptr)
{
datadir = std::getenv("G4LEDATA");
if(!datadir)
if(datadir == nullptr)
{
G4Exception("G4LivermoreRayleighModelModel::ReadData()","em0006",
FatalException,
@@ -159,7 +154,12 @@ void G4LivermoreRayleighModel::ReadData(size_t Z, const char* path)
dataCS[Z] = new G4PhysicsFreeVector();
std::ostringstream ostCS;
ostCS << datadir << "/livermore/rayl/re-cs-" << Z <<".dat";
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() )
@@ -205,10 +205,10 @@ G4double G4LivermoreRayleighModel::ComputeCrossSectionPerAtom(
// if element was not initialised
// do initialisation safely for MT mode
if(!pv) {
if(nullptr == pv) {
InitialiseForElement(0, intZ);
pv = dataCS[intZ];
if(!pv) { return xs; }
if(nullptr == pv) { return xs; }
}
G4int n = pv->GetVectorLength() - 1;
@@ -219,7 +219,7 @@ G4double G4LivermoreRayleighModel::ComputeCrossSectionPerAtom(
xs = pv->Value(e)/(e*e);
}
if(verboseLevel > 0)
if(verboseLevel > 1)
{
G4cout << "****** DEBUG: tcs value for Z=" << Z << " at energy (MeV)="
<< e << G4endl;
@@ -268,7 +268,7 @@ G4LivermoreRayleighModel::InitialiseForElement(const G4ParticleDefinition*,
G4int Z)
{
G4AutoLock l(&LivermoreRayleighModelMutex);
if(!dataCS[Z]) { ReadData(Z); }
if(nullptr == dataCS[Z]) { ReadData(Z); }
l.unlock();
}