diff --git a/src/ctselect/ctselect.cpp b/src/ctselect/ctselect.cpp index 5c06db7..d4d1a0c 100644 --- a/src/ctselect/ctselect.cpp +++ b/src/ctselect/ctselect.cpp @@ -21,7 +21,7 @@ /** * @file ctselect.cpp * @brief CTA data selection tool implementation - * @author J. Knoedlseder + * @author Juergen Knoedlseder */ /* __ Includes ___________________________________________________________ */ @@ -427,14 +427,17 @@ void ctselect::get_parameters(void) } // endif: there was no observation in the container // Get parameters - m_ra = (*this)["ra"].real(); - m_dec = (*this)["dec"].real(); - m_rad = (*this)["rad"].real(); - m_tmin = (*this)["tmin"].real(); - m_tmax = (*this)["tmax"].real(); - m_emin = (*this)["emin"].real(); - m_emax = (*this)["emax"].real(); - m_expr = (*this)["expr"].string(); + m_usepnt = (*this)["usepnt"].boolean(); + if (!m_usepnt) { + m_ra = (*this)["ra"].real(); + m_dec = (*this)["dec"].real(); + } + m_rad = (*this)["rad"].real(); + m_tmin = (*this)["tmin"].real(); + m_tmax = (*this)["tmax"].real(); + m_emin = (*this)["emin"].real(); + m_emax = (*this)["emax"].real(); + m_expr = (*this)["expr"].string(); // Optionally read ahead parameters so that they get correctly // dumped into the log file @@ -443,9 +446,10 @@ void ctselect::get_parameters(void) m_prefix = (*this)["prefix"].string(); } - // Derive time interval - m_timemin.time(m_tmin, G_CTA_MJDREF, "days"); - m_timemax.time(m_tmax, G_CTA_MJDREF, "days"); + // Set time interval with input times given in CTA reference + // time (in seconds) + m_timemin.set(m_tmin, m_cta_ref); + m_timemax.set(m_tmax, m_cta_ref); // Return return; @@ -490,7 +494,7 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) // Set RA/DEC selection double ra = m_ra; double dec = m_dec; - if (m_ra == 0.0 && m_dec == 0.0) { + if (m_usepnt) { const GCTAPointing *pnt = obs->pointing(); ra = pnt->dir().ra_deg(); dec = pnt->dir().dec_deg(); @@ -514,9 +518,10 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) // Make time selection if (select_time) { - // Extract effective time interval in native MJD reference - double tmin = gti.tstart().time(); - double tmax = gti.tstop().time(); + // Extract effective time interval in CTA reference time. We need + // this reference for filtering. + double tmin = gti.tstart().convert(m_cta_ref); + double tmax = gti.tstop().convert(m_cta_ref); // Format time with sufficient accuracy and add to selection string sprintf(cmin, "%.8f", tmin); @@ -663,13 +668,14 @@ void ctselect::init_members(void) m_infile.clear(); m_outfile.clear(); m_prefix.clear(); - m_ra = 0.0; - m_dec = 0.0; - m_rad = 0.0; - m_tmin = 0.0; - m_tmax = 0.0; - m_emin = 0.0; - m_emax = 0.0; + m_usepnt = false; + m_ra = 0.0; + m_dec = 0.0; + m_rad = 0.0; + m_tmin = 0.0; + m_tmax = 0.0; + m_emin = 0.0; + m_emax = 0.0; m_expr.clear(); // Initialise protected members @@ -679,6 +685,11 @@ void ctselect::init_members(void) m_timemax.clear(); m_use_xml = false; m_read_ahead = false; + + // Set CTA time reference. G_CTA_MJDREF is the CTA reference MJD, + // which is defined in GCTALib.hpp. This is somehow a kluge. We need + // a better mechanism to implement the CTA reference MJD. + m_cta_ref.set(G_CTA_MJDREF, "s", "TT", "LOCAL"); // Set logger properties log.date(true); @@ -699,6 +710,7 @@ void ctselect::copy_members(const ctselect& app) m_infile = app.m_infile; m_outfile = app.m_outfile; m_prefix = app.m_prefix; + m_usepnt = app.m_usepnt; m_ra = app.m_ra; m_dec = app.m_dec; m_rad = app.m_rad; @@ -715,6 +727,7 @@ void ctselect::copy_members(const ctselect& app) m_timemax = app.m_timemax; m_use_xml = app.m_use_xml; m_read_ahead = app.m_read_ahead; + m_cta_ref = app.m_cta_ref; // Return return; diff --git a/src/ctselect/ctselect.hpp b/src/ctselect/ctselect.hpp index 5302816..9877498 100644 --- a/src/ctselect/ctselect.hpp +++ b/src/ctselect/ctselect.hpp @@ -21,7 +21,7 @@ /** * @file ctselect.hpp * @brief CTA data selection tool definition - * @author J. Knoedlseder + * @author Juergen Knoedlseder */ #ifndef CTSELECT_HPP @@ -35,7 +35,7 @@ /* __Definitions _________________________________________________________ */ #define CTSELECT_NAME "ctselect" -#define CTSELECT_VERSION "00-03-01" +#define CTSELECT_VERSION "00-04-00" /***********************************************************************//** @@ -81,6 +81,7 @@ protected: std::string m_infile; //!< Input event list or XML file std::string m_outfile; //!< Output event list or XML file std::string m_prefix; //!< Prefix for multiple event lists + bool m_usepnt; //!< Use pointing instead of RA/DEC parameters double m_ra; //!< RA of ROI centre double m_dec; //!< DEC of ROI centre double m_rad; //!< ROI radius @@ -97,6 +98,7 @@ protected: GTime m_timemax; //!< Latest time bool m_use_xml; //!< Use XML file instead of FITS file bool m_read_ahead; //!< Read ahead parameters + GTimeReference m_cta_ref; //!< CTA time reference }; #endif /* CTSELECT_HPP */ diff --git a/src/ctselect/ctselect.par b/src/ctselect/ctselect.par index ab26715..32b2896 100644 --- a/src/ctselect/ctselect.par +++ b/src/ctselect/ctselect.par @@ -5,7 +5,7 @@ # ------------------------------------------------------------------------- # # # # File: ctselect.par # -# Version: 00-03-00 # +# Version: 00-04-00 # # # # Author: Jurgen Knodlseder # # Jurgen.Knodlseder@irap.omp.eu # @@ -23,14 +23,15 @@ prefix, s, h, "selected_",,,"Prefix for event lists in observation definition fi # # Selection parameters #===================== -ra, r, a, 83.63, 0,360, "RA for ROI centre (degrees)" -dec, r, a, 22.01, -90, 90, "Dec for ROI centre (degrees)" -rad, r, a, 3.0, 0,180, "Radius of ROI (degrees)" -tmin, r, a, 0.0, 0, , "Start time (CTA MJD in days)" -tmax, r, a, 10000.0, 0, , "End time (CTA MJD in days)" -emin, r, a, 0.1, 0, , "Lower energy limit (TeV)" -emax, r, a, 100.0, 0, , "Upper energy limit (TeV)" -expr, s, h, "", , , "Additional selection expression" +usepnt, b, h, no,,, "Use pointing instead of RA/DEC parameters?" +ra, r, a, 83.63, 0,360, "RA for ROI centre (degrees)" +dec, r, a, 22.01, -90, 90, "Dec for ROI centre (degrees)" +rad, r, a, 3.0, 0,180, "Radius of ROI (degrees)" +tmin, r, a, 0.0, 0, , "Start time (CTA MET in seconds)" +tmax, r, a, 0.0, 0, , "End time (CTA MET in seconds)" +emin, r, a, 0.1, 0, , "Lower energy limit (TeV)" +emax, r, a, 100.0, 0, , "Upper energy limit (TeV)" +expr, s, h, "", , , "Additional selection expression" # # Standard parameters #====================