EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
Classes | Functions | Variables
Main library

All concrete geometry and particle source classes and EGSnrc C++ applications link against the main library. More...

Classes

class  EGS_AliasTable
 A class for sampling random values from a given probability distribution using the alias table technique. More...
 
class  EGS_SimpleAliasTable
 A class for sampling random bins from a given probability distribution using the alias table technique. More...
 
struct  EGS_Particle
 A structure holding the information of one particle. More...
 
class  EGS_Application
 Base class for advanced EGSnrc C++ applications. More...
 
class  EGS_BaseGeometry
 Base geometry class. Every geometry class must be derived from EGS_BaseGeometry. More...
 
class  EGS_BaseSource
 Base source class. All particle sources must be derived from this class. More...
 
class  EGS_BaseSpectrum
 Base class for energy spectra. All energy spectra in the EGSnrc C++ class library are derived from this class. More...
 
class  EGS_BaseSimpleSource
 Base class for 'simple' particle sources. More...
 
class  EGS_Ensdf
 The ensdf class for reading ensdf format data files. More...
 
class  EGS_GeometryTester
 A class for testing geometries. More...
 
class  EGS_Input
 A class for storing information in a tree-like structure of key-value pairs. This class is used throughout the egspp class library for passing information to the various objects. More...
 
class  EGS_Interpolator
 A class for fast run-time interpolations. More...
 
class  EGS_Library
 A class for dynamically loading shared libraries. More...
 
class  EGS_Object
 Base egspp object. More...
 
class  EGS_ObjectFactory
 An object factory. More...
 
class  EGS_TypedObjectFactory< T >
 A typed object factory. More...
 
class  EGS_ParticleTrack
 A class representing a single track of a particle. More...
 
class  EGS_ParticleTrackContainer
 A class that stores all the tracks in a simulation. More...
 
class  EGS_2DPolygon
 A class to represent a polygon in a plane (a 2D polygon). More...
 
class  EGS_PolygonT< T >
 A template class for 3D polygons. More...
 
class  EGS_2DVector
 A class representing 2D vectors. More...
 
class  EGS_XProjector
 A projector into the x-plane. More...
 
class  EGS_YProjector
 A projector into the y-plane. More...
 
class  EGS_ZProjector
 A projector into the z-plane. More...
 
class  EGS_Projector
 A projector into any plane. More...
 
class  EGS_RandomGenerator
 Base random number generator class. All random number generators should be derived from this class. More...
 
class  EGS_RunControl
 A simple run control object for advanced EGSnrc C++ applications. More...
 
class  EGS_JCFControl
 A 'job control file' (JCF) RCO. More...
 
class  EGS_UniformRunControl
 A job control object for homogeneous computing environments (HCE). More...
 
class  EGS_ScoringSingle
 A class for scoring a single quantity of interest in a Monte Carlo simulation. More...
 
class  EGS_ScoringArray
 A class for scoring an array of quantities (e.g. a dose distribution) in a Monte Carlo simulation. More...
 
class  EGS_BaseShape
 Base shape class. All shapes in the EGSnrc C++ class library are derived from EGS_BaseShape. More...
 
class  EGS_SurfaceShape
 A surface shape. More...
 
class  EGS_PointShape
 A point shape. This is the simplest shape possible: it simply always returns the same point. More...
 
class  EGS_SphereShape
 A sphere shape. More...
 
class  EGS_CylinderShape
 A cylinder shape. More...
 
class  EGS_MonoEnergy
 A monoenergetic particle spectrum. More...
 
class  EGS_GaussianSpectrum
 A Gaussian spectrum. More...
 
class  EGS_DoubleGaussianSpectrum
 A double-Gaussian spectrum. More...
 
class  EGS_UniformSpectrum
 A uniform energy spectrum. More...
 
class  EGS_TabulatedSpectrum
 A tabulated spectrum. More...
 
class  EGS_RadionuclideBetaSpectrum
 Beta spectrum generation for EGS_RadionuclideSpectrum. More...
 
class  EGS_RadionuclideSpectrum
 A radionuclide spectrum. More...
 
class  EGS_Timer
 A simple class for measuring CPU time. More...
 
class  EGS_RotationMatrix
 A class for vector rotations. More...
 
class  EGS_AffineTransform
 A class providing affine transformations. More...
 
class  EGS_Vector
 A class representing 3D vectors. More...
 

Functions

