GammaLib 2.1.0.dev
|
Abstract observation base class. More...
#include <GObservation.hpp>
Classes | |
class | model_func |
class | npred_func |
class | npred_kern |
class | npred_spec_kern |
Public Member Functions | |
GObservation (void) | |
Void constructor. | |
GObservation (const GObservation &obs) | |
Copy constructor. | |
virtual | ~GObservation (void) |
Destructor. | |
virtual GObservation & | operator= (const GObservation &obs) |
Assignment operator. | |
virtual void | clear (void)=0 |
Clear object. | |
virtual GObservation * | clone (void) const =0 |
Clones object. | |
virtual std::string | classname (void) const =0 |
Return class name. | |
virtual void | response (const GResponse &rsp)=0 |
virtual const GResponse * | response (void) const =0 |
virtual std::string | instrument (void) const =0 |
virtual double | ontime (void) const =0 |
virtual double | livetime (void) const =0 |
virtual double | deadc (const GTime &time=GTime()) const =0 |
virtual void | read (const GXmlElement &xml)=0 |
virtual void | write (GXmlElement &xml) const =0 |
virtual std::string | print (const GChatter &chatter=NORMAL) const =0 |
Print content of object. | |
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 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_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 |
Abstract observation base class.
This class provides an abstract interface for an observation. The observation collects information about the instrument, holds the measured events, and provides information about the analysis definition.
The response() method returns a pointer to the response function. The derived classes have to make sure that this method never returns NULL.
The method model() returns the probability for an event to be measured with a given instrument direction, a given energy and at a given time, given a source model and an instrument pointing direction. The method npred() returns the total number of expected events within the analysis region for a given source model and a given instrument pointing direction. The methods are defined as virtual and can be overloaded by derived classes that implement instrument specific observations in order to optimize the execution speed for data analysis.
Definition at line 70 of file GObservation.hpp.
GObservation::GObservation | ( | void | ) |
GObservation::GObservation | ( | const GObservation & | obs | ) |
Copy constructor.
[in] | obs | Observation. |
Instantiate the class by copying from an existing observation.
Definition at line 101 of file GObservation.cpp.
References copy_members(), and init_members().
|
virtual |
|
pure virtual |
Return class name.
Returns the class name for non-abstract classes in a human readable way.
Implements GBase.
Implemented in GCOMObservation, GCTAObservation, GCTAOnOffObservation, GLATObservation, GMWLObservation, and GSPIObservation.
|
pure virtual |
Clear object.
Sets the object to a clean initial state. After calling the method the object will be in the same state as it were if an empty instance of the object would have been created.
Implements GBase.
Implemented in GCOMObservation, GCTAObservation, GCTAOnOffObservation, GLATObservation, GMWLObservation, and GSPIObservation.
|
pure virtual |
Clones object.
Creates a deep copy of the object and returns a pointer to the object.
Implements GBase.
Implemented in GCOMObservation, GCTAObservation, GCTAOnOffObservation, GLATObservation, GMWLObservation, and GSPIObservation.
Referenced by GObservationRegistry::alloc(), GObservations::append(), GObservations::insert(), and GObservations::set().
Signals that an analytical gradient was computed for a model parameter.
[in] | model | Model. |
[in] | par | Model parameter. |
Signals that an analytical gradient was computed for a model parameter.
Definition at line 1272 of file GObservation.cpp.
References m_pars_with_gradients, model(), and GOptimizerPar::name().
Referenced by GModelData::eval(), GSPIModelDataSpace::eval(), GCTAResponseCube::irf_radial(), and GModelSky::signal_analytical_gradients().
|
protected |
Copy class members.
[in] | obs | Observation. |
Copy members from an observation.
Definition at line 1336 of file GObservation.cpp.
References GEvents::clone(), m_events, m_id, m_name, m_pars_with_gradients, and m_statistic.
Referenced by GObservation(), and operator=().
Implemented in GCOMObservation, GCTAObservation, GCTAOnOffObservation, GLATObservation, GMWLObservation, and GSPIObservation.
Referenced by GCOMResponse::irf(), GCTAResponseIrf::irf(), GCTAResponseIrf::irf_diffuse(), GCTAResponseIrf::irf_elliptical(), GCTAResponseIrf::irf_radial(), GCTAResponseIrf::mc(), and GCTAResponseIrf::nirf().
|
virtual |
Set event container.
[in] | events | Event container. |
Set the event container for this observation by cloning the container specified in the argument.
Definition at line 218 of file GObservation.cpp.
References GEvents::clone(), events(), and m_events.
|
virtual |
Return events.
GException::no_events | No events allocated for observation. |
Returns pointer to events.
Definition at line 176 of file GObservation.cpp.
References G_EVENTS, and m_events.
Referenced by GCOMObservation::compute_drb_bgdlixa(), GCOMObservation::compute_drb_bgdlixe(), GCOMObservation::compute_drb_bgdlixf(), GCOMObservation::compute_drb_phinor(), GCOMDri::compute_dre(), GCOMDris::compute_drws(), GResponse::convolve(), gammalib::cta_event_cube(), gammalib::cta_event_list(), GModelData::eval(), GModels::eval(), GSPIModelDataSpace::eval(), GResponse::eval_probs(), events(), GCTAModelSpatialLookup::fill_buffer(), GSPIModelDataSpace::GSPIModelDataSpace(), GCOMResponse::irf(), GSPIResponse::irf(), GResponse::irf_composite(), GCOMResponse::irf_diffuse(), GResponse::irf_diffuse(), GSPIResponse::irf_diffuse(), GSPIResponse::irf_diffuse_map(), GCOMResponse::irf_elliptical(), GResponse::irf_elliptical(), GSPIResponse::irf_elliptical(), GSPIResponse::irf_init(), GCOMResponse::irf_ptsrc(), GResponse::irf_ptsrc(), GSPIResponse::irf_ptsrc(), GCOMResponse::irf_radial(), GCTAResponseCube::irf_radial(), GResponse::irf_radial(), GSPIResponse::irf_radial(), GCTAResponseCube::irf_spatial(), GResponse::irf_spatial(), likelihood(), likelihood_gaussian_binned(), likelihood_poisson_binned(), likelihood_poisson_unbinned(), GCTAObservation::load(), GCTAObservation::load(), GLATObservation::load_binned(), GLATObservation::load_unbinned(), GCTAModelRadialAcceptance::mc(), model(), model_grad(), GCOMObservation::npred(), npred(), npred_spec(), GCTAObservation::read(), GCTAObservation::read(), GSPIObservation::read(), GCTAOnOffObservation::set(), GLATMeanPsf::set(), GSPIResponse::set(), GLATMeanPsf::set_map_corrections(), GSPIModelDataSpace::setup(), GCTAObservation::write(), GCTAObservation::write(), and GCTAObservation::write_attributes().
|
virtual |
Return events (const version)
GException::no_events | No events allocated for observation. |
Returns const pointer to events.
Definition at line 197 of file GObservation.cpp.
|
protected |
Delete class members.
Definition at line 1357 of file GObservation.cpp.
References m_events.
Referenced by GCOMObservation::clear(), GCTAObservation::clear(), GLATObservation::clear(), GMWLObservation::clear(), GSPIObservation::clear(), operator=(), and ~GObservation().
|
inlinevirtual |
Return gradient step size for a given model parameter.
[in] | par | Model parameter |
Returns the step size that is used for numerical gradient computation for a given model parameter par
.
The step size is fixed to a value of 0.0002, which for spatial parameters corresponds to an angular resolution of about 1 arcsec. Parameters that need numerical gradient computations are typical angles, hence fixing this value to an accuracy of 1 arcsec should be more than sufficient for all considered cases.
Note, however, that numerical precision issues may occur ata this angular resolution, and depending on how the response is computed for a given instrument, the instrument specific interface may overload this parameter by different values.
Reimplemented in GCOMObservation, and GSPIObservation.
Definition at line 347 of file GObservation.hpp.
Referenced by model_grad(), model_grad(), and npred_grad().
|
inline |
Signal if observation has events.
Definition at line 239 of file GObservation.hpp.
References m_events.
Check whether a model parameter has an analytical gradient.
[in] | model | Model. |
[in] | par | Model parameter. |
Checks whether a model parameter is free and has an analytical gradient.
Definition at line 1236 of file GObservation.cpp.
References has_gradient(), GOptimizerPar::is_free(), m_pars_with_gradients, model(), and GOptimizerPar::name().
Referenced by has_gradient(), model(), and model().
|
inline |
Set observation identifier.
[in] | id | Observation identifier. |
Set identifier of the observation.
Definition at line 268 of file GObservation.hpp.
Referenced by GObservations::append(), gammalib::cta_obs(), gammalib::cta_rsp_irf(), GModels::eval(), GModels::eval(), GCTACubeBackground::fill(), GCTACubeEdisp::fill(), GCTACubeExposure::fill(), GCTACubePsf::fill(), GCTACubeEdisp::fill_cube(), GCTACubeExposure::fill_cube(), GCTACubePsf::fill_cube(), GObservations::insert(), GCOMResponse::irf_ptsrc(), GCTAResponseCube::irf_spatial(), GResponse::irf_spatial(), GResponse::irf_spatial(), GCTAModelAeffBackground::npred(), GCTAModelCubeBackground::npred(), GCTAModelIrfBackground::npred(), GCTAModelSkyCube::npred(), GCTAResponseIrf::nroi(), GObservations::read(), GCTAOnOffObservation::set(), and GObservations::set().
|
inline |
Return observation identifier.
Definition at line 308 of file GObservation.hpp.
References m_id.
Referenced by GCOMObservation::compute_drb_bgdlixa(), GCOMObservation::compute_drb_bgdlixe(), GCOMObservation::compute_drb_bgdlixf(), GCOMObservation::compute_drb_phinor(), id(), GMWLObservation::load(), GCOMObservation::obs_id(), GCTAObservation::read_attributes(), and remove_response_cache().
|
protected |
Initialise class members.
The step size for gradient computation is fixed by default to 0.0002 degrees, which corresponds to about 1 arcsec for parameters that are given in degrees. The reasoning behind this value is that parameters that use numerical gradients are typically angles, such as for example the position, and we want to achieve arcsec precision with this method.
Definition at line 1313 of file GObservation.cpp.
References m_events, m_id, m_name, m_pars_with_gradients, and m_statistic.
Referenced by GCOMObservation::clear(), GCTAObservation::clear(), GLATObservation::clear(), GMWLObservation::clear(), GSPIObservation::clear(), GObservation(), GObservation(), and operator=().
|
pure virtual |
Implemented in GCOMObservation, GCTAObservation, GCTAOnOffObservation, GLATObservation, GMWLObservation, and GSPIObservation.
Referenced by GObservations::append(), GResponse::convolve(), GResponse::convolve(), GResponse::edisp_kerns::edisp_kerns(), GModels::eval(), GModels::eval(), GResponse::eval_prob(), GResponse::eval_probs(), GObservations::insert(), model(), model(), GCTAModelAeffBackground::npred(), GCTAModelCubeBackground::npred(), GCTAModelIrfBackground::npred(), GCTAModelSkyCube::npred(), npred(), npred(), GCTAResponseIrf::nroi(), GObservations::set(), GModelSky::signal_analytical_gradients(), and GResponse::size_edisp_vector().
|
virtual |
Compute likelihood function.
[in] | models | Models. |
[in,out] | gradients | Pointer to gradients. |
[in,out] | curvature | Pointer to curvature matrix. |
[in,out] | npred | Pointer to Npred value. |
Computes the likelihood for a specified set of models. The method also returns the gradients, the curvature matrix, and the number of events that are predicted by all models.
Reimplemented in GCTAOnOffObservation.
Definition at line 247 of file GObservation.cpp.
References events(), G_LIKELIHOOD, likelihood_gaussian_binned(), likelihood_poisson_binned(), likelihood_poisson_unbinned(), npred(), statistic(), and gammalib::toupper().
|
protectedvirtual |
Evaluate log-likelihood function for Gaussian statistic and binned analysis (version with working arrays)
[in] | models | Models. |
[in,out] | gradients | Gradient. |
[in,out] | curvature | Curvature matrix. |
[in,out] | npred | Number of predicted events. |
This method evaluates the -(log-likelihood) function for parameter optimisation using binned analysis and Poisson statistic. The -(log-likelihood) function is given by
\[ L = 1/2 \sum_i (n_i - e_i)^2 \sigma_i^{-2} \]
where the sum is taken over all data space bins, \(n_i\) is the observed number of counts, \(e_i\) is the model and \(\sigma_i\) is the statistical uncertainty. This method also computes the parameter gradients \(\delta L/dp\) and the curvature matrix \(\delta^2 L/dp_1 dp_2\) and also updates the total number of predicted events m_npred.
Definition at line 1795 of file GObservation.cpp.
References GMatrixSparse::add_to_column(), GMatrixSparse::column_to_vector(), GEventBin::counts(), GVectorSparse::data(), GVectorSparse::elements(), GEventBin::error(), events(), GVectorSparse::inx(), gammalib::is_infinite(), minerr, minmod, model(), npred(), GEventBin::size(), GEvents::size(), GVector::size(), GMatrixSparse::transpose(), and use_event_for_likelihood().
Referenced by likelihood().
|
protectedvirtual |
Evaluate log-likelihood function for Poisson statistic and binned analysis (version with working arrays)
[in] | models | Models. |
[in,out] | gradients | Gradient. |
[in,out] | curvature | Curvature matrix. |
[in,out] | npred | Number of predicted events. |
This method evaluates the -(log-likelihood) function for parameter optimisation using binned analysis and Poisson statistic. The -(log-likelihood) function is given by
\[ L=-\sum_i n_i \log e_i - e_i \]
where the sum is taken over all data space bins, \(n_i\) is the observed number of counts and \(e_i\) is the model. This method also computes the parameter gradients \(\delta L/dp\) and the curvature matrix \(\delta^2 L/dp_1 dp_2\) and also updates the total number of predicted events m_npred.
Definition at line 1535 of file GObservation.cpp.
References GMatrixSparse::add_to_column(), GMatrixSparse::column_to_vector(), GEventBin::counts(), GVectorSparse::data(), GVectorSparse::elements(), events(), GVectorSparse::inx(), gammalib::is_infinite(), minmod, model(), npred(), GEventBin::size(), GEvents::size(), GVector::size(), GMatrixSparse::transpose(), and use_event_for_likelihood().
Referenced by likelihood().
|
protectedvirtual |
Evaluate log-likelihood function for Poisson statistic and unbinned analysis (version with working arrays)
[in] | models | Models. |
[in,out] | gradients | Gradient. |
[in,out] | curvature | Curvature matrix. |
[in,out] | npred | Number of predicted events. |
This method evaluates the -(log-likelihood) function for parameter optimisation using unbinned analysis and Poisson statistic. The -(log-likelihood) function is given by
\[ L = N_{\rm pred} - \sum_i \log e_i \]
where \(N_{\rm pred}\) is the number of events predicted by the model, and the sum is taken over all events. This method also computes the parameter gradients \(\delta L/dp\) and the curvature matrix \(\delta^2 L/dp_1 dp_2\).
Definition at line 1402 of file GObservation.cpp.
References GMatrixSparse::add_to_column(), GMatrixSparse::column_to_vector(), events(), gammalib::is_infinite(), minmod, model(), npred(), GEvents::size(), GVector::size(), GMatrixSparse::transpose(), and use_event_for_likelihood().
Referenced by likelihood().
|
pure virtual |
Implemented in GCOMObservation, GCTAObservation, GCTAOnOffObservation, GLATObservation, GMWLObservation, and GSPIObservation.
|
virtual |
Return model value and (optionally) gradients.
[in] | models | Model container. |
[in] | event | Observed event. |
[out] | gradients | Pointer to gradient vector (optional). |
GException::invalid_value | Dimension of gradient vector mismatches number of parameters. |
Implements generic model and gradient evaluation for an observation. The model gives the probability for an event to occur with a given instrument direction, at a given energy and at a given time. The gradient is the parameter derivative of this probability. If NULL is passed for the gradient vector, then gradients will not be computed.
The method will only operate on models for which the list of instruments and observation identifiers matches those of the observation. Models that do not match will be skipped.
Definition at line 337 of file GObservation.cpp.
References GModel::eval(), GModel::eval_indices(), GOptimizerPar::factor_gradient(), G_MODEL1, GModel::has_eval_indices(), has_gradient(), instrument(), GOptimizerPar::is_free(), GModel::is_valid(), m_pars_with_gradients, model(), model_grad(), GModels::npars(), GModel::size(), GModels::size(), GVector::size(), and gammalib::str().
Referenced by computed_gradient(), GCOMObservation::drm(), has_gradient(), likelihood_gaussian_binned(), likelihood_poisson_binned(), likelihood_poisson_unbinned(), model(), model_grad(), model_grad(), GCOMObservation::npred(), npred(), npred_grad(), npred_spec(), and GCTAOnOffObservation::set().
|
virtual |
Return vector of model values and (optionally) gradients.
[in] | models | Model container. |
[out] | gradients | Pointer to sparse gradient matrix. |
GException::invalid_argument | Gradient matrix mismatches number of events or model parameters. |
Returns the model values for each event in the observation.
If gradients
is not NULL, the matrix contains on output the model factor gradients for all events. Each row of the gradients
matrix corresponds to one event, the columns correspond to the parameters of the models
container.
The method is optimised for speed, using sparse vectors and matrices.
Definition at line 491 of file GObservation.cpp.
References GMatrixSparse::colfill_flush(), GMatrixSparse::colfill_init(), GMatrixSparse::colfill_set_column(), GMatrixSparse::column(), GMatrixSparse::column_to_vector(), GMatrixBase::columns(), GModel::eval(), GModel::eval_indices(), events(), G_MODEL2, GModel::has_eval_indices(), has_gradient(), instrument(), GOptimizerPar::is_free(), GModel::is_valid(), m_pars_with_gradients, model_grad(), GOptimizerPar::name(), GModels::npars(), GMatrixBase::rows(), GEvents::size(), GModel::size(), GModels::size(), GMatrixSparse::stack_destroy(), GMatrixSparse::stack_init(), and gammalib::str().
Returns parameter gradients of model for all events.
[in] | model | Model. |
[in] | par | Model parameter. |
This method uses a robust but simple difference method to estimate parameter gradients that have not been provided by the model. We use here a simple method as this method is likely used for spatial model parameters, and the spatial model may eventually be noisy due to numerical integration limits.
Definition at line 998 of file GObservation.cpp.
References events(), GOptimizerPar::factor_max(), GOptimizerPar::factor_min(), GOptimizerPar::factor_value(), grad_step_size(), GOptimizerPar::has_max(), GOptimizerPar::has_min(), GOptimizerPar::is_free(), and model().
|
virtual |
Returns parameter gradient of model for a given event.
[in] | model | Model. |
[in] | par | Model parameter. |
[in] | event | Event. |
This method uses a robust but simple difference method to estimate parameter gradients that have not been provided by the model. We use here a simple method as this method is likely used for spatial model parameters, and the spatial model may eventually be noisy due to numerical integration limits.
Definition at line 916 of file GObservation.cpp.
References GDerivative::difference(), GOptimizerPar::factor_max(), GOptimizerPar::factor_min(), GOptimizerPar::factor_value(), grad_step_size(), GOptimizerPar::has_max(), GOptimizerPar::has_min(), GOptimizerPar::is_free(), GDerivative::left_difference(), model(), and GDerivative::right_difference().
|
inline |
Set observation name.
[in] | name | Observation name. |
Set name of the observation.
Definition at line 253 of file GObservation.hpp.
References m_name, and name().
Referenced by gammalib::cta_obs(), gammalib::cta_rsp_irf(), GCTACubeBackground::fill(), GCTACubeEdisp::fill(), GCTACubeExposure::fill(), GCTACubePsf::fill(), GCTACubeEdisp::fill_cube(), GCTACubeExposure::fill_cube(), GCTACubePsf::fill_cube(), GCOMResponse::irf_ptsrc(), GObservations::read(), and GCTAOnOffObservation::set().
|
inline |
Return observation name.
Definition at line 296 of file GObservation.hpp.
References m_name.
Referenced by GCOMObservation::compute_drb_bgdlixa(), GCOMObservation::compute_drb_bgdlixe(), GCOMObservation::compute_drb_bgdlixf(), GCOMObservation::compute_drb_phinor(), GCOMObservation::drm(), GMWLObservation::load(), name(), GCOMObservation::print(), GCTAObservation::print(), GLATObservation::print(), GMWLObservation::print(), GSPIObservation::print(), remove_response_cache(), GCOMObservation::response(), GLATObservation::response(), GMWLObservation::response(), GSPIObservation::response(), and GLATObservation::write().
|
virtual |
Return total number of observed events.
Returns the total number of observed events. If the observation does not contain any events the method returns zero.
Reimplemented in GCTAOnOffObservation.
Definition at line 703 of file GObservation.cpp.
References m_events, nobserved(), and GEvents::number().
Referenced by nobserved().
|
virtual |
Return total number of predicted counts for one model.
[in] | model | Gamma-ray source model. |
GException::gti_invalid | Good Time Interval is invalid. |
Computes
\[ N_{\rm pred} = \int_{\rm GTI} \int_{E_{\rm bounds}} \int_{\rm ROI} P(p',E',t') \, dp' \, dE' \, dt' \]
of the event probability
\[ P(p',E',t') = \int \int \int S(p,E,t) \times R(p',E',t'|p,E,t) \, dp \, dE \, dt \]
where \(S(p,E,t)\) is the source model, \(R(p',E',t'|p,E,t)\) is the instrument response function, \(p'\) is the measured photon direction, \(E'\) is the measured photon energy, \(t'\) is the measured photon arrival time, \(p\) is the true photon arrival direction, \(E\) is the true photon energy, and \(t\) is the true photon arrival time.
This method performs the time integration over the Good Time Intervals \({\rm GTI}\). Note that MET is used for the time integration interval. This, however, is no specialisation since npred_grad_kern_spec::eval() converts the argument back in a GTime object by assuming that the argument is in MET, hence the correct time system will be used at the end by the method.
Reimplemented in GCOMObservation.
Definition at line 836 of file GObservation.cpp.
References events(), G_NPRED, GEvents::gti(), instrument(), model(), npred(), npred_spec(), ontime(), GIntegral::romberg(), and gammalib::str().
Return total number (and optionally gradients) of predicted counts for all models.
[in] | models | Models. |
[out] | gradients | Model parameter gradients (optional). |
GException::invalid_argument | Dimension of gradient vector mismatches number of parameters. |
Returns the total number of predicted counts within the analysis region. If NULL is passed for the gradient vector then gradients will not be computed.
The method will only operate on models for which the list of instruments and observation identifiers matches those of the observation. Models that do not match will be skipped.
Definition at line 736 of file GObservation.cpp.
References G_NPRED, instrument(), GModel::is_valid(), GModels::npars(), npred(), npred_grad(), GModel::size(), GModels::size(), GVector::size(), and gammalib::str().
Referenced by GObservation::npred_func::eval(), GCTAOnOffObservation::likelihood(), likelihood(), GCTAOnOffObservation::likelihood_cstat(), likelihood_gaussian_binned(), likelihood_poisson_binned(), likelihood_poisson_unbinned(), GCTAOnOffObservation::likelihood_wstat(), npred(), and npred().
Returns parameter gradient of Npred.
[in] | model | Gamma-ray source model. |
[in] | par | Model parameter. |
Computes
\[ \frac{{\rm d} N_{\rm pred}}{{\rm d} a_i} \]
where
\[ N_{\rm pred} = \int_{\rm GTI} \int_{E_{\rm bounds}} \int_{\rm ROI} P(p',E',t') \, dp' \, dE' \, dt' \]
is the integral of the event probability
\[ P(p',E',t') = \int \int \int S(p,E,t) \times R(p',E',t'|p,E,t) \, dp \, dE \, dt \]
and \(a_i\) is the model parameter \(i\). Furthermore \(S(p,E,t)\) is the source model, \(R(p',E',t'|p,E,t)\) is the instrument response function, \(p'\) is the measured photon direction, \(E'\) is the measured photon energy, \(t'\) is the measured photon arrival time, \(p\) is the true photon arrival direction, \(E\) is the true photon energy, and \(t\) is the true photon arrival time.
This method uses a robust but simple difference method to estimate parameter gradients that have not been provided by the model. We use here a simple method as this method is likely used for spatial model parameters, and the spatial model may eventually be noisy due to numerical integration limits.
Definition at line 1139 of file GObservation.cpp.
References GDerivative::difference(), GOptimizerPar::factor_max(), GOptimizerPar::factor_min(), GOptimizerPar::factor_value(), grad_step_size(), GOptimizerPar::has_max(), GOptimizerPar::has_min(), GOptimizerPar::is_free(), GDerivative::left_difference(), model(), and GDerivative::right_difference().
Referenced by npred().
|
protectedvirtual |
Integrates spatially integrated Npred kernel spectrally.
[in] | model | Gamma-ray source model. |
[in] | obsTime | Measured photon arrival time. |
GException::erange_invalid | Energy range is invalid. |
Computes
\[ N_{\rm pred}(t') = \int_{E_{\rm bounds}} \int_{\rm ROI} P(p',E',t') \, dp' \, dE' \]
of the event probability
\[ P(p',E',t') = \int \int \int S(p,E,t) \times R(p',E',t'|p,E,t) \, dp \, dE \, dt \]
where \(S(p,E,t)\) is the source model, \(R(p',E',t'|p,E,t)\) is the instrument response function, \(p'\) is the measured photon direction, \(E'\) is the measured photon energy, \(t'\) is the measured photon arrival time, \(p\) is the true photon arrival direction, \(E\) is the true photon energy, and \(t\) is the true photon arrival time.
This method performs the energy intergration over the energy boundaries \(E_{\rm bounds}\).
Definition at line 2067 of file GObservation.cpp.
References GEvents::ebounds(), GEbounds::emax(), GEbounds::emin(), events(), GIntegral::fixed_iter(), gammalib::is_infinite(), gammalib::is_notanumber(), GEnergy::MeV(), model(), GIntegral::romberg(), and GEbounds::size().
Referenced by npred().
|
pure virtual |
Implemented in GCOMObservation, GCTAObservation, GCTAOnOffObservation, GLATObservation, GMWLObservation, and GSPIObservation.
Referenced by npred().
|
virtual |
Assignment operator.
[in] | obs | Observation. |
Assign observation.
Definition at line 141 of file GObservation.cpp.
References copy_members(), free_members(), and init_members().
Referenced by GCOMObservation::operator=(), GCTAObservation::operator=(), GCTAOnOffObservation::operator=(), GLATObservation::operator=(), GMWLObservation::operator=(), and GSPIObservation::operator=().
Print content of object.
[in] | chatter | Chattiness (defaults to NORMAL). |
Formats the content in a standard way and puts this content in a C++ string that is returned.
Implements GBase.
Implemented in GCOMObservation, GCTAObservation, GCTAOnOffObservation, GLATObservation, GMWLObservation, and GSPIObservation.
|
pure virtual |
Implemented in GCOMObservation, GCTAObservation, GCTAOnOffObservation, GLATObservation, GMWLObservation, and GSPIObservation.
Referenced by GObservations::read().
|
virtual |
Remove response cache for specific model.
[in] | name | Model name. |
Removes response cache for model name
from current observation.
Definition at line 1214 of file GObservation.cpp.
References id(), name(), remove_response_cache(), and response().
Referenced by remove_response_cache().
|
pure virtual |
Implemented in GCOMObservation, GCTAObservation, GCTAOnOffObservation, GLATObservation, GMWLObservation, and GSPIObservation.
Referenced by GModelSky::eval(), GModelSky::eval(), and GModelSky::npred().
|
pure virtual |
Implemented in GCOMObservation, GCTAObservation, GCTAOnOffObservation, GLATObservation, GMWLObservation, and GSPIObservation.
Referenced by remove_response_cache().
|
inline |
Set optimizer statistic.
[in] | statistic | Optimizer statistic. |
Set optimizer statistic for the observation.
Definition at line 283 of file GObservation.hpp.
References m_statistic, and statistic().
|
inline |
Return optimizer statistic.
Definition at line 320 of file GObservation.hpp.
References m_statistic.
Referenced by GCTAOnOffObservation::likelihood(), likelihood(), GCTAOnOffObservation::model_background(), GCOMObservation::print(), GCTAObservation::print(), GCTAOnOffObservation::print(), GLATObservation::print(), GMWLObservation::print(), GSPIObservation::print(), GCTAObservation::read(), GCTAOnOffObservation::read(), statistic(), GCTAObservation::write(), and GCTAOnOffObservation::write().
|
protectedvirtual |
Check whether bin should be used for likelihood analysis.
[in] | index | Event index. |
This is a dummy virtual method that allows implementation of a hook for event selection in the likelihood computation. The dummy method always returns true.
Reimplemented in GCOMObservation.
Definition at line 1960 of file GObservation.cpp.
Referenced by likelihood_gaussian_binned(), likelihood_poisson_binned(), and likelihood_poisson_unbinned().
|
pure virtual |
Implemented in GCOMObservation, GCTAObservation, GCTAOnOffObservation, GLATObservation, GMWLObservation, and GSPIObservation.
|
protected |
Pointer to event container.
Definition at line 226 of file GObservation.hpp.
Referenced by GCOMObservation::check_dri(), copy_members(), GCTAObservation::dispose_events(), GCOMObservation::drm(), GCTAObservation::ebounds(), events(), events(), events(), GCTAObservation::eventtype(), free_members(), GCOMObservation::GCOMObservation(), GCOMObservation::GCOMObservation(), GCTAObservation::gti(), GCTAObservation::has_events(), has_events(), init_members(), GCOMObservation::is_binned(), GCOMObservation::is_unbinned(), GCOMObservation::load(), GMWLObservation::load(), GLATObservation::load_binned(), GCOMObservation::load_dre(), GLATObservation::load_unbinned(), nobserved(), GCOMObservation::print(), GCTAObservation::print(), GLATObservation::print(), GMWLObservation::print(), GSPIObservation::print(), GCTAObservation::read(), GSPIObservation::read(), GCTAObservation::roi(), and GLATObservation::write().
|
protected |
Observation identifier.
Definition at line 224 of file GObservation.hpp.
Referenced by copy_members(), id(), id(), init_members(), GCTAOnOffObservation::print(), and GCOMObservation::read().
|
protected |
Observation name.
Definition at line 223 of file GObservation.hpp.
Referenced by copy_members(), GCOMObservation::GCOMObservation(), GCOMObservation::GCOMObservation(), init_members(), name(), name(), GCTAOnOffObservation::print(), GCOMObservation::read(), and GCOMObservation::read_attributes().
|
mutableprotected |
Definition at line 229 of file GObservation.hpp.
Referenced by computed_gradient(), copy_members(), has_gradient(), init_members(), model(), and model().
|
protected |
Optimizer statistic.
Definition at line 225 of file GObservation.hpp.
Referenced by copy_members(), GMWLObservation::init_members(), init_members(), statistic(), and statistic().