GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpatialElliptical.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelSpatialElliptical.hpp - Abstract elliptical spatial model class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2013-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 GModelSpatialElliptical.hpp
23  * @brief Abstract elliptical spatial model base class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GMODELSPATIALELLIPTICAL_HPP
28 #define GMODELSPATIALELLIPTICAL_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 GModelSpatialElliptical
45  *
46  * @brief Abstract elliptical spatial model base class
47  *
48  * This class defines the interface for an elliptical model as spatial
49  * component of the factorized source model. Typical examples of elliptical
50  * components are elliptical Disk, Gaussian or Shell shaped sources.
51  ***************************************************************************/
53 
54 public:
55  // Constructors and destructors
58  explicit GModelSpatialElliptical(const GXmlElement& xml);
59  virtual ~GModelSpatialElliptical(void);
60 
61  // Operators
63 
64  // Pure virtual methods
65  virtual void clear(void) = 0;
66  virtual GModelSpatialElliptical* 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 double& posangle,
71  const GEnergy& energy,
72  const GTime& time,
73  const bool& gradients = false) const = 0;
74  virtual GSkyDir mc(const GEnergy& energy,
75  const GTime& time,
76  GRan& ran) const = 0;
77  virtual bool contains(const GSkyDir& dir,
78  const double& margin = 0.0) const = 0;
79  virtual double theta_max(void) const = 0;
80  virtual GSkyRegion* region(void) const = 0;
81  virtual std::string print(const GChatter& chatter = NORMAL) const = 0;
82 
83  // Implemented virtual base class methods
84  virtual GClassCode code(void) const;
85  virtual double eval(const GPhoton& photon,
86  const bool& gradients = false) const;
87  virtual double mc_norm(const GSkyDir& dir, const double& radius) const;
88  virtual void read(const GXmlElement& xml);
89  virtual void write(GXmlElement& xml) const;
90 
91  // Other methods
92  double ra(void) const;
93  double dec(void) const;
94  void ra(const double& ra);
95  void dec(const double& dec);
96  double posangle(void) const;
97  void posangle(const double& posangle);
98  double semiminor(void) const;
99  double semimajor(void) const;
100  void semiminor(const double& semiminor);
101  void semimajor(const double& semimajor);
102  GSkyDir dir(void) const;
103  void dir(const GSkyDir& dir);
104 
105 protected:
106  // Protected methods
107  void init_members(void);
108  void copy_members(const GModelSpatialElliptical& model);
109  void free_members(void);
110 
111  // Protected members
112  GModelPar m_ra; //!< Right Ascension (deg)
113  GModelPar m_dec; //!< Declination (deg)
114  GModelPar m_posangle; //!< Position angle from North, counterclockwise (deg)
115  GModelPar m_semiminor; //!< Semi-minor axis of ellipse (deg)
116  GModelPar m_semimajor; //!< Semi-major axis of ellipse (deg)
117 };
118 
119 
120 /***********************************************************************//**
121  * @brief Return class code
122  *
123  * @return GModelSpatialElliptical.
124  *
125  * Returns the code GModelSpatialElliptical of the class.
126  ***************************************************************************/
127 inline
129 {
131 }
132 
133 
134 /***********************************************************************//**
135  * @brief Return Right Ascencion of model centre
136  *
137  * @return Right Ascencion of model centre (degrees).
138  *
139  * Returns the Right Ascension of the model centre in degrees.
140  ***************************************************************************/
141 inline
142 double GModelSpatialElliptical::ra(void) const
143 {
144  return (m_ra.value());
145 }
146 
147 
148 /***********************************************************************//**
149  * @brief Set Right Ascencion of model centre
150  *
151  * @param[in] ra Right Ascension (degrees).
152  *
153  * Sets the Right Ascension of the model centre in degrees.
154  ***************************************************************************/
155 inline
156 void GModelSpatialElliptical::ra(const double& ra)
157 {
158  m_ra.value(ra);
159  return;
160 }
161 
162 
163 /***********************************************************************//**
164  * @brief Return Declination of model centre
165  *
166  * @return Declination of model centre (degrees).
167  *
168  * Returns the Declination of the model centre in degrees.
169  ***************************************************************************/
170 inline
172 {
173  return (m_dec.value());
174 }
175 
176 
177 /***********************************************************************//**
178  * @brief Set Declination of model centre
179  *
180  * @param[in] dec Declination (degrees).
181  *
182  * Sets the Declination of the model centre in degrees.
183  ***************************************************************************/
184 inline
185 void GModelSpatialElliptical::dec(const double& dec)
186 {
187  m_dec.value(dec);
188  return;
189 }
190 
191 
192 /***********************************************************************//**
193  * @brief Return Position Angle of model
194  *
195  * @return Position Angle of model (degrees).
196  *
197  * Returns the Position Angle of model in degrees, measured counterclockwise
198  * from celestial North.
199  ***************************************************************************/
200 inline
202 {
203  return (m_posangle.value());
204 }
205 
206 
207 /***********************************************************************//**
208  * @brief Set Position Angle of model
209  *
210  * @param[in] posangle Position Angle of model (degrees).
211  *
212  * Sets the Position Angle of model in degrees, measured counterclockwise
213  * from celestial North.
214  ***************************************************************************/
215 inline
216 void GModelSpatialElliptical::posangle(const double& posangle)
217 {
218  m_posangle.value(posangle);
219  return;
220 }
221 
222 
223 /***********************************************************************//**
224  * @brief Return semi-minor axis of ellipse
225  *
226  * @return Semi-minor axis of ellipse (degrees).
227  *
228  * Returns the semi-minor axis of the ellipse in degrees.
229  ***************************************************************************/
230 inline
232 {
233  return (m_semiminor.value());
234 }
235 
236 
237 /***********************************************************************//**
238  * @brief Set semi-minor axis of ellipse
239  *
240  * @param[in] semiminor Semi-minor axis of ellipse (degrees)
241  *
242  * Sets the semi-minor axis of the ellipse in degrees.
243  ***************************************************************************/
244 inline
245 void GModelSpatialElliptical::semiminor(const double& semiminor)
246 {
247  m_semiminor.value(semiminor);
248  return;
249 }
250 
251 
252 /***********************************************************************//**
253  * @brief Return semi-major axis of ellipse
254  *
255  * @return Semi-major axis of ellipse (degrees).
256  *
257  * Returns the semi-major axis of the ellipse in degrees.
258  ***************************************************************************/
259 inline
261 {
262  return (m_semimajor.value());
263 }
264 
265 
266 /***********************************************************************//**
267  * @brief Set semi-major axis of ellipse
268  *
269  * @param[in] semimajor Semi-major axis of ellipse (degrees)
270  *
271  * Sets the semi-major axis of the ellipse in degrees.
272  ***************************************************************************/
273 inline
274 void GModelSpatialElliptical::semimajor(const double& semimajor)
275 {
276  m_semimajor.value(semimajor);
277  return;
278 }
279 
280 
281 /***********************************************************************//**
282  * @brief Return normalization of elliptical source for Monte Carlo
283  * simulations
284  *
285  * @param[in] dir Centre of simulation cone.
286  * @param[in] radius Radius of simulation cone (degrees).
287  * @return Normalization.
288  *
289  * Returns the normalization for an elliptical source within a circular
290  * region. The normalization is 1 if the elliptical source falls within
291  * the circle define by @p dir and @p radius, 0 otherwise.
292  ***************************************************************************/
293 inline
295  const double& radius) const
296 {
297  double norm = (dir.dist_deg(this->dir()) <= radius+theta_max()) ? 1.0 : 0.0;
298  return (norm);
299 }
300 
301 #endif /* GMODELSPATIALELLIPTICAL_HPP */
GModelPar m_semimajor
Semi-major axis of ellipse (deg)
GSkyDir dir(void) const
Return position of elliptical spatial model.
virtual void write(GXmlElement &xml) const
Write model into XML element.
void free_members(void)
Delete class members.
virtual std::string classname(void) const =0
Return class name.
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.
Abstract elliptical spatial model base class.
Random number generator class definition.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const =0
GModelPar m_ra
Right Ascension (deg)
XML element node class interface definition.
virtual double mc_norm(const GSkyDir &dir, const double &radius) const
Return normalization of elliptical source for Monte Carlo simulations.
Sky direction class interface definition.
virtual GModelSpatialElliptical & operator=(const GModelSpatialElliptical &model)
Assignment operator.
virtual std::string type(void) const =0
XML element node class.
Definition: GXmlElement.hpp:47
Abstract spatial model base class interface definition.
Random number generator class.
Definition: GRan.hpp:44
GModelPar m_dec
Declination (deg)
Time class.
Definition: GTime.hpp:54
GModelPar m_posangle
Position angle from North, counterclockwise (deg)
void init_members(void)
Initialise class members.
virtual double theta_max(void) const =0
virtual GClassCode code(void) const
Return class code.
Model parameter class interface definition.
Class that handles photons.
Definition: GPhoton.hpp:47
Model parameter class.
Definition: GModelPar.hpp:87
GModelSpatialElliptical(void)
Void constructor.
double semiminor(void) const
Return semi-minor axis of ellipse.
virtual ~GModelSpatialElliptical(void)
Destructor.
Abstract interface for the sky region class.
Definition: GSkyRegion.hpp:57
double ra(void) const
Return Right Ascencion of model centre.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const =0
double dec(void) const
Return Declination of model centre.
void copy_members(const GModelSpatialElliptical &model)
Copy class members.
virtual GSkyRegion * region(void) const =0
GChatter
Definition: GTypemaps.hpp:33
virtual void read(const GXmlElement &xml)
Read model from XML element.
GModelPar m_semiminor
Semi-minor axis of ellipse (deg)
Photon class definition.
virtual void clear(void)=0
Clear object.
double posangle(void) const
Return Position Angle of model.
GClassCode
Definition: GTypemaps.hpp:42
double value(void) const
Return parameter value.
Abstract spatial model base class.
virtual GModelSpatialElliptical * clone(void) const =0
Clones object.
virtual double eval(const double &theta, const double &posangle, const GEnergy &energy, const GTime &time, const bool &gradients=false) const =0
Sky direction class.
Definition: GSkyDir.hpp:62
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
double semimajor(void) const
Return semi-major axis of ellipse.
Time class interface definition.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48