GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 _______________________________________________ */
38 class GFits;
39 class GFitsBinTable;
40 class GRan;
41 class GObservations;
42 class GCTAInstDir;
43 
44 
45 /***********************************************************************//**
46  * @class GCTACubeBackground
47  *
48  * @brief CTA cube background class
49  ***************************************************************************/
50 class GCTACubeBackground : public GBase {
51 
52 public:
53  // Constructors and destructors
54  GCTACubeBackground(void);
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 
90 private:
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  ***************************************************************************/
118 inline
119 std::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  ***************************************************************************/
133 inline
135 {
136  return (m_cube);
137 }
138 
139 
140 /***********************************************************************//**
141  * @brief Return energy boundaries
142  *
143  * @return Energy boundaries
144  ***************************************************************************/
145 inline
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  ***************************************************************************/
160 inline
162 {
163  return (m_filename);
164 }
165 
166 #endif /* GCTACUBEBACKGROUND_HPP */
Sky map class.
Definition: GSkyMap.hpp:89
void init_members(void)
Initialise class members.
Node array class.
Definition: GNodeArray.hpp:60
GEbounds m_ebounds
Energy boundaries of background cube.
void free_members(void)
Delete class members.
const GFilename & filename(void) const
Return background cube filename.
CTA cube background class.
GCTACubeBackground(void)
Void constructor.
Random number generator class.
Definition: GRan.hpp:44
std::string print(const GChatter &chatter=NORMAL) const
Print background information.
FITS file class.
Definition: GFits.hpp:63
Sky map class definition.
void update(const double &logE) const
Update 1D cache.
void write(GFits &file) const
Write CTA background cube into FITS object.
int m_inx_right
Index of right node.
virtual ~GCTACubeBackground(void)
Destructor.
GCTACubeBackground * clone(void) const
Clone background.
GFilename m_filename
Name of background response file.
double m_wgt_left
Weight of left node.
void read(const GFits &fits)
Read background cube from FITS object.
Information logger interface definition.
Definition: GLog.hpp:62
void set_eng_axis(void)
Set nodes for a logarithmic (base 10) energy axis.
Node array class interface definition.
CTA event bin container class.
GNodeArray m_elogmeans
Mean energy for the background cube.
void clear(void)
Clear background.
const GEbounds & ebounds(void) const
Return energy boundaries.
Energy boundaries container class.
Definition: GEbounds.hpp:60
Filename class.
Definition: GFilename.hpp:62
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
Definition: GVector.cpp:1184
const GSkyMap & cube(void) const
Return background cube.
GChatter
Definition: GTypemaps.hpp:33
int m_inx_left
Index of left node.
double integral(const double &logE) const
Return spatially integrated background rate in units of events MeV s .
void copy_members(const GCTACubeBackground &bgd)
Copy class members.
GCTACubeBackground & operator=(const GCTACubeBackground &bgd)
Assignment operator.
Observation container class.
void load(const GFilename &filename)
Load background cube from FITS file.
void fill(const GObservations &obs, GLog *log=NULL)
Fill background cube from observation container.
std::string classname(void) const
Return class name.
FITS binary table class.
void save(const GFilename &filename, const bool &clobber=false) const
Save background cube into FITS file.
Energy boundaries class interface definition.
double m_wgt_right
Weight of right node.
double operator()(const GCTAInstDir &dir, const GEnergy &energy) const
Return background rate in units of events MeV s sr .
CTA instrument direction class.
Definition: GCTAInstDir.hpp:59
Filename class interface definition.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
GSkyMap m_cube
Background cube.