GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTACubeExposure Class Reference

CTA exposure cube class. More...

#include <GCTACubeExposure.hpp>

Inheritance diagram for GCTACubeExposure:
GBase

Public Member Functions

 GCTACubeExposure (void)
 Void constructor. More...
 
 GCTACubeExposure (const GCTACubeExposure &cube)
 Copy constructor. More...
 
 GCTACubeExposure (const GFilename &filename)
 File constructor. More...
 
 GCTACubeExposure (const GCTAEventCube &cube)
 Event cube constructor. More...
 
 GCTACubeExposure (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)
 Exposure cube constructor. More...
 
virtual ~GCTACubeExposure (void)
 Destructor. More...
 
GCTACubeExposureoperator= (const GCTACubeExposure &exp)
 Assignment operator. More...
 
double operator() (const GSkyDir &dir, const GEnergy &energy) const
 Return exposure (in units of cm**2 s) More...
 
void clear (void)
 Clear instance. More...
 
GCTACubeExposureclone (void) const
 Clone exposure cube. More...
 
std::string classname (void) const
 Return class name. More...
 
void set (const GCTAObservation &obs)
 Set exposure cube for one CTA observation. More...
 
void fill (const GObservations &obs, GLog *log=NULL)
 Fill exposure cube from observation container. More...
 
const GSkyMapcube (void) const
 Return exposure cube. More...
 
const GEnergiesenergies (void) const
 Return energies. More...
 
const GGtigti (void) const
 Return Good Time Intervals. More...
 
const double & livetime (void) const
 Return livetime. More...
 
const double & ontime (void) const
 Return ontime. More...
 
double deadc (void) const
 Return deadtime correction. More...
 
void read (const GFits &fits)
 Read exposure cube from FITS object. More...
 
void write (GFits &file) const
 Write CTA exposure cube into FITS file. More...
 
void load (const GFilename &filename)
 Load exposure cube from FITS file. More...
 
void save (const GFilename &filename, const bool &clobber=false) const
 Save exposure cube into FITS file. More...
 
const GFilenamefilename (void) const
 Return exposure cube filename. More...
 
std::string print (const GChatter &chatter=NORMAL) const
 Print exposure 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 GCTACubeExposure &exp)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
void fill_cube (const GCTAObservation &obs, GLog *log=NULL)
 Fill exposure cube for one observation. More...
 
void update (const double &logE) const
 Update 1D cache. More...
 
void set_eng_axis (void)
 Set nodes for a logarithmic (base 10) energy axis. More...
 
void read_attributes (const GFitsHDU &hdu)
 Read exposure attributes. More...
 
void write_attributes (GFitsHDU &hdu) const
 Write attributes to exposure extension. More...
 

Protected Attributes

GFilename m_filename
 Filename. More...
 
GSkyMap m_cube
 Average Exposure cube. More...
 
GEnergies m_energies
 Energy values for the Exposure cube. More...
 
GNodeArray m_elogmeans
 Mean energy for the Exposure cube. More...
 
GGti m_gti
 Good time interval for the Exposure cube. More...
 
double m_livetime
 Livetime (sec) More...
 

Private Attributes

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...
 

Detailed Description

CTA exposure cube class.

This class implements a CTA exposure cube which provides the average exposure for binned analysis as function of sky position and energy.

Definition at line 55 of file GCTACubeExposure.hpp.

Constructor & Destructor Documentation

GCTACubeExposure::GCTACubeExposure ( void  )

Void constructor.

Definition at line 64 of file GCTACubeExposure.cpp.

References init_members().

Referenced by clone().

GCTACubeExposure::GCTACubeExposure ( const GCTACubeExposure cube)

Copy constructor.

Parameters
[in]cubeExposure cube.

Definition at line 79 of file GCTACubeExposure.cpp.

References copy_members(), and init_members().

GCTACubeExposure::GCTACubeExposure ( const GFilename filename)
explicit

File constructor.

Parameters
[in]filenameExposure cube filename.

Construct exposure cube by loading the information from an exposure cube file.

