GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTAModelSpatial.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCTAModelSpatial.hpp - Spatial model abstract base class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 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 GCTAModelSpatial.hpp
23  * @brief Abstract spatial model class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GCTAMODELSPATIAL_HPP
28 #define GCTAMODELSPATIAL_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GBase.hpp"
33 #include "GFunction.hpp"
34 #include "GEnergy.hpp"
35 #include "GTime.hpp"
36 #include "GModelPar.hpp"
37 
38 /* __ Forward declarations _______________________________________________ */
39 class GRan;
40 class GObservation;
41 class GXmlElement;
42 class GCTAInstDir;
43 class GCTAObservation;
44 
45 
46 /***********************************************************************//**
47  * @class GCTAModelSpatial
48  *
49  * @brief Abstract spatial model class
50  *
51  * This class implements the spatial component of the CTA background model.
52  ***************************************************************************/
53 class GCTAModelSpatial : public GBase {
54 
55 public:
56  // Constructors and destructors
57  GCTAModelSpatial(void);
58  GCTAModelSpatial(const GCTAModelSpatial& model);
59  virtual ~GCTAModelSpatial(void);
60 
61  // Operators
62  virtual GCTAModelSpatial& operator=(const GCTAModelSpatial& model);
63  virtual GModelPar& operator[](const int& index);
64  virtual const GModelPar& operator[](const int& index) const;
65  virtual GModelPar& operator[](const std::string& name);
66  virtual const GModelPar& operator[](const std::string& name) const;
67 
68  // Pure virtual methods
69  virtual void clear(void) = 0;
70  virtual GCTAModelSpatial* clone(void) const = 0;
71  virtual std::string classname(void) const = 0;
72  virtual std::string type(void) const = 0;
73  virtual double eval(const GCTAInstDir& dir,
74  const GEnergy& energy,
75  const GTime& time,
76  const bool& gradients = false) const = 0;
77  virtual double mc_max_value(const GCTAObservation& obs) const = 0;
78  virtual void read(const GXmlElement& xml) = 0;
79  virtual void write(GXmlElement& xml) const = 0;
80  virtual std::string print(const GChatter& chatter = NORMAL) const = 0;
81 
82  // Implemented virtual methods
83  virtual GCTAInstDir mc(const GEnergy& energy,
84  const GTime& time,
85  const GCTAObservation& obs,
86  GRan& ran) const;
87 
88  // Methods
89  int size(void) const;
90  virtual double npred(const GEnergy& energy,
91  const GTime& time,
92  const GObservation& obs) const;
93 
94 protected:
95  // Protected methods
96  void init_members(void);
97  void copy_members(const GCTAModelSpatial& model);
98  void free_members(void);
99 
100  // RoI integration kernel over theta
102  public:
104  const GEnergy& energy,
105  const GTime& time,
106  const int& min_iter,
107  const int& max_iter) :
108  m_spatial(spatial),
109  m_energy(energy),
110  m_time(time),
111  m_min_iter(min_iter),
112  m_max_iter(max_iter) { }
113  double eval(const double& theta);
114  protected:
115  const GCTAModelSpatial* m_spatial; //!< Pointer to spatial component
116  GEnergy m_energy; //!< Energy
117  GTime m_time; //!< Time
118  int m_min_iter; //!< Minimum number of Romberg iterations
119  int m_max_iter; //!< Maximum number of Romberg iterations
120  };
121 
122  // RoI integration kernel over phi
123  class npred_roi_kern_phi : public GFunction {
124  public:
126  const GEnergy& energy,
127  const GTime& time,
128  const double& theta) :
129  m_spatial(spatial),
130  m_energy(energy),
131  m_time(time),
132  m_theta(theta) { }
133  double eval(const double& phi);
134  protected:
135  const GCTAModelSpatial* m_spatial; //!< Pointer to spatial component
136  GEnergy m_energy; //!< Energy
137  GTime m_time; //!< Time
138  double m_theta; //!< Offset angle (radians)
139  };
140 
141  // Proteced members
142  std::vector<GModelPar*> m_pars; //!< Parameter pointers
143 };
144 
145 
146 /***********************************************************************//**
147  * @brief Return number of model parameters
148  *
149  * @return Number of model parameters.
150  ***************************************************************************/
151 inline
152 int GCTAModelSpatial::size(void) const
153 {
154  return ((int)m_pars.size());
155 }
156 
157 #endif /* GCTAMODELSPATIAL_HPP */
virtual GCTAInstDir mc(const GEnergy &energy, const GTime &time, const GCTAObservation &obs, GRan &ran) const
Returns MC instrument direction.
Abstract spatial model class.
Energy value class definition.
void copy_members(const GCTAModelSpatial &model)
Copy class members.
double eval(const double &phi)
Kernel for azimuth angle integration of spatial component.
GCTAModelSpatial(void)
Void constructor.
virtual void write(GXmlElement &xml) const =0
virtual double mc_max_value(const GCTAObservation &obs) const =0
Definition of interface for all GammaLib classes.
virtual GCTAModelSpatial & operator=(const GCTAModelSpatial &model)
Assignment operator.
XML element node class.
Definition: GXmlElement.hpp:47
const GCTAModelSpatial * m_spatial
Pointer to spatial component.
Random number generator class.
Definition: GRan.hpp:44
Time class.
Definition: GTime.hpp:54
virtual std::string type(void) const =0
virtual void clear(void)=0
Clear object.
int m_min_iter
Minimum number of Romberg iterations.
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
Model parameter class interface definition.
Model parameter class.
Definition: GModelPar.hpp:87
int m_max_iter
Maximum number of Romberg iterations.
virtual ~GCTAModelSpatial(void)
Destructor.
Single parameter function abstract base class definition.
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
npred_roi_kern_phi(const GCTAModelSpatial *spatial, const GEnergy &energy, const GTime &time, const double &theta)
void free_members(void)
Delete class members.
const GCTAModelSpatial * m_spatial
Pointer to spatial component.
void init_members(void)
Initialise class members.
int size(void) const
Return number of model parameters.
GChatter
Definition: GTypemaps.hpp:33
virtual GModelPar & operator[](const int &index)
Returns model parameter.
Abstract observation base class.
double m_theta
Offset angle (radians)
virtual std::string classname(void) const =0
Return class name.
Single parameter function abstract base class.
Definition: GFunction.hpp:44
virtual double eval(const GCTAInstDir &dir, const GEnergy &energy, const GTime &time, const bool &gradients=false) const =0
CTA instrument direction class.
Definition: GCTAInstDir.hpp:59
virtual GCTAModelSpatial * clone(void) const =0
Clones object.
npred_roi_kern_theta(const GCTAModelSpatial *spatial, const GEnergy &energy, const GTime &time, const int &min_iter, const int &max_iter)
CTA observation class.
std::vector< GModelPar * > m_pars
Parameter pointers.
virtual double npred(const GEnergy &energy, const GTime &time, const GObservation &obs) const
Return integral of spatial model component.
double eval(const double &theta)
Kernel for offset angle integration of spatial component.
Time class interface definition.
virtual void read(const GXmlElement &xml)=0
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48