Commit b2132baf6b51f60fc3ce02b437506240e2cf9474

Authored by Jürgen Knödlseder
1 parent 6e39d7c7

Make sure that simulated events are within ROI. Add also an ROI margin of 0.5 de…

…g so that also sources outside but at the edge of the ROI will be simulated.
ChangeLog
1 -2013-02-21 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu> 1 +2013-04-09 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu>
2 2
3 * Version 0.7.0 released 3 * Version 0.7.0 released
4 ======================== 4 ========================
5 5
6 Adapt to GammaLib-00-08-00 interface 6 Adapt to GammaLib-00-08-00 interface
  7 + ctobssim now only simulates events within ROI
7 8
8 2012-12-21 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu> 9 2012-12-21 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu>
9 10
@@ -2,7 +2,7 @@ New Features and Important Changes in ctools 00-07-00 @@ -2,7 +2,7 @@ New Features and Important Changes in ctools 00-07-00
2 2
3 Author(s) : Juergen Knoedlseder 3 Author(s) : Juergen Knoedlseder
4 4
5 -February 21th, 2013 5 +April 9th, 2013
6 6
7 7
8 1. Introduction 8 1. Introduction
@@ -27,7 +27,11 @@ None @@ -27,7 +27,11 @@ None
27 27
28 4. ctobssim - CTA observation simulation 28 4. ctobssim - CTA observation simulation
29 ---------------------------------------- 29 ----------------------------------------
30 -None 30 +The application now checks for each event whether it lies within the
  31 +circular region of interested defined by the region centre (parameters
  32 +ra and dec) and region radius (parameter rad). A margin of 0.5 has been
  33 +added internally to the radius so that also sources at the edge but
  34 +slightly outside of the ROI will be simulated correctly.
31 35
32 36
33 5. ctselect - CTA event selection 37 5. ctselect - CTA event selection
src/ctobssim/ctobssim.cpp
@@ -36,6 +36,9 @@ @@ -36,6 +36,9 @@
36 #define G_SIMULATE_SOURCE "ctobssim::simulate_source(GCTAObservation*,"\ 36 #define G_SIMULATE_SOURCE "ctobssim::simulate_source(GCTAObservation*,"\
37 " GPhotons&)" 37 " GPhotons&)"
38 38
  39 +/* __ Constants __________________________________________________________ */
  40 +const double g_roi_margin = 0.5; //!< Simulation radius margin (degrees)
  41 +
39 /* __ Debug definitions __________________________________________________ */ 42 /* __ Debug definitions __________________________________________________ */
40 43
41 /* __ Coding definitions _________________________________________________ */ 44 /* __ Coding definitions _________________________________________________ */
@@ -66,10 +69,12 @@ ctobssim::ctobssim(void) : GApplication(CTOBSSIM_NAME, CTOBSSIM_VERSION) @@ -66,10 +69,12 @@ ctobssim::ctobssim(void) : GApplication(CTOBSSIM_NAME, CTOBSSIM_VERSION)
66 /***********************************************************************//** 69 /***********************************************************************//**
67 * @brief Observations constructor 70 * @brief Observations constructor
68 * 71 *
69 - * This constructor creates an instance of the class that is initialised from  
70 - * an observation container. 72 + * @param[in] obs Observation container.
  73 + *
  74 + * Constructs application by initialising from an observation container.
71 ***************************************************************************/ 75 ***************************************************************************/
72 -ctobssim::ctobssim(GObservations obs) : GApplication(CTOBSSIM_NAME, CTOBSSIM_VERSION) 76 +ctobssim::ctobssim(GObservations obs) :
  77 + GApplication(CTOBSSIM_NAME, CTOBSSIM_VERSION)
