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()) {
497 write(fits, evtname, gtiname);
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()) {
676 int n_remove = (index + number >
size()) ?
size() - index :
number;
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) {
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");
1193 for (
int i = 0; i < nids; ++i) {
1196 char keyword_id[10];
1197 char keyword_name[10];
1198 sprintf(keyword_id,
"MID%5.5d", i+1);
1199 sprintf(keyword_name,
"MMN%5.5d", i+1);
1202 int id = table.
integer(std::string(keyword_id));
1203 std::string name = table.
string(std::string(keyword_name));
1266 col_dec.
unit(
"deg");
1267 col_energy.
unit(
"TeV");
1270 for (
int i = 0; i <
size(); ++i) {
1271 col_eid(i) =
m_events[i].m_event_id;
1273 col_ra(i) =
m_events[i].dir().dir().ra_deg();
1274 col_dec(i) =
m_events[i].dir().dir().dec_deg();
1275 col_energy(i) =
m_events[i].energy().TeV();
1294 col_detx.
unit(
"deg");
1295 col_dety.
unit(
"deg");
1298 for (
int i = 0; i <
size(); ++i) {
1316 for (
int i = 0; i <
size(); ++i) {
1317 col_phase(i) =
m_events[i].m_phase;
1332 for (
int i = 0; i <
size(); ++i) {
1333 col_mc_id(i) =
m_events[i].m_mc_id;
1342 for (
int i = 0; i <
m_columns.size(); ++i) {
1408 std::string dsref1 =
":"+
gtiname;
1411 hdu.
card(
"DSTYP1",
"TIME",
"Data sub-space type");
1412 hdu.
card(
"DSUNI1",
"s",
"Data sub-space unit");
1413 hdu.
card(
"DSVAL1",
"TABLE",
"Data sub-space value");
1414 hdu.
card(
"DSREF1", dsref1,
"Data sub-space reference");
1417 hdu.
card(
"DSTYP2",
"ENERGY",
"Data sub-space type");
1418 hdu.
card(
"DSUNI2",
"TeV",
"Data sub-space unit");
1419 hdu.
card(
"DSVAL2", dsval2,
"Data sub-space value");
1428 std::string dsval3 =
"CIRCLE(" +
1434 hdu.
card(
"DSTYP3",
"POS(RA,DEC)",
"Data sub-space type");
1435 hdu.
card(
"DSUNI3",
"deg",
"Data sub-space unit");
1436 hdu.
card(
"DSVAL3", dsval3,
"Data sub-space value");
1445 std::string dsval4 =
"";
1457 "Data sub-space type");
1459 "Data sub-space unit");
1461 "Data sub-space value");
1466 hdu.
card(
"NDSKEYS", ndskeys,
"Number of data sub-space keys");
1497 hdu.
card(
"NMCIDS", nids,
"Number of Monte Carlo identifiers");
1500 for (
int i = 0; i < nids; ++i) {
1503 char keyword_id[10];
1504 char keyword_name[10];
1505 sprintf(keyword_id,
"MID%5.5d", i+1);
1506 sprintf(keyword_name,
"MMN%5.5d", i+1);
1509 std::string comment_id =
"Monte Carlo identifier for model " +
1511 std::string comment_name =
"Name of model " +
gammalib::str(i+1);
1514 hdu.
card(std::string(keyword_id),
m_mc_ids[i], comment_id);
void clear(void)
Clear CTA pointing.
void clear(void)
Clear phase intervals.
GCTARoi read_ds_roi(const GFitsHDU &hdu)
Extract ROI from data sub-space keywords.
void unit(const std::string &unit)
Set column unit.
const int & ncols(void) const
Return number of columns in table.
const GGti & gti(void) const
Return Good Time Intervals.
std::string read_ds_gti_extname(const GFitsHDU &hdu)
Return Good Time Intervals extension name from data sub-space keywords.
bool m_has_mc_id
Signal presence of MC identifier.
FITS table double column class interface definition.
virtual GFitsTableCol * clone(void) const =0
Clones object.
CTA event list class interface definition.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
std::string number(const std::string &noun, const int &number)
Convert singular noun into number noun.
virtual void save(const GFilename &filename, const bool &clobber=false) const
Save events into FITS file.
bool contains(const int &extno) const
Check if HDU exists in FITS file.
bool has_card(const int &cardno) const
Check existence of header card.
GCTAInstDir m_dir
Event direction.
double dec_deg(void) const
Returns Declination in degrees.
void append_column(const GFitsTableCol &column)
Append FITS table column to event list.
void detx(const double &x)
Set DETX coordinate (in radians)
GFilename m_filename
Event list file name.
void write_events(GFitsBinTable &table) const
Write CTA events into FITS table.
FITS table unsigned long integer column class interface definition.
virtual void write(GFits &fits) const
Write CTA events and Good Time Intervals into FITS file.
double pmax(const int &index) const
Returns upper boundary for a given phase interval.
Definition of GammaLib CTA typemaps.
bool has_expression(void) const
Signal if filename has an expression.
void set_mc_id_names(const std::vector< int > &ids, const std::vector< std::string > &names)
Set Monte Carlo identifiers and model names.
bool m_has_phase
Signal presence of phase.
Abstract FITS extension base class.
void init_members(void)
Initialise class members.
Abstract event atom container class.
void init_members(void)
Initialise class members.
void write_ds_keys(GFitsHDU &hdu, const std::string >iname=gammalib::extname_gti) const
Write data sub-space keywords into FITS HDU.
const GFilename & filename(void) const
Return FITS filename.
virtual ~GCTAEventList(void)
Destructor.
void append(const GCTAEventAtom &event)
Append event to event list.
const std::string & gtiname(void) const
Return Good Time Interval extension name.
bool is_empty(void) const
Signal if filename is empty.
const GTime & tstop(void) const
Return stop time.
bool contains(const std::string &colname) const
Checks the presence of a column in table.
std::string m_gti_extname
GTI extension name.
const double & radius(void) const
Returns radius of region of interest in degrees.
void nrows(const int &nrows)
Set number of rows in column.
virtual void clear(void)
Clear event list.
GEbounds m_ebounds
Energy boundaries covered by events.
std::vector< std::string > m_mc_id_names
List of model names.
double TeV(void) const
Return energy in TeV.
std::string extname(const std::string &defaultname="") const
Return extension name.
void fetch(void) const
Fetch events.
GFitsTableCol * append(const GFitsTableCol &column)
Append column to the table.
int size(void) const
Return number of phase intervals.
Interface for the CTA region of interest class.
const bool & has_dir(void) const
Signal if instrument direction has valid sky direction.
void write_mc_ids(GFitsHDU &hdu) const
Write Monte Carlo identifier keywords into FITS HDU.
void copy_members(const GCTAEventList &list)
Copy class members.
FITS table float column class interface definition.
const std::string extname_gti
FITS file class interface definition.
GCTARoi m_roi
Region of interest.
GPhases read_ds_phase(const GFitsHDU &hdu)
Read phase boundary data sub-space keywords.
void dir(const GSkyDir &dir)
Set sky direction.
FITS table column abstract base class definition.
void append(const GTime &tstart, const GTime &tstop)
Append Good Time Interval.
std::string centre(const std::string &s, const int &n, const char &c= ' ')
Centre string to achieve a length of n characters.
Definition of support function used by CTA classes.
std::vector< GCTAEventAtom > m_events
Events.
double real(const std::string &keyname) const
Return card value as double precision.
void reference(const GTimeReference &ref)
Set time reference for Good Time Intervals.
virtual GCTAEventList * clone(void) const
Clone event list.
std::string print(const GChatter &chatter=NORMAL) const
Print event list information.
void free_members(void)
Delete class members.
Abstract interface for FITS table column.
const GCTAInstDir & centre(void) const
Returns region of interest centre.
Time reference class interface definition.
const std::string extname_cta_events
GCTAInstDir instdir(const GSkyDir &skydir) const
Get instrument direction from sky direction.
virtual GEventList & operator=(const GEventList &list)
Assignment operator.
FITS table unsigned long integer column.
void dispose(void) const
Dispose events.
double ra_deg(void) const
Returns Right Ascension in degrees.
virtual void load(const GFilename &filename)
Load events from FITS file.
Abstract interface for FITS table.
GGti m_gti
Good time intervals covered by events.
virtual void clear(void)
Clear instance.
int m_num_events
Number of events.
int integer(const std::string &keyname) const
Return card value as integer.
std::vector< GFitsTableCol * > m_columns
Pointers to optional columns.
virtual GCTAEventAtom * operator[](const int &index)
Event atom access operator.
void radec_deg(const double &ra, const double &dec)
Set equatorial sky direction (degrees)
const std::string & extname(void) const
Return extension name.
GCTAPointing m_pnt
Pointing direction for DETX/Y conversion.
FITS table long integer column.
const int & nrows(void) const
Return number of rows in table.
void free_members(void)
Delete class members.
void read_mc_ids(const GFitsTable &table)
Read Monte Carlo identifier keywords from FITS HDU.
void init_members(void)
Initialise class members.
std::string url(void) const
Return Uniform Resource Locator (URL)
GSkyDir m_dir
Observed incident direction of event.
virtual int integer(const int &row, const int &inx=0) const =0
void clear(void)
Clear file name.
virtual double real(const int &row, const int &inx=0) const =0
const GEnergy & emin(void) const
Return minimum energy.
void read(const GFitsTable &table)
Read Good Time Intervals and time reference from FITS table.
GChatter reduce(const GChatter &chatter)
Reduce chattiness by one level.
std::string string(const std::string &keyname) const
Return card value as string.
std::vector< int > m_mc_ids
List of Monte Carlo IDs.
bool is_valid(void) const
Checks if RoI is valid.
FITS table long integer column class interface definition.
virtual int size(void) const
Return number of events in list.
GFitsHDU * append(const GFitsHDU &hdu)
Append HDU to FITS file.
Implements a time reference.
GCTAEventList(void)
Void constructor.
FITS binary table class definition.
void free_members(void)
Delete class members.
const GEbounds & ebounds(void) const
Return energy boundaries.
CTA instrument direction class.
const GSkyDir & dir(void) const
Return pointing sky direction.
double pmin(const int &index) const
Returns lower boundary for a given phase interval.
void dety(const double &y)
Set DETY coordinate (in radians)
Interface for the region of interest classes.
#define G_CTA_MJDREF
Reference of CTA time frame.
#define G_SET_MC_ID_NAMES
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
GEbounds read_ds_ebounds(const GFitsHDU &hdu)
Read energy boundary data sub-space keywords.
virtual int number(void) const
Return number of events in list.
const GTime & tstart(void) const
Return start time.
GFitsHeaderCard & card(const int &cardno)
Return header card.
void name(const std::string &name)
Set column name.
virtual const GCTARoi & roi(void) const
Return Region of Interest.
void write(GFits &fits, const std::string &extname=gammalib::extname_gti) const
Write Good Time Intervals and time reference into FITS object.
void close(void)
Close FITS file.
void read_events(const GFitsTable &table) const
Read CTA events from FITS table.
bool m_has_detxy
Signal presence of detector coordinates.
Time class interface definition.
const GEnergy & emax(void) const
Return maximum energy.
virtual void read(const GFits &fits)
Read events from FITS file.
FITS table double column.
Filename class interface definition.
GPhases m_phases
Phase intervals.
virtual GCTAEventList & operator=(const GCTAEventList &list)
Assignment operator.
Mathematical function definitions.
void remove(const int &index, const int &number=1)
Remove events from event list.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
FITS table abstract base class interface definition.