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_BaseSimpleSource Class Referenceabstract

Base class for 'simple' particle sources. More...

#include <egs_base_source.h>

Inheritance diagram for EGS_BaseSimpleSource:
EGS_BaseSource EGS_Object EGS_CollimatedSource EGS_FanoSource EGS_IsotropicSource EGS_ParallelBeam EGS_PointSource

Public Member Functions

 EGS_BaseSimpleSource (int Q, EGS_BaseSpectrum *Spec, const string &Name="", EGS_ObjectFactory *f=0)
 Constructor. More...
 
 EGS_BaseSimpleSource (EGS_Input *input, EGS_ObjectFactory *f=0)
 Construct a 'simple' particle source from the information pointed to by input. More...
 
 ~EGS_BaseSimpleSource ()
 Destructor. More...
 
virtual bool isValid () const
 Is this a valid source? More...
 
virtual EGS_I64 getNextParticle (EGS_RandomGenerator *rndm, int &Q, int &latch, EGS_Float &E, EGS_Float &wt, EGS_Vector &x, EGS_Vector &u)
 Sample the next source particle from the source probability distribution. More...
 
virtual void getPositionDirection (EGS_RandomGenerator *rndm, EGS_Vector &x, EGS_Vector &u, EGS_Float &wt)=0
 Sample a particle position and direction. More...
 
virtual EGS_Float getEmax () const
 Get the maximum energy of the source. More...
 
int getCharge () const
 Get the charge of the source. More...
 
virtual bool storeFluenceState (ostream &data_out) const
 Store the fluence state of this source to the data stream data_out. More...
 
virtual bool storeState (ostream &data_out) const
 Store the source state to the data stream data_out. More...
 
virtual bool addState (istream &data)
 Add the source state from the stream data to the current state. More...
 
virtual void resetCounter ()
 Reset the source to a state with zero sampled particles. More...
 
virtual bool addFluenceData (istream &data)
 Add fluence data from the stream data to the current state. More...
 
virtual void resetFluenceCounter ()
 Reset the data related to the sampling of positions and directions to a state with zero sampled particles. More...
 
virtual bool setFluenceState (istream &data)
 Set the data related to the sampling of positions and directions to a state contained in the stream data. More...
 
virtual bool setState (istream &data)
 Set the source state according to the data in the stream data. More...
 
- Public Member Functions inherited from EGS_BaseSource
 EGS_BaseSource (const string &Name="", EGS_ObjectFactory *f=0)
 Construct a source named Name. More...
 
 EGS_BaseSource (EGS_Input *input, EGS_ObjectFactory *f=0)
 Construct a source from the input pointed to by inp. More...
 
const char * getSourceDescription () const
 Get a short description of this source. More...
 
virtual void setSimulationChunk (EGS_I64 nstart, EGS_I64 nrun)
 Set the next simulation chunk to start at nstart and to consist of nrun particles. More...
 
virtual EGS_Float getFluence () const =0
 Return the fluence this source has emitted so far. More...
 
virtual EGS_Float getMu ()
 
- Public Member Functions inherited from EGS_Object
 EGS_Object (const string &Name="", EGS_ObjectFactory *f=0)
 Create an EGS_Object named Name belonging to the object factory f. More...
 
 EGS_Object (EGS_Input *inp, EGS_ObjectFactory *f=0)
 Create an EGS_Object from the information pointed to by inp that belongs to object factory f. More...
 
const string & getObjectName () const
 Get the object name.
 
void setObjectName (const string &Name)
 Set the object name to Name.
 
const string & getObjectType () const
 Get the object type.
 
virtual EGS_ObjectcreateObject (EGS_Input *inp)
 Create an object from the infromation pointed to by inp. More...
 
void setName (EGS_Input *inp)
 Set the name of the object from the information provided by inp. More...
 
int ref ()
 Increase the reference count to this object.
 
int deref ()
 Decrease the reference count to this object.
 
void setFactory (EGS_ObjectFactory *f)
 Set the factory to which the object belongs. More...
 

Protected Member Functions

virtual void setLatch (int &latch)
 

Protected Attributes

int q
 The charge of this simple source.
 
EGS_BaseSpectrums
 The energy spectrum of this source.
 
string type
 A short description of the source type.
 
EGS_I64 count
 Number of statistically independent particles delivered so far.
 