73 { 78 {
74 // Initialise members 79 // Initialise members
75 init_members(); 80 init_members();
@@ -90,9 +95,11 @@ ctobssim::ctobssim(GObservations obs) : GApplication(CTOBSSIM_NAME, CTOBSSIM_VER @@ -90,9 +95,11 @@ ctobssim::ctobssim(GObservations obs) : GApplication(CTOBSSIM_NAME, CTOBSSIM_VER
90 * 95 *
91 * @param[in] argc Number of arguments in command line. 96 * @param[in] argc Number of arguments in command line.
92 * @param[in] argv Array of command line arguments. 97 * @param[in] argv Array of command line arguments.
  98 + *
  99 + * Constructs application using command line arguments for parameter setting.
93 ***************************************************************************/ 100 ***************************************************************************/
94 ctobssim::ctobssim(int argc, char *argv[]) : 101 ctobssim::ctobssim(int argc, char *argv[]) :
95 - GApplication(CTOBSSIM_NAME, CTOBSSIM_VERSION, argc, argv) 102 + GApplication(CTOBSSIM_NAME, CTOBSSIM_VERSION, argc, argv)
96 { 103 {
97 // Initialise members 104 // Initialise members
98 init_members(); 105 init_members();
@@ -146,6 +153,7 @@ ctobssim::~ctobssim(void) @@ -146,6 +153,7 @@ ctobssim::~ctobssim(void)
146 * @brief Assignment operator 153 * @brief Assignment operator
147 * 154 *
148 * @param[in] app Application. 155 * @param[in] app Application.
  156 + * @return Application.
149 ***************************************************************************/ 157 ***************************************************************************/
150 ctobssim& ctobssim::operator= (const ctobssim& app) 158 ctobssim& ctobssim::operator= (const ctobssim& app)
151 { 159 {
@@ -178,7 +186,7 @@ ctobssim&amp; ctobssim::operator= (const ctobssim&amp; app) @@ -178,7 +186,7 @@ ctobssim&amp; ctobssim::operator= (const ctobssim&amp; app)
178 ==========================================================================*/ 186 ==========================================================================*/
179 187
180 /***********************************************************************//** 188 /***********************************************************************//**
181 - * @brief Clear instance 189 + * @brief Clear application
182 ***************************************************************************/ 190 ***************************************************************************/
183 void ctobssim::clear(void) 191 void ctobssim::clear(void)
184 { 192 {
@@ -598,11 +606,6 @@ void ctobssim::set_list(GCTAObservation* obs) @@ -598,11 +606,6 @@ void ctobssim::set_list(GCTAObservation* obs)
598 * 606 *
599 * This method does nothing if the observation pointer is NULL. It also 607 * This method does nothing if the observation pointer is NULL. It also
600 * verifies if the observation has a valid pointing and response. 608 * verifies if the observation has a valid pointing and response.
601 - *  
602 - * @todo Add margins to the data selections so that we generate also photons  
603 - * that fall slightly outside the ROI and the energy interval so that  
604 - * they can be scatter within the ROI and energy interval by the  
605 - * PSF and energy dispersion.  
606 ***************************************************************************/ 609 ***************************************************************************/
607 void ctobssim::simulate_source(GCTAObservation* obs, const GModels& models, 610 void ctobssim::simulate_source(GCTAObservation* obs, const GModels& models,
608 GRan& ran, GLog* wrklog) 611 GRan& ran, GLog* wrklog)
@@ -631,9 +634,9 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models, @@ -631,9 +634,9 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models,
631 // Get pointer on event list (circumvent const correctness) 634 // Get pointer on event list (circumvent const correctness)
632 GCTAEventList* events = static_cast<GCTAEventList*>(const_cast<GEvents*>(obs->events())); 635 GCTAEventList* events = static_cast<GCTAEventList*>(const_cast<GEvents*>(obs->events()));
633 636
634 - // Extract ROI 637 + // Extract simulation region.
635 GSkyDir dir = events->roi().centre().dir(); 638 GSkyDir dir = events->roi().centre().dir();
636 - double rad = events->roi().radius(); 639 + double rad = events->roi().radius() + g_roi_margin;
637 640
638 // Dump simulation cone information 641 // Dump simulation cone information
639 if (logNormal()) { 642 if (logNormal()) {
@@ -649,7 +652,7 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models, @@ -649,7 +652,7 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models,
649 int indent = 0; 652 int indent = 0;
650 653
651 // Loop over all Good Time Intervals 654 // Loop over all Good Time Intervals
652 - for (int it = 0; it < events->gti().size(); ++it) { 655 + for (int it = 0; it < events->gti().size(); ++it) {
653 656
654 // Extract time interval 657 // Extract time interval
655 GTime tmin = events->gti().tstart(it); 658 GTime tmin = events->gti().tstart(it);
@@ -744,10 +747,14 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models, @@ -744,10 +747,14 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models,
744 *obs, 747 *obs,
745 ran); 748 ran);
746 if (event != NULL) { 749 if (event != NULL) {
747 - event->event_id(m_event_id);  
748 - events->append(*event); 750 + // Use event only if it falls within ROI
  751 + if (event->dir().dist_deg(events->roi().centre().dir()) <=
  752 + events->roi().radius()) {
  753 + event->event_id(m_event_id);
  754 + events->append(*event);
  755 + m_event_id++;
  756 + }
749 delete event; 757 delete event;
750 - m_event_id++;  
751 } 758 }
752 759
753 } // endfor: looped over events 760 } // endfor: looped over events
@@ -886,12 +893,18 @@ void ctobssim::simulate_background(GCTAObservation* obs, @@ -886,12 +893,18 @@ void ctobssim::simulate_background(GCTAObservation* obs,
886 // Get event pointer 893 // Get event pointer
887 GCTAEventAtom* event = (*list)[k]; 894 GCTAEventAtom* event = (*list)[k];
888 895
889 - // Set event identifier  
890 - event->event_id(m_event_id);  
891 - m_event_id++; 896 + // Use event only if it falls within ROI
  897 + if (event->dir().dist_deg(events->roi().centre().dir()) <=
  898 + events->roi().radius()) {
  899 +
  900 + // Set event identifier
  901 + event->event_id(m_event_id);
  902 + m_event_id++;
  903 +
  904 + // Append event
  905 + events->append(*event);
892 906
893 - // Append event  
894 - events->append(*event); 907 + } // endif: event was within ROI
895 908
896 } // endfor: looped over all events 909 } // endfor: looped over all events
897 910
src/ctobssim/ctobssim.hpp
@@ -57,7 +57,7 @@ public: @@ -57,7 +57,7 @@ public:
57 virtual ~ctobssim(void); 57 virtual ~ctobssim(void);
58 58
59 // Operators 59 // Operators
60 - ctobssim& operator= (const ctobssim& app); 60 + ctobssim& operator=(const ctobssim& app);
61 61
62 // Methods 62 // Methods
63 void clear(void); 63 void clear(void);
@@ -87,7 +87,7 @@ protected: @@ -87,7 +87,7 @@ protected:
87 int m_seed; //!< Random number generator seed 87 int m_seed; //!< Random number generator seed
88 double m_ra; //!< RA of pointing direction 88 double m_ra; //!< RA of pointing direction
89 double m_dec; //!< DEC of pointing direction 89 double m_dec; //!< DEC of pointing direction
90 - double m_rad; //!< FOV radius 90 + double m_rad; //!< FOV radius (degrees)
91 double m_tmin; //!< Start time (MET) 91 double m_tmin; //!< Start time (MET)
92 double m_tmax; //!< Stop time (MET) 92 double m_tmax; //!< Stop time (MET)
93 double m_emin; //!< Lower energy (TeV) 93 double m_emin; //!< Lower energy (TeV)
src/ctobssim/ctobssim.par
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 # ------------------------------------------------------------------------- # 5 # ------------------------------------------------------------------------- #
6 # # 6 # #
7 # File: ctobssim.par # 7 # File: ctobssim.par #
8 -# Version: 00-07-00 # 8 +# Version: 00-08-00 #
9 # # 9 # #
10 # Author: Jurgen Knodlseder # 10 # Author: Jurgen Knodlseder #
11 # Jurgen.Knodlseder@irap.omp.eu # 11 # Jurgen.Knodlseder@irap.omp.eu #