GammaLib 2.0.0
Loading...
Searching...
No Matches
GCTACubePsf.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCTACubePsf.hpp - CTA cube analysis point spread function class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2014-2017 by Chia-Chun Lu *
5 * ----------------------------------------------------------------------- *
6 * *
7 * This program is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19 * *
20 ***************************************************************************/
21/**
22 * @file GCTACubePsf.hpp
23 * @brief CTA cube analysis point spread function class definition
24 * @author Chia-Chun Lu
25 */
26
27#ifndef GCTACUBEPSF_HPP
28#define GCTACUBEPSF_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include "GBase.hpp"
33#include "GMath.hpp"
34#include "GFits.hpp"
35#include "GSkyMap.hpp"
36#include "GEnergies.hpp"
37#include "GNodeArray.hpp"
38
39/* __ Forward declarations _______________________________________________ */
40class GFilename;
41class GObservations;
42class GCTAEventCube;
43class GCTAObservation;
44
45/* __ Constants __________________________________________________________ */
46namespace gammalib {
47 const std::string extname_deltas = "DELTAS";
48}
49
50
51
52/***********************************************************************//**
53 * @class GCTACubePsf
54 *
55 * @brief CTA point spread function for cube analysis
56 *
57 * This class implements a mean CTA point spread function which provides the
58 * average point spread function for cube analysis as function of sky
59 * position, log10 energy and delta angle between true and measured photon
60 * direction.
61 ***************************************************************************/
62class GCTACubePsf : public GBase {
63
64public:
65
66 // Constructors and destructors
67 GCTACubePsf(void);
69 explicit GCTACubePsf(const GFilename& filename);
71 const double& dmax, const int& ndbins);
72 GCTACubePsf(const std::string& wcs,
73 const std::string& coords,
74 const double& x,
75 const double& y,
76 const double& dx,
77 const double& dy,
78 const int& nx,
79 const int& ny,
80 const GEnergies& energies,
81 const double& dmax,
82 const int& ndbins);
83 virtual ~GCTACubePsf(void);
84
85 // Operators
87 double operator()(const GSkyDir& dir,
88 const double& delta,
89 const GEnergy& energy) const;
90
91 // Methods
92 void clear(void);
93 GCTACubePsf* clone(void) const;
94 std::string classname(void) const;
95 void set(const GCTAObservation& obs);
96 void fill(const GObservations& obs, GLog* log = NULL);
97 const GSkyMap& cube(void) const;
98 const GEnergies& energies(void) const;
99 const GNodeArray& deltas(void) const;
100 double delta_max(void) const;
101 int offset(const int& idelta, const int& iebin) const;
102 void read(const GFits& fits);
103 void write(GFits& file) const;
104 void load(const GFilename& filename);
105 void save(const GFilename& filename,
106 const bool& clobber = false) const;
107 const GFilename& filename(void) const;
108 std::string print(const GChatter& chatter = NORMAL) const;
109
110protected:
111 // Methods
112 void init_members(void);
113 void copy_members(const GCTACubePsf& cube);
114 void free_members(void);
115 void clear_cube(void);
116 void fill_cube(const GCTAObservation& obs, GSkyMap* exposure = NULL,
117 GLog* log = NULL);
118 void update(const double& delta, const double& logE) const;
119 void set_delta_axis(void);
120 void set_eng_axis(void);
121 void set_to_smooth(void);
122
123 // Data
124 mutable GFilename m_filename; //!< Filename
125 GSkyMap m_cube; //!< PSF cube
126 GEnergies m_energies; //!< Energy values for the PSF cube
127 GNodeArray m_elogmeans; //!< Mean log10TeV energy for the PSF cube
128 GNodeArray m_deltas; //!< Delta bins (deg) for the PSF cube
129 GNodeArray m_deltas_cache; //!< Internal delta bins (rad)
130 bool m_quadratic_binning; //!< Internal binning is linear
131
132private:
133 // Response table computation cache for 2D access
134 mutable int m_inx1; //!< Index of upper left node
135 mutable int m_inx2; //!< Index of lower left node
136 mutable int m_inx3; //!< Index of upper right node
137 mutable int m_inx4; //!< Index of lower right node
138 mutable double m_wgt1; //!< Weight of upper left node
139 mutable double m_wgt2; //!< Weight of lower left node
140 mutable double m_wgt3; //!< Weight of upper right node
141 mutable double m_wgt4; //!< Weight of lower right node
142};
143
144
145/***********************************************************************//**
146 * @brief Return class name
147 *
148 * @return String containing the class name ("GCTACubePsf").
149 ***************************************************************************/
150inline
151std::string GCTACubePsf::classname(void) const
152{
153 return ("GCTACubePsf");
154}
155
156
157/***********************************************************************//**
158 * @brief Return psf cube sky map
159 *
160 * @return psf cube sky map.
161 *
162 * The GCTACubePsf represents the psf cube as a sky map. This methods
163 * returns the sky map that is stored internally by GCTACubePsf as psf
164 * cube.
165 ***************************************************************************/
166inline
167const GSkyMap& GCTACubePsf::cube(void) const
168{
169 return (m_cube);
170}
171
172
173/***********************************************************************//**
174 * @brief Return energies
175 *
176 * @return Energies
177 ***************************************************************************/
178inline
180{
181 return (m_energies);
182}
183
184
185/***********************************************************************//**
186 * @brief Return offset angles between true and measured photon direction
187 *
188 * @return Offset angles between true and measured photon direction
189 ***************************************************************************/
190inline
192{
193 return (m_deltas);
194}
195
196
197/***********************************************************************//**
198 * @brief Return maximum delta value in radians
199 *
200 * @return Maximum delta value (radians).
201 ***************************************************************************/
202inline
203double GCTACubePsf::delta_max(void) const
204{
205 // Get maximum delta value
206 double delta_max = (m_deltas.size() > 0) ? m_deltas[m_deltas.size()-1] : 0.0;
207
208 // Return
209 return (delta_max * gammalib::deg2rad);
210}
211
212
213/***********************************************************************//**
214 * @brief Return exposure cube filename
215 *
216 * @return Exposure cube filename.
217 *
218 * Returns the filename from which the exposure cube was loaded or into which
219 * the exposure cube has been saved.
220 ***************************************************************************/
221inline
223{
224 return (m_filename);
225}
226
227
228/***********************************************************************//**
229 * @brief Return map offset
230 *
231 * @return Map offset.
232 ***************************************************************************/
233inline
234int GCTACubePsf::offset(const int& idelta, const int& iebin) const
235{
236 return (idelta + iebin*m_deltas.size());
237}
238
239#endif /* GCTACUBEPSF_HPP */
Definition of interface for all GammaLib classes.
Energy container class definition.
FITS file class interface definition.
Mathematical function definitions.
Node array class interface definition.
Sky map class definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
Definition GVector.cpp:1274
Interface class for all GammaLib classes.
Definition GBase.hpp:52
CTA point spread function for cube analysis.
int m_inx2
Index of lower left node.
GNodeArray m_deltas
Delta bins (deg) for the PSF cube.
void read(const GFits &fits)
Read PSF cube from FITS object.
void set(const GCTAObservation &obs)
Set PSF cube from one CTA observation.
int offset(const int &idelta, const int &iebin) const
Return map offset.
void write(GFits &file) const
Write CTA PSF cube into FITS object.
double delta_max(void) const
Return maximum delta value in radians.
int m_inx1
Index of upper left node.
GCTACubePsf * clone(void) const
Clone instance.
double m_wgt1
Weight of upper left node.
bool m_quadratic_binning
Internal binning is linear.
GEnergies m_energies
Energy values for the PSF cube.
const GNodeArray & deltas(void) const
Return offset angles between true and measured photon direction.
void fill(const GObservations &obs, GLog *log=NULL)
Fill PSF cube from observation container.
std::string print(const GChatter &chatter=NORMAL) const
Print PSF cube information.
std::string classname(void) const
Return class name.
void save(const GFilename &filename, const bool &clobber=false) const
Save PSF cube into FITS file.
double m_wgt3
Weight of upper right node.
int m_inx4
Index of lower right node.
void update(const double &delta, const double &logE) const
Update PSF parameter cache.
void fill_cube(const GCTAObservation &obs, GSkyMap *exposure=NULL, GLog *log=NULL)
Fill PSF cube for one observation.
void load(const GFilename &filename)
Load PSF cube from FITS file.
void set_delta_axis(void)
Set nodes for delta axis in radians.
void copy_members(const GCTACubePsf &cube)
Copy class members.
void init_members(void)
Initialise class members.
int m_inx3
Index of upper right node.
GFilename m_filename
Filename.
void clear_cube(void)
Clear all pixels in the PSF cube.
GCTACubePsf & operator=(const GCTACubePsf &cube)
Assignment operator.
void set_eng_axis(void)
Set nodes for a logarithmic (base 10) energy axis.
void free_members(void)
Delete class members.
GSkyMap m_cube
PSF cube.
const GFilename & filename(void) const
Return exposure cube filename.
GNodeArray m_elogmeans
Mean log10TeV energy for the PSF cube.
double operator()(const GSkyDir &dir, const double &delta, const GEnergy &energy) const
Return point spread function (in units of sr )
virtual ~GCTACubePsf(void)
Destructor.
double m_wgt2
Weight of lower left node.
GNodeArray m_deltas_cache
Internal delta bins (rad)
void set_to_smooth(void)
Pad the last delta bins with zero.
GCTACubePsf(void)
Void constructor.
void clear(void)
Clear instance.
const GSkyMap & cube(void) const
Return psf cube sky map.
double m_wgt4
Weight of lower right node.
const GEnergies & energies(void) const
Return energies.
CTA event bin container class.
CTA observation class.
Energy container class.
Definition GEnergies.hpp:60
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Filename class.
Definition GFilename.hpp:62
FITS file class.
Definition GFits.hpp:63
Information logger interface definition.
Definition GLog.hpp:62
Node array class.
int size(void) const
Return number of nodes in node array.
Observation container class.
Sky direction class.
Definition GSkyDir.hpp:62
Sky map class.
Definition GSkyMap.hpp:89
const double deg2rad
Definition GMath.hpp:43
const std::string extname_deltas