GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpatialRadialProfile.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelSpatialRadialProfile.hpp - Radial profile source model class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2016-2020 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 GModelSpatialRadialProfile.hpp
23  * @brief Radial profile model class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GMODELSPATIALRADIALPROFILE_HPP
28 #define GMODELSPATIALRADIALPROFILE_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GModelSpatialRadial.hpp"
33 #include "GNodeArray.hpp"
34 #include "GSkyRegionCircle.hpp"
35 
36 /* __ Forward declaration ________________________________________________ */
37 class GXmlElement;
38 class GSkyDir;
39 
40 
41 /**************************************************************************
42  * @class GModelSpatialRadialProfile
43  *
44  * @brief Radial profile source model class
45  *
46  * This class implements the spatial component of the factorised source
47  * model for an arbitrary radial profile.
48  ***************************************************************************/
50 
51 public:
52  // Constructors and destructors
54  explicit GModelSpatialRadialProfile(const GXmlElement& xml);
56  virtual ~GModelSpatialRadialProfile(void);
57 
58  // Operators
60 
61  // Pure virtual methods
62  virtual void clear(void) = 0;
63  virtual GModelSpatialRadialProfile* clone(void) const = 0;
64  virtual std::string classname(void) const = 0;
65  virtual double theta_min(void) const = 0;
66  virtual double theta_max(void) const = 0;
67  virtual std::string print(const GChatter& chatter = NORMAL) const = 0;
68 
69  // Implemented pure virtual base class methods
70  virtual double eval(const double& theta,
71  const GEnergy& energy,
72  const GTime& time,
73  const bool& gradients = false) const;
74  virtual GSkyDir mc(const GEnergy& energy,
75  const GTime& time,
76  GRan& ran) const;
77  virtual bool contains(const GSkyDir& dir,
78  const double& margin = 0.0) const;
79 
80  // Implement other methods
81  int num_nodes(void) const;
82  void num_nodes(const int& number);
83 
84 protected:
85  // Protected methods
86  void init_members(void);
87  void copy_members(const GModelSpatialRadialProfile& model);
88  void free_members(void);
89  int cache_index(void) const;
90  virtual double profile_value(const double& theta) const = 0;
91  virtual void set_region(void) const;
92 
93  // Protected members
94  bool m_coord_indep; //!< True if model independent of sky coordinates
95  int m_num_nodes; //!< Number of profile nodes
96 
97  // Pre-computed radial profile
98  struct profile {
99  std::vector<double> pars; //!< Profile parameters
100  GNodeArray nodes; //!< Profile nodes
101  std::vector<double> values; //!< Profile values
102  std::vector<double> mc; //!< Profile for MC
103  double mc_max; //!< Maximum of profile for MC
104  };
105 
106  // Pre-computation cache
107  mutable std::vector<profile> m_profile; //!< Pre-computation cache
108 };
109 
110 
111 /***********************************************************************//**
112  * @brief Return number of nodes
113  *
114  * @return Number of nodes.
115  *
116  * Returns the number of nodes in the radial profile.
117  ***************************************************************************/
118 inline
120 {
121  return (m_num_nodes);
122 }
123 
124 
125 /***********************************************************************//**
126  * @brief Set number of nodes
127  *
128  * @param[in] number Number of nodes.
129  *
130  * Sets the number of nodes in the radial profile.
131  ***************************************************************************/
132 inline
134 {
136  return;
137 }
138 
139 #endif /* GMODELSPATIALRADIALPROFILE_HPP */
GModelSpatialRadialProfile(void)
Void constructor.
virtual void clear(void)=0
Clear object.
std::string number(const std::string &noun, const int &number)
Convert singular noun into number noun.
Definition: GTools.cpp:1167
Node array class.
Definition: GNodeArray.hpp:60
double mc_max
Maximum of profile for MC.
std::vector< profile > m_profile
Pre-computation cache.
virtual double theta_min(void) const =0
std::vector< double > pars
Profile parameters.
Abstract radial spatial model base class interface definition.
XML element node class.
Definition: GXmlElement.hpp:48
Random number generator class.
Definition: GRan.hpp:44
Time class.
Definition: GTime.hpp:55
void copy_members(const GModelSpatialRadialProfile &model)
Copy class members.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Return MC sky direction.
int num_nodes(void) const
Return number of nodes.
void init_members(void)
Initialise class members.
Node array class interface definition.
const GSkyDir & dir(void) const
Return position of radial spatial model.
void free_members(void)
Delete class members.
virtual double theta_max(void) const =0
GChatter
Definition: GTypemaps.hpp:33
virtual double eval(const double &theta, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
Evaluate function (in units of sr^-1)
virtual std::string classname(void) const =0
Return class name.
int m_num_nodes
Number of profile nodes.
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
virtual GModelSpatialRadialProfile & operator=(const GModelSpatialRadialProfile &model)
Assignment operator.
int cache_index(void) const
Return index to pre-computation cache.
virtual void set_region(void) const
Set boundary sky region.
Abstract radial spatial model base class.
virtual ~GModelSpatialRadialProfile(void)
Destructor.
virtual GModelSpatialRadialProfile * clone(void) const =0
Clones object.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks where model contains specified sky direction.
virtual double profile_value(const double &theta) const =0
Sky direction class.
Definition: GSkyDir.hpp:62
std::vector< double > mc
Profile for MC.
std::vector< double > values
Profile values.
Circular sky region class interface definition.
bool m_coord_indep
True if model independent of sky coordinates.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48