78 inline void score(
unsigned short ncase, EGS_Float f) {
79 if (ncase == current_ncase) {
90 inline void finishCase(
unsigned short new_case, EGS_Float new_result) {
91 current_ncase = new_case;
106 ncase = current_ncase;
129 dr = sqrt(dr/(ncase-1));
147 data << current_ncase <<
" " << sum+tmp <<
" " << sum2+tmp *tmp
162 data >> current_ncase >> sum >> sum2;
185 sum += tmp + x.
sum + x.
tmp;
237 void setHistory(EGS_I64 ncase);
244 inline void score(
int ireg, EGS_Float f) {
245 result[ireg].score(current_ncase_short,f);
255 return result[ireg].currentScore();
262 result[ireg].currentScore(res,nc);
263 return nc == current_ncase_short ? res : 0;
272 result[ireg].currentScore(s,s2);
281 result[ireg].currentResult(current_ncase,r,dr);
302 void reportResults(
double norm,
const char *title,
bool relative_error,
303 const char *format = 0);
317 data << nreg <<
" " << current_ncase_short <<
"\n";
325 for (
int j=0; j<nreg; j++) {
326 if (!result[j].storeState(data)) {
342 data >> nreg1 >> current_ncase_short;
343 if (!data.good() || nreg1 < 1) {
349 if (!
egsGetI64(data,current_ncase_65536)) {
359 for (
int j=0; j<nreg; j++) {
360 if (!result[j].setState(data)) {
370 current_ncase_65536 = 0;
371 current_ncase_short = 0;
372 for (
int j=0; j<nreg; j++) {
385 current_ncase_65536 = current_ncase >> 16;
386 EGS_I64 aux = current_ncase - (current_ncase_65536 << 16);
387 current_ncase_short = (
unsigned short) aux;
388 for (
int j=0; j<nreg; j++) {
A class for scoring an array of quantities (e.g. a dose distribution) in a Monte Carlo simulation.
int bins() const
Returns the number of bins (or elements or regions, the most appropriate term depending on the way th...
EGS_I64 current_ncase_65536
EGS_Float thisHistoryScore(int ireg) const
Returns the score in ireg in the current event.
int regions() const
Returns the number of regions (or elements or bins, the most appropriate term depending on the way th...
void currentScore(int ireg, double &s, double &s2)
Sets s and s2 to the sum of scores and sum of scores squared in element ireg.
EGS_Float currentScore(int ireg) const
Returns the score in element ireg from the last statistically indepent event that contributed to ireg...
bool storeState(ostream &data)
Stores the state of the scoring array object into the data stream data.
void score(int ireg, EGS_Float f)
Add f to the score in the element ireg.
void currentResult(int ireg, double &r, double &dr)
Sets r to the result in region ireg and dr to its statistical uncertainty.
EGS_ScoringArray & operator+=(const EGS_ScoringArray &x)
Add the results of x to the rtesults of the invoking object.
void reset()
Reset the scoring array to a pristine state.
EGS_ScoringSingle * result
bool setState(istream &data)
Sets the state fof the scoring array object from the data in the input stream data.
unsigned short current_ncase_short
A class for scoring a single quantity of interest in a Monte Carlo simulation.
bool setState(istream &data)
Set the state of the scoring object from the data stream data.
unsigned short current_ncase
bool storeState(ostream &data)
Stores the state of the scoring object into the data stream data. Returns true on success,...
EGS_ScoringSingle()
Construct a scoring object initialized to zero.
void currentScore(double &s, double &s2)
Sets s to the sum of scores collected so far and s2 to the sum of scores squared.
EGS_Float currentScore() const
Returns the score of the current event.
void score(unsigned short ncase, EGS_Float f)
Add f to the score of the ncase'th statistically independent event.
EGS_ScoringSingle & operator+=(const EGS_ScoringSingle &x)
Combine the results of two scoring objects.
void reset()
Reset the scoring object to a pristine state (i.e. all counters set to zero).
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 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...
void currentResult(EGS_I64 ncase, double &r, double &dr)
Sets r to the current result and dr to its statistical uncertainty assuming ncase statistically indep...
Global egspp functions header file.
Defines the EGS_EXPORT and EGS_LOCAL macros.
#define EGS_EXPORT
Export symbols from the egspp library.
Attempts to fix broken math header files.
bool EGS_EXPORT egsStoreI64(ostream &data, EGS_I64 n)
Writes the 64 bit integer n to the output stream data and returns true on success,...
bool EGS_EXPORT egsGetI64(istream &data, EGS_I64 &n)
Reads a 64 bit integer from the stream data and assigns it to n. Returns true on success,...