GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTAModelRadialProfile.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCTAModelRadialProfile.hpp - Radial Profile CTA model class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2011-2018 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 GCTAModelRadialProfile.hpp
23  * @brief Radial Profile model class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GCTAMODELRADIALPROFILE_HPP
28 #define GCTAMODELRADIALPROFILE_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include <cmath>
33 #include "GMath.hpp"
34 #include "GModelPar.hpp"
35 #include "GCTAModelRadial.hpp"
36 #include "GFunction.hpp"
37 
38 /* __ Forward declarations _______________________________________________ */
39 class GRan;
40 class GXmlElement;
41 class GCTAObservation;
42 class GCTAInstDir;
43 
44 
45 /***********************************************************************//**
46  * @class GCTAModelRadialProfile
47  *
48  * @brief Radial Profile CTA model class
49  *
50  * This class implements the radial profile function
51  * \f[f(\theta) = (1 + (\theta/c_0)^{c_1})^{-c_2/c_1}\f]
52  * where
53  * \f$\theta\f$ is the offset angle (in degrees),
54  * \f$c_0\f$ is the width of the profile (width),
55  * \f$c_1\f$ is the width of the central plateau (core), and
56  * \f$c_2\f$ is the size of the tail (tail).
57  * Note that all 3 parameters are positive values.
58  ***************************************************************************/
60 
61 public:
62  // Constructors and destructors
64  explicit GCTAModelRadialProfile(const double& width, const double& core,
65  const double& tail);
66  explicit GCTAModelRadialProfile(const GXmlElement& xml);
68  virtual ~GCTAModelRadialProfile(void);
69 
70  // Operators
72 
73  // Implemented pure virtual methods
74  virtual void clear(void);
75  virtual GCTAModelRadialProfile* clone(void) const;
76  virtual std::string classname(void) const;
77  virtual std::string type(void) const;
78  virtual double eval(const double& offset,
79  const bool& gradients = false) const;
80  virtual GCTAInstDir mc(GRan& ran) const;
81  virtual double mc_max_value(const GCTAObservation& obs) const;
82  virtual double omega(void) const;
83  virtual void read(const GXmlElement& xml);
84  virtual void write(GXmlElement& xml) const;
85  virtual std::string print(const GChatter& chatter = NORMAL) const;
86 
87  // Other methods
88  double width(void) const;
89  double core(void) const;
90  double tail(void) const;
91  void width(const double& width);
92  void core(const double& core);
93  void tail(const double& tail);
94 
95 protected:
96  // Protected methods
97  void init_members(void);
98  void copy_members(const GCTAModelRadialProfile& model);
99  void free_members(void);
100 
101  // Radial integration class (used by omega() method). Note that the
102  // integration is done in radians
103  class integrand : public GFunction {
104  public:
105  integrand(const GCTAModelRadialProfile* model) : m_model(model) { }
106  double eval(const double& x) {
107  return (std::sin(x)*m_model->eval(x*gammalib::rad2deg));
108  }
109  private:
111  };
112 
113  // Protected members
114  GModelPar m_width; //!< Width parameter
115  GModelPar m_core; //!< Core parameter
116  GModelPar m_tail; //!< Tail parameter
117 };
118 
119 
120 /***********************************************************************//**
121  * @brief Return class name
122  *
123  * @return String containing the class name ("GCTAModelRadialProfile").
124  ***************************************************************************/
125 inline
126 std::string GCTAModelRadialProfile::classname(void) const
127 {
128  return ("GCTAModelRadialProfile");
129 }
130 
131 
132 /***********************************************************************//**
133  * @brief Return model type
134  *
135  * @return Model type "Profile".
136  ***************************************************************************/
137 inline
138 std::string GCTAModelRadialProfile::type(void) const
139 {
140  return ("Profile");
141 }
142 
143 
144 /***********************************************************************//**
145  * @brief Return profile width
146  *
147  * @return Profile width.
148  ***************************************************************************/
149 inline
151 {
152  return (m_width.value());
153 }
154 
155 
156 /***********************************************************************//**
157  * @brief Return profile core
158  *
159  * @return Profile core.
160  ***************************************************************************/
161 inline
163 {
164  return (m_core.value());
165 }
166 
167 
168 /***********************************************************************//**
169  * @brief Return profile tail
170  *
171  * @return Profile tail.
172  ***************************************************************************/
173 inline
175 {
176  return (m_tail.value());
177 }
178 
179 
180 /***********************************************************************//**
181  * @brief Set profile width
182  *
183  * @param[in] width Profile width.
184  ***************************************************************************/
185 inline
186 void GCTAModelRadialProfile::width(const double& width)
187 {
188  m_width.value(width);
189  return;
190 }
191 
192 
193 /***********************************************************************//**
194  * @brief Set profile core
195  *
196  * @param[in] core Profile core.
197  ***************************************************************************/
198 inline
199 void GCTAModelRadialProfile::core(const double& core)
200 {
201  m_core.value(core);
202  return;
203 }
204 
205 
206 /***********************************************************************//**
207  * @brief Set profile tail
208  *
209  * @param[in] tail Profile tail.
210  ***************************************************************************/
211 inline
212 void GCTAModelRadialProfile::tail(const double& tail)
213 {
214  m_tail.value(tail);
215  return;
216 }
217 
218 #endif /* GCTAMODELRADIALPROFILE_HPP */
virtual std::string print(const GChatter &chatter=NORMAL) const
Print point source information.
GCTAModelRadialProfile(void)
Void constructor.
void init_members(void)
Initialise class members.
double tail(void) const
Return profile tail.
XML element node class.
Definition: GXmlElement.hpp:48
virtual void clear(void)
Clear instance.
virtual std::string classname(void) const
Return class name.
virtual GCTAModelRadialProfile * clone(void) const
Clone instance.
Random number generator class.
Definition: GRan.hpp:44
double width(void) const
Return profile width.
Model parameter class interface definition.
Model parameter class.
Definition: GModelPar.hpp:87
virtual double omega(void) const
Returns integral over radial model (in steradians)
Single parameter function abstract base class definition.
void free_members(void)
Delete class members.
virtual double eval(const double &offset, const bool &gradients=false) const
Evaluate function.
virtual ~GCTAModelRadialProfile(void)
Destructor.
Abstract radial acceptance model class interface definition.
GModelPar m_core
Core parameter.
GChatter
Definition: GTypemaps.hpp:33
Radial Profile CTA model class.
virtual double mc_max_value(const GCTAObservation &obs) const
Return maximum function value for Monte Carlo simulations.
GModelPar m_tail
Tail parameter.
virtual GCTAInstDir mc(GRan &ran) const
Returns MC instrument direction.
virtual GCTAModelRadialProfile & operator=(const GCTAModelRadialProfile &model)
Assignment operator.
integrand(const GCTAModelRadialProfile *model)
virtual void read(const GXmlElement &xml)
Read model from XML element.
double value(void) const
Return parameter value.
Single parameter function abstract base class.
Definition: GFunction.hpp:44
const GCTAModelRadialProfile * m_model
GVector sin(const GVector &vector)
Computes sine of vector elements.
Definition: GVector.cpp:1316
virtual void write(GXmlElement &xml) const
Write model into XML element.
CTA instrument direction class.
Definition: GCTAInstDir.hpp:63
GModelPar m_width
Width parameter.
Abstract radial acceptance model class.
void copy_members(const GCTAModelRadialProfile &model)
Copy class members.
double core(void) const
Return profile core.
const double rad2deg
Definition: GMath.hpp:44
CTA observation class.
virtual std::string type(void) const
Return model type.
Mathematical function definitions.