59G4ElementData* G4ParticleInelasticXS::data[] = {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr};
60G4double G4ParticleInelasticXS::coeff[MAXZINELP][5] = {{1.0}, {1.0}, {1.0}, {1.0}, {1.0}};
61G4String G4ParticleInelasticXS::gDataDirectory = {
""};
66 G4String pname[5] = {
"proton",
"deuteron",
"triton",
"He3",
"alpha"};
75 if (
nullptr == part) {
76 G4Exception(
"G4ParticleInelasticXS::G4ParticleInelasticXS(..)",
"had015",
80 const G4String& particleName = particle->GetParticleName();
82 G4cout <<
"G4ParticleInelasticXS::G4ParticleInelasticXS for "
83 << particleName <<
" on atoms with Z < " << MAXZINELP <<
G4endl;
85 if (particleName ==
"proton") {
86 highEnergyXsection = xsr->GetComponentCrossSection(
"Glauber-Gribov");
87 if(highEnergyXsection ==
nullptr) {
92 xsr->GetComponentCrossSection(
"Glauber-Gribov Nucl-nucl");
93 if(highEnergyXsection ==
nullptr) {
96 for (index=1; index<5; ++index) {
97 if (particleName == pname[index]) {
break; }
99 index = std::min(index, 4);
104 if (
nullptr == highEnergyXsection) {
105 highEnergyXsection = xsr->GetComponentCrossSection(
"Glauber-Gribov");
108 if (gDataDirectory.empty()) {
111 G4String ss = pname[index] +
"ParticleXS";
113 if (data[index] ==
nullptr) {
115 data[index]->SetName(pname[index] +
"PartInel");
116 for (
G4int Z=1; Z<MAXZINELP; ++Z) { Initialise(Z); }
122 outFile <<
"G4ParticleInelasticXS calculates n, p, d, t, he3, he4 inelastic\n"
123 <<
"cross section on nuclei using data from the high precision\n"
124 <<
"neutron database. These data are simplified and smoothed over\n"
125 <<
"the resonance region in order to reduce CPU time.\n"
126 <<
"For high energy Glauber-Gribov cross section model is used.\n";
163 G4int Z = (ZZ >= MAXZINELP) ? MAXZINELP - 1 : ZZ;
166 auto pv = GetPhysicsVector(Z);
170 if (ekin > pv->Energy(0)) {
171 xs = (ekin <= pv->GetMaxEnergy()) ? pv->LogVectorValue(ekin, loge)
172 : coeff[Z][index]*highEnergyXsection->GetInelasticElementCrossSection(particle,
178 G4cout <<
"ElmXS: Z= " << Z <<
" Ekin(MeV)= " << ekin/CLHEP::MeV
179 <<
" xs(bn)= " << xs/CLHEP::barn <<
" element data for "
180 << particle->GetParticleName()
181 <<
" idx= " << index <<
G4endl;
210 G4int Z = (ZZ >= MAXZINELP) ? MAXZINELP - 1 : ZZ;
213 auto pv = GetPhysicsVector(Z);
216 if (ekin <= elimit && data[index]->GetNumberOfComponents(Z) > 0) {
217 auto pviso = data[index]->GetComponentDataByID(Z,
A);
218 if (pviso !=
nullptr && ekin > pviso->Energy(0)) {
219 xs = pviso->LogVectorValue(ekin, logE);
222 G4cout <<
"G4ParticleInelasticXS::IsoXS: for "
223 << particle->GetParticleName() <<
" Ekin(MeV)= "
224 << ekin/CLHEP::MeV <<
" xs(b)= " << xs/CLHEP::barn
225 <<
" Z= " << Z <<
" A= " <<
A
226 <<
" idx= " << index <<
G4endl;
233 if (ekin > pv->Energy(0)) {
234 xs = (ekin <= pv->GetMaxEnergy()) ? pv->LogVectorValue(ekin, logE) :
236 highEnergyXsection->GetInelasticElementCrossSection(particle, ekin, Z, aeff[Z])
241 G4cout <<
"IsoXS for " << particle->GetParticleName()
242 <<
" Target Z= " << Z <<
" A= " <<
A
243 <<
" Ekin(MeV)= " << ekin/CLHEP::MeV
244 <<
" xs(bn)= " << xs/CLHEP::barn
245 <<
" idx= " << index <<
G4endl;
257 if (1 == nIso) {
return iso; }
271 if (Z >= MAXZINELP || 0 == data[index]->GetNumberOfComponents(Z)) {
272 for (j=0; j<nIso; ++j) {
273 sum += abundVector[j];
283 if (nn < nIso) { temp.resize(nIso, 0.); }
285 for (j=0; j<nIso; ++j) {
291 for (j=0; j<nIso; ++j) {
292 if (temp[j] >= sum) {
304 G4cout <<
"G4ParticleInelasticXS::BuildPhysicsTable for "
307 if (&p != particle) {
310 << particle->GetParticleName() <<
" is expected";
311 G4Exception(
"G4ParticleInelasticXS::BuildPhysicsTable(..)",
"had012",
320 std::size_t nIso = temp.size();
323 for (
auto const & elm : *table ) {
324 std::size_t n = elm->GetNumberOfIsotopes();
325 if (n > nIso) { nIso = n; }
326 G4int Z = std::min( elm->GetZasInt(), MAXZINELP-1);
327 if (
nullptr == (data[index])->GetElementData(Z) ) {
331 temp.resize(nIso, 0.0);
334void G4ParticleInelasticXS::InitialiseOnFly(
G4int Z)
341void G4ParticleInelasticXS::Initialise(
G4int Z)
343 if (
nullptr != (data[index])->GetElementData(Z) ) {
return; }
346 std::ostringstream ost;
347 ost << gDataDirectory <<
"/" << pname[index] <<
"/inel" << Z;
348 G4PhysicsVector* v = RetrieveVector(ost,
true);
349 data[index]->InitialiseForElement(Z, v);
353 if (amin[Z] < amax[Z]) {
354 for (
G4int A=amin[Z];
A<=amax[Z]; ++
A) {
355 std::ostringstream ost1;
356 ost1 << gDataDirectory <<
"/" << pname[index] <<
"/inel" << Z <<
"_" <<
A;
357 G4PhysicsVector* v1 = RetrieveVector(ost1,
false);
360 G4int nmax = amax[Z] -
A + 1;
361 data[index]->InitialiseForComponent(Z, nmax);
364 data[index]->AddComponent(Z,
A, v1);
369 if (noComp) { data[index]->InitialiseForComponent(Z, 0); }
374 G4double sig2 = highEnergyXsection->GetInelasticElementCrossSection(
375 particle, ehigh, Z, aeff[Z]);
376 coeff[Z][index] = (sig2 > 0.) ? sig1/sig2 : 1.0;
380G4ParticleInelasticXS::RetrieveVector(std::ostringstream& ost,
G4bool warn)
382 G4PhysicsLogVector* v =
nullptr;
383 std::ifstream filein(ost.str().c_str());
384 if (!filein.is_open()) {
387 ed <<
"Data file <" << ost.str().c_str()
388 <<
"> is not opened! index=" << index
389 <<
" dir: <" << gDataDirectory <<
">. ";
390 G4Exception(
"G4ParticleInelasticXS::RetrieveVector(..)",
"had014",
395 G4cout <<
"File " << ost.str()
396 <<
" is opened by G4ParticleInelasticXS" <<
G4endl;
399 v =
new G4PhysicsLogVector();
402 ed <<
"Data file <" << ost.str().c_str()
403 <<
"> is not retrieved!";
404 G4Exception(
"G4ParticleInelasticXS::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
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()
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
G4VCrossSectionDataSet(const G4String &nam="")
void SetMaxKinEnergy(G4double value)
void SetForAllAtomsAndEnergies(G4bool val)
void SetName(const G4String &nam)