EGSnrc C++ class library
Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
|
A class for scoring a single quantity of interest in a Monte Carlo simulation. More...
#include <egs_scoring.h>
Public Member Functions | |
EGS_ScoringSingle () | |
Construct a scoring object initialized to zero. | |
void | score (unsigned short ncase, EGS_Float f) |
Add f to the score of the ncase'th statistically independent event. More... | |
void | finishCase (unsigned short new_case, EGS_Float new_result) |
Finish the current 'case' (event) and start a new event with index new_case and a score of new_result. | |
EGS_Float | currentScore () const |
Returns the score of the current event. | |
void | currentScore (EGS_Float &s, unsigned short &ncase) const |
Sets s to the score of the current event and ncase to the index of the current event. | |
void | currentScore (double &s, double &s2) |
Sets s to the sum of scores collected so far and s2 to the sum of scores squared. | |
void | currentResult (EGS_I64 ncase, double &r, double &dr) |
Sets r to the current result and dr to its statistical uncertainty assuming ncase statistically independent events. More... | |
bool | storeState (ostream &data) |
Stores the state of the scoring object into the data stream data. Returns true on success, false on failure. More... | |
bool | setState (istream &data) |
Set the state of the scoring object from the data stream data. More... | |
void | reset () |
Reset the scoring object to a pristine state (i.e. all counters set to zero). | |
EGS_ScoringSingle & | operator+= (const EGS_ScoringSingle &x) |
Combine the results of two scoring objects. More... | |
Protected Attributes | |
double | sum |
double | sum2 |
EGS_Float | tmp |
unsigned short | current_ncase |
A class for scoring a single quantity of interest in a Monte Carlo simulation.
This class implements most of the functionality needed for scoring a single quantity of interest in a Monte Carlo simulation, including a history-by-history statistical analysis. However, as this class is meant to be used by EGS_ScoringArray for collecting results of potentially a large number of quantities (e.g. a 3D dose distribution in a XYZ patient geometry), the history counter is represented with an unsigned 16 bit integer and therefore the maximum number of different histories is
Definition at line 63 of file egs_scoring.h.
void EGS_ScoringSingle::score | ( | unsigned short | ncase, |
EGS_Float | f | ||
) |
Add f to the score of the ncase'th statistically independent event.
If ncase is the same as the ncase passed in the last call to this function, then f is simply added to the score of the current event, otherwise a new statistically independent event is started.
Definition at line 78 of file egs_scoring.h.
void EGS_ScoringSingle::currentResult | ( | EGS_I64 | ncase, |
double & | r, | ||
double & | dr | ||
) |
Sets r to the current result and dr to its statistical uncertainty assuming ncase statistically independent events.
This function sets r to the ratio of the sum of scores collected so far and ncase and dr to the statistical uncertainty of r.
Definition at line 122 of file egs_scoring.h.
Referenced by EGS_ScoringArray::reportResults().
bool EGS_ScoringSingle::storeState | ( | ostream & | data | ) |
Stores the state of the scoring object into the data stream data. Returns true
on success, false on failure.
This function can be used for storing intermediate results into a data file for later recovery in e.g. restarted calculations. The data stored is the sum of scores, sum of scores squared and the 16 bit integer representing the last statistically independent event that contributed to the score.
Definition at line 144 of file egs_scoring.h.
bool EGS_ScoringSingle::setState | ( | istream & | data | ) |
Set the state of the scoring object from the data stream data.
The data extracted from the stream is the 16 bit integer representing the last statistically independent event that contributed to the score, the sum of scores and the sum of scores squared (both double precision).
Definition at line 161 of file egs_scoring.h.
EGS_ScoringSingle& EGS_ScoringSingle::operator+= | ( | const EGS_ScoringSingle & | x | ) |
Combine the results of two scoring objects.
This operator adds the results of the scoring object x to the results collected so far by the invoking object, assuming that x is statistically independent. This method is useful for combining parallel runs.
Definition at line 184 of file egs_scoring.h.
|
protected |
Sum of scores collected so far by the scoring object.
Definition at line 190 of file egs_scoring.h.
Referenced by operator+=().
|
protected |
Sum of scores squared collected so far by the scoring object.
Definition at line 198 of file egs_scoring.h.
Referenced by operator+=().
|
protected |
The score of the current event.
Definition at line 200 of file egs_scoring.h.
Referenced by operator+=().
|
protected |
The index of the current statistically independent event
Definition at line 202 of file egs_scoring.h.