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

Interface for the Fermi/LAT effective area. More...

#include <GLATAeff.hpp>

Inheritance diagram for GLATAeff:
GBase

Public Member Functions

 GLATAeff (void)
 Void constructor. More...
 
 GLATAeff (const GFilename &filename, const std::string &evtype)
 File constructor. More...
 
 GLATAeff (const GLATAeff &aeff)
 Copy constructor. More...
 
virtual ~GLATAeff (void)
 Destructor. More...
 
GLATAeffoperator= (const GLATAeff &aeff)
 Assignment operator. More...
 
double operator() (const double &logE, const double &ctheta)
 Return effective area in units of cm2. More...
 
double operator() (const double &logE, const double &ctheta, const double &phi)
 Return effective area in units of cm2. More...
 
void clear (void)
 Clear effective area. More...
 
GLATAeffclone (void) const
 Clone effective area. More...
 
std::string classname (void) const
 Return class name. More...
 
const std::string & evtype (void) const
 Return event type. More...
 
void load (const GFilename &filename, const std::string &evtype)
 Load effective area from FITS file. More...
 
void save (const GFilename &filename, const bool &clobber=false)
 Save effective area into FITS file. More...
 
void read (const GFits &file, const std::string &evtype)
 Read effective area from FITS file. More...
 
void write (GFits &file) const
 Write effective area into FITS file. More...
 
int size (void) const
 Return number of bins in effective area response. More...
 
int nenergies (void) const
 Return number of energies in effective area response. More...
 
int ncostheta (void) const
 Return number of cosine theta bins in effective area response. More...
 
const double & costhetamin (void) const
 Return cosine theta minimum. More...
 
void costhetamin (const double &ctheta)
 Set minimum cos(theta) angle for effective area access. More...
 
bool has_phi (void) const
 Signal that effective area has Phi dependence. More...
 
bool has_efficiency (void) const
 Signals whether efficiency factors are present. More...
 
double efficiency_factor1 (const GEnergy &srcEng) const
 Returns efficiency factor 1. More...
 
double efficiency_factor2 (const GEnergy &srcEng) const
 Returns efficiency factor 2. More...
 
std::string print (const GChatter &chatter=NORMAL) const
 Print effective area 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 GLATAeff &aeff)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
void read_aeff (const GFitsTable &hdu)
 Read effective area from FITS table. More...
 
void read_efficiency (const GFitsTable &hdu)
 Read efficiency factor parameters from FITS table. More...
 
void write_aeff (GFits &file) const
 Write effective area into FITS file. More...
 
void write_efficiency (GFits &file) const
 Write efficiency factors into FITS file. More...
 

Private Attributes

std::string m_evtype
 Event type. More...
 
GLATResponseTable m_aeff_bins
 Aeff energy and cos theta binning. More...
 
std::vector< double > m_aeff
 Aeff array. More...
 
double m_min_ctheta
 Minimum valid cos(theta) More...
 
GLATEfficiencym_eff_func1
 Efficiency functor 1. More...
 
GLATEfficiencym_eff_func2
 Efficiency functor 2. More...
 

Detailed Description

Interface for the Fermi/LAT effective area.

This class handles the effective area information for Fermi/LAT. It also handles the IRF efficiency information that has been introduced for Pass 7 data analysis.

Definition at line 59 of file GLATAeff.hpp.

Constructor & Destructor Documentation

GLATAeff::GLATAeff ( void  )

Void constructor.

Definition at line 63 of file GLATAeff.cpp.

References init_members().

Referenced by clone().

GLATAeff::GLATAeff ( const GFilename filename,
const std::string &  evtype 
)

File constructor.

Parameters
[in]filenameFITS file name.
[in]evtypeEvent type.

Construct instance by loading the information from a FITS file. Both the effective area information and the efficiency factor parameters are loaded when available.

Definition at line 83 of file GLATAeff.cpp.

References init_members(), and load().

GLATAeff::GLATAeff ( const GLATAeff aeff)

Copy constructor.

Parameters
[in]aeffEffective area.

Definition at line 101 of file GLATAeff.cpp.

References copy_members(), and init_members().

