Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4CrossSectionDataStore Class Reference

#include <G4CrossSectionDataStore.hh>

Public Member Functions

 G4CrossSectionDataStore ()
 
 ~G4CrossSectionDataStore ()
 
G4double GetCrossSection (const G4DynamicParticle *, const G4Material *)
 
G4double GetCrossSection (const G4DynamicParticle *, const G4Element *, const G4Material *)
 
G4double GetCrossSection (const G4DynamicParticle *, G4int Z, G4int A, const G4Isotope *, const G4Element *, const G4Material *)
 
G4ElementSampleZandA (const G4DynamicParticle *, const G4Material *, G4Nucleus &target)
 
void BuildPhysicsTable (const G4ParticleDefinition &)
 
void DumpPhysicsTable (const G4ParticleDefinition &)
 
void DumpHtml (const G4ParticleDefinition &, std::ofstream &) const
 
void PrintCrossSectionHtml (const G4VCrossSectionDataSet *cs) const
 
void AddDataSet (G4VCrossSectionDataSet *)
 
void SetVerboseLevel (G4int value)
 
const
G4FastPathHadronicCrossSection::fastPathParameters
GetFastPathParameters () const
 
const
G4FastPathHadronicCrossSection::controlFlag
GetFastPathControlFlags () const
 
void DumpFastPath (const G4ParticleDefinition *, const G4Material *, std::ostream &os)
 
void ActivateFastPath (const G4ParticleDefinition *, const G4Material *, G4double)
 

Friends

struct G4FastPathHadronicCrossSection::fastPathEntry
 

Detailed Description

Definition at line 63 of file G4CrossSectionDataStore.hh.

Constructor & Destructor Documentation

G4CrossSectionDataStore::G4CrossSectionDataStore ( )

Definition at line 63 of file G4CrossSectionDataStore.cc.

63  :
64  nDataSetList(0), verboseLevel(0),fastPathFlags(),fastPathParams(),
65  counters(),fastPathCache()
66 {
67  nist = G4NistManager::Instance();
68  currentMaterial = elmMaterial = 0;
69  currentElement = 0; //ALB 14-Aug-2012 Coverity fix.
70  matParticle = elmParticle = 0;
71  matKinEnergy = elmKinEnergy = matCrossSection = elmCrossSection = 0.0;
72 }
static G4NistManager * Instance()

Here is the call graph for this function:

G4CrossSectionDataStore::~G4CrossSectionDataStore ( )

Definition at line 76 of file G4CrossSectionDataStore.cc.

77 {}

Member Function Documentation

void G4CrossSectionDataStore::ActivateFastPath ( const G4ParticleDefinition pdef,
const G4Material mat,
G4double  min_cutoff 
)

Definition at line 531 of file G4CrossSectionDataStore.cc.

532 {
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";
539  throw G4HadronicException(__FILE__,__LINE__,msg.str());
540  }
541 }
const G4String & GetName() const
Definition: G4Material.hh:178
static constexpr double second
Definition: G4SIunits.hh:157
const G4String & GetParticleName() const
std::pair< const G4ParticleDefinition *, const G4Material * > G4CrossSectionDataStore_Key
void G4CrossSectionDataStore::AddDataSet ( G4VCrossSectionDataSet p)
inline

Definition at line 160 of file G4CrossSectionDataStore.hh.

161 {
162  dataSetList.push_back(p);
163  ++nDataSetList;
164 }

Here is the caller graph for this function:

void G4CrossSectionDataStore::BuildPhysicsTable ( const G4ParticleDefinition aParticleType)

Definition at line 496 of file G4CrossSectionDataStore.cc.

