41 #ifndef EGS_APPLICATION_
42 #define EGS_APPLICATION_
314 virtual int initSimulation();
325 virtual void setSimulationChunk(EGS_I64 nstart, EGS_I64 nrun,
int npar,
int nchunk);
348 virtual int runSimulation();
358 virtual int finishSimulation();
366 virtual void describeSimulation();
382 virtual int simulateSingleShower();
424 virtual int combineResults();
432 virtual int combinePartialResults();
441 int howManyJobsDone();
459 virtual int outputData();
475 virtual int readData();
513 return final_output_file;
523 string constructIOFileName(
const char *extension,
bool with_run_dir)
const;
555 BeforeAnnihFlight = 12,
556 AfterAnnihFlight = 13,
557 BeforeAnnihRest = 28,
570 FluorescentEvent = 25,
571 CosterKronigEvent = 26,
578 AfterSubElectron = 34,
588 ausgab_flag[call] = on_or_off;
619 return first_parallel;
627 EGS_Float &t,
int *newmed) {
629 geometry->resetErrorFlag();
631 int inew = geometry->howfar(ireg,x,u,t,newmed);
632 storeGeometryStep(ireg,inew,x,u,twant,t);
633 if (geometry->getLastError()) {
634 reportGeometryError();
646 return geometry->hownear(ireg,x);
651 return geometry->medium(ireg);
662 return geometry->isRealRegion(ireg);
665 return geometry->isWhere(r);
684 geometry->getNumberRegions(str, regs);
696 geometry->getLabelRegions(str, regs);
708 return source->getTimeIndex();
715 source->setTimeIndex(temp_time);
724 int userScoring(
int iarg,
int ir=-1);
775 virtual void fillRandomArray(
int n, EGS_Float *rns);
813 virtual EGS_I64 randomNumbersUsed()
const;
840 virtual int addState(istream &data);
851 virtual void resetCounter();
864 virtual void appInformation(
const char *);
868 virtual void appWarning(
const char *);
872 virtual void appFatal(
const char *);
876 void checkDeviceFull(FILE *);
887 static bool getArgument(
int &argc,
char **argv,
888 const char *name1,
const char *name2,
string &arg);
896 static void checkEnvironmentVar(
int &argc,
char **argv,
const char *env,
897 const char *n1,
const char *n2,
string &var);
914 virtual int initGeometry();
929 virtual int initSource();
976 virtual int initRunControl();
989 virtual int initRNG();
1015 void initAusgabObjects();
1028 virtual int startNewShower();
1054 virtual void finishRun() { };
1056 void storeGeometryStep(
int ireg,
int inew,
const EGS_Vector &x,
1057 const EGS_Vector &u, EGS_Float twant, EGS_Float t);
1059 void reportGeometryError();
1067 bool ausgab_flag[UnknownCall];
1132 EGS_Float getFluence() {
1139 return geometry->
nMedia();
1141 const char *getMediumName(
int ind) {
1144 virtual EGS_Float getMediumRho(
int ind) {
1147 virtual EGS_Float getEdep() {
1150 virtual void setEdep(EGS_Float edep) {};
1151 virtual EGS_Float getEcut() {
1154 virtual EGS_Float getPcut() {
1157 virtual EGS_Float getRM() {
1164 virtual void setRadiativeSplitting(
const EGS_Float &nsplit) {};
1165 virtual void setRussianRoulette(
const EGS_Float &iSwitchRR) {};
1166 virtual void splitTopParticleIsotropically(
const EGS_Float &fsplit) {}
1171 virtual EGS_Float getTVSTEP() {
1179 string sourceType() {
1183 int sourceCharge() {
1191 virtual void setLatch(
const int &ip,
const int &latch) {};
1193 virtual void incLatch(
const int &ip,
const int &increment) {};
1195 virtual int getNp() {
1199 virtual int getNpOld() {
1206 virtual void setLatch(
int latch) {};
1208 bool containsDynamic() {
1209 bool hasDynamic =
false;
1210 geometry->containsDynamic(hasDynamic);
1212 source->containsDynamic(hasDynamic);
1218 #define APP_MAIN(app_name) \
1219 int main(int argc, char **argv) { \
1220 app_name app(argc,argv); \
1221 int err = app.initSimulation(); \
1222 if( err ) return err; \
1223 err = app.runSimulation(); \
1224 if( err < 0 ) return err; \
1225 return app.finishSimulation(); \
1228 #define APP_SIMPLE_MAIN(app_name) \
1229 int main(int argc, char **argv) { \
1230 app_name app(argc,argv); \
1232 app.reportResults(); \
1237 #define APP_LIB(app_name) \
1239 APP_EXPORT EGS_Application* createApplication(int argc, char **argv) {\
1240 return new app_name(argc,argv);\
Base class for advanced EGSnrc C++ applications.
string app_dir
The user code directory.
bool uniform_run
Use a uniform run control object for parallel runs.
string run_dir
The working directory during the run.
int Np
The index of the top particle on the stack.
bool simple_run
Use a simple run control object for parallel runs.
EGS_RandomGenerator * rndm
the random number generator
bool is_pegsless
set to true if a pegsless run
int n_parallel
Number of parallel jobs.
void getLabelRegions(const string &str, vector< int > ®s)
Gets the regions for the labels in str and pushes onto regs.
EGS_SimpleContainer< EGS_AusgabObject * > a_objects_list
The ausgab objects.
int getMedium(int ireg)
Returns the medium index in region ireg using C-style indexing.
string input_file
The input file name.
string output_file
The output file name (no extension)
virtual void analyzeResults()
Analyze the simulation results.
virtual void setAusgabCall(AusgabCall call, bool on_or_off)
Turns on or off a call to the user scoring function ausgab.
EGS_I64 last_case
The last case simulated.
int howfar(int ireg, const EGS_Vector &x, const EGS_Vector &u, EGS_Float &t, int *newmed)
Calculates distance to a boundary along the current direction.
virtual void startNewParticle()
Start the transport of a new particle.
string pegs_file
The pegs file name.
int getNparallel() const
Returns the number of parallel jobs executing.
virtual int initScoring()
Initialize the scoring of quantities of interest.
EGS_Input * input
the input to this simulation.
EGS_Input * getInput()
Returns a pointer to the EGS_Input object containing the user input to the application found in the i...
virtual int ausgab(int)
User scoring function.
string app_name
The application name.
virtual void outputResults()
Output the simulation results.
const string & getRunDir() const
Returns the name of the working directory.
virtual void getElectronSteps(double &ch_steps, double &all_steps) const
Get the number of electron steps taken.
const string & getEgsHome() const
Returns the EGS_HOME directory.
const string & getAppName() const
Returns the application name.
bool isRealRegion(int ireg)
Returns true if ireg is a real region, false otherwise.
virtual void getCurrentResult(double &sum, double &sum2, double &norm, double &count)
Report the current result.
string final_output_file
The final output file name.
EGS_BaseGeometry * geometry
the geometry of this simulation
AusgabCall
Possible calls to the user scoring function ausgab().
int getFirstParallel() const
Returns the first job number in a parallel run.
EGS_Float getTimeIndex()
Returns the value of the time synchronization parameter.
EGS_I64 current_case
The current case as returned from the source.
const string & getOutputFile() const
Returns the base name of the output file(s)
bool batch_run
Interactive or batch run.
int i_parallel
Job index in parallel runs.
istream * data_in
data input stream
string egs_home
The EGS_HOME directory.
int first_parallel
first parallel job number
int app_index
the index of this application.
virtual int initCrossSections()
Initialize the EGSnrc cross sections and cross section/transport options.
const string & getFinalOutputFile() const
Returns the base name of the final output file(s)
virtual void describeUserCode() const
Describe the user code.
virtual void enterNewRegion()
Particle enters new region.
string abs_pegs_file
The pegs file name including absolute path.
virtual int finishShower()
Called just after the shower() function.
const string & getAppDir() const
Returns the absolute path to the user code directory.
ostream * data_out
data output stream
EGS_Float hownear(int ireg, const EGS_Vector &x)
Calculates nearest distance to a boundary in any direction.
EGS_RunControl * run
the run control object.
EGS_SimpleContainer< EGS_AusgabObject * > * a_objects
The ausgab objects for the various ausgab calls.
const string & getWorkDir() const
Returns the name of the working directory.
void getNumberRegions(const string &str, vector< int > ®s)
Gets numbers out of str and pushes them onto regs.
string egs_config
The EGSnrc config.
string hen_house
The HEN_HOUSE directory.
virtual int initEGSnrcBackEnd()
Initialize the EGSnrc backend.
void setTimeIndex(EGS_Float temp_time)
const string & getHenHouse() const
Returns the HEN_HOUSE directory.
int getIparallel() const
Returns the job number in a parallel run.
EGS_BaseSource * source
the particle source
EGS_Particle top_p
The top particle on the stack (i.e., the particle being transported)
virtual int shower()
Simulate a single shower.
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
static int nMedia()
Get the number of media registered so far by all geometries.
int regions() const
Returns the number of local regions in this geometry.
static const char * getMediumName(int ind)
Get the name of medium with index ind.
Base source class. All particle sources must be derived from this class.
virtual int getCharge() const
Get the charge of the source.
virtual EGS_Float getEmax() const =0
Return the maximum energy of this source.
virtual EGS_Float getFluence() const =0
Return the fluence this source has emitted so far.
A class for fast run-time interpolations.
const string & getObjectType() const
Get the object type.
Base random number generator class. All random number generators should be derived from this class.
A simple run control object for advanced EGSnrc C++ applications.
A class representing 3D vectors.
EGS_BaseGeometry class header file.
EGS_BaseSource class header file.
EGS_Interpolator class header file.
#define EGS_EXPORT
Export symbols from the egspp library.
EGS_SimpleContainer template class.
A structure holding the information of one particle.
EGS_Float E
particle energy in MeV
int ir
particle region index
int latch
latch variable (useful as a flag on many occasions)
EGS_Float wt
statistical weight