50 #define STRINGIFY(s) HELP_S(s)
52 #define F77_NAME(fname,FNAME) STRINGIFY(F77_OBJ(fname,FNAME))
53 #define F77_NAME_(fname,FNAME) STRINGIFY(F77_OBJ_(fname,FNAME))
71 int err1 = input->
getInput(
"beam code",beam_code);
73 int err2 = input->
getInput(
"pegs file",pegs_file);
75 int err3 = input->
getInput(
"input file",input_file);
77 egsWarning(
"EGS_BeamSource: no 'beam code' input\n");
80 egsWarning(
"EGS_BeamSource: no 'pegs file' input\n");
83 egsWarning(
"EGS_BeamSource: no 'input file' input\n");
85 if (err1 || err2 || err3) {
89 int err_eh = input->
getInput(
"egs_home",egs_home);
91 char *eh = getenv(
"EGS_HOME");
93 egsWarning(
"EGS_BeamSource: EGS_HOME is not defined\n");
104 int err_hh = input->
getInput(
"hen_house",hen_house);
106 char *hh = getenv(
"HEN_HOUSE");
108 egsWarning(
"EGS_BeamSource: HEN_HOUSE is not defined\n");
118 string path = egs_home;
123 InitFunction init = (InitFunction)
124 lib->
resolve(F77_NAME_(beamlib_init,BEAMLIB_INIT));
126 lib->
resolve(F77_NAME_(beamlib_finish,BEAMLIB_FINISH));
128 lib->
resolve(F77_NAME_(beamlib_sample,BEAMLIB_SAMPLE));
129 motionsample = (MotionSampleFunction)
130 lib->
resolve(F77_NAME_(beamlib_motionsample,BEAMLIB_MOTIONSAMPLE));
131 MaxEnergyFunction maxenergy = (MaxEnergyFunction)
132 lib->
resolve(F77_NAME_(beamlib_max_energy,BEAMLIB_MAX_ENERGY));
134 egsWarning(
"EGS_BeamSource: failed to resolve the init function\n");
137 egsWarning(
"EGS_BeamSource: failed to resolve the sample function\n");
140 egsWarning(
"EGS_BeamSource: failed to resolve the motionsample function\n");
143 egsWarning(
"EGS_BeamSource: failed to resolve the finish function\n");
146 egsWarning(
"EGS_BeamSource: failed to resolve the max. energy function\n");
160 init(&ipar,&npar,&ilog,hen_house.c_str(),egs_home.c_str(),
161 beam_code.c_str(),pegs_file.c_str(),input_file.c_str(),
162 hen_house.size(), egs_home.size(),
163 beam_code.size(),pegs_file.size(),input_file.size());
168 vector<EGS_Float> cutout;
169 int err = input->
getInput(
"cutout",cutout);
170 if (!err && cutout.size() == 4) {
171 setCutout(cutout[0],cutout[1],cutout[2],cutout[3]);
173 vector<string> ptype;
174 ptype.push_back(
"electrons");
175 ptype.push_back(
"photons");
176 ptype.push_back(
"positrons");
177 ptype.push_back(
"all");
178 ptype.push_back(
"charged");
179 particle_type = input->
getInput(
"particle type",ptype,3)-1;
181 vector<EGS_Float> wwindow;
182 err = input->
getInput(
"weight window",wwindow);
183 if (!err && wwindow.size() == 2) {
189 err = input->
getInput(
"reuse photons",ntmp);
190 if (!err && ntmp > 1) {
191 n_reuse_photon = ntmp;
193 err = input->
getInput(
"reuse electrons",ntmp);
194 if (!err && ntmp > 1) {
195 n_reuse_electron = ntmp;
201 motionsample(&tei,&txi,&tyi,&tzi,&tui,&tvi,&twi,&twti,&tqi,&tlatchi,&counti,&tiphati,&ttimei);
204 if (ttimei >= 0.0 && ttimei <= 1.0) {
205 egsInformation(
"EGS_BeamSource:: Time index passed from this source.\n");
210 use_iparticle =
true;
216 otype=
"EGS_BeamSource";
221 if (n_reuse_photon > 0 && i_reuse_photon < n_reuse_photon) {
232 if (n_reuse_electron > 0 && i_reuse_electron < n_reuse_electron) {
243 EGS_Float te,tx,ty,tz,tu,tv,tw,twt,ttime;
244 int tq,tlatch,tiphat;
265 motionsample(&te,&tx,&ty,&tz,&tu,&tv,&tw,&twt,&tq,&tlatch,&count,&tiphat,&ttime);
272 egsWarning(
"EGS_BeamSource::getNextParticle: Time index is stored in this source but time returned < 0\n");
284 if (particle_type < 2 && tq != particle_type) {
287 if (particle_type == 3 && !tq) {
290 if (tx < Xmin || tx > Xmax || ty < Ymin || ty > Ymax) {
293 if (twt < wmin || twt > wmax) {
298 i_reuse_electron = n_reuse_electron;
299 i_reuse_photon = n_reuse_photon;
304 bool save_it =
false;
305 if (n_reuse_photon > 1 && !tq) {
306 twt /= n_reuse_photon;
310 if (n_reuse_electron > 1 && tq) {
311 twt /= n_reuse_electron;
312 i_reuse_electron = 1;
351 EGS_BeamSource::~EGS_BeamSource() {
365 createSourceTemplate<EGS_BeamSource>(input,f,
"beam source");
Base class for advanced EGSnrc C++ applications.
static EGS_Application * activeApplication()
Get the active application.
int getNparallel() const
Returns the number of parallel jobs executing.
int getIparallel() const
Returns the job number in a parallel run.
Base source class. All particle sources must be derived from this class.
string description
A short source description.
SampleFunction sample
The function that returns the next particle.
void containsDynamic(bool &hasdynamic)
Check if the simulation source contains time indices.
EGS_BeamSource(EGS_Input *, EGS_ObjectFactory *f=0)
Create a BEAM simulation source from the input inp.
bool time_stored
true if time index stored
EGS_Library * lib
The BEAMnrc user code library.
A class for dynamically loading shared libraries.
void * resolve(const char *func)
Returns the address of the exported symbol func.
string otype
The object type.
Base random number generator class. All random number generators should be derived from this class.
A class representing 3D vectors.
EGS_Application class header file.
A BEAM simulation source.
Global egspp functions header file.
EGS_Library class header file.
EGS_InfoFunction EGS_EXPORT egsInformation
Always use this function for reporting the progress of a simulation and any other type of information...
string egsExpandPath(const string &aname)
Expands first environment variable found in a file name.
const EGS_Float epsilon
The epsilon constant for floating point comparisons.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.
const EGS_Float veryFar
A very large float.