GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpatialPointSource.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelSpatialPointSource.hpp - Spatial point source model class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2009-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 GModelSpatialPointSource.hpp
23  * @brief Point source spatial model class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GMODELSPATIALPOINTSOURCE_HPP
28 #define GMODELSPATIALPOINTSOURCE_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GModelSpatial.hpp"
33 #include "GModelPar.hpp"
34 #include "GSkyDir.hpp"
35 #include "GSkyRegionCircle.hpp"
36 #include "GXmlElement.hpp"
37 
38 
39 /***********************************************************************//**
40  * @class GModelSpatialPointSource
41  *
42  * @brief Point source spatial model
43  *
44  * This class implements a point source as the spatial component of the
45  * factorised source model. The point source has two parameters: the Right
46  * Ascension and Declination of the point source location.
47  ***************************************************************************/
49 
50 public:
51  // Constructors and destructors
53  GModelSpatialPointSource(const bool& dummy, const std::string& type);
54  explicit GModelSpatialPointSource(const GSkyDir& dir);
55  GModelSpatialPointSource(const double& ra, const double& dec);
56  explicit GModelSpatialPointSource(const GXmlElement& xml);
58  virtual ~GModelSpatialPointSource(void);
59 
60  // Operators
62 
63  // Implemented pure virtual methods
64  virtual void clear(void);
65  virtual GModelSpatialPointSource* clone(void) const;
66  virtual std::string classname(void) const;
67  virtual std::string type(void) const;
68  virtual GClassCode code(void) const;
69  virtual double eval(const GPhoton& photon,
70  const bool& gradients = false) const;
71  virtual GSkyDir mc(const GEnergy& energy,
72  const GTime& time,
73  GRan& ran) const;
74  virtual double mc_norm(const GSkyDir& dir,
75  const double& radius) const;
76  virtual bool contains(const GSkyDir& dir,
77  const double& margin = 0.0) const;
78  virtual GSkyRegion* region(void) const;
79  virtual void read(const GXmlElement& xml);
80  virtual void write(GXmlElement& xml) const;
81  virtual std::string print(const GChatter& chatter = NORMAL) const;
82 
83  // Other methods
84  void type(const std::string& type);
85  double ra(void) const;
86  double dec(void) const;
87  void ra(const double& ra);
88  void dec(const double& dec);
89  GSkyDir dir(void) const;
90  void dir(const GSkyDir& dir);
91 
92 protected:
93  // Protected methods
94  void init_members(void);
95  void copy_members(const GModelSpatialPointSource& model);
96  void free_members(void);
97  void set_region(void) const;
98 
99  // Protected members
100  std::string m_type; //!< Model type
101  GModelPar m_ra; //!< Right Ascension (deg)
102  GModelPar m_dec; //!< Declination (deg)
103  mutable GSkyRegionCircle m_region; //!< Bounding circle
104 };
105 
106 
107 /***********************************************************************//**
108  * @brief Return class name
109  *
110  * @return String containing the class name ("GModelSpatialPointSource").
111  ***************************************************************************/
112 inline
113 std::string GModelSpatialPointSource::classname(void) const
114 {
115  return ("GModelSpatialPointSource");
116 }
117 
118 
119 /***********************************************************************//**
120  * @brief Return model type
121  *
122  * @return Model type.
123  *
124  * Returns the type of the spatial point source model.
125  ***************************************************************************/
126 inline
127 std::string GModelSpatialPointSource::type(void) const
128 {
129  return (m_type);
130 }
131 
132 
133 /***********************************************************************//**
134  * @brief Set model type
135  *
136  * @param[in] type Model type.
137  *
138  * Set the type of the spatial point source model.
139  ***************************************************************************/
140 inline
141 void GModelSpatialPointSource::type(const std::string& type)
142 {
143  m_type = type;
144  return;
145 }
146 
147 
148 /***********************************************************************//**
149  * @brief Return class code
150  *
151  * @return GModelSpatialPointSource.
152  *
153  * Returns the code GModelSpatialPointSource of the class.
154  ***************************************************************************/
155 inline
157 {
159 }
160 
161 
162 /***********************************************************************//**
163  * @brief Return Right Ascencion of model centre
164  *
165  * @return Right Ascencion of model centre (degrees).
166  *
167  * Returns the Right Ascension of the model centre in degrees.
168  ***************************************************************************/
169 inline
171 {
172  return (m_ra.value());
173 }
174 
175 
176 /***********************************************************************//**
177  * @brief Set Right Ascencion of model centre
178  *
179  * @param[in] ra Right Ascencion of model centre.
180  *
181  * Sets the Right Ascencion of model centre.
182  ***************************************************************************/
183 inline
184 void GModelSpatialPointSource::ra(const double& ra)
185 {
186  m_ra.value(ra);
187  return;
188 }
189 
190 
191 /***********************************************************************//**
192  * @brief Return Declination of model centre
193  *
194  * @return Declination of model centre (degrees).
195  *
196  * Returns the Declination of the model centre in degrees.
197  ***************************************************************************/
198 inline
200 {
201  return (m_dec.value());
202 }
203 
204 
205 /***********************************************************************//**
206  * @brief Set Declination of model centre
207  *
208  * @param[in] dec Declination of model centre.
209  *
210  * Sets the Declination of model centre.
211  ***************************************************************************/
212 inline
213 void GModelSpatialPointSource::dec(const double& dec)
214 {
215  m_dec.value(dec);
216  return;
217 }
218 
219 
220 /***********************************************************************//**
221  * @brief Return normalization of point source for Monte Carlo simulations
222  *
223  * @param[in] dir Centre of simulation cone.
224  * @param[in] radius Radius of simulation cone (degrees).
225  * @return Normalization.
226  *
227  * Returns the normalization for a point source within a circular region.
228  * The normalization is 1 if the point source falls within the circle
229  * defined by @p dir and @p radius, 0 otherwise.
230  ***************************************************************************/
231 inline
233  const double& radius) const
234 {
235  double norm = (dir.dist_deg(this->dir()) <= radius) ? 1.0 : 0.0;
236  return (norm);
237 }
238 
239 
240 /***********************************************************************//**
241  * @brief Return boundary sky region
242  *
243  * @return Boundary sky region.
244  *
245  * Returns a sky region that fully encloses the point source.
246  ***************************************************************************/
247 inline
249 {
250  set_region();
251  return (&m_region);
252 }
253 
254 #endif /* GMODELSPATIALPOINTSOURCE_HPP */
void free_members(void)
Delete class members.
double dist_deg(const GSkyDir &dir) const
Compute angular distance between sky directions in degrees.
Definition: GSkyDir.hpp:280
double norm(const GVector &vector)
Computes vector norm.
Definition: GVector.cpp:821
XML element node class interface definition.
Sky direction class interface definition.
virtual double mc_norm(const GSkyDir &dir, const double &radius) const
Return normalization of point source for Monte Carlo simulations.
double dec(void) const
Return Declination of model centre.
virtual GSkyRegion * region(void) const
Return boundary sky region.
XML element node class.
Definition: GXmlElement.hpp:47
virtual GModelSpatialPointSource * clone(void) const
Clone point source model.
virtual double eval(const GPhoton &photon, const bool &gradients=false) const
Evaluate function.
Abstract spatial model base class interface definition.
Random number generator class.
Definition: GRan.hpp:44
Time class.
Definition: GTime.hpp:54
double ra(void) const
Return Right Ascencion of model centre.
Interface for the circular sky region class.
virtual void clear(void)
Clear point source model.
void copy_members(const GModelSpatialPointSource &model)
Copy class members.
Model parameter class interface definition.
Class that handles photons.
Definition: GPhoton.hpp:47
virtual GClassCode code(void) const
Return class code.
Model parameter class.
Definition: GModelPar.hpp:87
Abstract interface for the sky region class.
Definition: GSkyRegion.hpp:57
virtual std::string print(const GChatter &chatter=NORMAL) const
Print point source information.
virtual ~GModelSpatialPointSource(void)
Destructor.
virtual void write(GXmlElement &xml) const
Write model into XML element.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
virtual void read(const GXmlElement &xml)
Read model from XML element.
GChatter
Definition: GTypemaps.hpp:33
Point source spatial model.
virtual std::string type(void) const
Return model type.
GSkyDir dir(void) const
Return position of point source.
GModelPar m_ra
Right Ascension (deg)
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks where model contains specified sky direction.
GClassCode
Definition: GTypemaps.hpp:42
double value(void) const
Return parameter value.
GModelSpatialPointSource(void)
Void constructor.
void init_members(void)
Initialise class members.
Abstract spatial model base class.
GModelPar m_dec
Declination (deg)
void set_region(void) const
Set boundary sky region.
virtual GModelSpatialPointSource & operator=(const GModelSpatialPointSource &model)
Assignment operator.
virtual std::string classname(void) const
Return class name.
GSkyRegionCircle m_region
Bounding circle.
Sky direction class.
Definition: GSkyDir.hpp:62
Circular sky region class interface definition.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48