EGSnrc C++ class library
Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs++
ausgab_objects
egs_radiative_splitting
egs_radiative_splitting.cpp
Go to the documentation of this file.
1
/*
2
###############################################################################
3
#
4
# EGSnrc egs++ radiative splitting object
5
# Copyright (C) 2018 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: Ernesto Mainegra-Hing, 2018
25
#
26
# Contributors:
27
#
28
###############################################################################
29
#
30
# A general radiative splitting tool.
31
#
32
# TODO:
33
#
34
# - Add directional radiative splitting (DRS)
35
#
36
###############################################################################
37
*/
38
39
45
#include <fstream>
46
#include <string>
47
#include <cstdlib>
48
49
#include "
egs_radiative_splitting.h
"
50
#include "
egs_input.h
"
51
#include "
egs_functions.h
"
52
53
EGS_RadiativeSplitting::EGS_RadiativeSplitting(
const
string
&Name,
54
EGS_ObjectFactory
*f) :
55
nsplit(1) {
56
otype =
"EGS_RadiativeSplitting"
;
57
}
58
59
EGS_RadiativeSplitting::~EGS_RadiativeSplitting() {
60
}
61
62
void
EGS_RadiativeSplitting::setApplication(
EGS_Application
*App) {
63
EGS_AusgabObject::setApplication
(App);
64
if
(!
app
) {
65
return
;
66
}
67
68
char
buf[32];
69
70
// Set EGSnrc internal UBS + RR
71
if
(i_play_RR) {
72
app
->setRussianRoulette(nsplit);
73
i_play_RR =
true
;
74
}
75
// Set EGSnrc internal radiative splitting number.
76
else
if
(nsplit > 0) {
77
app
->setRadiativeSplitting(nsplit);
78
i_play_RR =
false
;
79
}
80
81
description
=
"\n===========================================\n"
;
82
description
+=
"Radiative splitting Object ("
;
83
description
+=
name
;
84
description
+=
")\n"
;
85
description
+=
"===========================================\n"
;
86
if
(i_play_RR) {
87
description
+=
"\n - Splitting radiative events in "
;
88
sprintf(buf,
"%d"
,nsplit);
89
description
+= buf;
90
description
+=
"\n - Play RR with higher order e-/e+ with probability 1/"
;
91
sprintf(buf,
"%d\n\n"
,nsplit);
92
description
+= buf;
93
}
94
else
if
(nsplit > 1) {
95
description
+=
"\n - Splitting radiative events in "
;
96
sprintf(buf,
"%d\n\n"
,nsplit);
97
description
+= buf;
98
}
99
else
if
(nsplit == 1) {
100
description
+=
"\n - NO radiative splitting"
;
101
}
102
else
{
103
description
+=
"\n - BEWARE: Turning OFF radiative events !!!"
;
104
}
105
description
+=
"\n===========================================\n\n"
;
106
}
107
108
//*********************************************************************
109
// Process input for this ausgab object
110
//
111
//**********************************************************************
112
extern
"C"
{
113
114
EGS_RADIATIVE_SPLITTING_EXPORT
EGS_AusgabObject
*
createAusgabObject
(
EGS_Input
*input,
115
EGS_ObjectFactory
*f) {
116
const
static
char
*func =
"createAusgabObject(radiative_splitting)"
;
117
if
(!input) {
118
egsWarning
(
"%s: null input?\n"
,func);
119
return
0;
120
}
121
122
EGS_Float nsplit = 1.0;
124
int
err = input->
getInput
(
"splitting"
,nsplit);
125
126
//=================================================
127
128
/* Setup radiative splitting object with input parameters */
129
EGS_RadiativeSplitting
*result =
new
EGS_RadiativeSplitting
(
""
,f);
130
result->
setSplitting
(nsplit);
131
result->
setName
(input);
132
return
result;
133
}
134
}
EGS_Application
Base class for advanced EGSnrc C++ applications.
Definition:
egs_application.h:268
EGS_AusgabObject
Definition:
egs_ausgab_object.h:64
EGS_AusgabObject::setApplication
virtual void setApplication(EGS_Application *App)
Set the application this object belongs to.
Definition:
egs_ausgab_object.h:105
EGS_AusgabObject::description
string description
A short ausgab object description.
Definition:
egs_ausgab_object.h:242
EGS_AusgabObject::app
EGS_Application * app
The application this object belongs to.
Definition:
egs_ausgab_object.h:245
EGS_Input
A class for storing information in a tree-like structure of key-value pairs. This class is used throu...
Definition:
egs_input.h:182
EGS_Input::getInput
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
EGS_ObjectFactory
An object factory.
Definition:
egs_object_factory.h:206
EGS_Object::setName
void setName(EGS_Input *inp)
Set the name of the object from the information provided by inp.
Definition:
egs_object_factory.cpp:95
EGS_Object::name
string name
The object name.
Definition:
egs_object_factory.h:175
EGS_RadiativeSplitting
A radiative splitting object: header.
Definition:
egs_radiative_splitting.h:93
EGS_RadiativeSplitting::setSplitting
void setSplitting(const int &n_s)
Definition:
egs_radiative_splitting.h:110
egs_functions.h
Global egspp functions header file.
egs_input.h
EGS_Input class header file.
createAusgabObject
EGS_RADIATIVE_SPLITTING_EXPORT EGS_AusgabObject * createAusgabObject(EGS_Input *input, EGS_ObjectFactory *f)
Definition:
egs_radiative_splitting.cpp:114
egs_radiative_splitting.h
A radiative splitting ausgab object: header.
egsWarning
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.
Definition:
egs_functions.cpp:136
Generated by
1.9.1