497 {
498  if (nDataSetList == 0)
499  {
500  throw G4HadronicException(__FILE__, __LINE__,
501  "G4CrossSectionDataStore: no data sets registered");
502  return;
503  }
504  for (G4int i=0; i<nDataSetList; ++i) {
505  dataSetList[i]->BuildPhysicsTable(aParticleType);
506  }
507  //A.Dotti: if fast-path has been requested we can now create the surrogate
508  // model for fast path.
509  if ( fastPathFlags.useFastPathIfAvailable ) {
510  fastPathFlags.initializationPhase = true;
511  using my_value_type=G4FastPathHadronicCrossSection::G4CrossSectionDataStore_Requests::value_type;
512  //Loop on all requests, if particle matches create the corresponding fsat-path
513  std::for_each( requests.begin() , requests.end() ,
514  [&aParticleType,this](const my_value_type& req) {
515  if ( aParticleType == *req.part_mat.first ) {
517  new G4FastPathHadronicCrossSection::cycleCountEntry(aParticleType.GetParticleName(),req.part_mat.second);
518  entry->fastPath =
519  new G4FastPathHadronicCrossSection::fastPathEntry(&aParticleType,req.part_mat.second,req.min_cutoff);
520  entry->fastPath->Initialize(this);
521  fastPathCache[req.part_mat] = entry;
522  }
523  }
524  );
525  fastPathFlags.initializationPhase = false;
526  }
527 }
void Initialize(G4CrossSectionDataStore *)
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
fastPathEntry * fastPath

Here is the call graph for this function:

Here is the caller graph for this function:

void G4CrossSectionDataStore::DumpFastPath ( const G4ParticleDefinition pd,
const G4Material mat,
std::ostream &  os 
)

Definition at line 253 of file G4CrossSectionDataStore.cc.

254 {
255  const G4FastPathHadronicCrossSection::cycleCountEntry* entry = fastPathCache[{pd,mat}];
256  if ( entry != nullptr ) {
257  if ( entry->fastPath != nullptr ) {
258  os<<*entry->fastPath;
259  } else {
260  os<<"#Cache entry for {"<<(pd!=nullptr?pd->GetParticleName():"UNDEFINED")<<",";
261  os<<(mat!=nullptr?mat->GetName():"UNDEFINED")<<"} found, but no fast path defined";
262  }
263  } else {
264  os<<"#Cache entry for {"<<(pd!=nullptr?pd->GetParticleName():"UNDEFINED")<<",";
265  os<<(mat!=nullptr?mat->GetName():"UNDEFINED")<<"} not found.";
266  }
267 }
const G4String & GetName() const
Definition: G4Material.hh:178
const G4String & GetParticleName() const
fastPathEntry * fastPath

Here is the call graph for this function:

void G4CrossSectionDataStore::DumpHtml ( const G4ParticleDefinition ,
std::ofstream &  outFile 
) const

Definition at line 573 of file G4CrossSectionDataStore.cc.

575 {
576  // Write cross section data set info to html physics list
577  // documentation page
578 
579  G4double ehi = 0;
580  G4double elo = 0;
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";
589  //G4cerr << i << ": XS for " << pD.GetParticleName() << " : " << dataSetList[i]->GetName()
590  // << " typeid : " << typeid(dataSetList[i]).name()<< G4endl;
591  PrintCrossSectionHtml(dataSetList[i]);
592  }
593 
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";
599  PrintCrossSectionHtml(dataSetList[0]);
600  }
601 }
int G4int
Definition: G4Types.hh:78
static constexpr double GeV
Definition: G4SIunits.hh:217
void PrintCrossSectionHtml(const G4VCrossSectionDataSet *cs) const
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

void G4CrossSectionDataStore::DumpPhysicsTable ( const G4ParticleDefinition aParticleType)

Definition at line 546 of file G4CrossSectionDataStore.cc.

547 {
548  // Print out all cross section data sets used and the energies at
549  // which they apply
550 
551  if (nDataSetList == 0) {
552  G4cout << "WARNING - G4CrossSectionDataStore::DumpPhysicsTable: "
553  << " no data sets registered" << G4endl;
554  return;
555  }
556 
557  for (G4int i = nDataSetList-1; i >= 0; --i) {
558  G4double e1 = dataSetList[i]->GetMinKinEnergy();
559  G4double e2 = dataSetList[i]->GetMaxKinEnergy();
560  G4cout
561  << " Cr_sctns: " << std::setw(25) << dataSetList[i]->GetName() << ": "
562  << G4BestUnit(e1, "Energy")
563  << " ---> "
564  << G4BestUnit(e2, "Energy") << "\n";
565  if (dataSetList[i]->GetName() == "G4CrossSectionPairGG") {
566  dataSetList[i]->DumpPhysicsTable(aParticleType);
567  }
568  }
569 }
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76

