GammaLib 2.0.0
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 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
90protected:
91 // Protected methods
92 void init_members(void);
93 void copy_members(const GSPIModelDataSpace& model);
94 void free_members(void);
95 void set_pointers(void);
96 void setup_model(const GObservation& obs) const;
97 void setup_pars(GSPIEventCube* cube);
99 std::vector<int>* indices,
100 std::vector<std::string>* names);
102 std::vector<int>* indices,
103 std::vector<std::string>* names);
105 std::vector<int>* indices,
106 std::vector<std::string>* names);
107 void setup_point(GSPIEventCube* cube,
108 std::vector<int>* indices,
109 std::vector<std::string>* names);
110 void setup_orbit(GSPIEventCube* cube,
111 std::vector<int>* indices,
112 std::vector<std::string>* names);
113 void setup_date(GSPIEventCube* cube,
114 std::vector<int>* indices,
115 std::vector<std::string>* names,
116 const double& time);
117 void add_gedfail(GSPIEventCube* cube,
118 std::vector<int>* indices,
119 std::vector<std::string>* names);
120 void add_gedanneal(GSPIEventCube* cube,
121 std::vector<int>* indices,
122 std::vector<std::string>* names);
123 void setup_dete(GSPIEventCube* cube,
124 std::vector<int>* indices,
125 std::vector<std::string>* names);
126 void setup_evtclass(GSPIEventCube* cube,
127 std::vector<int>* indices,
128 std::vector<std::string>* names);
129 void setup_ebin(GSPIEventCube* cube,
130 std::vector<int>* indices,
131 std::vector<std::string>* names);
132 double get_date_time(const std::string& method) const;
134 std::vector<int>* indices,
135 std::vector<std::string>* names,
136 const GTime& time,
137 const std::string& reason) const;
138
139 // Protected data members
140 mutable GSPIObservation* m_obs; //!< SPI observation
141 std::string m_method; //!< Fitting method
142 int m_index; //!< Index of model in event bins
143 int m_map_size; //!< Size of parameter map
144 int* m_map; //!< Parameter map
145 std::vector<GModelPar> m_parameters; //!< Model parameters
146};
147
148
149/***********************************************************************//**
150 * @brief Return class name
151 *
152 * @return String containing the class name ("GSPIModelDataSpace").
153 ***************************************************************************/
154inline
155std::string GSPIModelDataSpace::classname(void) const
156{
157 return ("GSPIModelDataSpace");
158}
159
160
161/***********************************************************************//**
162 * @brief Return model type
163 *
164 * @return Model type.
165 *
166 * Returns "DataSpace" as model type.
167 ***************************************************************************/
168inline
169std::string GSPIModelDataSpace::type(void) const
170{
171 return ("DataSpace");
172}
173
174
175/***********************************************************************//**
176 * @brief Signal if model is temporally constant
177 *
178 * @return True.
179 *
180 * Signals that the data space model is temporally constant.
181 ***************************************************************************/
182inline
184{
185 return (true);
186}
187
188#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
Abstract data model class.
const std::string & name(void) const
Return parameter name.
Definition GModel.hpp:261
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.
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.
void setup_model(const GObservation &obs) const
Setup model.
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
XML element node class.