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);
666 table = fits.
table(1);
671 std::string msg =
"No lookup table found in file \""+
672 filename.
url()+
"\".";
718 if (fits.contains(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;
Abstract spatial model class.
double norm(void) const
Get lookup table model normalisation.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print lookup table information.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
void append_table(const std::string &name, const std::string &unit)
Append table to response table.
const double & factor_gradient(void) const
Return parameter factor gradient.
Energy value class definition.
const std::string & name(void) const
Return parameter name.
double gradient(void) const
Return parameter gradient.
virtual std::string type(void) const
Return model type.
bool has_extno(void) const
Signal if filename has an extension number.
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
int size(void) const
Return number of energy boundaries.
bool is_empty(void) const
Signal if filename is empty.
void prepare_table(void)
Prepare lookup table indices.
virtual GCTAModelSpatial & operator=(const GCTAModelSpatial &model)
Assignment operator.
bool has_extname(void) const
Signal if filename has an extension name.
void fill_buffer(const GCTAObservation &obs, std::vector< double > &buffer)
Fill buffer from events in CTA observation.
double TeV(void) const
Return energy in TeV.
std::string extname(const std::string &defaultname="") const
Return extension name.
double log10TeV(void) const
Return log10 of energy in TeV.
const int & tables(void) const
Return number of tables.
void axis_radians(const int &axis)
Set nodes for a radians axis.
FITS file class interface definition.
GFilename xml_file_reduce(const GXmlElement &xml, const std::string &filename)
Reduce file name provided for writing as XML attribute.
void read(const GFitsTable &table)
Read response table from FITS table HDU.
bool is_free(void) const
Signal if parameter is free.
Interface definition for the spatial model registry class.
const GCTAResponseTable & table(void) const
Return lookup table.
const double & axis_lo(const int &axis, const int &bin) const
Return lower bin boundary for bin in axis.
const double & scale(void) const
Return parameter scale.
void write(GFitsTable &table) const
Write response table into FITS table HDU.
int axis(const std::string &name) const
Determine index of an axis.
virtual void read(const GXmlElement &xml)
Read model from XML element.
void set_from_buffer(const std::vector< double > &buffer)
Set lookup table from buffer.
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
void init_members(void)
Initialise class members.
Energy boundaries container class.
void remove(const int &extno)
Remove HDU from FITS file.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
GCTAModelSpatialLookup(void)
Void constructor.
double theta(void) const
Return offset angle (in radians)
void save(const GFilename &filename, const bool &clobber=false) const
Save lookup table into FITS file.
void clear(void)
Clear response table.
void load(const GFilename &filename)
Load lookup table.
const GEnergy & emin(void) const
Return minimum energy of all intervals.
void free_members(void)
Delete class members.
int m_inx_theta
Theta index.
void fix(void)
Fix a parameter.
GModelPar m_norm
Normalization factor.
GFilename m_filename
Name of lookup table.
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
virtual GCTAModelSpatialLookup & operator=(const GCTAModelSpatialLookup &model)
Assignment operator.
int table_index(const int &ienergy, const int &itheta) const
Return index of lookup table element.
void init_members(void)
Initialise class members.
void clear(void)
Clear parameter.
CTA instrument direction class interface definition.
virtual void clear(void)
Clear instance.
const int & elements(void) const
Return number of elements per table.
Abstract interface for FITS table.
const std::string extname_cta_spatial_lookup
void normalise_table(void)
Normalise lookup table.
int size(void) const
Return number of observations in container.
virtual void write(GXmlElement &xml) const
Write model into XML element.
const std::string & extname(void) const
Return extension name.
void axis_log10(const int &axis)
Set nodes for a logarithmic (base 10) axis.
CTA observation class interface definition.
Observation container class.
virtual GCTAModelSpatialLookup * clone(void) const
Clone instance.
Spatial lookup table model class.
std::string url(void) const
Return Uniform Resource Locator (URL)
int axis_bins(const int &axis) const
Return number bins in an axis.
void clear(void)
Clear file name.
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 range(const double &min, const double &max)
Set minimum and maximum parameter boundaries.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
double value(void) const
Return parameter value.
const double & axis_hi(const int &axis, const int &bin) const
Return upper bin boundary for bin in axis.
const GCTAModelSpatialLookup g_cta_spatial_lookup_seed
void fill(const GCTAObservation &obs)
Fill lookup table with events from one CTA observation.
int extno(const int &defaultno=-1) const
Return extension number.
virtual GEvents * events(void)
Return events.
Energy boundaries class interface definition.
std::string eventtype(void) const
Return event type string.
virtual int size(void) const
Return number of events in list.
GCTAResponseTable m_lookup
Lookup table.
FITS binary table class definition.
CTA response table class.
CTA instrument direction class.
const GEnergy & emax(void) const
Return maximum energy of all intervals.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
std::vector< GModelPar * > m_pars
Parameter pointers.
virtual double eval(const GCTAInstDir &dir, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
Evaluate function.
Observations container class interface definition.
Spatial lookup table model interface definition.
void close(void)
Close FITS file.
const int & axes(void) const
Return number of axes of the tables.
Time class interface definition.
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.
void free_members(void)
Delete class members.
Spatial model registry class definition.
virtual ~GCTAModelSpatialLookup(void)
Destructor.
int m_inx_energy
Energy index.
void copy_members(const GCTAModelSpatialLookup &model)
Copy class members.
Mathematical function definitions.
Class that handles energies in a unit independent way.
GFilename xml_file_expand(const GXmlElement &xml, const std::string &filename)
Expand file name provided as XML attribute for loading.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
FITS table abstract base class interface definition.