GammaLib 2.1.0.dev
Loading...
Searching...
No Matches
GCTACubeBackground.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCTACubeBackground.hpp - CTA cube background class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2015-2018 by Michael Mayer *
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 GCTACubeBackground.hpp
23 * @brief CTA cube background class definition
24 * @author Michael Mayer
25 */
26
27#ifndef GCTACUBEBACKGROUND_HPP
28#define GCTACUBEBACKGROUND_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include "GFilename.hpp"
33#include "GSkyMap.hpp"
34#include "GNodeArray.hpp"
35#include "GEbounds.hpp"
36
37/* __ Forward declarations _______________________________________________ */
38class GFits;
39class GFitsBinTable;
40class GRan;
41class GObservations;
42class GCTAInstDir;
43
44
45/***********************************************************************//**
46 * @class GCTACubeBackground
47 *
48 * @brief CTA cube background class
49 ***************************************************************************/
50class GCTACubeBackground : public GBase {
51
52public:
53 // Constructors and destructors
55 explicit GCTACubeBackground(const GFilename& filename);
56 explicit GCTACubeBackground(const GCTAEventCube& cube);
58 GCTACubeBackground(const std::string& wcs,
59 const std::string& coords,
60 const double& x,
61 const double& y,
62 const double& dx,
63 const double& dy,
64 const int& nx,
65 const int& ny,
66 const GEbounds& ebounds);
67 virtual ~GCTACubeBackground(void);
68
69 // Operators
71 double operator()(const GCTAInstDir& dir,
72 const GEnergy& energy) const;
73
74 // Methods
75 void clear(void);
76 GCTACubeBackground* clone(void) const;
77 std::string classname(void) const;
78 void fill(const GObservations& obs, GLog* log = NULL);
79 double integral(const double& logE) const;
80 void read(const GFits& fits);
81 void write(GFits& file) const;
82 void load(const GFilename& filename);
83 void save(const GFilename& filename,
84 const bool& clobber = false) const;
85 const GSkyMap& cube(void) const;
86 const GEbounds& ebounds(void) const;
87 const GFilename& filename(void) const;
88 std::string print(const GChatter& chatter = NORMAL) const;
89
90private:
91 // Methods
92 void init_members(void);
93 void copy_members(const GCTACubeBackground& bgd);
94 void free_members(void);
95 void set_eng_axis(void);
96 void update(const double& logE) const;
97
98 // Members
99 mutable GFilename m_filename; //!< Name of background response file
100 GSkyMap m_cube; //!< Background cube
101 GEbounds m_ebounds; //!< Energy boundaries of background cube
102 GNodeArray m_elogmeans; //!< Mean energy for the background cube
103
104 // Response table computation cache for 1D access
105 mutable int m_inx_left; //!< Index of left node
106 mutable int m_inx_right; //!< Index of right node
107 mutable double m_wgt_left; //!< Weight of left node
108 mutable double m_wgt_right; //!< Weight of right node
109
110};
111
112
113/***********************************************************************//**
114 * @brief Return class name
115 *
116 * @return String containing the class name ("GCTACubeBackground").
117 ***************************************************************************/
118inline
119std::string GCTACubeBackground::classname(void) const
120{
121 return ("GCTACubeBackground");
122}
123
124
125/***********************************************************************//**
126 * @brief Return background cube
127 *
128 * @return Sky map holding the background cube.
129 *
130 * Returns the GSkyMap object that is used to store the background cube
131 * information.
132 ***************************************************************************/
133inline
135{
136 return (m_cube);
137}
138
139
140/***********************************************************************//**
141 * @brief Return energy boundaries
142 *
143 * @return Energy boundaries
144 ***************************************************************************/
145inline
147{
148 return (m_ebounds);
149}
150
151
152/***********************************************************************//**
153 * @brief Return background cube filename
154 *
155 * @return Background cube filename.
156 *
157 * Returns the filename from which the background cube was loaded or into
158 * which the background cube has been saved.
159 ***************************************************************************/
160inline
162{
163 return (m_filename);
164}
165
166#endif /* GCTACUBEBACKGROUND_HPP */
Energy boundaries class interface definition.
Filename class interface definition.
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:1342
Interface class for all GammaLib classes.
Definition GBase.hpp:52
CTA cube background class.
GFilename m_filename
Name of background response file.
void init_members(void)
Initialise class members.
void load(const GFilename &filename)
Load background cube from FITS file.
void set_eng_axis(void)
Set nodes for a logarithmic (base 10) energy axis.
void clear(void)
Clear background.
double integral(const double &logE) const
Return spatially integrated background rate in units of events MeV s .
int m_inx_left
Index of left node.
GCTACubeBackground & operator=(const GCTACubeBackground &bgd)
Assignment operator.
void copy_members(const GCTACubeBackground &bgd)
Copy class members.
GCTACubeBackground * clone(void) const
Clone background.
void update(const double &logE) const
Update 1D cache.
std::string classname(void) const
Return class name.
const GFilename & filename(void) const
Return background cube filename.
double m_wgt_left
Weight of left node.
GCTACubeBackground(void)
Void constructor.
std::string print(const GChatter &chatter=NORMAL) const
Print background information.
void free_members(void)
Delete class members.
void write(GFits &file) const
Write CTA background cube into FITS object.
GEbounds m_ebounds
Energy boundaries of background cube.
const GSkyMap & cube(void) const
Return background cube.
double m_wgt_right
Weight of right node.
void fill(const GObservations &obs, GLog *log=NULL)
Fill background cube from observation container.
virtual ~GCTACubeBackground(void)
Destructor.
GSkyMap m_cube
Background cube.
GNodeArray m_elogmeans
Mean energy for the background cube.
double operator()(const GCTAInstDir &dir, const GEnergy &energy) const
Return background rate in units of events MeV s sr .
void read(const GFits &fits)
Read background cube from FITS object.
int m_inx_right
Index of right node.
void save(const GFilename &filename, const bool &clobber=false) const
Save background cube into FITS file.
const GEbounds & ebounds(void) const
Return energy boundaries.
CTA event bin container class.
CTA instrument direction class.
Energy boundaries container class.
Definition GEbounds.hpp:60
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Filename class.
Definition GFilename.hpp:62
FITS binary table class.
FITS file class.
Definition GFits.hpp:63
Information logger interface definition.
Definition GLog.hpp:62
Node array class.
Observation container class.
Random number generator class.
Definition GRan.hpp:44
Sky map class.
Definition GSkyMap.hpp:89