GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpatialRadialShell.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelSpatialRadialShell.hpp - Radial shell source model class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2011-2022 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 GModelSpatialRadialShell.hpp
23  * @brief Radial shell model class interface definition
24  * @author Christoph Deil
25  */
26 
27 #ifndef GMODELSPATIALRADIALSHELL_HPP
28 #define GMODELSPATIALRADIALSHELL_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 GModelSpatialRadialShell
47  *
48  * @brief Shell source model class
49  *
50  * This class implements the spatial component of the factorised source
51  * model for a shell source (can be used e.g. as a toy supernova remnant
52  * model). The shell is simply the volume between an inner and outer radius
53  * (a large sphere with a smaller sphere cut out) with constant volume
54  * emissivity and no absorption. To determine the surface brightness
55  * distribution on the sky, the shell is analytically integrated along lines
56  * of sight.
57  * The shell is parametrised by the inner shell radius and the shell width.
58  * Obviously, the shell width has to be a positive quantity. To assure
59  * positivity, 1 arcsec is added internally to the shell width. This should
60  * be negligible compared to shell widths encountered (and detectable) in
61  * the gamma-ray domain, and improves the convergence of the fitting
62  * algorithms.
63  ***************************************************************************/
65 
66 public:
67  // Constructors and destructors
69  GModelSpatialRadialShell(const bool& dummy, const std::string& type);
71  const double& radius,
72  const double& width,
73  const std::string& coordsys = "CEL");
74  explicit GModelSpatialRadialShell(const GXmlElement& xml);
76  virtual ~GModelSpatialRadialShell(void);
77 
78  // Operators
80 
81  // Implemented pure virtual methods
82  virtual void clear(void);
83  virtual GModelSpatialRadialShell* clone(void) const;
84  virtual std::string classname(void) const;
85  virtual double eval(const double& theta,
86  const GEnergy& energy,
87  const GTime& time,
88  const bool& gradients = false) const;
89  virtual GSkyDir mc(const GEnergy& energy,
90  const GTime& time,
91  GRan& ran) const;
92  virtual bool contains(const GSkyDir& dir,
93  const double& margin = 0.0) const;
94  virtual double theta_max(void) const;
95  virtual void read(const GXmlElement& xml);
96  virtual void write(GXmlElement& xml) const;
97  virtual std::string print(const GChatter& chatter = NORMAL) const;
98 
99  // Other methods
100  double radius(void) const;
101  double width(void) const;
102  void radius(const double& radius);
103  void width(const double& width);
104 
105 protected:
106  // Protected methods
107  void init_members(void);
108  void copy_members(const GModelSpatialRadialShell& model);
109  void free_members(void);
110  void update(void) const;
111  static double f1(double x);
112  static double f2(double x);
113  virtual void set_region(void) const;
114 
115  // Protected members
116  GModelPar m_radius; //!< Inner shell radius (deg)
117  GModelPar m_width; //!< Shell thickness (deg)
118 
119  // Cached members used for pre-computations
120  mutable double m_last_radius; //!< Last shell radius (deg)
121  mutable double m_last_width; //!< Last shell width (deg)
122  mutable double m_theta_in; //!< Inner shell radius (rad)
123  mutable double m_x_in; //!< sin(m_theta_in)^2
124  mutable double m_theta_out; //!< Outer shell radius (rad)
125  mutable double m_x_out; //!< sin(m_theta_out)^2
126  mutable double m_norm; //!< Shell normalization
127 };
128 
129 
130 /***********************************************************************//**
131  * @brief Return class name
132  *
133  * @return String containing the class name ("GModelSpatialRadialShell").
134  ***************************************************************************/
135 inline
136 std::string GModelSpatialRadialShell::classname(void) const
137 {
138  return ("GModelSpatialRadialShell");
139 }
140 
141 
142 /***********************************************************************//**
143  * @brief Return shell radius
144  *
145  * @return Shell radius (degrees).
146  *
147  * Returns the shell radius in degrees.
148  ***************************************************************************/
149 inline
151 {
152  return (m_radius.value());
153 }
154 
155 
156 /***********************************************************************//**
157  * @brief Set shell radius
158  *
159  * @param[in] radius Shell radius (degrees).
160  *
161  * Sets the shell radius in degrees.
162  ***************************************************************************/
163 inline
164 void GModelSpatialRadialShell::radius(const double& radius)
165 {
166  m_radius.value(radius);
167  return;
168 }
169 
170 
171 /***********************************************************************//**
172  * @brief Return shell width
173  *
174  * @return Shell width (degrees).
175  *
176  * Returns the shell width in degrees.
177  ***************************************************************************/
178 inline
180 {
181  return (m_width.value());
182 }
183 
184 
185 /***********************************************************************//**
186  * @brief Set width radius
187  *
188  * @param[in] width Shell width (degrees).
189  *
190  * Sets the shell width in degrees.
191  ***************************************************************************/
192 inline
193 void GModelSpatialRadialShell::width(const double& width)
194 {
195  m_width.value(width);
196  return;
197 }
198 
199 #endif /* GMODELSPATIALRADIALSHELL_HPP */
double width(void) const
Return shell width.
GModelPar m_width
Shell thickness (deg)
virtual GModelSpatialRadialShell & operator=(const GModelSpatialRadialShell &model)
Assignment operator.
double m_last_width
Last shell width (deg)
void init_members(void)
Initialise class members.
Abstract radial spatial model base class interface definition.
XML element node class.
Definition: GXmlElement.hpp:48
virtual void set_region(void) const
Set boundary sky region.
std::string coordsys(void) const
Return coordinate system.
virtual void read(const GXmlElement &xml)
Read model from XML element.
Random number generator class.
Definition: GRan.hpp:44
Time class.
Definition: GTime.hpp:55
static double f2(double x)
Return function 2 value needed for precomputation.
double m_x_in
sin(m_theta_in)^2
Model parameter class interface definition.
Class that handles photons.
Definition: GPhoton.hpp:47
Model parameter class.
Definition: GModelPar.hpp:87
double radius(void) const
Return shell radius.
void free_members(void)
Delete class members.
void copy_members(const GModelSpatialRadialShell &model)
Copy class members.
Abstract interface for the sky region class.
Definition: GSkyRegion.hpp:57
void update(void) const
Update precomputation cache.
const GSkyDir & dir(void) const
Return position of radial spatial model.
virtual double theta_max(void) const
Return maximum model radius (in radians)
virtual void write(GXmlElement &xml) const
Write model into XML element.
virtual ~GModelSpatialRadialShell(void)
Destructor.
virtual GModelSpatialRadialShell * clone(void) const
Clone radial shell model.
GChatter
Definition: GTypemaps.hpp:33
double m_last_radius
Last shell radius (deg)
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks where model contains specified sky direction.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
std::string type(void) const
Return model type.
GModelPar m_radius
Inner shell radius (deg)
GModelSpatialRadialShell(void)
Void constructor.
virtual void clear(void)
Clear radial shell model.
double m_theta_in
Inner shell radius (rad)
virtual std::string classname(void) const
Return class name.
virtual double eval(const double &theta, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
Evaluate function (in units of sr^-1)
double value(void) const
Return parameter value.
double m_theta_out
Outer shell radius (rad)
static double f1(double x)
Return function 1 value needed for precomputation.
Abstract radial spatial model base class.
double m_norm
Shell normalization.
double m_x_out
sin(m_theta_out)^2
Sky direction class.
Definition: GSkyDir.hpp:62
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
virtual std::string print(const GChatter &chatter=NORMAL) const
Print information.