|
GammaLib 2.2.0.dev
|
COSI observation class. More...
#include <GCOSObservation.hpp>
Public Member Functions | |
| GCOSObservation (void) | |
| Void constructor. | |
| GCOSObservation (const GXmlElement &xml) | |
| XML constructor. | |
| GCOSObservation (const GFilename &eventname, const GFilename &spacename, const GFilename &rspname) | |
| Load constructor. | |
| GCOSObservation (const std::vector< GFilename > &eventnames, const GFilename &spacename, const GFilename &rspname) | |
| Load constructor. | |
| GCOSObservation (const GCOSObservation &obs) | |
| Copy constructor. | |
| virtual | ~GCOSObservation (void) |
| Destructor. | |
| virtual GCOSObservation & | operator= (const GCOSObservation &obs) |
| Assignment operator. | |
| virtual void | clear (void) |
| Clear COSI observation. | |
| virtual GCOSObservation * | clone (void) const |
| Clone COSI observation. | |
| virtual std::string | classname (void) const |
| Return class name. | |
| virtual void | response (const GResponse &rsp) |
| Set COSI response function. | |
| virtual const GCOSResponse * | response (void) const |
| Return pointer to response function. | |
| virtual std::string | instrument (void) const |
| Return instrument. | |
| virtual double | ontime (void) const |
| Return ontime. | |
| virtual double | livetime (void) const |
| Return livetime. | |
| virtual double | deadc (const GTime &time=GTime()) const |
| Return deadtime correction factor. | |
| virtual void | read (const GXmlElement &xml) |
| Read COSI observation from XML element. | |
| virtual void | write (GXmlElement &xml) const |
| Write COSI observation into XML element. | |
| virtual std::string | print (const GChatter &chatter=NORMAL) const |
| Print observation information. | |
| bool | is_unbinned (void) const |
| Check whether observation is unbinned. | |
| bool | is_binned (void) const |
| Check whether observation is binned. | |
| const GCOSSpaceCraft & | spacecraft (void) const |
| Return space craft information. | |
| void | ontime (const double &ontime) |
| Set ontime. | |
| void | livetime (const double &livetime) |
| Set livetime. | |
| void | deadc (const double &deadc) |
| Set deadtime correction factor. | |
| void | load (const GFilename &eventname, const GFilename &spacename, const GFilename &rspname) |
| Load data for an unbinned observation. | |
| void | load (const std::vector< GFilename > &eventnames, const GFilename &spacename, const GFilename &rspname) |
| Load data for an unbinned observation. | |
Public Member Functions inherited from GObservation | |
| GObservation (void) | |
| Void constructor. | |
| GObservation (const GObservation &obs) | |
| Copy constructor. | |
| virtual | ~GObservation (void) |
| Destructor. | |
| virtual GObservation & | operator= (const GObservation &obs) |
| Assignment operator. | |
| virtual GEvents * | events (void) |
| Return events. | |
| virtual const GEvents * | events (void) const |
| Return events (const version) | |
| virtual void | events (const GEvents &events) |
| Set event container. | |
| virtual double | likelihood (const GModels &models, GVector *gradients, GMatrixSparse *curvature, double *npred) const |
| Compute likelihood function. | |
| virtual double | model (const GModels &models, const GEvent &event, GVector *gradients=NULL) const |
| Return model value and (optionally) gradients. | |
| virtual GVector | model (const GModels &models, GMatrixSparse *gradients=NULL) const |
| Return vector of model values and (optionally) gradients. | |
| virtual double | nobserved (void) const |
| Return total number of observed events. | |
| virtual double | npred (const GModels &models, GVector *gradients=NULL) const |
| Return total number (and optionally gradients) of predicted counts for all models. | |
| virtual double | npred (const GModel &model) const |
| Return total number of predicted counts for one model. | |
| virtual double | model_grad (const GModel &model, const GModelPar &par, const GEvent &event) const |
| Returns parameter gradient of model for a given event. | |
| virtual GVector | model_grad (const GModel &model, const GModelPar &par) const |
| Returns parameter gradients of model for all events. | |
| virtual double | npred_grad (const GModel &model, const GModelPar &par) const |
| Returns parameter gradient of Npred. | |
| virtual void | remove_response_cache (const std::string &name) |
| Remove response cache for specific model. | |
| virtual double | grad_step_size (const GModelPar &par) const |
| Return gradient step size for a given model parameter. | |
| bool | has_events (void) const |
| Signal if observation has events. | |
| bool | has_gradient (const GModel &model, const GModelPar &par) const |
| Check whether a model parameter has an analytical gradient. | |
| void | name (const std::string &name) |
| Set observation name. | |
| void | id (const std::string &id) |
| Set observation identifier. | |
| void | statistic (const std::string &statistic) |
| Set optimizer statistic. | |
| const std::string & | name (void) const |
| Return observation name. | |
| const std::string & | id (void) const |
| Return observation identifier. | |
| const std::string & | statistic (void) const |
| Return optimizer statistic. | |
| void | computed_gradient (const GModel &model, const GModelPar &par) const |
| Signals that an analytical gradient was computed for a model parameter. | |
Public Member Functions inherited from GBase | |
| virtual | ~GBase (void) |
| Destructor. | |
Protected Member Functions | |
| void | init_members (void) |
| Initialise class members. | |
| void | copy_members (const GCOSObservation &obs) |
| Copy class members. | |
| void | free_members (void) |
| Delete class members. | |
Protected Member Functions inherited from GObservation | |
| void | init_members (void) |
| Initialise class members. | |
| void | copy_members (const GObservation &obs) |
| Copy class members. | |
| void | free_members (void) |
| Delete class members. | |
| virtual double | likelihood_poisson_unbinned (const GModels &models, GVector *gradients, GMatrixSparse *curvature, double *npred) const |
| Evaluate log-likelihood function for Poisson statistic and unbinned analysis (version with working arrays) | |
| virtual double | likelihood_poisson_binned (const GModels &models, GVector *gradients, GMatrixSparse *curvature, double *npred) const |
| Evaluate log-likelihood function for Poisson statistic and binned analysis (version with working arrays) | |
| virtual double | likelihood_gaussian_binned (const GModels &models, GVector *gradients, GMatrixSparse *curvature, double *npred) const |
| Evaluate log-likelihood function for Gaussian statistic and binned analysis (version with working arrays) | |
| virtual bool | use_event_for_likelihood (const int &index) const |
| Check whether bin should be used for likelihood analysis. | |
| virtual double | npred_spec (const GModel &model, const GTime &obsTime) const |
| Integrates spatially integrated Npred kernel spectrally. | |
Protected Attributes | |
| std::string | m_instrument |
| Instrument name. | |
| GCOSResponse | m_response |
| Response functions. | |
| GCOSSpaceCraft | m_spacecraft |
| Space craft information. | |
| double | m_ontime |
| Ontime (sec) | |
| double | m_livetime |
| Livetime (sec) | |
| double | m_deadc |
| Deadtime correction. | |
| std::vector< GFilename > | m_eventnames |
| Event list filenames. | |
| GFilename | m_spacename |
| Space craft filename. | |
| GFilename | m_rspname |
| Response filename. | |
Protected Attributes inherited from GObservation | |
| std::string | m_name |
| Observation name. | |
| std::string | m_id |
| Observation identifier. | |
| std::string | m_statistic |
| Optimizer statistic. | |
| GEvents * | m_events |
| Pointer to event container. | |
| std::vector< std::string > | m_pars_with_gradients |
COSI observation class.
The COSI observation class defines an observation.
Definition at line 57 of file GCOSObservation.hpp.
| GCOSObservation::GCOSObservation | ( | void | ) |
Void constructor.
Creates an empty COSI observation.
Definition at line 65 of file GCOSObservation.cpp.
References init_members().
Referenced by clone().
|
explicit |
XML constructor.
| [in] | xml | XML element. |
Constructs a COSI observation from the information that is found in an XML element. See the read() method for more information.
Definition at line 83 of file GCOSObservation.cpp.
References init_members(), and read().
| GCOSObservation::GCOSObservation | ( | const GFilename & | eventname, |
| const GFilename & | spacename, | ||
| const GFilename & | rspname ) |
Load constructor.
| [in] | eventname | Event list FITS file name. |
| [in] | spacename | Space craft file name. |
| [in] | rspname | Response file name. |
Creates an unbinned COSI observation by loading an event list, a space craft file and a response file.
Definition at line 106 of file GCOSObservation.cpp.
References init_members(), and load().
| GCOSObservation::GCOSObservation | ( | const std::vector< GFilename > & | eventnames, |
| const GFilename & | spacename, | ||
| const GFilename & | rspname ) |
Load constructor.
| [in] | eventnames | Vector of event list FITS file names. |
| [in] | spacename | Space craft file name. |
| [in] | rspname | Response file name. |
Creates an unbinned COSI observation by loading event lists, a space craft file and a response file. Multiple event lists are appended to each other and events are sorted by increasing time.
Definition at line 132 of file GCOSObservation.cpp.
References init_members(), and load().
| GCOSObservation::GCOSObservation | ( | const GCOSObservation & | obs | ) |
Copy constructor.
| [in] | obs | COSI observation. |
Creates COSI observation by copying from an existing COSI observation.
Definition at line 155 of file GCOSObservation.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GObservation.
Definition at line 132 of file GCOSObservation.hpp.
|
virtual |
Clear COSI observation.
Clears COSI observation by resetting all class members to an initial state. Any information that was present before will be lost.
Implements GObservation.
Definition at line 234 of file GCOSObservation.cpp.
References free_members(), GObservation::free_members(), init_members(), and GObservation::init_members().
|
virtual |
Clone COSI observation.
Implements GObservation.
Definition at line 254 of file GCOSObservation.cpp.
References GCOSObservation().
|
protected |
Copy class members.
| [in] | obs | COSI observation. |
Definition at line 612 of file GCOSObservation.cpp.
References m_deadc, m_eventnames, m_instrument, m_livetime, m_ontime, m_response, m_rspname, m_spacecraft, and m_spacename.
Referenced by GCOSObservation(), and operator=().
|
inline |
Set deadtime correction factor.
| [in] | deadc | Deadtime correction factor. |
Definition at line 273 of file GCOSObservation.hpp.
Return deadtime correction factor.
| [in] | time | Time. |
Implements GObservation.
Definition at line 198 of file GCOSObservation.hpp.
References m_deadc.
Referenced by deadc().
|
protected |
Delete class members.
Definition at line 635 of file GCOSObservation.cpp.
Referenced by clear(), operator=(), and ~GCOSObservation().
|
protected |
Initialise class members.
Definition at line 587 of file GCOSObservation.cpp.
References GCOSResponse::clear(), GCOSSpaceCraft::clear(), GFilename::clear(), m_deadc, m_eventnames, m_instrument, m_livetime, m_ontime, m_response, m_rspname, m_spacecraft, and m_spacename.
Referenced by clear(), GCOSObservation(), GCOSObservation(), GCOSObservation(), GCOSObservation(), GCOSObservation(), and operator=().
|
inlinevirtual |
Return instrument.
Implements GObservation.
Definition at line 157 of file GCOSObservation.hpp.
References m_instrument.
Referenced by print().
|
inline |
Check whether observation is binned.
Definition at line 223 of file GCOSObservation.hpp.
References GObservation::m_events.
Referenced by write().
|
inline |
Check whether observation is unbinned.
Definition at line 211 of file GCOSObservation.hpp.
References GObservation::m_events.
Referenced by write().
|
inline |
Set livetime.
| [in] | livetime | Livetime. |
Definition at line 260 of file GCOSObservation.hpp.
References livetime(), and m_livetime.
|
inlinevirtual |
Return livetime.
Implements GObservation.
Definition at line 183 of file GCOSObservation.hpp.
References m_livetime.
Referenced by livetime(), and print().
| void GCOSObservation::load | ( | const GFilename & | eventname, |
| const GFilename & | spacename, | ||
| const GFilename & | rspname ) |
Load data for an unbinned observation.
| [in] | eventname | Event list FITS file name. |
| [in] | spacename | Space craft file name. |
| [in] | rspname | Response file name. |
Loads the event list, space craft file and the response for an unbinned observation.
Definition at line 433 of file GCOSObservation.cpp.
References clear(), and load().
Referenced by GCOSObservation(), GCOSObservation(), load(), and read().
| void GCOSObservation::load | ( | const std::vector< GFilename > & | eventnames, |
| const GFilename & | spacename, | ||
| const GFilename & | rspname ) |
Load data for an unbinned observation.
| [in] | eventnames | Vector of event list FITS file names. |
| [in] | spacename | Space craft file name. |
| [in] | rspname | Response file name. |
| GException::invalid_argument | Empty event list name vector provided. |
Loads the event lists, space craft file and the response for an unbinned observation. Multiple event lists are appended to each other and events are sorted by increasing time.
The method uses the Good Time Intervals provided in the space craft file and attaches them to the event list. The method also sets the m_ontime, m_livetime and m_deadc members from the information provided by the space craft file.
The specified file names are stored in the m_eventnames, m_spacename and m_rspname class members which are used when writing the observation information into an XML element.
Definition at line 475 of file GCOSObservation.cpp.
References clear(), GCOSSpaceCraft::deadc(), GObservation::events(), G_LOAD, GCOSSpaceCraft::gti(), GEvents::gti(), GCOSSpaceCraft::livetime(), GCOSResponse::load(), GCOSSpaceCraft::load(), m_deadc, m_eventnames, GObservation::m_events, m_livetime, m_ontime, m_response, m_rspname, m_spacecraft, m_spacename, and GCOSSpaceCraft::ontime().
|
inline |
|
inlinevirtual |
Return ontime.
Implements GObservation.
Definition at line 170 of file GCOSObservation.hpp.
References m_ontime.
|
virtual |
Assignment operator.
| [in] | obs | COSI observation. |
Assign COSI observation to this object. The assignment performs a deep copy of all information, hence the original object from which the assignment was made can be destroyed after this operation without any loss of information.
Definition at line 198 of file GCOSObservation.cpp.
References copy_members(), free_members(), init_members(), and GObservation::operator=().
Print observation information.
| [in] | chatter | Chattiness. |
Implements GObservation.
Definition at line 540 of file GCOSObservation.cpp.
References instrument(), livetime(), m_deadc, GObservation::m_events, GObservation::name(), ontime(), gammalib::parformat(), GEvents::print(), gammalib::reduce(), SILENT, GObservation::statistic(), and gammalib::str().
|
virtual |
Read COSI observation from XML element.
| [in] | xml | XML element. |
Reads information for a COSI observation from an XML element. The method supports both an unbinned and a binned observation.
For an unbinned observation the XML format is
<observation name="Crab" id="00001" instrument="COS"> <parameter name="EventList" file="cosi_event_list.fits"/> <parameter name="SpaceCraftFile" file="cosi_orientation.ori"/> <parameter name="Response" file="cosi_response.h5"/> </observation>
The method supports the presence of multiple "EventList" entries which will load all specified event lists and merge them into a single event list. The events will be ordered by increasing time.
For a binned observation the XML format is
<observation name="Crab" id="00001" instrument="COS"> </observation>
Implements GObservation.
Definition at line 316 of file GCOSObservation.cpp.
References GXmlElement::attribute(), clear(), GXmlNode::element(), GXmlNode::elements(), G_READ, load(), GObservation::m_id, m_instrument, GObservation::m_name, gammalib::xml_file_expand(), gammalib::xml_get_attr(), and gammalib::xml_has_par().
Referenced by GCOSObservation().
|
virtual |
Set COSI response function.
| [in] | rsp | COSI response function. |
| GException::invalid_argument | Specified response is not a COSI response. |
Sets the response function for the observation.
Implements GObservation.
Definition at line 270 of file GCOSObservation.cpp.
References G_RESPONSE, m_response, and GObservation::name().
|
inlinevirtual |
Return pointer to response function.
Implements GObservation.
Definition at line 144 of file GCOSObservation.hpp.
References m_response.
|
inline |
Return space craft information.
Definition at line 235 of file GCOSObservation.hpp.
References m_spacecraft.
|
virtual |
Write COSI observation into XML element.
| [in] | xml | XML element. |
Writes information for a COSI observation into an XML element. The method supports both an unbinned and a binned observation.
For an unbinned observation the XML format is
<observation name="Crab" id="00001" instrument="COS"> <parameter name="EventList" file="cosi_event_list.fits"/> <parameter name="SpaceCraftFile" file="cosi_orientation.ori"/> <parameter name="Response" file="cosi_response.h5"/> </observation>
If multiple event lists were read by the read() method, the method will write back the file names of all the event lists.
For a binned observation the XML format is
<observation name="Crab" id="00001" instrument="COS"> </observation>
Implements GObservation.
Definition at line 389 of file GCOSObservation.cpp.
References GXmlNode::append(), GXmlElement::attribute(), G_WRITE, is_binned(), is_unbinned(), m_eventnames, m_rspname, m_spacename, gammalib::xml_file_reduce(), and gammalib::xml_need_par().
|
protected |
Deadtime correction.
Definition at line 115 of file GCOSObservation.hpp.
Referenced by copy_members(), deadc(), deadc(), init_members(), load(), and print().
|
protected |
Event list filenames.
Definition at line 120 of file GCOSObservation.hpp.
Referenced by copy_members(), init_members(), load(), and write().
|
protected |
Instrument name.
Definition at line 110 of file GCOSObservation.hpp.
Referenced by copy_members(), init_members(), instrument(), and read().
|
protected |
Livetime (sec)
Definition at line 114 of file GCOSObservation.hpp.
Referenced by copy_members(), init_members(), livetime(), livetime(), and load().
|
protected |
Ontime (sec)
Definition at line 113 of file GCOSObservation.hpp.
Referenced by copy_members(), init_members(), load(), ontime(), and ontime().
|
protected |
Response functions.
Definition at line 111 of file GCOSObservation.hpp.
Referenced by copy_members(), init_members(), load(), response(), and response().
|
protected |
Response filename.
Definition at line 122 of file GCOSObservation.hpp.
Referenced by copy_members(), init_members(), load(), and write().
|
protected |
Space craft information.
Definition at line 112 of file GCOSObservation.hpp.
Referenced by copy_members(), init_members(), load(), and spacecraft().
|
protected |
Space craft filename.
Definition at line 121 of file GCOSObservation.hpp.
Referenced by copy_members(), init_members(), load(), and write().