Commit 9f8a8ffe071edd3f5e52f2dd9ffdb71191360e05

Authored by Jürgen Knödlseder
1 parent 8e9b4411

Add usepnt parameter and adapt to new GTime interface.

The usepnt parameter now signals when the pointing should be used as ROI centre. This allows arbitrary values for ra/dec (before, ra=0 and dec=0 signalled that the pointing should be used).

The tool now uses the new GTime interface. In particular, the input time is now given in CTA reference time in seconds.
src/ctselect/ctselect.cpp
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 /** 21 /**
22 * @file ctselect.cpp 22 * @file ctselect.cpp
23 * @brief CTA data selection tool implementation 23 * @brief CTA data selection tool implementation
24 - * @author J. Knoedlseder 24 + * @author Juergen Knoedlseder
25 */ 25 */
26 26
27 /* __ Includes ___________________________________________________________ */ 27 /* __ Includes ___________________________________________________________ */
@@ -427,14 +427,17 @@ void ctselect::get_parameters(void) @@ -427,14 +427,17 @@ void ctselect::get_parameters(void)
427 } // endif: there was no observation in the container 427 } // endif: there was no observation in the container
428 428
429 // Get parameters 429 // Get parameters
430 - m_ra = (*this)["ra"].real();  
431 - m_dec = (*this)["dec"].real();  
432 - m_rad = (*this)["rad"].real();  
433 - m_tmin = (*this)["tmin"].real();  
434 - m_tmax = (*this)["tmax"].real();  
435 - m_emin = (*this)["emin"].real();  
436 - m_emax = (*this)["emax"].real();  
437 - m_expr = (*this)["expr"].string(); 430 + m_usepnt = (*this)["usepnt"].boolean();
  431 + if (!m_usepnt) {
  432 + m_ra = (*this)["ra"].real();
  433 + m_dec = (*this)["dec"].real();
  434 + }
  435 + m_rad = (*this)["rad"].real();
  436 + m_tmin = (*this)["tmin"].real();
  437 + m_tmax = (*this)["tmax"].real();
  438 + m_emin = (*this)["emin"].real();
  439 + m_emax = (*this)["emax"].real();
  440 + m_expr = (*this)["expr"].string();
438 441
439 // Optionally read ahead parameters so that they get correctly 442 // Optionally read ahead parameters so that they get correctly
440 // dumped into the log file 443 // dumped into the log file
@@ -443,9 +446,10 @@ void ctselect::get_parameters(void) @@ -443,9 +446,10 @@ void ctselect::get_parameters(void)
443 m_prefix = (*this)["prefix"].string(); 446 m_prefix = (*this)["prefix"].string();
444 } 447 }
445 448
446 - // Derive time interval  
447 - m_timemin.time(m_tmin, G_CTA_MJDREF, "days");  
448 - m_timemax.time(m_tmax, G_CTA_MJDREF, "days"); 449 + // Set time interval with input times given in CTA reference
  450 + // time (in seconds)
  451 + m_timemin.set(m_tmin, m_cta_ref);
  452 + m_timemax.set(m_tmax, m_cta_ref);
