57G4double G4NeutronInelasticXS::coeff[] = {1.0};
58G4double G4NeutronInelasticXS::lowcoeff[] = {1.0};
61G4String G4NeutronInelasticXS::gDataDirectory =
"";
63static std::once_flag applyOnce;
73 lowElimit(1.0e-7*
CLHEP::eV)
77 G4cout <<
"G4NeutronInelasticXS::G4NeutronInelasticXS Initialise for Z < "
80 loglowElimit =
G4Log(lowElimit);
83 if (ggXsection ==
nullptr)
86 if (
nullptr == data) {
88 data->SetName(
"nInelastic");
90 dataR->SetName(
"nRInelastic");
92 for (
G4int Z=1; Z<MAXZINEL; ++Z) { Initialise(Z); }
100 outFile <<
"G4NeutronInelasticXS calculates the neutron inelastic scattering\n"
101 <<
"cross section on nuclei using data from the high precision\n"
102 <<
"neutron database. These data are simplified and smoothed over\n"
103 <<
"the resonance region in order to reduce CPU time.\n"
104 <<
"For high energy Glauber-Gribov cross section model is used\n";
142 G4int Z = std::min(ZZ, MAXZINEL-1);
149 if (ekin < lowElimit) {
155 if (fRfilesEnabled) {
156 auto pv = GetPhysicsVectorR(Z);
157 if (
nullptr != pv && ekin < inel_max_r_e[Z]) {
158 xs = pv->LogVectorValue(ekin, loge);
164 auto pv = GetPhysicsVector(Z);
165 if (ekin <= pv->GetMaxEnergy()) {
166 xs = pv->LogVectorValue(ekin, loge);
169 xs = coeff[Z]*ggXsection->GetInelasticElementCrossSection(neutron, ekin,
176 G4cout <<
"G4NeutronInelasticXS::ElementCrossSection Z= " << Z
177 <<
" Ekin(MeV)= " << ekin/CLHEP::MeV
178 <<
", ElmXSinel(b)= " << xs/CLHEP::barn
210 G4int Z = std::min(ZZ, MAXZINEL-1);
214 if (fRfilesEnabled) {
215 auto pv = GetPhysicsVectorR(Z);
216 if (
nullptr != pv && ekin < inel_max_r_e[Z]) {
218 if (dataR->GetNumberOfComponents(Z) > 0) {
219 auto pviso = dataR->GetComponentDataByID(Z,
A);
220 if (pviso !=
nullptr) {
221 xs = pviso->LogVectorValue(ekin, loge);
227 xs = pv->LogVectorValue(ekin, loge);
234 auto pv = GetPhysicsVector(Z);
236 if (data->GetNumberOfComponents(Z) > 0) {
237 auto pviso = data->GetComponentDataByID(Z,
A);
238 if (pviso !=
nullptr && ekin <= pviso->GetMaxEnergy()) {
239 xs = pviso->LogVectorValue(ekin, loge);
246 if (ekin <= pv->GetMaxEnergy()) {
247 xs = pv->LogVectorValue(ekin, loge);
251 ggXsection->GetInelasticElementCrossSection(neutron, ekin,
259 G4cout <<
"G4NeutronInelasticXS::IsoXS: Z= " << Z <<
" A= " <<
A
260 <<
" Ekin(MeV)= " << ekin/CLHEP::MeV
261 <<
", ElmXS(b)= " << xs/CLHEP::barn <<
G4endl;
272 if(1 == nIso) {
return iso; }
276 if (
nullptr == data->GetElementData(Z)) { InitialiseOnFly(Z); }
284 if (Z >= MAXZINEL || 0 == data->GetNumberOfComponents(Z)) {
285 for (j=0; j<nIso; ++j) {
286 sum += abundVector[j];
296 auto nn = temp.size();
297 if(nn < nIso) { temp.resize(nIso, 0.); }
299 for (j=0; j<nIso; ++j) {
305 for (j = 0; j<nIso; ++j) {
306 if (temp[j] >= sum) {
318 G4cout <<
"G4NeutronInelasticXS::BuildPhysicsTable for "
324 <<
" only neutron is allowed";
325 G4Exception(
"G4NeutronInelasticXS::BuildPhysicsTable(..)",
"had012",
336 std::call_once(applyOnce, [
this]() { isInitializer =
true; });
342 for (
auto const & elm : *table ) {
343 G4int Z = std::max( 1, std::min( elm->GetZasInt(), MAXZINEL-1) );
344 if (
nullptr == data->GetElementData(Z) ) { Initialise(Z); }
349 std::size_t nIso = temp.size();
350 for (
auto const & elm : *table ) {
351 std::size_t n = elm->GetNumberOfIsotopes();
352 if (n > nIso) { nIso = n; }
354 temp.resize(nIso, 0.0);
357const G4String& G4NeutronInelasticXS::FindDirectoryPath()
360 if (gDataDirectory.empty()) {
361 std::ostringstream ost;
363 gDataDirectory = ost.str();
365 return gDataDirectory;
368void G4NeutronInelasticXS::InitialiseOnFly(
G4int Z)
375void G4NeutronInelasticXS::Initialise(
G4int Z)
377 if (
nullptr != data->GetElementData(Z)) {
return; }
380 std::ostringstream ost;
381 ost << FindDirectoryPath() <<
"inel" << Z;
382 G4PhysicsVector* v = RetrieveVector(ost,
true);
383 data->InitialiseForElement(Z, v);
385 G4PhysicsVector* vr =
nullptr;
386 if (fRfilesEnabled) {
387 std::ostringstream ostr;
388 ostr << FindDirectoryPath() <<
"Rinel" << Z;
389 vr = RetrieveVector(ostr,
false);
390 dataR->InitialiseForElement(Z, vr);
396 if (amin[Z] < amax[Z]) {
398 for (
G4int A=amin[Z];
A<=amax[Z]; ++
A) {
399 std::ostringstream ost1;
400 ost1 << gDataDirectory <<
"inel" << Z <<
"_" <<
A;
401 G4PhysicsVector* v1 = RetrieveVector(ost1,
false);
404 G4int nmax = amax[Z] -
A + 1;
405 data->InitialiseForComponent(Z, nmax);
408 data->AddComponent(Z,
A, v1);
411 std::ostringstream ost2;
412 ost2 << gDataDirectory <<
"Rinel" << Z <<
"_" <<
A;
413 G4PhysicsVector* v2 = RetrieveVector(ost2,
false);
416 G4int nmax = amax[Z] -
A + 1;
417 dataR->InitialiseForComponent(Z, nmax);
420 dataR->AddComponent(Z,
A, v2);
426 if (noComp) { data->InitialiseForComponent(Z, 0); }
427 if (noCompR) { dataR->InitialiseForComponent(Z, 0); }
432 G4double sig2 = ggXsection->GetInelasticElementCrossSection(neutron,
434 coeff[Z] = (sig2 > 0.) ? sig1/sig2 : 1.0;
438G4NeutronInelasticXS::RetrieveVector(std::ostringstream& ost,
G4bool warn)
440 G4PhysicsLogVector* v =
nullptr;
441 std::ifstream filein(ost.str().c_str());
442 if (!filein.is_open()) {
445 ed <<
"Data file <" << ost.str().c_str()
446 <<
"> is not opened!";
447 G4Exception(
"G4NeutronInelasticXS::RetrieveVector(..)",
"had014",
452 G4cout <<
"File " << ost.str()
453 <<
" is opened by G4NeutronInelasticXS" <<
G4endl;
456 v =
new G4PhysicsLogVector();
459 ed <<
"Data file <" << ost.str().c_str()
460 <<
"> is not retrieved!";
461 G4Exception(
"G4NeutronInelasticXS::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
G4double G4Log(G4double x)
#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
G4double ComputeCrossSectionPerElement(G4double kinEnergy, G4double loge, const G4ParticleDefinition *, const G4Element *, const G4Material *) final
static const char * Default_Name()
G4double ComputeIsoCrossSection(G4double kinEnergy, G4double loge, const G4ParticleDefinition *, G4int Z, G4int A, const G4Isotope *iso, const G4Element *elm, const G4Material *mat) final
G4double IsoCrossSection(G4double ekin, G4double logekin, G4int Z, G4int A)
G4double ElementCrossSection(G4double kinEnergy, G4double loge, G4int Z)
G4bool IsElementApplicable(const G4DynamicParticle *, G4int Z, const G4Material *) final
void BuildPhysicsTable(const G4ParticleDefinition &) final
G4bool IsIsoApplicable(const G4DynamicParticle *, G4int Z, G4int A, const G4Element *, const G4Material *) final
void CrossSectionDescription(std::ostream &) const final
const G4Isotope * SelectIsotope(const G4Element *, G4double kinEnergy, G4double logE) final
G4double GetElementCrossSection(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
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)