45#include "egs_advanced_application.h"
46#include "egs_functions.h"
48#include "egs_interface2.h"
49#include "egs_scoring.h"
67 EGS_Float rest_mass = 0;
68 if (subtractRM && p->q != 0){
69 rest_mass = the_useful->prm;
71 return (p->E - rest_mass)*p->wt;
150 EGS_Particle *p =
static_cast<EGS_Particle *
>(particle);
153 EGS_Particle *p =
static_cast<EGS_Particle *
>(particle);
157 EGS_Particle *p =
static_cast<EGS_Particle *
>(particle);
169 egsInformation(
"\n\nEnergy Initialized and Escaping\n%s\n", sep.c_str());
172 "\nTotal Energy Escaping Sources : %.5G MeV (%.3f%%)",
178 "\nTotal Energy Escaping Geometry: %.5G MeV (%.3f%%)\n",
206 EGS_Float total_energy_initialized_tmp;
207 EGS_Float energy_escaping_sources_tmp;
208 EGS_Float energy_escaping_geom_tmp;
210 data >> total_energy_initialized_tmp;
211 data >> energy_escaping_sources_tmp;
212 data >> energy_escaping_geom_tmp;
290 int getBin(EGS_Float E)
const;
293 return "EGS_Brachy: spectrum";
318 virtual void getResult(
int bin, EGS_Float &r, EGS_Float &dr);
335 egsInformation(
"Total quantity scored: %.3g\n",
total_scored);
417 void getResult(
int bin, EGS_Float &r, EGS_Float &dr);
420 return "EGS_Brachy: " +
getParticleName() +
" counts on surface of source";
428 return "counts / total counts / MeV\\S-1";
475 void getResult(
int bin, EGS_Float &r, EGS_Float &dr);
478 return "EGS_Brachy: energy weighted surface " +
getParticleName() +
" spectrum";
486 return "(dR/dE)/R / MeV\\S-1";
538 void getResult(
int bin, EGS_Float &r, EGS_Float &dr);
542 ss <<
"EGS_Brachy: " <<
getParticleName() <<
" fluence spectrum in region ";
548 return "fluence / MeV / cm\\S2";
565 "Energy fluence spectra may only be scored for photons. See:\n\t"
566 "https://github.com/nrc-cnrc/EGSnrc/issues/109/\n"
572 int err = input->getInput(
"geometry",gname);
574 egsWarning(
"FluenceSpectrumInVoxel: missing or invalid `geometry` input\n");
579 geometry = EGS_BaseGeometry::getGeometry(gname);
581 egsWarning(
"FluenceSpectrumInVoxel: unable to find geometry named `%s` \n", gname.c_str());
588 egsWarning(
"FluenceSpectrumInVoxel: no `scoring region` defined. Assuming region 0\n");
592 if (scoring_region < 0 || local_scoring_region >
geometry->regions()) {
593 egsWarning(
"FluenceSpectrumInVoxel: invalid region `scoring region` defined. Assuming region 0\n");
644 void getResult(
int bin, EGS_Float &r, EGS_Float &dr);
648 ss <<
"EGS_Brachy: " <<
getParticleName() <<
" energy fluence spectrum in region ";
654 return "fluence / MeV / cm\\S2";
671 "Energy fluence spectra may only be scored for photons. See:\n\t"
672 "https://github.com/nrc-cnrc/EGSnrc/issues/109/\n"
678 int err = input->getInput(
"geometry",gname);
680 egsWarning(
"EnergyFluenceSpectrumInVoxel: missing or invalid `geometry` input\n");
685 geometry = EGS_BaseGeometry::getGeometry(gname);
687 egsWarning(
"EnergyFluenceSpectrumInVoxel: unable to find geometry named `%s` \n", gname.c_str());
694 egsWarning(
"EnergyFluenceSpectrumInVoxel: no `scoring region` defined. Assuming region 0\n");
698 if (scoring_region < 0 || local_scoring_region >
geometry->regions()) {
699 egsWarning(
"EnergyFluenceSpectrumInVoxel: invalid region `scoring region` defined. Assuming region 0\n");
abstract base class for scoring spectrum information
virtual string getSubTitle() const
EGS_ScoringArray * bins
spectrum scoring array
int readData(istream *ifile)
string getParticleName() const
Return name of particle we are scoring.
EGS_Float getBinWidth() const
void setEffectiveHistories(EGS_Float effective_histories)
string outputCSV(string filename)
output results to csv file
int addState(istream &data)
int nbins
number of bins to score spectrum in
virtual void getResult(int bin, EGS_Float &r, EGS_Float &dr)
set r & dr to result/uncertainty for given bin. Normalization can be done in this routine
string outputXMGR(string filename)
output results to xmgrace file
static BaseSpectrumScorer * getSpectrumScorer(EGS_Input *inp, EGS_BaseSource *source, GeomInfo *ginfo, Publisher *publisher)
factory method for creating one of the derived spectrum scoring classes
virtual void score(EB_Message message, void *data=0)=0
virtual string getTitle() const
int getBin(EGS_Float E) const
get index of bin that that E falls in
virtual string getInfo() const
virtual void update(EB_Message message, void *data=0)
Receives messages from application. This method handles NEW_HISTORY messages but delegates all other ...
virtual void outputTotal()
int outputData(ostream *ofile)
string getFileName(string root) const
virtual ~BaseSpectrumScorer()
static const int DEFAULT_NBINS
virtual string getXAxisLabel() const
EGS_Float e_max
maximum spectrum energy to score
virtual string getYAxisLabel() const
virtual string getFileExtension() const
double getParticleEnergy(const EGS_Particle *p) const
string outputEGSnrc(string filename)
output results to EGSnrc tabulated spectrum format
EGS_Float e_min
minimum spectrum energy to score
int outputResults(string root_name)
, write the scored spectrum to file with filename. Returns 0 on success, all other values indicate a ...
A class for scoring the energy fluence of particles enter a voxel of the scoring phantom geometry.
string getYAxisLabel() const
EGS_BaseGeometry * geometry
string getFileExtension() const
EnergyFluenceSpectrumInVoxel(EGS_Input *input, EGS_BaseSource *src, GeomInfo *ginfo, Publisher *publisher)
virtual void score(EB_Message message, void *data=0)
void getResult(int bin, EGS_Float &r, EGS_Float &dr)
set r & dr to result/uncertainty for given bin. Normalization can be done in this routine
a class to use for scoring information about total energy initialzed, escaping sources etc
void scoreParticleEscapingGeom(EGS_Particle *p)
add energy from a escaping simulation geometry to the total
EGS_Float energyEscapingGeom()
returns the total energy of particles escaping simulation geometry
EGS_Float energyEscapingSources()
returns the total paticle energy escaping source geometry
EnergyScoringStats(Publisher *publisher)
EGS_Float escapingGeomRatio()
return the ratio of energy escaping the simulation geometry to total energy initialized
void scoreEnergyInitialized(EGS_Float E)
Needed for loading data from egsdat file.
EGS_Float getParticleEnergy(const EGS_Particle *p, bool subtractRM=true)
EGS_Float total_energy_initialized
total energy of particles initialized so far
void update(EB_Message message, void *particle)
delegate messages to appropriate scoring functions
void scoreParticleEscapingSource(EGS_Particle *p)
add energy from a particle escaping a source to the total
int readData(istream *ifile)
void scoreParticleInitialized(EGS_Particle *p)
add energy from initial particle to total
int outputData(ostream *ofile)
EGS_Float totalEnergyInitialized()
returns the total energy initialized
EGS_Float energy_escaping_geom
total energy of particles escaping the simulation geometry
EGS_Float energy_escaping_sources
total energy of particles escaping the source geometry note: doesn't currently exclude particles reen...
int addState(istream &data)
EGS_Float escapingSourcesRatio()
return the ratio of energy escaping the source to total energy initialized
void outputResults()
write results to console
A class for scoring the energy weighted spectrum (normalized to total radiant energy) of particles on...
string getYAxisLabel() const
EnergyWeightedSurfaceSpectrum(EGS_Input *input, EGS_BaseSource *src, GeomInfo *ginfo, Publisher *publisher)
void getResult(int bin, EGS_Float &r, EGS_Float &dr)
set r & dr to result/uncertainty for given bin. Normalization can be done in this routine
virtual void score(EB_Message message, void *data=0)
string getSubTitle() const
string getFileExtension() const
A class for scoring the fluence of particles enter a voxel of the scoring phantom geometry.
virtual void score(EB_Message message, void *data=0)
string getFileExtension() const
string getYAxisLabel() const
FluenceSpectrumInVoxel(EGS_Input *input, EGS_BaseSource *src, GeomInfo *ginfo, Publisher *publisher)
void getResult(int bin, EGS_Float &r, EGS_Float &dr)
set r & dr to result/uncertainty for given bin. Normalization can be done in this routine
EGS_BaseGeometry * geometry
a container for organizing meta data about the geometries
int localToGlobal(GeomRegT)
void subscribe(Subscriber *s, EB_Message message)
A class for scoring a histogram of the number of particles escaping a source geometry.
void getResult(int bin, EGS_Float &r, EGS_Float &dr)
set r & dr to result/uncertainty for given bin. Normalization can be done in this routine
SurfaceCountSpectrum(EGS_Input *input, EGS_BaseSource *src, GeomInfo *ginfo, Publisher *publisher)
string getFileExtension() const
string getYAxisLabel() const
virtual void score(EB_Message message, void *data=0)
string getSubTitle() const
ginfo contains classes for organizing information about the geometries present in an egs_brachy simul...
pair< EGS_BaseGeometry *, int > GeomRegT
pair of geometry and local region number
A simple pub/sub module to allow various egs_brachy classes to subscribe to particle events.
@ PARTICLE_ESCAPING_SOURCE