449 453
450 // Return 454 // Return
451 return; 455 return;
@@ -490,7 +494,7 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) @@ -490,7 +494,7 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename)
490 // Set RA/DEC selection 494 // Set RA/DEC selection
491 double ra = m_ra; 495 double ra = m_ra;
492 double dec = m_dec; 496 double dec = m_dec;
493 - if (m_ra == 0.0 && m_dec == 0.0) { 497 + if (m_usepnt) {
494 const GCTAPointing *pnt = obs->pointing(); 498 const GCTAPointing *pnt = obs->pointing();
495 ra = pnt->dir().ra_deg(); 499 ra = pnt->dir().ra_deg();
496 dec = pnt->dir().dec_deg(); 500 dec = pnt->dir().dec_deg();
@@ -514,9 +518,10 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) @@ -514,9 +518,10 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename)
514 // Make time selection 518 // Make time selection
515 if (select_time) { 519 if (select_time) {
516 520
517 - // Extract effective time interval in native MJD reference  
518 - double tmin = gti.tstart().time();  
519 - double tmax = gti.tstop().time(); 521 + // Extract effective time interval in CTA reference time. We need
  522 + // this reference for filtering.
  523 + double tmin = gti.tstart().convert(m_cta_ref);
  524 + double tmax = gti.tstop().convert(m_cta_ref);
520 525
521 // Format time with sufficient accuracy and add to selection string 526 // Format time with sufficient accuracy and add to selection string
522 sprintf(cmin, "%.8f", tmin); 527 sprintf(cmin, "%.8f", tmin);
@@ -663,13 +668,14 @@ void ctselect::init_members(void) @@ -663,13 +668,14 @@ void ctselect::init_members(void)
663 m_infile.clear(); 668 m_infile.clear();
664 m_outfile.clear(); 669 m_outfile.clear();
665 m_prefix.clear(); 670 m_prefix.clear();
666 - m_ra = 0.0;  
667 - m_dec = 0.0;  
668 - m_rad = 0.0;  
669 - m_tmin = 0.0;  
670 - m_tmax = 0.0;  
671 - m_emin = 0.0;  
672 - m_emax = 0.0; 671 + m_usepnt = false;
  672 + m_ra = 0.0;
  673 + m_dec = 0.0;
  674 + m_rad = 0.0;
  675 + m_tmin = 0.0;
  676 + m_tmax = 0.0;
  677 + m_emin = 0.0;
  678 + m_emax = 0.0;
673 m_expr.clear(); 679 m_expr.clear();
674 680
675 // Initialise protected members 681 // Initialise protected members
@@ -679,6 +685,11 @@ void ctselect::init_members(void) @@ -679,6 +685,11 @@ void ctselect::init_members(void)
679 m_timemax.clear(); 685 m_timemax.clear();
680 m_use_xml = false; 686 m_use_xml = false;
681 m_read_ahead = false; 687 m_read_ahead = false;
  688 +
  689 + // Set CTA time reference. G_CTA_MJDREF is the CTA reference MJD,
  690 + // which is defined in GCTALib.hpp. This is somehow a kluge. We need
  691 + // a better mechanism to implement the CTA reference MJD.
  692 + m_cta_ref.set(G_CTA_MJDREF, "s", "TT", "LOCAL");
682 693
683 // Set logger properties 694 // Set logger properties
684 log.date(true); 695 log.date(true);
@@ -699,6 +710,7 @@ void ctselect::copy_members(const ctselect& app) @@ -699,6 +710,7 @@ void ctselect::copy_members(const ctselect& app)
699 m_infile = app.m_infile; 710 m_infile = app.m_infile;
700 m_outfile = app.m_outfile; 711 m_outfile = app.m_outfile;
701 m_prefix = app.m_prefix; 712 m_prefix = app.m_prefix;
  713 + m_usepnt = app.m_usepnt;
702 m_ra = app.m_ra; 714 m_ra = app.m_ra;
703 m_dec = app.m_dec; 715 m_dec = app.m_dec;
704 m_rad = app.m_rad; 716 m_rad = app.m_rad;
@@ -715,6 +727,7 @@ void ctselect::copy_members(const ctselect& app) @@ -715,6 +727,7 @@ void ctselect::copy_members(const ctselect& app)
715 m_timemax = app.m_timemax; 727 m_timemax = app.m_timemax;
716 m_use_xml = app.m_use_xml; 728 m_use_xml = app.m_use_xml;
717 m_read_ahead = app.m_read_ahead; 729 m_read_ahead = app.m_read_ahead;
  730 + m_cta_ref = app.m_cta_ref;
718 731
719 // Return 732 // Return
720 return; 733 return;
src/ctselect/ctselect.hpp
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 /** 21 /**
22 * @file ctselect.hpp 22 * @file ctselect.hpp
23 * @brief CTA data selection tool definition 23 * @brief CTA data selection tool definition
24 - * @author J. Knoedlseder 24 + * @author Juergen Knoedlseder
25 */ 25 */
26 26
27 #ifndef CTSELECT_HPP 27 #ifndef CTSELECT_HPP
@@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
35 35
36 /* __Definitions _________________________________________________________ */ 36 /* __Definitions _________________________________________________________ */
37 #define CTSELECT_NAME "ctselect" 37 #define CTSELECT_NAME "ctselect"
38 -#define CTSELECT_VERSION "00-03-01" 38 +#define CTSELECT_VERSION "00-04-00"
39 39
40 40
41 /***********************************************************************//** 41 /***********************************************************************//**
@@ -81,6 +81,7 @@ protected: @@ -81,6 +81,7 @@ protected:
81 std::string m_infile; //!< Input event list or XML file 81 std::string m_infile; //!< Input event list or XML file
82 std::string m_outfile; //!< Output event list or XML file 82 std::string m_outfile; //!< Output event list or XML file
83 std::string m_prefix; //!< Prefix for multiple event lists 83 std::string m_prefix; //!< Prefix for multiple event lists
  84 + bool m_usepnt; //!< Use pointing instead of RA/DEC parameters
84 double m_ra; //!< RA of ROI centre 85 double m_ra; //!< RA of ROI centre
85 double m_dec; //!< DEC of ROI centre 86 double m_dec; //!< DEC of ROI centre
86 double m_rad; //!< ROI radius 87 double m_rad; //!< ROI radius
@@ -97,6 +98,7 @@ protected: @@ -97,6 +98,7 @@ protected:
97 GTime m_timemax; //!< Latest time 98 GTime m_timemax; //!< Latest time
98 bool m_use_xml; //!< Use XML file instead of FITS file 99 bool m_use_xml; //!< Use XML file instead of FITS file
99 bool m_read_ahead; //!< Read ahead parameters 100 bool m_read_ahead; //!< Read ahead parameters
  101 + GTimeReference m_cta_ref; //!< CTA time reference
100 }; 102 };
101 103
102 #endif /* CTSELECT_HPP */ 104 #endif /* CTSELECT_HPP */
src/ctselect/ctselect.par
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 # ------------------------------------------------------------------------- # 5 # ------------------------------------------------------------------------- #
6 # # 6 # #
7 # File: ctselect.par # 7 # File: ctselect.par #
8 -# Version: 00-03-00 # 8 +# Version: 00-04-00 #
9 # # 9 # #
10 # Author: Jurgen Knodlseder # 10 # Author: Jurgen Knodlseder #
11 # Jurgen.Knodlseder@irap.omp.eu # 11 # Jurgen.Knodlseder@irap.omp.eu #
@@ -23,14 +23,15 @@ prefix, s, h, &quot;selected_&quot;,,,&quot;Prefix for event lists in observation definition fi @@ -23,14 +23,15 @@ prefix, s, h, &quot;selected_&quot;,,,&quot;Prefix for event lists in observation definition fi
23 # 23 #
24 # Selection parameters 24 # Selection parameters
25 #===================== 25 #=====================
26 -ra, r, a, 83.63, 0,360, "RA for ROI centre (degrees)"  
27 -dec, r, a, 22.01, -90, 90, "Dec for ROI centre (degrees)"  
28 -rad, r, a, 3.0, 0,180, "Radius of ROI (degrees)"  
29 -tmin, r, a, 0.0, 0, , "Start time (CTA MJD in days)"  
30 -tmax, r, a, 10000.0, 0, , "End time (CTA MJD in days)"  
31 -emin, r, a, 0.1, 0, , "Lower energy limit (TeV)"  
32 -emax, r, a, 100.0, 0, , "Upper energy limit (TeV)"  
33 -expr, s, h, "", , , "Additional selection expression" 26 +usepnt, b, h, no,,, "Use pointing instead of RA/DEC parameters?"
  27 +ra, r, a, 83.63, 0,360, "RA for ROI centre (degrees)"
  28 +dec, r, a, 22.01, -90, 90, "Dec for ROI centre (degrees)"
  29 +rad, r, a, 3.0, 0,180, "Radius of ROI (degrees)"
  30 +tmin, r, a, 0.0, 0, , "Start time (CTA MET in seconds)"
  31 +tmax, r, a, 0.0, 0, , "End time (CTA MET in seconds)"
  32 +emin, r, a, 0.1, 0, , "Lower energy limit (TeV)"
  33 +emax, r, a, 100.0, 0, , "Upper energy limit (TeV)"
  34 +expr, s, h, "", , , "Additional selection expression"
34 # 35 #
35 # Standard parameters 36 # Standard parameters
36 #==================== 37 #====================