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