GammaLib  1.7.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 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 std::string type(void) const = 0;
66  virtual double theta_min(void) const = 0;
67  virtual double theta_max(void) const = 0;
68  virtual std::string print(const GChatter& chatter = NORMAL) const = 0;
69 
70  // Implemented pure virtual base class methods
71  virtual double eval(const double& theta,
72  const GEnergy& energy,
73  const GTime& time,
74  const bool& gradients = false) const;
75  virtual GSkyDir mc(const GEnergy& energy,
76  const GTime& time,
77  GRan& ran) const;
78  virtual bool contains(const GSkyDir& dir,
79  const double& margin = 0.0) const;
80  virtual GSkyRegion* region(void) const;
81 
82  // Implement other methods
83  int num_nodes(void) const;
84  void num_nodes(const int& number);
85 
86 protected:
87  // Protected methods
88  void init_members(void);
89  void copy_members(const GModelSpatialRadialProfile& model);
90  void free_members(void);
91  int cache_index(void) const;
92  virtual double profile_value(const double& theta) const = 0;
93  void set_region(void) const;
94 
95  // Protected members
96  bool m_coord_indep; //!< True if model independent
97  //!< of sky coordinates
98  int m_num_nodes; //!< Number of profile nodes
99  mutable GSkyRegionCircle m_region; //!< Bounding circle
100 
101  // Pre-computed radial profile
102  struct profile {
103  std::vector<double> pars; //!< Profile parameters
104  GNodeArray nodes; //!< Profile nodes
105  std::vector<double> values; //!< Profile values
106  std::vector<double> mc; //!< Profile for MC
107  double mc_max; //!< Maximum of profile for MC
108  };
109 
110  // Pre-computation cache
111  mutable std::vector<profile> m_profile; //!< Pre-computation cache
112 };
113 
114 
115 /***********************************************************************//**
116  * @brief Return number of nodes
117  *
118  * @return Number of nodes.
119  *
120  * Returns the number of nodes in the radial profile.
121  ***************************************************************************/
122 inline
124 {
125  return (m_num_nodes);
126 }
127 
128 
129 /***********************************************************************//**
130  * @brief Set number of nodes
131  *
132  * @param[in] number Number of nodes.
133  *
134  * Sets the number of nodes in the radial profile.
135  ***************************************************************************/
136 inline
138 {
140  return;
141 }
142 
143 
144 /***********************************************************************//**
145  * @brief Return boundary sky region
146  *
147  * @return Boundary sky region.
148  *
149  * Returns a sky region that fully encloses the spatial model component.
150  ***************************************************************************/
151 inline
153 {
154  set_region();
155  return (&m_region);
156 }
157 
158 #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:1046
Node array class.
Definition: GNodeArray.hpp:60
double mc_max
Maximum of profile for MC.
std::vector< profile > m_profile
Pre-computation cache.
virtual std::string type(void) const =0
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:47
Random number generator class.
Definition: GRan.hpp:44
Time class.
Definition: GTime.hpp:54
void copy_members(const GModelSpatialRadialProfile &model)
Copy class members.
Interface for the circular sky region class.
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.
virtual GSkyRegion * region(void) const
Return boundary sky region.
Node array class interface definition.
GSkyRegionCircle m_region
Bounding circle.
Abstract interface for the sky region class.
Definition: GSkyRegion.hpp:57
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.
GSkyDir dir(void) const
Return position of radial spatial model.
virtual GModelSpatialRadialProfile & operator=(const GModelSpatialRadialProfile &model)
Assignment operator.
int cache_index(void) const
Return index to pre-computation cache.
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.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48