GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpatialRadialGauss.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelSpatialRadialGauss.hpp - Radial Gaussian source model class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2011-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 GModelSpatialRadialGauss.hpp
23  * @brief Radial Gaussian model class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GMODELSPATIALRADIALGAUSS_HPP
28 #define GMODELSPATIALRADIALGAUSS_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GModelSpatialRadial.hpp"
33 #include "GModelPar.hpp"
34 
35 /* __ Forward declarations _______________________________________________ */
36 class GEnergy;
37 class GTime;
38 class GPhoton;
39 class GRan;
40 class GSkyDir;
41 class GSkyRegion;
42 class GXmlElement;
43 
44 
45 /***********************************************************************//**
46  * @class GModelSpatialRadialGauss
47  *
48  * @brief Radial Gaussian model class
49  *
50  * This class implements the spatial component of the factorised source
51  * model for a Gaussian source.
52  ***************************************************************************/
54 
55 public:
56  // Constructors and destructors
58  GModelSpatialRadialGauss(const bool& dummy, const std::string& type);
60  const double& sigma,
61  const std::string& coordsys = "CEL");
62  explicit GModelSpatialRadialGauss(const GXmlElement& xml);
64  virtual ~GModelSpatialRadialGauss(void);
65 
66  // Operators
68 
69  // Implemented pure virtual methods
70  virtual void clear(void);
71  virtual GModelSpatialRadialGauss* clone(void) const;
72  virtual std::string classname(void) const;
73  virtual double eval(const double& theta,
74  const GEnergy& energy,
75  const GTime& time,
76  const bool& gradients = false) const;
77  virtual GSkyDir mc(const GEnergy& energy,
78  const GTime& time,
79  GRan& ran) const;
80  virtual bool contains(const GSkyDir& dir,
81  const double& margin = 0.0) const;
82  virtual double theta_max(void) const;
83  virtual void read(const GXmlElement& xml);
84  virtual void write(GXmlElement& xml) const;
85  virtual std::string print(const GChatter& chatter = NORMAL) const;
86 
87  // Other methods
88  double sigma(void) const;
89  void sigma(const double& sigma);
90 
91 protected:
92  // Protected methods
93  void init_members(void);
94  void copy_members(const GModelSpatialRadialGauss& model);
95  void free_members(void);
96  void update(const bool& gradients) const;
97  virtual void set_region(void) const;
98 
99  // Protected members
100  GModelPar m_sigma; //!< Gaussian width (deg)
101 
102  // Cached members used for pre-computations
103  mutable double m_last_sigma; //!< Last Gaussian sigma
104  mutable double m_inv_sigma2_rad; //!< sigma(rad)^-2
105  mutable double m_value_norm; //!< (2pi sigma(rad))^-2
106  mutable double m_g_theta_norm; //!< sigma(rad)^-2 deg2rad
107  mutable double m_g_sigma_norm; //!< sigma(rad)^-1 sigma_scale deg2rad
108 };
109 
110 
111 /***********************************************************************//**
112  * @brief Return class name
113  *
114  * @return String containing the class name ("GModelSpatialRadialGauss").
115  ***************************************************************************/
116 inline
117 std::string GModelSpatialRadialGauss::classname(void) const
118 {
119  return ("GModelSpatialRadialGauss");
120 }
121 
122 
123 /***********************************************************************//**
124  * @brief Return Gaussian sigma
125  *
126  * @return Gaussian sigma (degrees).
127  *
128  * Returns the Gaussian sigma in degrees.
129  ***************************************************************************/
130 inline
132 {
133  return (m_sigma.value());
134 }
135 
136 
137 /***********************************************************************//**
138  * @brief Set Gaussian sigma
139  *
140  * @param[in] sigma Gaussian sigma (degrees).
141  *
142  * Sets the Gaussian sigma in degrees.
143  ***************************************************************************/
144 inline
145 void GModelSpatialRadialGauss::sigma(const double& sigma)
146 {
147  m_sigma.value(sigma);
148  return;
149 }
150 
151 #endif /* GMODELSPATIALRADIALGAUSS_HPP */
double sigma(void) const
Return Gaussian sigma.
virtual double theta_max(void) const
Return maximum model radius (in radians)
Abstract radial spatial model base class interface definition.
XML element node class.
Definition: GXmlElement.hpp:48
std::string coordsys(void) const
Return coordinate system.
Random number generator class.
Definition: GRan.hpp:44
Time class.
Definition: GTime.hpp:55
virtual void write(GXmlElement &xml) const
Write model into XML element.
GModelPar m_sigma
Gaussian width (deg)
void copy_members(const GModelSpatialRadialGauss &model)
Copy class members.
virtual GModelSpatialRadialGauss * clone(void) const
Clone radial Gauss model.
Model parameter class interface definition.
Class that handles photons.
Definition: GPhoton.hpp:47
Model parameter class.
Definition: GModelPar.hpp:87
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
Abstract interface for the sky region class.
Definition: GSkyRegion.hpp:57
const GSkyDir & dir(void) const
Return position of radial spatial model.
GModelSpatialRadialGauss(void)
Void constructor.
double m_g_theta_norm
sigma(rad)^-2 deg2rad
double m_value_norm
(2pi sigma(rad))^-2
double m_g_sigma_norm
sigma(rad)^-1 sigma_scale deg2rad
virtual void read(const GXmlElement &xml)
Read model from XML element.
GChatter
Definition: GTypemaps.hpp:33
virtual void set_region(void) const
Set boundary sky region.
virtual double eval(const double &theta, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
Evaluate Gaussian source model.
std::string type(void) const
Return model type.
virtual std::string classname(void) const
Return class name.
void init_members(void)
Initialise class members.
double value(void) const
Return parameter value.
double m_last_sigma
Last Gaussian sigma.
virtual GModelSpatialRadialGauss & operator=(const GModelSpatialRadialGauss &model)
Assignment operator.
Abstract radial spatial model base class.
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.
Radial Gaussian model class.
void update(const bool &gradients) const
Update precomputation cache.
Sky direction class.
Definition: GSkyDir.hpp:62
virtual void clear(void)
Clear radial Gauss model.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print Gaussian source information.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
virtual ~GModelSpatialRadialGauss(void)
Destructor.