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