GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpatialRadialGeneralGauss.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelSpatialRadialGeneralGauss.hpp - Generalised radial Gaussian *
3  * source model class *
4  * ----------------------------------------------------------------------- *
5  * copyright (C) 2021-2022 by Luigi Tibaldo *
6  * ----------------------------------------------------------------------- *
7  * *
8  * This program is free software: you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation, either version 3 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
20  * *
21  ***************************************************************************/
22 /**
23  * @file GModelSpatialRadialGeneralGauss.hpp
24  * @brief Generalized radial Gaussian model class interface definition
25  * @author Luigi Tibaldo
26  */
27 
28 #ifndef GMODELSPATIALRADIALGENERALGAUSS_HPP
29 #define GMODELSPATIALRADIALGENERALGAUSS_HPP
30 
31 /* __ Includes ___________________________________________________________ */
32 #include <string>
33 #include "GModelSpatialRadial.hpp"
34 #include "GModelPar.hpp"
35 
36 /* __ Forward declarations _______________________________________________ */
37 class GEnergy;
38 class GTime;
39 class GPhoton;
40 class GRan;
41 class GSkyDir;
42 class GSkyRegion;
43 class GXmlElement;
44 
45 
46 /***********************************************************************//**
47  * @class GModelSpatialRadialGeneralGauss
48  *
49  * @brief Generalized radial Gaussian model class
50  *
51  * This class implements the spatial component of the factorised source
52  * model for a generalised radial Gaussian source.
53  ***************************************************************************/
55 
56 public:
57  // Constructors and destructors
60  const double& radius,
61  const double& ridx,
62  const std::string& coordsys = "CEL");
63  explicit GModelSpatialRadialGeneralGauss(const GXmlElement& xml);
66 
67  // Operators
69 
70  // Implemented pure virtual methods
71  virtual void clear(void);
72  virtual GModelSpatialRadialGeneralGauss* clone(void) const;
73  virtual std::string classname(void) const;
74  virtual double eval(const double& theta,
75  const GEnergy& energy,
76  const GTime& time,
77  const bool& gradients = false) const;
78  virtual GSkyDir mc(const GEnergy& energy,
79  const GTime& time,
80  GRan& ran) const;
81  virtual bool contains(const GSkyDir& dir,
82  const double& margin = 0.0) const;
83  virtual double theta_max(void) const;
84  virtual void read(const GXmlElement& xml);
85  virtual void write(GXmlElement& xml) const;
86  virtual std::string print(const GChatter& chatter = NORMAL) const;
87 
88  // Other methods
89  double radius(void) const;
90  void radius(const double& radius);
91  double ridx(void) const;
92  void ridx(const double& ridx);
93 
94 protected:
95  // Protected methods
96  void init_members(void);
98  void free_members(void);
99  void update(void) const;
100  virtual void set_region(void) const;
101 
102  // Protected members
103  GModelPar m_radius; //!< Gaussian width (deg)
104  GModelPar m_ridx; //!< Reciprocal of exponent of the radial profile
105 
106  // Cached members used for pre-computations
107  mutable double m_last_radius; //!< Last radius
108  mutable double m_inv_radius_rad; //!< radius(rad)^-1
109  mutable double m_last_ridx; //!< Last reciprocal radial index
110  mutable double m_inv_ridx; //!< Spatial profile index
111  mutable double m_value_norm; //!< 1/(2pi radius(rad)^2 ridx Gamma(ridx))
112 };
113 
114 
115 /***********************************************************************//**
116  * @brief Return class name
117  *
118  * @return String containing the class name ("GModelSpatialRadialGeneralGauss").
119  ***************************************************************************/
120 inline
122 {
123  return ("GModelSpatialRadialGeneralGauss");
124 }
125 
126 
127 /***********************************************************************//**
128  * @brief Return radius
129  *
130  * @return Radius (deg).
131  *
132  * Returns the radius in degrees.
133  ***************************************************************************/
134 inline
136 {
137  return (m_radius.value());
138 }
139 
140 /***********************************************************************//**
141  * @brief Set radius
142  *
143  * @param[in] radius (deg).
144  *
145  * Sets the radius in degrees.
146  ***************************************************************************/
147 inline
148 void GModelSpatialRadialGeneralGauss::radius(const double& radius)
149 {
150  m_radius.value(radius);
151  return;
152 }
153 
154 /***********************************************************************//**
155  * @brief Return ridx
156  *
157  * @return Reciprocal of the radial profile index.
158  *
159  * Returns the reciprocal of the radial profile index.
160  ***************************************************************************/
161 inline
163 {
164  return (m_ridx.value());
165 }
166 
167 /***********************************************************************//**
168  * @brief Set reciprocal index
169  *
170  * @param[in] ridx Reciprocal of the radial profile index.
171  *
172  * Sets the reciprocal index of the radial profile.
173  ***************************************************************************/
174 inline
176 {
177  m_ridx.value(ridx);
178  return;
179 }
180 
181 #endif /* GMODELSPATIALRADIALGENERALGAUSS_HPP */
virtual void clear(void)
Clear radial Gauss model.
GModelPar m_ridx
Reciprocal of exponent of the radial profile.
virtual ~GModelSpatialRadialGeneralGauss(void)
Destructor.
virtual void read(const GXmlElement &xml)
Read model from XML element.
void update(void) const
Update precomputation cache.
Abstract radial spatial model base class interface definition.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
XML element node class.
Definition: GXmlElement.hpp:48
virtual void set_region(void) const
Set boundary sky region.
std::string coordsys(void) const
Return coordinate system.
Random number generator class.
Definition: GRan.hpp:44
Time class.
Definition: GTime.hpp:55
Model parameter class interface definition.
Class that handles photons.
Definition: GPhoton.hpp:47
Model parameter class.
Definition: GModelPar.hpp:87
void init_members(void)
Initialise class members.
Abstract interface for the sky region class.
Definition: GSkyRegion.hpp:57
const GSkyDir & dir(void) const
Return position of radial spatial model.
virtual GModelSpatialRadialGeneralGauss & operator=(const GModelSpatialRadialGeneralGauss &model)
Assignment operator.
virtual double theta_max(void) const
Return maximum model radius (in radians)
virtual GModelSpatialRadialGeneralGauss * clone(void) const
Clone radial Gauss model.
double radius(void) const
Return radius.
GChatter
Definition: GTypemaps.hpp:33
double m_last_ridx
Last reciprocal radial index.
void free_members(void)
Delete class members.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks where model contains specified sky direction.
double value(void) const
Return parameter value.
Generalized radial Gaussian model class.
virtual std::string classname(void) const
Return class name.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print generalised radial Gaussian source information.
void copy_members(const GModelSpatialRadialGeneralGauss &model)
Copy class members.
Abstract radial spatial model base class.
virtual void write(GXmlElement &xml) const
Write model into XML element.
Sky direction class.
Definition: GSkyDir.hpp:62
double m_value_norm
1/(2pi radius(rad)^2 ridx Gamma(ridx))
virtual double eval(const double &theta, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
Evaluate Generalised Gaussian source model.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48