53#define G_CONSTRUCTOR "GCTAModelSpatialLookup(double&, double&, GEbounds&)"
54#define G_READ_XML "GCTAModelSpatialLookup::read(GXmlElement&)"
55#define G_WRITE_XML "GCTAModelSpatialLookup::write(GXmlElement&)"
56#define G_FILL_1 "GCTAModelSpatialLookup::fill(GCTAObservation&)"
57#define G_FILL_2 "GCTAModelSpatialLookup::fill(GObservations&)"
58#define G_READ_TABLE "GCTAModelSpatialLookup::read(GFitsTable&)"
59#define G_LOAD "GCTAModelSpatialLookup::load(GFilename&)"
60#define G_FILL_BUFFER "GCTAModelSpatialLookup::fill_buffer(GCTAObservation&,"\
61 " std::vector<double>&)"
174 const double& radbin,
180 std::string msg =
"Non-positive radial bin size "+
189 std::vector<double> eng_lo(ebds.
size());
190 std::vector<double> eng_hi(ebds.
size());
191 for (
int i = 0; i < ebds.
size(); ++i) {
192 eng_lo[i] = ebds.
emin(i).
TeV();
193 eng_hi[i] = ebds.
emax(i).
TeV();
197 int nrad = int(maxrad/radbin+0.5);
198 std::vector<double> rad_lo(nrad);
199 std::vector<double> rad_hi(nrad);
200 for (
int i = 0; i < nrad; ++i) {
201 rad_lo[i] = double(i)*radbin;
202 rad_hi[i] = double(i+1)*radbin;
264 if (
this != &model) {
339 const bool& gradients)
const
342 double offset = dir.
theta();
435 std::string msg =
"Spatial model \""+xml.
attribute(
"type")+
436 "\" is not of type \""+
type()+
"\".";
470 std::string msg =
"Attempting to fill a yet undefined lookup table. "
471 "Please allocate a valid lookup table before "
472 "calling this method.";
476 std::string msg =
"Attempting to fill non-existing lookup table. "
477 "While the lookup table axes were defined, no table "
478 "exists. Please allocate a valid lookup table before "
479 "calling this method.";
513 std::string msg =
"Attempting to fill a yet undefined lookup table. "
514 "Please allocate a valid lookup table before "
515 "calling this method.";
519 std::string msg =
"Attempting to fill non-existing lookup table. "
520 "While the lookup table axes were defined, no table "
521 "exists. Please allocate a valid lookup table before "
522 "calling this method.";
530 for (
int i = 0; i < obs.
size(); ++i) {
608 std::string msg =
"Expected two-dimensional lookup table but found "+
610 "specify a two-dimensional lookup table.";
655 GFits fits(filename);
671 std::string msg =
"No lookup table found in file \""+
672 filename.
url()+
"\".";
729 table.extname(extname);
775 result.append(
"=== GCTAModelSpatialLookup ===");
911 for (
int i_energy = 0; i_energy < energy_size; ++i_energy) {
914 double rad_max = 0.0;
917 for (
int i_theta = 0; i_theta < theta_size; ++i_theta) {
926 for (
int i_theta = 0; i_theta < theta_size; ++i_theta) {
947 const int& itheta)
const
969 std::vector<double>& buffer)
974 if (events == NULL) {
975 std::string msg =
"CTA Observation does not contain an event "
976 "list. An event list is needed to fill the "
986 for (
int i = 0; i < events->
size(); ++i) {
997 for (; i_theta < theta_size; ++i_theta) {
1005 if (i_theta >= theta_size) {
1010 double energy =
event->energy().TeV();
1014 for (; i_energy < energy_size; ++i_energy) {
1022 if (i_energy >= theta_size) {
1049 for (
int i_theta = 0; i_theta < theta_size; ++i_theta) {
1054 double area =
gammalib::pi * (theta_max*theta_max - theta_min*theta_min);
1057 for (
int i_energy = 0; i_energy < energy_size; ++i_energy) {
1059 m_lookup(0,inx) = buffer[inx] / area;
CTA instrument direction class interface definition.
const GCTAModelSpatialLookup g_cta_spatial_lookup_seed
Spatial lookup table model interface definition.
Spatial model registry class definition.
CTA observation class interface definition.
Energy boundaries class interface definition.
Energy value class definition.
FITS binary table class definition.
FITS table abstract base class interface definition.
FITS file class interface definition.
Mathematical function definitions.
Observations container class interface definition.
Time class interface definition.
virtual int size(void) const
Return number of events in list.
CTA instrument direction class.
double theta(void) const
Return offset angle (in radians)
Spatial lookup table model class.
void load(const GFilename &filename)
Load lookup table.
const GCTAResponseTable & table(void) const
Return lookup table.
virtual void write(GXmlElement &xml) const
Write model into XML element.
void prepare_table(void)
Prepare lookup table indices.
GFilename m_filename
Name of lookup table.
virtual void clear(void)
Clear instance.
void set_from_buffer(const std::vector< double > &buffer)
Set lookup table from buffer.
virtual GCTAModelSpatialLookup * clone(void) const
Clone instance.
void copy_members(const GCTAModelSpatialLookup &model)
Copy class members.
GModelPar m_norm
Normalization factor.
int m_inx_energy
Energy index.
int m_inx_theta
Theta index.
int table_index(const int &ienergy, const int &itheta) const
Return index of lookup table element.
virtual double eval(const GCTAInstDir &dir, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
Evaluate function.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print lookup table information.
void free_members(void)
Delete class members.
void fill_buffer(const GCTAObservation &obs, std::vector< double > &buffer)
Fill buffer from events in CTA observation.
virtual std::string type(void) const
Return model type.
void save(const GFilename &filename, const bool &clobber=false) const
Save lookup table into FITS file.
void fill(const GCTAObservation &obs)
Fill lookup table with events from one CTA observation.
virtual GCTAModelSpatialLookup & operator=(const GCTAModelSpatialLookup &model)
Assignment operator.
GCTAResponseTable m_lookup
Lookup table.
virtual void read(const GXmlElement &xml)
Read model from XML element.
void init_members(void)
Initialise class members.
GCTAModelSpatialLookup(void)
Void constructor.
double norm(void) const
Get lookup table model normalisation.
virtual ~GCTAModelSpatialLookup(void)
Destructor.
void normalise_table(void)
Normalise lookup table.
Interface definition for the spatial model registry class.
Abstract spatial model class.
void init_members(void)
Initialise class members.
std::vector< GModelPar * > m_pars
Parameter pointers.
virtual GCTAModelSpatial & operator=(const GCTAModelSpatial &model)
Assignment operator.
void free_members(void)
Delete class members.
std::string eventtype(void) const
Return event type string.
CTA response table class.
void read(const GFitsTable &table)
Read response table from FITS table HDU.
const int & elements(void) const
Return number of elements per table.
void axis_log10(const int &axis)
Set nodes for a logarithmic (base 10) axis.
const int & tables(void) const
Return number of tables.
void append_axis(const std::vector< double > &axis_lo, const std::vector< double > &axis_hi, const std::string &name, const std::string &unit)
Append an axis to the response table.
void axis_radians(const int &axis)
Set nodes for a radians axis.
int axis(const std::string &name) const
Determine index of an axis.
const int & axes(void) const
Return number of axes of the tables.
void append_table(const std::string &name, const std::string &unit)
Append table to response table.
void write(GFitsTable &table) const
Write response table into FITS table HDU.
int axis_bins(const int &axis) const
Return number bins in an axis.
const double & axis_hi(const int &axis, const int &bin) const
Return upper bin boundary for bin in axis.
void clear(void)
Clear response table.
const double & axis_lo(const int &axis, const int &bin) const
Return lower bin boundary for bin in axis.
Energy boundaries container class.
const GEnergy & emax(void) const
Return maximum energy of all intervals.
int size(void) const
Return number of energy boundaries.
const GEnergy & emin(void) const
Return minimum energy of all intervals.
Class that handles energies in a unit independent way.
double log10TeV(void) const
Return log10 of energy in TeV.
double TeV(void) const
Return energy in TeV.
bool has_extname(void) const
Signal if filename has an extension name.
bool has_extno(void) const
Signal if filename has an extension number.
std::string url(void) const
Return Uniform Resource Locator (URL)
std::string extname(const std::string &defaultname="") const
Return extension name.
int extno(const int &defaultno=-1) const
Return extension number.
bool is_empty(void) const
Signal if filename is empty.
void clear(void)
Clear file name.
Abstract interface for FITS table.
bool contains(const int &extno) const
Check if HDU exists in FITS file.
GFitsHDU * append(const GFitsHDU &hdu)
Append HDU to FITS file.
void close(void)
Close FITS file.
void remove(const int &extno)
Remove HDU from FITS file.
void save(const bool &clobber=false)
Saves FITS file.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
virtual GEvents * events(void)
Return events.
Observation container class.
int size(void) const
Return number of observations in container.
bool is_free(void) const
Signal if parameter is free.
const double & scale(void) const
Return parameter scale.
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
void range(const double &min, const double &max)
Set minimum and maximum parameter boundaries.
const double & factor_gradient(void) const
Return parameter factor gradient.
void fix(void)
Fix a parameter.
double gradient(void) const
Return parameter gradient.
void clear(void)
Clear parameter.
double value(void) const
Return parameter value.
const std::string & name(void) const
Return parameter name.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
const GXmlElement * xml_get_par(const std::string &origin, const GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
const std::string extname_cta_spatial_lookup
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
GFilename xml_file_reduce(const GXmlElement &xml, const std::string &filename)
Reduce file name provided for writing as XML attribute.
GFilename xml_file_expand(const GXmlElement &xml, const std::string &filename)
Expand file name provided as XML attribute for loading.