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) {
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;
555 result += value * m_cube.solidangle(i);
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)
633 GFits fits(filename);
661 const bool& clobber)
const
664 #pragma omp critical(GCTACubeBackground_save)
674 fits.
saveto(filename, clobber);
704 result.append(
"=== GCTACubeBackground ===");
805 for (
int i = 0; i < bins; ++i) {
Abstract FITS image base class.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
void init_members(void)
Initialise class members.
GEbounds m_ebounds
Energy boundaries of background cube.
void free_members(void)
Delete class members.
Random number generator class definition.
virtual const GCTAInstDir & dir(void) const
Return instrument direction of event bin.
GVector abs(const GVector &vector)
Computes absolute of vector elements.
const GFilename & filename(void) const
Return background cube filename.
void ebounds(const GEbounds &ebounds)
Set energy boundaries.
Abstract FITS extension base class.
bool overlaps(const GSkyRegion ®ion) const
Checks whether a region overlaps with this map.
int size(void) const
Return number of energy boundaries.
GCTAEventBin class interface definition.
CTA cube background class.
GCTACubeBackground(void)
Void constructor.
GEbounds ebounds(void) const
Get energy boundaries.
bool contains(const GEnergy &eng) const
Checks whether energy boundaries contain energy.
const double & radius(void) const
Returns radius of region of interest in degrees.
const double & wgt_left(void) const
Returns left node weight.
void gti(const GGti >i)
Set Good Time Intervals.
void models(const GModels &models)
Set model container.
void clear(void)
Clear node array.
void counts(const GSkyMap &counts)
Set event cube counts from sky map.
double log10TeV(void) const
Return log10 of energy in TeV.
std::string print(const GChatter &chatter=NORMAL) const
Print background information.
Interface for the CTA region of interest class.
void read(const GFitsTable &table)
Read energy boundaries from FITS table.
virtual const GEnergy & energy(void) const
Return energy of event bin.
FITS file class interface definition.
Interface for the circular sky region class.
void set_value(const double &value) const
Set indices and weighting factors for interpolation.
void pointing(const GCTAPointing &pointing)
Set CTA pointing.
void read(const GFitsHDU &hdu)
Read skymap from FITS HDU.
void dir(const GSkyDir &dir)
Set sky direction.
void write(GFits &file, const std::string &extname=gammalib::extname_ebounds, const std::string &unit="keV") const
Write energy boundaries into FITS object.
void update(const double &logE) const
Update 1D cache.
void id(const std::string &id)
Set observation identifier.
void write(GFits &file) const
Write CTA background cube into FITS object.
int m_inx_right
Index of right node.
virtual ~GCTACubeBackground(void)
Destructor.
GCTACubeBackground * clone(void) const
Clone background.
GFilename m_filename
Name of background response file.
CTA cube background class definition.
virtual double ontime(void) const
Return ontime.
double m_wgt_left
Weight of left node.
void saveto(const GFilename &filename, const bool &clobber=false)
Saves to specified FITS file.
std::string print(const GChatter &chatter=NORMAL) const
Print sky map.
void read(const GFits &fits)
Read background cube from FITS object.
Information logger interface definition.
void set_eng_axis(void)
Set nodes for a logarithmic (base 10) energy axis.
CTA event bin container class.
GNodeArray m_elogmeans
Mean energy for the background cube.
void clear(void)
Clear background.
const GEbounds & ebounds(void) const
Return energy boundaries.
int npix(void) const
Return number of pixels in one energy bins of the event cube.
const double & wgt_right(void) const
Returns right node weight.
Energy boundaries container class.
const int & nmaps(void) const
Returns number of maps.
GCTARoi roi(void) const
Get Region of Interest.
GFitsHDU * write(GFits &file, const std::string &extname="") const
Write sky map into FITS file.
const GEnergy & emin(void) const
Return minimum energy of all intervals.
GGti gti(void) const
Get Good Time Intervals.
const GCTAInstDir & centre(void) const
Returns region of interest centre.
virtual std::string instrument(void) const
Return instrument name.
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
const std::string extname_ebounds
CTA instrument direction class interface definition.
Abstract interface for FITS table.
virtual bool contains(const GEvent &event) const
Check if region of interest contains an event.
std::string print(const GChatter &chatter=NORMAL) const
Print energy boundaries.
int m_inx_left
Index of left node.
GEnergy elogmean(const int &index) const
Returns logarithmic mean energy for a given energy interval.
const int & inx_left(void) const
Returns left node index.
void clear(void)
Clear instance.
Good Time Interval class.
double integral(const double &logE) const
Return spatially integrated background rate in units of events MeV s .
int size(void) const
Return number of observations in container.
void copy_members(const GCTACubeBackground &bgd)
Copy class members.
GCTACubeBackground & operator=(const GCTACubeBackground &bgd)
Assignment operator.
void clear(void)
Clear energy boundaries.
CTA region of interest class interface definition.
CTA observation class interface definition.
Observation container class.
void load(const GFilename &filename)
Load background cube from FITS file.
const int & inx_right(void) const
Returns right node index.
void name(const std::string &name)
Set observation name.
GFitsImage * image(const int &extno)
Get pointer to image HDU.
Information logger class definition.
void clear(void)
Clear file name.
void fill(const GObservations &obs, GLog *log=NULL)
Fill background cube from observation container.
int size(void) const
Return number of HDUs in FITS file.
void save(const GFilename &filename, const bool &clobber=false) const
Save background cube into FITS file.
CTA event bin container class interface definition.
std::string eventtype(void) const
Return event type string.
bool is_valid(void) const
Checks if RoI is valid.
Exception handler interface definition.
FITS binary table class definition.
double m_wgt_right
Weight of right node.
double operator()(const GCTAInstDir &dir, const GEnergy &energy) const
Return background rate in units of events MeV s sr .
GVector exp(const GVector &vector)
Computes exponential of vector elements.
CTA instrument direction class.
const GEnergy & emax(void) const
Return maximum energy of all intervals.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
void append(const double &node)
Append one node to array.
const int & npix(void) const
Returns number of pixels.
GFitsHeaderCard & card(const int &cardno)
Return header card.
Observations container class interface definition.
void close(void)
Close FITS file.
virtual double counts(void) const
Return number of counts in event bin.
Circular sky region class interface definition.
Mathematical function definitions.
Class that handles energies in a unit independent way.
GSkyMap m_cube
Background cube.
virtual int size(void) const
Return number of bins in event cube.