GammaLib 2.0.0
Loading...
Searching...
No Matches
GModelSpatialElliptical.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GModelSpatialElliptical.hpp - Abstract elliptical spatial model class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2013-2022 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 GModelSpatialElliptical.hpp
23 * @brief Abstract elliptical spatial model base class interface definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GMODELSPATIALELLIPTICAL_HPP
28#define GMODELSPATIALELLIPTICAL_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include <vector>
33#include "GModelSpatial.hpp"
34#include "GModelPar.hpp"
35#include "GSkyDir.hpp"
36
37/* __ Forward declarations _______________________________________________ */
38class GEnergy;
39class GTime;
40class GPhoton;
41class GRan;
42class GSkyRegion;
43class GXmlElement;
44
45
46/***********************************************************************//**
47 * @class GModelSpatialElliptical
48 *
49 * @brief Abstract elliptical spatial model base class
50 *
51 * This class defines the interface for an elliptical model as spatial
52 * component of the factorized source model. Typical examples of elliptical
53 * components are elliptical Disk, Gaussian or Shell shaped sources.
54 ***************************************************************************/
56
57public:
58 // Constructors and destructors
61 explicit GModelSpatialElliptical(const GXmlElement& xml);
62 virtual ~GModelSpatialElliptical(void);
63
64 // Operators
66
67 // Pure virtual methods
68 virtual void clear(void) = 0;
69 virtual GModelSpatialElliptical* clone(void) const = 0;
70 virtual std::string classname(void) const = 0;
71 virtual double eval(const double& theta,
72 const double& posangle,
73 const GEnergy& energy,
74 const GTime& time,
75 const bool& gradients = false) const = 0;
76 virtual GSkyDir mc(const GEnergy& energy,
77 const GTime& time,
78 GRan& ran) const = 0;
79 virtual bool contains(const GSkyDir& dir,
80 const double& margin = 0.0) const = 0;
81 virtual double theta_max(void) const = 0;
82 virtual std::string print(const GChatter& chatter = NORMAL) const = 0;
83
84 // Implemented virtual base class methods
85 virtual GClassCode code(void) const;
86 virtual double eval(const GPhoton& photon,
87 const bool& gradients = false) const;
88 virtual double mc_norm(const GSkyDir& dir, const double& radius) const;
89 virtual void read(const GXmlElement& xml);
90 virtual void write(GXmlElement& xml) const;
91
92 // Other methods
93 std::string coordsys(void) const;
94 const GSkyDir& dir(void) const;
95 void dir(const GSkyDir& dir);
96 double posangle(void) const;
97 void posangle(const double& posangle);
98 double semiminor(void) const;
99 double semimajor(void) const;
100 void semiminor(const double& semiminor);
101 void semimajor(const double& semimajor);
102
103protected:
104 // Protected methods
105 void init_members(void);
106 void copy_members(const GModelSpatialElliptical& model);
107 void free_members(void);
108 bool is_celestial(void) const;
109 virtual void set_region(void) const = 0;
110
111 // Protected members
112 GModelPar m_lon; //!< Right Ascension or Galactic longitude (deg)
113 GModelPar m_lat; //!< Declination or Galactic latitude (deg)
114 GModelPar m_posangle; //!< Position angle from North, counterclockwise (deg)
115 GModelPar m_semiminor; //!< Semi-minor axis of ellipse (deg)
116 GModelPar m_semimajor; //!< Semi-major axis of ellipse (deg)
117
118 // Cached members for sky direction handling
119 mutable GSkyDir m_dir; //!< Sky direction representing parameters
120 mutable double m_last_lon; //!< Last longitude
121 mutable double m_last_lat; //!< Last latitude
122};
123
124
125/***********************************************************************//**
126 * @brief Return class code
127 *
128 * @return GModelSpatialElliptical.
129 *
130 * Returns the code GModelSpatialElliptical of the class.
131 ***************************************************************************/
132inline
137
138
139/***********************************************************************//**
140 * @brief Return Position Angle of model
141 *
142 * @return Position Angle of model (degrees).
143 *
144 * Returns the Position Angle of model in degrees, measured counterclockwise
145 * from celestial North.
146 ***************************************************************************/
147inline
149{
150 return (m_posangle.value());
151}
152
153
154/***********************************************************************//**
155 * @brief Set Position Angle of model
156 *
157 * @param[in] posangle Position Angle of model (degrees).
158 *
159 * Sets the Position Angle of model in degrees, measured counterclockwise
160 * from celestial North.
161 ***************************************************************************/
162inline
163void GModelSpatialElliptical::posangle(const double& posangle)
164{
166 return;
167}
168
169
170/***********************************************************************//**
171 * @brief Return semi-minor axis of ellipse
172 *
173 * @return Semi-minor axis of ellipse (degrees).
174 *
175 * Returns the semi-minor axis of the ellipse in degrees.
176 ***************************************************************************/
177inline
179{
180 return (m_semiminor.value());
181}
182
183
184/***********************************************************************//**
185 * @brief Set semi-minor axis of ellipse
186 *
187 * @param[in] semiminor Semi-minor axis of ellipse (degrees)
188 *
189 * Sets the semi-minor axis of the ellipse in degrees.
190 ***************************************************************************/
191inline
192void GModelSpatialElliptical::semiminor(const double& semiminor)
193{
195 return;
196}
197
198
199/***********************************************************************//**
200 * @brief Return semi-major axis of ellipse
201 *
202 * @return Semi-major axis of ellipse (degrees).
203 *
204 * Returns the semi-major axis of the ellipse in degrees.
205 ***************************************************************************/
206inline
208{
209 return (m_semimajor.value());
210}
211
212
213/***********************************************************************//**
214 * @brief Set semi-major axis of ellipse
215 *
216 * @param[in] semimajor Semi-major axis of ellipse (degrees)
217 *
218 * Sets the semi-major axis of the ellipse in degrees.
219 ***************************************************************************/
220inline
221void GModelSpatialElliptical::semimajor(const double& semimajor)
222{
224 return;
225}
226
227
228/***********************************************************************//**
229 * @brief Return normalization of elliptical source for Monte Carlo
230 * simulations
231 *
232 * @param[in] dir Centre of simulation cone.
233 * @param[in] radius Radius of simulation cone (degrees).
234 * @return Normalization.
235 *
236 * Returns the normalization for an elliptical source within a circular
237 * region. The normalization is 1 if the elliptical source falls within
238 * the circle define by @p dir and @p radius, 0 otherwise.
239 ***************************************************************************/
240inline
242 const double& radius) const
243{
244 double norm = (dir.dist_deg(this->dir()) <= radius+theta_max()) ? 1.0 : 0.0;
245 return (norm);
246}
247
248
249/***********************************************************************//**
250 * @brief Return coordinate system
251 *
252 * @return Coordinate system of point source model.
253 *
254 * Returns "CEL" for a celestial coordinate system and "GAL" for a Galactic
255 * coordinate system.
256 ***************************************************************************/
257inline
259{
260 return (is_celestial() ? "CEL" : "GAL");
261}
262
263
264/***********************************************************************//**
265 * @brief Check if model holds celestial coordinates
266 *
267 * @return True if model holds celestial coordinates, false otherwise.
268 ***************************************************************************/
269inline
271{
272 return (m_lon.name() == "RA");
273}
274
275#endif /* GMODELSPATIALELLIPTICAL_HPP */
Model parameter class interface definition.
Abstract spatial model base class interface definition.
Sky direction class interface definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
GClassCode
Definition GTypemaps.hpp:42
@ GMODEL_SPATIAL_ELLIPTICAL
Definition GTypemaps.hpp:45
double norm(const GVector &vector)
Computes vector norm.
Definition GVector.cpp:864
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Model parameter class.
Definition GModelPar.hpp:87
Abstract elliptical spatial model base class.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const =0
void init_members(void)
Initialise class members.
virtual std::string classname(void) const =0
Return class name.
void copy_members(const GModelSpatialElliptical &model)
Copy class members.
GModelPar m_semiminor
Semi-minor axis of ellipse (deg)
double semimajor(void) const
Return semi-major axis of ellipse.
virtual GClassCode code(void) const
Return class code.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const =0
virtual void write(GXmlElement &xml) const
Write model into XML element.
virtual double mc_norm(const GSkyDir &dir, const double &radius) const
Return normalization of elliptical source for Monte Carlo simulations.
virtual ~GModelSpatialElliptical(void)
Destructor.
virtual GModelSpatialElliptical * clone(void) const =0
Clones object.
bool is_celestial(void) const
Check if model holds celestial coordinates.
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
virtual void clear(void)=0
Clear object.
virtual void set_region(void) const =0
GModelPar m_semimajor
Semi-major axis of ellipse (deg)
GModelPar m_lat
Declination or Galactic latitude (deg)
virtual double eval(const double &theta, const double &posangle, const GEnergy &energy, const GTime &time, const bool &gradients=false) const =0
void free_members(void)
Delete class members.
GSkyDir m_dir
Sky direction representing parameters.
double posangle(void) const
Return Position Angle of model.
virtual GModelSpatialElliptical & operator=(const GModelSpatialElliptical &model)
Assignment operator.
GModelPar m_lon
Right Ascension or Galactic longitude (deg)
GModelSpatialElliptical(void)
Void constructor.
const GSkyDir & dir(void) const
Return position of elliptical spatial model.
std::string coordsys(void) const
Return coordinate system.
double semiminor(void) const
Return semi-minor axis of ellipse.
virtual double theta_max(void) const =0
virtual void read(const GXmlElement &xml)
Read model from XML element.
GModelPar m_posangle
Position angle from North, counterclockwise (deg)
Abstract spatial model base class.
double value(void) const
Return parameter value.
const std::string & name(void) const
Return parameter name.
Class that handles photons.
Definition GPhoton.hpp:47
Random number generator class.
Definition GRan.hpp:44
Sky direction class.
Definition GSkyDir.hpp:62
double dist_deg(const GSkyDir &dir) const
Compute angular distance between sky directions in degrees.
Definition GSkyDir.hpp:286
Abstract interface for the sky region class.
Time class.
Definition GTime.hpp:55
XML element node class.