GCTAResponseTable.hpp
9.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/***************************************************************************
* GCTAResponseTable.hpp - CTA response table class *
* ----------------------------------------------------------------------- *
* copyright (C) 2012-2014 by Juergen Knoedlseder *
* ----------------------------------------------------------------------- *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
***************************************************************************/
/**
* @file GCTAResponseTable.hpp
* @brief CTA response table class definition
* @author Juergen Knoedlseder
*/
#ifndef GCTARESPONSETABLE_HPP
#define GCTARESPONSETABLE_HPP
/* __ Includes ___________________________________________________________ */
#include <string>
#include <vector>
#include "GBase.hpp"
#include "GNodeArray.hpp"
#include "GFitsTable.hpp"
/***********************************************************************//**
* @class GCTAResponseTable
*
* @brief Interface for the CTA response table class
*
* A response table contains response parameters in multi-dimensional vector
* column format. Each dimension is described by axes columns.
***************************************************************************/
class GCTAResponseTable : public GBase {
public:
// Constructors and destructors
GCTAResponseTable(void);
GCTAResponseTable(const GCTAResponseTable& table);
explicit GCTAResponseTable(const GFitsTable& hdu);
virtual ~GCTAResponseTable(void);
// Operators
GCTAResponseTable& operator=(const GCTAResponseTable& table);
std::vector<double> operator()(const double& arg) const;
std::vector<double> operator()(const double& arg1, const double& arg2) const;
std::vector<double> operator()(const double& arg1, const double& arg2,
const double& arg3) const;
const double& operator()(const int& element) const;
double& operator()(const int& element);
const double& operator()(const int& index, const int& element) const;
double& operator()(const int& index, const int& element);
double operator()(const int& index, const double& arg) const;
double operator()(const int& index, const double& arg1,
const double& arg2) const;
double operator()(const int& index, const double& arg1,
const double& arg2, const double& arg3) const;
// Methods
void clear(void);
GCTAResponseTable* clone(void) const;
std::string classname(void) const;
int size(void) const;
const int& elements(void) const;
const int& axes(void) const;
int axis(const int& index) const;
const double& axis_lo(const int& index, const int& bin) const;
const double& axis_hi(const int& index, const int& bin) const;
const std::string& axis_lo_name(const int& index) const;
const std::string& axis_hi_name(const int& index) const;
const std::string& axis_lo_unit(const int& index) const;
const std::string& axis_hi_unit(const int& index) const;
void axis_linear(const int& index);
void axis_log10(const int& index);
void axis_radians(const int& index);
const std::string& unit(const int& index) const;
void append_axis(const std::vector<double>& axis_lo,
const std::vector<double>& axis_hi,
const std::string& name,
const std::string& unit);
void append_parameter(const std::string& name,
const std::string& unit);
const GNodeArray& nodes(const int& index) const;
void scale(const int& index, const double& scale);
void read(const GFitsTable& table);
void write(GFitsTable& table) const;
std::string print(const GChatter& chatter = NORMAL) const;
private:
// Methods
void init_members(void);
void copy_members(const GCTAResponseTable& table);
void free_members(void);
void read_colnames(const GFitsTable& hdu);
void read_axes(const GFitsTable& hdu);
void read_pars(const GFitsTable& hdu);
void update(const double& arg) const;
void update(const double& arg1, const double& arg2) const;
void update(const double& arg1, const double& arg2,
const double& arg3) const;
protected:
// Table information
int m_naxes; //!< Number of axes
int m_npars; //!< Number of parameters
int m_nelements; //!< Number of elements per parameter
std::vector<std::string> m_colname_lo; //!< Column names for lower boundaries
std::vector<std::string> m_colname_hi; //!< Column names for upper boundaries
std::vector<std::string> m_colname_par; //!< Column names for parameters
std::vector<std::vector<double> > m_axis_lo; //!< Axes lower boundaries
std::vector<std::vector<double> > m_axis_hi; //!< Axes upper boundaries
std::vector<std::string> m_units_lo; //!< Lower boundaries units
std::vector<std::string> m_units_hi; //!< Upper boundaries units
std::vector<std::string> m_units_par; //!< Parameter units
std::vector<GNodeArray> m_axis_nodes; //!< Axes node arrays
std::vector<std::vector<double> > m_pars; //!< Parameters
// Response table computation cache for 1D access
mutable int m_inx_left; //!< Index of left node
mutable int m_inx_right; //!< Index of right node
mutable double m_wgt_left; //!< Weight of left node
mutable double m_wgt_right; //!< Weight of right node
// Response table computation cache for 2D access
mutable int m_inx1; //!< Index of upper left node
mutable int m_inx2; //!< Index of lower left node
mutable int m_inx3; //!< Index of upper right node
mutable int m_inx4; //!< Index of lower right node
mutable double m_wgt1; //!< Weight of upper left node
mutable double m_wgt2; //!< Weight of lower left node
mutable double m_wgt3; //!< Weight of upper right node
mutable double m_wgt4; //!< Weight of lower right node
// Response table computation cache for 3D access
mutable int m_inx5; //!< Index of upper left node
mutable int m_inx6; //!< Index of lower left node
mutable int m_inx7; //!< Index of upper right node
mutable int m_inx8; //!< Index of lower right node
mutable double m_wgt5; //!< Weight of upper left node
mutable double m_wgt6; //!< Weight of lower left node
mutable double m_wgt7; //!< Weight of upper right node
mutable double m_wgt8; //!< Weight of lower right node
};
/***********************************************************************//**
* @brief Return class name
*
* @return String containing the class name ("GCTAResponseTable").
***************************************************************************/
inline
std::string GCTAResponseTable::classname(void) const
{
return ("GCTAResponseTable");
}
/***********************************************************************//**
* @brief Return number of parameters in response table
*
* @return Number of parameters in response table.
*
* Returns the number of parameters in response table.
***************************************************************************/
inline
int GCTAResponseTable::size(void) const
{
return m_npars;
}
/***********************************************************************//**
* @brief Return number of elements per parameter
*
* @return Number of elements per parameter.
*
* Returns the number of elements per parameter.
***************************************************************************/
inline
const int& GCTAResponseTable::elements(void) const
{
return m_nelements;
}
/***********************************************************************//**
* @brief Return number of axes in response table
*
* @return Number of axes in response table.
*
* Returns the number of axes in response table.
***************************************************************************/
inline
const int& GCTAResponseTable::axes(void) const
{
// Return number of axes
return m_naxes;
}
#endif /* GCTARESPONSETABLE_HPP */