GammaLib
2.1.0.dev
|
CTA cube background class. More...
#include <GCTACubeBackground.hpp>
Public Member Functions | |
GCTACubeBackground (void) | |
Void constructor. More... | |
GCTACubeBackground (const GFilename &filename) | |
File constructor. More... | |
GCTACubeBackground (const GCTAEventCube &cube) | |
Event cube constructor. More... | |
GCTACubeBackground (const GCTACubeBackground &bgd) | |
Copy constructor. More... | |
GCTACubeBackground (const std::string &wcs, const std::string &coords, const double &x, const double &y, const double &dx, const double &dy, const int &nx, const int &ny, const GEbounds &ebounds) | |
Background cube constructor. More... | |
virtual | ~GCTACubeBackground (void) |
Destructor. More... | |
GCTACubeBackground & | operator= (const GCTACubeBackground &bgd) |
Assignment operator. More... | |
double | operator() (const GCTAInstDir &dir, const GEnergy &energy) const |
Return background rate in units of events MeV \(^{-1}\) s \(^{-1}\) sr \(^{-1}\). More... | |
void | clear (void) |
Clear background. More... | |
GCTACubeBackground * | clone (void) const |
Clone background. More... | |
std::string | classname (void) const |
Return class name. More... | |
void | fill (const GObservations &obs, GLog *log=NULL) |
Fill background cube from observation container. More... | |
double | integral (const double &logE) const |
Return spatially integrated background rate in units of events MeV \(^{-1}\) s \(^{-1}\). More... | |
void | read (const GFits &fits) |
Read background cube from FITS object. More... | |
void | write (GFits &file) const |
Write CTA background cube into FITS object. More... | |
void | load (const GFilename &filename) |
Load background cube from FITS file. More... | |
void | save (const GFilename &filename, const bool &clobber=false) const |
Save background cube into FITS file. More... | |
const GSkyMap & | cube (void) const |
Return background cube. More... | |
const GEbounds & | ebounds (void) const |
Return energy boundaries. More... | |
const GFilename & | filename (void) const |
Return background cube filename. More... | |
std::string | print (const GChatter &chatter=NORMAL) const |
Print background information. More... | |
Public Member Functions inherited from GBase | |
virtual | ~GBase (void) |
Destructor. More... | |
Private Member Functions | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GCTACubeBackground &bgd) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
void | set_eng_axis (void) |
Set nodes for a logarithmic (base 10) energy axis. More... | |
void | update (const double &logE) const |
Update 1D cache. More... | |
Private Attributes | |
GFilename | m_filename |
Name of background response file. More... | |
GSkyMap | m_cube |
Background cube. More... | |
GEbounds | m_ebounds |
Energy boundaries of background cube. More... | |
GNodeArray | m_elogmeans |
Mean energy for the background cube. More... | |
int | m_inx_left |
Index of left node. More... | |
int | m_inx_right |
Index of right node. More... | |
double | m_wgt_left |
Weight of left node. More... | |
double | m_wgt_right |
Weight of right node. More... | |
CTA cube background class.
Definition at line 50 of file GCTACubeBackground.hpp.
GCTACubeBackground::GCTACubeBackground | ( | void | ) |
Void constructor.
Definition at line 72 of file GCTACubeBackground.cpp.
References init_members().
Referenced by clone().
|
explicit |
File constructor.
[in] | filename | FITS file name. |
Construct instance by loading the background information from a FITS file.
Definition at line 89 of file GCTACubeBackground.cpp.
References init_members(), and load().
|
explicit |
Event cube constructor.
[in] | cube | Event cube. |
Construct background cube using the same binning and sky projection that is used for the event cube.
Definition at line 110 of file GCTACubeBackground.cpp.
References GCTAEventCube::counts(), GEvents::ebounds(), init_members(), m_cube, m_ebounds, GSkyMap::nmaps(), set_eng_axis(), and GEbounds::size().
GCTACubeBackground::GCTACubeBackground | ( | const GCTACubeBackground & | bgd | ) |
Copy constructor.
[in] | bgd | Background. |
Definition at line 140 of file GCTACubeBackground.cpp.
References copy_members(), and init_members().
GCTACubeBackground::GCTACubeBackground | ( | const std::string & | wcs, |
const std::string & | coords, | ||
const double & | x, | ||
const double & | y, | ||
const double & | dx, | ||
const double & | dy, | ||
const int & | nx, | ||
const int & | ny, | ||
const GEbounds & | ebounds | ||
) |
Background cube constructor.
[in] | wcs | World Coordinate System. |
[in] | coords | Coordinate System (CEL or GAL). |
[in] | x | X coordinate of sky map centre (deg). |
[in] | y | Y coordinate of sky map centre (deg). |
[in] | dx | Pixel size in x direction at centre (deg/pixel). |
[in] | dy | Pixel size in y direction at centre (deg/pixel). |
[in] | nx | Number of pixels in x direction. |
[in] | ny | Number of pixels in y direction. |
[in] | ebounds | Energy boundaries. |
Constructs a background cube by specifying the sky map grid and the energies.
Definition at line 169 of file GCTACubeBackground.cpp.
References ebounds(), init_members(), m_cube, m_ebounds, set_eng_axis(), and GEbounds::size().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GBase.
Definition at line 119 of file GCTACubeBackground.hpp.
|
virtual |
Clear background.
This method properly resets the background to an initial state.
Implements GBase.
Definition at line 306 of file GCTACubeBackground.cpp.
References free_members(), and init_members().
Referenced by GCTAResponseCube::init_members(), and read().
|
virtual |
Clone background.
Implements GBase.
Definition at line 324 of file GCTACubeBackground.cpp.
References GCTACubeBackground().
|
private |
Copy class members.
[in] | bgd | Background. |
Definition at line 761 of file GCTACubeBackground.cpp.
References m_cube, m_ebounds, m_elogmeans, m_filename, m_inx_left, m_inx_right, m_wgt_left, and m_wgt_right.
Referenced by GCTACubeBackground(), and operator=().
|
inline |
Return background cube.
Returns the GSkyMap object that is used to store the background cube information.
Definition at line 134 of file GCTACubeBackground.hpp.
References m_cube.
|
inline |
Return energy boundaries.
Definition at line 146 of file GCTACubeBackground.hpp.
References m_ebounds.
Referenced by GCTACubeBackground().
|
inline |
Return background cube filename.
Returns the filename from which the background cube was loaded or into which the background cube has been saved.
Definition at line 161 of file GCTACubeBackground.hpp.
References m_filename.
Referenced by load(), save(), and GCTAResponseCube::write().
void GCTACubeBackground::fill | ( | const GObservations & | obs, |
GLog * | log = NULL |
||
) |
Fill background cube from observation container.
[in] | obs | Observation container. |
[in] | log | Pointer to logger (optional). |
GException::invalid_value | No event list found in CTA observations. |
Set the background cube by computing the ontime weighted background rate for all CTA observations in an observation container. The cube pixel values are computed as the sum over the background rates.
Definition at line 343 of file GCTACubeBackground.cpp.
References GCTARoi::centre(), GCTARoi::contains(), GEbounds::contains(), GCTAEventBin::counts(), GCTAEventCube::counts(), GCTAEventBin::dir(), GCTAInstDir::dir(), GCTAObservation::ebounds(), GEbounds::elogmean(), GEbounds::emax(), GEbounds::emin(), GCTAEventBin::energy(), GCTAObservation::eventtype(), G_FILL, GEvents::gti(), GCTAObservation::gti(), GObservation::id(), GCTAObservation::instrument(), GCTARoi::is_valid(), m_cube, m_ebounds, GObservations::models(), GObservation::name(), GCTAEventCube::npix(), GCTAObservation::ontime(), GSkyMap::overlaps(), GCTAObservation::pointing(), GCTARoi::radius(), GCTAObservation::roi(), GCTAEventCube::size(), GEbounds::size(), and GObservations::size().
|
private |
Delete class members.
Definition at line 783 of file GCTACubeBackground.cpp.
Referenced by clear(), operator=(), and ~GCTACubeBackground().
|
private |
Initialise class members.
Definition at line 737 of file GCTACubeBackground.cpp.
References GNodeArray::clear(), GFilename::clear(), GEbounds::clear(), GSkyMap::clear(), m_cube, m_ebounds, m_elogmeans, m_filename, m_inx_left, m_inx_right, m_wgt_left, and m_wgt_right.
Referenced by clear(), GCTACubeBackground(), and operator=().
double GCTACubeBackground::integral | ( | const double & | logE | ) | const |
Return spatially integrated background rate in units of events MeV \(^{-1}\) s \(^{-1}\).
[in] | logE | Logarithm (base 10) of energy in TeV |
Spatially integrates the background cube at a given energy. This method performs an interpolation between the energy maps. The integration is performed by summing over all bin contents multiplied by the solid angle of the bin.
Definition at line 539 of file GCTACubeBackground.cpp.
References m_cube, m_inx_left, m_inx_right, m_wgt_left, m_wgt_right, GSkyMap::npix(), and update().
Referenced by GCTAModelCubeBackground::npred().
void GCTACubeBackground::load | ( | const GFilename & | filename | ) |
Load background cube from FITS file.
[in] | filename | FITS file. |
Loads the background cube from a FITS file.
Definition at line 626 of file GCTACubeBackground.cpp.
References GFits::close(), filename(), m_filename, and read().
Referenced by GCTACubeBackground(), and GCTAResponseCube::read().
double GCTACubeBackground::operator() | ( | const GCTAInstDir & | dir, |
const GEnergy & | energy | ||
) | const |
Return background rate in units of events MeV \(^{-1}\) s \(^{-1}\) sr \(^{-1}\).
[in] | dir | Reconstructed event position where rate should be computed |
[in] | energy | Energy at which the rate should be computed |
Returns the background rate for a giben instrument direction and energy. The rate is given per ontime. The method assures that the background rate never becomes negative.
The method interpolates logarithmically in the energy direction.
Definition at line 256 of file GCTACubeBackground.cpp.
References abs(), GCTAInstDir::dir(), exp(), log(), GEnergy::log10TeV(), m_cube, m_inx_left, m_inx_right, m_wgt_left, m_wgt_right, and update().
GCTACubeBackground & GCTACubeBackground::operator= | ( | const GCTACubeBackground & | bgd | ) |
Assignment operator.
[in] | bgd | Background cube. |
Definition at line 221 of file GCTACubeBackground.cpp.
References copy_members(), free_members(), and init_members().
Print background information.
[in] | chatter | Chattiness. |
Implements GBase.
Definition at line 695 of file GCTACubeBackground.cpp.
References m_cube, m_ebounds, m_filename, gammalib::parformat(), GEbounds::print(), GSkyMap::print(), SILENT, and GEbounds::size().
Referenced by GCTAResponseCube::print().
void GCTACubeBackground::read | ( | const GFits & | fits | ) |
Read background cube from FITS object.
[in] | fits | FITS object. |
Read the background cube from a FITS object.
Definition at line 571 of file GCTACubeBackground.cpp.
References clear(), gammalib::extname_ebounds, GFits::image(), m_cube, m_ebounds, GEbounds::read(), GSkyMap::read(), set_eng_axis(), and GFits::table().
Referenced by load().
void GCTACubeBackground::save | ( | const GFilename & | filename, |
const bool & | clobber = false |
||
) | const |
Save background cube into FITS file.
[in] | filename | background cube FITS file name. |
[in] | clobber | Overwrite existing file? |
Save the background cube into a FITS file.
Definition at line 660 of file GCTACubeBackground.cpp.
References GFits::close(), filename(), m_filename, GFits::saveto(), and write().
|
private |
Set nodes for a logarithmic (base 10) energy axis.
Set axis nodes so that each node is the logarithm of the energy values.
Definition at line 796 of file GCTACubeBackground.cpp.
References GNodeArray::append(), GNodeArray::clear(), GEbounds::elogmean(), GEnergy::log10TeV(), m_ebounds, m_elogmeans, and GEbounds::size().
Referenced by GCTACubeBackground(), and read().
|
private |
Update 1D cache.
[in] | logE | Log10 energy in TeV. |
Updates the 1D interpolation cache. The interpolation cache is composed of two indices and weights that define 2 data values of the 2D skymap that are used for linear interpolation.
Definition at line 828 of file GCTACubeBackground.cpp.
References GNodeArray::inx_left(), GNodeArray::inx_right(), m_elogmeans, m_inx_left, m_inx_right, m_wgt_left, m_wgt_right, GNodeArray::set_value(), GNodeArray::wgt_left(), and GNodeArray::wgt_right().
Referenced by integral(), and operator()().
void GCTACubeBackground::write | ( | GFits & | fits | ) | const |
Write CTA background cube into FITS object.
[in] | fits | FITS file. |
Definition at line 599 of file GCTACubeBackground.cpp.
References GFitsHDU::card(), m_cube, m_ebounds, GFits::size(), GEbounds::write(), and GSkyMap::write().
Referenced by save().
|
private |
Background cube.
Definition at line 100 of file GCTACubeBackground.hpp.
Referenced by copy_members(), cube(), fill(), GCTACubeBackground(), init_members(), integral(), operator()(), print(), read(), and write().
|
private |
Energy boundaries of background cube.
Definition at line 101 of file GCTACubeBackground.hpp.
Referenced by copy_members(), ebounds(), fill(), GCTACubeBackground(), init_members(), print(), read(), set_eng_axis(), and write().
|
private |
Mean energy for the background cube.
Definition at line 102 of file GCTACubeBackground.hpp.
Referenced by copy_members(), init_members(), set_eng_axis(), and update().
|
mutableprivate |
Name of background response file.
Definition at line 99 of file GCTACubeBackground.hpp.
Referenced by copy_members(), filename(), init_members(), load(), print(), and save().
|
mutableprivate |
Index of left node.
Definition at line 105 of file GCTACubeBackground.hpp.
Referenced by copy_members(), init_members(), integral(), operator()(), and update().
|
mutableprivate |
Index of right node.
Definition at line 106 of file GCTACubeBackground.hpp.
Referenced by copy_members(), init_members(), integral(), operator()(), and update().
|
mutableprivate |
Weight of left node.
Definition at line 107 of file GCTACubeBackground.hpp.
Referenced by copy_members(), init_members(), integral(), operator()(), and update().
|
mutableprivate |
Weight of right node.
Definition at line 108 of file GCTACubeBackground.hpp.
Referenced by copy_members(), init_members(), integral(), operator()(), and update().