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

CTA cube background class. More...

#include <GCTACubeBackground.hpp>

Inheritance diagram for GCTACubeBackground:
GBase

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...
 
GCTACubeBackgroundoperator= (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...
 
GCTACubeBackgroundclone (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 GSkyMapcube (void) const
 Return background cube. More...
 
const GEboundsebounds (void) const
 Return energy boundaries. More...
 
const GFilenamefilename (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...
 

Detailed Description

CTA cube background class.

Definition at line 50 of file GCTACubeBackground.hpp.

Constructor & Destructor Documentation

GCTACubeBackground::GCTACubeBackground ( void  )

Void constructor.

Definition at line 72 of file GCTACubeBackground.cpp.

References init_members().

Referenced by clone().

GCTACubeBackground::GCTACubeBackground ( const GFilename filename)
explicit

File constructor.

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

GCTACubeBackground::GCTACubeBackground ( const GCTAEventCube cube)
explicit

Event cube constructor.

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

Parameters
[in]bgdBackground.

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.

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]eboundsEnergy 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().

GCTACubeBackground::~GCTACubeBackground ( void  )
virtual

Destructor.

Definition at line 199 of file GCTACubeBackground.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GBase.

Definition at line 119 of file GCTACubeBackground.hpp.

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

GCTACubeBackground * GCTACubeBackground::clone ( void  ) const
virtual

Clone background.

Returns
Pointer to deep copy of background.

Implements GBase.

Definition at line 324 of file GCTACubeBackground.cpp.

References GCTACubeBackground().

void GCTACubeBackground::copy_members ( const GCTACubeBackground bgd)
private

Copy class members.

Parameters
[in]bgdBackground.

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=().

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

Return background cube.

Returns
Sky map holding the 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.

const GEbounds & GCTACubeBackground::ebounds ( void  ) const
inline

Return energy boundaries.

Returns
Energy boundaries

Definition at line 146 of file GCTACubeBackground.hpp.

References m_ebounds.

Referenced by GCTACubeBackground().

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

Return background cube filename.

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

Parameters
[in]obsObservation container.
[in]logPointer to logger (optional).
Exceptions
GException::invalid_valueNo 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().

void GCTACubeBackground::free_members ( void  )
private

Delete class members.

Definition at line 783 of file GCTACubeBackground.cpp.

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

void GCTACubeBackground::init_members ( void  )
private
double GCTACubeBackground::integral ( const double &  logE) const

Return spatially integrated background rate in units of events MeV \(^{-1}\) s \(^{-1}\).

Parameters
[in]logELogarithm (base 10) of energy in TeV
Returns
Spatially integrated background rate (events MeV \(^{-1}\) s \(^{-1}\))

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.

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

Parameters
[in]dirReconstructed event position where rate should be computed
[in]energyEnergy at which the rate should be computed
Returns
Background rate (events MeV \(^{-1}\) s \(^{-1}\) sr \(^{-1}\)).

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.

Parameters
[in]bgdBackground cube.
Returns
Background cube.

Definition at line 221 of file GCTACubeBackground.cpp.

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

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

Print background information.

Parameters
[in]chatterChattiness.
Returns
String containing background information.

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.

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

Parameters
[in]filenamebackground cube FITS file name.
[in]clobberOverwrite 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().

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

void GCTACubeBackground::update ( const double &  logE) const
private

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

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

Member Data Documentation

GSkyMap GCTACubeBackground::m_cube
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().

GEbounds GCTACubeBackground::m_ebounds
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().

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

GFilename GCTACubeBackground::m_filename
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().

int GCTACubeBackground::m_inx_left
mutableprivate

Index of left node.

Definition at line 105 of file GCTACubeBackground.hpp.

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

int GCTACubeBackground::m_inx_right
mutableprivate

Index of right node.

Definition at line 106 of file GCTACubeBackground.hpp.

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

double GCTACubeBackground::m_wgt_left
mutableprivate

Weight of left node.

Definition at line 107 of file GCTACubeBackground.hpp.

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

double GCTACubeBackground::m_wgt_right
mutableprivate

Weight of right node.

Definition at line 108 of file GCTACubeBackground.hpp.

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


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