GLATAeff::~GLATAeff ( void  )
virtual

Destructor.

Definition at line 117 of file GLATAeff.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GBase.

Definition at line 122 of file GLATAeff.hpp.

void GLATAeff::clear ( void  )
virtual

Clear effective area.

This method properly resets the object to an initial state.

Implements GBase.

Definition at line 229 of file GLATAeff.cpp.

References free_members(), and init_members().

Referenced by read().

GLATAeff * GLATAeff::clone ( void  ) const
virtual

Clone effective area.

Returns
Pointer to deep copy of effective area.

Implements GBase.

Definition at line 247 of file GLATAeff.cpp.

References GLATAeff().

void GLATAeff::copy_members ( const GLATAeff aeff)
private

Copy class members.

Parameters
[in]aeffEffective area.

Definition at line 516 of file GLATAeff.cpp.

References GLATEfficiency::clone(), m_aeff, m_aeff_bins, m_eff_func1, m_eff_func2, m_evtype, and m_min_ctheta.

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

const double & GLATAeff::costhetamin ( void  ) const
inline

Return cosine theta minimum.

Returns
Cosine theta minimum.

Definition at line 182 of file GLATAeff.hpp.

References m_min_ctheta.

void GLATAeff::costhetamin ( const double &  ctheta)
inline

Set minimum cos(theta) angle for effective area access.

Parameters
[in]cthetaCosine of maximum zenith angle.

Definition at line 194 of file GLATAeff.hpp.

References m_min_ctheta.

double GLATAeff::efficiency_factor1 ( const GEnergy srcEng) const

Returns efficiency factor 1.

Parameters
[in]srcEngTrue energy of photon.

Returns the efficiency factor 1 as function of the true photon energy.

If no efficiency factors are present returns 1.

Todo:
Implement cache to save computation time if called with same energy value (happens for binned analysis for example)

Definition at line 403 of file GLATAeff.cpp.

References GEnergy::log10MeV(), and m_eff_func2.

Referenced by GLATLtCube::operator()().

double GLATAeff::efficiency_factor2 ( const GEnergy srcEng) const

Returns efficiency factor 2.

Parameters
[in]srcEngTrue energy of photon.

Returns the efficiency factor 2 as function of the true photon energy.

If no efficiency factors are present returns 2.

Todo:
Implement cache to save computation time if called with same energy value (happens for binned analysis for example)

Definition at line 432 of file GLATAeff.cpp.

References GEnergy::log10MeV(), and m_eff_func1.

Referenced by GLATLtCube::operator()().

const std::string & GLATAeff::evtype ( void  ) const
inline

Return event type.

Returns
Event type.

Definition at line 134 of file GLATAeff.hpp.

References m_evtype.

Referenced by read().

void GLATAeff::free_members ( void  )
private

Delete class members.

Definition at line 536 of file GLATAeff.cpp.

References m_eff_func1, and m_eff_func2.

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

bool GLATAeff::has_efficiency ( void  ) const

Signals whether efficiency factors are present.

Verifies whether 2 efficiency factors are present. If efficiency factors are included in the effective area FITS file, they will be automatically loaded from the file, and efficiency factor functors will be allocated. Otherwise, the functors point towards NULL.

The method returns true if both efficiency factor functors exist, false otherwise.

Definition at line 384 of file GLATAeff.cpp.

References m_eff_func1, and m_eff_func2.

Referenced by GLATLtCube::operator()(), print(), and write_efficiency().

bool GLATAeff::has_phi ( void  ) const
inline

Signal that effective area has Phi dependence.

Returns
True if effective area has Phi dependence.

Definition at line 207 of file GLATAeff.hpp.

Referenced by GLATLtCubeMap::operator()().

void GLATAeff::init_members ( void  )
private

Initialise class members.

Definition at line 496 of file GLATAeff.cpp.

References GLATResponseTable::clear(), m_aeff, m_aeff_bins, m_eff_func1, m_eff_func2, m_evtype, and m_min_ctheta.

Referenced by clear(), GLATAeff(), and operator=().

void GLATAeff::load ( const GFilename filename,
const std::string &  evtype 
)

