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

An IAEA phase-space file source. More...

#include <iaea_phsp_source.h>

Inheritance diagram for IAEA_PhspSource:
EGS_BaseSource EGS_Object

Public Member Functions

 IAEA_PhspSource (const string &phsp_file, const string &Name="", EGS_ObjectFactory *f=0)
 Constructor. More...
 
 IAEA_PhspSource (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)
 
void setSimulationChunk (EGS_I64 nstart, EGS_I64 nrun)
 
EGS_Float getEmax () const
 
EGS_Float getFluence () const
 
EGS_Float getMu ()
 
bool storeState (ostream &data) const
 
bool setState (istream &data)
 
bool addState (istream &data)
 
void resetCounter ()
 
bool isValid () const
 
void setCutout (EGS_Float xmin, EGS_Float xmax, EGS_Float ymin, EGS_Float ymax)
 
void setFilter (int, int, int, const int *)
 
- 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...
 
- 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 openFile (const string &)
 
void init ()
 
bool rejectParticle () const
 

Protected Attributes

bool is_valid
 
string the_file_name
 The phase-space file name.
 
bool mode2
 true, if a MODE2 file (i.e. storing Zlast)
 
bool latch_stored
 true if LATCH is stored in data
 
bool mu_stored
 true if mu index stored
 
bool swap_bytes
 
EGS_Float Emax
 Maximum k.e. (obtained from the phsp file)
 
EGS_Float Pinc
 Number of incident particles that created the file.
 
EGS_I64 Nparticle
 Number of particles in the file.
 
EGS_I64 Nphoton
 Number of photons in the file.
 
EGS_I64 Nread
 Number of particles read so far.
 
EGS_I64 Npos
 Next record to be read.
 
EGS_I64 Nfirst
 first record this source can use
 
EGS_I64 Nlast
 Last record this source can use.
 
EGS_I64 count
 
int Nrestart
 Number of times the file was restarted.
 
int Nrecycle_g
 Number of times to recycle a photon.
 
int Nrecycle_e
 Number of times to recycle a charged particle.
 
int Nrecycle
 Number of times to recycle current particle.
 
int Nuse
 Number of times current particle was used so far.
 
int iaea_iostat
 iostat on read/write of iaea phsp file
 
int iaea_fileid
 phsp file unit no.
 
int n_extra_floats
 no. of extra floats stored in phsp file
 
int n_extra_longs
 no. of extra longs stored in phsp file
 
int i_zlast
 index of zlast in extra_floats array
 
int i_mu
 index of mu index in extra_floats array
 
int i_latch
 index of latch in extra_floats array
 
bool first
 
int particle_type
 
int filter_type
 
unsigned long filter1
 
unsigned long filter2
 
EGS_Float Xmin
 
EGS_Float Xmax
 
EGS_Float Ymin
 
EGS_Float Ymax
 
EGS_Float wmin
 
EGS_Float wmax
 
- 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

An IAEA phase-space file source.

An IAEA format phase-space file source reads and delivers particles from a IAEA phase-space file. The phase-space file contains iq, E, x, y, u, v, w, latch, (Zlast). The format also allows z to be defined for each particle. In the case of a planar source (e.g. output by BEAMnrc), the constant z where the file was scored is read from the header of the file and applied to every particle. Note that this is different from an EGS phase space source, which always sets the incident z equal to zero. Thus, for the IAEA phase space source, you have to be aware of the z where the source was scored when defining the position of the source relative to the chamber/phantom geometry. An IAEA phase-space file source is defined as follows:

:start source:
    library = iaea_phsp_source
    name = some_name
    iaea phase space file = base name of the phase space file (no extension)
    particle type = one of photons, electrons, positrons, all, or charged
    cutout = x1 x2 y1 y2  (optional)
    weight window = wmin wmax, the min and max particle weights to use. If the particle weight is not in this range, it is rejected. (optional)
    recycle photons = number of times to recycle each photon (optional)
    recycle electrons = number of times to recycle each electron (optional)
:stop source:

The optional cutout key permits to set a rectangular cutout defined by its upper-left and lower-right corners x1,y1 and x2,y2 (all particles not within this rectangle will be thrown away). The particle type key permits to select a subset of particles based on the particle charge. No filters based on the value of the latch variable are implemented yet but such filters will be added in future versions of the library. Note that an iaea phase-space source can be used as the source in a transformed source permitting in this way arbitrary transformations to be applied to the particle positions and directions. It is worth noting that, together with a transformation, the iaea phase-space source can reproduce the functionality of any iaea phase-space file based source in the RZ series of user codes and in DOSXYZnrc.

A simple example:

:start source definition:
    :start source:
        name        = my_source
        library     = iaea_phsp_source
        iaea phase space file = your phase space file (no extension)
        particle type = all
        cutout      = -1 1 -2 2
        recycle photons = 10
        recycle electrons = 10
    :stop source:

    simulation source = my_source

:stop source definition:
egs_phsp_source.png
A simple example
Todo:
Fully implement latch filters

Definition at line 133 of file iaea_phsp_source.h.

Constructor & Destructor Documentation

IAEA_PhspSource::IAEA_PhspSource ( const string &  phsp_file,
const string &  Name = "",
EGS_ObjectFactory f = 0 
)

Constructor.

Construct a phase-space file source delivering particles from the IAEA format phase-space file phsp_file.

Definition at line 43 of file iaea_phsp_source.cpp.

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

Constructor.

Construct a phase-space file source from the information pointed to by inp.

Definition at line 225 of file iaea_phsp_source.cpp.

References EGS_BaseSource::description, egsWarning, EGS_Input::getInput(), Nrecycle_e, Nrecycle_g, and the_file_name.

Member Data Documentation

bool IAEA_PhspSource::swap_bytes
protected
\c true, if phase-space file was generated

on a CPU with different endianness

Definition at line 255 of file iaea_phsp_source.h.

EGS_I64 IAEA_PhspSource::count
protected
 Particles delivered so far (may be less than

Nread because some particles were rejected

Definition at line 259 of file iaea_phsp_source.h.


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