53 void _null_terminate(
char *s,
int len) {
55 for (j=len-1; j>=0; j--) {
120 if (egsApp)
egsFatal(
"There can only be a single EGS_SimpleApplication"
128 for (
int i=0; i<argc-1; i++) {
129 if (!strcmp(
"-n",argv[i]) || !strcmp(
"--ncase",argv[i])) {
130 ncase = atoi(argv[i+1]);
146 _null_terminate(
the_egsio->user_code,64);
147 _null_terminate(
the_egsio->input_file,256);
148 _null_terminate(
the_egsio->output_file,256);
149 _null_terminate(
the_egsio->egs_home,128);
150 _null_terminate(
the_egsio->hen_house,128);
151 _null_terminate(
the_egsio->pegs_file,256);
152 _null_terminate(
the_egsio->work_dir,128);
170 egsFatal(
"No geometry definition in the input file\n");
174 egsFatal(
"Failed to construct the simulation geometry\n");
178 egsInformation(
"\nThe simulation geometry is of type %s and has the "
184 for (
int j=0; j<
g->
nMedia(); j++) {
186 int len = strlen(medname);
189 egsFatal(
"Medium index mismatch: %d %d\n",ind,j+1);
198 egsFatal(
"No source definition in the input file\n");
202 egsFatal(
"Failed to construct the particle source\n");
237 for (
int imed=0; imed<
g->
nMedia(); imed++) {
240 egsWarning(
"The maximum energy of the source (%g) is higher than\n"
241 " the cross section data energy range for medium %d\n",
247 egsFatal(
"Create new PEGS data sets and retry\n");
284 EGS_Float aperb = ((EGS_Float)nperb)/((EGS_Float)
ncase);
293 for (EGS_I64 icase=1; icase<=
ncase; icase++) {
295 " cases, cpu time = %9.3f\n",
296 100*aperb*(icase/nperb),timer.
time());
365 int inew = egsApp->
howfar(ireg,
virtual const string & getType() const =0
Get the geometry type.
static EGS_BaseSource * createSource(EGS_Input *)
Create sources from the information pointed to by input.
__extc__ struct EGS_Stack * the_stack
The address of the mortran STACK common block as a pointer to a C-structure of type EGS_Stack...
const char * egsHome() const
EGS_I32 medium
Current medium.
virtual int run()
Run the simulation.
int deref()
Decrease the reference count to this geometry.
EGS_Float time()
Returns the CPU time in seconds since start() was called.
EGS_I64 ncase
Number of showers to simulate.
const char * henHouse() const
EGS_BaseSource class header file.
EGS_BaseSource * source
The particle source.
void fillRandomArray(int n, EGS_Float *r)
Fill the array pointed to by r with n random numbers.
double sum_E
sum of E*wt of particles from the source
This file defines the C/C++ interface to the EGSnrc mortran back-end.
A class representing 3D vectors.
__extc__ struct EGS_IO * the_egsio
The address of the mortran egs_io common block as a pointer to a C-structure of type EGS_IO...
A base class for developing simple EGSnrc applications.
virtual void endHistory()
EGS_I32 medium_new
Medium in the new region.
virtual int isWhere(const EGS_Vector &x)=0
In which region is poisition x?
virtual int howfar(int ireg, const EGS_Vector &x, const EGS_Vector &u, EGS_Float &t, int *newmed=0, EGS_Vector *normal=0)=0
Calculate the distance to a boundary from x along the direction u.
const EGS_Float veryFar
A very large float.
__extc__ void egsFinish(void)
Finish a simulation.
EGS_Float hownear(int ireg, const EGS_Vector &x)
See the EGSnrc hownear geometry specification .
const char * outputFile() const
__extc__ struct EGS_Epcont * the_epcont
The address of the mortran EPCONT common block as a pointer to a C-structure of type EGS_Epcont...
virtual void fillArray(int n, EGS_Float *array)=0
Fill the array of n elements pointed to by array with random numbers.
__extc__ struct EGS_Bounds * the_bounds
The address of the morrtan BOUNDS common block as a pointer to a C-structure of type EGS_Bounds...
__extc__ EGS_I32 egsAddMedium(const char *medname, EGS_I32 length)
Add a medium to the list of media.
virtual void startHistory(EGS_I64)
Start a new shower.
int getMedium(int ireg)
Get the medium index in region ireg.
EGS_InfoFunction EGS_EXPORT egsFatal
Always use this function for reporting fatal errors.
static int nMedia()
Get the number of media registered so far by all geometries.
EGS_Input * input
The input found in the input file.
EGS_RandomGenerator class header file.
virtual ~EGS_SimpleApplication()
EGS_SimpleApplication class header file.
__extc__ struct EGS_Useful * the_useful
The address of the mortran USEFUL common block as a pointer to a C-structure of type EGS_Useful...
EGS_InfoFunction EGS_EXPORT egsInformation
Always use this function for reporting the progress of a simulation and any other type of information...
const char * inputFile() const
const char * userCode() const
#define egsFillRandomArray
EGS_RandomGenerator * rndm
The random number generator.
virtual void finish()
Finish the simulation.
int nreport
How often to report the progress.
A simple class for measuring CPU time.
static void describeGeometries()
Describes all existing geometries.
__extc__ void egsGetTransportParameter(const int *ounit)
Get the transport parameter settings from the input file.
double sum_w
sum of weights
EGS_SimpleApplication(int argc, char **argv)
Construct a simple application object.
EGS_Float rm
Electron rest energy.
void start()
Starts the time measurement.
static EGS_BaseGeometry * createGeometry(EGS_Input *)
Create a geometry (or geometries) from a given input.
static EGS_RandomGenerator * createRNG(EGS_Input *inp, int sequence=0)
Create a RNG object from the information pointed to by inp and return a pointer to it...
__extc__ void egsInit(int argc, char **argv)
Initializes the EGSnrc mortran back-end.
static const char * getMediumName(int ind)
Get the name of medium with index ind.
const string & getName() const
Get the name of this geometry.
static EGS_RandomGenerator * defaultRNG(int sequence=0)
Returns a pointer to the default egspp RNG.
virtual EGS_I64 getNextParticle(EGS_RandomGenerator *rndm, int &q, int &latch, EGS_Float &E, EGS_Float &wt, EGS_Vector &x, EGS_Vector &u)=0
Sample the next source particle from the source probability distribution.
const char * workDir() const
__extc__ struct EGS_Thresh * the_thresh
The address of the mortran THRESH common block as a pointer to a C-structure of type EGS_Thresh...
__extc__ void egsShower(void)
Transport the particles currently on the particle stack.
__extc__ void egsHatch(void)
Initialize cross section data from a PEGS4 data file.
EGS_Timer class header file.
virtual EGS_Float getEmax() const =0
Return the maximum energy of this source.
double sum_E2
sum of E*E*wt of particles from the source
EGS_I64 last_case
last statistically independent event
double sum_w2
sum of weights squared
const char * pegsFile() const
int howfar(int ireg, const EGS_Vector &x, const EGS_Vector &u, EGS_Float &t, int *newmed)
See the EGSnrc howfar geometry specification .
EGS_BaseGeometry * g
The simulation geometry.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.