EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs_dose_scoring.cpp
Go to the documentation of this file.
1 /*
2 ###############################################################################
3 #
4 # EGSnrc egs++ dose scoring object
5 # Copyright (C) 2015 National Research Council Canada
6 #
7 # This file is part of EGSnrc.
8 #
9 # EGSnrc is free software: you can redistribute it and/or modify it under
10 # the terms of the GNU Affero General Public License as published by the
11 # Free Software Foundation, either version 3 of the License, or (at your
12 # option) any later version.
13 #
14 # EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
17 # more details.
18 #
19 # You should have received a copy of the GNU Affero General Public License
20 # along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
21 #
22 ###############################################################################
23 #
24 # Author: Ernesto Mainegra-Hing, 2012
25 #
26 # Contributors: Frederic Tessier
27 # Reid Townson
28 # Hubert Ho
29 # Blake Walters
30 #
31 ###############################################################################
32 #
33 # A general dose calculation tool. Since it is outside the scope of the
34 # EGS_Application class, a few utility methods are needed in EGS_Application
35 # to retrieve information regarding media, geometry and source.
36 #
37 # Dose is output for each dose region without any spacial information. For a
38 # more detailed dose scoring grid it is better to create a user code which
39 # could produce 3D dose distributions and graph data.
40 #
41 # Can be used in any C++ user code by entering the proper input block in
42 # the ausgab object definition block.
43 #
44 # Prints out dose in each dose scoring region.
45 #
46 # Dose scoring regions can be defined by input using one the following
47 # syntax for individual regions:
48 #
49 # :start ausgab object definition:
50 # :start ausgab object:
51 # library = egs_dose_scoring
52 # name = some_name
53 # volume = V0 V1 ... Vn
54 # dose regions = IR0 IR1 ... IRn
55 # :stop ausgab object:
56 # :stop ausgab object definition:
57 #
58 # or by groups of consecutive regions:
59 #
60 # :start ausgab object definition:
61 # :start ausgab object:
62 # library = egs_dose_scoring
63 # name = some_name
64 # volume = V0 V1 ... Vn
65 # dose start region = IRI_0 ... IRI_N
66 # dose stop region = IRE_0 ... IRE_N
67 # :stop ausgab object:
68 # :stop ausgab object definition:
69 #
70 # where one can have same number of volume entries as group of regions (n=N)
71 # or same number of volume entries as number of individual regions. If there
72 # are more dose scoring regions than volume entries, a default volume is use for
73 # those regions without volume information. This default can be either the first
74 # volume entry or 1 g/cm3.
75 #
76 # TODO:
77 #
78 # - Classify dose as contributed by primary or scattered particles
79 # - Custom classification using latch
80 # - Dose to medium calculation
81 #
82 ###############################################################################
83 */
84 
85 
91 #include <fstream>
92 #include <string>
93 #include <cstdlib>
94 
95 #include "egs_dose_scoring.h"
96 #include "egs_input.h"
97 #include "egs_functions.h"
98 
99 EGS_DoseScoring::EGS_DoseScoring(const string &Name,
100  EGS_ObjectFactory *f) :
101  EGS_AusgabObject(Name,f), dose(0), doseM(0), doseF(0),
102  norm_u(1.0), nreg(0), nmedia(0), max_dreg(-1), max_medl(0),
103  m_lastCase(-1),score_medium_dose(false), score_region_dose(false), output_dose_file(false) {
104  otype = "EGS_DoseScoring";
105 }
106 
107 EGS_DoseScoring::~EGS_DoseScoring() {
108  if (dose) {
109  delete dose;
110  }
111  if (doseM) {
112  delete doseM;
113  }
114  if (doseF) {
115  delete doseF;
116  }
117 }
118 
119 void EGS_DoseScoring::setApplication(EGS_Application *App) {
121  if (!app) {
122  return;
123  }
124 
125  if (d_regionString.length() > 0 && d_region.size() < 1) {
126  getNumberRegions(d_regionString, d_region);
127  getLabelRegions(d_regionString, d_region);
128  }
129 
130  // Get the number of regions in the geometry.
131  nreg = app->getnRegions();
132  // Get the number of media in the input file
133  nmedia = app->getnMedia();
134  // determine maximum medium name length
135  char buf[64];
136  int count = 0;
137  int imed=0;
138  max_medl = 6; // length of the string "medium" is the minimum
139  for (imed=0; imed < nmedia; imed++) {
140  sprintf(buf,"%s%n",app->getMediumName(imed),&count);
141  if (count > max_medl) {
142  max_medl = count;
143  }
144  }
145  if (d_region.size()>nreg)
146  egsWarning("\n*********************************************"
147  "\n WARNING:"
148  "\nRequesting %d dose scoring regions, but there"
149  "\nare only %d geometrical regions!"
150  "\nscoring will be done in all regions!"
151  "\n*********************************************",
152  d_region.size(),nreg);
153  // Flag dose scoring regions in geometry
154  // and set their volume.
155  if (score_region_dose) {
156  if (d_region.size() && d_region.size() < nreg) { // specific dose regions provided
157  // Get maximum dose scoring region
158  for (vector<int>::iterator it = d_region.begin(); it < d_region.end(); it++) {
159  if (*it > max_dreg) {
160  max_dreg = *it;
161  }
162  }
163  for (int j=0; j<nreg; j++) {
164  d_reg_index.push_back(-1);
165  vol.push_back(vol_list[0]);// set to either 1.0 or first volume entered
166  }
167  for (int i=0; i<d_region.size(); i++) {
168  d_reg_index[d_region[i]]=i;
169  if (i < vol_list.size()) {
170  vol[d_region[i]] = vol_list[i];
171  }
172  }
173  if (score_region_dose) {
174  dose = new EGS_ScoringArray(d_region.size());
175  }
176  }
177  else { // scoring in all regions
178  max_dreg = nreg-1;
179  for (int j=0; j<nreg; j++) {
180  d_reg_index.push_back(j);
181  if (j < vol_list.size()) {
182  vol.push_back(vol_list[j]);
183  }
184  else { // more regions than volumes, use default 1 g/cm3 or first volume entered
185  vol.push_back(vol_list[0]);
186  }
187  }
188  if (score_region_dose) {
189  dose = new EGS_ScoringArray(nreg);
190  }
191  }
192  }
193  // If requested request memory for medium dose
194  if (score_medium_dose) {
195  doseM = new EGS_ScoringArray(nmedia);
196  }
197  if (!score_region_dose) { // setup volumes
198  if (vol_list.size() == 1) {
199  vol.push_back(vol_list[0]);
200  }
201  else {
202  for (int j=0; j<nreg; j++) {
203  if (j < vol_list.size()) {
204  vol.push_back(vol_list[j]);
205  }
206  else { // more regions than volumes, use default 1 g/cm3 or first volume entered
207  vol.push_back(vol_list[0]);
208  }
209  }
210  }
211  }
212 
213  if (output_dose_file) {
214  //set df_reg to default (non-scoring) values
215  for (int i=0; i<nreg; i++) {
216  df_reg.push_back(-1);
217  }
218  //determine the region no. in the EGS_XYZGeometry and corresponding
219  //global reg. no.
220  EGS_Vector tp;
221  int nx=dose_geom->getNRegDir(0);
222  int ny=dose_geom->getNRegDir(1);
223  int nz=dose_geom->getNRegDir(2);
224  EGS_Float minx,maxx,miny,maxy,minz,maxz;
225  for (int k=0; k<nz; k++) {
226  for (int j=0; j<ny; j++) {
227  for (int i=0; i<nx; i++) {
228  minx=dose_geom->getBound(0,i);
229  maxx=dose_geom->getBound(0,i+1);
230  miny=dose_geom->getBound(1,j);
231  maxy=dose_geom->getBound(1,j+1);
232  minz=dose_geom->getBound(2,k);
233  maxz=dose_geom->getBound(2,k+1);
234  tp.x=(minx+maxx)/2.;
235  tp.y=(miny+maxy)/2.;
236  tp.z=(minz+maxz)/2.;
237  int g_reg = app->isWhere(tp);
238  df_reg[g_reg]=i+j*nx+k*nx*ny;
239  }
240  }
241  }
242  //create an egs_scoring_array of the appropriate size
243  doseF = new EGS_ScoringArray(nx*ny*nz);
244  }
245 
246  description = "\n*******************************************\n";
247  description += "Dose Scoring Object (";
248  description += name;
249  description += ")\n";
250  description += "*******************************************\n";
251  if (dose) {
252  description +="\n - Regions in dose calculator :";
253  sprintf(buf,"%d\n\n",dose->regions());
254  description += buf;
255  }
256  if (doseM) {
257  description += " - Medium dose will be calculated\n";
258  }
259  description += "\n--------------------------------------\n";
260  sprintf(buf,"%*s rho (g/cm^3)\n",max_medl,"medium");
261  description += buf;
262  description += "--------------------------------------\n";
263  for (imed=0; imed < nmedia; imed++) {
264  description += buf;
265  description += " ";
266  sprintf(buf,"%11.8f",app->getMediumRho(imed));
267  description += buf;
268  description += "\n";
269  }
270  description += "--------------------------------------\n";
271  if (norm_u != 1.0) {
272  description += " Non-unity user-requested normalization = ";
273  sprintf(buf,"%g\n",norm_u);
274  description += buf;
275  }
276  description += "\n*******************************************\n\n";
277  vol_list.clear();
278  if (d_region.size()) {
279  d_region.clear();
280  }
281  if (doseF) {
282  description += "\n Will output dose to file:\n";
283  description += " EGS_XYZGeometry: " + dose_geom->getName();
284  description += "\n file format: ";
285  if (file_type==0) {
286  //only type supported so far
287  description += " 3ddose";
288  }
289  description += "\n file name: ";
290  if (file_type==0) {
291  df_name=getObjectName() + ".3ddose";
292  df_name=egsJoinPath(app->getAppDir(),df_name);
293  }
294  description += df_name;
295  }
296 }
297 
298 void EGS_DoseScoring::getNumberRegions(const string &str, vector<int> &regs) {
299  app->getNumberRegions(str, regs);
300 }
301 
302 void EGS_DoseScoring::getLabelRegions(const string &str, vector<int> &regs) {
303  app->getLabelRegions(str, regs);
304 }
305 
306 void EGS_DoseScoring::reportResults() {
307  egsInformation("\n======================================================\n");
308  egsInformation("Dose Scoring Object(%s)\n",name.c_str());
309  egsInformation("======================================================\n");
310  EGS_Float normD = 1., normE=1.;
311  int count = 0;
312  EGS_Float F = app->getFluence();
313  egsInformation("=> last case = %lld fluence = %g\n", m_lastCase, F);
314  /* Normalize to actual source fluence */
315  normE = m_lastCase/F*norm_u;
316  normD = 1.602e-10*normE;
317  int irmax_digits = getDigits(max_dreg);
318  if (irmax_digits < 2) {
319  irmax_digits = 2;
320  }
321  string line;
322  double r,dr;
323  if (dose) {
324  if (normE==1) {
325  egsInformation("\n\n==> Summary of region dosimetry (per particle)\n\n");
327  "%*s %*s %12s %12s Edep (MeV) D (Gy) %n\n",
328  irmax_digits,"ir",max_medl,"medium","rho (g/cm^3)","Volume (cm^3)",&count);
329  }
330  else {
331  egsInformation("\n==> Summary of region dosimetry (per fluence)\n");
333  "%*s %*s %12s %12s Edep (MeV*cm^2) D (Gy*cm^2) %n\n",
334  irmax_digits,"ir",max_medl,"medium","rho (g/cm^3)","Volume (cm^3)",&count);
335  }
336  line.append(count,'-');
337  egsInformation("%s\n",line.c_str());
338 
339  /* Compute deposited energy and dose */
340  for (int ireg = 0; ireg < nreg; ireg++) {
341  if (d_reg_index[ireg]>=0) {
342  if (!(app->isRealRegion(ireg))) {
343  continue;
344  }
345  int imed = app->getMedium(ireg);
346  EGS_Float rho = app->getMediumRho(imed);
347  EGS_Float mass = vol[ireg]*rho;
348  dose->currentResult(d_reg_index[ireg],r,dr);
349  if (r > 0) {
350  dr = dr/r;
351  }
352  else {
353  dr=1;
354  }
355  egsInformation("%*d %-*s %11.8f %13.6f %12.4e +/- %-7.3f%% %10.4e +/- %-7.3f%%\n",
356  irmax_digits,ireg,max_medl,app->getMediumName(imed),rho,vol[ireg],r*normE,dr*100.,r*normD/mass,dr*100.);
357  }
358  }
359  egsInformation("%s\n",line.c_str());
360  }
361  if (doseM) {
362  vector<EGS_Float> massM(nmedia,0);
363  int imed = 0;
364  for (int ir=0; ir<nreg; ir++) {
365  if (app->isRealRegion(ir)) {
366  imed = app->getMedium(ir);
367  // skip vacuum regions
368  if (imed == -1) {
369  continue;
370  }
371  EGS_Float volume = vol.size() > 1 ? vol[ir]:vol[0];
372  massM[imed] += app->getMediumRho(imed)*volume;
373  }
374  }
375  if (normE==1) {
376  egsInformation("\n\n==> Summary of media dosimetry (per particle)\n");
378  "%*s %*s Edep/[MeV] D/[Gy] %n\n",
379  max_medl/2,"medium",max_medl/2," ",&count);
380  }
381  else {
382  egsInformation("\n\n==> Summary of media dosimetry (per fluence)\n");
384  "%*s %*s Edep/[MeV*cm2] D/[Gy*cm2] %n\n",
385  max_medl/2,"medium",max_medl/2," ",&count);
386  }
387  line="";
388  line.append(count,'-');
389  egsInformation("%s\n",line.c_str());
390  /* Compute deposited energy in medium (MeV)*/
391  for (int im=0; im<nmedia; im++) {
392  doseM->currentResult(im,r,dr);
393  if (r > 0) {
394  dr = dr/r;
396  "%-*s %10.4e +/- %-7.3f%% %10.4e +/- %-7.3f%%\n",
397  max_medl,app->getMediumName(im),r*normE,dr*100.,r*normD/massM[im],dr*100.);
398  }
399  }
400  egsInformation("%s\n",line.c_str());
401  }
402  if (doseF) {
403  if (app->getIparallel()>0) {
404  egsInformation("\n EGS_DoseScoring: This is one of a number of parallel jobs. Will only output dose file on combining results.\n");
405  }
406  else {
407  outputDoseFile(normD);
408  }
409  }
410  egsInformation("\n======================================================\n");
411 }
412 
413 void EGS_DoseScoring::outputDoseFile(const EGS_Float &normD) {
414  double r,dr;
415  ofstream df_out;
416  egsInformation("\n EGS_DoseScoring: Writing dose data for EGS_XYZGeometry %s... \n",dose_geom->getName().c_str());
417  egsInformation(" Output file name: %s\n",df_name.c_str());
418  //idea is to add new file_types as they become available
419  if (file_type==0) {
420  //open file
421  df_out.open(df_name.c_str());
422  if (!df_out) {
423  egsFatal("\n EGS_DoseScoring: Error: Failed to open file %s\n",df_name.c_str());
424  exit(1);
425  }
426  //output data
427  int nx=dose_geom->getNRegDir(0);
428  int ny=dose_geom->getNRegDir(1);
429  int nz=dose_geom->getNRegDir(2);
430  //output no. of voxels in x,y,z
431  df_out << nx << " " << ny << " " << nz << "\n";
432  //use single precision real for output
433  float bound, dose, doseun;
434  //output voxel boundaries
435  for (int i=0; i<=nx; i++) {
436  bound=dose_geom->getBound(0,i);
437  df_out << bound << " ";
438  }
439  df_out << "\n";
440  for (int j=0; j<=ny; j++) {
441  bound=dose_geom->getBound(1,j);
442  df_out << bound << " ";
443  }
444  df_out << "\n";
445  for (int k=0; k<=nz; k++) {
446  bound=dose_geom->getBound(2,k);
447  df_out << bound << " ";
448  }
449  df_out << "\n";
450  //divide dose by mass and output
451  for (int i=0; i<nx*ny*nz; i++) {
452  doseF->currentResult(i,r,dr);
453  EGS_Float mass = dose_geom->getVolume(i)*getRealRho(i); //local reg.
454  dose=r*normD/mass;
455  df_out << dose << " ";
456  }
457  df_out << "\n";
458  //output uncertainties
459  for (int i=0; i<nx*ny*nz; i++) {
460  doseF->currentResult(i,r,dr);
461  if (r > 0) {
462  dr = dr/r;
463  }
464  else {
465  dr=1;
466  }
467  doseun=dr;
468  df_out << doseun << " ";
469  }
470  df_out << "\n";
471  df_out.close();
472  }
473  else {
474  egsFatal("\n EGS_DoseScoring: Warning: Dose output file type not recognized.\n");
475  }
476 }
477 
478 bool EGS_DoseScoring::storeState(ostream &data) const {
479  //egsInformation("Storing EGS_DoseScoring...\n");
480  if (!egsStoreI64(data,m_lastCase)) {
481  return false;
482  }
483  data << endl;
484  if (dose && !dose->storeState(data)) {
485  return false;
486  }
487  if (doseM && !doseM->storeState(data)) {
488  return false;
489  }
490  if (doseF && !doseF->storeState(data)) {
491  return false;
492  }
493  return true;
494 }
495 
496 bool EGS_DoseScoring::setState(istream &data) {
497  if (!egsGetI64(data,m_lastCase)) {
498  return false;
499  }
500  if (dose && !dose->setState(data)) {
501  return false;
502  }
503  if (doseM && !doseM->setState(data)) {
504  return false;
505  }
506  if (doseF && !doseF->setState(data)) {
507  return false;
508  }
509  return true;
510 }
511 
512 bool EGS_DoseScoring::addState(istream &data) {
513  int err = addTheStates(data);
514  if (err) {
515  egsInformation("Error code: %d",err);
516  return false;
517  }
518  return true;
519 }
520 int EGS_DoseScoring::addTheStates(istream &data) {
521  EGS_I64 tmp_case;
522  if (!egsGetI64(data,tmp_case)) {
523  return 4401;
524  }
525  m_lastCase += tmp_case;
526  if (dose) {
527  EGS_ScoringArray tmp(nreg);
528  if (!tmp.setState(data)) {
529  return 4402;
530  }
531  (*dose) += tmp;
532  }
533  if (doseM) {
534  EGS_ScoringArray tmpM(nmedia);
535  if (!tmpM.setState(data)) {
536  return 4403;
537  }
538  (*doseM) += tmpM;
539  }
540  if (doseF) {
541  int nx=dose_geom->getNRegDir(0);
542  int ny=dose_geom->getNRegDir(1);
543  int nz=dose_geom->getNRegDir(2);
544  EGS_ScoringArray tmpF(nx*ny*nz);
545  if (!tmpF.setState(data)) {
546  return 4404;
547  }
548  (*doseF) += tmpF;
549  }
550  return 0;
551 }
552 
553 void EGS_DoseScoring::resetCounter() {
554  m_lastCase = 0;
555  if (dose) {
556  dose->reset();
557  }
558  if (doseM) {
559  doseM->reset();
560  }
561  if (doseF) {
562  doseF->reset();
563  }
564 }
565 
566 //*********************************************************************
567 // Process input for this ausgab object
568 //
569 // volume: Set to 1 cm3 by default
570 // One entry => same size dose scoring regions
571 // Several entries => volume for each dose region
572 // SAME as dose region number
573 // or else default value used
574 //
575 // dose scoring regions: Defaults to all regions in geometry
576 // dose regions => Individual regions
577 // dose start/stop region => Groups of consecutive
578 // dose regions
579 //
580 // If there is a mismatch between number of regions and volumes
581 // default volume values will be used. Default volume will be either
582 // the first volume entry or 1 g/cm3 if no volume entry found.
583 //
584 // TODO:
585 // - Classify in primary, scattered and total dose
586 // - Specify for wich media to score or not the dose
587 //
588 //**********************************************************************
589 extern "C" {
590 
591  EGS_DOSE_SCORING_EXPORT EGS_AusgabObject *createAusgabObject(EGS_Input *input,
592  EGS_ObjectFactory *f) {
593  const static char *func = "createAusgabObject(dose_scoring)";
594  if (!input) {
595  egsWarning("%s: null input?\n",func);
596  return 0;
597  }
598  vector <EGS_Float> v_in;// voxel volume[s] in g/cm3
599  /* get voxel volume */
600  input->getInput("volume",v_in);
601  /* get dose scoring mode: region dose, medium dose or both */
602  vector<string> allowed_mode;
603  allowed_mode.push_back("no");
604  allowed_mode.push_back("yes");
605  int d_in_medium = input->getInput("medium dose",allowed_mode,0);
606  int d_in_region = input->getInput("region dose",allowed_mode,1);
607 
608  /* get dose regions */
609  string d_regionsString;
610  vector <int> d_regions;
611  bool using_all_regions=true;
612  vector <int> d_start, d_stop;
613  if (!input->getInput("dose regions",d_regionsString)&& d_regionsString.length()>0) {
614  using_all_regions = false; // individual regions
615  }
616  else {
617  int err1 = input->getInput("dose start region",d_start);
618  int err2 = input->getInput("dose stop region",d_stop);
619  if (!err1 && !err2) {
620  if (d_start.size()==d_stop.size()) { // group of dose regions
621  for (int i=0; i<d_start.size(); i++) {
622  int ir = d_start[i], fr = d_stop[i];
623  for (int ireg=ir; ireg<=fr; ireg++) {
624  d_regions.push_back(ireg);
625  }
626  }
627  using_all_regions = false;
628  }
629  else egsWarning(
630  "%s: Mismatch in start and stop dose region groups !!!\n"
631  " Calculating dose in ALL regions.\n",func);
632  }
633  }
634  EGS_Float norma = 1.0;
635  int err04 = input->getInput("normalization",norma);
636 
637  //================================================
638  // Check if one volume for each group requested.
639  // If not just pass the volumes read and if there
640  // is a mismatch, then the first volume element
641  // or 1g/cm3 will be used.
642  //=================================================
643  vector <EGS_Float> volin;
644  // groups of regions with same volume
645  if (! using_all_regions && v_in.size()== d_start.size()) {
646  for (int i=0; i<d_start.size(); i++) {
647  int ir = d_start[i], fr = d_stop[i];
648  for (int ireg=ir; ireg<=fr; ireg++) {
649  volin.push_back(v_in[i]);
650  }
651  }
652  }
653  else { // all other possibilities handled here
654  volin = v_in;
655  }
656 
657  //see if the user wants to output the dose to a file for an EGS_XYZGeometry
658  bool outputdosefile=false;
659  EGS_Input *fileinp = input->takeInputItem("output dose file");
660  EGS_BaseGeometry *dgeom;
661  int ftype;
662  if (fileinp) {
663  //get geometry name and filename and do some checks
664  string gname;
665  int err05 = fileinp->getInput("geometry name",gname);
666  if (err05) {
667  egsFatal("EGS_DoseScoring: Output dose file: missing/incorrect input for name of geometry.\n");
668  }
669  else {
670  dgeom = EGS_BaseGeometry::getGeometry(gname);
671  if (!dgeom) {
672  egsFatal("EGS_DoseScoring: Output dose file: %s does not name an existing geometry\n",gname.c_str());
673  }
674  else if (dgeom->getType()!="EGS_XYZGeometry") {
675  egsFatal("EGS_DoseScoring: Output dose file: %s is not an EGS_XYZGeometry.\n",gname.c_str());
676  }
677  else {
678  string str;
679  if (fileinp->getInput("file type", str) < 0) {
680  ftype = 0;
681  }
682  else {
683  vector<string> allowed_ftype;
684  allowed_ftype.push_back("3ddose");
685  ftype = fileinp->getInput("file type", allowed_ftype, -1);
686  if (ftype < 0) {
687  egsFatal("EGS_DoseScoring: Output dose file: Invalid file type. Currently only 3ddose is supported.\n");
688  }
689  }
690  outputdosefile=true;
691  }
692  }
693  }
694 
695 
696  //=================================================
697 
698  /* Setup dose scoring object with input parameters */
699  EGS_DoseScoring *result = new EGS_DoseScoring("",f);
700  if (volin.size()==1) {
701  result->setVol(volin[0]); // one size for all regions
702  }
703  else if (volin.size()) {
704  result->setVol(volin); // regions with their volumes
705  }
706  else {
707  result->setVol(1.0); // default value if no entry
708  }
709  if (!using_all_regions) {
710  if (d_regions.size() > 0) {
711  result->setDoseRegions(d_regions);
712  }
713  else {
714  result->setDoseRegions(d_regionsString);
715  }
716  }
717  if (d_in_medium) {
718  result->setMediumScoring(true);
719  }
720  if (d_in_region) {
721  result->setRegionScoring(true);
722  }
723  if (outputdosefile) {
724  result->setOutputFile(true,dgeom,ftype);
725  }
726  result->setName(input);
727  if (!err04) {
728  result->setUserNorm(norma);
729  }
730  return result;
731  }
732 }
virtual const string & getType() const =0
Get the geometry type.
A class for scoring an array of quantities (e.g. a dose distribution) in a Monte Carlo simulation...
Definition: egs_scoring.h:219
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, false on failure.
int regions() const
Returns the number of regions (or elements or bins, the most appropriate term depending on the way th...
Definition: egs_scoring.h:406
EGS_ScoringArray * doseM
Scoring dose in each medium.
virtual int getNRegDir(int idir)
string description
A short ausgab object description.
void getNumberRegions(const string &str, vector< int > &regs)
Gets numbers out of str and pushes them onto regs.
void getLabelRegions(const string &str, vector< int > &regs)
Gets the regions for the labels in str and pushes onto regs.
const string & getObjectName() const
Get the object name.
A dose scoring object: header.
EGS_I64 m_lastCase
The event set via setCurrentCase()
A dose scoring ausgab object.
EGS_Input class header file.
EGS_Float y
y-component
Definition: egs_vector.h:61
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, false on failure.
A class representing 3D vectors.
Definition: egs_vector.h:56
string egsJoinPath(const string &first, const string &second)
Join two path variables (or a path and a file name) using the platform specific directory separator a...
virtual EGS_Float getVolume(int ireg)
Calculates the volume of region ireg.
int getIparallel() const
Returns the job number in a parallel run.
Global egspp functions header file.
bool setState(istream &data)
Sets the state fof the scoring array object from the data in the input stream data.
Definition: egs_scoring.h:340
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
virtual EGS_Float getBound(int idir, int ind)
Returns region boundaries in direction determined by idir.
bool storeState(ostream &data)
Stores the state of the scoring array object into the data stream data.
Definition: egs_scoring.h:316
bool isRealRegion(int ireg)
Returns true if ireg is a real region, false otherwise.
EGS_Float z
z-component
Definition: egs_vector.h:62
static EGS_BaseGeometry * getGeometry(const string &Name)
Get a pointer to the geometry named Name.
EGS_ScoringArray * dose
Scoring in each dose scoring region.
EGS_InfoFunction EGS_EXPORT egsFatal
Always use this function for reporting fatal errors.
EGS_ScoringArray * doseF
Scoring dose in each voxel in EGS_XYZGeometry.
EGS_InfoFunction EGS_EXPORT egsInformation
Always use this function for reporting the progress of a simulation and any other type of information...
An object factory.
void reset()
Reset the scoring array to a pristine state.
Definition: egs_scoring.h:368
void currentResult(int ireg, double &r, double &dr)
Sets r to the result in region ireg and dr to its statistical uncertainty.
Definition: egs_scoring.h:280
int getMedium(int ireg)
Returns the medium index in region ireg using C-style indexing.
void setName(EGS_Input *inp)
Set the name of the object from the information provided by inp.
EGS_Float x
x-component
Definition: egs_vector.h:60
string name
The object name.
A class for storing information in a tree-like structure of key-value pairs. This class is used throu...
Definition: egs_input.h:182
const string & getName() const
Get the name of this geometry.
const string & getAppDir() const
Returns the absolute path to the user code directory.
string otype
The object type.
EGS_Input * takeInputItem(const string &key, bool self=true)
Get the property named key.
Definition: egs_input.cpp:226
virtual void setApplication(EGS_Application *App)
Set the application this object belongs to.
int getInput(const string &key, vector< string > &values) const
Assign values to an array of strings from an input identified by key.
Definition: egs_input.cpp:338
Base class for advanced EGSnrc C++ applications.
EGS_Application * app
The application this object belongs to.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.