40 #define G_OPERATOR1 "GCTAResponseTable::operator()(double&)"
41 #define G_OPERATOR2 "GCTAResponseTable::operator()(double&, double&)"
42 #define G_OPERATOR3 "GCTAResponseTable::operator()(double&, double&,"\
44 #define G_ELEMENT_OPERATOR1 "GCTAResponseTable::operator()(int&)"
45 #define G_ELEMENT_OPERATOR2 "GCTAResponseTable::operator()(int&, int&)"
46 #define G_INX_OPERATOR1 "GCTAResponseTable::operator()(int&, double&)"
47 #define G_INX_OPERATOR2 "GCTAResponseTable::operator()(int&, double&,"\
49 #define G_INX_OPERATOR3 "GCTAResponseTable::operator()(int&, double&,"\
51 #define G_TABLE "GCTAResponseTable::table(std::string&)"
52 #define G_SCALE "GCTAResponseTable::scale(int&, double&)"
53 #define G_AXIS "GCTAResponseTable::axis(std::string&)"
54 #define G_AXIS_BINS "GCTAResponseTable::axis_bins(int&)"
55 #define G_AXIS_LO_NAME "GCTAResponseTable::axis_lo_name(int&)"
56 #define G_AXIS_HI_NAME "GCTAResponseTable::axis_hi_name(int&)"
57 #define G_AXIS_LO_UNIT "GCTAResponseTable::axis_lo_unit(int&)"
58 #define G_AXIS_HI_UNIT "GCTAResponseTable::axis_hi_unit(int&)"
59 #define G_UNIT "GCTAResponseTable::unit(int&)"
60 #define G_AXIS_LO "GCTAResponseTable::axis_lo(int&, int&)"
61 #define G_AXIS_HI "GCTAResponseTable::axis_hi(int&, int&)"
62 #define G_AXIS_LINEAR "GCTAResponseTable::axis_linear(int&)"
63 #define G_AXIS_LOG10 "GCTAResponseTable::axis_log10(int&)"
64 #define G_AXIS_RADIANS "GCTAResponseTable::axis_radians(int&)"
65 #define G_AXIS_NODES "GCTAResponseTable::axis_nodes(int&)"
66 #define G_APPEND_AXIS "GCTAResponseTable::append_axis(std::vector<double>&,"\
67 " std::vector<double>&, std::string&, std::string&)"
68 #define G_APPEND_TABLE "GCTAResponseTable::append_table(std::string&,"\
70 #define G_READ "GCTAResponseTable::read(GFitsTable&)"
71 #define G_READ_COLNAMES "GCTAResponseTable::read_colnames(GFitsTable&)"
72 #define G_READ_AXES "GCTAResponseTable::read_axes(GFitsTable&)"
73 #define G_READ_TABLES "GCTAResponseTable::read_tables(GFitsTable&)"
182 if (
this != &table) {
224 std::string msg =
"Invalid response table dimension "+
226 "table needs to be one-dimensional.";
269 const double& arg2)
const
273 std::string msg =
"Invalid response table dimension "+
275 "table needs to be two-dimensional.";
322 const double& arg3)
const
326 std::string msg =
"Invalid response table dimension "+
328 "table needs to be tri-dimensional.";
369 #if defined(G_RANGE_CHECK)
370 if (element < 0 || element >=
elements()) {
395 #if defined(G_RANGE_CHECK)
396 if (element < 0 || element >=
elements()) {
423 #if defined(G_RANGE_CHECK)
424 if (table < 0 || table >=
tables()) {
428 if (element < 0 || element >=
elements()) {
455 #if defined(G_RANGE_CHECK)
456 if (table < 0 || table >=
tables()) {
460 if (element < 0 || element >=
elements()) {
498 std::string msg =
"Invalid response table dimension "+
500 "table needs to be one-dimensional.";
505 #if defined(G_RANGE_CHECK)
506 if (table < 0 || table >=
tables()) {
550 const double& arg2)
const
554 std::string msg =
"Invalid response table dimension "+
556 "table needs to be two-dimensional.";
561 #if defined(G_RANGE_CHECK)
562 if (table < 0 || table >=
tables()) {
610 const double& arg3)
const
614 std::string msg =
"Invalid response table dimension "+
616 "table needs to be three-dimensional.";
621 #if defined(G_RANGE_CHECK)
622 if (table < 0 || table >=
tables()) {
724 std::string col_lo = name +
"_LO";
725 std::string col_hi = name +
"_HI";
766 std::string msg =
"Table \""+name+
"\" not found. Please verify the "
790 #if defined(G_RANGE_CHECK)
791 if (table < 0 || table >=
tables()) {
815 #if defined(G_RANGE_CHECK)
816 if (table < 0 || table >=
tables()) {
848 std::string col_lo = name +
"_LO";
849 std::string col_hi = name +
"_HI";
861 if (axis >=
axes()) {
862 std::string msg =
"Axis definition columns for axis \""+name+
"\" not "
863 "found. Please verify the axis names in the "
887 #if defined(G_RANGE_CHECK)
888 if (axis < 0 || axis >=
axes()) {
913 #if defined(G_RANGE_CHECK)
914 if (axis < 0 || axis >=
axes()) {
917 if (bin < 0 || bin >=
m_axis_lo[axis].size()) {
943 #if defined(G_RANGE_CHECK)
944 if (axis < 0 || axis >=
axes()) {
947 if (bin < 0 || bin >=
m_axis_hi[axis].size()) {
973 #if defined(G_RANGE_CHECK)
974 if (axis < 0 || axis >=
axes()) {
999 #if defined(G_RANGE_CHECK)
1000 if (axis < 0 || axis >=
axes()) {
1024 #if defined(G_RANGE_CHECK)
1025 if (axis < 0 || axis >=
axes()) {
1049 #if defined(G_RANGE_CHECK)
1050 if (axis < 0 || axis >=
axes()) {
1079 #if defined(G_RANGE_CHECK)
1080 if (axis < 0 || axis >=
axes()) {
1093 for (
int i = 0; i < bins; ++i) {
1126 #if defined(G_RANGE_CHECK)
1127 if (axis < 0 || axis >=
axes()) {
1140 for (
int i = 0; i < bins; ++i) {
1172 #if defined(G_RANGE_CHECK)
1173 if (axis < 0 || axis >=
axes()) {
1186 for (
int i = 0; i < bins; ++i) {
1213 const std::vector<double>& axis_hi,
1214 const std::string& name,
1215 const std::string& unit)
1218 if (axis_lo.size() != axis_hi.size()) {
1219 std::string msg =
"Number of elements in lower axis boundaries "
1220 "mismatches the number of elements in upper axis "
1227 std::string name_lo = name +
"_LO";
1228 std::string name_hi = name +
"_HI";
1240 std::vector<double>
axis_nodes(axis_lo.size());
1241 for (
int k = 0; k < axis_lo.size(); ++k) {
1242 axis_nodes[k] = 0.5*(axis_lo[k] + axis_hi[k]);
1251 for (
int i = 1; i <
axes(); ++i) {
1274 const std::string& unit)
1278 std::string msg =
"No axis columns have been defined. Please append "
1279 "axis columns before appending table columns.";
1315 #if defined(G_RANGE_CHECK)
1316 if (axis < 0 || axis >=
axes()) {
1383 std::vector<int> dim;
1386 for (
int iaxis = 0; iaxis <
m_naxes; ++iaxis) {
1395 for (
int i = 0; i <
m_axis_lo[iaxis].size(); ++i) {
1414 for (
int itable = 0; itable <
m_ntables; ++itable) {
1421 for (
int i = 0; i <
m_tables[itable].size() ; ++i) {
1422 col_table(0,i) =
m_tables[itable][i];
1462 result.append(
"=== GCTAResponseTable ===");
1471 for (
int i = 0; i <
axes(); ++i) {
1475 result.append(
" (");
1480 result.append(
", ");
1489 for (
int i = 0; i <
tables(); ++i) {
1667 std::string lo_column;
1668 std::string next_column;
1671 for (
int i = 0; i < hdu.
ncols(); ++i) {
1674 std::string colname = hdu[i]->name();
1682 size_t pos = colname.rfind(
"_LO");
1683 if (pos != std::string::npos) {
1685 lo_column = colname;
1686 next_column = colname.substr(0, pos) +
"_HI";
1689 if (colname.rfind(
"_HI") != std::string::npos) {
1690 std::string msg =
"Column \""+colname+
"\" encountered "
1691 "without preceeding \"_LO\" column. "
1692 "Please correct response table format.";
1706 else if (mode == 1) {
1707 if (colname == next_column) {
1713 std::string msg =
"Expected column \""+next_column+
"\" not "
1714 "found. The axis upper bin boundary "
1715 "column has to follow immediately the "
1716 "lower bin boundary column.";
1724 if (colname.rfind(
"_LO") != std::string::npos) {
1725 std::string msg =
"Column \""+colname+
"\" encountered while "
1726 "searching for table columns. All "
1727 "lower bin boundary columns have to be "
1728 "placed before the table columns.";
1731 else if (colname.rfind(
"_HI") != std::string::npos) {
1732 std::string msg =
"Column \""+colname+
"\" encountered while "
1733 "searching for table columns. All "
1734 "upper bin boundary columns have to be "
1735 "placed before the table columns.";
1788 for (
int i = 0; i <
axes(); ++i) {
1796 int num = col_lo->
number();
1797 if (num != col_hi->
number()) {
1798 std::string msg =
"Axis lower bin boundary column \""+
1799 m_colname_lo[i]+
"\" contains "+
1801 "bin boundary column \""+m_colname_hi[i]+
1803 " elements. Both columns need to contain the "
1804 "same number of elements.";
1809 std::vector<double>
axis_lo(num);
1810 std::vector<double>
axis_hi(num);
1814 for (
int k = 0; k < num; ++k) {
1815 axis_lo[k] = col_lo->
real(0,k);
1816 axis_hi[k] = col_hi->
real(0,k);
1817 axis_nodes[k] = 0.5*(axis_lo[k] + axis_hi[k]);
1858 for (
int i = 1; i <
axes(); ++i) {
1863 for (
int i = 0; i <
tables(); ++i) {
1872 std::string msg =
"Table column \""+m_colname_table[i]+
"\" "
1875 "elements were expected from the axis "
1876 "definitions. Please check the response "
1877 "table for consistency.";
1882 if (col->
dim().size() > 0) {
1886 if (
axes() != col->
dim().size()) {
1887 std::string msg =
"Table column \""+m_colname_table[i]+
"\" "
1890 "inconsistent with "+
1892 "check the response table for consistency.";
1898 for (
int i = 0; i <
axes(); ++i) {
1900 std::string msg =
"Table column \""+m_colname_table[i]+
"\" "
1903 " while corresponding axis columns \""+
1907 "check the response table for "
1917 std::vector<double>
table(num);
1920 for (
int k = 0; k < num; ++k) {
1921 table[k] = col->
real(0,k);
1991 int offset_left = nodes2->
inx_left() * size1;
1992 int offset_right = nodes2->
inx_right() * size1;
2025 const double& arg3)
const
2041 int size12 = size1 * size2;
2042 int offset_left_2 = nodes2->
inx_left() * size1;
2043 int offset_right_2 = nodes2->
inx_right() * size1;
2044 int offset_left_3 = nodes3->
inx_left() * size12;
2045 int offset_right_3 = nodes3->
inx_right() * size12;
2048 int inx1l2l = nodes1->
inx_left() + offset_left_2;
2049 int inx1l2r = nodes1->
inx_left() + offset_right_2;
2050 int inx1r2l = nodes1->
inx_right() + offset_left_2;
2051 int inx1r2r = nodes1->
inx_right() + offset_right_2;
2054 m_inx1 = inx1l2l + offset_left_3;
2055 m_inx2 = inx1l2l + offset_right_3;
2056 m_inx3 = inx1l2r + offset_left_3;
2057 m_inx4 = inx1l2r + offset_right_3;
2058 m_inx5 = inx1r2l + offset_left_3;
2059 m_inx6 = inx1r2l + offset_right_3;
2060 m_inx7 = inx1r2r + offset_left_3;
2061 m_inx8 = inx1r2r + offset_right_3;
int m_inx_left
Index of left node.
const GNodeArray & axis_nodes(const int &axis) const
Return axis nodes.
void unit(const std::string &unit)
Set column unit.
const int & ncols(void) const
Return number of columns in table.
void number(const int &number)
Set number of elements in column.
int m_inx5
Index of upper left node.
bool has_card(const int &cardno) const
Check existence of header card.
void append_table(const std::string &name, const std::string &unit)
Append table to response table.
GCTAResponseTable(void)
Void constructor.
int m_ntables
Number of tables.
std::vector< std::string > m_units_hi
Upper boundaries units.
GCTAResponseTable & operator=(const GCTAResponseTable &table)
Assignment operator.
void update(const double &arg) const
Update 1D cache.
double m_wgt6
Weight of lower left node.
#define G_ELEMENT_OPERATOR2
void axis_linear(const int &axis)
Set nodes for a linear axis.
double m_wgt2
Weight of lower left node.
const double & wgt_left(void) const
Returns left node weight.
std::vector< double > operator()(const double &arg) const
Linear interpolation operator for 1D tables.
GFitsTableCol * append(const GFitsTableCol &column)
Append column to the table.
void init_members(void)
Initialise response table members.
int m_inx2
Index of lower left node.
const int & tables(void) const
Return number of tables.
int m_inx3
Index of upper right node.
void scale(const int &table, const double &scale)
Scale table.
void read_colnames(const GFitsTable &hdu)
Read column names from FITS HDU.
void read_axes(const GFitsTable &hdu)
Read axes definitions from FITS HDU.
std::vector< std::vector< double > > m_axis_hi
Axes upper boundaries.
FITS table float column class interface definition.
void axis_radians(const int &axis)
Set nodes for a radians axis.
void set_value(const double &value) const
Set indices and weighting factors for interpolation.
virtual ~GCTAResponseTable(void)
Destructor.
void read(const GFitsTable &table)
Read response table from FITS table HDU.
int m_inx4
Index of lower right node.
const double & axis_lo(const int &axis, const int &bin) const
Return lower bin boundary for bin in axis.
std::vector< std::vector< double > > m_tables
Tables.
void write(GFitsTable &table) const
Write response table into FITS table HDU.
int axis(const std::string &name) const
Determine index of an axis.
const std::string & unit(const int &table) const
Return table unit.
double m_wgt4
Weight of lower right node.
CTA response table class definition.
GVector sqrt(const GVector &vector)
Computes square root of vector elements.
bool has_table(const std::string &name) const
Check whether a table exists.
const double & wgt_right(void) const
Returns right node weight.
void clear(void)
Clear response table.
Abstract interface for FITS table column.
std::vector< std::string > m_colname_table
Column names for table.
double m_wgt3
Weight of upper right node.
int m_inx7
Index of upper right node.
const int & elements(void) const
Return number of elements per table.
#define G_ELEMENT_OPERATOR1
GCTAResponseTable * clone(void) const
Clone response table.
Abstract interface for FITS table.
double m_wgt_left
Weight of left node.
void dim(const std::vector< int > &dim)
Set column dimension.
const int & inx_left(void) const
Returns left node index.
std::string print(const GChatter &chatter=NORMAL) const
Print response table information.
void free_members(void)
Delete response table members.
void axis_log10(const int &axis)
Set nodes for a logarithmic (base 10) axis.
int table(const std::string &name) const
Determine index of table.
double m_wgt1
Weight of upper left node.
void copy_members(const GCTAResponseTable &table)
Copy response table members.
double m_wgt8
Weight of lower right node.
const int & inx_right(void) const
Returns right node index.
std::vector< std::string > m_units_table
Parameter units.
double m_wgt7
Weight of upper right node.
int axis_bins(const int &axis) const
Return number bins in an axis.
std::vector< std::vector< double > > m_axis_lo
Axes lower boundaries.
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.
const std::string & axis_lo_name(const int &axis) const
Return lower bin boundary FITS table column name for axis.
int m_inx_right
Index of right node.
std::vector< std::string > m_colname_hi
Column names for upper boundaries.
virtual double real(const int &row, const int &inx=0) const =0
int m_inx6
Index of lower left node.
std::vector< std::string > m_colname_lo
Column names for lower boundaries.
bool has_axis(const std::string &name) const
Check whether an axis exists.
const double & axis_hi(const int &axis, const int &bin) const
Return upper bin boundary for bin in axis.
const std::string & axis_hi_name(const int &axis) const
Return upper bin boundary FITS table column name for axis.
std::string string(const std::string &keyname) const
Return card value as string.
int m_naxes
Number of axes.
Exception handler interface definition.
std::vector< GNodeArray > m_axis_nodes
Axes node arrays.
void read_tables(const GFitsTable &hdu)
Read tables.
FITS binary table class definition.
CTA response table class.
int m_inx1
Index of upper left node.
const std::string & axis_lo_unit(const int &axis) const
Return lower bin boundary unit for axis.
const std::string & axis_hi_unit(const int &axis) const
Return upper bin boundary unit for axis.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
double m_wgt5
Weight of upper left node.
int m_inx8
Index of lower right node.
GFitsHeaderCard & card(const int &cardno)
Return header card.
const int & axes(void) const
Return number of axes of the tables.
int m_nelements
Number of elements per table.
std::vector< std::string > m_units_lo
Lower boundaries units.
double m_wgt_right
Weight of right node.
Mathematical function definitions.
GVector log10(const GVector &vector)
Computes base10 logarithm of vector elements.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
std::string m_telescope
Telescope keyword.