37 #ifndef EGS_DYNAMIC_SOURCE_
38 #define EGS_DYNAMIC_SOURCE_
50 #ifdef BUILD_DYNAMIC_SOURCE_DLL
51 #define EGS_DYNAMIC_SOURCE_EXPORT __declspec(dllexport)
53 #define EGS_DYNAMIC_SOURCE_EXPORT __declspec(dllimport)
55 #define EGS_DYNAMIC_SOURCE_LOCAL
59 #ifdef HAVE_VISIBILITY
60 #define EGS_DYNAMIC_SOURCE_EXPORT __attribute__ ((visibility ("default")))
61 #define EGS_DYNAMIC_SOURCE_LOCAL __attribute__ ((visibility ("hidden")))
63 #define EGS_DYNAMIC_SOURCE_EXPORT
64 #define EGS_DYNAMIC_SOURCE_LOCAL
194 egsWarning(
"EGS_DynamicSource: not enough or missing control points.\n");
198 if (cpts[0].mu > 0.0) {
199 egsWarning(
"EGS_DynamicSource: mu index of control point 1 > 0.0. This will generate many warning messages.\n");
201 int npts = cpts.size();
202 for (
int i=0; i<npts; i++) {
203 if (i>0 && cpts[i].mu < cpts[i-1].mu) {
204 egsWarning(
"EGS_DynamicSource: mu index of control point %i < mu index of control point %i\n",i,i-1);
207 if (cpts[i].mu<0.0) {
208 egsWarning(
"EGS_DynamicSource: mu index of control point %i < 0.0\n",i);
213 for (
int i=0; i<npts-1; i++) {
214 cpts[i].mu /= cpts[npts-1].mu;
228 int &q,
int &latch, EGS_Float &E, EGS_Float &wt,
231 EGS_ControlPoint ipt;
234 c = source->getNextParticle(rndm,q,latch,E,wt,x,u);
236 pmu = source->getMu();
238 egsWarning(
"EGS_DynamicSource: You have selected synchronization of dynamic source with %s\n",source->getObjectName().c_str());
239 egsWarning(
"However, this source does not return mu values for each particle. Will turn off synchronization.\n");
246 err = getCoord(pmu,ipt);
252 ipt.phicol *= M_PI/180;
253 ipt.theta *= M_PI/180;
260 u=Rphi*Rtheta*Rcol*u;
261 x=Rphi*Rtheta*Rcol*x + ipt.iso;
265 return source->getEmax();
268 return source->getFluence();
274 return source->storeState(data);
277 return source->setState(data);
280 return source->addState(data_in);
283 source->resetCounter();
286 bool isValid()
const {
287 return (valid && source != 0);
291 source->setSimulationChunk(nstart, nrun);
298 vector<EGS_ControlPoint> cpts;
307 int getCoord(
const EGS_Float rand, EGS_ControlPoint &ipt);
virtual void setSimulationChunk(EGS_I64 nstart, EGS_I64 nrun)
Set the next simulation chunk to start at nstart and to consist of nrun particles.
EGS_BaseSource class header file.
A class for vector rotations.
EGS_Vector methods for the manipulation of 3D vectors in cartesian co-ordinates.
A class representing 3D vectors.
virtual bool addState(istream &data_in)
Add data from the stream data_in to the source state.
static void deleteObject(EGS_Object *o)
Delete an object.
virtual void resetCounter()
Reset the source state.
static EGS_RotationMatrix rotY(EGS_Float cphi, EGS_Float sphi)
Returns a rotation around the y-axis by the angle with cphi, sphi = .
A source with time-varying rotations/translations.
virtual bool storeState(ostream &data_out) const
Store the source state into the stream data_out.
Base random number generator class. All random number generators should be derived from this class...
static EGS_RotationMatrix rotZ(EGS_Float cphi, EGS_Float sphi)
Returns a rotation around the z-axis by the angle with cphi, sphi = .
EGS_RandomGenerator class header file.
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.
virtual bool setState(istream &data_in)
Set the source state based on data from the stream data_in.
EGS_BaseShape and shape classes header file.
virtual EGS_Float getFluence() const =0
Return the fluence this source has emitted so far.
EGS_Float getUniform()
Returns a random number uniformly distributed between zero (inclusive) and 1 (exclusive).
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 EGS_Float getEmax() const =0
Return the maximum energy of this source.
Base source class. All particle sources must be derived from this class.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.