Definition at line 100 of file GCTACubeExposure.cpp.

References init_members(), and load().

GCTACubeExposure::GCTACubeExposure ( const GCTAEventCube cube)
explicit

Event cube constructor.

Parameters
[in]cubeEvent cube.

Construct exposure cube using the same binning and sky projection that is used for the event cube.

Definition at line 121 of file GCTACubeExposure.cpp.

References GCTAEventCube::counts(), GEvents::ebounds(), init_members(), m_cube, m_energies, GSkyMap::nmaps(), GEnergies::set(), set_eng_axis(), and GEnergies::size().

GCTACubeExposure::GCTACubeExposure ( 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 
)

Exposure 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]energiesEnergies.

Constructs an exposure cube by specifying the sky map grid and the energies.

Definition at line 162 of file GCTACubeExposure.cpp.

References energies(), init_members(), m_cube, m_energies, set_eng_axis(), and GEnergies::size().

GCTACubeExposure::~GCTACubeExposure ( void  )
virtual

Destructor.

Definition at line 192 of file GCTACubeExposure.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GBase.

Definition at line 135 of file GCTACubeExposure.hpp.

void GCTACubeExposure::clear ( void  )
virtual

Clear instance.

This method properly resets the object to an initial state.

Implements GBase.

Definition at line 272 of file GCTACubeExposure.cpp.

References free_members(), and init_members().

Referenced by GCTAResponseCube::init_members(), and read().

GCTACubeExposure * GCTACubeExposure::clone ( void  ) const
virtual

Clone exposure cube.

Returns
Deep copy of exposure cube instance.

Implements GBase.

Definition at line 290 of file GCTACubeExposure.cpp.

References GCTACubeExposure().

void GCTACubeExposure::copy_members ( const GCTACubeExposure cube)
protected

Copy class members.

Parameters
[in]cubeExposure cube

Definition at line 602 of file GCTACubeExposure.cpp.

References m_cube, m_elogmeans, m_energies, m_filename, m_gti, m_inx_left, m_inx_right, m_livetime, m_wgt_left, and m_wgt_right.

Referenced by GCTACubeExposure(), and operator=().

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

Return exposure cube.

Returns
Exposure cube.

Returns the GSkyMap object that is used to store the exposure cube information.

Definition at line 150 of file GCTACubeExposure.hpp.

References m_cube.

double GCTACubeExposure::deadc ( void  ) const
inline
const GEnergies & GCTACubeExposure::energies ( void  ) const
inline

Return energies.

Returns
Energies

Definition at line 162 of file GCTACubeExposure.hpp.

References m_energies.

Referenced by GCTACubeExposure().

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

Return exposure cube filename.

Returns
Exposure cube filename.

Returns the filename from which the exposure cube was loaded or into which the exposure cube has been saved.

Definition at line 225 of file GCTACubeExposure.hpp.

References m_filename.

Referenced by load(), save(), and GCTAResponseCube::write().

void GCTACubeExposure::fill ( const GObservations obs,
GLog log = NULL 
)

Fill exposure cube from observation container.

Parameters
[in]obsObservation container.
[in]logPointer to logger.

Set the exposure cube by summing the exposure for all CTA observations in an observation container. The cube pixel values are computed as the sum over the products of the effective area and the livetime.

Definition at line 329 of file GCTACubeExposure.cpp.

References GGti::clear(), GCTAObservation::eventtype(), fill_cube(), GObservation::id(), GCTAObservation::instrument(), m_cube, m_gti, m_livetime, GObservation::name(), and GObservations::size().

void GCTACubeExposure::fill_cube ( const GCTAObservation obs,
GLog log = NULL 
)
protected

Fill exposure cube for one observation.

Parameters
[in]obsObservation.
[in]logPointer to logger.
Exceptions
GException::invalid_valueNo RoI or response found in CTA observation.

Fill the exposure cube from one CTA observations. The exposure cube pixel values are computed as the product of the effective area and the livetime.

Definition at line 644 of file GCTACubeExposure.cpp.

