64 nDataSetList(0), verboseLevel(0),fastPathFlags(),fastPathParams(),
65 counters(),fastPathCache()
68 currentMaterial = elmMaterial = 0;
70 matParticle = elmParticle = 0;
71 matKinEnergy = elmKinEnergy = matCrossSection = elmCrossSection = 0.0;
138 requiresSlowPath=
true;
157 if(mat == currentMaterial && part->
GetDefinition() == matParticle
164 return matCrossSection;
174 return matCrossSection;
178 requiresSlowPath =
true;
190 if ( !requiresSlowPath ) {
195 currentMaterial = mat;
202 if ( entry !=
nullptr && ! requiresSlowPath ) {
211 assert(requiresSlowPath==
false);
212 requiresSlowPath =
true;
216 if ( !requiresSlowPath && fast_entry !=
nullptr ) {
230 if(
G4int(xsecelm.size()) < nElements) { xsecelm.resize(nElements); }
232 for(
G4int i=0; i<nElements; ++i) {
233 matCrossSection += nAtomsPerVolume[i] *
235 xsecelm[i] = matCrossSection;
241 if ( entry !=
nullptr ) {
247 return matCrossSection;
256 if ( entry !=
nullptr ) {
260 os<<
"#Cache entry for {"<<(pd!=
nullptr?pd->
GetParticleName():
"UNDEFINED")<<
",";
261 os<<(mat!=
nullptr?mat->
GetName():
"UNDEFINED")<<
"} found, but no fast path defined";
264 os<<
"#Cache entry for {"<<(pd!=
nullptr?pd->
GetParticleName():
"UNDEFINED")<<
",";
265 os<<(mat!=
nullptr?mat->
GetName():
"UNDEFINED")<<
"} not found.";
276 if(mat == elmMaterial && elm == currentElement &&
279 {
return elmCrossSection; }
282 currentElement = elm;
285 elmCrossSection = 0.0;
287 G4int i = nDataSetList-1;
290 dataSetList[i]->IsElementApplicable(part, Z, mat)) {
293 elmCrossSection = dataSetList[i]->GetElementCrossSection(part, Z, mat);
311 if(abundVector[j] > 0.0) {
312 iso = (*isoVector)[j];
313 elmCrossSection += abundVector[j]*
314 GetIsoCrossSection(part, Z, iso->
GetN(), iso, elm, mat, i);
324 return elmCrossSection;
341 if(dataSetList[idx]->IsIsoApplicable(part, Z, A, elm, mat) ) {
342 return dataSetList[idx]->GetIsoCrossSection(part, Z, A, iso, elm, mat);
346 for (
G4int j = nDataSetList-1; j >= 0; --j) {
347 if (dataSetList[j]->IsElementApplicable(part, Z, mat)) {
348 return dataSetList[j]->GetElementCrossSection(part, Z, mat);
349 }
else if (dataSetList[j]->IsIsoApplicable(part, Z, A, elm, mat)) {
350 return dataSetList[j]->GetIsoCrossSection(part, Z, A, iso, elm, mat);
354 G4cout <<
"G4CrossSectionDataStore::GetCrossSection ERROR: "
355 <<
" no isotope cross section found"
358 <<
" off Element " << elm->
GetName()
360 <<
" Z= " << Z <<
" A= " << A
363 " no applicable data set found for the isotope");
375 for (
G4int i = nDataSetList-1; i >= 0; --i) {
376 if (dataSetList[i]->IsIsoApplicable(part, Z, A, elm, mat) ) {
377 return dataSetList[i]->GetIsoCrossSection(part, Z, A, iso, elm, mat);
380 G4cout <<
"G4CrossSectionDataStore::GetCrossSection ERROR: "
381 <<
" no isotope cross section found"
384 <<
" off Element " << elm->
GetName()
386 <<
" Z= " << Z <<
" A= " << A
389 " no applicable data set found for the isotope");
403 G4Element* anElement = (*theElementVector)[0];
409 for(
G4int i=0; i<nElements; ++i) {
410 if(cross <= xsecelm[i]) {
411 anElement = (*theElementVector)[i];
420 G4int i = nDataSetList-1;
421 if (dataSetList[i]->IsElementApplicable(part, Z, mat)) {
430 <<
" has no isotopes " <<
G4endl;
432 " Isotope vector is not defined");
437 iso = (*isoVector)[0];
455 <<
" has no isotopes " <<
G4endl;
457 " Isotope vector is not defined");
463 iso = (*isoVector)[0];
468 if(
G4int(xseciso.size()) < nIso) { xseciso.resize(nIso); }
472 if(abundVector[j] > 0.0) {
473 iso = (*isoVector)[j];
474 xsec = abundVector[j]*
475 GetIsoCrossSection(part, Z, iso->GetN(), iso, anElement, mat, i);
482 if(cross <= xseciso[j]) {
483 iso = (*isoVector)[j];
498 if (nDataSetList == 0)
501 "G4CrossSectionDataStore: no data sets registered");
504 for (
G4int i=0; i<nDataSetList; ++i) {
505 dataSetList[i]->BuildPhysicsTable(aParticleType);
511 using my_value_type=G4FastPathHadronicCrossSection::G4CrossSectionDataStore_Requests::value_type;
513 std::for_each( requests.begin() , requests.end() ,
514 [&aParticleType,
this](
const my_value_type& req) {
515 if ( aParticleType == *req.part_mat.first ) {
521 fastPathCache[req.part_mat] = entry;
533 assert(pdef!=
nullptr&&mat!=
nullptr);
535 if ( requests.insert( { key , min_cutoff } ).
second ) {
536 std::ostringstream msg;
537 msg<<
"Attempting to request FastPath for couple: "<<pdef->GetParticleName()<<
","<<mat->
GetName();
538 msg<<
" but combination already exists";
551 if (nDataSetList == 0) {
552 G4cout <<
"WARNING - G4CrossSectionDataStore::DumpPhysicsTable: "
553 <<
" no data sets registered" <<
G4endl;
557 for (
G4int i = nDataSetList-1; i >= 0; --i) {
558 G4double e1 = dataSetList[i]->GetMinKinEnergy();
559 G4double e2 = dataSetList[i]->GetMaxKinEnergy();
561 <<
" Cr_sctns: " << std::setw(25) << dataSetList[i]->GetName() <<
": "
565 if (dataSetList[i]->GetName() ==
"G4CrossSectionPairGG") {
566 dataSetList[i]->DumpPhysicsTable(aParticleType);
574 std::ofstream& outFile)
const
581 G4String physListName(getenv(
"G4PhysListName"));
582 for (
G4int i = nDataSetList-1; i > 0; i--) {
583 elo = dataSetList[i]->GetMinKinEnergy()/
GeV;
584 ehi = dataSetList[i]->GetMaxKinEnergy()/
GeV;
585 outFile <<
" <li><b><a href=\"" << physListName <<
"_"
586 << dataSetList[i]->GetName() <<
".html\"> "
587 << dataSetList[i]->GetName() <<
"</a> from "
588 << elo <<
" GeV to " << ehi <<
" GeV </b></li>\n";
594 G4double defaultHi = dataSetList[0]->GetMaxKinEnergy()/
GeV;
595 if (ehi < defaultHi) {
596 outFile <<
" <li><b><a href=\"" << dataSetList[0]->GetName() <<
".html\"> "
597 << dataSetList[0]->GetName() <<
"</a> from "
598 << ehi <<
" GeV to " << defaultHi <<
" GeV </b></li>\n";
607 G4String dirName(getenv(
"G4PhysListDocDir"));
608 G4String physListName(getenv(
"G4PhysListName"));
610 G4String pathName = dirName +
"/" + physListName +
"_" + HtmlFileName(cs->
GetName());
612 outCS.open(pathName);
615 outCS <<
"<title>Description of " << cs->
GetName()
617 outCS <<
"</head>\n";
622 outCS <<
"</body>\n";
623 outCS <<
"</html>\n";
633 std::transform(str.begin(), str.end(), str.begin(), [](
char ch) {
634 return ch ==
' ' ?
'_' : ch;
638 for(std::string::iterator it = str.begin(); it != str.end(); ++it) {
639 if(*it ==
' ') *it =
'_';
size_t GetNumberOfIsotopes() const
void SetIsotope(const G4Isotope *iso)
G4bool GetNaturalAbundanceFlag() const
void Initialize(G4CrossSectionDataStore *)
std::vector< G4Isotope * > G4IsotopeVector
std::vector< G4Element * > G4ElementVector
G4double GetKineticEnergy() const
virtual void CrossSectionDescription(std::ostream &) const
static void logTiming(cycleCountEntry *, fastPathEntry *, timing &)
const G4String & GetName() const
G4bool prevCalcUsedFastPath
G4ParticleDefinition * GetDefinition() const
static constexpr double second
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
const G4String & GetName() const
G4double GetCrossSection(G4double ene) const
const G4double min_cutoff
const G4ElementVector * GetElementVector() const
static G4NistManager * Instance()
const G4String & GetParticleName() const
void ActivateFastPath(const G4ParticleDefinition *, const G4Material *, G4double)
void logStartCountCycles(timing &)
std::pair< const G4ParticleDefinition *, const G4Material * > G4CrossSectionDataStore_Key
const G4double * GetVecNbOfAtomsPerVolume() const
G4bool useFastPathIfAvailable
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
static void logInvocationOneLine(cycleCountEntry *)
static void logHit(cycleCountEntry *)
~G4CrossSectionDataStore()
G4double GetCrossSection(const G4DynamicParticle *, const G4Material *)
G4double * GetRelativeAbundanceVector() const
const G4ParticleDefinition * GetParticleDefinition() const
void DumpFastPath(const G4ParticleDefinition *, const G4Material *, std::ostream &os)
void BuildPhysicsTable(const G4ParticleDefinition &)
G4IsotopeVector * GetIsotopeVector() const
void DumpPhysicsTable(const G4ParticleDefinition &)
void DumpHtml(const G4ParticleDefinition &, std::ofstream &) const
G4CrossSectionDataStore()
static constexpr double GeV
void PrintCrossSectionHtml(const G4VCrossSectionDataSet *cs) const
static constexpr double MeV
static void logInvocationTriedOneLine(cycleCountEntry *)
size_t GetNumberOfElements() const
G4Element * SampleZandA(const G4DynamicParticle *, const G4Material *, G4Nucleus &target)
const G4String & GetName() const
G4bool initializationPhase
void logStopCountCycles(timing &)