GammaLib  2.1.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-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 _______________________________________________ */
40 class GRan;
41 class GObservation;
42 class GXmlElement;
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 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
126  class npred_roi_kern_phi : public GFunction {
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  ***************************************************************************/
157 inline
158 int GCTAModelSpatial::size(void) const
159 {
160  return ((int)m_pars.size());
161 }
162 
163 #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:48
const GCTAModelSpatial * m_spatial
Pointer to spatial component.
Random number generator class.
Definition: GRan.hpp:44
Time class.
Definition: GTime.hpp:55
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
void free_members(void)
Delete class members.
const GCTAModelSpatial * m_spatial
Pointer to spatial component.
void init_members(void)
Initialise class members.
CTA instrument direction class interface definition.
npred_roi_kern_phi(const GCTAModelSpatial *spatial, const GEnergy &energy, const GTime &time, const GCTAInstDir &roi_centre, const double &theta)
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:63
virtual GCTAModelSpatial * clone(void) const =0
Clones object.
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)
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