GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpatialEllipticalDisk.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelSpatialEllipticalDisk.hpp - Elliptical disk source model class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2013-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 GModelSpatialEllipticalDisk.hpp
23  * @brief Elliptical disk model class interface definition
24  * @author Michael Mayer
25  */
26 
27 #ifndef GMODELSPATIALELLIPTICALDISK_HPP
28 #define GMODELSPATIALELLIPTICALDISK_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 GModelSpatialEllipticalDisk
41  *
42  * @brief Elliptical disk source model class
43  *
44  * This class implements the spatial component of the factorised source
45  * model for an elliptical disk source, i.e. constant surface brightness
46  * within ellipse and no emission outside.
47  ***************************************************************************/
49 
50 public:
51  // Constructors and destructors
54  const double& semimajor,
55  const double& semiminor,
56  const double& posangle);
57  explicit GModelSpatialEllipticalDisk(const GXmlElement& xml);
59  virtual ~GModelSpatialEllipticalDisk(void);
60 
61  // Operators
63 
64  // Implemented pure virtual base class methods
65  virtual void clear(void);
66  virtual GModelSpatialEllipticalDisk* clone(void) const;
67  virtual std::string classname(void) const;
68  virtual std::string type(void) const;
69  virtual double eval(const double& theta,
70  const double& posangle,
71  const GEnergy& energy,
72  const GTime& time,
73  const bool& gradients = false) const;
74  virtual GSkyDir mc(const GEnergy& energy,
75  const GTime& time,
76  GRan& ran) const;
77  virtual bool contains(const GSkyDir& dir,
78  const double& margin = 0.0) const;
79  virtual double theta_max(void) const;
80  virtual GSkyRegion* region(void) const;
81  virtual void read(const GXmlElement& xml);
82  virtual void write(GXmlElement& xml) const;
83  virtual std::string print(const GChatter& chatter = NORMAL) const;
84 
85 
86 protected:
87  // Protected methods
88  void init_members(void);
89  void copy_members(const GModelSpatialEllipticalDisk& model);
90  void free_members(void);
91  void update(void) const;
92  void set_region(void) const;
93 
94  // Protected members
95  mutable GSkyRegionCircle m_region; //!< Bounding circle
96 
97  // Cached members used for pre-computations
98  mutable double m_last_semiminor; //!< Last semi-minor axis
99  mutable double m_last_semimajor; //!< Last semi-major axis
100  mutable double m_semiminor_rad; //!< Radius in radians
101  mutable double m_semimajor_rad; //!< Radius in radians
102  mutable double m_norm; //!< Normalization
103 };
104 
105 
106 /***********************************************************************//**
107  * @brief Return class name
108  *
109  * @return String containing the class name ("GModelSpatialEllipticalDisk").
110  ***************************************************************************/
111 inline
113 {
114  return ("GModelSpatialEllipticalDisk");
115 }
116 
117 
118 /***********************************************************************//**
119  * @brief Return model type
120  *
121  * @return "EllipticalDisk".
122  *
123  * Returns the type of the elliptical disk model.
124  ***************************************************************************/
125 inline
126 std::string GModelSpatialEllipticalDisk::type(void) const
127 {
128  return "EllipticalDisk";
129 }
130 
131 
132 /***********************************************************************//**
133  * @brief Return boundary sky region
134  *
135  * @return Boundary sky region.
136  *
137  * Returns a sky region that fully encloses the spatial model component.
138  ***************************************************************************/
139 inline
141 {
142  set_region();
143  return (&m_region);
144 }
145 
146 #endif /* GMODELSPATIALELLIPTICALDISK_HPP */
GSkyDir dir(void) const
Return position of elliptical spatial model.
virtual std::string type(void) const
Return model type.
void update(void) const
Update precomputation cache.
Abstract elliptical spatial model base class.
XML element node class interface definition.
void set_region(void) const
Set boundary sky region.
Sky direction class interface definition.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print information.
virtual double theta_max(void) const
Return maximum model radius (in radians)
void init_members(void)
Initialise class members.
virtual void write(GXmlElement &xml) const
Write model into XML element.
void copy_members(const GModelSpatialEllipticalDisk &model)
Copy class members.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
XML element node class.
Definition: GXmlElement.hpp:47
Random number generator class.
Definition: GRan.hpp:44
Time class.
Definition: GTime.hpp:54
virtual void read(const GXmlElement &xml)
Read model from XML element.
Interface for the circular sky region class.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks where model contains specified sky direction.
double m_last_semiminor
Last semi-minor axis.
void free_members(void)
Delete class members.
Model parameter class interface definition.
double semiminor(void) const
Return semi-minor axis of ellipse.
virtual std::string classname(void) const
Return class name.
virtual GModelSpatialEllipticalDisk * clone(void) const
Clone elliptical disk model.
Abstract interface for the sky region class.
Definition: GSkyRegion.hpp:57
virtual void clear(void)
Clear elliptical disk model.
double m_last_semimajor
Last semi-major axis.
GModelSpatialEllipticalDisk(void)
Void constructor.
virtual GSkyRegion * region(void) const
Return boundary sky region.
GChatter
Definition: GTypemaps.hpp:33
double m_semimajor_rad
Radius in radians.
Abstract elliptical spatial model base class interface definition.
double posangle(void) const
Return Position Angle of 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)
GSkyRegionCircle m_region
Bounding circle.
virtual GModelSpatialEllipticalDisk & operator=(const GModelSpatialEllipticalDisk &model)
Assignment operator.
virtual ~GModelSpatialEllipticalDisk(void)
Destructor.
double m_semiminor_rad
Radius in radians.
Sky direction class.
Definition: GSkyDir.hpp:62
double semimajor(void) const
Return semi-major axis of ellipse.
Circular sky region class interface definition.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48