58G4double G4NeutronElasticXS::coeff[] = {1.0};
59G4String G4NeutronElasticXS::gDataDirectory =
"";
61static std::once_flag applyOnce;
73 G4cout <<
"G4NeutronElasticXS::G4NeutronElasticXS Initialise for Z < "
78 if (ggXsection ==
nullptr)
81 if (
nullptr == data) {
83 data->SetName(
"nElastic");
85 dataR->SetName(
"nRElastic");
92 outFile <<
"G4NeutronElasticXS calculates the neutron elastic scattering\n"
93 <<
"cross section on nuclei using data from the high precision\n"
94 <<
"neutron database. These data are simplified and smoothed over\n"
95 <<
"the resonance region in order to reduce CPU time.\n"
96 <<
"For high energies Glauber-Gribiv cross section is used.\n";
133 G4int Z = std::min(ZZ, MAXZEL-1);
138 if (fRfilesEnabled) {
139 auto pv = GetPhysicsVectorR(Z);
140 if (
nullptr != pv && ekin < el_max_r_e[Z]) {
141 xs = pv->LogVectorValue(ekin, loge);
147 auto pv = GetPhysicsVector(Z);
148 xs = (ekin <= pv->GetMaxEnergy()) ? pv->LogVectorValue(ekin, loge)
149 : coeff[Z]*ggXsection->GetElasticElementCrossSection(neutron, ekin,
155 G4cout <<
"Z= " << Z <<
" Ekin(MeV)= " << ekin/CLHEP::MeV
156 <<
", nElmXSel(b)= " << xs/CLHEP::barn
170 G4int Z = std::min(ZZ, MAXZEL-1);
180 G4int Z = std::min(ZZ, MAXZEL-1);
192 if(1 == nIso) {
return iso; }
199 for (
G4int j=0; j<nIso; ++j) {
200 sum += abundVector[j];
213 G4cout <<
"G4NeutronElasticXS::BuildPhysicsTable for "
219 <<
" only neutron is allowed";
220 G4Exception(
"G4NeutronElasticXS::BuildPhysicsTable(..)",
"had012",
228 std::call_once(applyOnce, [
this]() { isInitializer =
true; });
235 for (
auto const & elm : *table ) {
236 G4int Z = std::max( 1, std::min( elm->GetZasInt(), MAXZEL-1) );
237 if (
nullptr == data->GetElementData(Z) ) { Initialise(Z); }
243const G4String& G4NeutronElasticXS::FindDirectoryPath()
246 if (gDataDirectory.empty()) {
247 std::ostringstream ost;
249 gDataDirectory = ost.str();
251 return gDataDirectory;
254void G4NeutronElasticXS::InitialiseOnFly(
G4int Z)
261void G4NeutronElasticXS::Initialise(
G4int Z)
263 if (
nullptr != data->GetElementData(Z)) {
return; }
266 std::ostringstream ost;
267 ost << FindDirectoryPath() <<
"el" << Z;
268 G4PhysicsVector* v = RetrieveVector(ost,
true);
269 data->InitialiseForElement(Z, v);
271 G4PhysicsVector* vr =
nullptr;
272 if (fRfilesEnabled) {
273 std::ostringstream ostr;
274 ostr << FindDirectoryPath() <<
"Rel" << Z;
275 vr = RetrieveVector(ostr,
false);
276 dataR->InitialiseForElement(Z, vr);
283 ggXsection->GetElasticElementCrossSection(neutron, ehigh, Z, aeff[Z]);
284 coeff[Z] = (sig2 > 0.) ? sig1/sig2 : 1.0;
288G4NeutronElasticXS::RetrieveVector(std::ostringstream& ost,
G4bool warn)
290 G4PhysicsLogVector* v =
nullptr;
291 std::ifstream filein(ost.str().c_str());
292 if (!filein.is_open()) {
295 ed <<
"Data file <" << ost.str().c_str()
296 <<
"> is not opened!";
297 G4Exception(
"G4NeutronElasticXS::RetrieveVector(..)",
"had014",
302 G4cout <<
"File " << ost.str()
303 <<
" is opened by G4NeutronElasticXS" <<
G4endl;
306 v =
new G4PhysicsLogVector();
309 ed <<
"Data file <" << ost.str().c_str()
310 <<
"> is not retrieved!";
311 G4Exception(
"G4NeutronElasticXS::RetrieveVector(..)",
"had015",
G4TemplateAutoLock< G4Mutex > G4AutoLock
std::vector< G4Element * > G4ElementTable
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define G4MUTEX_INITIALIZER
G4GLOB_DLL std::ostream G4cout
G4VComponentCrossSection * GetComponentCrossSection(const G4String &name)
static G4CrossSectionDataSetRegistry * Instance()
G4double GetLogKineticEnergy() const
G4double GetKineticEnergy() const
G4double * GetRelativeAbundanceVector() const
std::size_t GetNumberOfIsotopes() const
const G4Isotope * GetIsotope(G4int iso) const
static const G4ElementTable * GetElementTable()
static G4HadronicParameters * Instance()
G4bool UseRFilesForXS() const
const G4String & GetDirPARTICLEXS() const
G4bool IsElementApplicable(const G4DynamicParticle *, G4int Z, const G4Material *) final
G4double GetIsoCrossSection(const G4DynamicParticle *, G4int Z, G4int A, const G4Isotope *iso, const G4Element *elm, const G4Material *mat) final
void BuildPhysicsTable(const G4ParticleDefinition &) final
G4double ComputeIsoCrossSection(G4double kinEnergy, G4double loge, const G4ParticleDefinition *, G4int Z, G4int A, const G4Isotope *iso, const G4Element *elm, const G4Material *mat) final
G4double ElementCrossSection(G4double kinEnergy, G4double loge, G4int Z)
G4bool IsIsoApplicable(const G4DynamicParticle *, G4int Z, G4int A, const G4Element *, const G4Material *) final
G4double ComputeCrossSectionPerElement(G4double kinEnergy, G4double loge, const G4ParticleDefinition *, const G4Element *, const G4Material *) final
static const char * Default_Name()
const G4Isotope * SelectIsotope(const G4Element *, G4double kinEnergy, G4double logE) final
void CrossSectionDescription(std::ostream &) const final
G4double GetElementCrossSection(const G4DynamicParticle *, G4int Z, const G4Material *) final
const G4String & GetParticleName() const
G4double GetMaxEnergy() const
G4bool Retrieve(std::ifstream &fIn, G4bool ascii=false)
std::size_t GetVectorLength() const
G4VCrossSectionDataSet(const G4String &nam="")
void SetForAllAtomsAndEnergies(G4bool val)