EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs_parallel_beam.h
Go to the documentation of this file.
1 /*
2 ###############################################################################
3 #
4 # EGSnrc egs++ parallel beam 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: Iwan Kawrakow, 2005
25 #
26 # Contributors: Reid Townson
27 #
28 ###############################################################################
29 */
30 
31 
37 #ifndef EGS_PARALLEL_BEAM_
38 #define EGS_PARALLEL_BEAM_
39 
40 #include "egs_vector.h"
41 #include "egs_base_source.h"
42 #include "egs_rndm.h"
43 #include "egs_shapes.h"
44 
45 
46 #ifdef WIN32
47 
48  #ifdef BUILD_PARALLEL_BEAM_DLL
49  #define EGS_PARALLEL_BEAM_EXPORT __declspec(dllexport)
50  #else
51  #define EGS_PARALLEL_BEAM_EXPORT __declspec(dllimport)
52  #endif
53  #define EGS_PARALLEL_BEAM_LOCAL
54 
55 #else
56 
57  #ifdef HAVE_VISIBILITY
58  #define EGS_PARALLEL_BEAM_EXPORT __attribute__ ((visibility ("default")))
59  #define EGS_PARALLEL_BEAM_LOCAL __attribute__ ((visibility ("hidden")))
60  #else
61  #define EGS_PARALLEL_BEAM_EXPORT
62  #define EGS_PARALLEL_BEAM_LOCAL
63  #endif
64 
65 #endif
66 
125 class EGS_PARALLEL_BEAM_EXPORT EGS_ParallelBeam :
126  public EGS_BaseSimpleSource {
127 
128 public:
129 
136  const string &Name="", EGS_ObjectFactory *f=0) :
137  EGS_BaseSimpleSource(Q,Spec,Name,f), shape(Shape), uo(0,0,1) {
138  setUp();
139  };
140 
146  ~EGS_ParallelBeam() {
148  };
149 
151  EGS_Vector &x, EGS_Vector &u, EGS_Float &wt) {
152  x = shape->getRandomPoint(rndm);
153  u = uo;
154  wt = 1;
155  };
156 
157  EGS_Float getFluence() const {
158  return count/shape->area();
159  };
160 
161  bool storeFluenceState(ostream &) const {
162  return true;
163  };
164 
165  bool setFluenceState(istream &) {
166  return true;
167  };
168 
169  bool isValid() const {
170  return (s != 0 && shape != 0);
171  };
172 
173 protected:
174 
175  EGS_BaseShape *shape;
177 
178  void setUp();
179 
180 };
181 
182 #endif
virtual void getPositionDirection(EGS_RandomGenerator *rndm, EGS_Vector &x, EGS_Vector &u, EGS_Float &wt)=0
Sample a particle position and direction.
EGS_BaseSource class header file.
EGS_Vector methods for the manipulation of 3D vectors in cartesian co-ordinates.
A class representing 3D vectors.
Definition: egs_vector.h:56
static void deleteObject(EGS_Object *o)
Delete an object.
Base shape class. All shapes in the EGSnrc C++ class library are derived from EGS_BaseShape.
Definition: egs_shapes.h:112
EGS_ParallelBeam(int Q, EGS_BaseSpectrum *Spec, EGS_BaseShape *Shape, const string &Name="", EGS_ObjectFactory *f=0)
Constructor.
A parallel beam.
Base random number generator class. All random number generators should be derived from this class...
Definition: egs_rndm.h:67
EGS_RandomGenerator class header file.
EGS_BaseShape and shape classes header file.
An object factory.
EGS_Vector uo
The direction of the particles.
virtual EGS_Float getFluence() const =0
Return the fluence this source has emitted so far.
virtual bool storeFluenceState(ostream &data_out) const
Store the fluence state of this source to the data stream data_out.
A class for storing information in a tree-like structure of key-value pairs. This class is used throu...
Definition: egs_input.h:182
Base class for energy spectra. All energy spectra in the EGSnrc C++ class library are derived from th...
Base class for &#39;simple&#39; particle sources.
virtual bool isValid() const
Is this a valid source?
virtual bool setFluenceState(istream &data)
Set the data related to the sampling of positions and directions to a state contained in the stream d...