GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTAModelRadialPolynom.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCTAModelRadialPolynom.hpp - Radial Polynom 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 GCTAModelRadialPolynom.hpp
23  * @brief Radial Polynom model class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GCTAMODELRADIALPOLYNOM_HPP
28 #define GCTAMODELRADIALPOLYNOM_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include <vector>
33 #include <cmath>
34 #include "GMath.hpp"
35 #include "GModelPar.hpp"
36 #include "GCTAModelRadial.hpp"
37 #include "GFunction.hpp"
38 
39 /* __ Forward declarations _______________________________________________ */
40 class GRan;
41 class GXmlElement;
42 class GCTAObservation;
43 class GCTAInstDir;
44 
45 
46 /***********************************************************************//**
47  * @class GCTAModelRadialPolynom
48  *
49  * @brief Radial Polynom CTA model class
50  *
51  * This class implements the radial function
52  * \f[f(\theta) = \sum_{i=0}^m c_i \theta^i\f]
53  * where
54  * \f$\theta\f$ is the offset angle (in degrees), and
55  * \f$c_i\f$ are the polynomial coefficients.
56  *
57  * This function represents a Polynom in \f$\theta\f$.
58  ***************************************************************************/
60 
61 public:
62  // Constructors and destructors
64  explicit GCTAModelRadialPolynom(const std::vector<double>& coeffs);
65  explicit GCTAModelRadialPolynom(const GXmlElement& xml);
67  virtual ~GCTAModelRadialPolynom(void);
68 
69  // Operators
71 
72  // Implemented pure virtual methods
73  virtual void clear(void);
74  virtual GCTAModelRadialPolynom* clone(void) const;
75  virtual std::string classname(void) const;
76  virtual std::string type(void) const;
77  virtual double eval(const double& offset,
78  const bool& gradients = false) const;
79  virtual GCTAInstDir mc(GRan& ran) const;
80  virtual double mc_max_value(const GCTAObservation& obs) const;
81  virtual double omega(void) const;
82  virtual void read(const GXmlElement& xml);
83  virtual void write(GXmlElement& xml) const;
84  virtual std::string print(const GChatter& chatter = NORMAL) const;
85 
86  // Other methods
87  //double coeff(void) const;
88  //void coeff(const double& value);
89 
90 protected:
91  // Protected methods
92  void init_members(void);
93  void copy_members(const GCTAModelRadialPolynom& model);
94  void free_members(void);
95  void update_pars(void);
96 
97  // Radial integration class (used by omega() method). Note that the
98  // integration is done in radians
99  class integrand : public GFunction {
100  public:
101  integrand(const GCTAModelRadialPolynom* model) : m_model(model) { }
102  double eval(const double& x) {
103  return (std::sin(x)*m_model->eval(x*gammalib::rad2deg));
104  }
105  private:
107  };
108 
109  // Protected members
110  std::vector<GModelPar> m_coeffs; //!< Coefficients
111 };
112 
113 
114 /***********************************************************************//**
115  * @brief Return class name
116  *
117  * @return String containing the class name ("GCTAModelRadialPolynom").
118  ***************************************************************************/
119 inline
120 std::string GCTAModelRadialPolynom::classname(void) const
121 {
122  return ("GCTAModelRadialPolynom");
123 }
124 
125 
126 /***********************************************************************//**
127  * @brief Return model type
128  *
129  * @return Model type "Polynom".
130  ***************************************************************************/
131 inline
132 std::string GCTAModelRadialPolynom::type(void) const
133 {
134  return ("Polynom");
135 }
136 
137 #endif /* GCTAMODELRADIALPOLYNOM_HPP */
void free_members(void)
Delete class members.
integrand(const GCTAModelRadialPolynom *model)
virtual double omega(void) const
Returns integral over radial model (in steradians)
virtual std::string print(const GChatter &chatter=NORMAL) const
Print point source information.
virtual void write(GXmlElement &xml) const
Write model into XML element.
void copy_members(const GCTAModelRadialPolynom &model)
Copy class members.
virtual double mc_max_value(const GCTAObservation &obs) const
Return maximum function value for Monte Carlo simulations.
XML element node class.
Definition: GXmlElement.hpp:47
Random number generator class.
Definition: GRan.hpp:44
const GCTAModelRadialPolynom * m_model
void update_pars(void)
Update parameter mapping.
Model parameter class interface definition.
virtual ~GCTAModelRadialPolynom(void)
Destructor.
void init_members(void)
Initialise class members.
virtual GCTAInstDir mc(GRan &ran) const
Returns MC instrument direction.
Single parameter function abstract base class definition.
Radial Polynom CTA model class.
Abstract radial acceptance model class interface definition.
GChatter
Definition: GTypemaps.hpp:33
GCTAModelRadialPolynom(void)
Void constructor.
virtual GCTAModelRadialPolynom & operator=(const GCTAModelRadialPolynom &model)
Assignment operator.
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual void clear(void)
Clear instance.
Single parameter function abstract base class.
Definition: GFunction.hpp:44
virtual std::string classname(void) const
Return class name.
GVector sin(const GVector &vector)
Computes sine of vector elements.
Definition: GVector.cpp:1226
virtual std::string type(void) const
Return model type.
CTA instrument direction class.
Definition: GCTAInstDir.hpp:59
Abstract radial acceptance model class.
const double rad2deg
Definition: GMath.hpp:44
CTA observation class.
std::vector< GModelPar > m_coeffs
Coefficients.
virtual double eval(const double &offset, const bool &gradients=false) const
Evaluate function.
virtual GCTAModelRadialPolynom * clone(void) const
Clone instance.
Mathematical function definitions.