GammaLib 2.0.0
Loading...
Searching...
No Matches
GCOMDri.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCOMDri.hpp - COMPTEL Data Space class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2017-2022 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 GCOMDri.hpp
23 * @brief COMPTEL Data Space class definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GCOMDRI_HPP
28#define GCOMDRI_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include "GBase.hpp"
33#include "GSkyMap.hpp"
34#include "GEbounds.hpp"
35#include "GGti.hpp"
36#include "GCOMSelection.hpp"
37
38/* __ Forward declarations _______________________________________________ */
39class GFilename;
40class GFits;
41class GFitsHDU;
42class GFitsImage;
43class GModel;
44class GModelSky;
45class GCOMOad;
46class GCOMTim;
47class GCOMStatus;
48class GCOMObservation;
49
50/* __ Constants __________________________________________________________ */
51namespace gammalib {
52 const std::string extname_dri = "DRI";
53}
54
55
56/***********************************************************************//**
57 * @class GCOMDri
58 *
59 * @brief COMPTEL Data Space class
60 ***************************************************************************/
61class GCOMDri : public GBase {
62
63public:
64 // Constructors and destructors
65 GCOMDri(void);
66 explicit GCOMDri(const GFilename& filename);
67 GCOMDri(const GSkyMap& map, const double& phimin = 0.0,
68 const double& phibin = 0.0,
69 const int& nphibin = 0);
70 GCOMDri(const GCOMDri& dri);
71 virtual ~GCOMDri(void);
72
73 // Operators
74 GCOMDri& operator=(const GCOMDri& dri);
75 double& operator[](const int& index);
76 const double& operator[](const int& index) const;
77
78 // Implemented pure virtual base class methods
79 virtual void clear(void);
80 virtual GCOMDri* clone(void) const;
81 virtual std::string classname(void) const;
82 virtual std::string print(const GChatter& chatter = NORMAL) const;
83
84 // Other methods
85 int size(void) const;
86 int nchi(void) const;
87 int npsi(void) const;
88 int nphibar(void) const;
89 const GSkyMap& map(void) const;
90 const std::string& name(void) const;
91 void name(const std::string& name);
92 const GEbounds& ebounds(void) const;
93 void ebounds(const GEbounds& ebounds);
94 const GGti& gti(void) const;
95 void gti(const GGti& gti);
96 const double& phimin(void) const;
97 const double& phibin(void) const;
98 const double& tof_correction(void) const;
99 void tof_correction(const double& tofcor);
100 const double& phase_correction(void) const;
101 void phase_correction(const double& phasecor);
102 const int& num_superpackets(void) const;
103 void num_superpackets(const int& number);
104 const int& num_used_superpackets(void) const;
105 void num_used_superpackets(const int& number);
106 const int& num_skipped_superpackets(void) const;
107 void num_skipped_superpackets(const int& number);
108 void compute_dre(const GCOMObservation& obs,
109 const GCOMSelection& select = GCOMSelection(),
110 const double& zetamin = 5.0);
111 void compute_drg(const GCOMObservation& obs,
112 const GCOMSelection& select = GCOMSelection(),
113 const double& zetamin = 5.0);
114 void compute_drx(const GCOMObservation& obs,
115 const GCOMSelection& select = GCOMSelection());
116 void compute_drm(const GCOMObservation& obs,
117 const GModel& model);
118 double cone_content(const GSkyDir& dir,
119 const double& armmin,
120 const double& armmax) const;
121 void load(const GFilename& filename);
122 void save(const GFilename& filename,
123 const bool& clobber = false) const;
124 void read(const GFitsImage& image);
125 void write(GFits& fits,
126 const std::string& extname = "") const;
127
128protected:
129 // Protected methods
130 void init_members(void);
131 void copy_members(const GCOMDri& dri);
132 void free_members(void);
133 void init_cube(void);
134 void init_statistics(void);
135 bool use_superpacket(const GCOMOad& oad,
136 const GCOMTim& tim,
137 const GCOMSelection& select);
138 void read_attributes(const GFitsHDU* hdu);
139 void write_attributes(GFitsHDU* hdu) const;
140 double compute_geometry(const int& tjd, const double& theta,
141 const double& phi,
142 const GCOMSelection& select,
143 const GCOMStatus& status) const;
144 double compute_surface(const double& x1, const double& y1, const double& r1,
145 const double& x2, const double& y2, const double& r2) const;
146 double compute_overlap(const double& x1, const double& y1, const double& r1,
147 const double& x2, const double& y2, const double& r2,
148 const double& x3, const double& y3, const double& r3) const;
149 void compute_tof_correction(void);
150
151 // Protected members
152 std::string m_name; //!< Data cube name
153 GSkyMap m_dri; //!< Data cube
154 GEbounds m_ebounds; //!< Energy boundaries of data cube
155 GGti m_gti; //!< Good Time Intervals of data cube
156 double m_phimin; //!< Phibar minimum (deg)
157 double m_phibin; //!< Phibar binsize (deg)
158 double m_tofcor; //!< ToF correction
159 double m_phasecor; //!< Pulsar phase correction
160
161 // Computation statistics
162 GTime m_tstart; //!< Selection start time
163 GTime m_tstop; //!< Selection stop time
164 int m_num_superpackets; //!< Number of superpackets
165 int m_num_used_superpackets; //!< Number of used superpackets
166 int m_num_skipped_superpackets; //!< Number of skipped superpackets
167
168 // Selection parameters
169 bool m_has_selection; //!< Signal that selection was applied
170 GCOMSelection m_selection; //!< Selection parameters
171 double m_zetamin; //!< Minimum zeta angle
172};
173
174
175/***********************************************************************//**
176 * @brief Return class name
177 *
178 * @return String containing the class name ("GCOMDri").
179 ***************************************************************************/
180inline
181std::string GCOMDri::classname(void) const
182{
183 return ("GCOMDri");
184}
185
186
187/***********************************************************************//**
188 * @brief DRI bin access operators
189 *
190 * @param[in] index DRI bin index [0,...,size()-1].
191 * @return Reference to DRI bin.
192 ***************************************************************************/
193inline
194double& GCOMDri::operator[](const int& index)
195{
196 return (const_cast<double&>((m_dri.pixels()[index])));
197}
198
199
200/***********************************************************************//**
201 * @brief DRI bin access operators (const version)
202 *
203 * @param[in] index DRI bin index [0,...,size()-1].
204 * @return Reference to DRI bin.
205 ***************************************************************************/
206inline
207const double& GCOMDri::operator[](const int& index) const
208{
209 return (m_dri.pixels()[index]);
210}
211
212
213/***********************************************************************//**
214 * @brief Return number of bins
215 *
216 * @return Number of bins.
217 ***************************************************************************/
218inline
219int GCOMDri::size(void) const
220{
221 return (m_dri.npix()*m_dri.nmaps());
222}
223
224
225/***********************************************************************//**
226 * @brief Return number of Chi bins
227 *
228 * @return Number of Chi bins.
229 ***************************************************************************/
230inline
231int GCOMDri::nchi(void) const
232{
233 return (m_dri.nx());
234}
235
236
237/***********************************************************************//**
238 * @brief Return number of Psi bins
239 *
240 * @return Number of Psi bins.
241 ***************************************************************************/
242inline
243int GCOMDri::npsi(void) const
244{
245 return (m_dri.ny());
246}
247
248
249/***********************************************************************//**
250 * @brief Return number of Phibar bins
251 *
252 * @return Number of Phibar bins.
253 ***************************************************************************/
254inline
255int GCOMDri::nphibar(void) const
256{
257 return (m_dri.nmaps());
258}
259
260
261/***********************************************************************//**
262 * @brief Return DRI sky map
263 *
264 * @return Sky map containing DRI data.
265 ***************************************************************************/
266inline
267const GSkyMap& GCOMDri::map(void) const
268{
269 return (m_dri);
270}
271
272
273/***********************************************************************//**
274 * @brief Return DRI cube name
275 *
276 * @return DRI cube name.
277 ***************************************************************************/
278inline
279const std::string& GCOMDri::name(void) const
280{
281 return (m_name);
282}
283
284
285/***********************************************************************//**
286 * @brief Set DRI cube name
287 *
288 * @param[in] name DRI cube name.
289 *
290 * Sets the name of the DRI cube.
291 ***************************************************************************/
292inline
293void GCOMDri::name(const std::string& name)
294{
295 m_name = name;
296 return;
297}
298
299
300/***********************************************************************//**
301 * @brief Return energy boundaries of DRI cube
302 *
303 * @return Energy boundaries of DRI cube.
304 ***************************************************************************/
305inline
306const GEbounds& GCOMDri::ebounds(void) const
307{
308 return (m_ebounds);
309}
310
311
312/***********************************************************************//**
313 * @brief Set energy boundaries of DRI cube
314 *
315 * @param[in] ebounds Energy boundaries of DRI cube.
316 *
317 * Sets energy boundaries of DRI cube
318 ***************************************************************************/
319inline
320void GCOMDri::ebounds(const GEbounds& ebounds)
321{
323 return;
324}
325
326
327/***********************************************************************//**
328 * @brief Return Good Time Intervals of DRI cube
329 *
330 * @return Good Time Intervals of DRI cube.
331 ***************************************************************************/
332inline
333const GGti& GCOMDri::gti(void) const
334{
335 return (m_gti);
336}
337
338
339/***********************************************************************//**
340 * @brief Set Good Time Intervals of DRI cube
341 *
342 * @param[in] gti Good Time Intervals of DRI data.
343 *
344 * Sets the Good Time Intervals of DRI cube.
345 ***************************************************************************/
346inline
347void GCOMDri::gti(const GGti& gti)
348{
349 m_gti = gti;
350 return;
351}
352
353
354/***********************************************************************//**
355 * @brief Return minimum Compton scatter angle of DRI cube
356 *
357 * @return Minimum Compton scatter angle of DRI cube (deg).
358 ***************************************************************************/
359inline
360const double& GCOMDri::phimin(void) const
361{
362 return (m_phimin);
363}
364
365
366/***********************************************************************//**
367 * @brief Return Compton scatter angle bin of DRI cube
368 *
369 * @return Compton scatter angle bin of DRI cube (deg).
370 ***************************************************************************/
371inline
372const double& GCOMDri::phibin(void) const
373{
374 return (m_phibin);
375}
376
377
378/***********************************************************************//**
379 * @brief Return ToF correction factor
380 *
381 * @return ToF correction factor.
382 *
383 * Returns the ToF correction factor that corrects for the event selection
384 * in a ToF window.
385 ***************************************************************************/
386inline
387const double& GCOMDri::tof_correction(void) const
388{
389 return (m_tofcor);
390}
391
392
393/***********************************************************************//**
394 * @brief Set ToF correction factor
395 *
396 * @param[in] tofcor ToF correction factor.
397 *
398 * Set the ToF correction factor that corrects for the event selection
399 * in a ToF window.
400 ***************************************************************************/
401inline
402void GCOMDri::tof_correction(const double& tofcor)
403{
404 m_tofcor = tofcor;
405 return;
406}
407
408
409/***********************************************************************//**
410 * @brief Return pulsar phase correction factor
411 *
412 * @return Pulsar phase correction factor.
413 *
414 * Returns the pulsar phase correction factor that corrects for the phase
415 * selection for pulsar analysis.
416 ***************************************************************************/
417inline
418const double& GCOMDri::phase_correction(void) const
419{
420 return (m_phasecor);
421}
422
423
424/***********************************************************************//**
425 * @brief Set pulsar phase correction factor
426 *
427 * @param[in] phasecor Pulsar phase correction factor.
428 *
429 * Set the pulsar phase correction factor that corrects for the phase
430 * selection for pulsar analysis.
431 ***************************************************************************/
432inline
433void GCOMDri::phase_correction(const double& phasecor)
434{
435 m_phasecor = phasecor;
436 return;
437}
438
439
440/***********************************************************************//**
441 * @brief Return number of superpackets read for DRI
442 *
443 * @return Number of superpackets read for DRI.
444 *
445 * Returns the number of superpackets read for DRI.
446 ***************************************************************************/
447inline
448const int& GCOMDri::num_superpackets(void) const
449{
450 return (m_num_superpackets);
451}
452
453
454/***********************************************************************//**
455 * @brief Set number of superpackets read for DRI
456 *
457 * @param[in] number Number of superpackets read for DRI.
458 *
459 * Set the number of superpackets read for DRI.
460 ***************************************************************************/
461inline
462void GCOMDri::num_superpackets(const int& number)
463{
464 m_num_superpackets = number;
465 return;
466}
467
468
469/***********************************************************************//**
470 * @brief Return number of superpackets used for DRI
471 *
472 * @return Number of superpackets used for DRI.
473 *
474 * Returns the number of superpackets used for DRI.
475 ***************************************************************************/
476inline
477const int& GCOMDri::num_used_superpackets(void) const
478{
480}
481
482
483/***********************************************************************//**
484 * @brief Set number of superpackets used for DRI
485 *
486 * @param[in] number Number of superpackets used for DRI.
487 *
488 * Set the number of superpackets used for DRI.
489 ***************************************************************************/
490inline
491void GCOMDri::num_used_superpackets(const int& number)
492{
494 return;
495}
496
497
498/***********************************************************************//**
499 * @brief Return number of superpackets skipped for DRI
500 *
501 * @return Number of superpackets skipped for DRI.
502 *
503 * Returns the number of superpackets skipped for DRI.
504 ***************************************************************************/
505inline
507{
509}
510
511
512/***********************************************************************//**
513 * @brief Set number of superpackets skipped for DRI
514 *
515 * @param[in] number Number of superpackets skipped for DRI.
516 *
517 * Set the number of superpackets skipped for DRI.
518 ***************************************************************************/
519inline
521{
523 return;
524}
525
526#endif /* GCOMDRI_HPP */
Definition of interface for all GammaLib classes.
const double r1
Definition GCOMDri.cpp:73
COMPTEL selection set class definition.
Energy boundaries class interface definition.
Good time interval class interface definition.
Sky map class definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
Interface class for all GammaLib classes.
Definition GBase.hpp:52
COMPTEL Data Space class.
Definition GCOMDri.hpp:61
void init_statistics(void)
Initialise computation statistics.
Definition GCOMDri.cpp:1169
const std::string & name(void) const
Return DRI cube name.
Definition GCOMDri.hpp:279
const int & num_skipped_superpackets(void) const
Return number of superpackets skipped for DRI.
Definition GCOMDri.hpp:506
const GEbounds & ebounds(void) const
Return energy boundaries of DRI cube.
Definition GCOMDri.hpp:306
virtual void clear(void)
Clear COMPTEL Data Space.
Definition GCOMDri.cpp:228
GCOMDri & operator=(const GCOMDri &dri)
Assignment operator.
Definition GCOMDri.cpp:198
const int & num_used_superpackets(void) const
Return number of superpackets used for DRI.
Definition GCOMDri.hpp:477
int m_num_skipped_superpackets
Number of skipped superpackets.
Definition GCOMDri.hpp:166
void save(const GFilename &filename, const bool &clobber=false) const
Save COMPTEL Data Space into DRI FITS file.
Definition GCOMDri.cpp:918
double compute_overlap(const double &x1, const double &y1, const double &r1, const double &x2, const double &y2, const double &r2, const double &x3, const double &y3, const double &r3) const
Compute overlap between three circles.
Definition GCOMDri.cpp:1707
const double & phase_correction(void) const
Return pulsar phase correction factor.
Definition GCOMDri.hpp:418
virtual GCOMDri * clone(void) const
Clone COMPTEL Data Space.
Definition GCOMDri.cpp:246
int nchi(void) const
Return number of Chi bins.
Definition GCOMDri.hpp:231
void compute_drm(const GCOMObservation &obs, const GModel &model)
Compute DRM model.
Definition GCOMDri.cpp:810
double m_phibin
Phibar binsize (deg)
Definition GCOMDri.hpp:157
double m_phasecor
Pulsar phase correction.
Definition GCOMDri.hpp:159
const double & tof_correction(void) const
Return ToF correction factor.
Definition GCOMDri.hpp:387
void write_attributes(GFitsHDU *hdu) const
Write DRI attributes into FITS HDU.
Definition GCOMDri.cpp:1356
const GGti & gti(void) const
Return Good Time Intervals of DRI cube.
Definition GCOMDri.hpp:333
GTime m_tstart
Selection start time.
Definition GCOMDri.hpp:162
virtual ~GCOMDri(void)
Destructor.
Definition GCOMDri.cpp:176
double compute_surface(const double &x1, const double &y1, const double &r1, const double &x2, const double &y2, const double &r2) const
Compute surface of overlap between two circles.
Definition GCOMDri.cpp:1633
void free_members(void)
Delete class members.
Definition GCOMDri.cpp:1142
GGti m_gti
Good Time Intervals of data cube.
Definition GCOMDri.hpp:155
int m_num_used_superpackets
Number of used superpackets.
Definition GCOMDri.hpp:165
void compute_drx(const GCOMObservation &obs, const GCOMSelection &select=GCOMSelection())
Compute DRX exposure map.
Definition GCOMDri.cpp:703
void compute_drg(const GCOMObservation &obs, const GCOMSelection &select=GCOMSelection(), const double &zetamin=5.0)
Compute geometry cube.
Definition GCOMDri.cpp:558
void compute_tof_correction(void)
Compute ToF correction.
Definition GCOMDri.cpp:1823
double compute_geometry(const int &tjd, const double &theta, const double &phi, const GCOMSelection &select, const GCOMStatus &status) const
Compute DRG geometry factor.
Definition GCOMDri.cpp:1466
void init_members(void)
Initialise class members.
Definition GCOMDri.cpp:1080
const double & phibin(void) const
Return Compton scatter angle bin of DRI cube.
Definition GCOMDri.hpp:372
void init_cube(void)
Initialise DRI cube.
Definition GCOMDri.cpp:1154
void load(const GFilename &filename)
Load COMPTEL Data Space from DRI FITS file.
Definition GCOMDri.cpp:893
double & operator[](const int &index)
DRI bin access operators.
Definition GCOMDri.hpp:194
const GSkyMap & map(void) const
Return DRI sky map.
Definition GCOMDri.hpp:267
double m_zetamin
Minimum zeta angle.
Definition GCOMDri.hpp:171
const int & num_superpackets(void) const
Return number of superpackets read for DRI.
Definition GCOMDri.hpp:448
const double & phimin(void) const
Return minimum Compton scatter angle of DRI cube.
Definition GCOMDri.hpp:360
GCOMDri(void)
Void constructor.
Definition GCOMDri.cpp:89
virtual std::string print(const GChatter &chatter=NORMAL) const
Print COMPTEL Data Space.
Definition GCOMDri.cpp:988
GSkyMap m_dri
Data cube.
Definition GCOMDri.hpp:153
GCOMSelection m_selection
Selection parameters.
Definition GCOMDri.hpp:170
GEbounds m_ebounds
Energy boundaries of data cube.
Definition GCOMDri.hpp:154
int npsi(void) const
Return number of Psi bins.
Definition GCOMDri.hpp:243
double m_phimin
Phibar minimum (deg)
Definition GCOMDri.hpp:156
void compute_dre(const GCOMObservation &obs, const GCOMSelection &select=GCOMSelection(), const double &zetamin=5.0)
Compute event cube.
Definition GCOMDri.cpp:266
std::string m_name
Data cube name.
Definition GCOMDri.hpp:152
GTime m_tstop
Selection stop time.
Definition GCOMDri.hpp:163
int size(void) const
Return number of bins.
Definition GCOMDri.hpp:219
int m_num_superpackets
Number of superpackets.
Definition GCOMDri.hpp:164
bool use_superpacket(const GCOMOad &oad, const GCOMTim &tim, const GCOMSelection &select)
Check if superpacket should be used.
Definition GCOMDri.cpp:1199
bool m_has_selection
Signal that selection was applied.
Definition GCOMDri.hpp:169
void read_attributes(const GFitsHDU *hdu)
Read DRI attributes from FITS HDU.
Definition GCOMDri.cpp:1266
void write(GFits &fits, const std::string &extname="") const
Write COMPTEL Data Space into FITS image.
Definition GCOMDri.cpp:967
double m_tofcor
ToF correction.
Definition GCOMDri.hpp:158
int nphibar(void) const
Return number of Phibar bins.
Definition GCOMDri.hpp:255
virtual std::string classname(void) const
Return class name.
Definition GCOMDri.hpp:181
void read(const GFitsImage &image)
Read COMPTEL Data Space from DRI FITS image.
Definition GCOMDri.cpp:942
void copy_members(const GCOMDri &dri)
Copy class members.
Definition GCOMDri.cpp:1110
double cone_content(const GSkyDir &dir, const double &armmin, const double &armmax) const
Compute content in cone.
Definition GCOMDri.cpp:846
COMPTEL Orbit Aspect Data class.
Definition GCOMOad.hpp:49
Interface class for COMPTEL observations.
COMPTEL selection set class.
COMPTEL instrument status class.
COMPTEL Good Time Intervals class.
Definition GCOMTim.hpp:50
Energy boundaries container class.
Definition GEbounds.hpp:60
Filename class.
Definition GFilename.hpp:62
Abstract FITS extension base class.
Definition GFitsHDU.hpp:51
Abstract FITS image base class.
FITS file class.
Definition GFits.hpp:63
Good Time Interval class.
Definition GGti.hpp:62
Sky model class.
Abstract model class.
Definition GModel.hpp:100
Sky direction class.
Definition GSkyDir.hpp:62
Sky map class.
Definition GSkyMap.hpp:89
const int & nmaps(void) const
Returns number of maps.
Definition GSkyMap.hpp:389
const int & nx(void) const
Returns number of pixels in x coordinate.
Definition GSkyMap.hpp:361
const int & npix(void) const
Returns number of pixels.
Definition GSkyMap.hpp:345
const int & ny(void) const
Returns number of pixels in y coordinate.
Definition GSkyMap.hpp:377
const double * pixels(void) const
Returns pointer to pixel data.
Definition GSkyMap.hpp:475
Time class.
Definition GTime.hpp:55
const std::string extname_dri
Definition GCOMDri.hpp:52