GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTACubeEdisp Class Reference

CTA energy dispersion for stacked analysis. More...

#include <GCTACubeEdisp.hpp>

Inheritance diagram for GCTACubeEdisp:
GBase

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...
 
GCTACubeEdispoperator= (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...
 
GCTACubeEdispclone (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 GSkyMapcube (void) const
 Return energy dispersion cube sky map. More...
 
const GEnergiesenergies (void) const
 Return energies for energy dispersion cub. More...
 
const GNodeArraymigras (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 GFilenamefilename (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< GEboundsm_ebounds
 Energy boundaries. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Parameters
[in]cubeEnergy 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().

GCTACubeEdisp::GCTACubeEdisp ( const GFilename filename)
explicit

File constructor.

Parameters
[in]filenameEnergy 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.

Parameters
[in]cubeEvent cube.
[in]mmaxMaximum energy migration.
[in]nmbinsNumber of migration bins (2 ...).
Exceptions
GException::invalid_argumentMaximum 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.

Parameters
[in]wcsWorld Coordinate System.
[in]coordsCoordinate System (CEL or GAL).
[in]xX coordinate of sky map centre (deg).
[in]yY coordinate of sky map centre (deg).
[in]dxPixel size in x direction at centre (deg/pixel).
[in]dyPixel size in y direction at centre (deg/pixel).
[in]nxNumber of pixels in x direction.
[in]nyNumber of pixels in y direction.
[in]energiesTrue energies.
[in]mmaxMaximum energy migration.
[in]nmbinsNumber of migration bins (2 ...).
Exceptions
GException::invalid_argumentMaximum 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().

GCTACubeEdisp::~GCTACubeEdisp ( void  )
virtual

Destructor.

Destructs energy dispersion cube.

Definition at line 270 of file GCTACubeEdisp.cpp.

References free_members().

Member Function Documentation

std::string GCTACubeEdisp::classname ( void  ) const
inlinevirtual

Return class name.

Returns
String containing the class name ("GCTACubeEdisp").

Implements GBase.

Definition at line 151 of file GCTACubeEdisp.hpp.

void GCTACubeEdisp::clear ( void  )
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().

void GCTACubeEdisp::clear_cube ( void  )
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().

Referenced by fill(), and set().

GCTACubeEdisp * GCTACubeEdisp::clone ( void  ) const
virtual

Clone energy dispersion cube.

Returns
Pointer to deep copy of energy dispersion cube.

Implements GBase.

Definition at line 379 of file GCTACubeEdisp.cpp.

References GCTACubeEdisp().

void GCTACubeEdisp::compute_ebounds ( void  ) const
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().

Referenced by ebounds(), and read().

void GCTACubeEdisp::copy_members ( const GCTACubeEdisp cube)
protected

Copy class members.

Parameters
[in]cubeEnergy 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=().

const GSkyMap & GCTACubeEdisp::cube ( void  ) const
inline

Return energy dispersion cube sky map.

Returns
Energy dispersion cube sky map.

Returns the energy dispersion cube sky map.

Definition at line 165 of file GCTACubeEdisp.hpp.

References m_cube.

GEbounds GCTACubeEdisp::ebounds ( const GEnergy obsEng) const

Return boundaries in true energy.

Parameters
[in]obsEngObserved photon energy.
Returns
Boundaries in true energy.
Exceptions
GException::invalid_valueNo 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().

const GEnergies & GCTACubeEdisp::energies ( void  ) const
inline

Return energies for energy dispersion cub.

Returns
Energies for energy dispersion cube

Returns the true energies of the energy dispersion cube.

Definition at line 179 of file GCTACubeEdisp.hpp.

References m_energies.

Referenced by GCTACubeEdisp().

const GFilename & GCTACubeEdisp::filename ( void  ) const
inline

Return edisp cube filename.

Returns
Energy dispersion 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.

Parameters
[in]obsObservation container.
[in]logPointer 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().

void GCTACubeEdisp::fill_cube ( const GCTAObservation obs,
GSkyMap exposure = NULL,
GLog log = NULL 
)
protected

Fill energy dispersion cube from observation container.

Parameters
[in]obsCTA observation.
[in]exposurePointer towards exposure map.
[in]logPointer towards logger.
Exceptions
GException::invalid_valueNo 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().

Referenced by fill(), and set().

void GCTACubeEdisp::free_members ( void  )
protected

Delete class members.

Definition at line 803 of file GCTACubeEdisp.cpp.

Referenced by clear(), operator=(), and ~GCTACubeEdisp().

void GCTACubeEdisp::init_members ( void  )
protected
void GCTACubeEdisp::load ( const GFilename filename)

Load energy dispersion cube from FITS file.

Parameters
[in]filenameFITS 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().

double GCTACubeEdisp::migra_max ( void  ) const
inline

Return maximum migra value.

Returns
Maximum migra value.

Definition at line 203 of file GCTACubeEdisp.hpp.

References m_migras, and GNodeArray::size().

Referenced by compute_ebounds().

const GNodeArray & GCTACubeEdisp::migras ( void  ) const
inline

Return migra fractions of true and measured photon energy.

Returns
Offset migra between fractions of true and measured photon energy

Definition at line 191 of file GCTACubeEdisp.hpp.

References m_migras.

int GCTACubeEdisp::offset ( const int &  imigra,
const int &  iebin 
) const
inline

Return map offset.

Parameters
[in]imigraMigration bin index.
[in]iebinEnergy bin index.
Returns
Map offset.

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}\).

Parameters
[in]erecoReconstructed event energy.
[in]etrueTrue photon energy.
[in]dirCoordinate of the true photon position.
Returns
Energy dispersion (MeV \(^{-1}\))

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.

Parameters
[in]cubeEnergy dispersion cube.
Returns
Energy dispersion cube.

Assigns energy dispersion cube.

Definition at line 294 of file GCTACubeEdisp.cpp.

References copy_members(), free_members(), and init_members().

std::string GCTACubeEdisp::print ( const GChatter chatter = NORMAL) const
virtual

Print energy dispersion cube information.

Parameters
[in]chatterChattiness.
Returns
String containing energy dispersion cube information.

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.

Parameters
[in]fitsFITS 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.

Parameters
[in]filenameFITS file name.
[in]clobberOverwrite 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.

Parameters
[in]obsCTA observation.

Sets the energy dispersion cube for one CTA observation.

Definition at line 392 of file GCTACubeEdisp.cpp.

References clear_cube(), and fill_cube().

void GCTACubeEdisp::set_eng_axis ( void  )
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().

void GCTACubeEdisp::set_migras ( const double &  mmax,
const int &  nmbins 
)
protected

Set nodes for interpolation in migration.

Parameters
[in]mmaxMaximum energy migration (>0).
[in]nmbinsNumber 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().

void GCTACubeEdisp::update ( const GEnergy ereco,
const GEnergy etrue 
) const
protected

Update energy dispersion cube indices and weights cache.

Parameters
[in]erecoReconstructed event energy.
[in]etrueTrue 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.

Parameters
[in]fitsFITS 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().

Member Data Documentation

GSkyMap GCTACubeEdisp::m_cube
protected
std::vector<GEbounds> GCTACubeEdisp::m_ebounds
mutableprivate

Energy boundaries.

Definition at line 141 of file GCTACubeEdisp.hpp.

Referenced by compute_ebounds(), copy_members(), ebounds(), and init_members().

GNodeArray GCTACubeEdisp::m_elogmeans
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().

GEnergies GCTACubeEdisp::m_energies
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().

GFilename GCTACubeEdisp::m_filename
mutableprotected

Filename.

Definition at line 125 of file GCTACubeEdisp.hpp.

Referenced by copy_members(), filename(), init_members(), load(), print(), and save().

int GCTACubeEdisp::m_inx1
mutableprivate

Index of upper left node.

Definition at line 133 of file GCTACubeEdisp.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

int GCTACubeEdisp::m_inx2
mutableprivate

Index of lower left node.

Definition at line 134 of file GCTACubeEdisp.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

int GCTACubeEdisp::m_inx3
mutableprivate

Index of upper right node.

Definition at line 135 of file GCTACubeEdisp.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

int GCTACubeEdisp::m_inx4
mutableprivate

Index of lower right node.

Definition at line 136 of file GCTACubeEdisp.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

GNodeArray GCTACubeEdisp::m_migras
protected
double GCTACubeEdisp::m_wgt1
mutableprivate

Weight of upper left node.

Definition at line 137 of file GCTACubeEdisp.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

double GCTACubeEdisp::m_wgt2
mutableprivate

Weight of lower left node.

Definition at line 138 of file GCTACubeEdisp.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

double GCTACubeEdisp::m_wgt3
mutableprivate

Weight of upper right node.

Definition at line 139 of file GCTACubeEdisp.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().

double GCTACubeEdisp::m_wgt4
mutableprivate

Weight of lower right node.

Definition at line 140 of file GCTACubeEdisp.hpp.

Referenced by copy_members(), init_members(), operator()(), and update().


The documentation for this class was generated from the following files: