GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpatialEllipticalGauss.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelSpatialEllipticalGauss.hpp - Elliptical gauss source model class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2015-2022 by Michael Mayer *
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 GModelSpatialEllipticalGauss.hpp
23  * @brief Elliptical gauss model class interface definition
24  * @author Michael Mayer
25  */
26 
27 #ifndef GMODELSPATIALELLIPTICALGAUSS_HPP
28 #define GMODELSPATIALELLIPTICALGAUSS_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
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 GModelSpatialEllipticalGauss
47  *
48  * @brief Elliptical gauss source model class
49  *
50  * This class implements the spatial component of the factorised source
51  * model for an elliptical gauss source, i.e. constant surface brightness
52  * according to an asymmetric Gaussian.
53  ***************************************************************************/
55 
56 public:
57  // Constructors and destructors
59  GModelSpatialEllipticalGauss(const bool& dummy, const std::string& type);
61  const double& major,
62  const double& minor,
63  const double& posangle,
64  const std::string& coordsys = "CEL");
65  explicit GModelSpatialEllipticalGauss(const GXmlElement& xml);
67  virtual ~GModelSpatialEllipticalGauss(void);
68 
69  // Operators
71 
72  // Implemented pure virtual base class methods
73  virtual void clear(void);
74  virtual GModelSpatialEllipticalGauss* clone(void) const;
75  virtual std::string classname(void) const;
76  virtual double eval(const double& theta,
77  const double& posangle,
78  const GEnergy& energy,
79  const GTime& time,
80  const bool& gradients = false) const;
81  virtual GSkyDir mc(const GEnergy& energy,
82  const GTime& time,
83  GRan& ran) const;
84  virtual bool contains(const GSkyDir& dir,
85  const double& margin = 0.0) const;
86  virtual double theta_max(void) const;
87  virtual void read(const GXmlElement& xml);
88  virtual void write(GXmlElement& xml) const;
89  virtual std::string print(const GChatter& chatter = NORMAL) const;
90 
91 
92 protected:
93  // Protected methods
94  void init_members(void);
95  void copy_members(const GModelSpatialEllipticalGauss& model);
96  void free_members(void);
97  void update(void) const;
98  virtual void set_region(void) const;
99 
100  // Protected members
101 
102  // Cached members used for pre-computations
103  mutable double m_last_minor; //!< Last semi-minor axis
104  mutable double m_last_major; //!< Last semi-major axis
105  mutable double m_last_posangle; //!< Last position angle
106  mutable double m_cospos2; //!< squared cosine of position angle
107  mutable double m_sinpos2; //!< squared sine of position angle
108  mutable double m_sin2pos; //!< sine of twice the position angle
109  mutable double m_minor2; //!< square of minor axis
110  mutable double m_major2; //!< square of major axis
111  mutable double m_minor_rad; //!< Minor axis in radians
112  mutable double m_major_rad; //!< Major axis in radians
113  mutable double m_norm; //!< Normalization
114  mutable double m_term1; //!< Help term 1
115  mutable double m_term2; //!< Help term 2
116  mutable double m_term3; //!< Help term 3
117 
118 };
119 
120 
121 /***********************************************************************//**
122  * @brief Return class name
123  *
124  * @return String containing the class name ("GModelSpatialEllipticalGauss").
125  ***************************************************************************/
126 inline
128 {
129  return ("GModelSpatialEllipticalGauss");
130 }
131 
132 #endif /* GMODELSPATIALELLIPTICALGAUSS_HPP */
double m_last_major
Last semi-major axis.
double m_sinpos2
squared sine of position angle
virtual GModelSpatialEllipticalGauss * clone(void) const
Clone elliptical Gaussian model.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks whether model contains specified sky direction.
virtual void write(GXmlElement &xml) const
Write model into XML element.
Abstract elliptical spatial model base class.
GModelSpatialEllipticalGauss(void)
Void constructor.
virtual GModelSpatialEllipticalGauss & operator=(const GModelSpatialEllipticalGauss &model)
Assignment operator.
virtual void clear(void)
Clear elliptical Gaussian model.
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 void read(const GXmlElement &xml)
Read model from XML element.
double m_minor_rad
Minor axis in radians.
XML element node class.
Definition: GXmlElement.hpp:48
const GSkyDir & dir(void) const
Return position of elliptical spatial model.
virtual std::string classname(void) const
Return class name.
Random number generator class.
Definition: GRan.hpp:44
Time class.
Definition: GTime.hpp:55
double m_cospos2
squared cosine of position angle
virtual void set_region(void) const
Set boundary sky region.
Model parameter class interface definition.
Class that handles photons.
Definition: GPhoton.hpp:47
void update(void) const
Update precomputation cache.
Abstract interface for the sky region class.
Definition: GSkyRegion.hpp:57
double m_last_minor
Last semi-minor axis.
double m_sin2pos
sine of twice the position angle
GChatter
Definition: GTypemaps.hpp:33
void init_members(void)
Initialise class members.
std::string coordsys(void) const
Return coordinate system.
std::string type(void) const
Return model type.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
Abstract elliptical spatial model base class interface definition.
double posangle(void) const
Return Position Angle of model.
double m_last_posangle
Last position angle.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print information.
void copy_members(const GModelSpatialEllipticalGauss &model)
Copy class members.
virtual ~GModelSpatialEllipticalGauss(void)
Destructor.
void free_members(void)
Delete class members.
Sky direction class.
Definition: GSkyDir.hpp:62
double m_major_rad
Major axis in radians.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
virtual double theta_max(void) const
Return maximum model radius (in radians)