49 int err = input->
getInput(
"source name",sname);
51 egsWarning(
"EGS_DynamicSource: missing/wrong inline source "
52 "definition and missing wrong 'source name' input\n");
56 " does not exist\n",sname.c_str());
62 vector<string> sync_options;
63 sync_options.push_back(
"no");
64 sync_options.push_back(
"yes");
65 sync = input->
getInput(
"synchronize motion",sync_options,0);
68 egsWarning(
"EGS_DynamicSource: source motion can only be synchronized with a source of type iaea_phsp_source or egs_beam_source.\n Will not synchronize.\n");
77 vector<EGS_Float> point;
84 string inputTag =
"control point";
85 string inputTag_backCompat =
"control point " + itos.str();
90 if (!currentInput || currentInput->
getInput(inputTag, point)) {
92 if (!currentInput || currentInput->
getInput(inputTag_backCompat, point)) {
99 if (point.size()!=8) {
100 egsWarning(
"EGS_DynamicSource: control point %i does not specify 8 values.\n",icpts);
104 if (ncpts>0 && point[7] < cpts[ncpts-1].time) {
105 egsWarning(
"EGS_DynamicSource: time index of control point %i < time index of control point %i\n",icpts,ncpts);
108 else if (point[7] < 0.) {
109 egsWarning(
"EGS_DynamicSource: time index of control point %i < 0.0\n",icpts);
114 if (ncpts ==1 && point[7] > 0.0) {
115 egsWarning(
"EGS_DynamicSource: time index of control point 1 > 0.0. This will generate many warning messages.\n");
118 cpt.iso =
EGS_Vector(point[0],point[1],point[2]);
119 cpt.dsource = point[3];
120 cpt.theta = point[4];
122 cpt.phicol = point[6];
129 inputTag_backCompat =
"control point " + itos.str();
134 egsWarning(
"EGS_DynamicSource: not enough or missing control points.\n");
137 if (cpts[ncpts-1].time == 0.0) {
138 egsWarning(
"EGS_DynamicSource: time index of last control point = 0. Something's wrong.\n");
143 for (
int i=0; i<=ncpts-1; i++) {
144 cpts[i].time /= cpts[ncpts-1].time;
149 egsWarning(
"EGS_DynamicSource: no control points input.\n");
155 void EGS_DynamicSource::setUp() {
157 otype=
"EGS_DynamicSource";
165 description +=
"\n Source will be synched with time values read in (if available).";
171 int EGS_DynamicSource::getCoord(EGS_Float rand, EGS_ControlPoint &ipt) {
174 for (i=0; i<ncpts; i++) {
175 if (rand < cpts[i].time-
epsilon) {
181 egsWarning(
"EGS_DynamicSource: could not locate control point.\n");
184 EGS_Float factor = (rand-cpts[iindex-1].time)/(cpts[iindex].time-cpts[iindex-1].time);
185 ipt.iso.x=cpts[iindex-1].iso.x+ (cpts[iindex].iso.x-cpts[iindex-1].iso.x)*factor;
186 ipt.iso.y=cpts[iindex-1].iso.y+ (cpts[iindex].iso.y-cpts[iindex-1].iso.y)*factor;
187 ipt.iso.z=cpts[iindex-1].iso.z+ (cpts[iindex].iso.z-cpts[iindex-1].iso.z)*factor;
188 ipt.dsource=cpts[iindex-1].dsource+ (cpts[iindex].dsource-cpts[iindex-1].dsource)*factor;
189 ipt.theta=cpts[iindex-1].theta+ (cpts[iindex].theta-cpts[iindex-1].theta)*factor;
190 ipt.phi=cpts[iindex-1].phi+ (cpts[iindex].phi-cpts[iindex-1].phi)*factor;
191 ipt.phicol=cpts[iindex-1].phicol+ (cpts[iindex].phicol-cpts[iindex-1].phicol)*factor;
209 createSourceTemplate<EGS_DynamicSource>(input,f,
"dynamic source");
Base source class. All particle sources must be derived from this class.
const char * getSourceDescription() const
Get a short description of this source.
static EGS_BaseSource * getSource(const string &Name)
Get a pointer to the source named Name.
string description
A short source description.
static EGS_BaseSource * createSource(EGS_Input *)
Create sources from the information pointed to by input.
EGS_BaseSource * source
The source being rotated.
EGS_DynamicSource(EGS_BaseSource *Source, vector< EGS_ControlPoint > cpts, const string &Name="", EGS_ObjectFactory *f=0)
Construct a dynamic source using Source as the source and cpts as the control points....
void containsDynamic(bool &hasdynamic)
Check if the simulation source contains time indices.
string otype
The object type.
const string & getObjectType() const
Get the object type.
A class representing 3D vectors.
A source with simulated time-varying rotations/translations.
const EGS_Float epsilon
The epsilon constant for floating point comparisons.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.