62#define G_RESPONSE_SET "GCTAObservation::response(GResponse&)"
63#define G_RESPONSE_GET "GCTAObservation::response()"
64#define G_ROI "GCTAObservation::roi()"
65#define G_GTI "GCTAObservation::gti()"
66#define G_EBOUNDS "GCTAObservation::ebounds()"
67#define G_READ "GCTAObservation::read(GXmlElement&)"
68#define G_WRITE "GCTAObservation::write(GXmlElement&)"
69#define G_LOAD1 "GCTAObservation::load(GFilename&, GFilename&, "\
70 "GFilename&, GFilename&)"
71#define G_LOAD2 "GCTAObservation::load(GFilename&, GFilename&, "\
72 "GFilename&, GFilename&, GFilename&)"
117 const std::string& instrument) :
171 load(cntcube, expcube, psfcube, bkgcube);
200 load(cntcube, expcube, psfcube, edispcube, bkgcube);
360 std::string msg =
"No valid response function found in CTA "
496 std::string msg =
"Region of Interest is not defined since the "
497 "observation does not contain events.";
504 std::string msg =
"Region of Interest is not defined since the "
505 "observation does not contain an event list.";
510 return (list->
roi());
529 std::string msg =
"Good Time Intervals are not defined since the "
530 "observation does not contain events.";
554 std::string msg =
"Energy boundaries are not defined since the "
555 "observation does not contain events.";
673 std::string msg =
"Invalid statistic \""+
statistic+
"\" encountered "
674 "in observation definition XML file for "
676 "\""+xml.
attribute(
"id")+
"\". Only \"POISSON\", "
677 "\"CSTAT\", \"GAUSSIAN\" or \"CHI2\" are "
688 int npars = xml.
elements(
"parameter");
691 if (xml.
elements() < 1 || npars < 1) {
692 std::string msg =
"CTA observation contains "+
gammalib::str(npars)+
693 " parameters but at least one parameter is required. "
694 "Please verify the XML format.";
700 for (
int i = 0; i < npars; ++i) {
706 if ((par->
attribute(
"name") ==
"EventList") ||
707 (par->
attribute(
"name") ==
"CountsCube")) {
721 else if (par->
attribute(
"name") ==
"Background") {
729 else if (par->
attribute(
"name") ==
"OffRegions") {
743 bool has_evfile = (n_evfile > 0);
758 bool has_ebounds =
false;
759 bool has_gti =
false;
760 bool has_roi =
false;
788 if (has_ebounds || has_gti || has_roi) {
821 int response_type = 0;
822 for (
int i = 0; i < npars; ++i) {
828 if ((par->
attribute(
"name") ==
"EffectiveArea") ||
830 (par->
attribute(
"name") ==
"PointSpreadFunction") ||
832 (par->
attribute(
"name") ==
"EnergyDispersion") ||
834 (par->
attribute(
"name") ==
"Background") ||
835 (par->
attribute(
"name") ==
"Calibration")) {
836 if (response_type == 2) {
837 std::string msg =
"Response cube parameters expected but the "
838 "IRF response parameter \""+
839 par->
attribute(
"name")+
"\" was encountered. "
840 "Please verify the XML format.";
847 else if ((par->
attribute(
"name") ==
"ExposureCube") ||
850 if (response_type == 1) {
851 std::string msg =
"IRF response parameters expected but the "
852 "response cube parameter \""+
853 par->
attribute(
"name")+
"\" was encountered. "
854 "Please verify the XML format.";
863 switch (response_type) {
970 if ((evttype !=
"EventList") && (evttype !=
"CountsCube")) {
972 if (evttype.empty()) {
973 msg =
"The observation does not contain any events, hence "
974 "it cannot be written into an XML file.";
977 msg =
"The observation contains an unknown event type \""+
978 evttype+
"\". The event type needs to be either "
979 "\"EventList\" or \"CountsCube\".";
1018 list->
roi().write(xml);
1133 const std::string& gtiname)
const
1151 list->
write(fits, evtname, gtiname);
1162 else if (cube != NULL) {
1189 #pragma omp critical(GCTAObservation_load)
1195 GFits fits(filename);
1230 std::string msg =
"Specified file \""+cntcube.
url()+
"\" is not a CTA "
1231 "counts cube. Please provide a counts cube.";
1246 response(exposure, psf, background);
1276 std::string msg =
"Specified file \""+cntcube.
url()+
"\" is not a CTA "
1277 "counts cube. Please provide a counts cube.";
1295 response(exposure, psf, edisp, background);
1327 const bool& clobber)
const
1338 if (extnames.size() > 0) {
1341 if (extnames.size() > 1) {
1352 write(fits, evtname, gtiname);
1446 result.append(
"=== GCTAObservation ===");
1466 result.append(
" - ");
1468 result.append(
" TeV");
1471 result.append(
"> ");
1473 result.append(
" TeV");
1476 result.append(
"< ");
1478 result.append(
" TeV");
1481 result.append(
"undefined");
1486 if (reduced_chatter >
SILENT) {
1497 result.append(
"undefined");
1631 double ra_pnt = hdu.
real(
"RA_PNT");
1632 double dec_pnt = hdu.
real(
"DEC_PNT");
1641 std::string
id = (hdu.
has_card(
"OBS_ID")) ? hdu.
string(
"OBS_ID") :
"";
1642 double alt = (hdu.
has_card(
"ALT_PNT")) ? hdu.
real(
"ALT_PNT") : 0.0;
1643 double az = (hdu.
has_card(
"AZ_PNT")) ? hdu.
real(
"AZ_PNT") : 0.0;
1694 double telapse =
events()->
gti().telapse();
1700 std::string date_obs = utc_obs.substr(0, 10);
1701 std::string time_obs = utc_obs.substr(11, 8);
1702 std::string date_end = utc_end.substr(0, 10);
1703 std::string time_end = utc_end.substr(11, 8);
1706 hdu.
card(
"CREATOR",
"GammaLib",
"Program which created the file");
1708 hdu.
card(
"OBS_ID",
id(),
"Observation identifier");
1709 hdu.
card(
"DATE-OBS", date_obs,
"Observation start date");
1710 hdu.
card(
"TIME-OBS", time_obs,
"Observation start time");
1711 hdu.
card(
"DATE-END", date_end,
"Observation end date");
1712 hdu.
card(
"TIME-END", time_end,
"Observation end time");
1715 hdu.
card(
"TSTART", tstart,
"[s] Mission time of start of observation");
1716 hdu.
card(
"TSTOP", tstop,
"[s] Mission time of end of observation");
1718 hdu.
card(
"TELAPSE", telapse,
"[s] Mission elapsed time");
1719 hdu.
card(
"ONTIME",
ontime,
"[s] Total good time including deadtime");
1720 hdu.
card(
"LIVETIME",
livetime(),
"[s] Total livetime");
1721 hdu.
card(
"DEADC",
deadc,
"Deadtime correction factor");
1722 hdu.
card(
"TIMEDEL", 1.0,
"Time resolution");
1725 hdu.
card(
"OBJECT",
object(),
"Observed object");
1726 hdu.
card(
"RA_OBJ",
ra_obj(),
"[deg] Target Right Ascension");
1727 hdu.
card(
"DEC_OBJ",
dec_obj(),
"[deg] Target Declination");
1728 hdu.
card(
"RA_PNT", ra_pnt,
"[deg] Pointing Right Ascension");
1729 hdu.
card(
"DEC_PNT", dec_pnt,
"[deg] Pointing Declination");
1730 hdu.
card(
"ALT_PNT", alt,
"[deg] Average altitude of pointing");
1731 hdu.
card(
"AZ_PNT", az,
"[deg] Average azimuth of pointing");
1732 hdu.
card(
"RADECSYS",
"FK5",
"Coordinate system");
1733 hdu.
card(
"EQUINOX", 2000.0,
"Epoch");
1734 hdu.
card(
"CONV_DEP", 0.0,
"Convergence depth of telescopes");
1735 hdu.
card(
"CONV_RA", 0.0,
"[deg] Convergence Right Ascension");
1736 hdu.
card(
"CONV_DEC", 0.0,
"[deg] Convergence Declination");
1737 hdu.
card(
"OBSERVER",
"string",
"Observer");
1740 hdu.
card(
"N_TELS",
n_tels(),
"Number of telescopes in event list");
1741 hdu.
card(
"TELLIST",
"string",
"Telescope IDs");
1742 hdu.
card(
"GEOLAT", 0.0,
"[deg] Geographic latitude of array centre");
1743 hdu.
card(
"GEOLON", 0.0,
"[deg] Geographic longitude of array centre");
1744 hdu.
card(
"ALTITUDE", 0.0,
"[km] Altitude of array centre");
1747 hdu.
card(
"EUNIT",
"TeV",
"Energy unit");
1748 hdu.
card(
"EVTVER",
"draft1",
"Event list version number");
CTA event bin container class interface definition.
CTA event list class interface definition.
const GCTAObservation g_obs_magic_seed(true, "MAGIC")
const GCTAObservation g_obs_cta_seed(true, "CTA")
const GCTAObservation g_obs_fact_seed(true, "FACT")
const GCTAObservation g_obs_astri_seed(true, "ASTRI")
const GCTAObservation g_obs_veritas_seed(true, "VERITAS")
const GCTAObservation g_obs_hess_seed(true, "HESS")
CTA observation class interface definition.
CTA cube-style response function class definition.
CTA instrument response function class definition.
CTA region of interest class interface definition.
Definition of support function used by CTA classes.
Exception handler interface definition.
Filename class interface definition.
FITS file class interface definition.
Good time interval class interface definition.
Integration class interface definition.
Observation registry class definition.
CTA cube background class.
CTA energy dispersion for stacked analysis.
const double & ontime(void) const
Return ontime.
double deadc(void) const
Return deadtime correction.
const double & livetime(void) const
Return livetime.
CTA point spread function for cube analysis.
CTA event bin container class.
virtual void write(GFits &file) const
Write CTA event cube into FITS file.
void dispose(void) const
Dispose events.
virtual void roi(const GRoi &roi)
Set ROI.
virtual void write(GFits &fits) const
Write CTA events and Good Time Intervals into FITS file.
double m_ra_obj
Right Ascension of object (degrees)
GCTAResponse * m_response
Pointer to instrument response functions.
GGti gti(void) const
Get Good Time Intervals.
virtual GCTAObservation * clone(void) const
Clone CTA observation.
const int & n_tels(void) const
Return number of telescopes.
GFilename m_eventfile
Event filename.
void load(const GFilename &filename)
Load unbinned or binned analysis data.
double m_hi_user_thres
User defined upper energy boundary.
virtual double livetime(void) const
Return livetime.
void write_attributes(GFitsHDU &hdu) const
Write observation attributes.
std::string m_instrument
Instrument name.
std::string eventtype(void) const
Return event type string.
const double & dec_obj(void) const
Return CTA object Declination.
int m_n_tels
Number of telescopes.
void free_members(void)
Delete class members.
virtual const GCTAResponse * response(void) const
Return pointer to CTA response function.
const GSkyRegions & off_regions(void) const
Return sky off regions.
const GFilename & eventfile(void) const
Return event file name.
virtual ~GCTAObservation(void)
Destructor.
double m_deadc
Deadtime correction (livetime/ontime)
double m_lo_user_thres
User defined lower energy threshold.
const GCTAPointing & pointing(void) const
Return CTA pointing.
std::string m_bgdfile
Background filename.
void init_members(void)
Initialise class members.
void copy_members(const GCTAObservation &obs)
Copy class members.
GSkyRegions m_off_regions
Off regions.
virtual std::string instrument(void) const
Return instrument name.
void save(const GFilename &filename, const bool &clobber=false) const
Save CTA observation into FITS file.
double m_livetime
Livetime (seconds)
GCTARoi roi(void) const
Get Region of Interest.
virtual void write(GXmlElement &xml) const
Write observation into XML element.
GCTAObservation(void)
Void constructor.
virtual void clear(void)
Clear CTA observation.
virtual void read(const GXmlElement &xml)
Read observation from XML element.
void dispose_events(void)
Dispose events.
void read_attributes(const GFitsHDU &hdu)
Read observation attributes.
GCTAPointing m_pointing
Pointing direction.
virtual double ontime(void) const
Return ontime.
virtual double deadc(const GTime &time=GTime()) const
Return deadtime correction factor.
std::string m_object
Object name.
const double & ra_obj(void) const
Return CTA object Right Ascension.
GEbounds ebounds(void) const
Get energy boundaries.
double m_ontime
Ontime (seconds)
GCTAObservation & operator=(const GCTAObservation &obs)
Assignment operator.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print CTA observation information.
double m_dec_obj
Declination of object (degrees)
const double & zenith(void) const
Return pointing zenith angle.
void read(const GXmlElement &xml)
Read pointing from XML element.
const GSkyDir & dir(void) const
Return pointing sky direction.
const double & azimuth(void) const
Return pointing azimuth angle.
void clear(void)
Clear CTA pointing.
void write(GXmlElement &xml) const
Write pointing information into XML element.
CTA cube-style response function class.
CTA instrument response function class.
void load(const std::string &rspname)
Load CTA response.
void caldb(const GCaldb &caldb)
Set calibration database.
CTA instrument response function class.
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
virtual void read(const GXmlElement &xml)=0
virtual GCTAResponse * clone(void) const =0
Clones object.
virtual void write(GXmlElement &xml) const =0
Interface for the CTA region of interest class.
void read(const GXmlElement &xml)
Read region of interest from XML element.
Calibration database class.
Energy boundaries container class.
void read(const GFitsTable &table)
Read energy boundaries from FITS table.
void gti(const GGti >i)
Set Good Time Intervals.
virtual void read(const GFits &file)=0
void ebounds(const GEbounds &ebounds)
Set energy boundaries.
const GTime & tstart(void) const
Return start time.
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
const GTime & tstop(void) const
Return stop time.
bool has_extname(void) const
Signal if filename has an extension name.
std::string url(void) const
Return Uniform Resource Locator (URL)
std::string extname(const std::string &defaultname="") const
Return extension name.
bool is_empty(void) const
Signal if filename is empty.
void clear(void)
Clear file name.
Abstract FITS extension base class.
bool has_card(const int &cardno) const
Check existence of header card.
double real(const std::string &keyname) const
Return card value as double precision.
std::string string(const std::string &keyname) const
Return card value as string.
GFitsHeaderCard & card(const int &cardno)
Return header card.
int integer(const std::string &keyname) const
Return card value as integer.
bool contains(const int &extno) const
Check if HDU exists in FITS file.
void close(void)
Close FITS file.
void remove(const int &extno)
Remove HDU from FITS file.
GFitsHDU * at(const int &extno)
Get pointer to HDU.
void save(const bool &clobber=false)
Saves FITS file.
const GFilename & filename(void) const
Return FITS filename.
Good Time Interval class.
void read(const GFitsTable &table)
Read Good Time Intervals and time reference from FITS table.
const double & ontime(void) const
Returns ontime.
Interface definition for the observation registry class.
Abstract observation base class.
const std::string & statistic(void) const
Return optimizer statistic.
const std::string & id(void) const
Return observation identifier.
const std::string & name(void) const
Return observation name.
virtual GEvents * events(void)
Return events.
void init_members(void)
Initialise class members.
virtual GObservation & operator=(const GObservation &obs)
Assignment operator.
GEvents * m_events
Pointer to event container.
void free_members(void)
Delete class members.
Abstract instrument response base class.
double dec_deg(void) const
Returns Declination in degrees.
double ra_deg(void) const
Returns Right Ascension in degrees.
void radec_deg(const double &ra, const double &dec)
Set equatorial sky direction (degrees)
Sky region container class.
const GFilename & filename(void) const
Return regions file name.
void clear(void)
Clear object.
Implements a time reference.
void write(GFitsHDU &hdu) const
Write time reference into FITS header.
double convert(const GTimeReference &ref) const
Return time in specified reference.
std::string utc(const int &precision=0) const
Return time as string in UTC time system.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
virtual GXmlElement * element(const int &index)
Return pointer to GXMLElement child.
virtual int elements(void) const
Return number of GXMLElement children of node.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
const GXmlElement * xml_get_par(const std::string &origin, const GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
double todouble(const std::string &arg)
Convert string into double precision value.
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
GFilename xml_file_reduce(const GXmlElement &xml, const std::string &filename)
Reduce file name provided for writing as XML attribute.
std::string strip_whitespace(const std::string &arg)
Strip leading and trailing whitespace from string.
const GCTAResponse * cta_rsp(const std::string &origin, const GResponse &rsp)
Retrieve CTA response from generic observation.
GChatter reduce(const GChatter &chatter)
Reduce chattiness by one level.
const std::string extname_gti
bool xml_has_par(const GXmlElement &xml, const std::string &name)
Checks if parameter with given name in XML element exists.
void xml_check_par(const std::string &origin, const std::string &name, const int &number)
Checks whether a parameter has occured once.
const std::string extname_cta_events
std::vector< std::string > split(const std::string &s, const std::string &sep)
Split string.
std::string toupper(const std::string &s)
Convert string to upper case.
GFilename xml_file_expand(const GXmlElement &xml, const std::string &filename)
Expand file name provided as XML attribute for loading.