38 #ifndef EGS_SOURCE_COLLECTION_
39 #define EGS_SOURCE_COLLECTION_
48 #ifdef BUILD_SOURCE_COLLECTION_DLL
49 #define EGS_SOURCE_COLLECTION_EXPORT __declspec(dllexport)
51 #define EGS_SOURCE_COLLECTION_EXPORT __declspec(dllimport)
53 #define EGS_SOURCE_COLLECTION_LOCAL
57 #ifdef HAVE_VISIBILITY
58 #define EGS_SOURCE_COLLECTION_EXPORT __attribute__ ((visibility ("default")))
59 #define EGS_SOURCE_COLLECTION_LOCAL __attribute__ ((visibility ("hidden")))
61 #define EGS_SOURCE_COLLECTION_EXPORT
62 #define EGS_SOURCE_COLLECTION_LOCAL
131 const vector<EGS_Float> &prob,
144 for (
int j=0; j<nsource; j++) {
150 delete [] last_cases;
155 int &q,
int &latch, EGS_Float &E, EGS_Float &wt,
157 int j = table->sample(rndm);
158 EGS_I64 this_case = sources[j]->getNextParticle(rndm,q,latch,E,wt,x,u);
159 count += this_case - last_cases[j];
160 last_cases[j] = this_case;
168 for (
int j=0; j<nsource; j++) {
169 flu += sources[j]->getFluence();
183 for (
int j=0; j<nsource; j++) {
204 for (
int j=0; j<nsource; j++) {
219 for (
int j=0; j<nsource; ++j) {
221 sources[j]->resetCounter();
225 virtual bool addState(istream &data_in) {
236 for (
int j=0; j<nsource; j++) {
241 last_cases[j] += tmp;
242 if (!sources[j]->
addState(data_in)) {
249 bool isValid()
const {
250 return (nsource > 0);
254 for (
int j=0; j<nsource; j++) {
255 sources[j]->setSimulationChunk(nstart, nrun);
269 void setUp(
const vector<EGS_BaseSource *> &S,
const vector<EGS_Float> &);
bool EGS_EXPORT egsGetI64(istream &data, EGS_I64 &n)
Reads a 64 bit integer from the stream data and assigns it to n. Returns true on success, false on failure.
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_AliasTable class header file.
EGS_I64 count
Independent particles delivered.
EGS_Float Emax
Maximum energy (max of s[j]->getEmax()).
EGS_BaseSource class header file.
EGS_Vector methods for the manipulation of 3D vectors in cartesian co-ordinates.
bool EGS_EXPORT egsStoreI64(ostream &data, EGS_I64 n)
Writes the 64 bit integer n to the output stream data and returns true on success, false on failure.
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.
virtual bool storeState(ostream &data_out) const
Store the source state into the stream data_out.
EGS_SimpleAliasTable * table
Alias table for randomly picking a source.
Base random number generator class. All random number generators should be derived from this class...
EGS_RandomGenerator class header file.
EGS_SourceCollection(const vector< EGS_BaseSource * > &S, const vector< EGS_Float > &prob, const string &Name="", EGS_ObjectFactory *f=0)
Constructor.
virtual bool setState(istream &data_in)
Set the source state based on data from the stream data_in.
A class for sampling random bins from a given probability distribution using the alias table techniqu...
EGS_BaseSource ** sources
The sources in the collection.
virtual EGS_Float getFluence() const =0
Return the fluence this source has emitted so far.
EGS_I64 * last_cases
Last case returned from each source.
EGS_Float * p
The probabilities.
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.