#include <CompositeSource.h>
Inheritance diagram for CompositeSource::

Public Methods | |
| CompositeSource (double aRate=1.0) | |
| constructor/destructor. More... | |
| virtual | ~CompositeSource () |
| virtual void | addSource (EventSource *aSource) |
| add a source to the list. More... | |
| void | rmvSource (EventSource *aSource) |
| virtual FluxSource * | event (double time) |
| generate an event from from one of the sources which make up the composite, and return a pointer to it. More... | |
| virtual double | rate (double time) const |
| rate - compute overall rate... More... | |
| virtual void | setRate (double) |
| virtual double | flux (double time) const |
| flux into 1 m^2 integrated over angles. More... | |
| virtual std::string | fullTitle () const |
| full-length title description of this EventSource. More... | |
| virtual std::string | displayTitle () const |
| brief title description (for display) for this event source. More... | |
| void | printOn (std::ostream &out) const |
| dump current list of sources, rates. More... | |
| std::string | findSource () const |
| say which source created the current particle. More... | |
| int | numSource () const |
| return a unique number correcponding to that spectrum. More... | |
| std::vector< EventSource * > & | sourceList () |
| list of sources which make up this composite. More... | |
| const std::vector< EventSource * > & | sourceList () const |
| void | sourceList (const std::vector< EventSource * > &value) |
| double | interval (double) |
| interval to the next event. More... | |
| double | setInterval (double interval) |
| set the interval to the next event. More... | |
| int | howManySources () |
| return how many sources are in the sourcelist. More... | |
Public Attributes | |
| double | m_interval |
| double m_time;. More... | |
Protected Methods | |
| virtual void | setupXML (const DOM_Element &) |
Protected Attributes | |
| int | m_numofiters |
| std::vector< EventSource * > | m_sourceList |
| std::vector< int > | m_unusedSource |
| std::vector< double > | m_sourceInterval |
| EventSource * | m_recent |
$Header $
Definition at line 21 of file CompositeSource.h.
|
|
constructor/destructor.
Definition at line 23 of file CompositeSource.cxx.
00024 : EventSource(aRate), m_recent(0),m_numofiters(0)//,m_time(0) 00025 { 00026 } |
|
|
Definition at line 28 of file CompositeSource.cxx. References m_sourceList.
00029 {
00030 for (std::vector<EventSource*>::iterator it = m_sourceList.begin();
00031 it != m_sourceList.end(); ++it ) delete (*it);
00032 }
|
|
|
add a source to the list.
Definition at line 35 of file CompositeSource.cxx. References flux(), m_sourceInterval, m_sourceList, m_unusedSource, EventSource::setFlux(), and EventSource::time(). Referenced by CompositeDiffuse::addNewSource(), and FluxMgr::getSourceFromXML().
00036 {
00037 m_sourceList.push_back(aSource);
00038 EventSource::setFlux( flux(EventSource::time()) );
00039 //here, set up the associated vectors by default.
00040 m_unusedSource.push_back(0);
00041 m_sourceInterval.push_back(-1.);
00042 }
|
|
|
brief title description (for display) for this event source.
Reimplemented from EventSource. Definition at line 131 of file CompositeSource.cxx. References EventSource::displayTitle(), and m_recent.
00132 {
00133 return (m_recent == 0) ? "" : m_recent->displayTitle();
00134 }
|
|
|
generate an event from from one of the sources which make up the composite, and return a pointer to it.
Reimplemented from EventSource. Reimplemented in CompositeDiffuse. Definition at line 56 of file CompositeSource.cxx. References m_numofiters, m_recent, m_sourceInterval, m_sourceList, m_unusedSource, rate(), setInterval(), EventSource::setTime(), and EventSource::time().
00057 {
00058 int i=0; //for iterating through the m_unusedSource vector
00059 int winningsourcenum; //the number of the "winning" source
00060
00061 EventSource::setTime(time);
00062
00063 m_numofiters=0;
00064 double mr = rate(EventSource::time());
00065
00066 if( m_sourceList.size()==1 || mr ==0) {
00067 m_recent = m_sourceList.front();
00068 }else {
00069
00070 // more than one:: choose on basis of relative rates
00071 // NOT used? THB double x = RandFlat::shoot(mr), y = 0;
00072 std::vector<EventSource*>::iterator now = m_sourceList.begin();
00073 std::vector<EventSource*>::iterator it = now;
00074
00075 double intrval=0.,intrmin=100000.;
00076 for (int q=0 ; now != m_sourceList.end(); ++now) {
00077 if(m_unusedSource[i]==1){
00078 intrval=m_sourceInterval[i];
00079 //std::cout << i << " is unused, interval is "<< intrval << std::endl;
00080 }else{
00081 (*now)->event(time); // to initialize particles, so that the real interval for the particle is gotten.
00082 intrval=(*now)->interval(EventSource::time()); //this picks out the interval of each source
00083 m_unusedSource[i]=1;
00084 m_sourceInterval[i]=intrval;
00085 }
00086
00087 if(intrval < intrmin){
00088 //the present source is "winning" here
00089 it=now;
00090 intrmin=intrval;
00091 m_numofiters=q;
00092 winningsourcenum=i;
00093 }
00094
00095 m_recent = (*it);
00096 q++;
00097 i++;
00098 }
00099 setInterval(intrmin);
00100 now = m_sourceList.begin();
00101 for (q=0 ; now != m_sourceList.end(); ++now) {
00102 //this loop sets the intervals back in accordance with
00103 //how far ahead time will move.
00104 //std::cout << "decrementing source " << q << " , by " << intrmin << std::endl;
00105 m_sourceInterval[q] = m_sourceInterval[q] - intrmin;
00106 q++;
00107 }
00108 }
00109 m_unusedSource[winningsourcenum]=0; //the current "winning" source is getting used..
00110 // now ask the chosen one to return the event.
00111 return (FluxSource*)m_recent;
00112 }
|
|
|
say which source created the current particle.
Reimplemented from EventSource. Definition at line 181 of file CompositeSource.cxx.
|
|
|
flux into 1 m^2 integrated over angles.
Reimplemented from EventSource. Definition at line 41 of file CompositeSource.h. References rate(), EventSource::time(), and EventSource::totalArea(). Referenced by addSource(), and rmvSource().
|
|
|
full-length title description of this EventSource.
Reimplemented from EventSource. Definition at line 114 of file CompositeSource.cxx. References m_sourceList. Referenced by CompositeDiffuse::writeSourceCharacteristic().
00115 {
00116 std::strstream s;
00117 std::vector<EventSource*>::const_iterator it = m_sourceList.begin();
00118
00119 while (it != m_sourceList.end()) {
00120
00121 s << (*it)->fullTitle() << " ";
00122 ++it;
00123 if (it != m_sourceList.end()) s << "+ ";
00124 }
00125 s << '\0';
00126 std::string t(s.str());
00127 s.freeze(false);
00128 return t;
00129 }
|
|
|
return how many sources are in the sourcelist.
Reimplemented from EventSource. Definition at line 75 of file CompositeSource.h. References m_sourceList.
00075 {return m_sourceList.size();}
|
|
|
interval to the next event.
Reimplemented from EventSource. Definition at line 66 of file CompositeSource.h. References m_interval. Referenced by setInterval().
00066 {return m_interval;}
|
|
|
return a unique number correcponding to that spectrum.
Reimplemented from EventSource. Definition at line 186 of file CompositeSource.cxx.
00187 {
00189 return m_numofiters;
00190 }
|
|
|
dump current list of sources, rates.
Definition at line 167 of file CompositeSource.cxx. References EventSource::time().
00168 {
00169 out << "Source(s), total rate="<< rate(EventSource::time()) << std::endl;
00170
00171 for( std::vector<EventSource*>::const_iterator it = m_sourceList.begin();
00172 it != m_sourceList.end();++it) {
00173 out << std::setw(8) << std::setprecision(4) << (*it)->rate(EventSource::time()) <<" Hz, "
00174 << '#' << std::setw(6) << (*it)->eventNumber() <<' '
00175 << (*it)->name() << ' '<< (*it)->fullTitle() << std::endl;
00176
00177 }
00178
00179 }
|
|
|
rate - compute overall rate...
Reimplemented from EventSource. Definition at line 136 of file CompositeSource.cxx. References m_sourceList, and EventSource::time(). Referenced by event(), flux(), and setRate().
00137 {
00138 //m_time += m_time-time;
00139 std::vector<EventSource*>::const_iterator it = m_sourceList.begin();
00140 double total_rate = 0.;
00141 for(;it != m_sourceList.end();++it) {
00142 double rr = fabs((*it)->rate(time));
00143 total_rate += rr;
00144 }
00145 return total_rate;
00146 }
|
|
|
Definition at line 44 of file CompositeSource.cxx. References flux(), m_sourceList, EventSource::setFlux(), and EventSource::time().
00045 {
00046 std::vector<EventSource*>::iterator it = m_sourceList.begin();
00047 for (;it != m_sourceList.end(); ++it) {
00048 if ((*it) == aSource) break;
00049 }
00050 if (it != m_sourceList.end()) {
00051 m_sourceList.erase(it);
00052 EventSource::setFlux( flux(EventSource::time()) );
00053 }
00054 }
|
|
|
set the interval to the next event.
Definition at line 69 of file CompositeSource.h. References interval(), and m_interval. Referenced by event(), and CompositeDiffuse::event().
00069 {return (m_interval = interval);}
|
|
|
Reimplemented from EventSource. Definition at line 148 of file CompositeSource.cxx. References m_sourceList, rate(), EventSource::setRate(), and EventSource::time().
00149 {
00150 double f = rate(EventSource::time());
00151 if (f == 0.) return;
00152
00153 std::vector<float> fvec;
00154 std::vector<EventSource*>::iterator it = m_sourceList.begin();
00155
00156 while (it != m_sourceList.end()) {
00157
00158 (*it)->setRate( value * (*it)->rate(EventSource::time())/f );
00159 ++it;
00160 }
00161 EventSource::setRate( value );
00162 }
|
|
|
Definition at line 165 of file CompositeSource.cxx.
00165 {}
|
|
|
Definition at line 104 of file CompositeSource.h. References m_sourceList.
00105 {
00106 m_sourceList = value;
00107 }
|
|
|
Definition at line 99 of file CompositeSource.h. References m_sourceList.
00100 {
00101 return m_sourceList;
00102 }
|
|
|
list of sources which make up this composite.
Definition at line 94 of file CompositeSource.h. References m_sourceList.
00095 {
00096 return m_sourceList;
00097 }
|
|
|
double m_time;.
Definition at line 72 of file CompositeSource.h. Referenced by interval(), and setInterval(). |
|
|
Definition at line 83 of file CompositeSource.h. Referenced by event(), and CompositeDiffuse::event(). |
|
|
Definition at line 91 of file CompositeSource.h. Referenced by displayTitle(), event(), and CompositeDiffuse::event(). |
|
|
Definition at line 90 of file CompositeSource.h. |
|
|
Definition at line 86 of file CompositeSource.h. Referenced by addSource(), event(), CompositeDiffuse::event(), fullTitle(), howManySources(), rate(), rmvSource(), setRate(), sourceList(), and ~CompositeSource(). |
|
|
Definition at line 88 of file CompositeSource.h. |
1.2.13.1 written by Dimitri van Heesch,
© 1997-2001