GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpatialRadialRing.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelSpatialRadialRing.hpp - Radial ring source model class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2020-2022 by Pierrick Martin *
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 GModelSpatialRadialRing.hpp
23  * @brief Radial ring model class interface definition
24  * @author Pierrick Martin
25  */
26 
27 #ifndef GMODELSPATIALRADIALRING_HPP
28 #define GMODELSPATIALRADIALRING_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GModelSpatialRadial.hpp"
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 GModelSpatialRadialRing
47  *
48  * @brief Ring source model class
49  *
50  * This class implements the spatial component of the factorised source
51  * model for a ring source, i.e. constant surface brightness between an
52  * inner radius and an outer radius, and no emission elsewhere.
53  ***************************************************************************/
55 
56 public:
57  // Constructors and destructors
60  const double& radius,
61  const double& width,
62  const std::string& coordsys = "CEL");
63  explicit GModelSpatialRadialRing(const GXmlElement& xml);
65  virtual ~GModelSpatialRadialRing(void);
66 
67  // Operators
69 
70  // Implemented pure virtual base class methods
71  virtual void clear(void);
72  virtual GModelSpatialRadialRing* clone(void) const;
73  virtual std::string classname(void) const;
74  virtual double eval(const double& theta,
75  const GEnergy& energy,
76  const GTime& time,
77  const bool& gradients = false) const;
78  virtual GSkyDir mc(const GEnergy& energy,
79  const GTime& time,
80  GRan& ran) const;
81  virtual bool contains(const GSkyDir& dir,
82  const double& margin = 0.0) const;
83  virtual double theta_min(void) const;
84  virtual double theta_max(void) const;
85  virtual void read(const GXmlElement& xml);
86  virtual void write(GXmlElement& xml) const;
87  virtual std::string print(const GChatter& chatter = NORMAL) const;
88 
89  // Other methods
90  double radius(void) const;
91  void radius(const double& radius);
92  double width(void) const;
93  void width(const double& width);
94 
95 protected:
96  // Protected methods
97  void init_members(void);
98  void copy_members(const GModelSpatialRadialRing& model);
99  void free_members(void);
100  void update(void) const;
101  virtual void set_region(void) const;
102 
103  // Protected members
104  GModelPar m_radius; //!< Ring inner radius (degrees)
105  GModelPar m_width; //!< Ring width (degrees)
106 
107  // Cached members used for pre-computations
108  mutable double m_last_radius; //!< Last ring radius
109  mutable double m_last_width; //!< Last ring width
110  mutable double m_inner_radius_rad; //!< Inner radius in radians
111  mutable double m_outer_radius_rad; //!< Outer radius in radians
112  mutable double m_cos_inner_radius_rad; //!< Cosine of inner radius in radians
113  mutable double m_cos_outer_radius_rad; //!< Cosine of outer radius in radians
114  mutable double m_norm; //!< Normalization
115 };
116 
117 
118 /***********************************************************************//**
119  * @brief Return class name
120  *
121  * @return String containing the class name ("GModelSpatialRadialRing").
122  ***************************************************************************/
123 inline
124 std::string GModelSpatialRadialRing::classname(void) const
125 {
126  return ("GModelSpatialRadialRing");
127 }
128 
129 
130 /***********************************************************************//**
131  * @brief Return ring inner radius
132  *
133  * @return Ring inner radius (degrees).
134  *
135  * Returns the inner radius of the ring in degrees.
136  ***************************************************************************/
137 inline
139 {
140  return (m_radius.value());
141 }
142 
143 
144 /***********************************************************************//**
145  * @brief Set ring inner radius
146  *
147  * @param[in] radius Ring inner radius (degrees).
148  *
149  * Sets the inner radius of the ring in degrees.
150  ***************************************************************************/
151 inline
152 void GModelSpatialRadialRing::radius(const double& radius)
153 {
154  m_radius.value(radius);
155  return;
156 }
157 
158 
159 /***********************************************************************//**
160  * @brief Return ring width
161  *
162  * @return Ring width (degrees).
163  *
164  * Returns the width of the ring in degrees.
165  ***************************************************************************/
166 inline
168 {
169  return (m_width.value());
170 }
171 
172 
173 /***********************************************************************//**
174  * @brief Set ring width
175  *
176  * @param[in] width Ring width (degrees).
177  *
178  * Sets the width of the ring in degrees.
179  ***************************************************************************/
180 inline
181 void GModelSpatialRadialRing::width(const double& width)
182 {
183  m_width.value(width);
184  return;
185 }
186 
187 #endif /* GMODELSPATIALRADIALRING_HPP */
virtual std::string classname(void) const
Return class name.
double m_outer_radius_rad
Outer radius in radians.
virtual double theta_min(void) const
Return minimum model radius (in radians)
virtual std::string print(const GChatter &chatter=NORMAL) const
Print information.
Abstract radial spatial model base class interface definition.
GModelPar m_width
Ring width (degrees)
XML element node class.
Definition: GXmlElement.hpp:48
double m_last_width
Last ring width.
std::string coordsys(void) const
Return coordinate system.
Random number generator class.
Definition: GRan.hpp:44
void init_members(void)
Initialise class members.
Time class.
Definition: GTime.hpp:55
void free_members(void)
Delete class members.
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual GModelSpatialRadialRing * clone(void) const
Clone radial ring model.
virtual ~GModelSpatialRadialRing(void)
Destructor.
GModelPar m_radius
Ring inner radius (degrees)
Model parameter class interface definition.
Class that handles photons.
Definition: GPhoton.hpp:47
Model parameter class.
Definition: GModelPar.hpp:87
virtual double theta_max(void) const
Return maximum model radius (in radians)
void update(void) const
Update precomputation cache.
virtual void write(GXmlElement &xml) const
Write model into XML element.
virtual GModelSpatialRadialRing & operator=(const GModelSpatialRadialRing &model)
Assignment operator.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks whether model contains specified sky direction.
Abstract interface for the sky region class.
Definition: GSkyRegion.hpp:57
const GSkyDir & dir(void) const
Return position of radial spatial model.
double width(void) const
Return ring width.
virtual double eval(const double &theta, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
Evaluate function (in units of sr^-1)
GChatter
Definition: GTypemaps.hpp:33
void copy_members(const GModelSpatialRadialRing &model)
Copy class members.
virtual void set_region(void) const
Set boundary sky region.
double m_cos_outer_radius_rad
Cosine of outer radius in radians.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Return MC sky direction.
double value(void) const
Return parameter value.
Abstract radial spatial model base class.
double radius(void) const
Return ring inner radius.
double m_last_radius
Last ring radius.
double m_inner_radius_rad
Inner radius in radians.
double m_cos_inner_radius_rad
Cosine of inner radius in radians.
virtual void clear(void)
Clear radial ring model.
Sky direction class.
Definition: GSkyDir.hpp:62
GModelSpatialRadialRing(void)
Void constructor.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48