Load effective area from FITS file.

Parameters
[in]filenameFITS file.
[in]evtypeEvent type.

This method loads the effective area information, and if available, the efficiency factors, from the FITS response file. See the GLATAeff::read method for details.

Definition at line 263 of file GLATAeff.cpp.

References read().

Referenced by GLATAeff().

int GLATAeff::ncostheta ( void  ) const
inline

Return number of cosine theta bins in effective area response.

Returns
Number of cosine theta bins in effective area response.

Definition at line 170 of file GLATAeff.hpp.

References m_aeff_bins, and GLATResponseTable::ncostheta().

Referenced by print(), and size().

int GLATAeff::nenergies ( void  ) const
inline

Return number of energies in effective area response.

Returns
Number of energies in effective area response.

Definition at line 158 of file GLATAeff.hpp.

References m_aeff_bins, and GLATResponseTable::nenergies().

Referenced by print(), and size().

double GLATAeff::operator() ( const double &  logE,
const double &  ctheta 
)

Return effective area in units of cm2.

Parameters
[in]logELog10 of the true photon energy (MeV).
[in]cthetaCosine of zenith angle.

Returns the effective area in units of cm2 for a given energy and cos(theta) angle. The effective area is bi-linearily interpolated in the log10(energy) - cos(theta) plane. The method assures that the effective area value never becomes negative.

Definition at line 171 of file GLATAeff.cpp.

References GLATResponseTable::interpolate(), m_aeff, m_aeff_bins, and m_min_ctheta.

double GLATAeff::operator() ( const double &  logE,
const double &  ctheta,
const double &  phi 
)

Return effective area in units of cm2.

Parameters
[in]logELog10 of the true photon energy (MeV).
[in]cthetaCosine of zenith angle.
[in]phiAzimuth angle.

Returns the effective area in units of cm2 for a given energy, cos(theta) angle and azimuth angle. The effective area is bi-linearily interpolated in the log10(energy) - cos(theta) plane. The method assures that the effective area value never becomes negative.

Todo:
Phi-dependence not yet implemented.

Definition at line 201 of file GLATAeff.cpp.

References GLATResponseTable::interpolate(), m_aeff, m_aeff_bins, and m_min_ctheta.

GLATAeff & GLATAeff::operator= ( const GLATAeff aeff)

Assignment operator.

Parameters
[in]aeffEffective area.
Returns
Effective area.

Definition at line 139 of file GLATAeff.cpp.

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

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

Print effective area information.

Parameters
[in]chatterChattiness.
Returns
String containing effective area information.

Implements GBase.

Definition at line 455 of file GLATAeff.cpp.

References has_efficiency(), m_evtype, ncostheta(), nenergies(), gammalib::parformat(), SILENT, and gammalib::str().

void GLATAeff::read ( const GFits fits,
const std::string &  evtype 
)

Read effective area from FITS file.

Parameters
[in]fitsFITS file.
[in]evtypeEvent type.

Reads the effective area and efficiency parameter information form the FITS file. The effective area is read from the extension EFFECTIVE AREA (or EFFECTIVE AREA_<evtype> for Pass 8), the efficiency parameter information from the extension EFFICIENCY_PARAMS (or EFFICIENCY_PARAMS_<evtype> for Pass 8). If the latter extension does not exist, no efficiency parameters will be loaded.

Todo:
Implement reading of Phi-dependence information.

Definition at line 317 of file GLATAeff.cpp.

References clear(), GFits::contains(), evtype(), gammalib::extname_lat_aeff, gammalib::extname_lat_efficiency, m_evtype, read_aeff(), read_efficiency(), and GFits::table().

Referenced by load().

void GLATAeff::read_aeff ( const GFitsTable hdu)
private

Read effective area from FITS table.

Parameters
[in]hduFITS table.
Exceptions
GException::invalid_argumentInconsistent response table encountered

The effective area is converted into units of cm2.

Definition at line 561 of file GLATAeff.cpp.

