54#include "egs_advanced_application.h"
55#include "egs_functions.h"
57#include "egs_interface2.h"
58#include "egs_interpolator.h"
59#include "egs_alias_table.h"
61#include "egs_run_control.h"
62#include "egs_scoring.h"
63#include "egs_transformations.h"
64#include "egs_autoenvelope/egs_autoenvelope.h"
65#include "egs_rz/egs_rz.h"
66#include "egs_spheres/egs_spheres.h"
81#define PRINT_PARTICLE(P) cout << "\nParticle in reg "<<P.ir << " at "<<P.x.x << " "<<P.x.y<<" "<<P.x.z << " wt "<<P.wt<< " E "<<P.E << " q "<<P.q << " latch "<<P.latch<<"\n";
82#define PRINT_PARTICLE_WITH_DIR(P) cout << "\nParticle in reg "<<P.ir << " at "<<P.x.x << " "<<P.x.y<<" "<<P.x.z << " dir "<<P.u.x << " "<<P.u.y<<" "<<P.u.z << " wt "<<P.wt<< " E "<<P.E << " q "<<P.q << " latch "<<P.latch<<"\n";
83#define NUM_STUCK_STEPS 1000
84#define SAME_POSITION_TOLERANCE 1E-10
85#define EB_EPSILON 1E-10
206 int createPhantoms();
210 int correctVolumes();
213 int checkSourceOverlaps(EGS_Input *);
216 void initTrackLengthScoring(EGS_Input *);
219 void initMuenData(EGS_Input *);
222 void initOutputFiles(EGS_Input *);
225 void initPHSPScoring(EGS_Input *);
228 void initEDepScoring(EGS_Input *);
231 void initScatScoring(EGS_Input *);
234 void clearAusgabCalls();
237 void enableAusgabCalls(
int ncalls, AusgabCall calls[]);
241 void initGCRScoring(EGS_Input *);
247 void initAusgabCalls();
250 void initDoseScaling(EGS_Input *);
253 void initXCCScaling(EGS_Input *);
256 void initSpectrumScoring(EGS_Input *);
258 int initCrossSections();
260 void discardTopParticle(
int idisc=1);
262 void calcEffectiveHistories();
271 EGS_AdvancedApplication(argc,argv),
279 output_3ddose_files(true),
284 do_brem_split(false),
290 gcr_phantom(0), gcr_phantom_reg(0),
294 effective_histories(0) {
296 for (
int i=-1; i < 2; i++) {
297 steps_in_sources[i] = 0;
298 steps_in_phantoms[i] = 0;
299 steps_in_other[i] = 0;
309 for (vector<EB_Phantom>::size_type pp=0; pp < phantom_geoms.size(); pp++) {
310 delete phantom_geoms[pp];
312 phantom_geoms.clear();
314 map<int, EGS_Interpolator *>::iterator mit = media_muen.begin();
315 for (; mit != media_muen.end(); mit++) {
321 for (vector<EGS_AffineTransform *>::size_type st=0; st < source_transforms.size(); st++) {
322 delete source_transforms[st];
324 source_transforms.clear();
326 for (map<string, EGS_ScoringArray* >::iterator sa=extra_scoring_doses.begin(); sa != extra_scoring_doses.end(); sa++) {
329 extra_scoring_doses.clear();
331 for (map<string, EGS_ScoringArray* >::iterator sa=extra_scoring_doses_edep.begin(); sa != extra_scoring_doses_edep.end(); sa++) {
334 extra_scoring_doses_edep.clear();
344 vector<BaseSpectrumScorer *>::iterator it = spectrum_scorers.begin();
345 for (; it != spectrum_scorers.end(); it++) {
348 spectrum_scorers.clear();
354 if (base_transform_inv) {
355 delete base_transform_inv;
375 void describeUserCode()
const;
381 void describeSimulation();
383 void printIncludedFiles();
386 int initSimulation();
389 int initRunControl();
398 int initVarianceReduction();
401 int initRussianRoulette(EGS_Input *);
404 int initBCSE(EGS_Input *);
407 int ausgab(
int iarg);
418 int outputDataHelper(ostream *);
421 int egsApplicationOutputData(ostream *);
424 int egsAdvApplicationOutputData(ostream *);
427 int egsBrachyOutputData(ostream *);
435 int readDataHelper(istream *);
438 int egsApplicationReadData(istream *);
441 int egsAdvApplicationReadData(istream *);
444 int egsBrachyReadData(istream *);
446 int combineResults();
458 int addState(istream &data);
462 void outputResults();
466 void getCurrentResult(
double &sum,
double &sum2,
double &norm,
473 virtual void startNewParticle();
474 virtual void enterNewRegion();
476 virtual int runSimulation();
479 return output_volcor_format;
482 int howManyJobsDone();
486 void addRecycledParticlesToStack(EGS_Particle *p,
bool new_hist=
false);
487 void copyParticleToSourceLoc(EGS_Particle *p,
int source,
bool kill_orig,
bool rotate, EGS_Float new_wt);
489 void doPhotonSplitting(
int);
496 int simulateSingleShower();
497 int startNewShower();
511 int initSourceTransforms();
516 vector<EGS_AffineTransform *> createTransforms(EGS_Input *input);
The main egs_brachy application class. See the Main Page for full documentation.
vector< BaseSpectrumScorer * > spectrum_scorers
map< string, vector< EGS_Float > > extra_scoring_mass
EnergyScoringStats * escoring
Energy related scoring/stats.
vector< EGS_AffineTransform * > source_transforms
transforms to locations of all sources
map< string, vector< int > > extra_scoring_reg
map< int, EGS_I64 > steps_in_phantoms
EB_TimingTree timing_blocks
Track CPU times of various functions.
map< string, EGS_ScoringArray * > extra_scoring_doses
string output_volcor_format
text or gzip
Publisher pevent_pub
Particle event publisher.
string output_egsdat_format
text or gzip
vector< string > output_volcor_phantoms
vector of phantom names to output volume correctino files for
string output_voxinfo_format
text or gzip
igzstream * gz_data_in
GZip file for outputing egsdat.
EGS_Float global_e_max_rr
max range rejection energy globally
EB_Application(int argc, char **argv)
egs_brachy constructor
int gcr_phantom_reg
region of phantom to use for getCurrentResult (default to 0)
EGS_Float effective_histories
bool source_i_do_rr
enable range rejection in sources
bool output_egsphant
true if user requests egsphant ouput
bool global_i_do_rr
enable range rejection outside of sources
EGS_Float source_pcut
pcut for source objects
static string revision
the usercode revision number
EGS_Float global_pcut
pcut for source objects
bool output_3ddose_files
false if run mode is 'volume correction only'
map< string, EGS_ScoringArray * > extra_scoring_doses_edep
EB_Phantom * gcr_phantom
phantom object to use in getCurrentResult (defaults to 1st phantom)
static const EGS_Float DEFAULT_BCSE_FACTOR
map< string, string > media_muen_names
~EB_Application()
egs_brachy destructor
EGS_ASwitchedEnvelope * superpos_geom
an ASwitchedEnv cast of simulation geometry.
string output_dose_format
text or gzip
vector< EGS_Float > source_weights
map< string, vector< EGS_Float > > extra_scoring_vols
EGS_AffineTransform * base_transform
same as source_transforms[0]
EGS_BaseGeometry * source_envelope_geom
geometry that the sources are embedded in
vector< EB_Phantom * > phantom_geoms
pointers to all of the phantom objects
bool score_scat
true when scatter scoring is enabled
string output_egsphant_format
text or gzip
ogzstream * gz_data_out
GZip file for outputing egsdat.
int nbr_split
Number of times to split bremstrahlung phtons.
map< int, EGS_Interpolator * > media_muen
Map from medium index to muen interpolator for that medium.
ebvolcor::Results gen_vc_results
results from general volume correction
EGS_AffineTransform * base_transform_inv
same as source_transforms[0].inverse()
map< int, EGS_I64 > steps_in_sources
bool output_voxinfo
true if user requests voxel info file
map< int, EGS_I64 > steps_in_other
int nsources
total number of particle sources in current simulation
EGS_Float flu_cutoff
fluorescent photon cutoff energy
@ RM_SUPERPOSITION
Superposition mode for intersource effects.
@ RM_NORMAL
Standard running mode.
GeomInfo ginfo
meta data about the geometries
ebvolcor::Results source_vc_results
results from source volume correctio box phantom
EGS_Float source_ecut
ecut for source objects
bool score_edep
true when energy deposition is enabled
EGS_Float source_e_max_rr
max range rejection energy for source objects
EGS_Float global_ecut
ecut for source objects
vector< EGS_Vector > p_init_locs
bool score_tlen
true when tracklength estimator is enabled
string getOutputVolcorFormat()
RunMode run_mode
Which run mode are we using (RM_NORMAL, RM_SUPERPOSITION or RM_VC_ONLY */.
RecycleOpts * recycle_opts
int record_n_init
if > 0 write initial pos of record_n_init particles to {input_file}.pinit
ebvolcor::FileResults file_vc_results
results from precomputed volume correction
A class to represent a single phantom for scoring dose in egs_brachy.
a class to use for scoring information about total energy initialzed, escaping sources etc
a container for organizing meta data about the geometries
A class for handling latch bits relevant to egs_brachy. The Latch class listens for particle events a...
void subscribe(Subscriber *s, EB_Message message)
Volume correction routines for egs_brachy.
ginfo contains classes for organizing information about the geometries present in an egs_brachy simul...
handle particles latch bits for egs_brachy
Functions for loading muen data from a file.
Header file for phantom objects.
Definition of the PHSPControl object.
A simple pub/sub module to allow various egs_brachy classes to subscribe to particle events.
@ PARTICLE_ESCAPING_SOURCE
@ PARTICLE_ESCAPED_SOURCE
class definitions for recycling
Definition of spectrum scoring classes.
Struct used to collect and output results about a volume correction run.