38 #ifndef EGS_DYNAMIC_SOURCE_
39 #define EGS_DYNAMIC_SOURCE_
51 #ifdef BUILD_DYNAMIC_SOURCE_DLL
52 #define EGS_DYNAMIC_SOURCE_EXPORT __declspec(dllexport)
54 #define EGS_DYNAMIC_SOURCE_EXPORT __declspec(dllimport)
56 #define EGS_DYNAMIC_SOURCE_LOCAL
60 #ifdef HAVE_VISIBILITY
61 #define EGS_DYNAMIC_SOURCE_EXPORT __attribute__ ((visibility ("default")))
62 #define EGS_DYNAMIC_SOURCE_LOCAL __attribute__ ((visibility ("hidden")))
64 #define EGS_DYNAMIC_SOURCE_EXPORT
65 #define EGS_DYNAMIC_SOURCE_LOCAL
192 egsWarning(
"EGS_DynamicSource: not enough or missing control points.\n");
196 if (cpts[0].time > 0.0) {
197 egsWarning(
"EGS_DynamicSource: time index of control point 1 > 0.0. This will generate many warning messages.\n");
199 int npts = cpts.size();
200 for (
int i=0; i<npts; i++) {
201 if (i>0 && cpts[i].time < cpts[i-1].time) {
202 egsWarning(
"EGS_DynamicSource: time index of control point %i < time index of control point %i\n",i,i-1);
205 if (cpts[i].time<0.0) {
206 egsWarning(
"EGS_DynamicSource: time index of control point %i < 0.0\n",i);
211 for (
int i=0; i<npts-1; i++) {
212 cpts[i].time /= cpts[npts-1].time;
226 int &q,
int &latch, EGS_Float &E, EGS_Float &wt,
229 EGS_ControlPoint ipt;
232 c = source->getNextParticle(rndm,q,latch,E,wt,x,u);
234 ptime = source->getTimeIndex();
236 egsWarning(
"EGS_DynamicSource: You have selected synchronization of dynamic source with %s\n",source->getObjectName().c_str());
237 egsWarning(
"However, this source does not return time values for each particle. Will turn off synchronization.\n");
245 err = getCoord(ptime,ipt);
251 ipt.phicol *= M_PI/180;
252 ipt.theta *= M_PI/180;
259 u=Rphi*Rtheta*Rcol*u;
260 x=Rphi*Rtheta*Rcol*x + ipt.iso;
264 return source->getEmax();
267 return source->getFluence();
270 return source->storeState(data);
273 return source->setState(data);
276 return source->addState(data_in);
279 source->resetCounter();
282 bool isValid()
const {
283 return (valid && source != 0);
287 source->setSimulationChunk(nstart, nrun, npar, nchunk);
290 void containsDynamic(
bool &hasdynamic);
296 vector<EGS_ControlPoint> cpts;
Base source class. All particle sources must be derived from this class.
virtual bool addState(istream &data_in)
Add data from the stream data_in to the source state.
virtual EGS_Float getEmax() const =0
Return the maximum energy of this source.
virtual EGS_Float getFluence() const =0
Return the fluence this source has emitted so far.
virtual void resetCounter()
Reset the source state.
virtual EGS_I64 getNextParticle(EGS_RandomGenerator *rndm, int &q, int &latch, EGS_Float &E, EGS_Float &wt, EGS_Vector &x, EGS_Vector &u)=0
Sample the next source particle from the source probability distribution.
virtual bool setState(istream &data_in)
Set the source state based on data from the stream data_in.
virtual void setSimulationChunk(EGS_I64 nstart, EGS_I64 nrun, int npar, int nchunk)
Set the next simulation chunk to start at nstart and to consist of nrun particles.
virtual bool storeState(ostream &data_out) const
Store the source state into the stream data_out.
A source with time-varying rotations/translations.
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....
static void deleteObject(EGS_Object *o)
Delete an object.
Base random number generator class. All random number generators should be derived from this class.
EGS_Float getUniform()
Returns a random number uniformly distributed between zero (inclusive) and 1 (exclusive).
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 rotZ(EGS_Float cphi, EGS_Float sphi)
Returns a rotation around the z-axis by the angle with cphi, sphi = .
A class representing 3D vectors.
EGS_BaseSource class header file.
EGS_RandomGenerator class header file.
EGS_BaseShape and shape classes header file.
EGS_Vector methods for the manipulation of 3D vectors in cartesian co-ordinates.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.