39 #ifndef EGS_SOURCE_COLLECTION_
40 #define EGS_SOURCE_COLLECTION_
51 #ifdef BUILD_SOURCE_COLLECTION_DLL
52 #define EGS_SOURCE_COLLECTION_EXPORT __declspec(dllexport)
54 #define EGS_SOURCE_COLLECTION_EXPORT __declspec(dllimport)
56 #define EGS_SOURCE_COLLECTION_LOCAL
60 #ifdef HAVE_VISIBILITY
61 #define EGS_SOURCE_COLLECTION_EXPORT __attribute__ ((visibility ("default")))
62 #define EGS_SOURCE_COLLECTION_LOCAL __attribute__ ((visibility ("hidden")))
64 #define EGS_SOURCE_COLLECTION_EXPORT
65 #define EGS_SOURCE_COLLECTION_LOCAL
134 const vector<EGS_Float> &prob,
147 for (
int j=0; j<nsource; j++) {
153 delete [] last_cases;
160 int &q,
int &latch, EGS_Float &E, EGS_Float &wt,
162 int j = table->sample(rndm);
163 EGS_I64 this_case = sources[j]->getNextParticle(rndm,q,latch,E,wt,x,u);
164 count += this_case - last_cases[j];
165 last_cases[j] = this_case;
166 for (
int i=0; i<nsource; i++) {
171 if (i != j && sources[i]->
getFluence() > last_flu[i]) {
172 if (std::find(p_group[i].begin(), p_group[i].end(), j) == p_group[i].end()) {
173 p_group[i].push_back(j);
174 p_group[j].push_back(i);
177 last_cases[i]=last_cases[j];
179 last_flu[i] = sources[i]->getFluence();
188 for (
int j=0; j<nsource; j++) {
189 EGS_Float p_tot=p[j];
190 for (
int i=0; i<p_group[j].size(); i++) {
191 p_tot += p[p_group[j][i]];
198 norm = p_group[j].size()+1;
200 flu += p[j]/p_tot*sources[j]->getFluence()/norm;
214 for (
int j=0; j<nsource; j++) {
220 for (
int i=0; i<p_group[j].size(); i++) {
221 data << p_group[j][i] <<
" ";
240 for (
int j=0; j<nsource; j++) {
247 while (tmp_int != -1) {
248 if (std::find(p_group[j].begin(), p_group[j].end(), tmp_int) == p_group[j].end()) {
249 p_group[j].push_back(tmp_int);
256 last_flu[j]=sources[j]->getFluence();
264 for (
int j=0; j<nsource; ++j) {
267 sources[j]->resetCounter();
271 virtual bool addState(istream &data_in) {
282 for (
int j=0; j<nsource; j++) {
287 last_cases[j] += tmp;
290 while (tmp_int != -1) {
291 if (std::find(p_group[j].begin(), p_group[j].end(), tmp_int) == p_group[j].end()) {
292 p_group[j].push_back(tmp_int);
296 if (!sources[j]->
addState(data_in)) {
299 last_flu[j]=sources[j]->getFluence();
305 bool isValid()
const {
306 return (nsource > 0);
310 for (
int j=0; j<nsource; j++) {
311 sources[j]->setSimulationChunk(nstart, nrun, npar, nchunk);
315 void containsDynamic(
bool &hasdynamic);
318 for (
int j=0; j<nsource; j++) {
319 sources[j]->printSampledEmissions();
324 vector<EGS_Ensdf *> allDecays;
325 for (
int j=0; j<nsource; j++) {
327 allDecays.push_back(decays);
346 void setUp(
const vector<EGS_BaseSource *> &S,
const vector<EGS_Float> &);
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 void printSampledEmissions()
Print statistics on what was sampled from the source.
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 vector< EGS_Ensdf * > getRadionuclideEnsdf()
Get the radionuclide ENSDF object from the source.
virtual bool storeState(ostream &data_out) const
Store the source state into the stream data_out.
static void deleteObject(EGS_Object *o)
Delete an object.
Base random number generator class. All random number generators should be derived from this class.
A class for sampling random bins from a given probability distribution using the alias table techniqu...
EGS_Float * last_flu
Saved value of source_flu.
EGS_SimpleAliasTable * table
Alias table for randomly picking a source.
EGS_SourceCollection(const vector< EGS_BaseSource * > &S, const vector< EGS_Float > &prob, const string &Name="", EGS_ObjectFactory *f=0)
Constructor.
bool i_add
Set to true if parallel results have been combined.
EGS_Float Emax
Maximum energy (max of s[j]->getEmax()).
vector< EGS_I64 > * p_group
Vector of sources using the same base source.
EGS_BaseSource ** sources
The sources in the collection.
EGS_Float * p
The probabilities.
EGS_I64 count
Independent particles delivered.
EGS_I64 * last_cases
Last case returned from each source.
A class representing 3D vectors.
EGS_AliasTable class header file.
EGS_BaseSource class header file.
EGS_RandomGenerator 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,...
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,...