GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTAModelRadialGauss.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCTAModelRadialGauss.hpp - Radial Gaussian 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 GCTAModelRadialGauss.hpp
23  * @brief Radial Gaussian model class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GCTAMODELRADIALGAUSS_HPP
28 #define GCTAMODELRADIALGAUSS_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include <cmath>
33 #include "GModelPar.hpp"
34 #include "GCTAModelRadial.hpp"
35 #include "GFunction.hpp"
36 
37 /* __ Forward declarations _______________________________________________ */
38 class GRan;
39 class GXmlElement;
40 class GCTAObservation;
41 class GCTAInstDir;
42 
43 
44 /***********************************************************************//**
45  * @class GCTAModelRadialGauss
46  *
47  * @brief Radial Gaussian CTA model class
48  *
49  * This class implements the radial function
50  * \f[f(\theta) = \exp \left(-\frac{1}{2}
51  * \left( \frac{\theta^2}{\sigma} \right)^2 \right)\f]
52  * where
53  * \f$\theta\f$ is the offset angle (in degrees), and
54  * \f$\sigma\f$ is the width parameter (in degrees\f$^2\f$).
55  *
56  * This function represents a Gaussian in \f$\theta^2\f$.
57  ***************************************************************************/
59 
60 public:
61  // Constructors and destructors
63  explicit GCTAModelRadialGauss(const double& sigma);
64  explicit GCTAModelRadialGauss(const GXmlElement& xml);
66  virtual ~GCTAModelRadialGauss(void);
67 
68  // Operators
70 
71  // Implemented pure virtual methods
72  virtual void clear(void);
73  virtual GCTAModelRadialGauss* clone(void) const;
74  virtual std::string classname(void) const;
75  virtual std::string type(void) const;
76  virtual double eval(const double& offset,
77  const bool& gradients = false) const;
78  virtual GCTAInstDir mc(GRan& ran) const;
79  virtual double mc_max_value(const GCTAObservation& obs) const;
80  virtual double omega(void) const;
81  virtual void read(const GXmlElement& xml);
82  virtual void write(GXmlElement& xml) const;
83  virtual std::string print(const GChatter& chatter = NORMAL) const;
84 
85  // Other methods
86  double sigma(void) const;
87  void sigma(const double& sigma);
88 
89 protected:
90  // Protected methods
91  void init_members(void);
92  void copy_members(const GCTAModelRadialGauss& model);
93  void free_members(void);
94 
95  // Radial integration class (used by omega() method). Note that the
96  // sigma parameter is given in rad^2
97  class integrand : public GFunction {
98  public:
99  integrand(double sigma) : m_sigma(sigma) { }
100  double eval(const double& x) {
101  double arg = x * x / m_sigma;
102  double arg2 = arg * arg;
103  double f = std::exp(-0.5 * arg2);
104  return (f*std::sin(x));
105  }
106  private:
107  double m_sigma;
108  };
109 
110  // Protected members
111  GModelPar m_sigma; //!< Width parameter (degrees^2)
112 };
113 
114 
115 /***********************************************************************//**
116  * @brief Return class name
117  *
118  * @return String containing the class name ("GCTAModelRadialGauss").
119  ***************************************************************************/
120 inline
121 std::string GCTAModelRadialGauss::classname(void) const
122 {
123  return ("GCTAModelRadialGauss");
124 }
125 
126 
127 /***********************************************************************//**
128  * @brief Return model type
129  *
130  * @return Model type "Gaussian".
131  ***************************************************************************/
132 inline
133 std::string GCTAModelRadialGauss::type(void) const
134 {
135  return ("Gaussian");
136 }
137 
138 
139 /***********************************************************************//**
140  * @brief Return Gaussian width parameter
141  *
142  * @return Gaussian width parameter.
143  ***************************************************************************/
144 inline
145 double GCTAModelRadialGauss::sigma(void) const
146 {
147  return (m_sigma.value());
148 }
149 
150 
151 /***********************************************************************//**
152  * @brief Set Gaussian width parameter
153  *
154  * @param[in] sigma Gaussian width parameter.
155  ***************************************************************************/
156 inline
157 void GCTAModelRadialGauss::sigma(const double& sigma)
158 {
159  m_sigma.value(sigma);
160  return;
161 }
162 
163 #endif /* GCTAMODELRADIALGAUSS_HPP */
virtual std::string print(const GChatter &chatter=NORMAL) const
Print point source information.
virtual double eval(const double &offset, const bool &gradients=false) const
Evaluate function.
virtual ~GCTAModelRadialGauss(void)
Destructor.
GCTAModelRadialGauss(void)
Void constructor.
virtual GCTAModelRadialGauss & operator=(const GCTAModelRadialGauss &model)
Assignment operator.
XML element node class.
Definition: GXmlElement.hpp:48
void free_members(void)
Delete class members.
Random number generator class.
Definition: GRan.hpp:44
virtual void clear(void)
Clear instance.
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual std::string type(void) const
Return model type.
Radial Gaussian CTA model class.
Model parameter class interface definition.
Model parameter class.
Definition: GModelPar.hpp:87
GModelPar m_sigma
Width parameter (degrees^2)
Single parameter function abstract base class definition.
Abstract radial acceptance model class interface definition.
void copy_members(const GCTAModelRadialGauss &model)
Copy class members.
GChatter
Definition: GTypemaps.hpp:33
double sigma(void) const
Return Gaussian width parameter.
virtual GCTAModelRadialGauss * clone(void) const
Clone instance.
virtual double mc_max_value(const GCTAObservation &obs) const
Return maximum function value for Monte Carlo simulations.
double value(void) const
Return parameter value.
Single parameter function abstract base class.
Definition: GFunction.hpp:44
GVector sin(const GVector &vector)
Computes sine of vector elements.
Definition: GVector.cpp:1316
virtual std::string classname(void) const
Return class name.
void init_members(void)
Initialise class members.
GVector exp(const GVector &vector)
Computes exponential of vector elements.
Definition: GVector.cpp:1232
CTA instrument direction class.
Definition: GCTAInstDir.hpp:63
virtual GCTAInstDir mc(GRan &ran) const
Returns MC instrument direction.
Abstract radial acceptance model class.
virtual double omega(void) const
Returns integral over radial model (in steradians)
CTA observation class.
virtual void write(GXmlElement &xml) const
Write model into XML element.