- Protected Attributes inherited from EGS_BaseSource
string description
 A short source description. More...
 
- Protected Attributes inherited from EGS_Object
string name
 The object name.
 
string otype
 The object type.
 
int nref
 Number of references to the object.
 
EGS_ObjectFactoryfactory
 The factory this object belongs to.
 

Additional Inherited Members

- Static Public Member Functions inherited from EGS_BaseSource
static EGS_BaseSourcecreateSource (EGS_Input *)
 Create sources from the information pointed to by input. More...
 
static EGS_BaseSourcegetSource (const string &Name)
 Get a pointer to the source named Name. More...
 
static void addKnownSource (EGS_BaseSource *o)
 Add a known source object to the source factory. More...
 
static void addKnownTypeId (const char *name)
 Add a known source object typeid to the source factory. More...
 
- Static Public Member Functions inherited from EGS_Object
static string getUniqueName (const EGS_Object *o=0)
 Create and return a unique object name. More...
 
static void deleteObject (EGS_Object *o)
 Delete an object. More...
 

Detailed Description

Base class for 'simple' particle sources.

A 'simple' particle source source is a source with a fixed particle charge for which the energy distribution (the spectrum) is decoupled from the probability distribution for direction and position. Hence, to sample a particle, this type of source samples the energy from a spectrum object and the position and direction from another, energy independent distribution using getPositionDirection(). Except for phase space file and BEAM simulation sources, all other sources ever implemented and used in NRC mortran user codes are of this type. The EGS_BaseSimpleSource class is the base class for such sources and implements various algorithms that are common to all 'simple' sources.

Examples:
sources/egs_point_source/egs_point_source.cpp.

Definition at line 557 of file egs_base_source.h.

Constructor & Destructor Documentation

EGS_BaseSimpleSource::EGS_BaseSimpleSource ( int  Q,
EGS_BaseSpectrum Spec,
const string &  Name = "",
EGS_ObjectFactory f = 0 
)

Constructor.

Construct a 'simple' particle source with charge Q, spectrum Spec and name Name. The spectrum must not be null. The newly created source takes ownership of the spectrum object and will delete it in the destructor.

Examples:
sources/egs_point_source/egs_point_source.cpp.

Definition at line 568 of file egs_base_source.h.

EGS_BaseSimpleSource::EGS_BaseSimpleSource ( EGS_Input input,
EGS_ObjectFactory f = 0 
)

Construct a 'simple' particle source from the information pointed to by input.

In addition to the information needed by the base source class constructor , input must contain the information required to create a spectrum, a particle charge key-value pair and whatever else information the derived source class needs.

Definition at line 43 of file egs_base_source.cpp.

References EGS_BaseSpectrum::createSpectrum(), egsWarning, EGS_Input::getInput(), q, and s.

EGS_BaseSimpleSource::~EGS_BaseSimpleSource ( )

Destructor.

Deletes the spectrum object of the 'simple' source.

Definition at line 588 of file egs_base_source.h.

Member Function Documentation

virtual bool EGS_BaseSimpleSource::isValid ( ) const
virtual

Is this a valid source?

The default implementation of this function returns true, if the spectrum object of the source is not null and false otherwise. Should be re-implemented in derived classes to check that the additional prerequisites such sources need are fullfilled. This is used in the template source creation function createSourceTemplate() to check if the input was sufficient to construct the desired source.

Examples:
sources/egs_point_source/egs_point_source.cpp.

Definition at line 604 of file egs_base_source.h.

virtual EGS_I64 EGS_BaseSimpleSource::getNextParticle ( EGS_RandomGenerator rndm,
int &  Q,
int &  latch,
EGS_Float &  E,
EGS_Float &  wt,
EGS_Vector x,
EGS_Vector u 
)
virtual

Sample the next source particle from the source probability distribution.

Uses the sampleEnergy() function of the spectrum object to obtain the particle energy, the pure virtual function getPositionDirection() to obtain the position and direction, and the virtual setLatch() function to obtain a particle latch. Hence, particle source derived from EGS_BaseSimpleSource only need to implement these two functions. Increments count by one.

Implements EGS_BaseSource.

Definition at line 619 of file egs_base_source.h.

virtual void EGS_BaseSimpleSource::getPositionDirection ( EGS_RandomGenerator rndm,
EGS_Vector x,
EGS_Vector u,
EGS_Float &  wt 
)
pure virtual

