47#define G_READ "GCTACubeBackground::read(GFits&)"
48#define G_MC "GCTACubeBackground::mc(GEnergy&, GTime&, GRan&)"
49#define G_FILL "GCTACubeBackground::fill(GObservations&, GLog*)"
54#define G_LOG_INTERPOLATION
170 const std::string& coords,
260 double background = 0.0;
279 if (background_left > 0.0 && background_right > 0.0) {
280 background = std::exp(
m_wgt_left * std::log(background_left) +
286 if (background < 0.0) {
346 const GEnergy energy_margin(0.01,
"GeV");
360 double total_ontime = 0.0;
363 for (
int i = 0; i < obs.
size(); ++i) {
373 *
log << obs[i]->instrument();
374 *
log <<
" observation ";
375 *
log <<
"\"" << obs[i]->name() <<
"\"";
376 *
log <<
" (id=" << obs[i]->id() <<
")" << std::endl;
384 *
log <<
"Skipping binned ";
386 *
log <<
" observation ";
387 *
log <<
"\"" << cta->
name() <<
"\"";
388 *
log <<
" (id=" << cta->
id() <<
")" << std::endl;
394 double ontime = cta->
ontime();
399 *
log <<
"Skipping unbinned ";
401 *
log <<
" observation ";
402 *
log <<
"\"" << cta->
name() <<
"\"";
403 *
log <<
" (id=" << cta->
id() <<
") due to zero ontime";
417 std::string msg =
"No RoI information found in input observation "
418 "\""+cta->
name()+
"\". Run ctselect to specify "
419 "an RoI for this observation";
427 *
log <<
"Skipping unbinned ";
429 *
log <<
" observation ";
430 *
log <<
"\"" << cta->
name() <<
"\"";
431 *
log <<
" (id=" << cta->
id() <<
") since it does not overlap ";
432 *
log <<
"with the background cube.";
440 *
log <<
"Including ";
442 *
log <<
" observation \"" << cta->
name();
443 *
log <<
"\" (id=" << cta->
id() <<
")";
444 *
log <<
" in background cube computation." << std::endl;
448 eventcube.
gti(cta->
gti());
451 int npix = eventcube.
npix();
455 for (
int ipix = 0; ipix < npix; ++ipix) {
470 for (
int iebin = 0, ibin = ipix; iebin < nebins; ++iebin, ibin += npix) {
485 double model = obs.
models().eval(*bin, *cta) * ontime;
500 total_ontime += ontime;
505 if (total_ontime > 0.0) {
509 for (
int i = 0; i < eventcube.
size(); ++i) {
511 double rate = bin->
counts() / total_ontime;
605 if (fits.
size() > 0) {
607 hdu.
card(
"BUNIT",
"MeV**(-1) s**(-1) sr**(-1)",
608 "Unit of background cube");
629 #pragma omp critical(GCTACubeBackground_load)
661 const bool& clobber)
const
664 #pragma omp critical(GCTACubeBackground_save)
704 result.append(
"=== GCTACubeBackground ===");
805 for (
int i = 0; i < bins; ++i) {
CTA cube background class definition.
CTA event bin container class interface definition.
CTA instrument direction class interface definition.
CTA observation class interface definition.
CTA region of interest class interface definition.
Exception handler interface definition.
FITS binary table class definition.
FITS file class interface definition.
Information logger class definition.
Mathematical function definitions.
Observations container class interface definition.
Random number generator class definition.
Circular sky region class interface definition.
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
CTA cube background class.
GFilename m_filename
Name of background response file.
void init_members(void)
Initialise class members.
void load(const GFilename &filename)
Load background cube from FITS file.
void set_eng_axis(void)
Set nodes for a logarithmic (base 10) energy axis.
void clear(void)
Clear background.
double integral(const double &logE) const
Return spatially integrated background rate in units of events MeV s .
int m_inx_left
Index of left node.
GCTACubeBackground & operator=(const GCTACubeBackground &bgd)
Assignment operator.
void copy_members(const GCTACubeBackground &bgd)
Copy class members.
GCTACubeBackground * clone(void) const
Clone background.
void update(const double &logE) const
Update 1D cache.
const GFilename & filename(void) const
Return background cube filename.
double m_wgt_left
Weight of left node.
GCTACubeBackground(void)
Void constructor.
std::string print(const GChatter &chatter=NORMAL) const
Print background information.
void free_members(void)
Delete class members.
void write(GFits &file) const
Write CTA background cube into FITS object.
GEbounds m_ebounds
Energy boundaries of background cube.
const GSkyMap & cube(void) const
Return background cube.
double m_wgt_right
Weight of right node.
void fill(const GObservations &obs, GLog *log=NULL)
Fill background cube from observation container.
virtual ~GCTACubeBackground(void)
Destructor.
GSkyMap m_cube
Background cube.
GNodeArray m_elogmeans
Mean energy for the background cube.
double operator()(const GCTAInstDir &dir, const GEnergy &energy) const
Return background rate in units of events MeV s sr .
void read(const GFits &fits)
Read background cube from FITS object.
int m_inx_right
Index of right node.
void save(const GFilename &filename, const bool &clobber=false) const
Save background cube into FITS file.
const GEbounds & ebounds(void) const
Return energy boundaries.
GCTAEventBin class interface definition.
virtual double counts(void) const
Return number of counts in event bin.
virtual const GCTAInstDir & dir(void) const
Return instrument direction of event bin.
virtual const GEnergy & energy(void) const
Return energy of event bin.
CTA event bin container class.
virtual int size(void) const
Return number of bins in event cube.
int npix(void) const
Return number of pixels in one energy bins of the event cube.
void counts(const GSkyMap &counts)
Set event cube counts from sky map.
CTA instrument direction class.
void dir(const GSkyDir &dir)
Set sky direction.
void pointing(const GCTAPointing &pointing)
Set CTA pointing.
GGti gti(void) const
Get Good Time Intervals.
std::string eventtype(void) const
Return event type string.
virtual std::string instrument(void) const
Return instrument name.
GCTARoi roi(void) const
Get Region of Interest.
virtual double ontime(void) const
Return ontime.
GEbounds ebounds(void) const
Get energy boundaries.
Interface for the CTA region of interest class.
const double & radius(void) const
Returns radius of region of interest in degrees.
virtual bool contains(const GEvent &event) const
Check if region of interest contains an event.
bool is_valid(void) const
Checks if RoI is valid.
const GCTAInstDir & centre(void) const
Returns region of interest centre.
Energy boundaries container class.
const GEnergy & emax(void) const
Return maximum energy of all intervals.
bool contains(const GEnergy &eng) const
Checks whether energy boundaries contain energy.
void read(const GFitsTable &table)
Read energy boundaries from FITS table.
std::string print(const GChatter &chatter=NORMAL) const
Print energy boundaries.
int size(void) const
Return number of energy boundaries.
void clear(void)
Clear energy boundaries.
GEnergy elogmean(const int &index) const
Returns logarithmic mean energy for a given energy interval.
const GEnergy & emin(void) const
Return minimum energy of all intervals.
void write(GFits &file, const std::string &extname=gammalib::extname_ebounds, const std::string &unit="keV") const
Write energy boundaries into FITS object.
Class that handles energies in a unit independent way.
double log10TeV(void) const
Return log10 of energy in TeV.
void gti(const GGti >i)
Set Good Time Intervals.
void clear(void)
Clear file name.
Abstract FITS extension base class.
GFitsHeaderCard & card(const int &cardno)
Return header card.
Abstract FITS image base class.
Abstract interface for FITS table.
void saveto(const GFilename &filename, const bool &clobber=false)
Saves to specified FITS file.
int size(void) const
Return number of HDUs in FITS file.
GFitsImage * image(const int &extno)
Get pointer to image HDU.
void close(void)
Close FITS file.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
Good Time Interval class.
Information logger interface definition.
void set_value(const double &value) const
Set indices and weighting factors for interpolation.
const int & inx_right(void) const
Returns right node index.
const int & inx_left(void) const
Returns left node index.
const double & wgt_right(void) const
Returns right node weight.
const double & wgt_left(void) const
Returns left node weight.
void clear(void)
Clear node array.
void append(const double &node)
Append one node to array.
void name(const std::string &name)
Set observation name.
void id(const std::string &id)
Set observation identifier.
Observation container class.
int size(void) const
Return number of observations in container.
void models(const GModels &models)
Set model container.
double solidangle(const int &index) const
Returns solid angle of pixel.
const int & nmaps(void) const
Returns number of maps.
void clear(void)
Clear instance.
void read(const GFitsHDU &hdu)
Read skymap from FITS HDU.
const int & npix(void) const
Returns number of pixels.
GNdarray counts(void) const
Returns array with total number of counts for count maps.
GFitsHDU * write(GFits &file, const std::string &extname="") const
Write sky map into FITS file.
bool overlaps(const GSkyRegion ®ion) const
Checks whether a region overlaps with this map.
std::string print(const GChatter &chatter=NORMAL) const
Print sky map.
Interface for the circular sky region class.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
const std::string extname_ebounds