GammaLib 2.0.0
Loading...
Searching...
No Matches
GModelSpatialPointSource.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GModelSpatialPointSource.hpp - Spatial point source model class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2009-2022 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
36/* __ Forward declarations _______________________________________________ */
37class GEnergy;
38class GTime;
39class GPhoton;
40class GRan;
41class GSkyRegion;
42class GXmlElement;
43
44
45/***********************************************************************//**
46 * @class GModelSpatialPointSource
47 *
48 * @brief Point source spatial model
49 *
50 * This class implements a point source as the spatial component of the
51 * factorised source model. The point source has two parameters: the
52 * longitude and latitude of the point source location. The parameters may
53 * either be specified in celestial or Galactic coordinates. For celestial
54 * coordinates the parameter names are "RA" and "DEC", for Galactic
55 * coordinates the parameter names are "GLON" and "GLAT".
56 ***************************************************************************/
58
59public:
60 // Constructors and destructors
62 GModelSpatialPointSource(const bool& dummy, const std::string& type);
64 const std::string& coordsys = "CEL");
65 GModelSpatialPointSource(const double& lon,
66 const double& lat,
67 const std::string& coordsys = "CEL");
68 explicit GModelSpatialPointSource(const GXmlElement& xml);
70 virtual ~GModelSpatialPointSource(void);
71
72 // Operators
74
75 // Implemented pure virtual methods
76 virtual void clear(void);
77 virtual GModelSpatialPointSource* clone(void) const;
78 virtual std::string classname(void) const;
79 virtual GClassCode code(void) const;
80 virtual double eval(const GPhoton& photon,
81 const bool& gradients = false) const;
82 virtual GSkyDir mc(const GEnergy& energy,
83 const GTime& time,
84 GRan& ran) const;
85 virtual double mc_norm(const GSkyDir& dir,
86 const double& radius) const;
87 virtual bool contains(const GSkyDir& dir,
88 const double& margin = 0.0) const;
89 virtual void read(const GXmlElement& xml);
90 virtual void write(GXmlElement& xml) const;
91 virtual std::string print(const GChatter& chatter = NORMAL) const;
92
93 // Overloaded base class methods
94 virtual double flux(const GSkyRegion& region,
95 const GEnergy& srcEng = GEnergy(),
96 const GTime& srcTime = GTime()) const;
97
98 // Other methods
99 std::string coordsys(void) const;
100 const GSkyDir& dir(void) const;
101 void dir(const GSkyDir& dir);
102
103protected:
104 // Protected methods
105 void init_members(void);
106 void copy_members(const GModelSpatialPointSource& model);
107 void free_members(void);
108 bool is_celestial(void) const;
109 virtual void set_region(void) const;
110
111 // Protected members
112 GModelPar m_lon; //!< Right Ascension or Galactic longitude (deg)
113 GModelPar m_lat; //!< Declination or Galactic latitude (deg)
114
115 // Cached members for sky direction handling
116 mutable GSkyDir m_dir; //!< Sky direction representing parameters
117 mutable double m_last_lon; //!< Last longitude
118 mutable double m_last_lat; //!< Last latitude
119};
120
121
122/***********************************************************************//**
123 * @brief Return class name
124 *
125 * @return String containing the class name ("GModelSpatialPointSource").
126 ***************************************************************************/
127inline
129{
130 return ("GModelSpatialPointSource");
131}
132
133
134/***********************************************************************//**
135 * @brief Return class code
136 *
137 * @return GModelSpatialPointSource.
138 *
139 * Returns the code GModelSpatialPointSource of the class.
140 ***************************************************************************/
141inline
146
147
148/***********************************************************************//**
149 * @brief Return normalization of point source for Monte Carlo simulations
150 *
151 * @param[in] dir Centre of simulation cone.
152 * @param[in] radius Radius of simulation cone (degrees).
153 * @return Normalization.
154 *
155 * Returns the normalization for a point source within a circular region.
156 * The normalization is 1 if the point source falls within the circle
157 * defined by @p dir and @p radius, 0 otherwise.
158 ***************************************************************************/
159inline
161 const double& radius) const
162{
163 double norm = (dir.dist_deg(this->dir()) <= radius) ? 1.0 : 0.0;
164 return (norm);
165}
166
167
168/***********************************************************************//**
169 * @brief Return coordinate system
170 *
171 * @return Coordinate system of point source model.
172 *
173 * Returns "CEL" for a celestial coordinate system and "GAL" for a Galactic
174 * coordinate system.
175 ***************************************************************************/
176inline
178{
179 return (is_celestial() ? "CEL" : "GAL");
180}
181
182
183/***********************************************************************//**
184 * @brief Check if model holds celestial coordinates
185 *
186 * @return True if model holds celestial coordinates, false otherwise.
187 ***************************************************************************/
188inline
190{
191 return (m_lon.name() == "RA");
192}
193
194#endif /* GMODELSPATIALPOINTSOURCE_HPP */
Model parameter class interface definition.
Abstract spatial model base class interface definition.
Sky direction class interface definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
GClassCode
Definition GTypemaps.hpp:42
@ GMODEL_SPATIAL_POINT_SOURCE
Definition GTypemaps.hpp:43
double norm(const GVector &vector)
Computes vector norm.
Definition GVector.cpp:864
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Model parameter class.
Definition GModelPar.hpp:87
Point source spatial model.
GModelPar m_lat
Declination or Galactic latitude (deg)
GModelPar m_lon
Right Ascension or Galactic longitude (deg)
virtual void write(GXmlElement &xml) const
Write model into XML element.
void free_members(void)
Delete class members.
virtual double flux(const GSkyRegion &region, const GEnergy &srcEng=GEnergy(), const GTime &srcTime=GTime()) const
Returns model flux integrated in sky region.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print point source information.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks where model contains specified sky direction.
virtual double eval(const GPhoton &photon, const bool &gradients=false) const
Evaluate function.
virtual double mc_norm(const GSkyDir &dir, const double &radius) const
Return normalization of point source for Monte Carlo simulations.
virtual void clear(void)
Clear point source model.
GModelSpatialPointSource(void)
Void constructor.
GSkyDir m_dir
Sky direction representing parameters.
virtual void set_region(void) const
Set boundary sky region.
void init_members(void)
Initialise class members.
virtual GModelSpatialPointSource & operator=(const GModelSpatialPointSource &model)
Assignment operator.
virtual GModelSpatialPointSource * clone(void) const
Clone point source model.
virtual std::string classname(void) const
Return class name.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
const GSkyDir & dir(void) const
Return position of point source.
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual ~GModelSpatialPointSource(void)
Destructor.
bool is_celestial(void) const
Check if model holds celestial coordinates.
void copy_members(const GModelSpatialPointSource &model)
Copy class members.
std::string coordsys(void) const
Return coordinate system.
virtual GClassCode code(void) const
Return class code.
Abstract spatial model base class.
std::string type(void) const
Return model type.
const GSkyRegion * region(void) const
Return boundary sky region.
const std::string & name(void) const
Return parameter name.
Class that handles photons.
Definition GPhoton.hpp:47
Random number generator class.
Definition GRan.hpp:44
Sky direction class.
Definition GSkyDir.hpp:62
double dist_deg(const GSkyDir &dir) const
Compute angular distance between sky directions in degrees.
Definition GSkyDir.hpp:286
Abstract interface for the sky region class.
Time class.
Definition GTime.hpp:55
XML element node class.