Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

EventSource Class Reference

Interface to the EventSource class. Provides a generic interface to what Glastsim uses as a data source. This can constitute GISMO based event generation, reading in from a file, etc... More...

#include <EventSource.h>

Inheritance diagram for EventSource::

CompositeSource FluxSource CompositeDiffuse List of all members.

Public Methods

 EventSource (double aFlux=1.0, unsigned acode=0)
 ctor/dtor. More...

 EventSource (const DOM_Element &xelem)
virtual ~EventSource ()
virtual double interval (double)=0
 a randomized interval to the next event - default is 1/rate(). More...

virtual double rate (double time) const
 calculate the rate for a given flux/solid angle integral (NOTE: integral of solid angle). More...

virtual void setRate (double)
virtual FluxSourceevent (double)=0
 abstract method - create an event. More...

virtual std::string fullTitle () const
 UI titles - used for tuple header (verbose) or window title (display). More...

virtual std::string displayTitle () const
virtual double flux (double time) const
 flux for this source in (p/(m^2*sr*sec)). More...

virtual void setFlux (double value)
void disable ()
 disable/enable, test this particular source. More...

void enable ()
bool enabled () const
virtual double solidAngle () const
 integral of solid angle over which flux is incident. More...

void solidAngle (double)
const std::string & name () const
 name of this flux source - for UI. More...

void name (const std::string &value)
unsigned code () const
 code - for monte-carlo study. More...

virtual void code (unsigned)
virtual OrbitmakeOrbit () const
 makeOrbit - creates an orbit appropriate for this source. More...

virtual int eventNumber () const
 virtual event number: should be filled in by subclass. More...

virtual std::string findSource () const
 say which source created the current particle. More...

virtual int numSource () const
 return a unique number correcponding to that spectrum. More...

virtual double time () const
virtual void setTime (double time)
virtual int howManySources ()
virtual void writeSourceCharacteristic (std::ostream &out)
 write the characteristics of the current source distribution to a stream. More...


Static Public Methods

double totalArea ()
 area. More...

void totalArea (double value)

Private Attributes

double m_time
bool m_enabled
double m_flux
double m_solid_angle
std::string m_name
unsigned m_code

Static Private Attributes

unsigned int s_id = 0
double s_total_area = 6.

Detailed Description

Interface to the EventSource class. Provides a generic interface to what Glastsim uses as a data source. This can constitute GISMO based event generation, reading in from a file, etc...

$Header $

Definition at line 27 of file EventSource.h.


Constructor & Destructor Documentation

EventSource::EventSource double    aFlux = 1.0,
unsigned    acode = 0
 

ctor/dtor.

Definition at line 16 of file EventSource.cxx.

References code(), m_name, and s_id.

00017 :  m_enabled(true), m_flux(aFlux), m_solid_angle(1.), m_code(acode)
00018 {
00019     std::strstream  s;
00020     
00021     s << "Source_" << (++s_id) << '\0';
00022     if (acode == 0) code(s_id); // automatically assign event codes...
00023     
00024     m_name = s.str();
00025     s.freeze(false);
00026 }

EventSource::EventSource const DOM_Element &    xelem
 

Definition at line 28 of file EventSource.cxx.

References m_code, m_flux, m_name, m_solid_angle, and s_id.

00029 :  m_enabled(true), m_flux(1.0), m_solid_angle(1.), m_code(0)
00030 {
00031     m_name = xml::Dom::getAttribute(xelem, "name");
00032     m_flux = atof (xml::Dom::getAttribute(xelem, "flux").c_str());
00033     
00034     std::string code_str = xml::Dom::getAttribute(xelem, "code");
00035     if (code_str != std::string("")) {
00036         m_code = atoi(code_str.c_str());
00037     }
00038     else  {
00039         m_code = ++s_id;
00040     }
00041     
00042     // this is set by default to be overriden when the solid_angle 
00043     // element is present...
00044     DOM_Element   angles = 
00045         xml::Dom::findFirstChildByName(xelem, "solid_angle");
00046     
00047     if (angles != DOM_Element()) {
00048         double  mincos = atof(xml::Dom::getAttribute(angles, "mincos").c_str());
00049         double  maxcos = atof(xml::Dom::getAttribute(angles, "maxcos").c_str());
00050         
00051         m_solid_angle = (maxcos - mincos)*2*M_PI;
00052     }
00053     else if (xml::Dom::findFirstChildByName(xelem, "direction") != DOM_Element())
00054         m_solid_angle = 1.;
00055 }

