GammaLib 2.0.0
Loading...
Searching...
No Matches
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>
33#include "GNodeArray.hpp"
34#include "GSkyRegionCircle.hpp"
35
36/* __ Forward declaration ________________________________________________ */
37class GXmlElement;
38class 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
51public:
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
84protected:
85 // Protected methods
86 void init_members(void);
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 ***************************************************************************/
118inline
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 ***************************************************************************/
132inline
134{
135 m_num_nodes = number;
136 return;
137}
138
139#endif /* GMODELSPATIALRADIALPROFILE_HPP */
Abstract radial spatial model base class interface definition.
Node array class interface definition.
Circular sky region class interface definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks where model contains specified sky direction.
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
int cache_index(void) const
Return index to pre-computation cache.
int m_num_nodes
Number of profile nodes.
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.
virtual GModelSpatialRadialProfile & operator=(const GModelSpatialRadialProfile &model)
Assignment operator.
std::vector< profile > m_profile
Pre-computation cache.
virtual ~GModelSpatialRadialProfile(void)
Destructor.
virtual std::string classname(void) const =0
Return class name.
virtual void set_region(void) const
Set boundary sky region.
bool m_coord_indep
True if model independent of sky coordinates.
virtual double profile_value(const double &theta) const =0
virtual void clear(void)=0
Clear object.
virtual double theta_max(void) const =0
GModelSpatialRadialProfile(void)
Void constructor.
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 GModelSpatialRadialProfile * clone(void) const =0
Clones object.
void init_members(void)
Initialise class members.
void free_members(void)
Delete class members.
void copy_members(const GModelSpatialRadialProfile &model)
Copy class members.
virtual double theta_min(void) const =0
Abstract radial spatial model base class.
const GSkyDir & dir(void) const
Return position of radial spatial model.
Node array class.
Random number generator class.
Definition GRan.hpp:44
Sky direction class.
Definition GSkyDir.hpp:62
Time class.
Definition GTime.hpp:55
XML element node class.
std::vector< double > pars
Profile parameters.
std::vector< double > mc
Profile for MC.
std::vector< double > values
Profile values.