GammaLib
2.0.0
|
CTA event bin container class. More...
#include <GCTAEventCube.hpp>
Public Member Functions | |
GCTAEventCube (void) | |
Void constructor. More... | |
GCTAEventCube (const GFilename &filename) | |
File name constructor. More... | |
GCTAEventCube (const GSkyMap &map, const GEbounds &ebds, const GGti >i) | |
Constructor. More... | |
GCTAEventCube (const GSkyMap &map, const GSkyMap &weights, const GEbounds &ebds, const GGti >i) | |
Constructor. More... | |
GCTAEventCube (const GCTAEventCube &cube) | |
Copy constructor. More... | |
virtual | ~GCTAEventCube (void) |
Destructor. More... | |
virtual GCTAEventCube & | operator= (const GCTAEventCube &cube) |
Assignment operator. More... | |
virtual GCTAEventBin * | operator[] (const int &index) |
Event bin access operator. More... | |
virtual const GCTAEventBin * | operator[] (const int &index) const |
Event bin access operator (const version) More... | |
virtual void | clear (void) |
Clear CTA event cube. More... | |
virtual GCTAEventCube * | clone (void) const |
Clone CTA event cube. More... | |
virtual std::string | classname (void) const |
Return class name. More... | |
virtual int | size (void) const |
Return number of bins in event cube. More... | |
virtual int | dim (void) const |
Return dimension of event cube. More... | |
virtual int | naxis (const int &axis) const |
Return number of bins in axis. More... | |
virtual void | load (const GFilename &filename) |
Load CTA event cube from FITS file. More... | |
virtual void | save (const GFilename &filename, const bool &clobber=false) const |
Save CTA event cube into FITS file. More... | |
virtual void | read (const GFits &file) |
Read CTA event cube from FITS file. More... | |
virtual void | write (GFits &file) const |
Write CTA event cube into FITS file. More... | |
virtual int | number (void) const |
Return number of events in cube. More... | |
virtual std::string | print (const GChatter &chatter=NORMAL) const |
Print event cube information. More... | |
const GTime & | time (void) const |
Return event cube mean time. More... | |
const GEnergy & | energy (const int &index) const |
Return energy of cube layer. More... | |
void | counts (const GSkyMap &counts) |
Set event cube counts from sky map. More... | |
const GSkyMap & | counts (void) const |
Return event cube counts as sky map. More... | |
void | weights (const GSkyMap &weights) |
Set event cube weights from sky map. More... | |
const GSkyMap & | weights (void) const |
Return event cube weights as sky map. More... | |
int | nx (void) const |
Return number of bins in X direction. More... | |
int | ny (void) const |
Return number of bins in Y direction. More... | |
int | npix (void) const |
Return number of pixels in one energy bins of the event cube. More... | |
int | ebins (void) const |
Return number of energy bins in the event cube. More... | |
Public Member Functions inherited from GEventCube | |
GEventCube (void) | |
Void constructor. More... | |
GEventCube (const GEventCube &cube) | |
Copy constructor. More... | |
virtual | ~GEventCube (void) |
Destructor. More... | |
virtual GEventCube & | operator= (const GEventCube &cube) |
Assignment operator. More... | |
Public Member Functions inherited from GEvents | |
GEvents (void) | |
Void constructor. More... | |
GEvents (const GEvents &events) | |
Copy constructor. More... | |
virtual | ~GEvents (void) |
Destructor. More... | |
virtual GEvents & | operator= (const GEvents &events) |
Assignment operator. More... | |
void | ebounds (const GEbounds &ebounds) |
Set energy boundaries. More... | |
void | gti (const GGti >i) |
Set Good Time Intervals. More... | |
const GEbounds & | ebounds (void) const |
Return energy boundaries. More... | |
const GGti & | gti (void) const |
Return Good Time Intervals. More... | |
const GTime & | tstart (void) const |
Return start time. More... | |
const GTime & | tstop (void) const |
Return stop time. More... | |
const GEnergy & | emin (void) const |
Return minimum energy. More... | |
const GEnergy & | emax (void) const |
Return maximum energy. More... | |
Public Member Functions inherited from GBase | |
virtual | ~GBase (void) |
Destructor. More... | |
Protected Member Functions | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GCTAEventCube &cube) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
void | read_cntmap (const GFitsImage &hdu) |
Read CTA counts map from HDU. More... | |
void | read_ebds (const GFitsTable &hdu) |
Read energy boundaries from HDU. More... | |
void | read_gti (const GFitsTable &hdu) |
Read GTIs from HDU. More... | |
void | set_directions (void) |
Set sky directions and solid angles of events cube. More... | |
void | set_detxy (const GCTAPointing &pnt) |
Set DETX and DETY coordinates. More... | |
virtual void | set_energies (void) |
Set log mean energies and energy widths of event cube. More... | |
virtual void | set_times (void) |
Set mean event time and ontime of event cube. More... | |
void | init_bin (void) |
Initialise event bin. More... | |
void | set_bin (const int &index) |
Set event bin. More... | |
Protected Member Functions inherited from GEventCube | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GEventCube &cube) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Member Functions inherited from GEvents | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GEvents &events) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Attributes | |
GSkyMap | m_map |
Counts cube stored as sky map. More... | |
GSkyMap | m_weights |
Cube weights stored as sky map. More... | |
GCTAEventBin | m_bin |
Actual event bin. More... | |
GTime | m_time |
Event cube mean time. More... | |
GCTAPointing | m_pnt |
Event cube pointing. More... | |
bool | m_has_pnt |
Event cube has pointing. More... | |
std::vector< GCTAInstDir > | m_dirs |
Array of event directions. More... | |
std::vector< double > | m_solidangle |
Array of solid angles (sr) More... | |
std::vector< GEnergy > | m_energies |
Array of log mean energies. More... | |
std::vector< GEnergy > | m_ewidth |
Array of energy bin widths. More... | |
double | m_ontime |
Event cube ontime (sec) More... | |
Protected Attributes inherited from GEvents | |
GEbounds | m_ebounds |
Energy boundaries covered by events. More... | |
GGti | m_gti |
Good time intervals covered by events. More... | |
CTA event bin container class.
This class is a container class for CTA event bins.
Definition at line 62 of file GCTAEventCube.hpp.
GCTAEventCube::GCTAEventCube | ( | void | ) |
Void constructor.
Definition at line 62 of file GCTAEventCube.cpp.
References init_members().
Referenced by clone().
|
explicit |
File name constructor.
[in] | filename | Counts cube filename. |
Constructs instance of events cube from a counts cube file.
Definition at line 79 of file GCTAEventCube.cpp.
References init_members(), and load().
Constructor.
[in] | map | Sky map. |
[in] | ebds | Energy boundaries. |
[in] | gti | Good Time intervals. |
Constructs instance of events cube from a sky map, energy boundaries and Good Time Intervals. All event cube weights are set to unity.
Definition at line 102 of file GCTAEventCube.cpp.
References GEvents::ebounds(), GEvents::gti(), init_members(), m_map, m_weights, set_directions(), set_energies(), and set_times().
GCTAEventCube::GCTAEventCube | ( | const GSkyMap & | map, |
const GSkyMap & | weights, | ||
const GEbounds & | ebds, | ||
const GGti & | gti | ||
) |
Constructor.
[in] | map | Sky map. |
[in] | weights | Event cube weights. |
[in] | ebds | Energy boundaries. |
[in] | gti | Good Time intervals. |
Constructs instance of events cube from a sky map, a map of weights, energy boundaries and Good Time Intervals.
Definition at line 143 of file GCTAEventCube.cpp.
References GEvents::ebounds(), GEvents::gti(), init_members(), m_map, m_weights, set_directions(), set_energies(), set_times(), and weights().
GCTAEventCube::GCTAEventCube | ( | const GCTAEventCube & | cube | ) |
Copy constructor.
[in] | cube | Event cube. |
Definition at line 178 of file GCTAEventCube.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GEventCube.
Definition at line 142 of file GCTAEventCube.hpp.
|
virtual |
Clear CTA event cube.
Implements GEventCube.
Definition at line 283 of file GCTAEventCube.cpp.
References GEventCube::free_members(), GEvents::free_members(), free_members(), GEventCube::init_members(), GEvents::init_members(), and init_members().
|
virtual |
Clone CTA event cube.
Implements GEventCube.
Definition at line 305 of file GCTAEventCube.cpp.
References GCTAEventCube().
|
protected |
Copy class members.
[in] | cube | Event cube. |
This method copies the class members from another event cube in the actual object. It also prepares the event bin member that will be returned in case of an operator access to the class.
Definition at line 748 of file GCTAEventCube.cpp.
References init_bin(), m_dirs, m_energies, m_ewidth, GEvents::m_gti, m_has_pnt, m_map, m_ontime, m_pnt, m_solidangle, m_time, and m_weights.
Referenced by GCTAEventCube(), and operator=().
void GCTAEventCube::counts | ( | const GSkyMap & | counts | ) |
Set event cube counts from sky map.
[in] | counts | Event cube counts sky map. |
Sets event cube counts from sky map. The methods also sets all weights to unity.
Definition at line 576 of file GCTAEventCube.cpp.
References counts(), m_has_pnt, m_map, m_pnt, m_weights, set_detxy(), and set_directions().
Referenced by GCTACubeBackground::fill(), GCTACubeBackground::GCTACubeBackground(), GCTACubeEdisp::GCTACubeEdisp(), GCTACubeExposure::GCTACubeExposure(), GCTACubePsf::GCTACubePsf(), and GCTAResponseCube::irf_radial().
|
inline |
Return event cube counts as sky map.
Returns the event cube counts as sky map.
Definition at line 169 of file GCTAEventCube.hpp.
References m_map.
Referenced by counts().
|
inlinevirtual |
Return dimension of event cube.
Implements GEventCube.
Definition at line 154 of file GCTAEventCube.hpp.
References m_map, and GSkyMap::nmaps().
Referenced by naxis().
|
inline |
Return number of energy bins in the event cube.
Definition at line 246 of file GCTAEventCube.hpp.
References m_map, and GSkyMap::nmaps().
Referenced by energy(), GCTAResponseCube::irf_radial(), GCTAResponseCube::irf_spatial(), print(), set_bin(), and set_energies().
const GEnergy & GCTAEventCube::energy | ( | const int & | index | ) | const |
Return energy of cube layer.
[in] | index | Event cube layer index [0,...,ebins()-1] |
GException::out_of_range | Layer index is out of range. |
Returns the energy of the event cube layer specified by index
.
Definition at line 610 of file GCTAEventCube.cpp.
References ebins(), G_ENERGY, and m_energies.
Referenced by GCTAResponseCube::irf_radial().
|
protected |
Delete class members.
Definition at line 779 of file GCTAEventCube.cpp.
Referenced by clear(), operator=(), and ~GCTAEventCube().
|
protected |
Initialise event bin.
This method initialises the event bin. The event bin is cleared and all fixed pointers are set.
Definition at line 1028 of file GCTAEventCube.cpp.
References GCTAEventBin::free_members(), m_bin, GCTAEventBin::m_ontime, m_ontime, GCTAEventBin::m_time, and m_time.
Referenced by copy_members(), and init_members().
|
protected |
Initialise class members.
Definition at line 713 of file GCTAEventCube.cpp.
References GCTAEventBin::clear(), GCTAPointing::clear(), GTime::clear(), GSkyMap::clear(), G_CTA_MJDREF, init_bin(), m_bin, m_dirs, m_energies, m_ewidth, GEvents::m_gti, m_has_pnt, m_map, m_ontime, m_pnt, m_solidangle, m_time, m_weights, and GGti::reference().
Referenced by clear(), GCTAEventCube(), and operator=().
|
virtual |
Load CTA event cube from FITS file.
[in] | filename | FITS filename. |
Loads the event cube from a FITS file. See the read() method for more information about the structure of the FITS file.
The method clears the object before loading, thus any events residing in the object before loading will be lost.
Implements GEventCube.
Definition at line 374 of file GCTAEventCube.cpp.
References clear(), GFits::close(), and read().
Referenced by GCTAEventCube().
|
virtual |
Return number of bins in axis.
[in] | axis | Axis [0,...,dim()-1] |
GException::out_of_range | Axis is out of range. |
Returns the number of bins along a given event cube axis
.
Implements GEventCube.
Definition at line 335 of file GCTAEventCube.cpp.
References dim(), G_NAXIS, m_map, GSkyMap::nmaps(), GSkyMap::nx(), and GSkyMap::ny().
|
inline |
Return number of pixels in one energy bins of the event cube.
Definition at line 234 of file GCTAEventCube.hpp.
References m_map, and GSkyMap::npix().
Referenced by GCTACubeBackground::fill(), GCTAResponseCube::irf_radial(), print(), set_bin(), and set_directions().
|
virtual |
Return number of events in cube.
Returns the total number of events in the cube, rounded to the nearest integer value. All cube bins with a negative content will be excluded from the sum.
Implements GEventCube.
Definition at line 546 of file GCTAEventCube.cpp.
References m_map, GSkyMap::pixels(), and size().
Referenced by print().
|
inline |
Return number of bins in X direction.
Definition at line 210 of file GCTAEventCube.hpp.
References m_map, and GSkyMap::nx().
Referenced by GCTAResponseCube::irf_spatial(), and set_directions().
|
inline |
Return number of bins in Y direction.
Definition at line 222 of file GCTAEventCube.hpp.
References m_map, and GSkyMap::ny().
Referenced by GCTAResponseCube::irf_spatial(), and set_directions().
|
virtual |
Assignment operator.
[in] | cube | Event cube. |
Definition at line 216 of file GCTAEventCube.cpp.
References copy_members(), free_members(), init_members(), and GEventCube::operator=().
|
virtual |
Event bin access operator.
[in] | index | Event index [0,...,size()-1]. |
Returns pointer to an event bin.
Implements GEventCube.
Definition at line 247 of file GCTAEventCube.cpp.
|
virtual |
Event bin access operator (const version)
[in] | index | Event index [0,...,size()-1]. |
Returns pointer to an event bin.
Implements GEventCube.
Definition at line 264 of file GCTAEventCube.cpp.
References m_bin.
Print event cube information.
[in] | chatter | Chattiness. |
Implements GEventCube.
Definition at line 631 of file GCTAEventCube.cpp.
References GCTAPointing::dir(), ebins(), GEvents::ebounds(), GEvents::emax(), GEvents::emin(), GEvents::gti(), m_has_pnt, m_map, m_pnt, npix(), number(), gammalib::parformat(), GSkyDir::print(), GSkyMap::print(), gammalib::reduce(), SILENT, size(), gammalib::str(), GEvents::tstart(), and GEvents::tstop().
|
virtual |
Read CTA event cube from FITS file.
[in] | fits | FITS file. |
Read an event cube from a FITS file. The following HDUs will be read
COUNTS - Counts cube (or primary extension if COUNTS does not exist) WEIGHTS - Weights for each counts cube bin (optional) EBOUNDS - Energy boundaries GTI - Good Time Intervals
The method clears the event cube before reading, thus any events residing in the event cube will be lost.
Implements GEventCube.
Definition at line 434 of file GCTAEventCube.cpp.
References clear(), GFits::contains(), gammalib::extname_cta_counts, gammalib::extname_cta_weights, gammalib::extname_ebounds, gammalib::extname_gti, GFits::image(), m_map, m_weights, GSkyMap::read(), read_cntmap(), read_ebds(), read_gti(), and GFits::table().
Referenced by load(), and GCTAObservation::read().
|
protected |
Read CTA counts map from HDU.
[in] | hdu | Image HDU. |
This method reads a CTA counts map from a FITS HDU. The counts map is stored in a GSkyMap object.
Definition at line 794 of file GCTAEventCube.cpp.
References GCTAPointing::dir(), GFitsHDU::has_card(), m_has_pnt, m_map, m_pnt, GSkyDir::radec_deg(), GSkyMap::read(), GFitsHDU::real(), set_detxy(), and set_directions().
Referenced by read().
|
protected |
Read energy boundaries from HDU.
[in] | hdu | Energy boundaries table. |
Read the energy boundaries from the HDU.
Definition at line 831 of file GCTAEventCube.cpp.
References GEvents::m_ebounds, GEbounds::read(), and set_energies().
Referenced by read().
|
protected |
Read GTIs from HDU.
[in] | hdu | GTI table. |
Reads the Good Time Intervals from the HDU.
Definition at line 851 of file GCTAEventCube.cpp.
References GEvents::m_gti, GGti::read(), and set_times().
Referenced by read().
|
virtual |
Save CTA event cube into FITS file.
[in] | filename | FITS filename. |
[in] | clobber | Overwrite existing FITS file. |
Save the CTA event cube into FITS file. See the write() method for more information about the structure of the FITS file.
Implements GEventCube.
Definition at line 402 of file GCTAEventCube.cpp.
References GFits::saveto(), and write().
|
protected |
Set event bin.
[in] | index | Event index [0,...,size()-1]. |
GException::out_of_range | Event index is outside valid range. |
GException::invalid_value | Energy vectors have not been set up. Sky directions and solid angles vectors have not been set up. |
This method provides the event attributes to the event bin. The event bin is in fact physically stored in the event cube, and only a single event bin is indeed allocated. This method sets up the pointers in the event bin so that a client can easily access the information of individual bins as if they were stored in an array.
Definition at line 1059 of file GCTAEventCube.cpp.
References ebins(), G_SET_BIN, m_bin, GCTAEventBin::m_counts, GCTAEventBin::m_dir, m_dirs, m_energies, GCTAEventBin::m_energy, GCTAEventBin::m_ewidth, m_ewidth, GCTAEventBin::m_ieng, GCTAEventBin::m_ipix, m_map, GCTAEventBin::m_solidangle, m_solidangle, GCTAEventBin::m_weight, m_weights, npix(), GSkyMap::pixels(), size(), and gammalib::str().
Referenced by operator[]().
|
protected |
Set DETX and DETY coordinates.
[in] | pnt | CTA pointing. |
Computes DETX and DETY coordinates for a given pointing direction.
Definition at line 925 of file GCTAEventCube.cpp.
References GCTAPointing::instdir(), m_dirs, and size().
Referenced by counts(), and read_cntmap().
|
protected |
Set sky directions and solid angles of events cube.
GException::invalid_value | No sky pixels found in event cube. |
This method computes the sky directions and solid angles for all event cube pixels. Sky directions are stored in an array of GCTAInstDir objects while solid angles are stored in units of sr in an array of double precision variables.
A kluge has been introduced that handles invalid pixels. Invalid pixels may occur if a Hammer-Aitoff projection is used. In this case, pixels may lie outside the valid sky region. As invalid pixels lead to exceptions in the WCS classes, we simply need to catch the exceptions here. Invalid pixels are signaled by setting the solid angle of the pixel to 0.
Definition at line 881 of file GCTAEventCube.cpp.
References G_SET_DIRECTIONS, m_dirs, m_map, m_solidangle, npix(), nx(), ny(), GSkyMap::pix2dir(), and GSkyMap::solidangle().
Referenced by counts(), GCTAEventCube(), and read_cntmap().
|
protectedvirtual |
Set log mean energies and energy widths of event cube.
GException::invalid_value | No energy boundaries found in event cube. |
This method computes the log mean energies and the energy widths of the event cube. The log mean energies and energy widths are stored unit independent in arrays of GEnergy objects.
Reimplemented from GEventCube.
Definition at line 956 of file GCTAEventCube.cpp.
References ebins(), GEvents::ebounds(), gammalib::elogmean(), GEvents::emax(), GEvents::emin(), G_SET_ENERGIES, m_energies, m_ewidth, and GEbounds::size().
Referenced by GCTAEventCube(), and read_ebds().
|
protectedvirtual |
Set mean event time and ontime of event cube.
GException::invalid_value | No Good Time Intervals found. |
Computes the mean time of the event cube by taking the mean between start and stop time. Computes also the ontime by summing up of all good time intervals.
Reimplemented from GEventCube.
Definition at line 1001 of file GCTAEventCube.cpp.
References G_SET_TIMES, GEvents::m_gti, m_ontime, m_time, GGti::ontime(), GGti::size(), GGti::tstart(), and GGti::tstop().
Referenced by GCTAEventCube(), and read_gti().
|
virtual |
Return number of bins in event cube.
Implements GEventCube.
Definition at line 314 of file GCTAEventCube.cpp.
References m_map, GSkyMap::nmaps(), and GSkyMap::npix().
Referenced by GCTACubeBackground::fill(), number(), print(), set_bin(), and set_detxy().
|
inline |
Return event cube mean time.
Definition at line 258 of file GCTAEventCube.hpp.
References m_time.
Referenced by GCTAResponseCube::irf_radial().
|
inline |
Set event cube weights from sky map.
[in] | weights | Event cube weights sky map. |
Sets the event cube weights from sky map.
Definition at line 197 of file GCTAEventCube.hpp.
|
inline |
Return event cube weights as sky map.
Returns the event cube weights as sky map.
Definition at line 183 of file GCTAEventCube.hpp.
References m_weights.
Referenced by GCTAEventCube(), and weights().
|
virtual |
Write CTA event cube into FITS file.
[in] | fits | FITS file. |
Writes CTA event cube into a FITS file. The following HDUs will be written
COUNTS - Counts cube WEIGHTS - Weights for each counts cube bin EBOUNDS - Energy boundaries GTI - Good Time Intervals
The counts cube will be written as a double precision sky map. The weighing cube contains the weight for each counts cube, computed as the fraction of the event bin that has been selected in filling the counts cube. This allows to account for proper stacking of observations with different energy thresholds, or different regions of interest. The energy boundaries for all counts cube layers are also written, as well as the Good Time Intervals that have been used in generating the counts cube.
Implements GEventCube.
Definition at line 501 of file GCTAEventCube.cpp.
References GFits::contains(), GEvents::ebounds(), gammalib::extname_cta_counts, gammalib::extname_cta_weights, gammalib::extname_ebounds, gammalib::extname_gti, GEvents::gti(), m_map, m_weights, GFits::remove(), GGti::write(), GEbounds::write(), and GSkyMap::write().
Referenced by save(), and GCTAObservation::write().
|
protected |
Actual event bin.
Definition at line 124 of file GCTAEventCube.hpp.
Referenced by init_bin(), init_members(), operator[](), and set_bin().
|
protected |
Array of event directions.
Definition at line 128 of file GCTAEventCube.hpp.
Referenced by copy_members(), init_members(), set_bin(), set_detxy(), and set_directions().
|
protected |
Array of log mean energies.
Definition at line 130 of file GCTAEventCube.hpp.
Referenced by copy_members(), energy(), init_members(), set_bin(), and set_energies().
|
protected |
Array of energy bin widths.
Definition at line 131 of file GCTAEventCube.hpp.
Referenced by copy_members(), init_members(), set_bin(), and set_energies().
|
protected |
Event cube has pointing.
Definition at line 127 of file GCTAEventCube.hpp.
Referenced by copy_members(), counts(), init_members(), print(), and read_cntmap().
|
protected |
Counts cube stored as sky map.
Definition at line 122 of file GCTAEventCube.hpp.
Referenced by copy_members(), counts(), dim(), ebins(), GCTAEventCube(), init_members(), naxis(), npix(), number(), nx(), ny(), print(), read(), read_cntmap(), set_bin(), set_directions(), size(), and write().
|
protected |
Event cube ontime (sec)
Definition at line 132 of file GCTAEventCube.hpp.
Referenced by copy_members(), init_bin(), init_members(), and set_times().
|
protected |
Event cube pointing.
Definition at line 126 of file GCTAEventCube.hpp.
Referenced by copy_members(), counts(), init_members(), print(), and read_cntmap().
|
protected |
Array of solid angles (sr)
Definition at line 129 of file GCTAEventCube.hpp.
Referenced by copy_members(), init_members(), set_bin(), and set_directions().
|
protected |
Event cube mean time.
Definition at line 125 of file GCTAEventCube.hpp.
Referenced by copy_members(), init_bin(), init_members(), set_times(), and time().
|
protected |
Cube weights stored as sky map.
Definition at line 123 of file GCTAEventCube.hpp.
Referenced by copy_members(), counts(), GCTAEventCube(), init_members(), read(), set_bin(), weights(), and write().