GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpatialDiffuseConst.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelSpatialDiffuseConst.hpp - Spatial isotropic model class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2010-2016 by Juergen Knoedlseder *
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 GModelSpatialDiffuseConst.hpp
23  * @brief Isotropic spatial model class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GMODELSPATIALDIFFUSECONST_HPP
28 #define GMODELSPATIALDIFFUSECONST_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GModelSpatialDiffuse.hpp"
33 #include "GModelPar.hpp"
34 #include "GSkyDir.hpp"
35 #include "GSkyRegionCircle.hpp"
36 #include "GXmlElement.hpp"
37 
38 
39 /***********************************************************************//**
40  * @class GModelSpatialDiffuseConst
41  *
42  * @brief Isotropic spatial model
43  *
44  * This class implements the spatial component of the factorised source
45  * model for an isotropic source. The model has a single parameter which
46  * is the normalization factor of the model.
47  ***************************************************************************/
49 
50 public:
51  // Constructors and destructors
53  GModelSpatialDiffuseConst(const bool& dummy, const std::string& type);
54  explicit GModelSpatialDiffuseConst(const GXmlElement& xml);
55  explicit GModelSpatialDiffuseConst(const double& value);
57  virtual ~GModelSpatialDiffuseConst(void);
58 
59  // Operators
61 
62  // Implemented pure virtual base class methods
63  virtual void clear(void);
64  virtual GModelSpatialDiffuseConst* clone(void) const;
65  virtual std::string classname(void) const;
66  virtual std::string type(void) const;
67  virtual double eval(const GPhoton& photon,
68  const bool& gradients = false) const;
69  virtual GSkyDir mc(const GEnergy& energy,
70  const GTime& time,
71  GRan& ran) const;
72  virtual double mc_norm(const GSkyDir& dir,
73  const double& radius) const;
74  virtual bool contains(const GSkyDir& dir,
75  const double& margin = 0.0) const;
76  virtual GSkyRegion* region(void) const;
77  virtual void read(const GXmlElement& xml);
78  virtual void write(GXmlElement& xml) const;
79  virtual std::string print(const GChatter& chatter = NORMAL) const;
80 
81  // Other methods
82  double value(void) const;
83  void value(const double& value);
84 
85 protected:
86  // Protected methods
87  void init_members(void);
88  void copy_members(const GModelSpatialDiffuseConst& model);
89  void free_members(void);
90  void set_region(void) const;
91 
92  // Protected members
93  std::string m_type; //!< Model type
94  GModelPar m_value; //!< Value
95  mutable GSkyRegionCircle m_region; //!< Bounding circle
96  mutable GSkyDir m_mc_centre; //!< Simulation cone centre
97  mutable double m_mc_cos_radius; //!< Cosine of sim. cone radius
98 };
99 
100 
101 /***********************************************************************//**
102  * @brief Return class name
103  *
104  * @return String containing the class name ("GModelSpatialDiffuseConst").
105  ***************************************************************************/
106 inline
108 {
109  return ("GModelSpatialDiffuseConst");
110 }
111 
112 
113 /***********************************************************************//**
114  * @brief Return spatial model type
115  *
116  * @return Model type.
117  *
118  * Returns the type of the isotropic spatial model.
119  ***************************************************************************/
120 inline
121 std::string GModelSpatialDiffuseConst::type(void) const
122 {
123  return (m_type);
124 }
125 
126 
127 /***********************************************************************//**
128  * @brief Get model value
129  *
130  * @return Model value.
131  *
132  * Returns the value of the isotropic spatial model.
133  ***************************************************************************/
134 inline
136 {
137  return (m_value.value());
138 }
139 
140 
141 /***********************************************************************//**
142  * @brief Set model value
143  *
144  * @param[in] value Model value.
145  *
146  * Set the value of the isotropic spatial model.
147  ***************************************************************************/
148 inline
149 void GModelSpatialDiffuseConst::value(const double& value)
150 {
151  m_value.value(value);
152  return;
153 }
154 
155 
156 /***********************************************************************//**
157  * @brief Signals whether model contains sky direction
158  *
159  * @param[in] dir Sky direction.
160  * @param[in] margin Margin to be added to sky direction (deg, default: 0.0).
161  * @return True.
162  *
163  * Signals whether a sky direction falls within the bounding circle of
164  * the diffuse model. As the constant model is defined on the entire sphere,
165  * the method returns always true.
166  ***************************************************************************/
167 inline
169  const double& margin) const
170 {
171  return (true);
172 }
173 
174 
175 /***********************************************************************//**
176  * @brief Return boundary sky region
177  *
178  * @return Boundary sky region.
179  *
180  * Returns a sky region that fully encloses the point source.
181  ***************************************************************************/
182 inline
184 {
185  set_region();
186  return (&m_region);
187 }
188 
189 #endif /* GMODELSPATIALDIFFUSECONST_HPP */
virtual std::string classname(void) const
Return class name.
void init_members(void)
Initialise class members.
XML element node class interface definition.
GSkyRegionCircle m_region
Bounding circle.
Sky direction class interface definition.
void free_members(void)
Delete class members.
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.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print isotropic source model information.
void set_region(void) const
Set boundary sky region.
virtual void read(const GXmlElement &xml)
Read model from XML element.
Model parameter class interface definition.
virtual void write(GXmlElement &xml) const
Write model into XML element.
Class that handles photons.
Definition: GPhoton.hpp:47
Model parameter class.
Definition: GModelPar.hpp:87
Abstract interface for the sky region class.
Definition: GSkyRegion.hpp:57
virtual double mc_norm(const GSkyDir &dir, const double &radius) const
Return normalization of constant diffuse source for Monte Carlo simulations.
virtual ~GModelSpatialDiffuseConst(void)
Destructor.
virtual void clear(void)
Clear isotropic spatial model.
GSkyDir m_mc_centre
Simulation cone centre.
GChatter
Definition: GTypemaps.hpp:33
double m_mc_cos_radius
Cosine of sim. cone radius.
virtual GSkyRegion * region(void) const
Return boundary sky region.
GModelSpatialDiffuseConst(void)
Void constructor.
Abstract diffuse spatial model base class interface definition.
void copy_members(const GModelSpatialDiffuseConst &model)
Copy class members.
virtual std::string type(void) const
Return spatial model type.
virtual double eval(const GPhoton &photon, const bool &gradients=false) const
Evaluate isotropic spatial model value.
virtual GModelSpatialDiffuseConst * clone(void) const
Clone isotropic spatial model.
double value(void) const
Return parameter value.
GModelSpatialDiffuseConst & operator=(const GModelSpatialDiffuseConst &model)
Assignment operator.
double value(void) const
Get model value.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Signals whether model contains sky direction.
Abstract diffuse spatial model base class.
Sky direction class.
Definition: GSkyDir.hpp:62
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Return MC sky direction.
Circular sky region class interface definition.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48