41 static bool EGS_FOCAL_SPOT_LOCAL inputSet =
false;
46 if (input->
getInput(
"z position",z_pos)) {
47 egsWarning(
"EGS_FocalSpot: missing input for parameter 'z position'\n");
51 if (input->
getInput(
"spatial spread x",sigma_x_space)) {
52 egsWarning(
"EGS_FocalSpot: missing input for parameter 'spatial spread x\n");
55 else if (sigma_x_space <= 0) {
56 egsWarning(
"EGS_FocalSpot: 'spatial spread x' must be positive (got %g)\n",
61 if (input->
getInput(
"spatial spread y",sigma_y_space)) {
62 egsWarning(
"EGS_FocalSpot: missing input for parameter 'spatial spread y'\n");
65 else if (sigma_y_space <= 0) {
66 egsWarning(
"EGS_FocalSpot: 'spatial spread y' must be positive (got %g)\n",
72 int err_cut_x = input->
getInput(
"spatial cutoff x",space_cutoff_x);
73 int err_cut_y = input->
getInput(
"spatial cutoff y",space_cutoff_y);
74 input->
getInput(
"x translation",x_translation);
75 input->
getInput(
"y translation",y_translation);
76 input->
getInput(
"angular spread x",sigma_x_angle);
77 input->
getInput(
"angular spread y",sigma_y_angle);
80 space_cutoff_x = (err_cut_x) ? 5*sigma_x_space : space_cutoff_x;
81 space_cutoff_y = (err_cut_y) ? 5*sigma_y_space : space_cutoff_y;
84 if (space_cutoff_x <= 0 || space_cutoff_y <= 0) {
85 egsFatal(
"EGS_FocalSpot: spatial cutoff values must be positive "
86 "(got cutoff_x=%g, cutoff_y=%g)\n",
87 space_cutoff_x, space_cutoff_y);
91 if ((sigma_x_angle != 0) || (sigma_y_angle != 0)) {
94 if ((sigma_x_angle != 0) && (sigma_y_angle != 0)) {
98 else if (sigma_x_angle != 0) {
102 else if (sigma_y_angle != 0) {
109 if (!input->
getInput(
"z of rotation",z_point_of_rotation)) {
111 if (z_point_of_rotation >= z_pos) {
112 egsWarning(
"EGS_FocalSpot: wrong input for variable 'z of rotation'\n \
113 The requirement z of rotation < z position needs to be fullfilled !\n");
119 bool err_x = abs(input->
getInput(
"x rotation",x_rotation));
120 bool err_y = abs(input->
getInput(
"y rotation",y_rotation));
122 if ((x_rotation<=-90) || (x_rotation>=90)) {
123 egsWarning(
"EGS_FocalSpot: wrong input for variable 'x rotation' the value should be within -90 degrees < x rotation < 90 degrees\n");
127 if ((y_rotation<=-90) || (y_rotation>=90)) {
128 egsWarning(
"EGS_FocalSpot: wrong input for variable 'y rotation' the value should be within -90 degrees < y rotation < 90 degrees\n");
133 if ((!err_x || !err_y) && !is_rotated) {
134 egsWarning(
"EGS_FocalSpot: missing input for variable 'z of rotation'\n");
142 otype =
"EGS_FocalSpot";
162 description +=
" at a constant z "+ to_string(z_pos) +
" cm\n";
164 description +=
" that has a spatial distribution described by a 2D Gaussian with\n";
165 description +=
" - " + to_string(sigma_x_space) +
" cm standard deviation in x (Cutoff at: "+ to_string(space_cutoff_x) +
" cm)\n";
166 description +=
" - " + to_string(sigma_y_space) +
" cm standard deviation in y (Cutoff at: "+ to_string(space_cutoff_y) +
" cm)\n";
167 description +=
" Around the point ("+to_string(x_translation)+
"cm,"+to_string(y_translation)+
"cm)\n";
170 description +=
" The sampling of the direction vector determines the azimuth depending on the polar arc with \n";
172 description +=
" - " + to_string(sigma_x_angle) +
" degree standard deviation along x \n";
175 description +=
" - " + to_string(sigma_y_angle) +
" degree standard deviation along y \n";
182 description +=
" The initial direction of motion is constant and pointing along the z-axis.\n";
198 static void setInputs() {
201 setBaseSourceInputs();
203 srcBlockInput->getSingleInput(
"library")->setValues({
"egs_focal_spot_source"});
206 srcBlockInput->addSingleInput(
"z position",
true,
"The z position of the source");
207 srcBlockInput->addSingleInput(
"spatial spread x",
true,
"The standard deviation of the source along x");
208 srcBlockInput->addSingleInput(
"spatial spread y",
true,
"The standard deviation of the source along y");
209 srcBlockInput->addSingleInput(
"spatial cutoff x",
false,
"Particles will not be generated outside [x0-cutoff, x0+cutoff]");
210 srcBlockInput->addSingleInput(
"spatial cutoff y",
false,
"Particles will not be generated outside [y0-cutoff, y0+cutoff]");
211 srcBlockInput->addSingleInput(
"angular spread x",
false,
"The standard deviation in degrees from the z-axis toward x");
212 srcBlockInput->addSingleInput(
"angular spread y",
false,
"The standard deviation in degrees from the z-axis toward y");
213 srcBlockInput->addSingleInput(
"x translation",
false,
"An offset from the origin along x");
214 srcBlockInput->addSingleInput(
"y translation",
false,
"An offset from the origin along y");
215 srcBlockInput->addSingleInput(
"z of rotation",
false,
"The z position for the point of rotation");
216 srcBlockInput->addSingleInput(
"x rotation",
false,
"A rotation clockwise when viewed from the +x axis, in degrees");
217 srcBlockInput->addSingleInput(
"y rotation",
false,
"A rotation clockwise when viewed from the +y axis, in degrees");
220 EGS_FOCAL_SPOT_EXPORT
string getExample() {
224 # Example of egs_focal_spot_source
226 library = egs_focal_spot_source
227 name = focal_spot_test
229 spatial spread x = 0.2 # cm standard deviation always never FWHM
230 spatial spread y = 0.2 # cm standard deviation always never FWHM
231 spatial cutoff x = 0.3 # cm particles will not be generated outside [x0-cutoff, x0+cutoff] (optional)
232 spatial cutoff y = 0.3 # cm particles will not be generated outside [y0-cutoff, y0+cutoff] (optional)
233 angular spread x = 1.5 # degrees (optional) (standard deviation from z-axis)
234 angular spread y = 0.9 # degrees (optional) (standard deviation from z-axis)
235 x translation = 0 # cm (optional)
236 y translation = 0 # cm (optional)
237 z of rotation = 0 # cm (optional)
238 x rotation = 1 # degrees, clockwise when viewed from +x axis
239 y rotation = 0 # degrees, clockwise when viewed from +y axis
241 definition of the spectrum
243 charge = -1 or 0 or 1 for electrons or photons or positrons
249 EGS_FOCAL_SPOT_EXPORT shared_ptr<EGS_BlockInput> getInputs() {
253 return srcBlockInput;
258 return createSourceTemplate<EGS_FocalSpot>(input,f,
"focal spot");
Base class for 'simple' particle sources.
int q
The charge of this simple source.
EGS_BaseSpectrum * s
The energy spectrum of this source.
Base source class. All particle sources must be derived from this class.
string description
A short source description.
const string & getType() const
Get the spectrum type.
int angle_mode
rotation about z_point_of_rotation
EGS_FocalSpot(EGS_Input *, EGS_ObjectFactory *f=0)
Constructor All Inputs are read in from the input file non is Construct a focal spot (corresponding t...
void setUp()
Sets up the source type and description.
static constexpr double DEGREE_TO_RAD
governs angular sampling
string otype
The object type.
A class for vector rotations.
static EGS_RotationMatrix rotY(EGS_Float cphi, EGS_Float sphi)
Returns a rotation around the y-axis by the angle with cphi, sphi = .
static EGS_RotationMatrix rotX(EGS_Float cphi, EGS_Float sphi)
Returns a rotation around the x-axis by the angle with cphi, sphi = .
A class representing 3D vectors.
A source with gaussian distribution for XY and UV that is an expanded version of BEAMnrc's ISOURC19.
EGS_InfoFunction EGS_EXPORT egsFatal
Always use this function for reporting fatal errors.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.