GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpatialRadialDisk.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelSpatialRadialDisk.hpp - Radial disk source model class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2011-2016 by Christoph Deil *
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 GModelSpatialRadialDisk.hpp
23  * @brief Radial disk model class interface definition
24  * @author Christoph Deil
25  */
26 
27 #ifndef GMODELSPATIALRADIALDISK_HPP
28 #define GMODELSPATIALRADIALDISK_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GModelSpatialRadial.hpp"
33 #include "GModelPar.hpp"
34 #include "GSkyDir.hpp"
35 #include "GSkyRegionCircle.hpp"
36 #include "GXmlElement.hpp"
37 
38 
39 /**************************************************************************
40  * @class GModelSpatialRadialDisk
41  *
42  * @brief Disk source model class
43  *
44  * This class implements the spatial component of the factorised source
45  * model for a disk source, i.e. constant surface brightness within some
46  * radius and no emission outside.
47  ***************************************************************************/
49 
50 public:
51  // Constructors and destructors
53  GModelSpatialRadialDisk(const bool& dummy, const std::string& type);
54  GModelSpatialRadialDisk(const GSkyDir& dir, const double& radius);
55  explicit GModelSpatialRadialDisk(const GXmlElement& xml);
57  virtual ~GModelSpatialRadialDisk(void);
58 
59  // Operators
61 
62  // Implemented pure virtual base class methods
63  virtual void clear(void);
64  virtual GModelSpatialRadialDisk* clone(void) const;
65  virtual std::string classname(void) const;
66  virtual std::string type(void) const;
67  virtual double eval(const double& theta,
68  const GEnergy& energy,
69  const GTime& time,
70  const bool& gradients = false) const;
71  virtual GSkyDir mc(const GEnergy& energy,
72  const GTime& time,
73  GRan& ran) const;
74  virtual bool contains(const GSkyDir& dir,
75  const double& margin = 0.0) const;
76  virtual double theta_max(void) const;
77  virtual GSkyRegion* region(void) const;
78  virtual void read(const GXmlElement& xml);
79  virtual void write(GXmlElement& xml) const;
80  virtual std::string print(const GChatter& chatter = NORMAL) const;
81 
82  // Other methods
83  double radius(void) const;
84  void radius(const double& radius);
85 
86 protected:
87  // Protected methods
88  void init_members(void);
89  void copy_members(const GModelSpatialRadialDisk& model);
90  void free_members(void);
91  void update(void) const;
92  void set_region(void) const;
93 
94  // Protected members
95  std::string m_type; //!< Model type
96  GModelPar m_radius; //!< Disk radius (degrees)
97  mutable GSkyRegionCircle m_region; //!< Bounding circle
98 
99  // Cached members used for pre-computations
100  mutable double m_last_radius; //!< Last disk radius
101  mutable double m_radius_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 ("GModelSpatialRadialDisk").
110  ***************************************************************************/
111 inline
112 std::string GModelSpatialRadialDisk::classname(void) const
113 {
114  return ("GModelSpatialRadialDisk");
115 }
116 
117 
118 /***********************************************************************//**
119  * @brief Return model type
120  *
121  * @return Model type.
122  *
123  * Returns the type of the radial disk model.
124  ***************************************************************************/
125 inline
126 std::string GModelSpatialRadialDisk::type(void) const
127 {
128  return (m_type);
129 }
130 
131 
132 /***********************************************************************//**
133  * @brief Return disk radius
134  *
135  * @return Disk radius (degrees).
136  *
137  * Returns the radius of the disk in degrees.
138  ***************************************************************************/
139 inline
141 {
142  return (m_radius.value());
143 }
144 
145 
146 /***********************************************************************//**
147  * @brief Set disk radius
148  *
149  * @param[in] radius Disk radius (degrees).
150  *
151  * Sets the radius of the disk in degrees.
152  ***************************************************************************/
153 inline
154 void GModelSpatialRadialDisk::radius(const double& radius)
155 {
156  m_radius.value(radius);
157  return;
158 }
159 
160 
161 /***********************************************************************//**
162  * @brief Return boundary sky region
163  *
164  * @return Boundary sky region.
165  *
166  * Returns a sky region that fully encloses the spatial model component.
167  ***************************************************************************/
168 inline
170 {
171  set_region();
172  return (&m_region);
173 }
174 
175 #endif /* GMODELSPATIALRADIALDISK_HPP */
virtual GModelSpatialRadialDisk & operator=(const GModelSpatialRadialDisk &model)
Assignment operator.
virtual double theta_max(void) const
Return maximum model radius (in radians)
virtual void write(GXmlElement &xml) const
Write model into XML element.
void update(void) const
Update precomputation cache.
XML element node class interface definition.
std::string m_type
Model type.
Sky direction class interface definition.
double radius(void) const
Return disk radius.
virtual void clear(void)
Clear radial disk model.
Abstract radial spatial model base class interface definition.
XML element node class.
Definition: GXmlElement.hpp:47
Random number generator class.
Definition: GRan.hpp:44
Time class.
Definition: GTime.hpp:54
Interface for the circular sky region class.
GSkyRegionCircle m_region
Bounding circle.
GModelPar m_radius
Disk radius (degrees)
virtual ~GModelSpatialRadialDisk(void)
Destructor.
Model parameter class interface definition.
Model parameter class.
Definition: GModelPar.hpp:87
virtual double eval(const double &theta, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
Evaluate function (in units of sr^-1)
Abstract interface for the sky region class.
Definition: GSkyRegion.hpp:57
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual std::string classname(void) const
Return class name.
virtual GSkyRegion * region(void) const
Return boundary sky region.
GModelSpatialRadialDisk(void)
Void constructor.
GChatter
Definition: GTypemaps.hpp:33
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Return MC sky direction.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print information.
void set_region(void) const
Set boundary sky region.
GSkyDir dir(void) const
Return position of radial spatial model.
virtual GModelSpatialRadialDisk * clone(void) const
Clone radial disk model.
double value(void) const
Return parameter value.
void free_members(void)
Delete class members.
Abstract radial spatial model base class.
double m_radius_rad
Radius in radians.
double m_last_radius
Last disk radius.
void copy_members(const GModelSpatialRadialDisk &model)
Copy class members.
virtual std::string type(void) const
Return model type.
void init_members(void)
Initialise class members.
Sky direction class.
Definition: GSkyDir.hpp:62
Circular sky region class interface definition.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks where model contains specified sky direction.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48