Here is the caller graph for this function:

G4double G4CrossSectionDataStore::GetCrossSection ( const G4DynamicParticle particle,
const G4Material material 
)
inline

Definition at line 155 of file G4CrossSectionDataStore.hh.

155  {
156  //By default tries to use the fast-path mechanism
157  return GetCrossSection( particle , material , false);
158 }
G4double GetCrossSection(const G4DynamicParticle *, const G4Material *)

Here is the caller graph for this function:

G4double G4CrossSectionDataStore::GetCrossSection ( const G4DynamicParticle part,
const G4Element elm,
const G4Material mat 
)

Definition at line 272 of file G4CrossSectionDataStore.cc.

275 {
276  if(mat == elmMaterial && elm == currentElement &&
277  part->GetDefinition() == elmParticle &&
278  part->GetKineticEnergy() == elmKinEnergy)
279  { return elmCrossSection; }
280 
281  elmMaterial = mat;
282  currentElement = elm;
283  elmParticle = part->GetDefinition();
284  elmKinEnergy = part->GetKineticEnergy();
285  elmCrossSection = 0.0;
286 
287  G4int i = nDataSetList-1;
288  G4int Z = G4lrint(elm->GetZ());
289  if (elm->GetNaturalAbundanceFlag() &&
290  dataSetList[i]->IsElementApplicable(part, Z, mat)) {
291 
292  // element wise cross section
293  elmCrossSection = dataSetList[i]->GetElementCrossSection(part, Z, mat);
294 
295  //G4cout << "Element wise " << elmParticle->GetParticleName()
296  // << " xsec(barn)= " << elmCrossSection/barn
297  // << " E(MeV)= " << elmKinEnergy/MeV
298  // << " Z= " << Z << " AbundFlag= " << elm->GetNaturalAbandancesFlag()
299  // <<G4endl;
300 
301  } else {
302  // isotope wise cross section
303  G4int nIso = elm->GetNumberOfIsotopes();
304  G4Isotope* iso = 0;
305 
306  // user-defined isotope abundances
307  G4IsotopeVector* isoVector = elm->GetIsotopeVector();
308  G4double* abundVector = elm->GetRelativeAbundanceVector();
309 
310  for (G4int j = 0; j<nIso; ++j) {
311  if(abundVector[j] > 0.0) {
312  iso = (*isoVector)[j];
313  elmCrossSection += abundVector[j]*
314  GetIsoCrossSection(part, Z, iso->GetN(), iso, elm, mat, i);
315  //G4cout << "Isotope wise " << elmParticle->GetParticleName()
316  // << " xsec(barn)= " << elmCrossSection/barn
317  // << " E(MeV)= " << elmKinEnergy/MeV
318  // << " Z= " << Z << " A= " << iso->GetN() << " j= " << j << G4endl;
319  }
320  }
321  }
322  //G4cout << " E(MeV)= " << elmKinEnergy/MeV
323  // << "xsec(barn)= " << elmCrossSection/barn <<G4endl;
324  return elmCrossSection;
325 }
size_t GetNumberOfIsotopes() const
Definition: G4Element.hh:159
G4bool GetNaturalAbundanceFlag() const
Definition: G4Element.hh:262
std::vector< G4Isotope * > G4IsotopeVector
G4double GetKineticEnergy() const
G4double GetZ() const
Definition: G4Element.hh:131
G4ParticleDefinition * GetDefinition() const
int G4int
Definition: G4Types.hh:78
G4int GetN() const
Definition: G4Isotope.hh:94
G4double * GetRelativeAbundanceVector() const
Definition: G4Element.hh:167
G4IsotopeVector * GetIsotopeVector() const
Definition: G4Element.hh:163
int G4lrint(double ad)
Definition: templates.hh:163
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

