EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
EGS_TabulatedSpectrum Class Reference

A tabulated spectrum. More...

Inheritance diagram for EGS_TabulatedSpectrum:
EGS_BaseSpectrum

Public Member Functions

 EGS_TabulatedSpectrum (int N, const EGS_Float *x, const EGS_Float *f, int Type=1, const char *fname=0)
 Construct a tabulated spectrum from the energies x and the probabilities f. More...
 
EGS_Float maxEnergy () const
 
EGS_Float expectedAverage () const
 
- Public Member Functions inherited from EGS_BaseSpectrum
 EGS_BaseSpectrum ()
 Constructor. More...
 
virtual ~EGS_BaseSpectrum ()
 Destructor. Does nothing.
 
const string & getType () const
 Get the spectrum type. More...
 
EGS_Float sampleEnergy (EGS_RandomGenerator *rndm)
 Sample a particle energy. More...
 
virtual bool storeState (ostream &data_out) const
 Store the state of the spectrum object into the stream data_out. More...
 
virtual bool setState (istream &data_in)
 Set the state of the spectrum object from the data in the stream data_in. More...
 
virtual bool addState (istream &data_in)
 Add to the state of this object the data from the stream data_in. More...
 
virtual void resetCounter ()
 Reset the state of this spectrum object. More...
 
void getSampledAverage (EGS_Float &e, EGS_Float &de) const
 Get the average sampled energy and its statistical uncertainty. More...
 
void reportAverageEnergy () const
 Report the average energy (expected and actually sampled). More...
 

Protected Member Functions

void setType (int Type, const char *fname)
 
EGS_Float sample (EGS_RandomGenerator *rndm)
 

Protected Attributes

EGS_AliasTabletable
 The alias table object used to sample energies.
 
- Protected Attributes inherited from EGS_BaseSpectrum
EGS_I64 count
 Number of times the sampleEnergy() method was called.
 
double sum_E
 Sum of energies sampled so far.
 
double sum_E2
 Sum of energies squared sampled so far.
 
string type
 A short string describing the spectrum that must be set by derived classes.
 

Additional Inherited Members

- Static Public Member Functions inherited from EGS_BaseSpectrum
static EGS_BaseSpectrumcreateSpectrum (EGS_Input *inp)
 Create and return a pointer to a spectrum object from the information pointed to by inp. More...
 

Detailed Description

A tabulated spectrum.

A tabulated spectrum can be used to simulate any type of energy distribution. Three different types of a tabulated spectrum are available:

Internally the tabulated spectrum object uses an alias table object to sample energies efficiently.

There are two ways for defining a tabulated spectrum by specifying the name of a file containing a spectrum definition, or inline. In the former case the keys needed to define a spectrum are

:start spectrum:
    type = tabulated spectrum
    spectrum file = the name of a spectrum file
:stop spectrum:

The syntax of the spectrum file is the same as for the standard set of EGSnrc user codes (see the example spectra distributed with the system in $HEN_HOUSE/spectra), except that now the mode of the file can also be 2 (line spectrum) or 3 (interpolated spectrum). A spectrum is defined inline as follows:

:start spectrum:
    type = tabulated spectrum
    energies = list of discrete energies or bin edges
    probabilities = list of probabilities
    spectrum type = 0 or 1 or 2 or 3
:stop spectrum:

where the meaning of the spectrum type is the same as the mode of a spectrum file.

Definition at line 383 of file egs_spectra.cpp.

Constructor & Destructor Documentation

EGS_TabulatedSpectrum::EGS_TabulatedSpectrum ( int  N,
const EGS_Float *  x,
const EGS_Float *  f,
int  Type = 1,
const char *  fname = 0 
)

Construct a tabulated spectrum from the energies x and the probabilities f.

The interpretation of x and f depends on the spectrum type specified by Type. For Type=0,1 it is considered to be a histogram spectrum with N-1 bins defined by the N edge energies x. (the difference between a Type=0 and a Type=1 spectrum is that in the one case the probabilities f are considered to be counts per bin whereas in the latter case they are counts per MeV). For Type=2 the spectrum is considered to be a line spectrum with N discrete energies and probabilities given by x and f. For Type=3 the spectrum is considered to be an interpolated spectrum.

Definition at line 401 of file egs_spectra.cpp.


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