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