bool EGS_EXPORT egsStoreI64 (ostream &data, EGS_I64 n)
 Writes the 64 bit integer n to the output stream data and returns true on success, false on failure. More...
 
bool EGS_EXPORT egsGetI64 (istream &data, EGS_I64 &n)
 Reads a 64 bit integer from the stream data and assigns it to n. Returns true on success, false on failure. More...
 
EGS_InfoFunction EGS_EXPORT egsSetInfoFunction (EGS_InfoType t, EGS_InfoFunction func)
 Set a function to be used for outputing information, warning messages or reporting fatal errors. More...
 
void EGS_EXPORT egsSetDefaultIOFunctions ()
 Reset I/O functions to their defaults.
 
string EGS_EXPORT egsSimplifyCVSKey (const string &key)
 Remove the $'s from a CVS key. More...
 
void EGS_EXPORT egsSwapBytes (int *)
 Swap the bytes of 32 bit integers.
 
void EGS_EXPORT egsSwapBytes (short *)
 Swap the bytes of 16 bit integers.
 
void EGS_EXPORT egsSwapBytes (float *)
 Swap the bytes of 32 bit reals.
 
string EGS_EXPORT egsJoinPath (const string &first, const string &second)
 Join two path variables (or a path and a file name) using the platform specific directory separator and return the result.
 
string EGS_EXPORT egsStripPath (const string &fname)
 Strip the path from a file name and return the result.
 
string EGS_EXPORT egsExpandPath (const string &fname)
 Expands first environment variable found in a file name. More...
 
string EGS_EXPORT egsHostName ()
 Get the name of the host the program is running on.
 
int EGS_EXPORT egsGetPid ()
 Get the process id.
 
int EGS_EXPORT egsGetEndian ()
 Get the endianess of the machine. More...
 
bool EGS_EXPORT egsIsAbsolutePath (const string &path)
 Does the string path represent an absolute path name?
 
int main (int argc, char **argv)
 A main program for egspp applications.
 

Variables

const EGS_Float epsilon = 1.0/(1ULL<<50)
 The epsilon constant for floating point comparisons. More...
 
const EGS_Float distanceEpsilon = 1.0/(1ULL<<32)
 The distanceEpsilon constant for physical distance comparisons. More...
 
const EGS_I64 loopMax = 1e10
 The maximum number of iterations for near-infinite loops. More...
 
const EGS_Float veryFar = 1e30
 A very large float. More...
 
EGS_EXPORT EGS_InfoFunction egsInformation
 Always use this function for reporting the progress of a simulation and any other type of information. More...
 
EGS_EXPORT EGS_InfoFunction egsWarning
 Always use this function for reporting warnings. More...
 
EGS_EXPORT EGS_InfoFunction egsFatal
 Always use this function for reporting fatal errors. More...
 

Detailed Description

All concrete geometry and particle source classes and EGSnrc C++ applications link against the main library.

The main egspp library contains the base geometry class, the base source class, the base shape class, the base application class for developing EGSnrc C++ applications, as well as many utility classes such as a random number generator, an alias table, an interpolator, scoring classes, and many others that may be useful for developing MC transport simulation applications. Concrete geometries and particle sources are not part of the main library, they are loaded dynamically at run time as needed using the EGS_Library class from object factories (see e.g. EGS_ObjectFactory) based on the information stored in an EGS_Input object.

For more details, see the documentation of the individual classes in the library.

Function Documentation

bool EGS_EXPORT egsStoreI64 ( ostream &  data,
EGS_I64  n 
)

Writes the 64 bit integer n to the output stream data and returns true on success, false on failure.

This function is required because some C++ compilers don't have an implementation of the << operator for 64 bit integers (e.g. MSVC). The 64 bit integer is written as two space separated 32 bit integers.

Definition at line 57 of file egs_functions.cpp.

Referenced by EGS_Application::outputData(), EGS_RandomGenerator::storeState(), EGS_ScoringArray::storeState(), EGS_RadionuclideSource::storeState(), EGS_BaseSpectrum::storeState(), and EGS_BaseSimpleSource::storeState().

bool EGS_EXPORT egsGetI64 ( istream &  data,
EGS_I64 &  n 
)

Reads a 64 bit integer from the stream data and assigns it to n. Returns true on success, false on failure.

This function is required because some C++ compilers don't have an implementation of the >> operator for 64 bit integers (e.g. MSVC). The 64 bit integer is read as two space separated 32 bit integers as written by egsStoreI64().

Definition at line 68 of file egs_functions.cpp.

