72 currentMaterial = mat;
75 matCrossSection = 0.0;
80 if(xsecelm.size() < nElements) { xsecelm.resize(nElements); }
85 matCrossSection += std::max(xs, 0.0);
86 xsecelm[i] = matCrossSection;
88 return matCrossSection;
98 G4int i = nDataSetList-1;
102 dataSetList[i]->IsElementApplicable(dp, Z, mat))
105 return dataSetList[i]->GetElementCrossSection(dp, Z, mat);
117 for(
G4int j = 0; j < nIso; ++j)
120 sigma += abundVector[j] *
121 GetIsoCrossSection(dp, Z, iso->
GetN(), iso, elm, mat, i);
138 if(dataSetList[idx]->IsIsoApplicable(dp, Z,
A, elm, mat) ) {
139 return dataSetList[idx]->GetIsoCrossSection(dp, Z,
A, iso, elm, mat);
143 for (
G4int j = nDataSetList-1; j >= 0; --j) {
144 if(dataSetList[j]->IsElementApplicable(dp, Z, mat)) {
145 return dataSetList[j]->GetElementCrossSection(dp, Z, mat);
146 }
else if (dataSetList[j]->IsIsoApplicable(dp, Z,
A, elm, mat)) {
147 return dataSetList[j]->GetIsoCrossSection(dp, Z,
A, iso, elm, mat);
151 ed <<
"No isotope cross section found for "
153 <<
" off target Element " << elm->
GetName()
154 <<
" Z= " << Z <<
" A= " <<
A;
155 if(
nullptr != mat) ed <<
" from " << mat->
GetName();
157 G4Exception(
"G4CrossSectionDataStore::GetIsoCrossSection",
"had001",
171 for (
G4int i = nDataSetList-1; i >= 0; --i) {
172 if (dataSetList[i]->IsIsoApplicable(dp, Z,
A, elm, mat) ) {
173 return dataSetList[i]->GetIsoCrossSection(dp, Z,
A, iso, elm, mat);
174 }
else if(dataSetList[i]->IsElementApplicable(dp, Z, mat)) {
175 return dataSetList[i]->GetElementCrossSection(dp, Z, mat);
179 ed <<
"No isotope cross section found for "
181 <<
" off target Element " << elm->
GetName()
182 <<
" Z= " << Z <<
" A= " <<
A;
183 if(
nullptr != mat) ed <<
" from " << mat->
GetName();
185 G4Exception(
"G4CrossSectionDataStore::GetCrossSection",
"had001",
197 if(
nullptr != forcedElement) {
return forcedElement; }
205 if(cross <= xsecelm[i]) {
215 G4int i = nDataSetList-1;
216 if (dataSetList[i]->IsElementApplicable(dp, Z, mat)) {
227 iso = dataSetList[i]->SelectIsotope(anElement,
243 if(xseciso.size() < nIso) { xseciso.resize(nIso); }
247 for (j = 0; j<(
G4int)nIso; ++j) {
249 if(abundVector[j] > 0.0) {
251 xsec = abundVector[j]*
252 GetIsoCrossSection(dp, Z, iso->
GetN(), iso, anElement, mat, i);
258 for (j = 0; j<(
G4int)nIso; ++j) {
259 if(cross <= xseciso[j]) {
275 if (nDataSetList == 0) {
277 ed <<
"No cross section is registered for "
279 G4Exception(
"G4CrossSectionDataStore::BuildPhysicsTable",
"had001",
284 for (
G4int i=0; i<nDataSetList; ++i) {
285 dataSetList[i]->BuildPhysicsTable(part);
288 std::size_t nelm = 0;
289 std::size_t niso = 0;
290 for(
auto mat : *theMatTable) {
292 nelm = std::max(nelm, nElements);
298 xsecelm.resize(nelm, 0.0);
299 xseciso.resize(niso, 0.0);
310 if (nDataSetList == 0) {
311 G4cout <<
"WARNING - G4CrossSectionDataStore::DumpPhysicsTable: "
312 <<
" no data sets registered" <<
G4endl;
316 for (
G4int i = nDataSetList-1; i >= 0; --i) {
317 G4double e1 = dataSetList[i]->GetMinKinEnergy();
318 G4double e2 = dataSetList[i]->GetMaxKinEnergy();
320 <<
" Cr_sctns: " << std::setw(25) << dataSetList[i]->GetName() <<
": "
323 if (dataSetList[i]->GetName() ==
"G4CrossSectionPairGG") {
324 dataSetList[i]->DumpPhysicsTable(part);
333 std::ofstream& outFile)
const
341 G4String physListName = param->GetPhysListName();
342 G4String dirName = param->GetPhysListDocDir();
344 for (
G4int i = nDataSetList-1; i > 0; i--) {
345 elo = dataSetList[i]->GetMinKinEnergy()/GeV;
346 ehi = dataSetList[i]->GetMaxKinEnergy()/GeV;
347 outFile <<
" <li><b><a href=\"" << physListName <<
"_"
348 << dataSetList[i]->GetName() <<
".html\"> "
349 << dataSetList[i]->GetName() <<
"</a> from "
350 << elo <<
" GeV to " << ehi <<
" GeV </b></li>\n";
354 G4double defaultHi = dataSetList[0]->GetMaxKinEnergy()/GeV;
355 if (ehi < defaultHi) {
356 outFile <<
" <li><b><a href=\"" << dataSetList[0]->GetName()
358 << dataSetList[0]->GetName() <<
"</a> from "
359 << ehi <<
" GeV to " << defaultHi <<
" GeV </b></li>\n";
371 G4String pathName = dirName +
"/" + physListName +
"_" + HtmlFileName(cs->
GetName());
373 outCS.open(pathName);
376 outCS <<
"<title>Description of " << cs->
GetName()
378 outCS <<
"</head>\n";
383 outCS <<
"</body>\n";
384 outCS <<
"</html>\n";
393 std::transform(str.begin(), str.end(), str.begin(), [](
char ch) {
394 return ch ==
' ' ?
'_' : ch;
408 dataSetList.push_back(p);
418 dataSetList.push_back(p);
420 }
else if ( i >= dataSetList.size() ) {
421 dataSetList.push_back(p);
424 std::vector< G4VCrossSectionDataSet* >::iterator it = dataSetList.end() - i;
425 dataSetList.insert(it , p);
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
std::vector< G4Material * > G4MaterialTable
G4GLOB_DLL std::ostream G4cout
void DumpHtml(const G4ParticleDefinition &, std::ofstream &) const
void PrintCrossSectionHtml(const G4VCrossSectionDataSet *cs, const G4String &, const G4String &) const
void BuildPhysicsTable(const G4ParticleDefinition &)
void AddDataSet(G4VCrossSectionDataSet *)
void DumpPhysicsTable(const G4ParticleDefinition &)
G4double ComputeCrossSection(const G4DynamicParticle *, const G4Material *)
G4double GetCrossSection(const G4DynamicParticle *, const G4Material *)
G4CrossSectionDataStore()
const G4Element * SampleZandA(const G4DynamicParticle *, const G4Material *, G4Nucleus &target)
G4double GetLogKineticEnergy() const
G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
G4double * GetRelativeAbundanceVector() const
G4bool GetNaturalAbundanceFlag() const
const G4Isotope * GetIsotope(G4int iso) const
size_t GetNumberOfIsotopes() const
const G4String & GetName() const
static G4HadronicParameters * Instance()
const G4Element * GetElement(G4int iel) const
const G4double * GetVecNbOfAtomsPerVolume() const
static G4MaterialTable * GetMaterialTable()
std::size_t GetNumberOfElements() const
const G4String & GetName() const
void SetIsotope(const G4Isotope *iso)
const G4String & GetParticleName() const
bool ForAllAtomsAndEnergies() const
const G4String & GetName() const
virtual void CrossSectionDescription(std::ostream &) const