G4double G4CrossSectionDataStore::GetCrossSection ( const G4DynamicParticle part,
G4int  Z,
G4int  A,
const G4Isotope iso,
const G4Element elm,
const G4Material mat 
)

Definition at line 369 of file G4CrossSectionDataStore.cc.

374 {
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);
378  }
379  }
380  G4cout << "G4CrossSectionDataStore::GetCrossSection ERROR: "
381  << " no isotope cross section found"
382  << G4endl;
383  G4cout << " for " << part->GetDefinition()->GetParticleName()
384  << " off Element " << elm->GetName()
385  << " in " << mat->GetName()
386  << " Z= " << Z << " A= " << A
387  << " E(MeV)= " << part->GetKineticEnergy()/MeV << G4endl;
388  throw G4HadronicException(__FILE__, __LINE__,
389  " no applicable data set found for the isotope");
390 }
G4double GetKineticEnergy() const
const G4String & GetName() const
Definition: G4Material.hh:178
G4ParticleDefinition * GetDefinition() const
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
#define G4endl
Definition: G4ios.hh:61
static constexpr double MeV
Definition: G4SIunits.hh:214
const G4String & GetName() const
Definition: G4Element.hh:127

Here is the call graph for this function:

const G4FastPathHadronicCrossSection::controlFlag& G4CrossSectionDataStore::GetFastPathControlFlags ( ) const
inline

Definition at line 137 of file G4CrossSectionDataStore.hh.

137 { return fastPathFlags; }

Here is the caller graph for this function:

const G4FastPathHadronicCrossSection::fastPathParameters& G4CrossSectionDataStore::GetFastPathParameters ( ) const
inline

Definition at line 135 of file G4CrossSectionDataStore.hh.

135 { return fastPathParams; }

Here is the caller graph for this function:

void G4CrossSectionDataStore::PrintCrossSectionHtml ( const G4VCrossSectionDataSet cs) const

Definition at line 605 of file G4CrossSectionDataStore.cc.

606 {
607  G4String dirName(getenv("G4PhysListDocDir"));
608  G4String physListName(getenv("G4PhysListName"));
609 
610  G4String pathName = dirName + "/" + physListName + "_" + HtmlFileName(cs->GetName());
611  std::ofstream outCS;
612  outCS.open(pathName);
613  outCS << "<html>\n";
614  outCS << "<head>\n";
615  outCS << "<title>Description of " << cs->GetName()
616  << "</title>\n";
617  outCS << "</head>\n";
618  outCS << "<body>\n";
619 
620  cs->CrossSectionDescription(outCS);
621 
622  outCS << "</body>\n";
623  outCS << "</html>\n";
624 
625 }
virtual void CrossSectionDescription(std::ostream &) const
const G4String & GetName() const

Here is the call graph for this function:

Here is the caller graph for this function:

G4Element * G4CrossSectionDataStore::SampleZandA ( const G4DynamicParticle part,
const G4Material mat,
G4Nucleus target 
)

Definition at line 395 of file G4CrossSectionDataStore.cc.

