The cache of already computed cross sections.
More...
#include <ElementXsecCache.h>
|
| ElementXsecCache ()=default |
| Default constructor. More...
|
|
| ElementXsecCache (std::shared_ptr< PrototypeModel > model) |
| Constructor with a model to calculate the cross section.
|
|
G4double | get (G4double energy, G4double A, G4double Z) |
| Get the value of the cross section for the input variables and calculate the cross section if it wasn't calculated before. More...
|
|
void | stream (std::ostream &o) const |
| Stream the entire table into the output stream. More...
|
|
|
typedef unsigned long int | key_t |
| The type for the key we use in the cache.
|
|
|
key_t | computeKey (G4double energy, G4double A, G4double Z) const |
| Compute a key for the cache map Generating a unique key after making the energy [MeV] an integer. More...
|
|
|
std::map< key_t, G4double > | the_cache_ |
| the actual map from cache keys to calculated cross sections
|
|
std::shared_ptr< PrototypeModel > | model_ |
| shared pointer to the model for calculating cross sections
|
|
|
static const key_t | MAX_A {1000} |
| The maximum value of A.
|
|
static const key_t | MAX_E {1500000} |
| The maximum value for energy [MeV].
|
|
The cache of already computed cross sections.
We make a specific class for the cache in order to keep the key encoding/decoding process in a central location.
◆ ElementXsecCache()
g4db::ElementXsecCache::ElementXsecCache |
( |
| ) |
|
|
default |
Default constructor.
Does nothing interesting, but no model for calculating cross section has been set.
◆ computeKey()
Compute a key for the cache map Generating a unique key after making the energy [MeV] an integer.
The atomic mass (A) and charge (Z) are given by Geant4 as doubles as well, so I cast them to integers before computing the key.
This is what you would edit if you want a more/less find-grained cache of Xsecs. Right now, since the internal unit of energy in Geant4 is MeV, the cache is binned at the 1MeV scale.
- Parameters
-
[in] | energy | Energy of incident lepton [MeV] |
[in] | A | atomic mass of element [atomic mass units] |
[in] | Z | atomic number of element [num protons] |
- Returns
- unsigned integer cache key for these three inputs
- Note
- This implicitly converts the input double to a unsigned long int. Since the internal units for energy are MeV, this means the cache is binned at a 1 MeV level. The atomic inputs A and Z also undergo the implicit conversion; however, this is less of a worry since different elements are separated by at least one whole unit in A and Z.
◆ get()
G4double g4db::ElementXsecCache::get |
( |
G4double |
energy, |
|
|
G4double |
A, |
|
|
G4double |
Z |
|
) |
| |
Get the value of the cross section for the input variables and calculate the cross section if it wasn't calculated before.
- Exceptions
-
std::runtime_error | if no model is available for calculating cross sections |
- Parameters
-
[in] | energy | Energy of incident lepton [MeV] |
[in] | A | atomic mass of element [atomic mass units] |
[in] | Z | atomic number of element [num protons] |
- Returns
- cross section corresponding to the input parameters (including units Geant4 style)
◆ stream()
void g4db::ElementXsecCache::stream |
( |
std::ostream & |
o | ) |
const |
Stream the entire table into the output stream.
- Parameters
-
[in,out] | o | ostream to write to |
◆ operator<<
Overload the streaming operator for ease.
- Parameters
-
[in] | o | ostream to write to |
[in] | c | cache to write out |
- Returns
- modified ostream
The documentation for this class was generated from the following files: