51#define G_OPERATOR "GCTAEventList::operator[](int&)"
52#define G_ROI "GCTAEventList::roi(GRoi&)"
53#define G_APPEND_COLUMN "GCTAEventList::append_column(GFitsTableCol&)"
54#define G_SET_MC_ID_NAMES "GCTAEventList::set_mc_id_names(std::vector<int>&,"\
55 " std::vector<std::string>&)"
56#define G_FETCH "GCTAEventList::fetch()"
57#define G_WRITE_DS_KEYS "GCTAEventList::write_ds_keys(GFitsHDU&, "\
58 "const std::string&) const"
198 #if defined(G_RANGE_CHECK)
199 if (index < 0 || index >=
size()) {
227 #if defined(G_RANGE_CHECK)
228 if (index < 0 || index >=
size()) {
291 GFits fits(filename);
313 const bool& clobber)
const
401 double ra_pnt = events.
real(
"RA_PNT");
402 double dec_pnt = events.
real(
"DEC_PNT");
411 if (gti_extname.empty()) {
517 const std::string& gtiname)
const
531 table.
card(
"RA_PNT", ra_pnt,
"[deg] Pointing Right Ascension");
532 table.
card(
"DEC_PNT", dec_pnt,
"[deg] Pointing Declination");
571 std::string cls = std::string(
typeid(&
roi).name());
572 std::string msg =
"Invalid region of interest type \""+cls+
"\" "
573 "provided on input. Please specify a \"GCTARoi\" "
574 "object as argument.";
602 for (
int i = 0; i <
m_columns.size(); ++i) {
634 std::string msg =
"Incompatible column length. Attempt to append a "
637 " events. Please specify a column of length "+
673 if (index <
size()) {
680 m_events.begin() + index + n_remove);
683 for (
int i = 0; i <
m_columns.size(); ++i) {
724 bool has_exception =
false;
728 #pragma omp critical(GCTAEventList_fetch)
735 std::string extname =
749 has_exception =
true;
755 std::string msg =
"Unable to load events from file \""+
764 " events from FITS file while "+
766 "expected. This should never happen!";
775 " events since the name of the FITS file from "
776 "which to fetch the events is not known.";
799 for (
int i = 0; i <
m_columns.size(); ++i) {
829 const std::vector<std::string>& names)
832 if (ids.size() != names.size()) {
833 std::string msg =
"The number of Monte Carlo identifiers ("+
835 "the number of model names ("+
837 "same number of model names and Monte Carlo "
867 result.append(
"=== GCTAEventList ===");
874 result.append(
" (disposed in \""+
m_filename+
"\")");
877 result.append(
" (disposed without possibility to recover)");
881 result.append(
" (loaded)");
888 result.append(
" - ");
892 result.append(
"not defined");
909 result.append(
" - ");
913 result.append(
"not defined");
919 if (
roi().radius() > 0) {
929 if (
roi().radius() > 0) {
930 result.append(
roi().centre().
print());
931 result.append(
" Radius=");
935 result.append(
"not defined");
1006 for (
int i = 0; i < list.
m_columns.size(); ++i) {
1021 for (
int i = 0; i <
m_columns.size(); ++i) {
1061 int num = table.
nrows();
1087 for (
int i = 0; i < num; ++i) {
1098 event.m_dir.dir(dir);
1099 event.m_energy.TeV(ptr_energy->
real(i));
1100 event.m_event_id = ptr_eid->
integer(i);
1111 event.m_dir.dety(instdir.
dety());
1116 event.m_phase = ptr_phase->
real(i);
1121 event.m_mc_id = ptr_mc_id->
integer(i);
1130 for (
int i = 0; i < table.
ncols(); ++i) {
1136 const std::string name = col->
name();
1139 if (name ==
"EVENT_ID" ||
1183 int nids = table.
integer(
"NMCIDS");
1194 for (
int i = 0; i < nids+1; ++i) {
1197 char keyword_id[10];
1198 char keyword_name[10];
1201 sprintf(keyword_id,
"MID%5.5d", i);
1202 sprintf(keyword_name,
"MMN%5.5d", i);
1205 if (!table.
has_card(std::string(keyword_id)) ||
1206 !table.
has_card(std::string(keyword_name))) {
1211 int id = table.
integer(std::string(keyword_id));
1212 std::string name = table.
string(std::string(keyword_name));
1275 col_dec.
unit(
"deg");
1276 col_energy.
unit(
"TeV");
1279 for (
int i = 0; i <
size(); ++i) {
1280 col_eid(i) =
m_events[i].m_event_id;
1282 col_ra(i) =
m_events[i].dir().dir().ra_deg();
1283 col_dec(i) =
m_events[i].dir().dir().dec_deg();
1284 col_energy(i) =
m_events[i].energy().TeV();
1303 col_detx.
unit(
"deg");
1304 col_dety.
unit(
"deg");
1307 for (
int i = 0; i <
size(); ++i) {
1325 for (
int i = 0; i <
size(); ++i) {
1326 col_phase(i) =
m_events[i].m_phase;
1341 for (
int i = 0; i <
size(); ++i) {
1342 col_mc_id(i) =
m_events[i].m_mc_id;
1351 for (
int i = 0; i <
m_columns.size(); ++i) {
1417 std::string dsref1 =
":"+
gtiname;
1420 hdu.
card(
"DSTYP1",
"TIME",
"Data sub-space type");
1421 hdu.
card(
"DSUNI1",
"s",
"Data sub-space unit");
1422 hdu.
card(
"DSVAL1",
"TABLE",
"Data sub-space value");
1423 hdu.
card(
"DSREF1", dsref1,
"Data sub-space reference");
1426 hdu.
card(
"DSTYP2",
"ENERGY",
"Data sub-space type");
1427 hdu.
card(
"DSUNI2",
"TeV",
"Data sub-space unit");
1428 hdu.
card(
"DSVAL2", dsval2,
"Data sub-space value");
1437 std::string dsval3 =
"CIRCLE(" +
1443 hdu.
card(
"DSTYP3",
"POS(RA,DEC)",
"Data sub-space type");
1444 hdu.
card(
"DSUNI3",
"deg",
"Data sub-space unit");
1445 hdu.
card(
"DSVAL3", dsval3,
"Data sub-space value");
1454 std::string dsval4 =
"";
1466 "Data sub-space type");
1468 "Data sub-space unit");
1470 "Data sub-space value");
1475 hdu.
card(
"NDSKEYS", ndskeys,
"Number of data sub-space keys");
1506 hdu.
card(
"NMCIDS", nids,
"Number of Monte Carlo identifiers");
1509 for (
int i = 0; i < nids; ++i) {
1512 char keyword_id[10];
1513 char keyword_name[10];
1514 sprintf(keyword_id,
"MID%5.5d", i+1);
1515 sprintf(keyword_name,
"MMN%5.5d", i+1);
1518 std::string comment_id =
"Monte Carlo identifier for model " +
1520 std::string comment_name =
"Name of model " +
gammalib::str(i+1);
1523 hdu.
card(std::string(keyword_id),
m_mc_ids[i], comment_id);
#define G_SET_MC_ID_NAMES
CTA event list class interface definition.
Definition of support function used by CTA classes.
Definition of GammaLib CTA typemaps.
#define G_CTA_MJDREF
Reference of CTA time frame.
Filename class interface definition.
FITS binary table class definition.
FITS table column abstract base class definition.
FITS table double column class interface definition.
FITS table float column class interface definition.
FITS table long integer column class interface definition.
FITS table unsigned long integer column class interface definition.
FITS table abstract base class interface definition.
FITS file class interface definition.
Mathematical function definitions.
Time reference class interface definition.
Time class interface definition.
GCTAInstDir m_dir
Event direction.
virtual void clear(void)
Clear event list.
virtual ~GCTAEventList(void)
Destructor.
void append_column(const GFitsTableCol &column)
Append FITS table column to event list.
GCTAPointing m_pnt
Pointing direction for DETX/Y conversion.
void write_ds_keys(GFitsHDU &hdu, const std::string >iname=gammalib::extname_gti) const
Write data sub-space keywords into FITS HDU.
virtual GCTAEventAtom * operator[](const int &index)
Event atom access operator.
void copy_members(const GCTAEventList &list)
Copy class members.
void dispose(void) const
Dispose events.
virtual void read(const GFits &fits)
Read events from FITS file.
virtual const GCTARoi & roi(void) const
Return Region of Interest.
virtual GCTAEventList * clone(void) const
Clone event list.
void init_members(void)
Initialise class members.
const std::string & gtiname(void) const
Return Good Time Interval extension name.
virtual double number(void) const
Return number of events in list.
std::vector< std::string > m_mc_id_names
List of model names.
GFilename m_filename
Event list file name.
int m_num_events
Number of events.
bool m_has_phase
Signal presence of phase.
bool m_has_mc_id
Signal presence of MC identifier.
virtual int size(void) const
Return number of events in list.
GCTARoi m_roi
Region of interest.
void fetch(void) const
Fetch events.
GPhases m_phases
Phase intervals.
GCTAEventList(void)
Void constructor.
void read_events(const GFitsTable &table) const
Read CTA events from FITS table.
virtual GCTAEventList & operator=(const GCTAEventList &list)
Assignment operator.
bool m_has_detxy
Signal presence of detector coordinates.
virtual void write(GFits &fits) const
Write CTA events and Good Time Intervals into FITS file.
void read_mc_ids(const GFitsTable &table)
Read Monte Carlo identifier keywords from FITS HDU.
void remove(const int &index, const int &number=1)
Remove events from event list.
void write_mc_ids(GFitsHDU &hdu) const
Write Monte Carlo identifier keywords into FITS HDU.
void write_events(GFitsBinTable &table) const
Write CTA events into FITS table.
void set_mc_id_names(const std::vector< int > &ids, const std::vector< std::string > &names)
Set Monte Carlo identifiers and model names.
std::vector< GFitsTableCol * > m_columns
Pointers to optional columns.
void free_members(void)
Delete class members.
std::string m_gti_extname
GTI extension name.
virtual void load(const GFilename &filename)
Load events from FITS file.
virtual void save(const GFilename &filename, const bool &clobber=false) const
Save events into FITS file.
std::string print(const GChatter &chatter=NORMAL) const
Print event list information.
std::vector< GCTAEventAtom > m_events
Events.
void append(const GCTAEventAtom &event)
Append event to event list.
std::vector< int > m_mc_ids
List of Monte Carlo IDs.
CTA instrument direction class.
void dir(const GSkyDir &dir)
Set sky direction.
void dety(const double &y)
Set DETY coordinate (in radians)
void detx(const double &x)
Set DETX coordinate (in radians)
const bool & has_dir(void) const
Signal if instrument direction has valid sky direction.
GSkyDir m_dir
Observed incident direction of event.
GCTAInstDir instdir(const GSkyDir &skydir) const
Get instrument direction from sky direction.
const GSkyDir & dir(void) const
Return pointing sky direction.
void clear(void)
Clear CTA pointing.
Interface for the CTA region of interest class.
const double & radius(void) const
Returns radius of region of interest in degrees.
bool is_valid(void) const
Checks if RoI is valid.
virtual void clear(void)
Clear instance.
const GCTAInstDir & centre(void) const
Returns region of interest centre.
double TeV(void) const
Return energy in TeV.
Abstract event atom container class.
virtual GEventList & operator=(const GEventList &list)
Assignment operator.
void init_members(void)
Initialise class members.
void free_members(void)
Delete class members.
void free_members(void)
Delete class members.
GGti m_gti
Good time intervals covered by events.
const GTime & tstart(void) const
Return start time.
GEbounds m_ebounds
Energy boundaries covered by events.
const GGti & gti(void) const
Return Good Time Intervals.
void init_members(void)
Initialise class members.
const GTime & tstop(void) const
Return stop time.
const GEbounds & ebounds(void) const
Return energy boundaries.
const GEnergy & emax(void) const
Return maximum energy.
const GEnergy & emin(void) const
Return minimum energy.
bool has_expression(void) const
Signal if filename has an expression.
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.
const std::string & extname(void) const
Return extension name.
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.
Abstract interface for FITS table column.
virtual int integer(const int &row, const int &inx=0) const =0
void name(const std::string &name)
Set column name.
virtual double real(const int &row, const int &inx=0) const =0
void unit(const std::string &unit)
Set column unit.
void nrows(const int &nrows)
Set number of rows in column.
virtual GFitsTableCol * clone(void) const =0
Clones object.
FITS table double column.
FITS table long integer column.
FITS table unsigned long integer column.
Abstract interface for FITS table.
bool contains(const std::string &colname) const
Checks the presence of a column in table.
GFitsTableCol * append(const GFitsTableCol &column)
Append column to the table.
const int & nrows(void) const
Return number of rows in table.
const int & ncols(void) const
Return number of columns in table.
bool contains(const int &extno) const
Check if HDU exists in FITS file.
GFitsHDU * append(const GFitsHDU &hdu)
Append HDU to FITS file.
void close(void)
Close FITS file.
void save(const bool &clobber=false)
Saves FITS file.
const GFilename & filename(void) const
Return FITS filename.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
void reference(const GTimeReference &ref)
Set time reference for Good Time Intervals.
void write(GFits &fits, const std::string &extname=gammalib::extname_gti) const
Write Good Time Intervals and time reference into FITS object.
void read(const GFitsTable &table)
Read Good Time Intervals and time reference from FITS table.
void append(const GTime &tstart, const GTime &tstop)
Append Good Time Interval.
int size(void) const
Return number of phase intervals.
double pmax(const int &index) const
Returns upper boundary for a given phase interval.
void clear(void)
Clear phase intervals.
double pmin(const int &index) const
Returns lower boundary for a given phase interval.
Interface for the region of interest classes.
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)
Implements a time reference.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
std::string read_ds_gti_extname(const GFitsHDU &hdu)
Return Good Time Intervals extension name from data sub-space keywords.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
GCTARoi read_ds_roi(const GFitsHDU &hdu)
Extract ROI from data sub-space keywords.
GChatter reduce(const GChatter &chatter)
Reduce chattiness by one level.
GEbounds read_ds_ebounds(const GFitsHDU &hdu)
Read energy boundary data sub-space keywords.
const std::string extname_gti
const std::string extname_cta_events
GPhases read_ds_phase(const GFitsHDU &hdu)
Read phase boundary data sub-space keywords.