Referenced by EGS_RadionuclideSource::addState(), EGS_BaseSimpleSource::addState(), EGS_Application::addState(), EGS_Application::readData(), EGS_ScoringArray::setState(), EGS_RadionuclideSource::setState(), EGS_BaseSpectrum::setState(), and EGS_BaseSimpleSource::setState().

EGS_InfoFunction EGS_EXPORT egsSetInfoFunction ( EGS_InfoType  t,
EGS_InfoFunction  func 
)

Set a function to be used for outputing information, warning messages or reporting fatal errors.

Sets the function of type t to func and returns the previously used function for messages of that type.

Definition at line 138 of file egs_functions.cpp.

References egsFatal, egsInformation, and egsWarning.

string EGS_EXPORT egsSimplifyCVSKey ( const string &  key)

Remove the $'s from a CVS key.

This is handy in cases when one wants to output the value of a CVS key such as Id, Revision, etc., without the surrounding dollar signs.

Definition at line 343 of file egs_functions.cpp.

string EGS_EXPORT egsExpandPath ( const string &  fname)

Expands first environment variable found in a file name.

Looks for first Unix or Windows environment variable and expands it into its value. Missing folder separator is added, duplicated separators are removed. Final file name uses slashes as separators.

Definition at line 216 of file egs_functions.cpp.

References egsWarning.

Referenced by EGS_BaseSpectrum::createSpectrum(), and EGS_BeamSource::EGS_BeamSource().

int EGS_EXPORT egsGetEndian ( )

Get the endianess of the machine.

Returns 0, of the machine is big-endian, 1 if it is little endian, and -1, if the endianess could not be determined.

Definition at line 368 of file egs_functions.cpp.

Variable Documentation

const EGS_Float epsilon = 1.0/(1ULL<<50)

The epsilon constant for floating point comparisons.

The epsilon constant is a small number that can be used when comparing two floating point numbers that may be close in value. It is set to 4 times the machine epsilon (2 bits away), to allow for some leeway in floating point error accumulation. It is meant to be used as a float guard for comparisons involving numbers that are of order 1.0; typically used to test if a float x vanishes, as in fabs(x) < epsilon.

Examples:
sources/egs_point_source/egs_point_source.cpp.

Definition at line 61 of file egs_functions.h.

Referenced by EGS_2DPolygon::EGS_2DPolygon(), EGS_ParallelBeam::EGS_ParallelBeam(), EGS_Projector::EGS_Projector(), EGS_RotationMatrix::EGS_RotationMatrix(), EGS_SimpleAliasTable::EGS_SimpleAliasTable(), EGS_RadionuclideSource::getNextParticle(), EGS_SphereShape::getPointSourceDirection(), EGS_2DPolygon::howfar(), EGS_PolygonT< T >::howfar(), EGS_PolygonT< T >::howfar2D(), EGS_RotationMatrix::isI(), EGS_2DPolygon::isInside(), EGS_RotationMatrix::isRotation(), and EGS_RadionuclideSpectrum::sample().

const EGS_Float distanceEpsilon = 1.0/(1ULL<<32)

The distanceEpsilon constant for physical distance comparisons.

The distanceEpsilon constant is a small number that can be used when comparing distances in the egs++ geometry library. It is independent from the machine epsilon defined above. In double precision it is set to 1.0/(1<<32), i.e., about 2.3283e-10, which in centimetres (default units) is smaller than any atomic radius. In single precision it is ~ 4.7684e-7 cm, in which case the geometrical precision limit is then roughly 5 nm.

The distanceEpsilon constant is used as default value for the boundaryTolerance in the egs++ geometries. It is meant to be used as a float guard for comparisons involving distances that are on the order of 1.0 cm.

Definition at line 85 of file egs_functions.h.

const EGS_I64 loopMax = 1e10

The maximum number of iterations for near-infinite loops.

The loopMax constant can be used to replace while(1){} loops so that the code returns after some large number of iterations.

Definition at line 95 of file egs_functions.h.

Referenced by EGS_2DPolygon::EGS_2DPolygon(), EGS_SimpleAliasTable::EGS_SimpleAliasTable(), EGS_VoxelizedShape::EGS_VoxelizedShape(), EGS_BaseGeometry::howfarToOutside(), and EGS_AliasTable::initialize().

const EGS_Float veryFar = 1e30

A very large float.

The veryFar constant is simply a very large float used as a large ditance It is often used as an initial large value for geometry bounds.

Examples:
geometry/egs_box/egs_box.cpp.

