GammaLib 2.1.0.dev
Loading...
Searching...
No Matches
GSPIModelDataSpace.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GSPIModelDataSpace.hpp - INTEGRAL/SPI data space model *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2020-2025 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 GSPIModelDataSpace.hpp
23 * @brief INTEGRAL/SPI data space model interface definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GSPIMODELDATASPACE_HPP
28#define GSPIMODELDATASPACE_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include <vector>
33#include "GModelData.hpp"
34#include "GModelPar.hpp"
35#include "GSPIEventCube.hpp"
36
37/* __ Forward declarations _______________________________________________ */
38class GEnergy;
39class GTime;
40class GSPIInstDir;
41class GEvent;
42class GObservation;
43class GXmlElement;
44class GSPIObservation;
45
46/* __ Constants __________________________________________________________ */
47
48
49/***********************************************************************//**
50 * @class GSPIModelDataSpace
51 *
52 * @brief INTEGRAL/SPI data space model
53 *
54 * This class implements an INTEGRAL/SPI data space model that is based on
55 * model values that are found in the INTEGRAL/SPI event cube.
56 ***************************************************************************/
58
59public:
60 // Constructors and destructors
63 const std::string& name,
64 const std::string& method,
65 const int& index);
66 explicit GSPIModelDataSpace(const GXmlElement& xml);
68 virtual ~GSPIModelDataSpace(void);
69
70 // Operators
71 virtual GSPIModelDataSpace& operator=(const GSPIModelDataSpace& model);
72
73 // Implemented pure virtual methods
74 virtual void clear(void);
75 virtual GSPIModelDataSpace* clone(void) const;
76 virtual std::string classname(void) const;
77 virtual std::string type(void) const;
78 virtual bool is_constant(void) const;
79 virtual double eval(const GEvent& event,
80 const GObservation& obs,
81 const bool& gradients = false) const;
82 virtual double npred(const GEnergy& obsEng,
83 const GTime& obsTime,
84 const GObservation& obs) const;
85 virtual GSPIEventCube* mc(const GObservation& obs, GRan& ran) const;
86 virtual void read(const GXmlElement& xml);
87 virtual void write(GXmlElement& xml) const;
88 virtual std::string print(const GChatter& chatter = NORMAL) const;
89
90 // Reimplemented pure virtual base class methods
91 virtual GVector eval(const GObservation& obs,
92 GMatrixSparse* gradients = NULL,
93 const int& offset = 0) const;
94
95 // Reimplemented virtual base class methods
96 virtual void setup(const GObservation& obs) const;
97
98protected:
99 // Protected methods
100 void init_members(void);
101 void copy_members(const GSPIModelDataSpace& model);
102 void free_members(void);
103 void set_pointers(void);
104 void setup_pars(GSPIEventCube* cube);
106 std::vector<int>* indices,
107 std::vector<std::string>* names);
109 std::vector<int>* indices,
110 std::vector<std::string>* names);
112 std::vector<int>* indices,
113 std::vector<std::string>* names);
114 void setup_point(GSPIEventCube* cube,
115 std::vector<int>* indices,
116 std::vector<std::string>* names);
117 void setup_orbit(GSPIEventCube* cube,
118 std::vector<int>* indices,
119 std::vector<std::string>* names);
120 void setup_date(GSPIEventCube* cube,
121 std::vector<int>* indices,
122 std::vector<std::string>* names,
123 const double& time);
124 void add_gedfail(GSPIEventCube* cube,
125 std::vector<int>* indices,
126 std::vector<std::string>* names);
127 void add_gedanneal(GSPIEventCube* cube,
128 std::vector<int>* indices,
129 std::vector<std::string>* names);
130 void setup_dete(GSPIEventCube* cube,
131 std::vector<int>* indices,
132 std::vector<std::string>* names);
133 void setup_evtclass(GSPIEventCube* cube,
134 std::vector<int>* indices,
135 std::vector<std::string>* names);
136 void setup_ebin(GSPIEventCube* cube,
137 std::vector<int>* indices,
138 std::vector<std::string>* names);
139 double get_date_time(const std::string& method) const;
141 std::vector<int>* indices,
142 std::vector<std::string>* names,
143 const GTime& time,
144 const std::string& reason) const;
145
146 // Protected data members
147 mutable GSPIObservation* m_obs; //!< SPI observation
148 std::string m_method; //!< Fitting method
149 int m_index; //!< Index of model in event bins
150 int m_map_size; //!< Size of parameter map
151 int* m_map; //!< Parameter map
152 std::vector<GModelPar> m_parameters; //!< Model parameters
153};
154
155
156/***********************************************************************//**
157 * @brief Return class name
158 *
159 * @return String containing the class name ("GSPIModelDataSpace").
160 ***************************************************************************/
161inline
162std::string GSPIModelDataSpace::classname(void) const
163{
164 return ("GSPIModelDataSpace");
165}
166
167
168/***********************************************************************//**
169 * @brief Return model type
170 *
171 * @return Model type.
172 *
173 * Returns "DataSpace" as model type.
174 ***************************************************************************/
175inline
176std::string GSPIModelDataSpace::type(void) const
177{
178 return ("DataSpace");
179}
180
181
182/***********************************************************************//**
183 * @brief Signal if model is temporally constant
184 *
185 * @return True.
186 *
187 * Signals that the data space model is temporally constant.
188 ***************************************************************************/
189inline
191{
192 return (true);
193}
194
195#endif /* GSPIMODELDATASPACE_HPP */
Abstract data model base class interface definition.
Model parameter class interface definition.
INTEGRAL/SPI event bin container class definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Abstract interface for the event classes.
Definition GEvent.hpp:71
Sparse matrix class interface definition.
Abstract data model class.
const std::string & name(void) const
Return parameter name.
Definition GModel.hpp:265
Abstract observation base class.
Random number generator class.
Definition GRan.hpp:44
INTEGRAL/SPI event bin container class.
INTEGRAL/SPI instrument direction class.
INTEGRAL/SPI data space model.
void setup_evtclass(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names)
Setup detector indices and names for "evtclass" method.
virtual void setup(const GObservation &obs) const
Model setup hook.
int * m_map
Parameter map.
void split_pointing_indices(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names, const GTime &time, const std::string &reason) const
Split pointing indices and names at given time.
double get_date_time(const std::string &method) const
Get time scale from method string.
std::string m_method
Fitting method.
void setup_date(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names, const double &time)
Setup pointing indices and names for "date" method.
void init_members(void)
Initialise class members.
void copy_members(const GSPIModelDataSpace &model)
Copy class members.
void add_gedfail(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names)
Modify pointing indices and names for "gedfail" method.
int m_index
Index of model in event bins.
virtual GSPIModelDataSpace & operator=(const GSPIModelDataSpace &model)
Assignment operator.
void setup_detector_indices(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names)
Setup detector indices.
void setup_energy_indices(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names)
Setup energy indices.
int m_map_size
Size of parameter map.
virtual GSPIModelDataSpace * clone(void) const
Clone instance.
void add_gedanneal(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names)
Modify pointing indices and names for "gedanneal" method.
void setup_dete(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names)
Setup detector indices and names for "dete" method.
void free_members(void)
Delete class members.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print model information.
GSPIModelDataSpace(void)
Void constructor.
void setup_pointing_indices(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names)
Setup pointing indices.
void set_pointers(void)
Set pointers.
virtual double eval(const GEvent &event, const GObservation &obs, const bool &gradients=false) const
Evaluate function.
GSPIObservation * m_obs
SPI observation.
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual double npred(const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatially integrated data model.
virtual std::string type(void) const
Return model type.
virtual void clear(void)
Clear instance.
void setup_ebin(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names)
Setup energy indices and names for "ebin" method.
std::vector< GModelPar > m_parameters
Model parameters.
virtual void write(GXmlElement &xml) const
Write model into XML element.
virtual GSPIEventCube * mc(const GObservation &obs, GRan &ran) const
Return simulated list of events.
virtual std::string classname(void) const
Return class name.
virtual bool is_constant(void) const
Signal if model is temporally constant.
void setup_orbit(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names)
Setup pointing indices and names for "orbit" method.
void setup_point(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names)
Setup pointing indices and names for "point" method.
void setup_pars(GSPIEventCube *cube)
Setup parameters.
virtual ~GSPIModelDataSpace(void)
Destructor.
INTEGRAL/SPI observation class.
Time class.
Definition GTime.hpp:55
Vector class.
Definition GVector.hpp:46
XML element node class.