398 {
399  counters.SampleZandA();
400 
401  G4int nElements = mat->GetNumberOfElements();
402  const G4ElementVector* theElementVector = mat->GetElementVector();
403  G4Element* anElement = (*theElementVector)[0];
404 
405  G4double cross = GetCrossSection(part, mat , true);
406  // select element from a compound
407  if(1 < nElements) {
408  cross *= G4UniformRand();
409  for(G4int i=0; i<nElements; ++i) {
410  if(cross <= xsecelm[i]) {
411  anElement = (*theElementVector)[i];
412  break;
413  }
414  }
415  }
416 
417  G4int Z = G4lrint(anElement->GetZ());
418  G4Isotope* iso = 0;
419 
420  G4int i = nDataSetList-1;
421  if (dataSetList[i]->IsElementApplicable(part, Z, mat)) {
422 
423  //----------------------------------------------------------------
424  // element-wise cross section
425  // isotope cross section is not computed
426  //----------------------------------------------------------------
427  G4int nIso = anElement->GetNumberOfIsotopes();
428  if (0 >= nIso) {
429  G4cout << " Element " << anElement->GetName() << " Z= " << Z
430  << " has no isotopes " << G4endl;
431  throw G4HadronicException(__FILE__, __LINE__,
432  " Isotope vector is not defined");
433  return anElement;
434  }
435  // isotope abundances
436  G4IsotopeVector* isoVector = anElement->GetIsotopeVector();
437  iso = (*isoVector)[0];
438 
439  // more than 1 isotope
440  if(1 < nIso) {
441  iso = dataSetList[i]->SelectIsotope(anElement, part->GetKineticEnergy());
442  }
443 
444  } else {
445 
446  //----------------------------------------------------------------
447  // isotope-wise cross section
448  // isotope cross section is computed
449  //----------------------------------------------------------------
450  G4int nIso = anElement->GetNumberOfIsotopes();
451  cross = 0.0;
452 
453  if (0 >= nIso) {
454  G4cout << " Element " << anElement->GetName() << " Z= " << Z
455  << " has no isotopes " << G4endl;
456  throw G4HadronicException(__FILE__, __LINE__,
457  " Isotope vector is not defined");
458  return anElement;
459  }
460 
461  // user-defined isotope abundances
462  G4IsotopeVector* isoVector = anElement->GetIsotopeVector();
463  iso = (*isoVector)[0];
464 
465  // more than 1 isotope
466  if(1 < nIso) {
467  G4double* abundVector = anElement->GetRelativeAbundanceVector();
468  if(G4int(xseciso.size()) < nIso) { xseciso.resize(nIso); }
469 
470  for (G4int j = 0; j<nIso; ++j) {
471  G4double xsec = 0.0;
472  if(abundVector[j] > 0.0) {
473  iso = (*isoVector)[j];
474  xsec = abundVector[j]*
475  GetIsoCrossSection(part, Z, iso->GetN(), iso, anElement, mat, i);
476  }
477  cross += xsec;
478  xseciso[j] = cross;
479  }
480  cross *= G4UniformRand();
481  for (G4int j = 0; j<nIso; ++j) {
482  if(cross <= xseciso[j]) {
483  iso = (*isoVector)[j];
484  break;
485  }
486  }
487  }
488  }
489  target.SetIsotope(iso);
490  return anElement;
491 }
size_t GetNumberOfIsotopes() const
Definition: G4Element.hh:159
void SetIsotope(const G4Isotope *iso)
Definition: G4Nucleus.hh:122
std::vector< G4Isotope * > G4IsotopeVector
std::vector< G4Element * > G4ElementVector
G4double GetKineticEnergy() const
G4double GetZ() const
Definition: G4Element.hh:131
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:190
int G4int
Definition: G4Types.hh:78
#define G4UniformRand()
Definition: Randomize.hh:97
G4GLOB_DLL std::ostream G4cout
G4double GetCrossSection(const G4DynamicParticle *, const G4Material *)
G4double * GetRelativeAbundanceVector() const
Definition: G4Element.hh:167
G4IsotopeVector * GetIsotopeVector() const
Definition: G4Element.hh:163
int G4lrint(double ad)
Definition: templates.hh:163
#define G4endl
Definition: G4ios.hh:61
size_t GetNumberOfElements() const
Definition: G4Material.hh:186
double G4double
Definition: G4Types.hh:76
const G4String & GetName() const
Definition: G4Element.hh:127

Here is the call graph for this function:

Here is the caller graph for this function:

void G4CrossSectionDataStore::SetVerboseLevel ( G4int  value)
inline

Definition at line 166 of file G4CrossSectionDataStore.hh.

167 {
168  verboseLevel = value;
169 }
const XML_Char int const XML_Char * value
Definition: expat.h:331

Friends And Related Function Documentation

Definition at line 141 of file G4CrossSectionDataStore.hh.


The documentation for this class was generated from the following files: