GammaLib 2.0.0
Loading...
Searching...
No Matches
GModelSpatialComposite.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GModelSpatialComposite.hpp - Spatial composite model class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2016-2021 by Domenico Tiziani *
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 GModelSpatialComposite.hpp
23 * @brief Spatial composite model class interface definition
24 * @author Domenico Tiziani
25 */
26
27#ifndef GMODELSPATIALCOMPOSITE_HPP
28#define GMODELSPATIALCOMPOSITE_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include "GModelSpatial.hpp"
33#include "GModelPar.hpp"
34#include "GSkyDir.hpp"
35#include "GSkyRegionCircle.hpp"
36#include "GXmlElement.hpp"
37
38
39/***********************************************************************//**
40 * @class GModelSpatialComposite
41 *
42 * @brief Spatial composite model
43 *
44 * This class implements the spatial model for a composition of spatial
45 * models.
46 ***************************************************************************/
48
49public:
50 // Constructors and destructors
52 GModelSpatialComposite(const bool& dummy, const std::string& type);
53 explicit GModelSpatialComposite(const GXmlElement& xml);
55 virtual ~GModelSpatialComposite(void);
56
57 // Operators
59
60 // Implemented pure virtual methods
61 virtual void clear(void);
62 virtual GModelSpatialComposite* clone(void) const;
63 virtual std::string classname(void) const;
64 virtual GClassCode code(void) const;
65 virtual double eval(const GPhoton& photon,
66 const bool& gradients = false) const;
67 virtual GSkyDir mc(const GEnergy& energy,
68 const GTime& time,
69 GRan& ran) const;
70 virtual double mc_norm(const GSkyDir& dir,
71 const double& radius) const;
72 virtual bool contains(const GSkyDir& dir,
73 const double& margin = 0.0) const;
74 virtual void read(const GXmlElement& xml);
75 virtual void write(GXmlElement& xml) const;
76 virtual std::string print(const GChatter& chatter = NORMAL) const;
77
78 // Overloaded base class methods
79 virtual double flux(const GSkyRegion& region,
80 const GEnergy& srcEng = GEnergy(),
81 const GTime& srcTime = GTime()) const;
82
83 // Other methods
84 int components(void) const;
85 void append(const GModelSpatial& component,
86 const std::string& name = "",
87 const GModelPar& par = GModelPar("", 1.0));
88 const GModelSpatial* component(const int& index) const;
89 const GModelSpatial* component(const std::string& name) const;
90 double scale(const int& index) const;
91 double sum_of_scales(void) const;
92
93
94protected:
95 // Protected methods
96 void init_members(void);
97 void copy_members(const GModelSpatialComposite& model);
98 void free_members(void);
99 virtual void set_region(void) const;
100
101 // Protected members
102 std::vector<GModelSpatial*> m_components; //!< Components
103 std::vector<std::string> m_names; //!< Component names
104 std::vector<GModelPar*> m_scales; //!< Component scales
105};
106
107
108/***********************************************************************//**
109 * @brief Return class name
110 *
111 * @return String containing the class name ("GModelSpatialComposite").
112 ***************************************************************************/
113inline
115{
116 return ("GModelSpatialComposite");
117}
118
119
120/***********************************************************************//**
121 * @brief Return class code
122 *
123 * @return GModelSpatialComposite.
124 *
125 * Returns the code GModelSpatialComposite of the class.
126 ***************************************************************************/
127inline
132
133
134/***********************************************************************//**
135 * @brief Return normalization of composite source for Monte Carlo
136 * simulations
137 *
138 * @param[in] dir Centre of simulation cone.
139 * @param[in] radius Radius of simulation cone (degrees).
140 * @return Normalization.
141 *
142 * Returns unity.
143 ***************************************************************************/
144inline
146 const double& radius) const
147{
148 return 1.0;
149}
150
151
152/***********************************************************************//**
153 * @brief Return number of model components
154 *
155 * @return Number of model components.
156 ***************************************************************************/
157inline
159{
160 return ((int)m_components.size());
161}
162
163#endif /* GMODELSPATIALCOMPOSITE_HPP */
Model parameter class interface definition.
Abstract spatial model base class interface definition.
Sky direction class interface definition.
Circular sky region class interface definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
GClassCode
Definition GTypemaps.hpp:42
@ GMODEL_SPATIAL_COMPOSITE
Definition GTypemaps.hpp:47
XML element node class interface definition.
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Model parameter class.
Definition GModelPar.hpp:87
Spatial composite model.
void free_members(void)
Delete class members.
std::vector< std::string > m_names
Component names.
virtual void clear(void)
Clear spatial composite model.
std::vector< GModelSpatial * > m_components
Components.
virtual double flux(const GSkyRegion &region, const GEnergy &srcEng=GEnergy(), const GTime &srcTime=GTime()) const
Returns flux integrated in sky region.
void copy_members(const GModelSpatialComposite &model)
Copy class members.
const GModelSpatial * component(const int &index) const
Returns pointer to spatial component element.
void append(const GModelSpatial &component, const std::string &name="", const GModelPar &par=GModelPar("", 1.0))
Append spatial component.
virtual GModelSpatialComposite * clone(void) const
Clone spatial composite model.
virtual std::string classname(void) const
Return class name.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
virtual void read(const GXmlElement &xml)
Read model from XML element.
int components(void) const
Return number of model components.
virtual double eval(const GPhoton &photon, const bool &gradients=false) const
Evaluate function.
virtual void set_region(void) const
Set boundary sky region.
std::vector< GModelPar * > m_scales
Component scales.
virtual GClassCode code(void) const
Return class code.
void init_members(void)
Initialise class members.
double sum_of_scales(void) const
Returns sum of all model scales.
double scale(const int &index) const
Returns scale of spatial component.
virtual ~GModelSpatialComposite(void)
Destructor.
GModelSpatialComposite(void)
Void constructor.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks where model contains specified sky direction.
virtual void write(GXmlElement &xml) const
Write model into XML element.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print composite spatial model information.
virtual GModelSpatialComposite & operator=(const GModelSpatialComposite &model)
Assignment operator.
virtual double mc_norm(const GSkyDir &dir, const double &radius) const
Return normalization of composite source for Monte Carlo simulations.
Abstract spatial model base class.
std::string type(void) const
Return model type.
const GSkyRegion * region(void) const
Return boundary sky region.
Class that handles photons.
Definition GPhoton.hpp:47
Random number generator class.
Definition GRan.hpp:44
Sky direction class.
Definition GSkyDir.hpp:62
Abstract interface for the sky region class.
Time class.
Definition GTime.hpp:55
XML element node class.