57G4double G4ParticleInelasticXS::coeff[
MAXZINELP][5] = {{1.0}, {1.0}, {1.0}, {1.0}, {1.0}};
58G4String G4ParticleInelasticXS::gDataDirectory[] = {
""};
66 highEnergyXsection(nullptr),
72 G4Exception(
"G4ParticleInelasticXS::G4ParticleInelasticXS(..)",
"had015",
78 G4cout <<
"G4ParticleInelasticXS::G4ParticleInelasticXS for "
81 if(particleName ==
"proton") {
83 if(highEnergyXsection ==
nullptr) {
88 if(highEnergyXsection ==
nullptr) {
91 if(particleName ==
"deuteron") index = 1;
92 else if(particleName ==
"triton") index = 2;
93 else if(particleName ==
"He3") index = 3;
94 else if(particleName ==
"alpha") index = 4;
97 ed << particleName <<
" is a wrong particle type";
98 G4Exception(
"G4ParticleInelasticXS::BuildPhysicsTable(..)",
"had012",
111 data[index] =
nullptr;
117 outFile <<
"G4ParticleInelasticXS calculates n, p, d, t, he3, he4 inelastic\n"
118 <<
"cross section on nuclei using data from the high precision\n"
119 <<
"neutron database. These data are simplified and smoothed over\n"
120 <<
"the resonance region in order to reduce CPU time.\n"
121 <<
"For high energy Glauber-Gribov cross section model is used\n";
148 auto pv = GetPhysicsVector(Z);
149 if(
nullptr == pv) {
return xs; }
153 if(ekin <= pv->GetMaxEnergy()) {
162 G4cout <<
"ElmXS: Z= " << Z <<
" Ekin(MeV)= " << ekin/CLHEP::MeV
163 <<
" xs(bn)= " << xs/CLHEP::barn <<
" element data for "
165 <<
" idx= " << index <<
G4endl;
192 auto pv = GetPhysicsVector(Z);
193 if(pv ==
nullptr) {
return xs; }
196 const G4double emax = pv->GetMaxEnergy();
197 if(ekin <= emax && amin[Z]>0 &&
A >= amin[Z] &&
A <= amax[Z]) {
199 if(pviso !=
nullptr) {
203 G4cout <<
"G4ParticleInelasticXS::IsoXS: for "
205 << ekin/CLHEP::MeV <<
" xs(b)= " << xs/CLHEP::barn
206 <<
" Z= " << Z <<
" A= " <<
A
207 <<
" idx= " << index <<
G4endl;
215 xs = pv->LogVectorValue(ekin, logE);
217 xs = coeff[Z][index] *
225 <<
" Target Z= " << Z <<
" A= " <<
A
226 <<
" Ekin(MeV)= " << ekin/CLHEP::MeV
227 <<
" xs(bn)= " << xs/CLHEP::barn
228 <<
" idx= " << index <<
G4endl;
241 if(1 == nIso) {
return iso; }
254 for (j=0; j<nIso; ++j) {
255 sum += abundVector[j];
264 size_t nn = temp.size();
265 if(nn < nIso) { temp.resize(nIso, 0.); }
267 for (j=0; j<nIso; ++j) {
275 for (j=0; j<nIso; ++j) {
288 G4cout <<
"G4ParticleInelasticXS::BuildPhysicsTable for "
295 G4Exception(
"G4ParticleInelasticXS::BuildPhysicsTable(..)",
"had012",
300 if(data[index] ==
nullptr) {
301#ifdef G4MULTITHREADED
303 if(data[index] ==
nullptr) {
309#ifdef G4MULTITHREADED
320 size_t numOfCouples = theCoupleTable->GetTableSize();
321 for(
size_t j=0; j<numOfCouples; ++j) {
322 auto mat = theCoupleTable->GetMaterialCutsCouple(j)->GetMaterial();
323 auto elmVec = mat->GetElementVector();
324 size_t numOfElem = mat->GetNumberOfElements();
325 for (
size_t ie = 0; ie < numOfElem; ++ie) {
326 G4int Z = std::max(1,std::min(((*elmVec)[ie])->GetZasInt(),
MAXZINELP-1));
327 if(
nullptr == data[index]->GetElementData(Z)) { Initialise(Z); }
333const G4String& G4ParticleInelasticXS::FindDirectoryPath()
337 if(gDataDirectory[index].empty()) {
338 char* path = std::getenv(
"G4PARTICLEXSDATA");
340 std::ostringstream ost;
342 gDataDirectory[index] = ost.str();
344 G4Exception(
"G4NeutronInelasticXS::Initialise(..)",
"had013",
346 "Environment variable G4PARTICLEXSDATA is not defined");
349 return gDataDirectory[index];
352void G4ParticleInelasticXS::InitialiseOnFly(
G4int Z)
354#ifdef G4MULTITHREADED
356 if(
nullptr == data[index]->GetElementData(Z)) {
359#ifdef G4MULTITHREADED
365void G4ParticleInelasticXS::Initialise(
G4int Z)
367 if(
nullptr != data[index]->GetElementData(Z)) {
return; }
370 std::ostringstream ost;
371 ost << FindDirectoryPath() << Z ;
383 size_t nmax = (size_t)(amax[Z]-amin[Z]+1);
386 for(
G4int A=amin[Z];
A<=amax[Z]; ++
A) {
387 std::ostringstream ost1;
388 ost1 << FindDirectoryPath() << Z <<
"_" <<
A;
401 particle, ehigh, Z, aeff[Z]);
402 coeff[Z][index] = (sig2 > 0.) ? sig1/sig2 : 1.0;
410G4ParticleInelasticXS::RetrieveVector(std::ostringstream& ost,
G4bool warn)
413 std::ifstream filein(ost.str().c_str());
417 ed <<
"Data file <" << ost.str().c_str()
418 <<
"> is not opened!";
419 G4Exception(
"G4ParticleInelasticXS::RetrieveVector(..)",
"had014",
424 G4cout <<
"File " << ost.str()
425 <<
" is opened by G4ParticleInelasticXS" <<
G4endl;
431 ed <<
"Data file <" << ost.str().c_str()
432 <<
"> is not retrieved!";
433 G4Exception(
"G4ParticleInelasticXS::RetrieveVector(..)",
"had015",
double A(double temperature)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define G4MUTEX_INITIALIZER
#define G4MUTEXLOCK(mutex)
#define G4MUTEXUNLOCK(mutex)
G4GLOB_DLL std::ostream G4cout
G4VComponentCrossSection * GetComponentCrossSection(const G4String &name)
static G4CrossSectionDataSetRegistry * Instance()
G4double GetLogKineticEnergy() const
G4double GetKineticEnergy() const
void InitialiseForComponent(G4int Z, G4int nComponents=0)
void InitialiseForElement(G4int Z, G4PhysicsVector *v)
G4PhysicsVector * GetComponentDataByIndex(G4int Z, size_t idx)
void AddComponent(G4int Z, G4int id, G4PhysicsVector *v)
void SetName(const G4String &nam)
G4double * GetRelativeAbundanceVector() const
const G4Isotope * GetIsotope(G4int iso) const
size_t GetNumberOfIsotopes() const
const G4String & GetParticleName() const
~G4ParticleInelasticXS() final
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
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)
const G4Isotope * SelectIsotope(const G4Element *, G4double kinEnergy, G4double logE) final
void CrossSectionDescription(std::ostream &) const final
virtual G4bool Retrieve(std::ifstream &fIn, G4bool ascii) final
G4double GetMaxEnergy() const
std::size_t GetVectorLength() const
G4double LogVectorValue(const G4double theEnergy, const G4double theLogEnergy) const
static G4ProductionCutsTable * GetProductionCutsTable()
G4double GetInelasticElementCrossSection(const G4ParticleDefinition *, G4double kinEnergy, const G4Element *)
void SetForAllAtomsAndEnergies(G4bool val)