GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpatialEllipticalGeneralGauss.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelSpatialEllipticalGeneralGauss.hpp - Generalised elliptical *
3  * Gaussian source model class *
4  * ----------------------------------------------------------------------- *
5  * copyright (C) 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 GModelSpatialEllipticalGeneralGauss.hpp
24  * @brief Generalised elliptical gaussian model class interface definition
25  * @author Luigi Tibaldo
26  */
27 
28 #ifndef GMODELSPATIALELLIPTICALGENERALGAUSS_HPP
29 #define GMODELSPATIALELLIPTICALGENERALGAUSS_HPP
30 
31 /* __ Includes ___________________________________________________________ */
32 #include <string>
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 GModelSpatialEllipticalGeneralGauss
48  *
49  * @brief Generalised elliptical gaussian source model class
50  *
51  * This class implements the spatial component of the factorised source
52  * model for an generalised elliptical Gaussian source, i.e. surface
53  * brightness according to an asymmetric generalised Gaussian.
54  ***************************************************************************/
56 
57 public:
58  // Constructors and destructors
61  const double& major,
62  const double& minor,
63  const double& posangle,
64  const double& ridx,
65  const std::string& coordsys = "CEL");
69 
70  // Operators
72 
73  // Implemented pure virtual base class methods
74  virtual void clear(void);
75  virtual GModelSpatialEllipticalGeneralGauss* clone(void) const;
76  virtual std::string classname(void) const;
77  virtual double eval(const double& theta,
78  const double& posangle,
79  const GEnergy& energy,
80  const GTime& time,
81  const bool& gradients = false) const;
82  virtual GSkyDir mc(const GEnergy& energy,
83  const GTime& time,
84  GRan& ran) const;
85  virtual bool contains(const GSkyDir& dir,
86  const double& margin = 0.0) const;
87  virtual double theta_max(void) const;
88  virtual void read(const GXmlElement& xml);
89  virtual void write(GXmlElement& xml) const;
90  virtual std::string print(const GChatter& chatter = NORMAL) const;
91 
92  // Other methods
93  double ridx(void) const;
94  void ridx(const double& ridx);
95 
96 
97 protected:
98  // Protected methods
99  void init_members(void);
101  void free_members(void);
102  void update(void) const;
103  virtual void set_region(void) const;
104 
105  // Protected members
106  GModelPar m_ridx; //!< Reciprocal of exponent of the radial profile
107 
108  // Cached members used for pre-computations
109  mutable double m_last_minor; //!< Last semi-minor axis
110  mutable double m_last_major; //!< Last semi-major axis
111  mutable double m_last_posangle; //!< Last position angle
112  mutable double m_cospos2; //!< squared cosine of position angle
113  mutable double m_sinpos2; //!< squared sine of position angle
114  mutable double m_sin2pos; //!< sine of twice the position angle
115  mutable double m_minor2; //!< square of minor axis
116  mutable double m_major2; //!< square of major axis
117  mutable double m_minor_rad; //!< Minor axis in radians
118  mutable double m_major_rad; //!< Major axis in radians
119  mutable double m_norm; //!< Normalization
120  mutable double m_term1; //!< Help term 1
121  mutable double m_term2; //!< Help term 2
122  mutable double m_term3; //!< Help term 3
123  mutable double m_last_ridx; //!< Last reciprocal radial index
124  mutable double m_inv_ridx; //!< Spatial profile index
125 
126 };
127 
128 
129 /***********************************************************************//**
130  * @brief Return class name
131  *
132  * @return String containing the class name ("GModelSpatialEllipticalGeneralGauss").
133  ***************************************************************************/
134 inline
136 {
137  return ("GModelSpatialEllipticalGeneralGauss");
138 }
139 
140 /***********************************************************************//**
141  * @brief Return reciprocal of the elliptical profile index
142  *
143  * @return Reciprocal of the elliptical profile index.
144  *
145  * Returns the reciprocal of the elliptical profile index.
146  ***************************************************************************/
147 inline
149 {
150  return (m_ridx.value());
151 }
152 
153 /***********************************************************************//**
154  * @brief Set reciprocal of the elliptical profile index
155  *
156  * @param[in] ridx Reciprocal of the elliptical profile index.
157  *
158  * Sets the reciprocal of the elliptical profile index.
159  ***************************************************************************/
160 inline
162 {
163  m_ridx.value(ridx);
164  return;
165 }
166 
167 #endif /* GMODELSPATIALELLIPTICALGENERALGAUSS_HPP */
Abstract elliptical spatial model base class.
virtual void clear(void)
Clear generalised elliptical Gaussian model.
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual double eval(const double &theta, const double &posangle, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
Evaluate function (in units of sr^-1)
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
XML element node class.
Definition: GXmlElement.hpp:48
const GSkyDir & dir(void) const
Return position of elliptical spatial model.
Random number generator class.
Definition: GRan.hpp:44
Time class.
Definition: GTime.hpp:55
virtual std::string print(const GChatter &chatter=NORMAL) const
Print information.
virtual void set_region(void) const
Set boundary sky region.
Model parameter class interface definition.
Class that handles photons.
Definition: GPhoton.hpp:47
Model parameter class.
Definition: GModelPar.hpp:87
Abstract interface for the sky region class.
Definition: GSkyRegion.hpp:57
virtual std::string classname(void) const
Return class name.
GModelPar m_ridx
Reciprocal of exponent of the radial profile.
virtual double theta_max(void) const
Return maximum model radius (in radians)
GChatter
Definition: GTypemaps.hpp:33
virtual GModelSpatialEllipticalGeneralGauss & operator=(const GModelSpatialEllipticalGeneralGauss &model)
Assignment operator.
std::string coordsys(void) const
Return coordinate system.
Abstract elliptical spatial model base class interface definition.
void update(void) const
Update precomputation cache.
void copy_members(const GModelSpatialEllipticalGeneralGauss &model)
Copy class members.
double ridx(void) const
Return reciprocal of the elliptical profile index.
double posangle(void) const
Return Position Angle of model.
double value(void) const
Return parameter value.
double m_sin2pos
sine of twice the position angle
double m_cospos2
squared cosine of position angle
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks whether model contains specified sky direction.
Sky direction class.
Definition: GSkyDir.hpp:62
virtual GModelSpatialEllipticalGeneralGauss * clone(void) const
Clone generalised elliptical Gaussian model.
virtual void write(GXmlElement &xml) const
Write model into XML element.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48