EventSource::~EventSource   [virtual]
 

Definition at line 58 of file EventSource.cxx.

00059 {}


Member Function Documentation

void EventSource::code unsigned    c [inline, virtual]
 

Definition at line 127 of file EventSource.h.

References m_code.

00127 { m_code = c; }

unsigned EventSource::code   const [inline]
 

code - for monte-carlo study.

Definition at line 126 of file EventSource.h.

References m_code.

Referenced by EventSource().

00126 { return m_code; }

void EventSource::disable   [inline]
 

disable/enable, test this particular source.

Definition at line 55 of file EventSource.h.

References m_enabled.

00055 {m_enabled=false;}

std::string EventSource::displayTitle   const [virtual]
 

Reimplemented in FluxSource, and CompositeSource.

Definition at line 96 of file EventSource.cxx.

References m_name.

Referenced by FluxSource::displayTitle(), and CompositeSource::displayTitle().

00096 {  return m_name; }

void EventSource::enable   [inline]
 

Definition at line 56 of file EventSource.h.

References m_enabled.

00056 {m_enabled=true;}

bool EventSource::enabled   const [inline]
 

Definition at line 57 of file EventSource.h.

References m_enabled.

Referenced by FluxSource::flux().

00057 {return m_enabled;}

virtual FluxSource* EventSource::event double    time [pure virtual]
 

abstract method - create an event.

Reimplemented in FluxSource, CompositeDiffuse, and CompositeSource.

Referenced by Flux::generate(), rootplot::rootplot(), and FluxMgr::test().

virtual int EventSource::eventNumber   const [inline, virtual]
 

virtual event number: should be filled in by subclass.

Reimplemented in FluxSource.

Definition at line 79 of file EventSource.h.

00079 {return -1;} 

virtual std::string EventSource::findSource   const [inline, virtual]
 

say which source created the current particle.

Reimplemented in CompositeSource.

Definition at line 82 of file EventSource.h.

00082 {return "";}

double EventSource::flux double    time const [virtual]
 

flux for this source in (p/(m^2*sr*sec)).

Reimplemented in FluxSource, and CompositeSource.

Definition at line 61 of file EventSource.cxx.

References m_flux.

Referenced by FluxSource::flux(), and rootplot::rootplot().

00062 {
00063   // Purpose and Method: This method returns the flux of the particular source.
00064   // Inputs  - current time
00065   // Outputs - flux, in units of (particles/(m^2*sr*sec))
00066     return m_flux;  // default if not overridden
00067 }

std::string EventSource::fullTitle   const [virtual]
 

UI titles - used for tuple header (verbose) or window title (display).

Reimplemented in FluxSource, and CompositeSource.

Definition at line 94 of file EventSource.cxx.

Referenced by FluxMgr::test(), and writeSourceCharacteristic().

00095 { return std::string("EventSource");   }

virtual int EventSource::howManySources   [inline, virtual]
 

Reimplemented in CompositeSource.

Definition at line 93 of file EventSource.h.

Referenced by FluxMgr::test().

00093 {return 1;}

virtual double EventSource::interval double    [pure virtual]
 

a randomized interval to the next event - default is 1/rate().

Reimplemented in FluxSource, and CompositeSource.

Referenced by Flux::generate(), and FluxMgr::test().

Orbit * EventSource::makeOrbit   const [virtual]
 

makeOrbit - creates an orbit appropriate for this source.

Definition at line 87 of file EventSource.cxx.

00088 {
00089     return new Orbit;
00090 }

void EventSource::name const std::string &    value [inline]
 

Definition at line 121 of file EventSource.h.

References m_name.

00121 { m_name = value;   }

const std::string & EventSource::name   const [inline]
 

name of this flux source - for UI.

Definition at line 120 of file EventSource.h.

References m_name.

Referenced by CompositeDiffuse::fillTable(), and Flux::name().

00120 {   return m_name;  }

virtual int EventSource::numSource   const [inline, virtual]
 

return a unique number correcponding to that spectrum.

Reimplemented in CompositeSource.

Definition at line 86 of file EventSource.h.

Referenced by FluxMgr::test().

00086 {return -1;}

double EventSource::rate double    time const [virtual]
 

calculate the rate for a given flux/solid angle integral (NOTE: integral of solid angle).

Reimplemented in CompositeSource.

Definition at line 74 of file EventSource.cxx.

Referenced by rootplot::rootplot(), setRate(), and FluxMgr::test().