Definition at line 104 of file egs_functions.h.

Referenced by EGS_BaseGeometry::computeIntersections(), EGS_2DPolygon::EGS_2DPolygon(), EGS_BeamSource::EGS_BeamSource(), EGS_PlanesT< T >::EGS_PlanesT(), EGS_BaseGeometry::howfarToOutside(), EGS_2DPolygon::hownear(), EGS_SimpleApplication::run(), and EGS_Application::simulateSingleShower().

EGS_EXPORT EGS_InfoFunction egsInformation

Always use this function for reporting the progress of a simulation and any other type of information.

By default the output goes to the standard output. This behaviour can be changed using egsSetInfoFunction(). This is used, for instance, to write output generated in the C++ part of an EGSnrc application to a string and then pass it to the EGSnrc mortran back-end using the egs_write_string subroutine.

See Also
egsWarning and egsFatal.

Definition at line 134 of file egs_functions.cpp.

Referenced by EGS_AusgabObject::addKnownAusgabObject(), EGS_BaseSource::addKnownSource(), EGS_Application::combineResults(), EGS_BaseSpectrum::createSpectrum(), EGS_BaseGeometry::describeGeometries(), EGS_Ranmar::describeRNG(), EGS_Application::describeSimulation(), EGS_BeamSource::EGS_BeamSource(), EGS_Ensdf::EGS_Ensdf(), EGS_RadionuclideBetaSpectrum::EGS_RadionuclideBetaSpectrum(), EGS_RadionuclideSource::EGS_RadionuclideSource(), EGS_RadionuclideSpectrum::EGS_RadionuclideSpectrum(), EGS_SimpleApplication::EGS_SimpleApplication(), EGS_SourceCollection::EGS_SourceCollection(), EGS_VoxelizedShape::EGS_VoxelizedShape(), egsSetInfoFunction(), EGS_RunControl::finishBatch(), EGS_AdvancedApplication::finishSimulation(), EGS_RunControl::finishSimulation(), EGS_UniformRunControl::finishSimulation(), EGS_VolumetricFluence::getStepPerEnergyLoss(), EGS_AdvancedApplication::helpInit(), EGS_Application::initSimulation(), volcor::VCResults::outputResults(), EGS_Projector::printInfo(), EGS_BaseGeometry::printInfo(), EGS_RadionuclideSource::printSampledEmissions(), EGS_RadionuclideSpectrum::printSampledEmissions(), EGS_ParticleTrackContainer::readDataFile(), EGS_BaseSpectrum::reportAverageEnergy(), EGS_ScoringArray::reportResults(), EGS_ParticleTrackContainer::reportResults(), EGS_SimpleApplication::run(), EGS_Application::runSimulation(), EGS_RunControl::startBatch(), and EGS_RunControl::startSimulation().

Always use this function for reporting warnings.

By default the output goes to standard error. This behaviour can be changed using egsSetInfoFunction().

See Also
egsInformation, egsFatal

Definition at line 135 of file egs_functions.cpp.

