GammaLib  1.7.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-2016 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 #include "GSkyDir.hpp"
35 #include "GSkyRegionCircle.hpp"
36 #include "GXmlElement.hpp"
37 
38 
39 /**************************************************************************
40  * @class GModelSpatialEllipticalGauss
41  *
42  * @brief Elliptical gauss source model class
43  *
44  * This class implements the spatial component of the factorised source
45  * model for an elliptical gauss source, i.e. constant surface brightness
46  * according to an asymmetric Gaussian.
47  ***************************************************************************/
49 
50 public:
51  // Constructors and destructors
53  GModelSpatialEllipticalGauss(const bool& dummy, const std::string& type);
55  const double& major,
56  const double& minor,
57  const double& posangle);
58  explicit GModelSpatialEllipticalGauss(const GXmlElement& xml);
60  virtual ~GModelSpatialEllipticalGauss(void);
61 
62  // Operators
64 
65  // Implemented pure virtual base class methods
66  virtual void clear(void);
67  virtual GModelSpatialEllipticalGauss* clone(void) const;
68  virtual std::string classname(void) const;
69  virtual std::string type(void) const;
70  virtual double eval(const double& theta,
71  const double& posangle,
72  const GEnergy& energy,
73  const GTime& time,
74  const bool& gradients = false) const;
75  virtual GSkyDir mc(const GEnergy& energy,
76  const GTime& time,
77  GRan& ran) const;
78  virtual bool contains(const GSkyDir& dir,
79  const double& margin = 0.0) const;
80  virtual double theta_max(void) const;
81  virtual GSkyRegion* region(void) const;
82  virtual void read(const GXmlElement& xml);
83  virtual void write(GXmlElement& xml) const;
84  virtual std::string print(const GChatter& chatter = NORMAL) const;
85 
86 
87 protected:
88  // Protected methods
89  void init_members(void);
90  void copy_members(const GModelSpatialEllipticalGauss& model);
91  void free_members(void);
92  void update(void) const;
93  void set_region(void) const;
94 
95  // Protected members
96  std::string m_type; //!< Model type
97  mutable GSkyRegionCircle m_region; //!< Bounding circle
98 
99  // Cached members used for pre-computations
100  mutable double m_last_minor; //!< Last semi-minor axis
101  mutable double m_last_major; //!< Last semi-major axis
102  mutable double m_last_posangle; //!< Last position angle
103  mutable double m_cospos2; //!< squared cosine of position angle
104  mutable double m_sinpos2; //!< squared sine of position angle
105  mutable double m_sin2pos; //!< sine of twice the position angle
106  mutable double m_minor2; //!< square of minor axis
107  mutable double m_major2; //!< square of major axis
108  mutable double m_minor_rad; //!< Minor axis in radians
109  mutable double m_major_rad; //!< Major axis in radians
110  mutable double m_norm; //!< Normalization
111  mutable double m_term1; //!< Help term 1
112  mutable double m_term2; //!< Help term 2
113  mutable double m_term3; //!< Help term 3
114 
115 };
116 
117 
118 /***********************************************************************//**
119  * @brief Return class name
120  *
121  * @return String containing the class name ("GModelSpatialEllipticalGauss").
122  ***************************************************************************/
123 inline
125 {
126  return ("GModelSpatialEllipticalGauss");
127 }
128 
129 
130 /***********************************************************************//**
131  * @brief Return model type
132  *
133  * @return Model type.
134  *
135  * Returns the type of the elliptical gauss model.
136  ***************************************************************************/
137 inline
138 std::string GModelSpatialEllipticalGauss::type(void) const
139 {
140  return (m_type);
141 }
142 
143 
144 /***********************************************************************//**
145  * @brief Return boundary sky region
146  *
147  * @return Boundary sky region.
148  *
149  * Returns a sky region that fully encloses the spatial model component.
150  ***************************************************************************/
151 inline
153 {
154  set_region();
155  return (&m_region);
156 }
157 
158 #endif /* GMODELSPATIALELLIPTICALGAUSS_HPP */
double m_last_major
Last semi-major axis.
GSkyDir dir(void) const
Return position of elliptical spatial model.
double m_sinpos2
squared sine of position angle
GSkyRegionCircle m_region
Bounding circle.
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.
XML element node class interface definition.
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)
Sky direction class interface definition.
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:47
virtual std::string classname(void) const
Return class name.
virtual GSkyRegion * region(void) const
Return boundary sky region.
Random number generator class.
Definition: GRan.hpp:44
Time class.
Definition: GTime.hpp:54
Interface for the circular sky region class.
double m_cospos2
squared cosine of position angle
void set_region(void) const
Set boundary sky region.
Model parameter class interface definition.
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.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
Abstract elliptical spatial model base class interface definition.
virtual std::string type(void) const
Return model type.
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.
Circular sky region class interface definition.
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)