40 #ifndef EGS_APPLICATION_
41 #define EGS_APPLICATION_
313 virtual int initSimulation();
323 virtual void setSimulationChunk(EGS_I64 nstart, EGS_I64 nrun);
346 virtual int runSimulation();
356 virtual int finishSimulation();
364 virtual void describeSimulation();
380 virtual int simulateSingleShower();
422 virtual int combineResults();
430 virtual int combinePartialResults();
439 int howManyJobsDone();
457 virtual int outputData();
473 virtual int readData();
511 return final_output_file;
521 string constructIOFileName(
const char *extension,
bool with_run_dir)
const;
553 BeforeAnnihFlight = 12,
554 AfterAnnihFlight = 13,
555 BeforeAnnihRest = 28,
568 FluorescentEvent = 25,
569 CosterKronigEvent = 26,
576 AfterSubElectron = 34,
586 ausgab_flag[call] = on_or_off;
617 return first_parallel;
625 EGS_Float &t,
int *newmed) {
627 geometry->resetErrorFlag();
629 int inew = geometry->howfar(ireg,x,u,t,newmed);
630 storeGeometryStep(ireg,inew,x,u,twant,t);
631 if (geometry->getLastError()) {
632 reportGeometryError();
644 return geometry->hownear(ireg,x);
649 return geometry->medium(ireg);
660 return geometry->isRealRegion(ireg);
663 return geometry->isWhere(r);
682 geometry->getNumberRegions(str, regs);
694 geometry->getLabelRegions(str, regs);
706 return source->getMu();
715 int userScoring(
int iarg,
int ir=-1);
766 virtual void fillRandomArray(
int n, EGS_Float *rns);
804 virtual EGS_I64 randomNumbersUsed()
const;
831 virtual int addState(istream &data);
842 virtual void resetCounter();
855 virtual void appInformation(
const char *);
859 virtual void appWarning(
const char *);
863 virtual void appFatal(
const char *);
867 void checkDeviceFull(FILE *);
878 static bool getArgument(
int &argc,
char **argv,
879 const char *name1,
const char *name2,
string &arg);
887 static void checkEnvironmentVar(
int &argc,
char **argv,
const char *env,
888 const char *n1,
const char *n2,
string &var);
905 virtual int initGeometry();
920 virtual int initSource();
967 virtual int initRunControl();
980 virtual int initRNG();
1006 void initAusgabObjects();
1019 virtual int startNewShower();
1045 virtual void finishRun() { };
1047 void storeGeometryStep(
int ireg,
int inew,
const EGS_Vector &x,
1048 const EGS_Vector &u, EGS_Float twant, EGS_Float t);
1050 void reportGeometryError();
1058 bool ausgab_flag[UnknownCall];
1123 EGS_Float getFluence() {
1124 return source->getFluence();
1127 return geometry->regions();
1130 return geometry->nMedia();
1132 const char *getMediumName(
int ind) {
1133 return geometry->getMediumName(ind);
1135 virtual EGS_Float getMediumRho(
int ind) {
1138 virtual EGS_Float getEdep() {
1141 virtual void setEdep(EGS_Float edep) {};
1142 virtual EGS_Float getEcut() {
1145 virtual EGS_Float getPcut() {
1148 virtual EGS_Float getRM() {
1151 virtual void setRadiativeSplitting(
const EGS_Float &nsplit) {};
1156 virtual EGS_Float getTVSTEP() {
1164 string sourceType() {
1165 return source->getObjectType();
1168 int sourceCharge() {
1169 return source->getCharge();
1173 return source->getEmax();
1176 virtual void setLatch(
const int &ip,
const int &latch) {};
1178 virtual void incLatch(
const int &ip,
const int &increment) {};
1180 virtual int getNp() {
1184 virtual int getNpOld() {
1191 virtual void setLatch(
int latch) {};
1195 #define APP_MAIN(app_name) \
1196 int main(int argc, char **argv) { \
1197 app_name app(argc,argv); \
1198 int err = app.initSimulation(); \
1199 if( err ) return err; \
1200 err = app.runSimulation(); \
1201 if( err < 0 ) return err; \
1202 return app.finishSimulation(); \
1205 #define APP_SIMPLE_MAIN(app_name) \
1206 int main(int argc, char **argv) { \
1207 app_name app(argc,argv); \
1209 app.reportResults(); \
1214 #define APP_LIB(app_name) \
1216 APP_EXPORT EGS_Application* createApplication(int argc, char **argv) {\
1217 return new app_name(argc,argv);\
string app_dir
The user code directory.
const string & getFinalOutputFile() const
Returns the base name of the final output file(s)
#define EGS_EXPORT
Export symbols from the egspp library.
EGS_Input * input
the input to this simulation.
virtual int initScoring()
Initialize the scoring of quantities of interest.
EGS_Float hownear(int ireg, const EGS_Vector &x)
Calculates nearest distance to a boundary in any direction.
EGS_I64 current_case
The current case as returned from the source.
virtual void getElectronSteps(double &ch_steps, double &all_steps) const
Get the number of electron steps taken.
EGS_Float E
particle energy in MeV
A simple run control object for advanced EGSnrc C++ applications.
virtual void describeUserCode() const
Describe the user code.
void getNumberRegions(const string &str, vector< int > ®s)
Gets numbers out of str and pushes them onto regs.
EGS_BaseSource class header file.
void getLabelRegions(const string &str, vector< int > ®s)
Gets the regions for the labels in str and pushes onto regs.
int n_parallel
Number of parallel jobs.
AusgabCall
Possible calls to the user scoring function ausgab().
virtual void outputResults()
Output the simulation results.
virtual int ausgab(int)
User scoring function.
A class representing 3D vectors.
A structure holding the information of one particle.
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.
int getIparallel() const
Returns the job number in a parallel run.
bool batch_run
Interactive or batch run.
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
virtual int finishShower()
Called just after the shower() function.
int getNparallel() const
Returns the number of parallel jobs executing.
bool simple_run
Use a simple run control object for parallel runs.
bool isRealRegion(int ireg)
Returns true if ireg is a real region, false otherwise.
Base random number generator class. All random number generators should be derived from this class...
EGS_RandomGenerator * rndm
the random number generator
virtual int initEGSnrcBackEnd()
Initialize the EGSnrc backend.
const string & getRunDir() const
Returns the name of the working directory.
string run_dir
The working directory during the run.
virtual void getCurrentResult(double &sum, double &sum2, double &norm, double &count)
Report the current result.
const string & getAppName() const
Returns the application name.
int Np
The index of the top particle on the stack.
virtual int shower()
Simulate a single shower.
ostream * data_out
data output stream
bool is_pegsless
set to true if a pegsless run
virtual void analyzeResults()
Analyze the simulation results.
EGS_SimpleContainer template class.
A class for fast run-time interpolations.
EGS_RunControl * run
the run control object.
istream * data_in
data input stream
virtual int initCrossSections()
Initialize the EGSnrc cross sections and cross section/transport options.
int getMedium(int ireg)
Returns the medium index in region ireg using C-style indexing.
int ir
particle region index
string app_name
The application name.
string hen_house
The HEN_HOUSE directory.
string egs_config
The EGSnrc config.
const string & getEgsHome() const
Returns the EGS_HOME directory.
int app_index
the index of this application.
int getFirstParallel() const
Returns the first job number in a parallel run.
int latch
latch variable (useful as a flag on many occasions)
const string & getHenHouse() const
Returns the HEN_HOUSE directory.
virtual void startNewParticle()
Start the transport of a new particle.
EGS_Float getMU()
Returns the value of the mu synchronization parameter.
EGS_SimpleContainer< EGS_AusgabObject * > a_objects_list
The ausgab objects.
string output_file
The output file name (no extension)
EGS_I64 last_case
The last case simulated.
virtual void enterNewRegion()
Particle enters new region.
EGS_Input * getInput()
Returns a pointer to the EGS_Input object containing the user input to the application found in the i...
const string & getAppDir() const
Returns the absolute path to the user code directory.
string pegs_file
The pegs file name.
string input_file
The input file name.
EGS_Particle top_p
The top particle on the stack (i.e., the particle being transported)
virtual void setAusgabCall(AusgabCall call, bool on_or_off)
Turns on or off a call to the user scoring function ausgab.
EGS_BaseGeometry class header file.
string abs_pegs_file
The pegs file name including absolute path.
string egs_home
The EGS_HOME directory.
EGS_Float wt
statistical weight
const string & getWorkDir() const
Returns the name of the working directory.
EGS_Interpolator class header file.
EGS_BaseGeometry * geometry
the geometry of this simulation
EGS_BaseSource * source
the particle source
bool uniform_run
Use a uniform run control object for parallel runs.
EGS_SimpleContainer< EGS_AusgabObject * > * a_objects
The ausgab objects for the various ausgab calls.
Base class for advanced EGSnrc C++ applications.
const string & getOutputFile() const
Returns the base name of the output file(s)
Base source class. All particle sources must be derived from this class.
string final_output_file
The final output file name.