GammaLib 2.0.0
Loading...
Searching...
No Matches
GCTAModelSpatialLookup.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCTAModelSpatialLookup.hpp - Spatial lookup table model *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2019 by Juergen Knoedlseder *
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 GCTAModelSpatialLookup.hpp
23 * @brief Spatial lookup table model interface definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GCTAMODELSPATIALLOOKUP_HPP
28#define GCTAMODELSPATIALLOOKUP_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include "GCTAModelSpatial.hpp"
33#include "GCTAResponseTable.hpp"
34
35/* __ Forward declarations _______________________________________________ */
36class GFilename;
37class GXmlElement;
38class GCTAInstDir;
39class GEnergy;
40class GTime;
41class GEbounds;
42class GFitsTable;
43class GFitsBinTable;
44class GObservations;
45class GCTAObservation;
46
47/* __ Constants __________________________________________________________ */
48namespace gammalib {
49 const std::string extname_cta_spatial_lookup = "RADIAL BACKGROUND LOOKUP";
50}
51
52
53/***********************************************************************//**
54 * @class GCTAModelSpatialLookup
55 *
56 * @brief Spatial lookup table model class
57 ***************************************************************************/
59
60public:
61 // Constructors and destructors
63 explicit GCTAModelSpatialLookup(const GFilename& filename);
65 explicit GCTAModelSpatialLookup(const GXmlElement& xml);
66 GCTAModelSpatialLookup(const double& maxrad,
67 const double& radbin,
68 const GEbounds& ebds);
70 virtual ~GCTAModelSpatialLookup(void);
71
72 // Operators
74
75 // Implemented pure virtual methods
76 virtual void clear(void);
77 virtual GCTAModelSpatialLookup* clone(void) const;
78 virtual std::string classname(void) const;
79 virtual std::string type(void) const;
80 virtual double eval(const GCTAInstDir& dir,
81 const GEnergy& energy,
82 const GTime& time,
83 const bool& gradients = false) const;
84 virtual double mc_max_value(const GCTAObservation& obs) const;
85 virtual void read(const GXmlElement& xml);
86 virtual void write(GXmlElement& xml) const;
87 virtual std::string print(const GChatter& chatter = NORMAL) const;
88
89 // Other methods
90 void fill(const GCTAObservation& obs);
91 void fill(const GObservations& obs);
92 const GCTAResponseTable& table(void) const;
93 void table(const GCTAResponseTable& table);
94 void read(const GFitsTable& table);
95 void write(GFitsBinTable& table) const;
96 void load(const GFilename& filename);
97 void save(const GFilename& filename,
98 const bool& clobber = false) const;
99 double norm(void) const;
100 void norm(const double& norm);
101
102protected:
103 // Protected methods
104 void init_members(void);
105 void copy_members(const GCTAModelSpatialLookup& model);
106 void free_members(void);
107 void prepare_table(void);
108 void normalise_table(void);
109 int table_index(const int& ienergy, const int& itheta) const;
110 void fill_buffer(const GCTAObservation& obs, std::vector<double>& buffer);
111 void set_from_buffer(const std::vector<double>& buffer);
112
113 // Protected members
114 GFilename m_filename; //!< Name of lookup table
115 GCTAResponseTable m_lookup; //!< Lookup table
116 GModelPar m_norm; //!< Normalization factor
117 int m_inx_energy; //!< Energy index
118 int m_inx_theta; //!< Theta index
119};
120
121
122/***********************************************************************//**
123 * @brief Return class name
124 *
125 * @return String containing the class name ("GCTAModelSpatialLookup").
126 ***************************************************************************/
127inline
129{
130 return ("GCTAModelSpatialLookup");
131}
132
133
134/***********************************************************************//**
135 * @brief Return model type
136 *
137 * @return Model type "LookupTable".
138 ***************************************************************************/
139inline
140std::string GCTAModelSpatialLookup::type(void) const
141{
142 return ("LookupTable");
143}
144
145
146/***********************************************************************//**
147 * @brief Return maximum function value for Monte Carlo simulations
148 *
149 * @param[in] obs CTA Observation.
150 * @return Maximum function value for Monte Carlo simulations.
151 *
152 * This method always returns 1.
153 ***************************************************************************/
154inline
156{
157 return 1.0;
158}
159
160
161/***********************************************************************//**
162 * @brief Return lookup table
163 *
164 * @return Lookup table.
165 *
166 * Returns the lookup table.
167 ***************************************************************************/
168inline
170{
171 return m_lookup;
172}
173
174
175/***********************************************************************//**
176 * @brief Get lookup table model normalisation
177 *
178 * @return Lookup table model normalisation.
179 *
180 * Returns the normalisation of the lookup table model.
181 ***************************************************************************/
182inline
184{
185 return (m_norm.value());
186}
187
188
189/***********************************************************************//**
190 * @brief Set lookup table model normalisation
191 *
192 * @param[in] norm Lookup table model normalisation.
193 *
194 * Set the normalisation of the lookup table model.
195 ***************************************************************************/
196inline
198{
200 return;
201}
202
203#endif /* GCTAMODELSPATIALLOOKUP_HPP */
Abstract spatial model class interface definition.
CTA response table class definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
double norm(const GVector &vector)
Computes vector norm.
Definition GVector.cpp:864
CTA instrument direction class.
Spatial lookup table model class.
void load(const GFilename &filename)
Load lookup table.
const GCTAResponseTable & table(void) const
Return lookup table.
virtual void write(GXmlElement &xml) const
Write model into XML element.
void prepare_table(void)
Prepare lookup table indices.
GFilename m_filename
Name of lookup table.
virtual void clear(void)
Clear instance.
void set_from_buffer(const std::vector< double > &buffer)
Set lookup table from buffer.
virtual GCTAModelSpatialLookup * clone(void) const
Clone instance.
void copy_members(const GCTAModelSpatialLookup &model)
Copy class members.
GModelPar m_norm
Normalization factor.
int table_index(const int &ienergy, const int &itheta) const
Return index of lookup table element.
virtual double eval(const GCTAInstDir &dir, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
Evaluate function.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print lookup table information.
void free_members(void)
Delete class members.
void fill_buffer(const GCTAObservation &obs, std::vector< double > &buffer)
Fill buffer from events in CTA observation.
virtual double mc_max_value(const GCTAObservation &obs) const
Return maximum function value for Monte Carlo simulations.
virtual std::string type(void) const
Return model type.
void save(const GFilename &filename, const bool &clobber=false) const
Save lookup table into FITS file.
void fill(const GCTAObservation &obs)
Fill lookup table with events from one CTA observation.
virtual GCTAModelSpatialLookup & operator=(const GCTAModelSpatialLookup &model)
Assignment operator.
GCTAResponseTable m_lookup
Lookup table.
virtual void read(const GXmlElement &xml)
Read model from XML element.
void init_members(void)
Initialise class members.
GCTAModelSpatialLookup(void)
Void constructor.
double norm(void) const
Get lookup table model normalisation.
virtual ~GCTAModelSpatialLookup(void)
Destructor.
virtual std::string classname(void) const
Return class name.
void normalise_table(void)
Normalise lookup table.
Abstract spatial model class.
CTA observation class.
CTA response table 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.
Abstract interface for FITS table.
Model parameter class.
Definition GModelPar.hpp:87
Observation container class.
double value(void) const
Return parameter value.
Time class.
Definition GTime.hpp:55
XML element node class.
const std::string extname_cta_spatial_lookup