EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs_point_source.cpp
Go to the documentation of this file.
1 /*
2 ###############################################################################
3 #
4 # EGSnrc egs++ point source
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: Iwan Kawrakow, 2005
25 #
26 # Contributors:
27 #
28 ###############################################################################
29 */
30 
31 
37 #include "egs_point_source.h"
38 #include "egs_input.h"
39 
41  EGS_BaseSimpleSource(input,f), xo(), valid(true) {
42  vector<EGS_Float> pos;
43  int err = input->getInput("position",pos);
44  if (!err && pos.size() == 3) {
45  xo = EGS_Vector(pos[0],pos[1],pos[2]);
46  }
47  else {
48  egsWarning("EGS_PointSource: missing/wrong 'position' input\n");
49  valid = false;
50  }
51  setUp();
52 }
53 
55  otype = "EGS_PointSource";
56  if (!isValid()) {
57  description = "Invalid point source";
58  }
59  else {
60  description = "Point source with ";
61  description += s->getType();
62  if (q == -1) {
63  description += ", electrons";
64  }
65  else if (q == 0) {
66  description += ", photons";
67  }
68  else if (q == 1) {
69  description += ", positrons";
70  }
71  else {
72  description += ", unknown particle type";
73  }
74  }
75 }
76 
77 
78 extern "C" {
79 
80  EGS_POINT_SOURCE_EXPORT EGS_BaseSource *createSource(EGS_Input *input,
81  EGS_ObjectFactory *f) {
82  return createSourceTemplate<EGS_PointSource>(input,f,"point source");
83  }
84 
85 }
EGS_PointSource(int Q, EGS_BaseSpectrum *Spec, const EGS_Vector &Xo, const string &Name="", EGS_ObjectFactory *f=0)
Constructor.
EGS_Input class header file.
A class representing 3D vectors.
Definition: egs_vector.h:56
EGS_BaseSpectrum * s
The energy spectrum of this source.
void setUp()
Sets up the source type and description.
An object factory.
A point source.
int q
The charge of this simple source.
const string & getType() const
Get the spectrum type.
A class for storing information in a tree-like structure of key-value pairs. This class is used throu...
Definition: egs_input.h:182
string otype
The object type.
Base class for &#39;simple&#39; particle sources.
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 source class. All particle sources must be derived from this class.
string description
A short source description.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.