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_SourceCollection Class Reference

A source collection. More...

#include <egs_source_collection.h>

Inheritance diagram for EGS_SourceCollection:
EGS_BaseSource EGS_Object

Public Member Functions

 EGS_SourceCollection (const vector< EGS_BaseSource * > &S, const vector< EGS_Float > &prob, const string &Name="", EGS_ObjectFactory *f=0)
 Constructor. More...
 
 EGS_SourceCollection (EGS_Input *, EGS_ObjectFactory *f=0)
 Constructor. More...
 
EGS_I64 getNextParticle (EGS_RandomGenerator *rndm, int &q, int &latch, EGS_Float &E, EGS_Float &wt, EGS_Vector &x, EGS_Vector &u)
 
EGS_Float getEmax () const
 
EGS_Float getFluence () const
 
bool storeState (ostream &data) const
 
bool setState (istream &data)
 
void resetCounter ()
 
virtual bool addState (istream &data_in)
 
bool isValid () const
 
void setSimulationChunk (EGS_I64 nstart, EGS_I64 nrun)
 
- 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 int getCharge () const
 Get the charge of the source. 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

void setUp (const vector< EGS_BaseSource * > &S, const vector< EGS_Float > &)
 

Protected Attributes

int nsource
 
EGS_BaseSource ** sources
 The sources in the collection.
 
EGS_SimpleAliasTabletable
 Alias table for randomly picking a source.
 
EGS_I64 * last_cases
 Last case returned from each source.
 
EGS_Float * p
 The probabilities.
 
EGS_Float Emax
 Maximum energy (max of s[j]->getEmax()).
 
EGS_I64 count
 Independent particles delivered.
 
- 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

A source collection.

A source collection consists of an arbitrary number $N$ of any other sources $s_1, s_2, ..., s_N$ with weights of $w_1, w_2, ..., w_N$ and delivers particles from $s_j$ with probability $w_j$. A source collection is defined using

:start source:
    library = egs_source_collection
    name = some_name
    source names = list of names of previously defined sources
    weights = list of weights for the sources
:stop source:

A simple example:

:start source definition:
    :start source:
        library     = egs_point_source
        name        = p1
        position    = -2 0 0
        :start spectrum:
            type    = monoenergetic
            energy  = 1
        :stop spectrum:
        charge      = 0
    :stop source:
    :start source:
        library     = egs_point_source
        name        = p2
        position    = 2 0 0
        :start spectrum:
            type    = monoenergetic
            energy  = 1
        :stop spectrum:
        charge      = 0
    :stop source:
    :start source:
        library = egs_source_collection
        name = my_source
        source names = p1 p2
        weights = 0.1 0.9
    :stop source:

    simulation source = my_source

:stop source definition:
egs_source_collection.png
A simple example

Definition at line 120 of file egs_source_collection.h.

Constructor & Destructor Documentation

EGS_SourceCollection::EGS_SourceCollection ( const vector< EGS_BaseSource * > &  S,
const vector< EGS_Float > &  prob,
const string &  Name = "",
EGS_ObjectFactory f = 0 
)

Constructor.

Construct a source collection from the sources S using the probabilities prob.

Definition at line 130 of file egs_source_collection.h.

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

Constructor.

Construct a source collection from the input pointed to by inp.

Definition at line 40 of file egs_source_collection.cpp.

References EGS_BaseSource::createSource(), egsInformation, egsWarning, EGS_Input::getInput(), EGS_BaseSource::getSource(), EGS_Input::print(), and EGS_Input::takeInputItem().


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