60G4ElementData* G4ParticleInelasticXS::data[] = {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr};
61G4double G4ParticleInelasticXS::coeff[MAXZINELP][5] = {{1.0}, {1.0}, {1.0}, {1.0}, {1.0}};
62G4String G4ParticleInelasticXS::gDataDirectory[] = {
"",
"",
"",
"",
""};
64static std::once_flag applyOnce;
69 G4String pname[5] = {
"proton",
"deuteron",
"triton",
"He3",
"alpha"};
78 G4Exception(
"G4ParticleInelasticXS::G4ParticleInelasticXS(..)",
"had015",
84 G4cout <<
"G4ParticleInelasticXS::G4ParticleInelasticXS for "
85 << particleName <<
" on atoms with Z < " << MAXZINELP <<
G4endl;
88 if(particleName ==
"proton") {
89 highEnergyXsection = xsr->GetComponentCrossSection(
"Glauber-Gribov");
90 if(highEnergyXsection ==
nullptr) {
95 xsr->GetComponentCrossSection(
"Glauber-Gribov Nucl-nucl");
96 if(highEnergyXsection ==
nullptr) {
99 for (index=1; index<5; ++index) {
100 if (particleName == pname[index]) {
break; }
104 ed << particleName <<
" is a wrong particle type";
105 G4Exception(
"G4ParticleInelasticXS::BuildPhysicsTable(..)",
"had012",
112 if (data[0] ==
nullptr) {
113 for (
G4int i=0; i<5; ++i) {
115 data[i]->
SetName(pname[i] +
"IonInel");
123 outFile <<
"G4ParticleInelasticXS calculates n, p, d, t, he3, he4 inelastic\n"
124 <<
"cross section on nuclei using data from the high precision\n"
125 <<
"neutron database. These data are simplified and smoothed over\n"
126 <<
"the resonance region in order to reduce CPU time.\n"
127 <<
"For high energy Glauber-Gribov cross section model is used.\n";
164 G4int Z = (ZZ >= MAXZINELP) ? MAXZINELP - 1 : ZZ;
165 auto pv = GetPhysicsVector(Z);
167 G4double xs = (ekin <= pv->GetMaxEnergy()) ? pv->LogVectorValue(ekin, loge)
173 G4cout <<
"ElmXS: Z= " << Z <<
" Ekin(MeV)= " << ekin/CLHEP::MeV
174 <<
" xs(bn)= " << xs/CLHEP::barn <<
" element data for "
176 <<
" idx= " << index <<
G4endl;
205 G4int Z = (ZZ >= MAXZINELP) ? MAXZINELP - 1 : ZZ;
206 auto pv = GetPhysicsVector(Z);
209 if (ekin <= elimit && data[index]->GetNumberOfComponents(Z) > 0) {
211 if(pviso !=
nullptr) {
212 xs = pviso->LogVectorValue(ekin, logE);
215 G4cout <<
"G4ParticleInelasticXS::IsoXS: for "
217 << ekin/CLHEP::MeV <<
" xs(b)= " << xs/CLHEP::barn
218 <<
" Z= " << Z <<
" A= " <<
A
219 <<
" idx= " << index <<
G4endl;
226 xs = (ekin <= pv->GetMaxEnergy()) ? pv->LogVectorValue(ekin, logE)
234 <<
" Target Z= " << Z <<
" A= " <<
A
235 <<
" Ekin(MeV)= " << ekin/CLHEP::MeV
236 <<
" xs(bn)= " << xs/CLHEP::barn
237 <<
" idx= " << index <<
G4endl;
249 if (1 == nIso) {
return iso; }
253 if (
nullptr == data[index]->GetElementData(Z)) { InitialiseOnFly(Z); }
261 if (Z >= MAXZINELP || 0 == data[index]->GetNumberOfComponents(Z)) {
262 for (j=0; j<nIso; ++j) {
263 sum += abundVector[j];
273 if (nn < nIso) { temp.resize(nIso, 0.); }
275 for (j=0; j<nIso; ++j) {
281 for (j=0; j<nIso; ++j) {
282 if (temp[j] >= sum) {
294 G4cout <<
"G4ParticleInelasticXS::BuildPhysicsTable for "
297 if (&p != particle) {
301 G4Exception(
"G4ParticleInelasticXS::BuildPhysicsTable(..)",
"had012",
310 std::call_once(applyOnce, [
this]() { isInitializer =
true; });
316 for (
auto const & elm : *table ) {
317 G4int Z = std::max( 1, std::min( elm->GetZasInt(), MAXZINELP-1) );
318 for (
G4int i=0; i<5; ++i) {
319 if (
nullptr == (data[i])->GetElementData(Z) ) { Initialise(Z, i); }
325 std::size_t nIso = temp.size();
326 for (
auto const & elm : *table ) {
327 std::size_t n = elm->GetNumberOfIsotopes();
328 if (n > nIso) { nIso = n; }
330 temp.resize(nIso, 0.0);
333void G4ParticleInelasticXS::FindDirectoryPath()
336 if (gDataDirectory[0].empty()) {
337 for (
G4int i=0; i<5; ++i) {
338 std::ostringstream ost;
340 << pname[i] <<
"/inel";
341 gDataDirectory[i] = ost.str();
346void G4ParticleInelasticXS::InitialiseOnFly(
G4int Z)
349 for (
G4int i=0; i<5; ++i) {
350 if (
nullptr == (data[i])->GetElementData(Z) ) { Initialise(Z, i); }
355void G4ParticleInelasticXS::Initialise(
G4int Z,
G4int idx)
357 if (
nullptr != data[idx]->GetElementData(Z)) {
return; }
360 std::ostringstream ost;
361 ost << gDataDirectory[idx] << Z ;
367 if (amin[Z] < amax[Z]) {
369 for (
G4int A=amin[Z];
A<=amax[Z]; ++
A) {
370 std::ostringstream ost1;
371 ost1 << gDataDirectory[idx] << Z <<
"_" <<
A;
375 G4int nmax = amax[Z] -
A + 1;
390 particle, ehigh, Z, aeff[Z]);
391 coeff[Z][idx] = (sig2 > 0.) ? sig1/sig2 : 1.0;
395G4ParticleInelasticXS::RetrieveVector(std::ostringstream& ost,
G4bool warn)
398 std::ifstream filein(ost.str().c_str());
399 if (!filein.is_open()) {
402 ed <<
"Data file <" << ost.str().c_str()
403 <<
"> is not opened!";
404 G4Exception(
"G4ParticleInelasticXS::RetrieveVector(..)",
"had014",
409 G4cout <<
"File " << ost.str()
410 <<
" is opened by G4ParticleInelasticXS" <<
G4endl;
416 ed <<
"Data file <" << ost.str().c_str()
417 <<
"> is not retrieved!";
418 G4Exception(
"G4ParticleInelasticXS::RetrieveVector(..)",
"had015",
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
static G4CrossSectionDataSetRegistry * Instance()
G4double GetLogKineticEnergy() const
G4double GetKineticEnergy() const
void InitialiseForComponent(G4int Z, G4int nComponents=0)
void InitialiseForElement(G4int Z, G4PhysicsVector *v)
void AddComponent(G4int Z, G4int id, G4PhysicsVector *v)
G4PhysicsVector * GetComponentDataByID(G4int Z, G4int id) const
void SetName(const G4String &nam)
static G4ElementTable * GetElementTable()
G4double * GetRelativeAbundanceVector() const
const G4Isotope * GetIsotope(G4int iso) const
size_t GetNumberOfIsotopes() const
static G4HadronicParameters * Instance()
const G4String & GetDirPARTICLEXS() const
const G4String & GetParticleName() const
G4double GetElementCrossSection(const G4DynamicParticle *, G4int Z, const G4Material *mat=nullptr) final
void BuildPhysicsTable(const G4ParticleDefinition &) final
G4bool IsIsoApplicable(const G4DynamicParticle *, G4int Z, G4int A, const G4Element *elm=nullptr, const G4Material *mat=nullptr) final
G4double ComputeCrossSectionPerElement(G4double kinEnergy, G4double loge, const G4ParticleDefinition *, const G4Element *, const G4Material *) final
G4ParticleInelasticXS(const G4ParticleDefinition *)
G4bool IsElementApplicable(const G4DynamicParticle *, G4int Z, const G4Material *mat=nullptr) final
G4double GetIsoCrossSection(const G4DynamicParticle *, G4int Z, G4int A, const G4Isotope *iso=nullptr, const G4Element *elm=nullptr, const G4Material *mat=nullptr) final
G4double IsoCrossSection(G4double ekin, G4double logE, G4int Z, G4int A)
G4double ComputeIsoCrossSection(G4double kinEnergy, G4double loge, const G4ParticleDefinition *, G4int Z, G4int A, const G4Isotope *iso, const G4Element *elm, const G4Material *mat) final
const G4Isotope * SelectIsotope(const G4Element *, G4double kinEnergy, G4double logE) final
G4double ElementCrossSection(G4double kinEnergy, G4double loge, G4int Z)
void CrossSectionDescription(std::ostream &) const final
G4double GetMaxEnergy() const
G4bool Retrieve(std::ifstream &fIn, G4bool ascii=false)
std::size_t GetVectorLength() const
G4double GetInelasticElementCrossSection(const G4ParticleDefinition *, G4double kinEnergy, const G4Element *)
void SetMaxKinEnergy(G4double value)
void SetForAllAtomsAndEnergies(G4bool val)