GammaLib 2.0.0
Loading...
Searching...
No Matches
GCTAModelSpatial.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCTAModelSpatial.hpp - Spatial model abstract base class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2018-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 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#include "GCTAInstDir.hpp"
38
39/* __ Forward declarations _______________________________________________ */
40class GRan;
41class GObservation;
42class GXmlElement;
43class 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 ***************************************************************************/
53class GCTAModelSpatial : public GBase {
54
55public:
56 // Constructors and destructors
57 GCTAModelSpatial(void);
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
94protected:
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 GCTAInstDir& roi_centre,
107 const int& min_iter,
108 const int& max_iter) :
109 m_spatial(spatial),
110 m_energy(energy),
111 m_time(time),
112 m_roi_centre(roi_centre),
113 m_min_iter(min_iter),
114 m_max_iter(max_iter) { }
115 double eval(const double& theta);
116 protected:
117 const GCTAModelSpatial* m_spatial; //!< Pointer to spatial component
118 GEnergy m_energy; //!< Energy
119 GTime m_time; //!< Time
120 GCTAInstDir m_roi_centre; //!< RoI centre
121 int m_min_iter; //!< Minimum number of Romberg iterations
122 int m_max_iter; //!< Maximum number of Romberg iterations
123 };
124
125 // RoI integration kernel over phi
127 public:
129 const GEnergy& energy,
130 const GTime& time,
131 const GCTAInstDir& roi_centre,
132 const double& theta) :
133 m_spatial(spatial),
134 m_energy(energy),
135 m_time(time),
136 m_roi_centre(roi_centre),
137 m_theta(theta) { }
138 double eval(const double& phi);
139 protected:
140 const GCTAModelSpatial* m_spatial; //!< Pointer to spatial component
141 GEnergy m_energy; //!< Energy
142 GTime m_time; //!< Time
143 GCTAInstDir m_roi_centre; //!< RoI centre
144 double m_theta; //!< Offset angle (radians)
145 };
146
147 // Proteced members
148 std::vector<GModelPar*> m_pars; //!< Parameter pointers
149};
150
151
152/***********************************************************************//**
153 * @brief Return number of model parameters
154 *
155 * @return Number of model parameters.
156 ***************************************************************************/
157inline
159{
160 return ((int)m_pars.size());
161}
162
163#endif /* GCTAMODELSPATIAL_HPP */
Definition of interface for all GammaLib classes.
CTA instrument direction class interface definition.
Energy value class definition.
Single parameter function abstract base class definition.
Model parameter class interface definition.
Time class interface definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
Interface class for all GammaLib classes.
Definition GBase.hpp:52
CTA instrument direction class.
const GCTAModelSpatial * m_spatial
Pointer to spatial component.
double eval(const double &phi)
Kernel for azimuth angle integration of spatial component.
npred_roi_kern_phi(const GCTAModelSpatial *spatial, const GEnergy &energy, const GTime &time, const GCTAInstDir &roi_centre, const double &theta)
double m_theta
Offset angle (radians)
const GCTAModelSpatial * m_spatial
Pointer to spatial component.
int m_min_iter
Minimum number of Romberg iterations.
double eval(const double &theta)
Kernel for offset angle integration of spatial component.
int m_max_iter
Maximum number of Romberg iterations.
npred_roi_kern_theta(const GCTAModelSpatial *spatial, const GEnergy &energy, const GTime &time, const GCTAInstDir &roi_centre, const int &min_iter, const int &max_iter)
Abstract spatial model class.
void init_members(void)
Initialise class members.
GCTAModelSpatial(void)
Void constructor.
virtual double mc_max_value(const GCTAObservation &obs) const =0
virtual ~GCTAModelSpatial(void)
Destructor.
virtual void read(const GXmlElement &xml)=0
virtual std::string type(void) const =0
std::vector< GModelPar * > m_pars
Parameter pointers.
virtual GModelPar & operator[](const int &index)
Returns model parameter.
int size(void) const
Return number of model parameters.
virtual double eval(const GCTAInstDir &dir, const GEnergy &energy, const GTime &time, const bool &gradients=false) const =0
virtual double npred(const GEnergy &energy, const GTime &time, const GObservation &obs) const
Return integral of spatial model component.
virtual std::string classname(void) const =0
Return class name.
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
virtual void clear(void)=0
Clear object.
virtual GCTAModelSpatial & operator=(const GCTAModelSpatial &model)
Assignment operator.
virtual void write(GXmlElement &xml) const =0
virtual GCTAInstDir mc(const GEnergy &energy, const GTime &time, const GCTAObservation &obs, GRan &ran) const
Returns MC instrument direction.
void copy_members(const GCTAModelSpatial &model)
Copy class members.
void free_members(void)
Delete class members.
virtual GCTAModelSpatial * clone(void) const =0
Clones object.
CTA observation class.
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Single parameter function abstract base class.
Definition GFunction.hpp:44
Model parameter class.
Definition GModelPar.hpp:87
Abstract observation base class.
Random number generator class.
Definition GRan.hpp:44
Time class.
Definition GTime.hpp:55
XML element node class.