00075 {
00076   // Purpose and Method: This method returns the rate of particles entering the detector.
00077   // Inputs  - current time
00078   // Outputs - rate, in units of (particles/sec)
00079     return enabled()? (solidAngle()*flux(time)*s_total_area) :0;
00080 }

void EventSource::setFlux double    value [virtual]
 

Definition at line 69 of file EventSource.cxx.

References m_flux.

Referenced by CompositeSource::addSource(), CompositeSource::rmvSource(), and setRate().

00069                                          {
00070     m_flux = value;
00071 }

void EventSource::setRate double    value [virtual]
 

Reimplemented in CompositeSource.

Definition at line 82 of file EventSource.cxx.

References m_solid_angle, rate(), s_total_area, and setFlux().

Referenced by CompositeSource::setRate().

00083 {
00084     setFlux(  rate/(m_solid_angle*s_total_area) );
00085 }

virtual void EventSource::setTime double    time [inline, virtual]
 

Definition at line 89 of file EventSource.h.

References m_time, and time().

Referenced by FluxSource::event(), CompositeSource::event(), and CompositeDiffuse::event().

00089 {m_time=time;}

void EventSource::solidAngle double    value [inline]
 

Definition at line 118 of file EventSource.h.

References m_solid_angle.

00118 { m_solid_angle = value; }

double EventSource::solidAngle   const [inline, virtual]
 

integral of solid angle over which flux is incident.

Reimplemented in FluxSource.

Definition at line 117 of file EventSource.h.

References m_solid_angle.

Referenced by CompositeDiffuse::remainingFluxInterval(), FluxSource::setAcceptance(), and FluxSource::solidAngle().

00117 { return m_solid_angle; }

virtual double EventSource::time   const [inline, virtual]
 

Definition at line 88 of file EventSource.h.

References m_time.

Referenced by CompositeSource::addSource(), FluxSource::calculateInterval(), FluxSource::computeLaunch(), FluxSource::event(), CompositeSource::event(), CompositeDiffuse::event(), FluxSource::flux(), CompositeSource::flux(), CompositeSource::printOn(), CompositeSource::rate(), CompositeSource::rmvSource(), CompositeSource::setRate(), setTime(), FluxSource::spectrum(), and CompositeDiffuse::~CompositeDiffuse().

00088 {return m_time;}

void EventSource::totalArea double    value [inline, static]
 

Definition at line 124 of file EventSource.h.

References s_total_area.

00124 { s_total_area = value; }

double EventSource::totalArea   [inline, static]
 

area.

Definition at line 123 of file EventSource.h.

References s_total_area.

Referenced by CompositeSource::flux(), rootplot::rootplot(), FluxSource::setAcceptance(), Flux::setTargetArea(), and FluxMgr::test().

00123 { return s_total_area; }

virtual void EventSource::writeSourceCharacteristic std::ostream &    out [inline, virtual]
 

write the characteristics of the current source distribution to a stream.

Reimplemented in CompositeDiffuse.

Definition at line 96 of file EventSource.h.

References fullTitle().

Referenced by Flux::writeSourceCharacteristic().

00096                                                            {
00097         out << fullTitle() << std::endl;
00098         out<< "default message - no sources" << std::endl;
00099     }


Member Data Documentation

unsigned EventSource::m_code [private]
 

Definition at line 109 of file EventSource.h.

Referenced by code(), and EventSource().

bool EventSource::m_enabled [private]
 

Definition at line 105 of file EventSource.h.

Referenced by disable(), enable(), and enabled().

double EventSource::m_flux [private]
 

Definition at line 106 of file EventSource.h.

Referenced by EventSource(), flux(), and setFlux().

std::string EventSource::m_name [private]
 

Definition at line 108 of file EventSource.h.

Referenced by displayTitle(), EventSource(), and name().

double EventSource::m_solid_angle [private]
 

Definition at line 107 of file EventSource.h.

Referenced by EventSource(), setRate(), and solidAngle().

double EventSource::m_time [private]
 

Definition at line 103 of file EventSource.h.

Referenced by setTime(), and time().

unsigned int EventSource::s_id = 0 [static, private]
 

Definition at line 13 of file EventSource.cxx.

Referenced by EventSource().

double EventSource::s_total_area = 6. [static, private]
 

Definition at line 14 of file EventSource.cxx.

Referenced by setRate(), and totalArea().


The documentation for this class was generated from the following files:
Generated on Wed Oct 16 14:01:32 2002 by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001