GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 _______________________________________________ */
38 class GEnergy;
39 class GTime;
40 class GSPIInstDir;
41 class GEvent;
42 class GObservation;
43 class GXmlElement;
44 class 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 
59 public:
60  // Constructors and destructors
61  GSPIModelDataSpace(void);
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 protected:
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  ***************************************************************************/
154 inline
155 std::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  ***************************************************************************/
168 inline
169 std::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  ***************************************************************************/
182 inline
184 {
185  return (true);
186 }
187 
188 #endif /* GSPIMODELDATASPACE_HPP */
void setup_orbit(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names)
Setup pointing indices and names for &quot;orbit&quot; method.
int * m_map
Parameter map.
int m_map_size
Size of 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.
void setup_pointing_indices(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names)
Setup pointing indices.
virtual GSPIModelDataSpace * clone(void) const
Clone instance.
void setup_point(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names)
Setup pointing indices and names for &quot;point&quot; method.
std::vector< GModelPar > m_parameters
Model parameters.
Abstract interface for the event classes.
Definition: GEvent.hpp:71
XML element node class.
Definition: GXmlElement.hpp:48
virtual bool is_constant(void) const
Signal if model is temporally constant.
void setup_energy_indices(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names)
Setup energy indices.
Random number generator class.
Definition: GRan.hpp:44
INTEGRAL/SPI event bin container class definition.
Time class.
Definition: GTime.hpp:55
std::string m_method
Fitting method.
void add_gedanneal(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names)
Modify pointing indices and names for &quot;gedanneal&quot; method.
virtual GSPIEventCube * mc(const GObservation &obs, GRan &ran) const
Return simulated list of events.
INTEGRAL/SPI instrument direction class.
Definition: GSPIInstDir.hpp:52
virtual void write(GXmlElement &xml) const
Write model into XML element.
virtual void read(const GXmlElement &xml)
Read model from XML element.
Model parameter class interface definition.
GSPIObservation * m_obs
SPI observation.
INTEGRAL/SPI event bin container class.
void add_gedfail(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names)
Modify pointing indices and names for &quot;gedfail&quot; method.
INTEGRAL/SPI data space model.
const std::string & name(void) const
Return parameter name.
Definition: GModel.hpp:261
virtual GSPIModelDataSpace & operator=(const GSPIModelDataSpace &model)
Assignment operator.
Abstract data model base class interface definition.
virtual std::string type(void) const
Return model type.
GSPIModelDataSpace(void)
Void constructor.
Abstract data model class.
Definition: GModelData.hpp:55
double get_date_time(const std::string &method) const
Get time scale from method string.
GChatter
Definition: GTypemaps.hpp:33
virtual double npred(const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatially integrated data model.
void copy_members(const GSPIModelDataSpace &model)
Copy class members.
Abstract observation base class.
void free_members(void)
Delete class members.
void init_members(void)
Initialise class members.
INTEGRAL/SPI observation class.
void setup_model(const GObservation &obs) const
Setup model.
int m_index
Index of model in event bins.
virtual ~GSPIModelDataSpace(void)
Destructor.
void setup_ebin(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names)
Setup energy indices and names for &quot;ebin&quot; method.
virtual double eval(const GEvent &event, const GObservation &obs, const bool &gradients=false) const
Evaluate function.
void setup_date(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names, const double &time)
Setup pointing indices and names for &quot;date&quot; method.
virtual std::string classname(void) const
Return class name.
void setup_evtclass(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names)
Setup detector indices and names for &quot;evtclass&quot; method.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print model information.
void setup_pars(GSPIEventCube *cube)
Setup parameters.
void setup_dete(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names)
Setup detector indices and names for &quot;dete&quot; method.
void set_pointers(void)
Set pointers.
virtual void clear(void)
Clear instance.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
void setup_detector_indices(GSPIEventCube *cube, std::vector< int > *indices, std::vector< std::string > *names)
Setup detector indices.