Sample a particle position and direction.

This pure virtual function must be implemented in classes deriving from EGS_BaseSimpleSource to sample a particle position and direction using the random number generator rndm and to set x to the position, u to the direction and wt to the statistical weight of the particle. This function is needed by getNextParticle().

Examples:
sources/egs_point_source/egs_point_source.cpp.
virtual EGS_Float EGS_BaseSimpleSource::getEmax ( ) const
virtual

Get the maximum energy of the source.

Simply uses the maxEnergy() method of the spectrum object.

Implements EGS_BaseSource.

Definition at line 645 of file egs_base_source.h.

int EGS_BaseSimpleSource::getCharge ( ) const
virtual

Get the charge of the source.

Simply returns the value of the (protected) attribute q.

Reimplemented from EGS_BaseSource.

Definition at line 653 of file egs_base_source.h.

virtual bool EGS_BaseSimpleSource::storeFluenceState ( ostream &  data_out) const
virtual

Store the fluence state of this source to the data stream data_out.

Must be implemented in derived classes to store the data needed to set the state of this source object to its current state. This is needed in restarted calculations.

See Also
EGS_BaseSource::storeState(), EGS_BaseSource::setState(), EGS_BaseSource::addState() and EGS_BaseSource::resetCounter().
Examples:
sources/egs_point_source/egs_point_source.cpp.

Definition at line 667 of file egs_base_source.h.

virtual bool EGS_BaseSimpleSource::storeState ( ostream &  data_out) const
virtual

Store the source state to the data stream data_out.

Uses the storeState() of the spectrum object and the storeFluenceState() virtual function.

Reimplemented from EGS_BaseSource.

Definition at line 676 of file egs_base_source.h.

References egsStoreI64().

virtual bool EGS_BaseSimpleSource::addState ( istream &  data)
virtual

Add the source state from the stream data to the current state.

Uses the addState() of the spectrum object and the addFluenceData() virtual function.

Reimplemented from EGS_BaseSource.

Definition at line 695 of file egs_base_source.h.

References egsGetI64().

virtual void EGS_BaseSimpleSource::resetCounter ( )
virtual

Reset the source to a state with zero sampled particles.

Uses the resetCounter() function of the spectrum object and the virtual function resetFluenceCounter().

Reimplemented from EGS_BaseSource.

Definition at line 716 of file egs_base_source.h.

virtual bool EGS_BaseSimpleSource::addFluenceData ( istream &  data)
virtual

Add fluence data from the stream data to the current state.

This virtual function should be re-implemented in derived classes if the storeFluenceState() function was re-implemented to store additional data.

See Also
storeFluenceState(), setFluenceState(), resetFluenceCounter(), setState(), storeState(), resetCounter() and addState().

Definition at line 731 of file egs_base_source.h.

virtual void EGS_BaseSimpleSource::resetFluenceCounter ( )
virtual

Reset the data related to the sampling of positions and directions to a state with zero sampled particles.

This virtual method should be re-implemented in derived classes to reset all data associated with the sampling of particle positions and directions (if there is such data).

See Also
storeFluenceState(), setFluenceState(), addFluenceData(), setState(), storeState(), resetCounter() and addState().

Definition at line 745 of file egs_base_source.h.

virtual bool EGS_BaseSimpleSource::setFluenceState ( istream &  data)
virtual

Set the data related to the sampling of positions and directions to a state contained in the stream data.

This virtual method should be re-implemented in derived classes to set the data associated with the sampling of particle positions and directions to the state extracted from the data stream data.

See Also
storeFluenceState(), addFluenceState(), addFluenceData(), setState(), storeState(), resetCounter() and addState().
Examples:
sources/egs_point_source/egs_point_source.cpp.

Definition at line 757 of file egs_base_source.h.

virtual bool EGS_BaseSimpleSource::setState ( istream &  data)
virtual

Set the source state according to the data in the stream data.

Uses the setState() method of the spectrum object and the setFluenceState() virtual function.

Reimplemented from EGS_BaseSource.

Definition at line 767 of file egs_base_source.h.

References egsGetI64().

virtual void EGS_BaseSimpleSource::setLatch ( int &  latch)
protectedvirtual

Set the particle latch.

This virtual function can be re-implemented in derived classes to set the particle latch according to some condition. The default implementation sets the latch to zero.

Definition at line 788 of file egs_base_source.h.


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