GammaLib
2.0.0
|
CTA energy dispersion for stacked analysis. More...
#include <GCTACubeEdisp.hpp>
Public Member Functions | |
GCTACubeEdisp (void) | |
Void constructor. More... | |
GCTACubeEdisp (const GCTACubeEdisp &cube) | |
Copy constructor. More... | |
GCTACubeEdisp (const GFilename &filename) | |
File constructor. More... | |
GCTACubeEdisp (const GCTAEventCube &cube, const double &mmax, const int &nmbins) | |
Event cube constructor. More... | |
GCTACubeEdisp (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 GEnergies &energies, const double &mmax, const int &nmbins) | |
Energy dispersion cube constructor. More... | |
virtual | ~GCTACubeEdisp (void) |
Destructor. More... | |
GCTACubeEdisp & | operator= (const GCTACubeEdisp &cube) |
Assignment operator. More... | |
double | operator() (const GEnergy &ereco, const GEnergy &etrue, const GSkyDir &dir) const |
Return energy dispersion in units of MeV \(^{-1}\). More... | |
void | clear (void) |
Clear energy dispersion cube. More... | |
GCTACubeEdisp * | clone (void) const |
Clone energy dispersion cube. More... | |
std::string | classname (void) const |
Return class name. More... | |
void | set (const GCTAObservation &obs) |
Set energy dispersion cube for one CTA observation. More... | |
void | fill (const GObservations &obs, GLog *log=NULL) |
Fill energy dispersion cube from observation container. More... | |
const GSkyMap & | cube (void) const |
Return energy dispersion cube sky map. More... | |
const GEnergies & | energies (void) const |
Return energies for energy dispersion cub. More... | |
const GNodeArray & | migras (void) const |
Return migra fractions of true and measured photon energy. More... | |
double | migra_max (void) const |
Return maximum migra value. More... | |
int | offset (const int &imigra, const int &iebin) const |
Return map offset. More... | |
GEbounds | ebounds (const GEnergy &obsEng) const |
Return boundaries in true energy. More... | |
void | read (const GFits &fits) |
Read energy dispersion cube from FITS file. More... | |
void | write (GFits &file) const |
Write energy dispersion cube into FITS file. More... | |
void | load (const GFilename &filename) |
Load energy dispersion cube from FITS file. More... | |
void | save (const GFilename &filename, const bool &clobber=false) const |
Save energy dispersion cube into FITS file. More... | |
const GFilename & | filename (void) const |
Return edisp cube filename. More... | |
std::string | print (const GChatter &chatter=NORMAL) const |
Print energy dispersion cube information. 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 GCTACubeEdisp &cube) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
void | clear_cube (void) |
Clear all pixels in the energy dispersion cube. More... | |
void | fill_cube (const GCTAObservation &obs, GSkyMap *exposure=NULL, GLog *log=NULL) |
Fill energy dispersion cube from observation container. More... | |
void | update (const GEnergy &ereco, const GEnergy &etrue) const |
Update energy dispersion cube indices and weights cache. More... | |
void | set_eng_axis (void) |
Set nodes for interpolation in true energy. More... | |
void | set_migras (const double &mmax, const int &nmbins) |
Set nodes for interpolation in migration. More... | |
void | compute_ebounds (void) const |
Compute true energy boundary vector. More... | |
Protected Attributes | |
GFilename | m_filename |
Filename. More... | |
GSkyMap | m_cube |
Energy dispersion cube. More... | |
GEnergies | m_energies |
True energy values of cube. More... | |
GNodeArray | m_elogmeans |
Mean log10TeV energy for the Edisp cube. More... | |
GNodeArray | m_migras |
Migra bins for the Edisp cube. More... | |
Private Attributes | |
int | m_inx1 |
Index of upper left node. More... | |
int | m_inx2 |
Index of lower left node. More... | |
int | m_inx3 |
Index of upper right node. More... | |
int | m_inx4 |
Index of lower right node. More... | |
double | m_wgt1 |
Weight of upper left node. More... | |
double | m_wgt2 |
Weight of lower left node. More... | |
double | m_wgt3 |
Weight of upper right node. More... | |
double | m_wgt4 |
Weight of lower right node. More... | |
std::vector< GEbounds > | m_ebounds |
Energy boundaries. More... | |
CTA energy dispersion for stacked analysis.
This class implements a mean CTA energy dispersion which provides the average energy dispersion probability density function for stacked analysis as function of sky position, energy migration, and true log10 energy.
Definition at line 62 of file GCTACubeEdisp.hpp.
GCTACubeEdisp::GCTACubeEdisp | ( | void | ) |
Void constructor.
Constructs an empty energy dispersion cube.
Definition at line 74 of file GCTACubeEdisp.cpp.
References init_members().
Referenced by clone().
GCTACubeEdisp::GCTACubeEdisp | ( | const GCTACubeEdisp & | cube | ) |
Copy constructor.
[in] | cube | Energy dispersion cube. |
Constructs an energy dispersion cube by copying another energy dispersion cube.
Definition at line 92 of file GCTACubeEdisp.cpp.
References copy_members(), and init_members().
|
explicit |
File constructor.
[in] | filename | Energy dispersion cube filename. |
Constructs an energy dispersion cube by loading the energy dispersion information from an energy dispersion cube FITS file. See the load() method for details about the format of the FITS file.
Definition at line 114 of file GCTACubeEdisp.cpp.
References init_members(), and load().
GCTACubeEdisp::GCTACubeEdisp | ( | const GCTAEventCube & | cube, |
const double & | mmax, | ||
const int & | nmbins | ||
) |
Event cube constructor.
[in] | cube | Event cube. |
[in] | mmax | Maximum energy migration. |
[in] | nmbins | Number of migration bins (2 ...). |
GException::invalid_argument | Maximum energy migration or number of migration bins invalid. |
Construct an energy dispersion cube with all elements set to zero using the same binning and sky projection that is used for an event cube.
Definition at line 140 of file GCTACubeEdisp.cpp.
References GCTAEventCube::counts(), GEvents::ebounds(), G_CONSTRUCTOR1, init_members(), m_cube, m_energies, m_migras, GSkyMap::nmaps(), GEnergies::set(), set_eng_axis(), set_migras(), GSkyMap::shape(), GNodeArray::size(), GEnergies::size(), and gammalib::str().
GCTACubeEdisp::GCTACubeEdisp | ( | 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 GEnergies & | energies, | ||
const double & | mmax, | ||
const int & | nmbins | ||
) |
Energy dispersion 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] | energies | True energies. |
[in] | mmax | Maximum energy migration. |
[in] | nmbins | Number of migration bins (2 ...). |
GException::invalid_argument | Maximum energy migration or number of migration bins invalid. |
Constructs an energy dispersion cube by specifying the sky map grid and the energies.
Definition at line 212 of file GCTACubeEdisp.cpp.
References energies(), G_CONSTRUCTOR2, init_members(), m_cube, m_energies, m_migras, set_eng_axis(), set_migras(), GSkyMap::shape(), GNodeArray::size(), GEnergies::size(), and gammalib::str().
|
virtual |
Destructor.
Destructs energy dispersion cube.
Definition at line 270 of file GCTACubeEdisp.cpp.
References free_members().
|
inlinevirtual |
Return class name.
Implements GBase.
Definition at line 151 of file GCTACubeEdisp.hpp.
|
virtual |
Clear energy dispersion cube.
Clears energy dispersion cube.
Implements GBase.
Definition at line 361 of file GCTACubeEdisp.cpp.
References free_members(), and init_members().
Referenced by GCTAResponseCube::init_members(), and read().
|
protected |
Clear all pixels in the energy dispersion cube.
Definition at line 813 of file GCTACubeEdisp.cpp.
References m_cube, GSkyMap::nmaps(), and GSkyMap::npix().
|
virtual |
Clone energy dispersion cube.
Implements GBase.
Definition at line 379 of file GCTACubeEdisp.cpp.
References GCTACubeEdisp().
|
protected |
Compute true energy boundary vector.
Computes for all energies of the energy dispersion cube the boundaries in true energy that encompass non-zero migration matrix elements. In case that no matrix elements are found for a given energy, the interval of true energies will be set to 0,0.
Definition at line 1095 of file GCTACubeEdisp.cpp.
References GEnergy::clear(), m_cube, m_ebounds, m_energies, m_migras, migra_max(), GSkyMap::npix(), GNodeArray::size(), and GEnergies::size().
|
protected |
Copy class members.
[in] | cube | Energy dispersion cube. |
Definition at line 776 of file GCTACubeEdisp.cpp.
References m_cube, m_ebounds, m_elogmeans, m_energies, m_filename, m_inx1, m_inx2, m_inx3, m_inx4, m_migras, m_wgt1, m_wgt2, m_wgt3, and m_wgt4.
Referenced by GCTACubeEdisp(), and operator=().
|
inline |
Return energy dispersion cube sky map.
Returns the energy dispersion cube sky map.
Definition at line 165 of file GCTACubeEdisp.hpp.
References m_cube.
Return boundaries in true energy.
[in] | obsEng | Observed photon energy. |
GException::invalid_value | No energies defined for energy dispersion cube |
Returns the boundaries in true photon energies that enclose the energy disperson for a given observed photon energy obsEng
.
Definition at line 646 of file GCTACubeEdisp.cpp.
References compute_ebounds(), G_EBOUNDS, GEnergies::is_empty(), m_ebounds, m_energies, and GEnergies::size().
Referenced by GCTAResponseCube::ebounds().
|
inline |
Return energies for energy dispersion cub.
Returns the true energies of the energy dispersion cube.
Definition at line 179 of file GCTACubeEdisp.hpp.
References m_energies.
Referenced by GCTACubeEdisp().
|
inline |
Return edisp cube filename.
Returns the filename from which the energy dispersion cube was loaded or into which the cube has been saved.
Definition at line 222 of file GCTACubeEdisp.hpp.
References m_filename.
Referenced by load(), save(), and GCTAResponseCube::write().
void GCTACubeEdisp::fill | ( | const GObservations & | obs, |
GLog * | log = NULL |
||
) |
Fill energy dispersion cube from observation container.
[in] | obs | Observation container. |
[in] | log | Pointer towards logger. |
Sets the energy dispersion cube from all CTA observations in the observation container.
Definition at line 414 of file GCTACubeEdisp.cpp.
References clear_cube(), GCTAObservation::eventtype(), fill_cube(), GObservation::id(), GCTAObservation::instrument(), m_cube, m_energies, m_migras, GObservation::name(), norm(), GSkyMap::npix(), offset(), GNodeArray::size(), GEnergies::size(), and GObservations::size().
|
protected |
Fill energy dispersion cube from observation container.
[in] | obs | CTA observation. |
[in] | exposure | Pointer towards exposure map. |
[in] | log | Pointer towards logger. |
GException::invalid_value | No RoI or response found in CTA observation. |
Fills the energy dispersion cube from the observation container.
If the exposure
argument is not NULL, the energy dispersion is weighted by the exposure, and the exposure weighting is added to the exposure map.
If the log
argument is not NULL, the method puts information about exclusion and inclusion of a CTA observation into the energy dispersion cube.
Definition at line 852 of file GCTACubeEdisp.cpp.
References GCTARoi::centre(), GCTAInstDir::dir(), GSkyDir::dist(), GCTAObservation::ebounds(), GCTAObservation::eventtype(), G_FILL_CUBE, GObservation::id(), GCTAObservation::instrument(), GSkyMap::inx2dir(), GCTARoi::is_valid(), GCTAObservation::livetime(), m_cube, m_energies, m_migras, GObservation::name(), GSkyMap::npix(), offset(), GSkyMap::overlaps(), GCTAObservation::pointing(), GCTARoi::radius(), GCTAObservation::response(), GCTAObservation::roi(), GNodeArray::size(), and GEnergies::size().
|
protected |
Delete class members.
Definition at line 803 of file GCTACubeEdisp.cpp.
Referenced by clear(), operator=(), and ~GCTACubeEdisp().
|
protected |
Initialise class members.
Definition at line 746 of file GCTACubeEdisp.cpp.
References GNodeArray::clear(), GEnergies::clear(), GFilename::clear(), GSkyMap::clear(), m_cube, m_ebounds, m_elogmeans, m_energies, m_filename, m_inx1, m_inx2, m_inx3, m_inx4, m_migras, m_wgt1, m_wgt2, m_wgt3, and m_wgt4.
Referenced by clear(), GCTACubeEdisp(), and operator=().
void GCTACubeEdisp::load | ( | const GFilename & | filename | ) |
Load energy dispersion cube from FITS file.
[in] | filename | FITS file name. |
Loads the energy dispersion cube from a FITS file. See the read() method for information about the expected FITS file structure.
Definition at line 573 of file GCTACubeEdisp.cpp.
References GFits::close(), filename(), m_filename, and read().
Referenced by GCTACubeEdisp(), and GCTAResponseCube::read().
|
inline |
Return maximum migra value.
Definition at line 203 of file GCTACubeEdisp.hpp.
References m_migras, and GNodeArray::size().
Referenced by compute_ebounds().
|
inline |
Return migra fractions of true and measured photon energy.
Definition at line 191 of file GCTACubeEdisp.hpp.
References m_migras.
|
inline |
Return map offset.
[in] | imigra | Migration bin index. |
[in] | iebin | Energy bin index. |
Returns the offset of the energy dispersion in the sky map for a given migration bin index and a given energy bin index.
Definition at line 239 of file GCTACubeEdisp.hpp.
References m_migras, and GNodeArray::size().
Referenced by fill(), fill_cube(), and update().
double GCTACubeEdisp::operator() | ( | const GEnergy & | ereco, |
const GEnergy & | etrue, | ||
const GSkyDir & | dir | ||
) | const |
Return energy dispersion in units of MeV \(^{-1}\).
[in] | ereco | Reconstructed event energy. |
[in] | etrue | True photon energy. |
[in] | dir | Coordinate of the true photon position. |
Returns the energy dispersion for a given energy migration (reconstructed over true energy), true photon energy, and sky direction in units of MeV \(^{-1}\).
Definition at line 327 of file GCTACubeEdisp.cpp.
References m_cube, m_inx1, m_inx2, m_inx3, m_inx4, m_wgt1, m_wgt2, m_wgt3, m_wgt4, and update().
GCTACubeEdisp & GCTACubeEdisp::operator= | ( | const GCTACubeEdisp & | cube | ) |
Assignment operator.
[in] | cube | Energy dispersion cube. |
Assigns energy dispersion cube.
Definition at line 294 of file GCTACubeEdisp.cpp.
References copy_members(), free_members(), and init_members().
Print energy dispersion cube information.
[in] | chatter | Chattiness. |
Implements GBase.
Definition at line 689 of file GCTACubeEdisp.cpp.
References m_cube, m_energies, m_filename, m_migras, gammalib::parformat(), GEnergies::print(), GSkyMap::print(), SILENT, GNodeArray::size(), GEnergies::size(), and gammalib::str().
Referenced by GCTAResponseCube::print().
void GCTACubeEdisp::read | ( | const GFits & | fits | ) |
Read energy dispersion cube from FITS file.
[in] | fits | FITS file. |
Reads the energy dispersion cube from a FITS file. The energy dispersion cube values are expected in the primary extension of the FITS file, the true energy boundaries are expected in the ENERGIES
extension, and the migration values are expected in the MIGRAS
extension.
Definition at line 492 of file GCTACubeEdisp.cpp.
References clear(), compute_ebounds(), gammalib::extname_cta_migras, gammalib::extname_energies, GFits::image(), m_cube, m_energies, m_migras, GEnergies::read(), GNodeArray::read(), GSkyMap::read(), set_eng_axis(), and GFits::table().
Referenced by load().
void GCTACubeEdisp::save | ( | const GFilename & | filename, |
const bool & | clobber = false |
||
) | const |
Save energy dispersion cube into FITS file.
[in] | filename | FITS file name. |
[in] | clobber | Overwrite existing file? |
Save the energy dispersion cube into a FITS file.
Definition at line 606 of file GCTACubeEdisp.cpp.
References GFits::close(), filename(), m_filename, GFits::saveto(), and write().
void GCTACubeEdisp::set | ( | const GCTAObservation & | obs | ) |
Set energy dispersion cube for one CTA observation.
[in] | obs | CTA observation. |
Sets the energy dispersion cube for one CTA observation.
Definition at line 392 of file GCTACubeEdisp.cpp.
References clear_cube(), and fill_cube().
|
protected |
Set nodes for interpolation in true energy.
Definition at line 1046 of file GCTACubeEdisp.cpp.
References GNodeArray::append(), GNodeArray::clear(), m_elogmeans, m_energies, and GEnergies::size().
Referenced by GCTACubeEdisp(), and read().
|
protected |
Set nodes for interpolation in migration.
[in] | mmax | Maximum energy migration (>0). |
[in] | nmbins | Number of migration bins (2 ...). |
Sets the nodes for interpolation in migration. None of the nodes will have a value of zero unless mmax is zero.
Definition at line 1070 of file GCTACubeEdisp.cpp.
References GNodeArray::append(), GNodeArray::clear(), and m_migras.
Referenced by GCTACubeEdisp().
Update energy dispersion cube indices and weights cache.
[in] | ereco | Reconstructed event energy. |
[in] | etrue | True photon energy. |
Updates the energy dispersion cube indices, stored in the members m_inx1, m_inx2, m_inx3, and m_inx4, and weights cache, stored in m_wgt1, m_wgt2, m_wgt3, and m_wgt4.
Definition at line 1015 of file GCTACubeEdisp.cpp.
References GNodeArray::inx_left(), GNodeArray::inx_right(), GEnergy::log10TeV(), m_elogmeans, m_inx1, m_inx2, m_inx3, m_inx4, m_migras, m_wgt1, m_wgt2, m_wgt3, m_wgt4, offset(), GNodeArray::set_value(), GNodeArray::wgt_left(), and GNodeArray::wgt_right().
Referenced by operator()().
void GCTACubeEdisp::write | ( | GFits & | fits | ) | const |
Write energy dispersion cube into FITS file.
[in] | fits | FITS file. |
Write the energy dispersion cube into a FITS file. The energy dispersion cube values are written into the primary extension of the FITS file, the true energy boundaries are written into the ENERGIES
extension, and the migration values are written into the MIGRAS
extension.
Definition at line 532 of file GCTACubeEdisp.cpp.
References GFitsHDU::card(), GFits::contains(), gammalib::extname_cta_migras, gammalib::extname_energies, m_cube, m_energies, m_migras, GFits::remove(), GFits::size(), GEnergies::write(), GNodeArray::write(), and GSkyMap::write().
Referenced by save().
|
protected |
Energy dispersion cube.
Definition at line 126 of file GCTACubeEdisp.hpp.
Referenced by clear_cube(), compute_ebounds(), copy_members(), cube(), fill(), fill_cube(), GCTACubeEdisp(), init_members(), operator()(), print(), read(), and write().
|
mutableprivate |
Energy boundaries.
Definition at line 141 of file GCTACubeEdisp.hpp.
Referenced by compute_ebounds(), copy_members(), ebounds(), and init_members().
|
protected |
Mean log10TeV energy for the Edisp cube.
Definition at line 128 of file GCTACubeEdisp.hpp.
Referenced by copy_members(), init_members(), set_eng_axis(), and update().
|
protected |
True energy values of cube.
Definition at line 127 of file GCTACubeEdisp.hpp.
Referenced by compute_ebounds(), copy_members(), ebounds(), energies(), fill(), fill_cube(), GCTACubeEdisp(), init_members(), print(), read(), set_eng_axis(), and write().
|
mutableprotected |
Filename.
Definition at line 125 of file GCTACubeEdisp.hpp.
Referenced by copy_members(), filename(), init_members(), load(), print(), and save().
|
mutableprivate |
Index of upper left node.
Definition at line 133 of file GCTACubeEdisp.hpp.
Referenced by copy_members(), init_members(), operator()(), and update().
|
mutableprivate |
Index of lower left node.
Definition at line 134 of file GCTACubeEdisp.hpp.
Referenced by copy_members(), init_members(), operator()(), and update().
|
mutableprivate |
Index of upper right node.
Definition at line 135 of file GCTACubeEdisp.hpp.
Referenced by copy_members(), init_members(), operator()(), and update().
|
mutableprivate |
Index of lower right node.
Definition at line 136 of file GCTACubeEdisp.hpp.
Referenced by copy_members(), init_members(), operator()(), and update().
|
protected |
Migra bins for the Edisp cube.
Definition at line 129 of file GCTACubeEdisp.hpp.
Referenced by compute_ebounds(), copy_members(), fill(), fill_cube(), GCTACubeEdisp(), init_members(), migra_max(), migras(), offset(), print(), read(), set_migras(), update(), and write().
|
mutableprivate |
Weight of upper left node.
Definition at line 137 of file GCTACubeEdisp.hpp.
Referenced by copy_members(), init_members(), operator()(), and update().
|
mutableprivate |
Weight of lower left node.
Definition at line 138 of file GCTACubeEdisp.hpp.
Referenced by copy_members(), init_members(), operator()(), and update().
|
mutableprivate |
Weight of upper right node.
Definition at line 139 of file GCTACubeEdisp.hpp.
Referenced by copy_members(), init_members(), operator()(), and update().
|
mutableprivate |
Weight of lower right node.
Definition at line 140 of file GCTACubeEdisp.hpp.
Referenced by copy_members(), init_members(), operator()(), and update().