EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs_radionuclide_source.h
Go to the documentation of this file.
1 /*
2 ###############################################################################
3 #
4 # EGSnrc egs++ radionuclide source headers
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: Reid Townson, 2016
25 #
26 # Contributors: Martin Martinov
27 #
28 ###############################################################################
29 */
30 
31 
37 #ifndef EGS_RADIONUCLIDE_SOURCE_
38 #define EGS_RADIONUCLIDE_SOURCE_
39 
40 #include "egs_vector.h"
41 #include "egs_base_source.h"
42 #include "egs_rndm.h"
43 #include "egs_shapes.h"
44 #include "egs_base_geometry.h"
45 #include "egs_math.h"
46 #include "egs_application.h"
47 #include "egs_spectra.cpp"
48 
49 #include <algorithm>
50 
51 
52 #ifdef WIN32
53 
54  #ifdef BUILD_RADIONUCLIDE_SOURCE_DLL
55  #define EGS_RADIONUCLIDE_SOURCE_EXPORT __declspec(dllexport)
56  #else
57  #define EGS_RADIONUCLIDE_SOURCE_EXPORT __declspec(dllimport)
58  #endif
59  #define EGS_RADIONUCLIDE_SOURCE_LOCAL
60 
61 #else
62 
63  #ifdef HAVE_VISIBILITY
64  #define EGS_RADIONUCLIDE_SOURCE_EXPORT __attribute__ ((visibility ("default")))
65  #define EGS_RADIONUCLIDE_SOURCE_LOCAL __attribute__ ((visibility ("hidden")))
66  #else
67  #define EGS_RADIONUCLIDE_SOURCE_EXPORT
68  #define EGS_RADIONUCLIDE_SOURCE_LOCAL
69  #endif
70 
71 #endif
72 
269 class EGS_RADIONUCLIDE_SOURCE_EXPORT EGS_RadionuclideSource :
270  public EGS_BaseSource {
271 
272 public:
273 
276 
279  if (baseSource)
280  if (!baseSource->deref()) {
281  delete baseSource;
282  }
283 
284  for (vector<EGS_RadionuclideSpectrum * >::iterator it =
285  decays.begin();
286  it!=decays.end(); it++) {
287  delete *it;
288  *it=0;
289  }
290  decays.clear();
291  };
292 
294  EGS_I64 getNextParticle(EGS_RandomGenerator *rndm,
295  int &q, int &latch, EGS_Float &E, EGS_Float &wt,
296  EGS_Vector &x, EGS_Vector &u);
297 
299  EGS_Float getEmax() const {
300  return Emax;
301  };
302 
304  EGS_Float getFluence() const {
305  return (ishower+1)*(baseSource->getFluence()/sCount);
306  };
307 
309  double getTime() const {
310  return time;
311  };
312 
319  double getExperimentTime() const {
320  return experimentTime;
321  };
322 
324  EGS_I64 getShowerIndex() const {
325  return ishower;
326  };
327 
328  unsigned int getEmissionType() const {
329  return emissionType;
330  }
331 
334  egsInformation("\n======================================================\n");
335  egsInformation("Start of source emissions statistics:\n");
336  for (unsigned int i=0; i<decays.size(); ++i) {
337  decays[i]->printSampledEmissions();
338  }
339  egsInformation("End of source emissions statistics\n");
340  egsInformation("======================================================\n\n");
341  };
342 
344  bool isValid() const {
345  return baseSource;
346  };
347 
353  bool storeState(ostream &data_out) const;
354 
361  bool addState(istream &data);
362 
369  void resetCounter();
370 
377  bool setState(istream &data);
378 
379 private:
380  EGS_Application *app;
381 
382  EGS_I64 count;
383  EGS_Float Emax;
384 
385  void setUp();
386 
387  string sName;
388  EGS_I64 sCount;
389  EGS_BaseSource *baseSource;
390 
391  vector<int> q_allowed;
392  vector<EGS_RadionuclideSpectrum *> decays;
393  EGS_Float activity;
394 
395  bool q_allowAll;
396  bool disintegrationOccurred;
397  EGS_Float time,
398  experimentTime,
399  lastDisintTime;
400  EGS_I64 ishower;
401  EGS_Vector xOfDisintegration;
402 
403  unsigned int emissionType;
404 };
405 
406 #endif
EGS_BaseSpectrum implementation and several concrete spectra.
EGS_BaseSource class header file.
EGS_Vector methods for the manipulation of 3D vectors in cartesian co-ordinates.
double getTime() const
Returns the emission time of the most recent particle.
A class representing 3D vectors.
Definition: egs_vector.h:56
virtual bool addState(istream &data_in)
Add data from the stream data_in to the source state.
void printSampledEmissions()
Outputs the emission stats of the spectra.
virtual void resetCounter()
Reset the source state.
virtual bool storeState(ostream &data_out) const
Store the source state into the stream data_out.
Base random number generator class. All random number generators should be derived from this class...
Definition: egs_rndm.h:67
double getExperimentTime() const
Get the total possible length of the experiment that is being modelled.
EGS_RandomGenerator class header file.
virtual bool setState(istream &data_in)
Set the source state based on data from the stream data_in.
EGS_Float getFluence() const
Returns the current fluence (number of disintegrations)
EGS_InfoFunction EGS_EXPORT egsInformation
Always use this function for reporting the progress of a simulation and any other type of information...
EGS_BaseShape and shape classes header file.
An object factory.
Attempts to fix broken math header files.
A radionuclide source.
EGS_I64 getShowerIndex() const
Returns the shower index of the most recent particle.
bool isValid() const
Checks the validity of the source.
A class for storing information in a tree-like structure of key-value pairs. This class is used throu...
Definition: egs_input.h:182
virtual EGS_I64 getNextParticle(EGS_RandomGenerator *rndm, int &q, int &latch, EGS_Float &E, EGS_Float &wt, EGS_Vector &x, EGS_Vector &u)=0
Sample the next source particle from the source probability distribution.
EGS_Float getEmax() const
Returns the maximum energy out of all the spectra.
EGS_BaseGeometry class header file.
EGS_Application class header file.
Base class for advanced EGSnrc C++ applications.
Base source class. All particle sources must be derived from this class.