GammaLib 2.1.0.dev
Loading...
Searching...
No Matches
GSPIEventCube.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GSPIEventCube.hpp - INTEGRAL/SPI event cube class *
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 GSPIEventCube.hpp
23 * @brief INTEGRAL/SPI event bin container class definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GSPIEVENTCUBE_HPP
28#define GSPIEVENTCUBE_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include <vector>
33#include "GEventCube.hpp"
34#include "GSPIEventBin.hpp"
35
36/* __ Forward declarations _______________________________________________ */
37class GFilename;
38class GEbounds;
39class GGti;
40class GFits;
41class GSkyDir;
42class GEnergy;
43class GTime;
44class GSPIInstDir;
45
46/* __ Constants __________________________________________________________ */
47
48
49/***********************************************************************//**
50 * @class GSPIEventCube
51 *
52 * @brief INTEGRAL/SPI event bin container class
53 *
54 * This class is a container class for INTEGRAL/SPI event bins.
55 ***************************************************************************/
56class GSPIEventCube : public GEventCube {
57
58 // Friend classes
59 friend class GSPIResponse;
60
61public:
62 // Constructors and destructors
63 GSPIEventCube(void);
64 explicit GSPIEventCube(const GFilename& filename);
65 GSPIEventCube(const GSPIEventCube& cube);
66 virtual ~GSPIEventCube(void);
67
68 // Operators
69 virtual GSPIEventCube& operator=(const GSPIEventCube& cube);
70 virtual GSPIEventBin* operator[](const int& index);
71 virtual const GSPIEventBin* operator[](const int& index) const;
72
73 // Implemented pure virtual base class methods
74 virtual void clear(void);
75 virtual GSPIEventCube* clone(void) const;
76 virtual std::string classname(void) const;
77 virtual int size(void) const;
78 virtual int dim(void) const;
79 virtual int naxis(const int& axis) const;
80 virtual void load(const GFilename& filename);
81 virtual void save(const GFilename& filename,
82 const bool& clobber = false) const;
83 virtual void read(const GFits& file);
84 virtual void write(GFits& file) const;
85 virtual double number(void) const;
86 virtual std::string print(const GChatter& chatter = NORMAL) const;
87
88 // Other methods
89 double ontime(void) const;
90 double livetime(void) const;
91 int models(void) const;
92 double model_counts(const int& index) const;
93 const std::string& model_name(const int& index) const;
94 const std::string& ptid(const int& ipt) const;
95 const GSPIInstDir& dir(const int& ipt, const int& idet) const;
96 const GSkyDir& spi_x(const int& ipt) const;
97 const GSkyDir& spi_z(const int& ipt) const;
98
99 // Event attribute methods
100 const double& event_size(const int& ievent) const;
101 const double& event_model(const int& ievent, const int& imodel) const;
102
103protected:
104 // Protected methods
105 void init_members(void);
106 void copy_members(const GSPIEventCube& cube);
107 void free_members(void);
108 void alloc_data(void);
109 void read_ebds(const GFitsTable* ebds);
110 void read_pnt(const GFitsTable* pnt, const GFitsTable* gti);
111 void read_gti(const GFitsTable* gti);
112 void read_dti(const GFitsTable* dti);
113 void read_dsp(const GFitsTable* dsp);
114 void read_models(const GFits& file);
115 virtual void set_energies(void);
116 virtual void set_times(void);
117 void init_bin(void);
118 void set_bin(const int& index);
119
120 // Protected members
121 GSPIEventBin m_bin; //!< Actual event bin
122 int m_num_pt; //!< Number of pointings
123 int m_num_det; //!< Number of detectors
124 int m_num_ebin; //!< Number of energy bins
125 int m_num_sky; //!< Number of sky models
126 int m_num_bgm; //!< Number of background models
127 int m_gti_size; //!< Size of GTI arrays
128 int m_dsp_size; //!< Size of DSP arrays
129 int m_model_size; //!< Size of model arrays
130 int* m_detid; //!< Detector ID of event cube ADD!!!!
131 double* m_ontime; //!< Ontime array
132 double* m_livetime; //!< Livetime array
133 double* m_counts; //!< Counts array
134 double* m_stat_err; //!< Statistical error array
135 double* m_models; //!< Models array
136 double* m_size; //!< Event bin size array
137 GSPIInstDir* m_dir; //!< Event direction array
138 GTime* m_time; //!< Time array
139 GEnergy* m_energy; //!< Energy array
140 GEnergy* m_ewidth; //!< Energy bin width array
141 GSkyDir* m_spix; //!< SPI X axis array
142 GSkyDir* m_spiz; //!< SPI Z axis array
143 std::string* m_ptid; //!< Pointing identifiers
144 std::vector<std::string> m_modnames; //!< Model names
145};
146
147
148/***********************************************************************//**
149 * @brief Return class name
150 *
151 * @return String containing the class name ("GSPIEventCube").
152 ***************************************************************************/
153inline
154std::string GSPIEventCube::classname(void) const
155{
156 return ("GSPIEventCube");
157}
158
159
160/***********************************************************************//**
161 * @brief Return event cube size
162 *
163 * @return Number of bins in event cube.
164 *
165 * Returns number of bins in event cube.
166 ***************************************************************************/
167inline
168int GSPIEventCube::size(void) const
169{
170 return (m_dsp_size);
171}
172
173
174/***********************************************************************//**
175 * @brief Return event cube dimension
176 *
177 * @return Number of dimensions in event cube.
178 *
179 * Returns the dimension of the event cube which is always 3.
180 ***************************************************************************/
181inline
182int GSPIEventCube::dim(void) const
183{
184 return (3);
185}
186
187
188/***********************************************************************//**
189 * @brief Set energies
190 *
191 * Sets energies.
192 ***************************************************************************/
193inline
195{
196 return;
197}
198
199
200/***********************************************************************//**
201 * @brief Set times
202 *
203 * Sets times.
204 ***************************************************************************/
205inline
207{
208 return;
209}
210
211
212/***********************************************************************//**
213 * @brief Return number of models
214 *
215 * @return Number of models.
216 *
217 * Returns the number of models in the event cube.
218 ***************************************************************************/
219inline
221{
222 return (m_num_sky+m_num_bgm);
223}
224
225#endif /* GSPIEVENTCUBE_HPP */
Abstract event bin container class interface definition.
INTEGRAL/SPI event bin class definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
Energy boundaries container class.
Definition GEbounds.hpp:60
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Abstract event bin container class.
const GGti & gti(void) const
Return Good Time Intervals.
Definition GEvents.hpp:134
Filename class.
Definition GFilename.hpp:62
Abstract interface for FITS table.
FITS file class.
Definition GFits.hpp:63
Good Time Interval class.
Definition GGti.hpp:63
INTEGRAL/SPI event bin class.
INTEGRAL/SPI event bin container class.
void copy_members(const GSPIEventCube &cube)
Copy class members.
virtual void clear(void)
Clear INTEGRAL/SPI event cube.
void init_members(void)
Initialise class members.
void read_pnt(const GFitsTable *pnt, const GFitsTable *gti)
Read pointing information.
GSkyDir * m_spiz
SPI Z axis array.
GSkyDir * m_spix
SPI X axis array.
int m_model_size
Size of model arrays.
const GSPIInstDir & dir(const int &ipt, const int &idet) const
Return instrument direction.
const double & event_model(const int &ievent, const int &imodel) const
Return value of model for event bin.
const GSkyDir & spi_z(const int &ipt) const
Return SPI Z direction.
const double & event_size(const int &ievent) const
Return size of event bin.
double * m_livetime
Livetime array.
int models(void) const
Return number of models.
virtual double number(void) const
Return number of events in cube.
GSPIEventBin m_bin
Actual event bin.
void read_models(const GFits &file)
Read models from INTEGRAL/SPI Observation Group.
GTime * m_time
Time array.
virtual ~GSPIEventCube(void)
Destructor.
void read_dti(const GFitsTable *dti)
Read data from INTEGRAL/SPI "SPI.-OBS.-DTI" extension.
virtual int dim(void) const
Return event cube dimension.
void read_dsp(const GFitsTable *dsp)
Read data from INTEGRAL/SPI "SPI.-OBS.-DSP" extension.
virtual void save(const GFilename &filename, const bool &clobber=false) const
Save INTEGRAL/SPI event cube into FITS file.
virtual int naxis(const int &axis) const
Return number of bins in axis.
void free_members(void)
Delete class members.
double livetime(void) const
Return total livetime.
virtual int size(void) const
Return event cube size.
void init_bin(void)
Initialise event bin.
GEnergy * m_energy
Energy array.
int m_num_pt
Number of pointings.
std::vector< std::string > m_modnames
Model names.
const std::string & ptid(const int &ipt) const
Return pointing identifier.
virtual void set_energies(void)
Set energies.
void set_bin(const int &index)
Set event bin.
virtual GSPIEventCube & operator=(const GSPIEventCube &cube)
Assignment operator.
double ontime(void) const
Return total ontime.
virtual void load(const GFilename &filename)
Load INTEGRAL/SPI event cube from Observation Group.
virtual void write(GFits &file) const
Write INTEGRAL/SPI event cube into FITS file.
const std::string & model_name(const int &index) const
Return model name.
double * m_size
Event bin size array.
GSPIInstDir * m_dir
Event direction array.
void read_gti(const GFitsTable *gti)
Read data from INTEGRAL/SPI "SPI.-OBS.-GTI" extension.
virtual std::string classname(void) const
Return class name.
void alloc_data(void)
Allocate data.
int m_gti_size
Size of GTI arrays.
int m_num_sky
Number of sky models.
int * m_detid
Detector ID of event cube ADD!!!!
int m_num_ebin
Number of energy bins.
virtual GSPIEventBin * operator[](const int &index)
Event bin access operator.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print INTEGRAL/SPI event cube information.
int m_num_det
Number of detectors.
int m_num_bgm
Number of background models.
double * m_counts
Counts array.
double * m_stat_err
Statistical error array.
double * m_ontime
Ontime array.
virtual void set_times(void)
Set times.
std::string * m_ptid
Pointing identifiers.
GSPIEventCube(void)
Void constructor.
virtual GSPIEventCube * clone(void) const
Clone event cube.
int m_dsp_size
Size of DSP arrays.
virtual void read(const GFits &file)
Read INTEGRAL/SPI event cube from Observation Group FITS file.
GEnergy * m_ewidth
Energy bin width array.
double * m_models
Models array.
double model_counts(const int &index) const
Return number of events in model.
const GSkyDir & spi_x(const int &ipt) const
Return SPI X direction (pointing direction)
void read_ebds(const GFitsTable *ebds)
Read data from INTEGRAL/SPI "SPI.-EBDS-SET" extension.
INTEGRAL/SPI instrument direction class.
INTEGRAL/SPI instrument response function class.
Sky direction class.
Definition GSkyDir.hpp:62
Time class.
Definition GTime.hpp:55