References GLATResponseTable::costheta_lo(), G_READ_AEFF, m_aeff, m_aeff_bins, m_evtype, m_min_ctheta, GFitsTableCol::number(), GLATResponseTable::read(), GFitsTableCol::real(), GLATResponseTable::size(), size(), gammalib::str(), GFitsHDU::string(), and gammalib::strip_whitespace().

Referenced by read().

void GLATAeff::read_efficiency ( const GFitsTable hdu)
private

Read efficiency factor parameters from FITS table.

Parameters
[in]hduFITS table.

Reads the efficiency factor parameters from the EFFICIENCY_PARS column of the EFFICIENCY_PARAMS extension in the effective area file. Note that the column contains efficiency factor parameters for the front and back section of the LAT detector, and we read here only those factors that apply to the section for which the effective area has been defined. In that way, we keep the efficiency factors separate for each detector section, which is more precise than the handling in ScienceTools which apply average efficiency factors.

This method does not read efficiency factor parameters if neither the front nor the back section of the detector has been identified.

Definition at line 672 of file GLATAeff.cpp.

References m_eff_func1, m_eff_func2, m_evtype, GFitsTableCol::nrows(), and GFitsTableCol::real().

Referenced by read().

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

Save effective area into FITS file.

Parameters
[in]filenameFITS file.
[in]clobberOverwrite existing file? (default: false)

This method saves the effective area information, and if available, the efficiency factors, into the FITS response file. See the GLATAeff::write method for details.

Definition at line 286 of file GLATAeff.cpp.

References GFits::saveto(), and write().

int GLATAeff::size ( void  ) const
inline

Return number of bins in effective area response.

Returns
Number of bins in effective area response.

Definition at line 146 of file GLATAeff.hpp.

References ncostheta(), and nenergies().

Referenced by read_aeff(), and write_aeff().

void GLATAeff::write ( GFits fits) const

Write effective area into FITS file.

Parameters
[in]fitsFITS file.
Todo:
Write also phi and rate HDUs if they exist.

Definition at line 360 of file GLATAeff.cpp.

References write_aeff(), and write_efficiency().

Referenced by save().

void GLATAeff::write_aeff ( GFits file) const
private

Write effective area into FITS file.

Parameters
[in]fileFITS file.

This method does not write anything if the instance is empty.

Definition at line 616 of file GLATAeff.cpp.

References GFitsTable::append(), GFits::append(), GFitsHDU::card(), GFitsHDU::extname(), gammalib::extname_lat_aeff, m_aeff, m_aeff_bins, m_evtype, GLATResponseTable::size(), size(), and GLATResponseTable::write().

Referenced by write().

void GLATAeff::write_efficiency ( GFits file) const
private

Write efficiency factors into FITS file.

Parameters
[in]fileFITS file.

Writes efficiency factors into FITS file. The Pass 8 response format is used for writing the factors.

Definition at line 742 of file GLATAeff.cpp.

References GFitsTable::append(), GFits::append(), GFitsHDU::extname(), gammalib::extname_lat_efficiency, has_efficiency(), m_eff_func1, m_eff_func2, and GLATEfficiency::pars().

Referenced by write().

Member Data Documentation

std::vector<double> GLATAeff::m_aeff
private

Aeff array.

Definition at line 109 of file GLATAeff.hpp.

Referenced by copy_members(), init_members(), operator()(), read_aeff(), and write_aeff().

GLATResponseTable GLATAeff::m_aeff_bins
private

Aeff energy and cos theta binning.

Definition at line 108 of file GLATAeff.hpp.

Referenced by copy_members(), init_members(), ncostheta(), nenergies(), operator()(), read_aeff(), and write_aeff().

GLATEfficiency* GLATAeff::m_eff_func1
private
GLATEfficiency* GLATAeff::m_eff_func2
private
std::string GLATAeff::m_evtype
private

Event type.

Definition at line 107 of file GLATAeff.hpp.

Referenced by copy_members(), evtype(), init_members(), print(), read(), read_aeff(), read_efficiency(), and write_aeff().

double GLATAeff::m_min_ctheta
private

Minimum valid cos(theta)

Definition at line 110 of file GLATAeff.hpp.

Referenced by copy_members(), costhetamin(), init_members(), operator()(), and read_aeff().


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