GammaLib 2.1.0.dev
Loading...
Searching...
No Matches
GCOMEventCube.cpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCOMEventCube.cpp - COMPTEL event bin container class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2012-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 GCOMEventCube.cpp
23 * @brief COMPTEL event bin container class implementation
24 * @author Juergen Knoedlseder
25 */
26
27/* __ Includes ___________________________________________________________ */
28#ifdef HAVE_CONFIG_H
29#include <config.h>
30#endif
31#include "GException.hpp"
32#include "GTools.hpp"
33#include "GFits.hpp"
34#include "GFilename.hpp"
35#include "GCOMTools.hpp"
36#include "GCOMSupport.hpp"
37#include "GCOMEventCube.hpp"
38
39/* __ Method name definitions ____________________________________________ */
40#define G_NAXIS "GCOMEventCube::naxis(int)"
41#define G_SET_SCATTER_DIRECTIONS "GCOMEventCube::set_scatter_directions()"
42#define G_SET_ENERGIES "GCOMEventCube::set_energies()"
43#define G_SET_TIMES "GCOMEventCube::set_times()"
44#define G_SET_BIN "GCOMEventCube::set_bin(int&)"
45
46/* __ Macros _____________________________________________________________ */
47
48/* __ Coding definitions _________________________________________________ */
49
50/* __ Debug definitions __________________________________________________ */
51
52
53
54/*==========================================================================
55 = =
56 = Constructors/destructors =
57 = =
58 ==========================================================================*/
59
60/***********************************************************************//**
61 * @brief Void constructor
62 *
63 * Constructs an empty event cube.
64 ***************************************************************************/
66{
67 // Initialise members
69
70 // Return
71 return;
72}
73
74
75/***********************************************************************//**
76 * @brief Load constructor
77 *
78 * @param[in] filename DRE FITS filename.
79 *
80 * Constructs an event cube from a DRE FITS file.
81 ***************************************************************************/
83{
84 // Initialise members
86
87 // Load event cube
88 load(filename);
89
90 // Return
91 return;
92}
93
94
95/***********************************************************************//**
96 * @brief DRE constructor
97 *
98 * @param[in] dre DRE event cube.
99 *
100 * Constructs an event cube from a DRE event cube.
101 ***************************************************************************/
103{
104 // Initialise members
105 init_members();
106
107 // Set DRE event cube
108 m_dri = dre;
109
110 // Initialise event cube
111 init_cube();
112
113 // Return
114 return;
115}
116
117
118/***********************************************************************//**
119 * @brief Copy constructor
120 *
121 * @param[in] cube Event cube.
122 ***************************************************************************/
124{
125 // Initialise members
126 init_members();
127
128 // Copy members
129 copy_members(cube);
130
131 // Return
132 return;
133}
134
135
136/***********************************************************************//**
137 * @brief Destructor
138 ***************************************************************************/
140{
141 // Free members
142 free_members();
143
144 // Return
145 return;
146}
147
148
149/*==========================================================================
150 = =
151 = Operators =
152 = =
153 ==========================================================================*/
154
155/***********************************************************************//**
156 * @brief Assignment operator
157 *
158 * @param[in] cube Event cube.
159 * @return Event cube.
160 ***************************************************************************/
162{
163 // Execute only if object is not identical
164 if (this != &cube) {
165
166 // Copy base class members
167 this->GEventCube::operator=(cube);
168
169 // Free members
170 free_members();
171
172 // Initialise members
173 init_members();
174
175 // Copy members
176 copy_members(cube);
177
178 } // endif: object was not identical
179
180 // Return this object
181 return *this;
182}
183
184
185/***********************************************************************//**
186 * @brief Event bin access operator
187 *
188 * @param[in] index Event index [0,...,size()-1].
189 * @return Pointer to event bin.
190 *
191 * Returns pointer to an event bin. Note that the returned pointer is in
192 * fact always the same, but the method sets the pointers within the
193 * event bin so that they point to the appropriate information.
194 ***************************************************************************/
196{
197 // Set event bin
198 set_bin(index);
199
200 // Return pointer
201 return (&m_bin);
202}
203
204
205/***********************************************************************//**
206 * @brief Event bin access operator (const version)
207 *
208 * @param[in] index Event index [0,...,size()-1].
209 * @return Const pointer to event bin.
210 *
211 * Returns pointer to an event bin. Note that the returned pointer is in
212 * fact always the same, but the method sets the pointers within the
213 * event bin so that they point to the appropriate information.
214 ***************************************************************************/
215const GCOMEventBin* GCOMEventCube::operator[](const int& index) const
216{
217 // Set event bin (circumvent const correctness)
218 const_cast<GCOMEventCube*>(this)->set_bin(index);
219
220 // Return pointer
221 return (&m_bin);
222}
223
224
225/*==========================================================================
226 = =
227 = Public methods =
228 = =
229 ==========================================================================*/
230
231/***********************************************************************//**
232 * @brief Clear instance
233 *
234 * This method properly resets the object to an initial state.
235 ***************************************************************************/
237{
238 // Free class members (base and derived classes, derived class first)
239 free_members();
241 this->GEvents::free_members();
242
243 // Initialise members
244 this->GEvents::init_members();
246 init_members();
247
248 // Return
249 return;
250}
251
252
253/***********************************************************************//**
254 * @brief Clone instance
255 *
256 * @return Pointer to deep copy of event cube.
257 ***************************************************************************/
259{
260 return new GCOMEventCube(*this);
261}
262
263
264/***********************************************************************//**
265 * @brief Return dimension of event cube
266 *
267 * @return Number of dimensions in event cube.
268 *
269 * The dimension of the cube is either 2 or 3, depending on whether several
270 * scatter angle layers exist or not.
271 ***************************************************************************/
272int GCOMEventCube::dim(void) const
273{
274 // Compute dimension from sky map
275 int dim = (m_dri.nphibar() > 1) ? 3 : 2;
276
277 // Return dimension
278 return dim;
279}
280
281
282/***********************************************************************//**
283 * @brief Return number of bins in axis
284 *
285 * @param[in] axis Axis [0,...,dim()-1].
286 * @return Number of bins in axis.
287 *
288 * @exception GException::out_of_range
289 * Axis is out of range.
290 *
291 * Returns the number of bins along a given event cube @p axis.
292 ***************************************************************************/
293int GCOMEventCube::naxis(const int& axis) const
294{
295 // Optionally check if the axis is valid
296 #if defined(G_RANGE_CHECK)
297 if (axis < 0 || axis >= dim()) {
298 throw GException::out_of_range(G_NAXIS, "COMPTEL event cube axis", axis, dim());
299 }
300 #endif
301
302 // Set result
303 int naxis = 0;
304 switch (axis) {
305 case 0:
306 naxis = m_dri.nchi();
307 break;
308 case 1:
309 naxis = m_dri.npsi();
310 break;
311 case 2:
312 naxis = m_dri.nphibar();
313 break;
314 }
315
316 // Return result
317 return naxis;
318}
319
320
321/***********************************************************************//**
322 * @brief Load COMPTEL event cube from FITS file
323 *
324 * @param[in] filename FITS filename.
325 *
326 * Loads the event cube from a DRE FITS file.
327 ***************************************************************************/
328void GCOMEventCube::load(const GFilename& filename)
329{
330 // Open DRE FITS file
331 GFits fits(filename);
332
333 // Load DRE cube from FITS file
334 read(fits);
335
336 // Close FITS file
337 fits.close();
338
339 // Return
340 return;
341}
342
343
344/***********************************************************************//**
345 * @brief Save COMPTEL event cube into FITS file
346 *
347 * @param[in] filename FITS filename.
348 * @param[in] clobber Overwrite existing FITS file? (default: false).
349 *
350 * Saves the COMPTEL event cube into a DRE FITS file.
351 ***************************************************************************/
352void GCOMEventCube::save(const GFilename& filename, const bool& clobber) const
353{
354 // Create empty FITS file
355 GFits fits;
356
357 // Write event cube into FITS file
358 write(fits);
359
360 // Save FITS file
361 fits.saveto(filename, clobber);
362
363 // Return
364 return;
365}
366
367
368/***********************************************************************//**
369 * @brief Read COMPTEL event cube from FITS file
370 *
371 * @param[in] fits FITS file.
372 *
373 * Reads an COMPTEL event cube from a DRE FITS file.
374 ***************************************************************************/
375void GCOMEventCube::read(const GFits& fits)
376{
377 // Clear object
378 clear();
379
380 // Get image
381 const GFitsImage& image = *fits.image("Primary");
382
383 // Read DRI
384 m_dri.read(image);
385
386 // Initialise event cube
387 init_cube();
388
389 // Return
390 return;
391}
392
393
394/***********************************************************************//**
395 * @brief Write COMPTEL event cube into FITS file.
396 *
397 * @param[in] file FITS file.
398 *
399 * Writes the COMPTEL event cube into a DRE FITS file.
400 ***************************************************************************/
402{
403 // Write cube
404 m_dri.write(file);
405
406 // Return
407 return;
408}
409
410
411/***********************************************************************//**
412 * @brief Return number of events in cube
413 *
414 * @return Number of events in event cube.
415 *
416 * This method returns the number of events in the event cube.
417 ***************************************************************************/
418double GCOMEventCube::number(void) const
419{
420 // Initialise result
421 double number = 0.0;
422
423 // Sum event cube
424 for (int i = 0; i < m_dri.size(); ++i) {
425 number += m_dri[i];
426 }
427
428 // Return
429 return number;
430}
431
432
433/***********************************************************************//**
434 * @brief Print event cube information
435 *
436 * @param[in] chatter Chattiness.
437 * @return String containing event cube information.
438 ***************************************************************************/
439std::string GCOMEventCube::print(const GChatter& chatter) const
440{
441 // Initialise result string
442 std::string result;
443
444 // Continue only if chatter is not silent
445 if (chatter != SILENT) {
446
447 // Append header
448 result.append("=== GCOMEventCube ===");
449
450 // Append information
451 result.append("\n"+gammalib::parformat("Number of events"));
452 result.append(gammalib::str(number()));
453 result.append("\n"+gammalib::parformat("Number of elements"));
454 result.append(gammalib::str(size()));
455 result.append("\n"+gammalib::parformat("Size (Chi x Psi x Phi)"));
456 result.append(gammalib::str(m_dri.nchi())+" x ");
457 result.append(gammalib::str(m_dri.npsi())+" x ");
458 result.append(gammalib::str(m_dri.nphibar()));
459 result.append("\n"+gammalib::parformat("Energy range"));
460 result.append(gammalib::str(emin().MeV())+" - ");
461 result.append(gammalib::str(emax().MeV())+" MeV");
462 result.append("\n"+gammalib::parformat("Mean energy"));
463 result.append(m_energy.print(chatter));
464 result.append("\n"+gammalib::parformat("Energy bin width"));
465 result.append(m_ewidth.print(chatter));
466 result.append("\n"+gammalib::parformat("MJD interval"));
467 result.append(gammalib::str(tstart().mjd())+" - ");
468 result.append(gammalib::str(tstop().mjd())+" days");
469 result.append("\n"+gammalib::parformat("UTC interval"));
470 result.append(tstart().utc()+" - ");
471 result.append(tstop().utc());
472 result.append("\n"+gammalib::parformat("TJD interval"));
473 result.append(gammalib::str(gammalib::com_tjd(tstart()))+":");
474 result.append(gammalib::str(gammalib::com_tics(tstart()))+" - ");
475 result.append(gammalib::str(gammalib::com_tjd(tstop()))+":");
476 result.append(gammalib::str(gammalib::com_tics(tstop())));
477 result.append("\n"+gammalib::parformat("Mean time"));
478 result.append(m_time.print(chatter));
479 result.append("\n"+gammalib::parformat("Ontime"));
480 result.append(gammalib::str(m_ontime)+" s");
481
482 // Append ToF correction
483 double tofcor = m_dri.tof_correction();
484 result.append("\n"+gammalib::parformat("ToF correction"));
485 result.append(gammalib::str(tofcor));
486
487 // Append pulsar phase correction
488 double phasecor = m_dri.phase_correction();
489 result.append("\n"+gammalib::parformat("Phase correction"));
490 result.append(gammalib::str(phasecor));
491
492 // EXPLICIT: Append DRI
493 if (chatter >= EXPLICIT) {
494 result.append("\n"+m_dri.print(chatter));
495 }
496
497 } // endif: chatter was not silent
498
499 // Return result
500 return result;
501}
502
503
504/*==========================================================================
505 = =
506 = Private methods =
507 = =
508 ==========================================================================*/
509
510/***********************************************************************//**
511 * @brief Initialise class members
512 *
513 * The method initialises the class members to a well defined state. It also
514 * prepares the event bin member that will be returned in case of an operator
515 * access to the class. As the event bin member manipulates pointers, it will
516 * be possible to directly write to the memory that has been associated with
517 * a bin.
518 ***************************************************************************/
520{
521 // Initialise members
522 m_bin.clear();
523 m_dir.clear();
524 m_dri.clear();
525 m_time.clear();
526 m_ontime = 0.0;
527 m_energy.clear();
528 m_ewidth.clear();
529 m_npix = 0;
530 m_dirs.clear();
531 m_solidangle.clear();
532 m_phibar.clear();
533
534 // Prepare event bin
535 init_bin();
536
537 // Return
538 return;
539}
540
541
542/***********************************************************************//**
543 * @brief Copy class members
544 *
545 * @param[in] cube Event cube.
546 *
547 * This method copies the class members from another event cube in the actual
548 * object. It also prepares the event bin member that will be returned in
549 * case of an operator access to the class.
550 ***************************************************************************/
552{
553 // Copy members. Note that the event bin is not copied as it will
554 // be initialised later. The event bin serves just as a container of
555 // pointers, hence we do not want to copy over the pointers from the
556 // original class.
557 m_dir = cube.m_dir;
558 m_dri = cube.m_dri;
559 m_time = cube.m_time;
560 m_ontime = cube.m_ontime;
561 m_energy = cube.m_energy;
562 m_ewidth = cube.m_ewidth;
563 m_npix = cube.m_npix;
564 m_dirs = cube.m_dirs;
566 m_phibar = cube.m_phibar;
567
568 // Prepare event bin
569 init_bin();
570
571 // Return
572 return;
573}
574
575
576/***********************************************************************//**
577 * @brief Delete class members
578 ***************************************************************************/
580{
581 // Return
582 return;
583}
584
585
586/***********************************************************************//**
587 * @brief Initialise event cube
588 *
589 * This method needs to be called once a new DRI dataset has been read.
590 *
591 * The method copies the energy boundaries and the Good Time Intervals from
592 * the DRI cube into the event cube and sets up arrays that will be used
593 * for event bin access. In particular, the set_scatter_directions(),
594 * set_scatter_angles(), set_energies() and set_times() methods will be
595 * called by this method.
596 ***************************************************************************/
598{
599 // Copy energy boundaries from DRI
601
602 // Copy Good Time Intervals from DRI
603 gti(m_dri.gti());
604
605 // Set scatter directions
607
608 // Set scatter angles
610
611 // Set energies
612 set_energies();
613
614 // Set times
615 set_times();
616
617 // Return
618 return;
619}
620
621
622/***********************************************************************//**
623 * @brief Set sky directions and solid angles of events cube
624 *
625 * @exception GException::invalid_value
626 * No sky pixels have been defined.
627 *
628 * This method computes the sky directions and solid angles for all (Chi,Psi)
629 * values of the event cube. Sky directions are stored in an array of GSkyDir
630 * objects while solid angles are stored in units of sr in an array of double
631 * precision variables.
632 ***************************************************************************/
634{
635 // Compute number of sky pixels
636 m_npix = m_dri.nchi() * m_dri.npsi();
637
638 // Throw an error if we have no sky pixels
639 if (m_npix < 1) {
640 std::string msg = "No sky pixels have been found in event cube. "
641 "Every COMPTEL event cube needs a definition of "
642 "sky pixels.";
644 }
645
646 // Clear vectors
647 m_dirs.clear();
648 m_solidangle.clear();
649
650 // Reserve space for pixel directions and solid angles
651 m_dirs.reserve(m_npix);
652 m_solidangle.reserve(m_npix);
653
654 // Set pixel directions and solid angles
655 for (int iy = 0; iy < m_dri.npsi(); ++iy) {
656 for (int ix = 0; ix < m_dri.nchi(); ++ix) {
657 GSkyPixel pixel = GSkyPixel(double(ix), double(iy));
658 m_dirs.push_back(m_dri.map().pix2dir(pixel));
659 m_solidangle.push_back(m_dri.map().solidangle(pixel));
660 }
661 }
662
663 // Return
664 return;
665}
666
667
668/***********************************************************************//**
669 * @brief Set Compton scatter angles of event cube
670 *
671 * Sets a vector of the Compton scatter angles.
672 ***************************************************************************/
674{
675 // Clear vector
676 m_phibar.clear();
677
678 // Reserve space for pixel directions and solid angles
679 m_phibar.reserve(m_dri.nphibar());
680
681 // Set scatter angles
682 for (int iz = 0; iz < m_dri.nphibar(); ++iz) {
683 double phibar = m_dri.phimin() + (iz+0.5)*m_dri.phibin();
684 m_phibar.push_back(phibar);
685 }
686
687 // Return
688 return;
689}
690
691
692/***********************************************************************//**
693 * @brief Set log mean energy and energy width of event cube
694 *
695 * @exception GException::invalid_value
696 * No energy boundaries found.
697 *
698 * Computes the mean energy and energy bin width of the event cube.
699 ***************************************************************************/
701{
702 // Throw an error if GTI is empty
703 if (m_ebounds.size() < 1) {
704 std::string msg = "No energy boundaries have been found in event "
705 "cube. Every COMPTEL event cube needs a definition "
706 "of the energy boundaries.";
708 }
709
710 // Compute the logarithmic mean energy
712
713 // Compute the energy bin size
715
716 // Return
717 return;
718}
719
720
721/***********************************************************************//**
722 * @brief Set mean event time and ontime of event cube
723 *
724 * @exception GException::invalid_value
725 * No Good Time Intervals found.
726 *
727 * Computes the mean time of the event cube by taking the mean between start
728 * and stop time. Computes also the ontime by summing up of all good time
729 * intervals.
730 ***************************************************************************/
732{
733 // Throw an error if GTI is empty
734 if (m_gti.size() < 1) {
735 std::string msg = "No Good Time Intervals have been found in event "
736 "cube. Every COMPTEL event cube needs a definition "
737 "of the Good Time Intervals.";
739 }
740
741 // Compute mean time
742 m_time = m_gti.tstart() + 0.5 * (m_gti.tstop() - m_gti.tstart());
743
744 // Set ontime
746
747 // Return
748 return;
749}
750
751
752/***********************************************************************//**
753 * @brief Initialise event bin
754 *
755 * This method initialises the event bin. The event bin is cleared and all
756 * fixed pointers are set. Only the m_counts and the m_solidangle member of the
757 * event bin will be set to NULL, but these will be set by the set_bin method
758 * which is called before any event bin access.
759 ***************************************************************************/
761{
762 // Prepare event bin
764 m_bin.m_counts = NULL; //!< Will be set by set_bin method
765 m_bin.m_dir = &m_dir; //!< Content will be set by set_bin method
766 m_bin.m_solidangle = NULL; //!< Will be set by set_bin method
767 m_bin.m_time = &m_time; //!< Fixed content
768 m_bin.m_ontime = &m_ontime; //!< Fixed content
769 m_bin.m_energy = &m_energy; //!< Fixed content
770 m_bin.m_ewidth = &m_ewidth; //!< Fixed content
771
772 // Return
773 return;
774}
775
776
777/***********************************************************************//**
778 * @brief Set event bin
779 *
780 * @param[in] index Event index [0,...,size()[.
781 *
782 * @exception GException::out_of_range
783 * Event index is outside valid range.
784 * @exception GException::invalid_value
785 * Sky directions and solid angles vectors have not been set up.
786 *
787 * This method provides the event attributes to the event bin. The event bin
788 * is in fact physically stored in the event cube, and only a single event
789 * bin is indeed allocated. This method sets up the pointers in the event
790 * bin so that a client can easily access the information of individual bins
791 * as if they were stored in an array.
792 ***************************************************************************/
793void GCOMEventCube::set_bin(const int& index)
794{
795 // Optionally check if the index is valid
796 #if defined(G_RANGE_CHECK)
797 if (index < 0 || index >= size()) {
798 throw GException::out_of_range(G_SET_BIN, "Event index", index, size());
799 }
800 #endif
801
802 // Check for the existence of sky directions and solid angles
803 if (m_dirs.size() != m_npix || m_solidangle.size() != m_npix) {
804 std::string msg = "Sky direction vector has not been setup for "
805 "event cube. Every COMPTEL event cube needs an "
806 "internal vector of sky directions.";
808 }
809
810 // Get pixel and energy bin indices.
811 int ipix = index % m_npix;
812 int iphi = index / m_npix;
813
814 // Set indices
815 m_bin.m_index = index;
816
817 // Set instrument direction
818 m_dir.dir(m_dirs[ipix]);
819 m_dir.phibar(m_phibar[iphi]);
820
821 // Set pointers
822 m_bin.m_counts = &(m_dri[index]);
824
825 // Return
826 return;
827}
#define G_SET_TIMES
#define G_SET_ENERGIES
#define G_SET_SCATTER_DIRECTIONS
#define G_SET_BIN
#define G_NAXIS
COMPTEL event bin container class interface definition.
Implementation of support function used by COMPTEL classes.
Definition of COMPTEL tools.
Exception handler interface definition.
Filename class interface definition.
FITS file class interface definition.
Gammalib tools definition.
GChatter
Definition GTypemaps.hpp:33
@ EXPLICIT
Definition GTypemaps.hpp:37
@ SILENT
Definition GTypemaps.hpp:34
COMPTEL Data Space class.
Definition GCOMDri.hpp:62
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
const double & phase_correction(void) const
Return pulsar phase correction factor.
Definition GCOMDri.hpp:429
int nchi(void) const
Return number of Chi bins.
Definition GCOMDri.hpp:242
const double & tof_correction(void) const
Return ToF correction factor.
Definition GCOMDri.hpp:398
const GGti & gti(void) const
Return Good Time Intervals of DRI cube.
Definition GCOMDri.hpp:344
const double & phibin(void) const
Return Compton scatter angle bin of DRI cube.
Definition GCOMDri.hpp:383
const GSkyMap & map(void) const
Return DRI sky map.
Definition GCOMDri.hpp:278
const double & phimin(void) const
Return minimum Compton scatter angle of DRI cube.
Definition GCOMDri.hpp:371
virtual std::string print(const GChatter &chatter=NORMAL) const
Print COMPTEL Data Space.
Definition GCOMDri.cpp:1001
int npsi(void) const
Return number of Psi bins.
Definition GCOMDri.hpp:254
int size(void) const
Return number of bins.
Definition GCOMDri.hpp:230
void write(GFits &fits, const std::string &extname="") const
Write COMPTEL Data Space into FITS image.
Definition GCOMDri.cpp:980
int nphibar(void) const
Return number of Phibar bins.
Definition GCOMDri.hpp:266
void read(const GFitsImage &image)
Read COMPTEL Data Space from DRI FITS image.
Definition GCOMDri.cpp:955
COMPTEL event bin class.
GEnergy * m_ewidth
Pointer to energy width of bin.
double * m_counts
Pointer to number of counts.
GTime * m_time
Pointer to bin time.
GCOMInstDir * m_dir
Pointer to bin direction.
double * m_ontime
Pointer to ontime of bin (seconds)
double * m_solidangle
Pointer to solid angle of pixel (sr)
int m_index
Dataspace index.
virtual void clear(void)
Clear instance.
GEnergy * m_energy
Pointer to bin energy.
void free_members(void)
Delete class members.
COMPTEL event bin container class.
virtual void set_times(void)
Set mean event time and ontime of event cube.
int m_npix
Number of DRI pixels.
GEnergy m_ewidth
Event cube energy bin width.
virtual int dim(void) const
Return dimension of event cube.
virtual void load(const GFilename &filename)
Load COMPTEL event cube from FITS file.
std::vector< double > m_phibar
Array of event scatter angles.
virtual GCOMEventBin * operator[](const int &index)
Event bin access operator.
virtual int size(void) const
Return number of bins in event cube.
void free_members(void)
Delete class members.
std::vector< double > m_solidangle
Array of solid angles (sr)
void set_scatter_directions(void)
Set sky directions and solid angles of events cube.
virtual ~GCOMEventCube(void)
Destructor.
void init_members(void)
Initialise class members.
virtual GCOMEventCube * clone(void) const
Clone instance.
GTime m_time
Event cube mean time.
GCOMEventCube(void)
Void constructor.
virtual void save(const GFilename &filename, const bool &clobber=false) const
Save COMPTEL event cube into FITS file.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print event cube information.
virtual void read(const GFits &file)
Read COMPTEL event cube from FITS file.
void set_scatter_angles(void)
Set Compton scatter angles of event cube.
const GCOMDri & dre(void) const
Return reference to DRE data.
void init_bin(void)
Initialise event bin.
std::vector< GSkyDir > m_dirs
Array of event scatter directions.
double m_ontime
Event cube ontime (sec)
virtual GCOMEventCube & operator=(const GCOMEventCube &cube)
Assignment operator.
virtual void clear(void)
Clear instance.
void init_cube(void)
Initialise event cube.
virtual void set_energies(void)
Set log mean energy and energy width of event cube.
GCOMDri m_dri
DRI cube.
GEnergy m_energy
Event cube mean energy.
virtual void write(GFits &file) const
Write COMPTEL event cube into FITS file.
void copy_members(const GCOMEventCube &cube)
Copy class members.
GCOMEventBin m_bin
Actual event bin.
virtual int naxis(const int &axis) const
Return number of bins in axis.
void set_bin(const int &index)
Set event bin.
virtual double number(void) const
Return number of events in cube.
GCOMInstDir m_dir
Actual event direction.
void dir(const GSkyDir &dir)
Set event scatter direction.
virtual void clear(void)
Clear instance.
void phibar(const double &phibar)
Set event Compton scatter angle.
const GEnergy & emax(void) const
Return maximum energy of all intervals.
Definition GEbounds.hpp:199
int size(void) const
Return number of energy boundaries.
Definition GEbounds.hpp:163
GEnergy elogmean(const int &index) const
Returns logarithmic mean energy for a given energy interval.
const GEnergy & emin(void) const
Return minimum energy of all intervals.
Definition GEbounds.hpp:187
std::string print(const GChatter &chatter=NORMAL) const
Print energy.
Definition GEnergy.cpp:822
void clear(void)
Clear instance.
Definition GEnergy.cpp:267
Abstract event bin container class.
void free_members(void)
Delete class members.
void init_members(void)
Initialise class members.
virtual GEventCube & operator=(const GEventCube &cube)
Assignment operator.
void free_members(void)
Delete class members.
Definition GEvents.cpp:206
GGti m_gti
Good time intervals covered by events.
Definition GEvents.hpp:112
const GTime & tstart(void) const
Return start time.
Definition GEvents.hpp:146
GEbounds m_ebounds
Energy boundaries covered by events.
Definition GEvents.hpp:111
const GGti & gti(void) const
Return Good Time Intervals.
Definition GEvents.hpp:134
void init_members(void)
Initialise class members.
Definition GEvents.cpp:176
const GTime & tstop(void) const
Return stop time.
Definition GEvents.hpp:158
const GEbounds & ebounds(void) const
Return energy boundaries.
Definition GEvents.hpp:122
const GEnergy & emax(void) const
Return maximum energy.
Definition GEvents.hpp:182
const GEnergy & emin(void) const
Return minimum energy.
Definition GEvents.hpp:170
Filename class.
Definition GFilename.hpp:62
Abstract FITS image base class.
FITS file class.
Definition GFits.hpp:63
void saveto(const GFilename &filename, const bool &clobber=false)
Saves to specified FITS file.
Definition GFits.cpp:1293
GFitsImage * image(const int &extno)
Get pointer to image HDU.
Definition GFits.cpp:368
void close(void)
Close FITS file.
Definition GFits.cpp:1342
const GTime & tstop(void) const
Returns latest stop time in Good Time Intervals.
Definition GGti.hpp:210
int size(void) const
Return number of Good Time Intervals.
Definition GGti.hpp:157
const double & ontime(void) const
Returns ontime.
Definition GGti.hpp:243
const GTime & tstart(void) const
Returns earliest start time in Good Time Intervals.
Definition GGti.hpp:197
double solidangle(const int &index) const
Returns solid angle of pixel.
Definition GSkyMap.cpp:1858
GSkyDir pix2dir(const GSkyPixel &pixel) const
Returns sky direction of pixel.
Definition GSkyMap.cpp:1360
Sky map pixel class.
Definition GSkyPixel.hpp:74
void clear(void)
Clear time.
Definition GTime.cpp:252
std::string print(const GChatter &chatter=NORMAL) const
Print time.
Definition GTime.cpp:1188
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
Definition GTools.cpp:1162
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
Definition GTools.cpp:508
int com_tics(const GTime &time)
Convert GTime in COMPTEL tics.
int com_tjd(const GTime &time)
Convert GTime in COMPTEL TJD.
Definition GCOMTools.cpp:91