Referenced by EGS_BaseGeometry::addBooleanProperty(), EGS_ObjectFactory::addObject(), EGS_AdvancedApplication::addState(), EGS_Application::combineResults(), createGeometry(), EGS_BaseGeometry::createGeometry(), EGS_PointShape::createObject(), EGS_BoxShape::createObject(), EGS_SphereShape::createObject(), EGS_CylinderShape::createObject(), EGS_ObjectFactory::createObjects(), EGS_RandomGenerator::createRNG(), EGS_ObjectFactory::createSingleObject(), createSourceTemplate(), EGS_BaseSpectrum::createSpectrum(), EGS_AEnvelope::createTransforms(), EGS_Application::EGS_Application(), EGS_AtomicRelaxations::EGS_AtomicRelaxations(), EGS_BaseSimpleSource::EGS_BaseSimpleSource(), EGS_BeamSource::EGS_BeamSource(), EGS_CollimatedSource::EGS_CollimatedSource(), EGS_DoubleGaussianSpectrum::EGS_DoubleGaussianSpectrum(), EGS_DynamicSource::EGS_DynamicSource(), EGS_Ensdf::EGS_Ensdf(), EGS_FanoSource::EGS_FanoSource(), EGS_IsotropicSource::EGS_IsotropicSource(), EGS_ParallelBeam::EGS_ParallelBeam(), EGS_PhspSource::EGS_PhspSource(), EGS_PointSource::EGS_PointSource(), EGS_RadionuclideSource::EGS_RadionuclideSource(), EGS_RunControl::EGS_RunControl(), EGS_SimpleAliasTable::EGS_SimpleAliasTable(), EGS_SimpleApplication::EGS_SimpleApplication(), EGS_SourceCollection::EGS_SourceCollection(), EGS_TransformedSource::EGS_TransformedSource(), EGS_UnionGeometry::EGS_UnionGeometry(), EGS_VoxelizedShape::EGS_VoxelizedShape(), egsExpandPath(), egsHowfar(), egsSetInfoFunction(), EGS_Ranmar::fillArray(), EGS_RunControl::finishBatch(), EGS_AusgabObject::getAusgabObject(), EGS_GeometryTester::getGeometryTester(), volcor::getShapeVolume(), EGS_BaseSource::getSource(), EGS_AffineTransform::getTransformation(), EGS_AdvancedApplication::helpInit(), IAEA_PhspSource::IAEA_PhspSource(), EGS_AdvancedApplication::initCrossSections(), EGS_Application::initRNG(), EGS_Application::initSimulation(), EGS_AdvancedApplication::outputData(), EGS_Application::outputData(), EGS_RadionuclideSpectrum::printSampledEmissions(), EGS_AdvancedApplication::readData(), EGS_Application::readData(), EGS_ParticleTrackContainer::readDataFile(), EGS_ScoringArray::reportResults(), EGS_ParticleTrackContainer::reportResults(), EGS_Application::runSimulation(), EGS_BaseGeometry::setBoundaryTolerance(), volcor::VCOptions::setBoundsShape(), EGS_BaseGeometry::setBScaling(), EGS_DeformedXYZ::setDeformations(), volcor::VCOptions::setDensity(), EGS_BaseGeometry::setLabels(), EGS_TransformedGeometry::setMedia(), EGS_UnionGeometry::setMedia(), EGS_SmartEnvelope::setMedia(), EGS_AEnvelope::setMedia(), EGS_NDGeometry::setMedia(), EGS_EnvelopeGeometry::setMedia(), EGS_BaseGeometry::setMedia(), EGS_FastEnvelope::setMedia(), EGS_BaseGeometry::setName(), EGS_BaseGeometry::setRelativeRho(), volcor::VCOptions::setRNG(), EGS_Application::simulateSingleShower(), and EGS_RunControl::startBatch().

Always use this function for reporting fatal errors.

By default the output goes to standard error and the exit function is called. This behaviour can be changed using egsSetInfoFunction(). However, keep in mind that there may be code that is not prepared to deal with the situation that egsFatal actually returns.

Definition at line 136 of file egs_functions.cpp.

Referenced by EGS_Application::addAusgabObject(), EGS_Application::checkDeviceFull(), EGS_Application::checkEnvironmentVar(), EGS_BaseGeometry::createGeometry(), EGS_BaseSpectrum::createSpectrum(), EGS_RandomGenerator::defaultRNG(), EGS_2DPolygon::EGS_2DPolygon(), EGS_Application::EGS_Application(), EGS_BaseGeometry::EGS_BaseGeometry(), EGS_FanoSource::EGS_FanoSource(), EGS_GaussianSpectrum::EGS_GaussianSpectrum(), EGS_ObjectFactory::EGS_ObjectFactory(), EGS_PlanesT< T >::EGS_PlanesT(), EGS_Projector::EGS_Projector(), EGS_PyramidT< T >::EGS_PyramidT(), EGS_RadionuclideSource::EGS_RadionuclideSource(), EGS_RotationMatrix::EGS_RotationMatrix(), EGS_RunControl::EGS_RunControl(), EGS_ScoringArray::EGS_ScoringArray(), EGS_SimpleAliasTable::EGS_SimpleAliasTable(), EGS_SimpleApplication::EGS_SimpleApplication(), EGS_StackGeometry::EGS_StackGeometry(), EGS_UnionGeometry::EGS_UnionGeometry(), EGS_VoxelizedShape::EGS_VoxelizedShape(), egsSetInfoFunction(), EGS_BaseShape::getPoint(), EGS_BaseShape::getPointSourceDirection(), volcor::getShapeVolume(), EGS_BaseGeometry::howfarToOutside(), EGS_AliasTable::initialize(), volcor::loadFileResults(), main(), EGS_AdvancedApplication::saveRNGState(), EGS_ASwitchedEnvelope::setActiveGeometries(), and volcor::VCOptions::setRNG().