EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs_angular_spread_source.cpp
Go to the documentation of this file.
1 /*
2 ###############################################################################
3 #
4 # EGSnrc egs++ angular spread 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, 2009
25 #
26 # Contributors:
27 #
28 ###############################################################################
29 */
30 
31 
38 #include "egs_input.h"
39 #include "egs_math.h"
40 
41 EGS_AngularSpreadSource::EGS_AngularSpreadSource(EGS_Input *input,
42  EGS_ObjectFactory *f) : EGS_BaseSource(input,f), source(0), sigma(0) {
43  EGS_Input *isource = input->takeInputItem("source",false);
44  if (isource) {
45  source = EGS_BaseSource::createSource(isource);
46  delete isource;
47  }
48  if (!source) {
49  string sname;
50  int err = input->getInput("source name",sname);
51  if (err)
52  egsWarning("EGS_AngularSpreadSource: missing/wrong inline source "
53  "definition and missing wrong 'source name' input\n");
54  else {
55  source = EGS_BaseSource::getSource(sname);
56  if (!source) egsWarning("EGS_AngularSpreadSource: a source named %s"
57  " does not exist\n");
58  }
59  }
60  int err = input->getInput("sigma",sigma);
61  if (!err) {
62  if (sigma < 0) {
63  sigma = -0.4246609001440095285*sigma;
64  }
65  sigma *= M_PI/180;
66  sigma *= sigma;
67  }
68  setUp();
69 }
70 
71 void EGS_AngularSpreadSource::setUp() {
72  otype = "EGS_AngularSpreadSource";
73  if (!isValid()) {
74  description = "Invalid angular spread source";
75  return;
76  }
77  description = "Angular spread added to a ";
79  source->ref();
80 }
81 
82 extern "C" {
83 
84  EGS_ANGULAR_SPREAD_SOURCE_EXPORT EGS_BaseSource *createSource(EGS_Input *input,
85  EGS_ObjectFactory *f) {
86  return
87  createSourceTemplate<EGS_AngularSpreadSource>(input,f,"angular spread source");
88  }
89 
90 }
static EGS_BaseSource * createSource(EGS_Input *)
Create sources from the information pointed to by input.
EGS_Input class header file.
const char * getSourceDescription() const
Get a short description of this source.
An angular spread source: header.
int ref()
Increase the reference count to this object.
An object factory.
static EGS_BaseSource * getSource(const string &Name)
Get a pointer to the source named Name.
Attempts to fix broken math header files.
EGS_BaseSource * source
The source being transformed.
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.
EGS_Input * takeInputItem(const string &key, bool self=true)
Get the property named key.
Definition: egs_input.cpp:226
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.