GammaLib  2.1.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-2021 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 double eval(const GPhoton& photon,
67  const bool& gradients = false) const;
68  virtual GSkyDir mc(const GEnergy& energy,
69  const GTime& time,
70  GRan& ran) const;
71  virtual double mc_norm(const GSkyDir& dir,
72  const double& radius) const;
73  virtual bool contains(const GSkyDir& dir,
74  const double& margin = 0.0) const;
75  virtual void read(const GXmlElement& xml);
76  virtual void write(GXmlElement& xml) const;
77  virtual std::string print(const GChatter& chatter = NORMAL) const;
78 
79  // Overloaded base class methods
80  virtual double flux(const GSkyRegion& region,
81  const GEnergy& srcEng = GEnergy(),
82  const GTime& srcTime = GTime()) const;
83 
84  // Other methods
85  double value(void) const;
86  void value(const double& value);
87 
88 protected:
89  // Protected methods
90  void init_members(void);
91  void copy_members(const GModelSpatialDiffuseConst& model);
92  void free_members(void);
93  virtual void set_region(void) const;
94 
95  // Protected members
96  GModelPar m_value; //!< Value
97  mutable GSkyDir m_mc_centre; //!< Simulation cone centre
98  mutable double m_mc_cos_radius; //!< Cosine of sim. cone radius
99 };
100 
101 
102 /***********************************************************************//**
103  * @brief Return class name
104  *
105  * @return String containing the class name ("GModelSpatialDiffuseConst").
106  ***************************************************************************/
107 inline
109 {
110  return ("GModelSpatialDiffuseConst");
111 }
112 
113 
114 /***********************************************************************//**
115  * @brief Get model value
116  *
117  * @return Model value.
118  *
119  * Returns the value of the isotropic spatial model.
120  ***************************************************************************/
121 inline
123 {
124  return (m_value.value());
125 }
126 
127 
128 /***********************************************************************//**
129  * @brief Set model value
130  *
131  * @param[in] value Model value.
132  *
133  * Set the value of the isotropic spatial model.
134  ***************************************************************************/
135 inline
136 void GModelSpatialDiffuseConst::value(const double& value)
137 {
138  m_value.value(value);
139  return;
140 }
141 
142 
143 /***********************************************************************//**
144  * @brief Signals whether model contains sky direction
145  *
146  * @param[in] dir Sky direction.
147  * @param[in] margin Margin to be added to sky direction (deg, default: 0.0).
148  * @return True.
149  *
150  * Signals whether a sky direction falls within the bounding circle of
151  * the diffuse model. As the constant model is defined on the entire sphere,
152  * the method returns always true.
153  ***************************************************************************/
154 inline
156  const double& margin) const
157 {
158  return (true);
159 }
160 
161 #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.
Sky direction class interface definition.
void free_members(void)
Delete class members.
XML element node class.
Definition: GXmlElement.hpp:48
Random number generator class.
Definition: GRan.hpp:44
Time class.
Definition: GTime.hpp:55
virtual std::string print(const GChatter &chatter=NORMAL) const
Print isotropic source model information.
virtual 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.
std::string type(void) const
Return model type.
GModelSpatialDiffuseConst(void)
Void constructor.
Abstract diffuse spatial model base class interface definition.
void copy_members(const GModelSpatialDiffuseConst &model)
Copy class members.
const GSkyRegion * region(void) const
Return boundary sky region.
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.
virtual double flux(const GSkyRegion &region, const GEnergy &srcEng=GEnergy(), const GTime &srcTime=GTime()) const
Returns isotropic flux integrated in sky region.
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