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-2024 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 double model_counts(const int& index) const;
92 int models(void) const;
93 const std::string& ptid(const int& ipt) const;
94 const GSPIInstDir& dir(const int& ipt, const int& idet) const;
95 const GSkyDir& spi_x(const int& ipt) const;
96 const GSkyDir& spi_z(const int& ipt) const;
97
98 // Event attribute methods
99 const double& event_size(const int& ievent) const;
100 const double& event_model(const int& ievent, const int& imodel) const;
101
102protected:
103 // Protected methods
104 void init_members(void);
105 void copy_members(const GSPIEventCube& cube);
106 void free_members(void);
107 void alloc_data(void);
108 void read_ebds(const GFitsTable* ebds);
109 void read_pnt(const GFitsTable* pnt, const GFitsTable* gti);
110 void read_gti(const GFitsTable* gti);
111 void read_dti(const GFitsTable* dti);
112 void read_dsp(const GFitsTable* dsp);
113 void read_models(const GFits& file);
114 virtual void set_energies(void);
115 virtual void set_times(void);
116 void init_bin(void);
117 void set_bin(const int& index);
118
119 // Protected members
120 GSPIEventBin m_bin; //!< Actual event bin
121 int m_num_pt; //!< Number of pointings
122 int m_num_det; //!< Number of detectors
123 int m_num_ebin; //!< Number of energy bins
124 int m_num_sky; //!< Number of sky models
125 int m_num_bgm; //!< Number of background models
126 int m_gti_size; //!< Size of GTI arrays
127 int m_dsp_size; //!< Size of DSP arrays
128 int m_model_size; //!< Size of model arrays
129 int* m_detid; //!< Detector ID of event cube ADD!!!!
130 double* m_ontime; //!< Ontime array
131 double* m_livetime; //!< Livetime array
132 double* m_counts; //!< Counts array
133 double* m_stat_err; //!< Statistical error array
134 double* m_models; //!< Models array
135 double* m_size; //!< Event bin size array
136 GSPIInstDir* m_dir; //!< Event direction array
137 GTime* m_time; //!< Time array
138 GEnergy* m_energy; //!< Energy array
139 GEnergy* m_ewidth; //!< Energy bin width array
140 GSkyDir* m_spix; //!< SPI X axis array
141 GSkyDir* m_spiz; //!< SPI Z axis array
142 std::string* m_ptid; //!< Pointing identifiers
143 std::vector<std::string> m_modnames; //!< Model names
144};
145
146
147/***********************************************************************//**
148 * @brief Return class name
149 *
150 * @return String containing the class name ("GSPIEventCube").
151 ***************************************************************************/
152inline
153std::string GSPIEventCube::classname(void) const
154{
155 return ("GSPIEventCube");
156}
157
158
159/***********************************************************************//**
160 * @brief Return event cube size
161 *
162 * @return Number of bins in event cube.
163 *
164 * Returns number of bins in event cube.
165 ***************************************************************************/
166inline
167int GSPIEventCube::size(void) const
168{
169 return (m_dsp_size);
170}
171
172
173/***********************************************************************//**
174 * @brief Return event cube dimension
175 *
176 * @return Number of dimensions in event cube.
177 *
178 * Returns the dimension of the event cube which is always 3.
179 ***************************************************************************/
180inline
181int GSPIEventCube::dim(void) const
182{
183 return (3);
184}
185
186
187/***********************************************************************//**
188 * @brief Set energies
189 *
190 * Sets energies.
191 ***************************************************************************/
192inline
194{
195 return;
196}
197
198
199/***********************************************************************//**
200 * @brief Set times
201 *
202 * Sets times.
203 ***************************************************************************/
204inline
206{
207 return;
208}
209
210
211/***********************************************************************//**
212 * @brief Return number of models
213 *
214 * @return Number of models.
215 *
216 * Returns the number of models in the event cube.
217 ***************************************************************************/
218inline
220{
221 return (m_num_sky+m_num_bgm);
222}
223
224#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.
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