GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpatialRadial.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelSpatialRadial.hpp - Abstract radial spatial model base class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2011-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 GModelSpatialRadial.hpp
23  * @brief Abstract radial spatial model base class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GMODELSPATIALRADIAL_HPP
28 #define GMODELSPATIALRADIAL_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include <vector>
33 #include "GModelSpatial.hpp"
34 #include "GModelPar.hpp"
35 #include "GSkyDir.hpp"
36 #include "GEnergy.hpp"
37 #include "GTime.hpp"
38 #include "GPhoton.hpp"
39 #include "GXmlElement.hpp"
40 #include "GRan.hpp"
41 
42 
43 /***********************************************************************//**
44  * @class GModelSpatialRadial
45  *
46  * @brief Abstract radial spatial model base class
47  *
48  * This class defines the interface for a radial model as spatial component
49  * of the factorized source model. Typical examples of radial components are
50  * axisymmetric Disk, Gaussian or Shell sources.
51  ***************************************************************************/
53 
54 public:
55  // Constructors and destructors
56  GModelSpatialRadial(void);
58  explicit GModelSpatialRadial(const GXmlElement& xml);
59  virtual ~GModelSpatialRadial(void);
60 
61  // Operators
62  virtual GModelSpatialRadial& operator=(const GModelSpatialRadial& model);
63 
64  // Pure virtual methods
65  virtual void clear(void) = 0;
66  virtual GModelSpatialRadial* clone(void) const = 0;
67  virtual std::string classname(void) const = 0;
68  virtual std::string type(void) const = 0;
69  virtual double eval(const double& theta,
70  const GEnergy& energy,
71  const GTime& time,
72  const bool& gradients = false) const = 0;
73  virtual GSkyDir mc(const GEnergy& energy,
74  const GTime& time,
75  GRan& ran) const = 0;
76  virtual bool contains(const GSkyDir& dir,
77  const double& margin = 0.0) const = 0;
78  virtual double theta_max(void) const = 0;
79  virtual GSkyRegion* region(void) const = 0;
80  virtual std::string print(const GChatter& chatter = NORMAL) const = 0;
81 
82  // Implemented pure virtual base class methods
83  virtual GClassCode code(void) const;
84  virtual double eval(const GPhoton& photon,
85  const bool& gradients = false) const;
86  virtual double mc_norm(const GSkyDir& dir, const double& radius) const;
87  virtual void read(const GXmlElement& xml);
88  virtual void write(GXmlElement& xml) const;
89 
90  // Other methods
91  double ra(void) const;
92  double dec(void) const;
93  void ra(const double& ra);
94  void dec(const double& dec);
95  GSkyDir dir(void) const;
96  void dir(const GSkyDir& dir);
97 
98 protected:
99  // Protected methods
100  void init_members(void);
101  void copy_members(const GModelSpatialRadial& model);
102  void free_members(void);
103 
104  // Proteced members
105  GModelPar m_ra; //!< Right Ascension (deg)
106  GModelPar m_dec; //!< Declination (deg)
107 };
108 
109 
110 /***********************************************************************//**
111  * @brief Return class code
112  *
113  * @return GModelSpatialRadial.
114  *
115  * Returns the code GModelSpatialRadial of the class.
116  ***************************************************************************/
117 inline
119 {
120  return GMODEL_SPATIAL_RADIAL;
121 }
122 
123 
124 /***********************************************************************//**
125  * @brief Return Right Ascencion of model centre
126  *
127  * @return Right Ascencion of model centre (degrees).
128  *
129  * Returns the Right Ascension of the model centre in degrees.
130  ***************************************************************************/
131 inline
132 double GModelSpatialRadial::ra(void) const
133 {
134  return (m_ra.value());
135 }
136 
137 
138 /***********************************************************************//**
139  * @brief Set Right Ascencion of model centre
140  *
141  * @param[in] ra Right Ascension (degrees).
142  *
143  * Sets the Right Ascension of the model centre in degrees.
144  ***************************************************************************/
145 inline
146 void GModelSpatialRadial::ra(const double& ra)
147 {
148  m_ra.value(ra);
149  return;
150 }
151 
152 
153 /***********************************************************************//**
154  * @brief Return Declination of model centre
155  *
156  * @return Declination of model centre (degrees).
157  *
158  * Returns the Declination of the model centre in degrees.
159  ***************************************************************************/
160 inline
161 double GModelSpatialRadial::dec(void) const
162 {
163  return (m_dec.value());
164 }
165 
166 
167 /***********************************************************************//**
168  * @brief Set Declination of model centre
169  *
170  * @param[in] dec Declination (degrees).
171  *
172  * Sets the Declination of the model centre in degrees.
173  ***************************************************************************/
174 inline
175 void GModelSpatialRadial::dec(const double& dec)
176 {
177  m_dec.value(dec);
178  return;
179 }
180 
181 
182 /***********************************************************************//**
183  * @brief Return normalization of radial source for Monte Carlo simulations
184  *
185  * @param[in] dir Centre of simulation cone.
186  * @param[in] radius Radius of simulation cone (degrees).
187  * @return Normalization.
188  *
189  * Returns the normalization for a radial source within a circular region.
190  * The normalization is 1 if the radial source falls within the circle
191  * defined by @p dir and @p radius, 0 otherwise.
192  ***************************************************************************/
193 inline
195  const double& radius) const
196 {
197  double norm = (dir.dist_deg(this->dir()) <= radius+theta_max()) ? 1.0 : 0.0;
198  return (norm);
199 }
200 
201 #endif /* GMODELSPATIALRADIAL_HPP */
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
Energy value class definition.
Random number generator class definition.
XML element node class interface definition.
virtual double mc_norm(const GSkyDir &dir, const double &radius) const
Return normalization of radial source for Monte Carlo simulations.
Sky direction class interface definition.
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
virtual GClassCode code(void) const
Return class code.
void copy_members(const GModelSpatialRadial &model)
Copy class members.
XML element node class.
Definition: GXmlElement.hpp:47
Abstract spatial model base class interface definition.
Random number generator class.
Definition: GRan.hpp:44
GModelSpatialRadial(void)
Void constructor.
Time class.
Definition: GTime.hpp:54
GModelPar m_dec
Declination (deg)
virtual GSkyRegion * region(void) const =0
virtual GModelSpatialRadial * clone(void) const =0
Clones object.
virtual void clear(void)=0
Clear object.
void init_members(void)
Initialise class members.
Model parameter class interface definition.
Class that handles photons.
Definition: GPhoton.hpp:47
Model parameter class.
Definition: GModelPar.hpp:87
virtual ~GModelSpatialRadial(void)
Destructor.
virtual double eval(const double &theta, const GEnergy &energy, const GTime &time, const bool &gradients=false) const =0
Abstract interface for the sky region class.
Definition: GSkyRegion.hpp:57
void free_members(void)
Delete class members.
virtual void read(const GXmlElement &xml)
Read model from XML element.
double dec(void) const
Return Declination of model centre.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const =0
GChatter
Definition: GTypemaps.hpp:33
double ra(void) const
Return Right Ascencion of model centre.
virtual std::string classname(void) const =0
Return class name.
Photon class definition.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const =0
GModelPar m_ra
Right Ascension (deg)
virtual void write(GXmlElement &xml) const
Write model into XML element.
virtual std::string type(void) const =0
virtual GModelSpatialRadial & operator=(const GModelSpatialRadial &model)
Assignment operator.
GSkyDir dir(void) const
Return position of radial spatial model.
GClassCode
Definition: GTypemaps.hpp:42
double value(void) const
Return parameter value.
virtual double theta_max(void) const =0
Abstract spatial model base class.
Abstract radial spatial model base class.
Sky direction class.
Definition: GSkyDir.hpp:62
Time class interface definition.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48