42 vector<EGS_BaseSource *> s;
50 egsWarning(
"EGS_SourceCollection: got null source\n");
53 s.push_back(this_source);
57 vector<string> snames;
58 int err = input->
getInput(
"source names",snames);
60 for (
unsigned int j=0; j<snames.size(); j++) {
63 egsWarning(
"EGS_SourceCollection: got null source\n");
66 s.push_back(this_source);
71 egsWarning(
"EGS_SourceCollection: no sources\n");
74 vector<EGS_Float> prob;
75 err = input->
getInput(
"weights",prob);
77 egsWarning(
"EGS_SourceCollection: missing 'weights' input\n");
80 if (prob.size() != s.size()) {
81 egsWarning(
"EGS_SourceCollection: the number of sources (%d) is not"
82 " the same as the number of input probabilities (%d)\n",
83 s.size(),prob.size());
89 void EGS_SourceCollection::setUp(
const vector<EGS_BaseSource *> &S,
90 const vector<EGS_Float> &prob) {
91 otype =
"EGS_SourceCollection";
93 if (prob.size() < nsource) {
94 nsource = prob.size();
98 p =
new EGS_Float [nsource];
101 for (
int j=0; j<nsource; j++) {
105 if (
p[j] < 0)
egsWarning(
"EGS_SourceCollection: input "
106 "probability p[%d]=%g is less than zero.\n",j,
p[j]);
108 egsWarning(
"EGS_SourceCollection: source %d is null\n",j);
111 for (
int i=0; i<j; j++) {
127 for (
int i=0; i<nsource; i++) {
138 createSourceTemplate<EGS_SourceCollection>(input,f,
"source collection");
static EGS_BaseSource * createSource(EGS_Input *)
Create sources from the information pointed to by input.
EGS_Float Emax
Maximum energy (max of s[j]->getEmax()).
static void deleteObject(EGS_Object *o)
Delete an object.
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.
int ref()
Increase the reference count to this object.
EGS_InfoFunction EGS_EXPORT egsInformation
Always use this function for reporting the progress of a simulation and any other type of information...
A class for sampling random bins from a given probability distribution using the alias table techniqu...
static EGS_BaseSource * getSource(const string &Name)
Get a pointer to the source named Name.
EGS_BaseSource ** sources
The sources in the collection.
EGS_I64 * last_cases
Last case returned from each source.
EGS_Float * p
The probabilities.
string otype
The object type.
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.
string description
A short source description.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.