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