58G4String G4NeutronCaptureXS::gDataDirectory =
"";
70 G4cout <<
"G4NeutronCaptureXS::G4NeutronCaptureXS: Initialise for Z < "
73 logElimit =
G4Log(elimit);
80 if(isMaster) {
delete data; data =
nullptr; }
85 outFile <<
"G4NeutronCaptureXS calculates the neutron capture cross sections\n"
86 <<
"on nuclei using data from the high precision neutron database.\n"
87 <<
"These data are simplified and smoothed over the resonance region\n"
88 <<
"in order to reduce CPU time. G4NeutronCaptureXS is set to zero\n"
89 <<
"above 20 MeV for all targets. Cross section is zero also for Z>92.\n";
113 if(ekin > emax) {
return xs; }
117 if(ekin < elimit) { ekin = elimit; logEkin = logElimit; }
119 auto pv = GetPhysicsVector(Z);
120 if(pv ==
nullptr) {
return xs; }
123 xs = (ekin >= e1) ? pv->LogVectorValue(ekin, logEkin)
124 : (*pv)[1]*std::sqrt(e1/ekin);
128 G4cout <<
"Ekin= " << ekin/CLHEP::MeV
129 <<
" ElmXScap(b)= " << xs/CLHEP::barn <<
G4endl;
150 if(eKin > emax) {
return xs; }
160 auto pv = GetPhysicsVector(Z);
161 if(pv ==
nullptr) {
return xs; }
163 if(amin[Z] > 0 &&
A >= amin[Z] &&
A <= amax[Z]) {
165 if(pviso !=
nullptr) {
168 : (*pviso)[1]*std::sqrt(e1/ekin);
171 G4cout <<
"G4NeutronCaptureXS::IsoXS: Ekin(MeV)= " << ekin/MeV
172 <<
" xs(b)= " << xs/barn
173 <<
" Z= " << Z <<
" A= " <<
A <<
G4endl;
181 xs = (ekin >= e1) ? pv->LogVectorValue(ekin, logEkin)
182 : (*pv)[1]*std::sqrt(e1/ekin);
185 G4cout <<
"G4NeutronCaptureXS::IsoXS: Ekin(MeV)= " << ekin/MeV
186 <<
" xs(b)= " << xs/barn
187 <<
" Z= " << Z <<
" A= " <<
A <<
" no iso XS" <<
G4endl;
201 if(1 == nIso) {
return iso; }
213 for (j = 0; j<nIso; ++j) {
214 sum += abundVector[j];
222 size_t nn = temp.size();
223 if(nn < nIso) { temp.resize(nIso, 0.); }
225 for (j=0; j<nIso; ++j) {
231 for (j = 0; j<nIso; ++j) {
244 G4cout <<
"G4NeutronCaptureXS::BuildPhysicsTable for "
250 <<
" only neutron is allowed";
251 G4Exception(
"G4NeutronCaptureXS::BuildPhysicsTable(..)",
"had012",
256 if(
nullptr == data) {
257#ifdef G4MULTITHREADED
259 if(
nullptr == data) {
263 data->
SetName(
"NeutronCapture");
265#ifdef G4MULTITHREADED
276 size_t numOfCouples = theCoupleTable->GetTableSize();
277 for(
size_t j=0; j<numOfCouples; ++j) {
278 auto mat = theCoupleTable->GetMaterialCutsCouple(j)->GetMaterial();
279 auto elmVec = mat->GetElementVector();
280 size_t numOfElem = mat->GetNumberOfElements();
281 for (
size_t ie = 0; ie < numOfElem; ++ie) {
282 G4int Z = std::max(1,std::min(((*elmVec)[ie])->GetZasInt(),
MAXZCAPTURE-1));
289const G4String& G4NeutronCaptureXS::FindDirectoryPath()
293 if(gDataDirectory.empty()) {
294 char* path = std::getenv(
"G4PARTICLEXSDATA");
296 std::ostringstream ost;
297 ost << path <<
"/neutron/cap";
298 gDataDirectory = ost.str();
300 G4Exception(
"G4NeutronCaptureXS::Initialise(..)",
"had013",
302 "Environment variable G4PARTICLEXSDATA is not defined");
305 return gDataDirectory;
308void G4NeutronCaptureXS::InitialiseOnFly(
G4int Z)
310#ifdef G4MULTITHREADED
315#ifdef G4MULTITHREADED
321void G4NeutronCaptureXS::Initialise(
G4int Z)
326 std::ostringstream ost;
327 ost << FindDirectoryPath() << Z ;
333 size_t nmax = (size_t)(amax[Z]-amin[Z]+1);
336 for(
G4int A=amin[Z];
A<=amax[Z]; ++
A) {
337 std::ostringstream ost1;
338 ost1 << gDataDirectory << Z <<
"_" <<
A;
339 v = RetrieveVector(ost1,
false);
346G4NeutronCaptureXS::RetrieveVector(std::ostringstream& ost,
G4bool warn)
349 std::ifstream filein(ost.str().c_str());
353 ed <<
"Data file <" << ost.str().c_str()
354 <<
"> is not opened!";
355 G4Exception(
"G4NeutronCaptureXS::RetrieveVector(..)",
"had014",
360 G4cout <<
"File " << ost.str()
361 <<
" is opened by G4NeutronCaptureXS" <<
G4endl;
367 ed <<
"Data file <" << ost.str().c_str()
368 <<
"> is not retrieved!";
369 G4Exception(
"G4NeutronCaptureXS::RetrieveVector(..)",
"had015",
#define G4_DECLARE_XS_FACTORY(cross_section)
double A(double temperature)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4double G4Log(G4double x)
#define G4MUTEX_INITIALIZER
#define G4MUTEXLOCK(mutex)
#define G4MUTEXUNLOCK(mutex)
G4GLOB_DLL std::ostream G4cout
G4double GetLogKineticEnergy() const
G4double GetKineticEnergy() const
void InitialiseForComponent(G4int Z, G4int nComponents=0)
void InitialiseForElement(G4int Z, G4PhysicsVector *v)
G4PhysicsVector * GetElementData(G4int Z)
void AddComponent(G4int Z, G4int id, G4PhysicsVector *v)
void SetName(const G4String &nam)
G4PhysicsVector * GetComponentDataByID(G4int Z, G4int id)
G4double * GetRelativeAbundanceVector() const
const G4Isotope * GetIsotope(G4int iso) const
size_t GetNumberOfIsotopes() const
void CrossSectionDescription(std::ostream &) const final
~G4NeutronCaptureXS() final
G4bool IsIsoApplicable(const G4DynamicParticle *, G4int Z, G4int A, const G4Element *, const G4Material *) final
G4double GetIsoCrossSection(const G4DynamicParticle *, G4int Z, G4int A, const G4Isotope *iso, const G4Element *elm, const G4Material *mat) final
const G4Isotope * SelectIsotope(const G4Element *, G4double kinEnergy, G4double logE) final
G4bool IsElementApplicable(const G4DynamicParticle *, G4int Z, const G4Material *) final
G4double IsoCrossSection(G4double ekin, G4double logekin, G4int Z, G4int A)
void BuildPhysicsTable(const G4ParticleDefinition &) final
G4double GetElementCrossSection(const G4DynamicParticle *, G4int Z, const G4Material *) final
const G4String & GetParticleName() const
virtual G4bool Retrieve(std::ifstream &fIn, G4bool ascii) final
G4double Energy(std::size_t index) const
G4double LogVectorValue(const G4double theEnergy, const G4double theLogEnergy) const
static G4ProductionCutsTable * GetProductionCutsTable()