GammaLib  1.7.0.dev
 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-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 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 #include "GSkyDir.hpp"
35 #include "GSkyRegionCircle.hpp"
36 #include "GXmlElement.hpp"
37 
38 
39 /**************************************************************************
40  * @class GModelSpatialRadialShell
41  *
42  * @brief Shell source model class
43  *
44  * This class implements the spatial component of the factorised source
45  * model for a shell source (can be used e.g. as a toy supernova remnant
46  * model). The shell is simply the volume between an inner and outer radius
47  * (a large sphere with a smaller sphere cut out) with constant volume
48  * emissivity and no absorption. To determine the surface brightness
49  * distribution on the sky, the shell is analytically integrated along lines
50  * of sight.
51  * The shell is parametrised by the inner shell radius and the shell width.
52  * Obviously, the shell width has to be a positive quantity. To assure
53  * positivity, 1 arcsec is added internally to the shell width. This should
54  * be negligible compared to shell widths encountered (and detectable) in
55  * the gamma-ray domain, and improves the convergence of the fitting
56  * algorithms.
57  ***************************************************************************/
59 
60 public:
61  // Constructors and destructors
63  GModelSpatialRadialShell(const bool& dummy, const std::string& type);
65  const double& radius,
66  const double& width);
67  explicit GModelSpatialRadialShell(const GXmlElement& xml);
69  virtual ~GModelSpatialRadialShell(void);
70 
71  // Operators
73 
74  // Implemented pure virtual methods
75  virtual void clear(void);
76  virtual GModelSpatialRadialShell* clone(void) const;
77  virtual std::string classname(void) const;
78  virtual std::string type(void) const;
79  virtual double eval(const double& theta,
80  const GEnergy& energy,
81  const GTime& time,
82  const bool& gradients = false) const;
83  virtual GSkyDir mc(const GEnergy& energy,
84  const GTime& time,
85  GRan& ran) const;
86  virtual bool contains(const GSkyDir& dir,
87  const double& margin = 0.0) const;
88  virtual double theta_max(void) const;
89  virtual GSkyRegion* region(void) const;
90  virtual void read(const GXmlElement& xml);
91  virtual void write(GXmlElement& xml) const;
92  virtual std::string print(const GChatter& chatter = NORMAL) const;
93 
94  // Other methods
95  double radius(void) const;
96  double width(void) const;
97  void radius(const double& radius);
98  void width(const double& width);
99 
100 protected:
101  // Protected methods
102  void init_members(void);
103  void copy_members(const GModelSpatialRadialShell& model);
104  void free_members(void);
105  void update(void) const;
106  static double f1(double x);
107  static double f2(double x);
108  void set_region(void) const;
109 
110  // Protected members
111  std::string m_type; //!< Model type
112  GModelPar m_radius; //!< Inner shell radius (deg)
113  GModelPar m_width; //!< Shell thickness (deg)
114  mutable GSkyRegionCircle m_region; //!< Bounding circle
115 
116  // Cached members used for pre-computations
117  mutable double m_last_radius; //!< Last shell radius (deg)
118  mutable double m_last_width; //!< Last shell width (deg)
119  mutable double m_theta_in; //!< Inner shell radius (rad)
120  mutable double m_x_in; //!< sin(m_theta_in)^2
121  mutable double m_theta_out; //!< Outer shell radius (rad)
122  mutable double m_x_out; //!< sin(m_theta_out)^2
123  mutable double m_norm; //!< Shell normalization
124 };
125 
126 
127 /***********************************************************************//**
128  * @brief Return class name
129  *
130  * @return String containing the class name ("GModelSpatialRadialShell").
131  ***************************************************************************/
132 inline
133 std::string GModelSpatialRadialShell::classname(void) const
134 {
135  return ("GModelSpatialRadialShell");
136 }
137 
138 
139 /***********************************************************************//**
140  * @brief Return model type
141  *
142  * @return Model type.
143  *
144  * Returns the type of the radial shell model.
145  ***************************************************************************/
146 inline
147 std::string GModelSpatialRadialShell::type(void) const
148 {
149  return (m_type);
150 }
151 
152 
153 /***********************************************************************//**
154  * @brief Return shell radius
155  *
156  * @return Shell radius (degrees).
157  *
158  * Returns the shell radius in degrees.
159  ***************************************************************************/
160 inline
162 {
163  return (m_radius.value());
164 }
165 
166 
167 /***********************************************************************//**
168  * @brief Set shell radius
169  *
170  * @param[in] radius Shell radius (degrees).
171  *
172  * Sets the shell radius in degrees.
173  ***************************************************************************/
174 inline
175 void GModelSpatialRadialShell::radius(const double& radius)
176 {
177  m_radius.value(radius);
178  return;
179 }
180 
181 
182 /***********************************************************************//**
183  * @brief Return shell width
184  *
185  * @return Shell width (degrees).
186  *
187  * Returns the shell width in degrees.
188  ***************************************************************************/
189 inline
191 {
192  return (m_width.value());
193 }
194 
195 
196 /***********************************************************************//**
197  * @brief Set width radius
198  *
199  * @param[in] width Shell width (degrees).
200  *
201  * Sets the shell width in degrees.
202  ***************************************************************************/
203 inline
204 void GModelSpatialRadialShell::width(const double& width)
205 {
206  m_width.value(width);
207  return;
208 }
209 
210 
211 /***********************************************************************//**
212  * @brief Return boundary sky region
213  *
214  * @return Boundary sky region.
215  *
216  * Returns a sky region that fully encloses the spatial model component.
217  ***************************************************************************/
218 inline
220 {
221  set_region();
222  return (&m_region);
223 }
224 
225 #endif /* GMODELSPATIALRADIALSHELL_HPP */
double width(void) const
Return shell width.
GModelPar m_width
Shell thickness (deg)
virtual GModelSpatialRadialShell & operator=(const GModelSpatialRadialShell &model)
Assignment operator.
XML element node class interface definition.
double m_last_width
Last shell width (deg)
void init_members(void)
Initialise class members.
Sky direction class interface definition.
Abstract radial spatial model base class interface definition.
XML element node class.
Definition: GXmlElement.hpp:47
void set_region(void) const
Set boundary sky region.
virtual void read(const GXmlElement &xml)
Read model from XML element.
Random number generator class.
Definition: GRan.hpp:44
Time class.
Definition: GTime.hpp:54
Interface for the circular sky region class.
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.
Model parameter class.
Definition: GModelPar.hpp:87
double radius(void) const
Return shell radius.
virtual GSkyRegion * region(void) const
Return boundary sky region.
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.
virtual std::string type(void) const
Return model type.
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.
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.
GSkyDir dir(void) const
Return position of radial spatial model.
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
Circular sky region class interface definition.
GSkyRegionCircle m_region
Bounding circle.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
virtual std::string print(const GChatter &chatter=NORMAL) const
Print information.