References GCTARoi::centre(), GCTAInstDir::dir(), GSkyDir::dist(), GCTAObservation::ebounds(), GCTAObservation::eventtype(), GGti::extend(), G_FILL_CUBE, GCTAObservation::gti(), GObservation::id(), GCTAObservation::instrument(), GSkyMap::inx2dir(), GGti::is_empty(), GCTARoi::is_valid(), GCTAObservation::livetime(), m_cube, m_energies, m_gti, m_livetime, GObservation::name(), GSkyMap::npix(), GSkyMap::overlaps(), GCTAObservation::pointing(), GCTARoi::radius(), GGti::reference(), GCTAObservation::response(), GCTAObservation::roi(), and GEnergies::size().

Referenced by fill(), and set().

void GCTACubeExposure::free_members ( void  )
protected

Delete class members.

Definition at line 625 of file GCTACubeExposure.cpp.

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

const GGti & GCTACubeExposure::gti ( void  ) const
inline

Return Good Time Intervals.

Returns
Good Time Intervals.

Definition at line 174 of file GCTACubeExposure.hpp.

References m_gti.

void GCTACubeExposure::init_members ( void  )
protected
const double & GCTACubeExposure::livetime ( void  ) const
inline
void GCTACubeExposure::load ( const GFilename filename)

Load exposure cube from FITS file.

Parameters
[in]filenamePerformance table file name.

Loads the exposure cube from a FITS file into the object.

Definition at line 451 of file GCTACubeExposure.cpp.

References GFits::close(), filename(), m_filename, and read().

Referenced by GCTACubeExposure(), and GCTAResponseCube::read().

const double & GCTACubeExposure::ontime ( void  ) const
inline

Return ontime.

Returns
Ontime (seconds).

Definition at line 198 of file GCTACubeExposure.hpp.

References m_gti, and GGti::ontime().

Referenced by GCTAObservation::response(), and write_attributes().

double GCTACubeExposure::operator() ( const GSkyDir dir,
const GEnergy energy 
) const

Return exposure (in units of cm**2 s)

Parameters
[in]dirCoordinate of the true photon position.
[in]energyEnergy of the true photon.
Returns
Exposure (in units of cm**2 s)

Definition at line 242 of file GCTACubeExposure.cpp.

References GEnergy::log10TeV(), m_cube, m_inx_left, m_inx_right, m_wgt_left, m_wgt_right, and update().

GCTACubeExposure & GCTACubeExposure::operator= ( const GCTACubeExposure cube)

Assignment operator.

Parameters
[in]cubeExposure cube.
Returns
Exposure cube.

Definition at line 214 of file GCTACubeExposure.cpp.

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

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

Print exposure cube information.

Parameters
[in]chatterChattiness.
Returns
String containing exposure cube information.
Todo:
Add content

Implements GBase.

Definition at line 520 of file GCTACubeExposure.cpp.

References m_cube, m_energies, m_filename, m_gti, m_livetime, gammalib::parformat(), GEnergies::print(), GGti::print(), GSkyMap::print(), SILENT, GGti::size(), GEnergies::size(), and gammalib::str().

Referenced by GCTAResponseCube::print().

void GCTACubeExposure::read ( const GFits fits)

Read exposure cube from FITS object.

Parameters
[in]fitsFITS object.

Read the exposure cube from a FITS object.

Definition at line 384 of file GCTACubeExposure.cpp.

References clear(), gammalib::extname_energies, gammalib::extname_gti, GFits::image(), m_cube, m_energies, m_gti, GGti::read(), GEnergies::read(), GSkyMap::read(), read_attributes(), set_eng_axis(), and GFits::table().

Referenced by load().

void GCTACubeExposure::read_attributes ( const GFitsHDU hdu)
protected

Read exposure attributes.

Parameters
[in]hduFITS HDU.

Reads CTA exposure attributes from the HDU.

Definition at line 822 of file GCTACubeExposure.cpp.

References GFitsHDU::has_card(), m_livetime, and GFitsHDU::real().

Referenced by read().

void GCTACubeExposure::save ( const GFilename filename,
const bool &  clobber = false 
) const

