GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 _______________________________________________ */
40 class GFilename;
41 class GObservations;
42 class GCTAEventCube;
43 class GCTAObservation;
44 
45 /* __ Constants __________________________________________________________ */
46 namespace 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  ***************************************************************************/
62 class GCTACubePsf : public GBase {
63 
64 public:
65 
66  // Constructors and destructors
67  GCTACubePsf(void);
69  explicit GCTACubePsf(const GFilename& filename);
70  GCTACubePsf(const GCTAEventCube& cube,
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
86  GCTACubePsf& operator=(const GCTACubePsf& cube);
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 
110 protected:
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 
132 private:
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  ***************************************************************************/
150 inline
151 std::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  ***************************************************************************/
166 inline
167 const GSkyMap& GCTACubePsf::cube(void) const
168 {
169  return (m_cube);
170 }
171 
172 
173 /***********************************************************************//**
174  * @brief Return energies
175  *
176  * @return Energies
177  ***************************************************************************/
178 inline
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  ***************************************************************************/
190 inline
191 const GNodeArray& GCTACubePsf::deltas(void) const
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  ***************************************************************************/
202 inline
203 double 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  ***************************************************************************/
221 inline
223 {
224  return (m_filename);
225 }
226 
227 
228 /***********************************************************************//**
229  * @brief Return map offset
230  *
231  * @return Map offset.
232  ***************************************************************************/
233 inline
234 int GCTACubePsf::offset(const int& idelta, const int& iebin) const
235 {
236  return (idelta + iebin*m_deltas.size());
237 }
238 
239 #endif /* GCTACUBEPSF_HPP */
void save(const GFilename &filename, const bool &clobber=false) const
Save PSF cube into FITS file.
const GEnergies & energies(void) const
Return energies.
int size(void) const
Return number of nodes in node array.
Definition: GNodeArray.hpp:192
Sky map class.
Definition: GSkyMap.hpp:89
Node array class.
Definition: GNodeArray.hpp:60
GNodeArray m_deltas
Delta bins (deg) for the PSF cube.
void update(const double &delta, const double &logE) const
Update PSF parameter cache.
void load(const GFilename &filename)
Load PSF cube from FITS file.
void clear(void)
Clear instance.
GCTACubePsf & operator=(const GCTACubePsf &cube)
Assignment operator.
void free_members(void)
Delete class members.
void write(GFits &file) const
Write CTA PSF cube into FITS object.
Definition of interface for all GammaLib classes.
GNodeArray m_deltas_cache
Internal delta bins (rad)
const std::string extname_deltas
Definition: GCTACubePsf.hpp:47
const GNodeArray & deltas(void) const
Return offset angles between true and measured photon direction.
FITS file class.
Definition: GFits.hpp:63
FITS file class interface definition.
GFilename m_filename
Filename.
int m_inx1
Index of upper left node.
Sky map class definition.
Energy container class.
Definition: GEnergies.hpp:60
double m_wgt4
Weight of lower right node.
void fill(const GObservations &obs, GLog *log=NULL)
Fill PSF cube from observation container.
Information logger interface definition.
Definition: GLog.hpp:62
const double deg2rad
Definition: GMath.hpp:43
Node array class interface definition.
CTA event bin container class.
double operator()(const GSkyDir &dir, const double &delta, const GEnergy &energy) const
Return point spread function (in units of sr )
void init_members(void)
Initialise class members.
Filename class.
Definition: GFilename.hpp:62
Energy container class definition.
double m_wgt3
Weight of upper right node.
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
GCTACubePsf * clone(void) const
Clone instance.
int m_inx3
Index of upper right node.
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
Definition: GVector.cpp:1274
void read(const GFits &fits)
Read PSF cube from FITS object.
int m_inx2
Index of lower left node.
void set_eng_axis(void)
Set nodes for a logarithmic (base 10) energy axis.
const GSkyMap & cube(void) const
Return psf cube sky map.
GChatter
Definition: GTypemaps.hpp:33
std::string classname(void) const
Return class name.
Observation container class.
GCTACubePsf(void)
Void constructor.
Definition: GCTACubePsf.cpp:68
void set_delta_axis(void)
Set nodes for delta axis in radians.
void set(const GCTAObservation &obs)
Set PSF cube from one CTA observation.
GEnergies m_energies
Energy values for the PSF cube.
void clear_cube(void)
Clear all pixels in the PSF cube.
GSkyMap m_cube
PSF cube.
CTA point spread function for cube analysis.
Definition: GCTACubePsf.hpp:62
int m_inx4
Index of lower right node.
std::string print(const GChatter &chatter=NORMAL) const
Print PSF cube information.
double delta_max(void) const
Return maximum delta value in radians.
void fill_cube(const GCTAObservation &obs, GSkyMap *exposure=NULL, GLog *log=NULL)
Fill PSF cube for one observation.
GNodeArray m_elogmeans
Mean log10TeV energy for the PSF cube.
void set_to_smooth(void)
Pad the last delta bins with zero.
CTA observation class.
virtual ~GCTACubePsf(void)
Destructor.
const GFilename & filename(void) const
Return exposure cube filename.
Sky direction class.
Definition: GSkyDir.hpp:62
int offset(const int &idelta, const int &iebin) const
Return map offset.
bool m_quadratic_binning
Internal binning is linear.
double m_wgt2
Weight of lower left node.
void copy_members(const GCTACubePsf &cube)
Copy class members.
double m_wgt1
Weight of upper left node.
Mathematical function definitions.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48