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;
83 string sstring =
"control point " + itos.str();
84 while (!(err = dyninp->
getInput(sstring,point))) {
85 if (point.size()!=8) {
86 egsWarning(
"EGS_DynamicSource: control point %i does not specify 8 values.\n",icpts);
90 if (ncpts>0 && point[7] < cpts[ncpts-1].mu) {
91 egsWarning(
"EGS_DynamicSource: mu index of control point %i < mu index of control point %i\n",icpts,ncpts);
94 else if (point[7] < 0.) {
95 egsWarning(
"EGS_DynamicSource: mu index of control point %i < 0.0\n",icpts);
100 if (ncpts ==1 && point[7] > 0.0) {
101 egsWarning(
"EGS_DynamicSource: mu index of control point 1 > 0.0. This will generate many warning messages.\n");
104 cpt.iso =
EGS_Vector(point[0],point[1],point[2]);
105 cpt.dsource = point[3];
106 cpt.theta = point[4];
108 cpt.phicol = point[6];
115 sstring =
"control point " + itos.str();
120 egsWarning(
"EGS_DynamicSource: not enough or missing control points.\n");
123 if (cpts[ncpts-1].mu == 0.0) {
124 egsWarning(
"EGS_DynamicSource: mu index of last control point = 0. Something's wrong.\n");
129 for (
int i=0; i<ncpts-1; i++) {
130 cpts[i].mu /= cpts[ncpts-1].mu;
135 egsWarning(
"EGS_DynamicSource: no control points input.\n");
141 void EGS_DynamicSource::setUp() {
143 otype=
"EGS_DynamicSource";
151 description +=
"\n Source will be synched with mu values read in (if available).";
157 int EGS_DynamicSource::getCoord(EGS_Float rand, EGS_ControlPoint &ipt) {
160 for (i=0; i<ncpts; i++) {
161 if (rand < cpts[i].mu) {
167 egsWarning(
"EGS_DynamicSource: could not locate control point.\n");
170 EGS_Float factor = (rand-cpts[iindex-1].mu)/(cpts[iindex].mu-cpts[iindex-1].mu);
171 ipt.iso.x=cpts[iindex-1].iso.x+ (cpts[iindex].iso.x-cpts[iindex-1].iso.x)*factor;
172 ipt.iso.y=cpts[iindex-1].iso.y+ (cpts[iindex].iso.y-cpts[iindex-1].iso.y)*factor;
173 ipt.iso.z=cpts[iindex-1].iso.z+ (cpts[iindex].iso.z-cpts[iindex-1].iso.z)*factor;
174 ipt.dsource=cpts[iindex-1].dsource+ (cpts[iindex].dsource-cpts[iindex-1].dsource)*factor;
175 ipt.theta=cpts[iindex-1].theta+ (cpts[iindex].theta-cpts[iindex-1].theta)*factor;
176 ipt.phi=cpts[iindex-1].phi+ (cpts[iindex].phi-cpts[iindex-1].phi)*factor;
177 ipt.phicol=cpts[iindex-1].phicol+ (cpts[iindex].phicol-cpts[iindex-1].phicol)*factor;
186 createSourceTemplate<EGS_DynamicSource>(input,f,
"dynamic source");
static EGS_BaseSource * createSource(EGS_Input *)
Create sources from the information pointed to by input.
A source with simulated time-varying rotations/translations.
A class representing 3D vectors.
const char * getSourceDescription() const
Get a short description of this source.
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. Not sure if this will ever be used but here just in case.
static EGS_BaseSource * getSource(const string &Name)
Get a pointer to the source named Name.
const string & getObjectType() const
Get the object type.
EGS_BaseSource * source
The source being rotated.
string otype
The object type.
Base source class. All particle sources must be derived from this class.
string description
A short source description.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.