Save exposure cube into FITS file.

Parameters
[in]filenameExposure cube FITS file name.
[in]clobberOverwrite existing file?

Save the exposure cube into a FITS file.

Definition at line 484 of file GCTACubeExposure.cpp.

References GFits::close(), filename(), m_filename, GFits::saveto(), and write().

void GCTACubeExposure::set ( const GCTAObservation obs)

Set exposure cube for one CTA observation.

Parameters
[in]obsCTA observation.

Set the exposure cube for one CTA observation. The cube pixel values are computed as product of the effective area and the livetime.

Definition at line 304 of file GCTACubeExposure.cpp.

References GGti::clear(), fill_cube(), m_cube, m_gti, and m_livetime.

void GCTACubeExposure::set_eng_axis ( void  )
protected

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 794 of file GCTACubeExposure.cpp.

References GNodeArray::append(), GNodeArray::clear(), m_elogmeans, m_energies, and GEnergies::size().

Referenced by GCTACubeExposure(), and read().

void GCTACubeExposure::update ( const double &  logE) const
protected

Update 1D cache.

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

Todo:
Write down formula

Definition at line 773 of file GCTACubeExposure.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 operator()().

void GCTACubeExposure::write ( GFits fits) const

Write CTA exposure cube into FITS file.

Parameters
[in]fitsFITS file.

Writes the exposure cube image, the energies and the Good Time Intervals into the FITS file.

Definition at line 422 of file GCTACubeExposure.cpp.

References m_cube, m_energies, m_gti, GFits::size(), GGti::write(), GEnergies::write(), GSkyMap::write(), and write_attributes().

Referenced by save().

void GCTACubeExposure::write_attributes ( GFitsHDU hdu) const
protected

Write attributes to exposure extension.

Parameters
[in]hduFITS HDU.

Definition at line 837 of file GCTACubeExposure.cpp.

References GFitsHDU::card(), GTime::convert(), deadc(), m_gti, m_livetime, ontime(), GGti::ontime(), GGti::reference(), GGti::telapse(), GGti::tstart(), GGti::tstop(), and GTime::utc().

Referenced by write().

Member Data Documentation

GSkyMap GCTACubeExposure::m_cube
protected

Average Exposure cube.

Definition at line 112 of file GCTACubeExposure.hpp.

Referenced by copy_members(), cube(), fill(), fill_cube(), GCTACubeExposure(), init_members(), operator()(), print(), read(), set(), and write().

GNodeArray GCTACubeExposure::m_elogmeans
protected

Mean energy for the Exposure cube.

Definition at line 114 of file GCTACubeExposure.hpp.

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

GEnergies GCTACubeExposure::m_energies
protected

Energy values for the Exposure cube.

Definition at line 113 of file GCTACubeExposure.hpp.

Referenced by copy_members(), energies(), fill_cube(), GCTACubeExposure(), init_members(), print(), read(), set_eng_axis(), and write().

GFilename GCTACubeExposure::m_filename
mutableprotected

Filename.

Definition at line 111 of file GCTACubeExposure.hpp.

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

GGti GCTACubeExposure::m_gti
protected

Good time interval for the Exposure cube.

Definition at line 115 of file GCTACubeExposure.hpp.

Referenced by copy_members(), deadc(), fill(), fill_cube(), gti(), init_members(), ontime(), print(), read(), set(), write(), and write_attributes().

int GCTACubeExposure::m_inx_left
mutableprivate

Index of left node.

Definition at line 122 of file GCTACubeExposure.hpp.

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

int GCTACubeExposure::m_inx_right
mutableprivate

Index of right node.

Definition at line 123 of file GCTACubeExposure.hpp.

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

double GCTACubeExposure::m_livetime
protected
double GCTACubeExposure::m_wgt_left
mutableprivate

Weight of left node.

Definition at line 124 of file GCTACubeExposure.hpp.

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

double GCTACubeExposure::m_wgt_right
mutableprivate

Weight of right node.

Definition at line 125 of file GCTACubeExposure.hpp.

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


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