Commit 05cf25d92a9be83c47919b5720f0b2a43943a32a
1 parent
8f4e5b3e
ctobssim now derives from ctool base class.
Showing
4 changed files
with
41 additions
and
67 deletions
pyext/ctobssim.i
| 1 | 1 | /*************************************************************************** |
| 2 | - * ctobssim - CTA observation simulation tool * | |
| 2 | + * ctobssim - Observation simulator tool * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | 4 | * copyright (C) 2011-2014 by Juergen Knoedlseder * |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| ... | ... | @@ -20,22 +20,21 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file ctobssim.i |
| 23 | - * @brief CTA observation simulation tool Python interface definition | |
| 23 | + * @brief Observation simulator tool definition | |
| 24 | 24 | * @author Juergen Knoedlseder |
| 25 | 25 | */ |
| 26 | 26 | %{ |
| 27 | 27 | /* Put headers and other declarations here that are needed for compilation */ |
| 28 | 28 | #include "ctobssim.hpp" |
| 29 | -#include "GTools.hpp" | |
| 30 | 29 | %} |
| 31 | 30 | |
| 32 | 31 | |
| 33 | 32 | /***********************************************************************//** |
| 34 | 33 | * @class ctobssim |
| 35 | 34 | * |
| 36 | - * @brief CTA data selection tool Python interface | |
| 35 | + * @brief Observation simulator tool | |
| 37 | 36 | ***************************************************************************/ |
| 38 | -class ctobssim : public GApplication { | |
| 37 | +class ctobssim : public ctool { | |
| 39 | 38 | public: |
| 40 | 39 | // Constructors and destructors |
| 41 | 40 | ctobssim(void); |
| ... | ... | @@ -54,7 +53,7 @@ public: |
| 54 | 53 | |
| 55 | 54 | |
| 56 | 55 | /***********************************************************************//** |
| 57 | - * @brief CTA observation simulation tool Python extension | |
| 56 | + * @brief Observation simulation tool Python extension | |
| 58 | 57 | ***************************************************************************/ |
| 59 | 58 | %extend ctobssim { |
| 60 | 59 | ctobssim copy() { | ... | ... |
src/ctobssim/Makefile.am
| 1 | 1 | ## Process this file with automake to produce Makefile.in |
| 2 | 2 | |
| 3 | +# Set include directories | |
| 4 | +INCLUDES = -I$(top_srcdir)/src/support | |
| 5 | + | |
| 3 | 6 | # Program name |
| 4 | 7 | bin_PROGRAMS = ctobssim |
| 5 | 8 | |
| ... | ... | @@ -15,7 +18,7 @@ libctobssim_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@ |
| 15 | 18 | ctobssim_SOURCES = main.cpp |
| 16 | 19 | ctobssim_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@ |
| 17 | 20 | ctobssim_CPPFLAGS = @CPPFLAGS@ |
| 18 | -ctobssim_LDADD = libctobssim.la | |
| 21 | +ctobssim_LDADD = libctobssim.la $(top_srcdir)/src/support/libsupport.la | |
| 19 | 22 | |
| 20 | 23 | # Parameter files |
| 21 | 24 | pfilesdir = $(prefix)/syspfiles | ... | ... |
src/ctobssim/ctobssim.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * ctobssim - CTA observation simulator tool * | |
| 2 | + * ctobssim - Observation simulator tool * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | 4 | * copyright (C) 2011-2014 by Juergen Knoedlseder * |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| ... | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file ctobssim.cpp |
| 23 | - * @brief CTA observation simulator tool implementation | |
| 23 | + * @brief Observation simulator tool implementation | |
| 24 | 24 | * @author Juergen Knoedlseder |
| 25 | 25 | */ |
| 26 | 26 | |
| ... | ... | @@ -53,14 +53,11 @@ const double g_roi_margin = 0.5; //!< Simulation radius margin (degrees) |
| 53 | 53 | /***********************************************************************//** |
| 54 | 54 | * @brief Void constructor |
| 55 | 55 | ***************************************************************************/ |
| 56 | -ctobssim::ctobssim(void) : GApplication(CTOBSSIM_NAME, CTOBSSIM_VERSION) | |
| 56 | +ctobssim::ctobssim(void) : ctool(CTOBSSIM_NAME, CTOBSSIM_VERSION) | |
| 57 | 57 | { |
| 58 | 58 | // Initialise members |
| 59 | 59 | init_members(); |
| 60 | 60 | |
| 61 | - // Write header into logger | |
| 62 | - log_header(); | |
| 63 | - | |
| 64 | 61 | // Return |
| 65 | 62 | return; |
| 66 | 63 | } |
| ... | ... | @@ -74,7 +71,7 @@ ctobssim::ctobssim(void) : GApplication(CTOBSSIM_NAME, CTOBSSIM_VERSION) |
| 74 | 71 | * Constructs application by initialising from an observation container. |
| 75 | 72 | ***************************************************************************/ |
| 76 | 73 | ctobssim::ctobssim(const GObservations& obs) : |
| 77 | - GApplication(CTOBSSIM_NAME, CTOBSSIM_VERSION) | |
| 74 | + ctool(CTOBSSIM_NAME, CTOBSSIM_VERSION) | |
| 78 | 75 | { |
| 79 | 76 | // Initialise members |
| 80 | 77 | init_members(); |
| ... | ... | @@ -82,9 +79,6 @@ ctobssim::ctobssim(const GObservations& obs) : |
| 82 | 79 | // Set observations |
| 83 | 80 | m_obs = obs; |
| 84 | 81 | |
| 85 | - // Write header into logger | |
| 86 | - log_header(); | |
| 87 | - | |
| 88 | 82 | // Return |
| 89 | 83 | return; |
| 90 | 84 | } |
| ... | ... | @@ -99,14 +93,11 @@ ctobssim::ctobssim(const GObservations& obs) : |
| 99 | 93 | * Constructs application using command line arguments for parameter setting. |
| 100 | 94 | ***************************************************************************/ |
| 101 | 95 | ctobssim::ctobssim(int argc, char *argv[]) : |
| 102 | - GApplication(CTOBSSIM_NAME, CTOBSSIM_VERSION, argc, argv) | |
| 96 | + ctool(CTOBSSIM_NAME, CTOBSSIM_VERSION, argc, argv) | |
| 103 | 97 | { |
| 104 | 98 | // Initialise members |
| 105 | 99 | init_members(); |
| 106 | 100 | |
| 107 | - // Write header into logger | |
| 108 | - log_header(); | |
| 109 | - | |
| 110 | 101 | // Return |
| 111 | 102 | return; |
| 112 | 103 | } |
| ... | ... | @@ -117,7 +108,7 @@ ctobssim::ctobssim(int argc, char *argv[]) : |
| 117 | 108 | * |
| 118 | 109 | * @param[in] app Application. |
| 119 | 110 | ***************************************************************************/ |
| 120 | -ctobssim::ctobssim(const ctobssim& app) : GApplication(app) | |
| 111 | +ctobssim::ctobssim(const ctobssim& app) : ctool(app) | |
| 121 | 112 | { |
| 122 | 113 | // Initialise members |
| 123 | 114 | init_members(); |
| ... | ... | @@ -155,13 +146,13 @@ ctobssim::~ctobssim(void) |
| 155 | 146 | * @param[in] app Application. |
| 156 | 147 | * @return Application. |
| 157 | 148 | ***************************************************************************/ |
| 158 | -ctobssim& ctobssim::operator= (const ctobssim& app) | |
| 149 | +ctobssim& ctobssim::operator=(const ctobssim& app) | |
| 159 | 150 | { |
| 160 | 151 | // Execute only if object is not identical |
| 161 | 152 | if (this != &app) { |
| 162 | 153 | |
| 163 | 154 | // Copy base class members |
| 164 | - this->GApplication::operator=(app); | |
| 155 | + this->ctool::operator=(app); | |
| 165 | 156 | |
| 166 | 157 | // Free members |
| 167 | 158 | free_members(); |
| ... | ... | @@ -192,10 +183,12 @@ void ctobssim::clear(void) |
| 192 | 183 | { |
| 193 | 184 | // Free members |
| 194 | 185 | free_members(); |
| 186 | + this->ctool::free_members(); | |
| 195 | 187 | this->GApplication::free_members(); |
| 196 | 188 | |
| 197 | 189 | // Initialise members |
| 198 | 190 | this->GApplication::init_members(); |
| 191 | + this->ctool::init_members(); | |
| 199 | 192 | init_members(); |
| 200 | 193 | |
| 201 | 194 | // Return |
| ... | ... | @@ -453,8 +446,6 @@ void ctobssim::get_parameters(void) |
| 453 | 446 | |
| 454 | 447 | // Get CTA observation parameters |
| 455 | 448 | m_infile = (*this)["infile"].filename(); |
| 456 | - m_caldb = (*this)["caldb"].string(); | |
| 457 | - m_irf = (*this)["irf"].string(); | |
| 458 | 449 | m_ra = (*this)["ra"].real(); |
| 459 | 450 | m_dec = (*this)["dec"].real(); |
| 460 | 451 | |
| ... | ... | @@ -467,21 +458,11 @@ void ctobssim::get_parameters(void) |
| 467 | 458 | // Allocate CTA observation |
| 468 | 459 | GCTAObservation obs; |
| 469 | 460 | |
| 470 | - // Set calibration database. If specified parameter is a directory | |
| 471 | - // then use this as the pathname to the calibration database. Other- | |
| 472 | - // wise interpret this as the instrument name, the mission being | |
| 473 | - // "cta" | |
| 474 | - GCaldb caldb; | |
| 475 | - if (gammalib::dir_exists(m_caldb)) { | |
| 476 | - caldb.rootdir(m_caldb); | |
| 477 | - } | |
| 478 | - else { | |
| 479 | - caldb.open("cta", m_caldb); | |
| 480 | - } | |
| 461 | + // Set response | |
| 462 | + set_obs_response(&obs); | |
| 481 | 463 | |
| 482 | - // Set CTA observation attributes | |
| 464 | + // Set pointing | |
| 483 | 465 | obs.pointing(pnt); |
| 484 | - obs.response(m_irf, caldb); | |
| 485 | 466 | |
| 486 | 467 | // Set event list (queries remaining parameters) |
| 487 | 468 | set_list(&obs); |
| ... | ... | @@ -1042,8 +1023,6 @@ void ctobssim::init_members(void) |
| 1042 | 1023 | m_infile.clear(); |
| 1043 | 1024 | m_outfile.clear(); |
| 1044 | 1025 | m_prefix.clear(); |
| 1045 | - m_caldb.clear(); | |
| 1046 | - m_irf.clear(); | |
| 1047 | 1026 | m_seed = 1; |
| 1048 | 1027 | m_ra = 0.0; |
| 1049 | 1028 | m_dec = 0.0; |
| ... | ... | @@ -1092,8 +1071,6 @@ void ctobssim::copy_members(const ctobssim& app) |
| 1092 | 1071 | m_infile = app.m_infile; |
| 1093 | 1072 | m_outfile = app.m_outfile; |
| 1094 | 1073 | m_prefix = app.m_prefix; |
| 1095 | - m_caldb = app.m_caldb; | |
| 1096 | - m_irf = app.m_irf; | |
| 1097 | 1074 | m_seed = app.m_seed; |
| 1098 | 1075 | m_ra = app.m_ra; |
| 1099 | 1076 | m_dec = app.m_dec; |
| ... | ... | @@ -1125,11 +1102,6 @@ void ctobssim::copy_members(const ctobssim& app) |
| 1125 | 1102 | ***************************************************************************/ |
| 1126 | 1103 | void ctobssim::free_members(void) |
| 1127 | 1104 | { |
| 1128 | - // Write separator into logger | |
| 1129 | - if (logTerse()) { | |
| 1130 | - log << std::endl; | |
| 1131 | - } | |
| 1132 | - | |
| 1133 | 1105 | // Return |
| 1134 | 1106 | return; |
| 1135 | 1107 | } | ... | ... |
src/ctobssim/ctobssim.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * ctobssim - CTA observation simulator tool * | |
| 2 | + * ctobssim - Observation simulator tool * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | 4 | * copyright (C) 2011-2014 by Juergen Knoedlseder * |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| ... | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file ctobssim.hpp |
| 23 | - * @brief CTA observation simulator tool definition | |
| 23 | + * @brief Observation simulator tool definition | |
| 24 | 24 | * @author Juergen Knoedlseder |
| 25 | 25 | */ |
| 26 | 26 | |
| ... | ... | @@ -30,6 +30,7 @@ |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include "GammaLib.hpp" |
| 32 | 32 | #include "GCTALib.hpp" |
| 33 | +#include "ctool.hpp" | |
| 33 | 34 | |
| 34 | 35 | /* __Definitions _________________________________________________________ */ |
| 35 | 36 | #define CTOBSSIM_NAME "ctobssim" |
| ... | ... | @@ -39,7 +40,7 @@ |
| 39 | 40 | /***********************************************************************//** |
| 40 | 41 | * @class ctobssim |
| 41 | 42 | * |
| 42 | - * @brief CTA observation simulator tool interface definition | |
| 43 | + * @brief Observation simulator tool | |
| 43 | 44 | * |
| 44 | 45 | * This class simulates CTA observation(s) using Monte Carlo sampling of the |
| 45 | 46 | * source and background models. The class supports simulation of data of |
| ... | ... | @@ -47,7 +48,8 @@ |
| 47 | 48 | * processed and the save method is called, events FITS files will be written |
| 48 | 49 | * for each observation. |
| 49 | 50 | ***************************************************************************/ |
| 50 | -class ctobssim : public GApplication { | |
| 51 | +class ctobssim : public ctool { | |
| 52 | + | |
| 51 | 53 | public: |
| 52 | 54 | // Constructors and destructors |
| 53 | 55 | ctobssim(void); |
| ... | ... | @@ -85,21 +87,19 @@ protected: |
| 85 | 87 | void save_xml(void); |
| 86 | 88 | |
| 87 | 89 | // User parameters |
| 88 | - std::string m_infile; //!< Input model | |
| 89 | - std::string m_outfile; //!< Output events file | |
| 90 | - std::string m_prefix; //!< Prefix for multiple event lists | |
| 91 | - std::string m_caldb; //!< Calibration database repository | |
| 92 | - std::string m_irf; //!< Instrument response function | |
| 93 | - int m_seed; //!< Random number generator seed | |
| 94 | - double m_ra; //!< RA of pointing direction | |
| 95 | - double m_dec; //!< DEC of pointing direction | |
| 96 | - double m_rad; //!< FOV radius (degrees) | |
| 97 | - double m_tmin; //!< Start time (MET) | |
| 98 | - double m_tmax; //!< Stop time (MET) | |
| 99 | - double m_emin; //!< Lower energy (TeV) | |
| 100 | - double m_emax; //!< Upper energy (TeV) | |
| 101 | - bool m_apply_edisp; //!< Apply energy dispersion? | |
| 102 | - double m_deadc; //!< Average deadtime correction | |
| 90 | + std::string m_infile; //!< Input model | |
| 91 | + std::string m_outfile; //!< Output events file | |
| 92 | + std::string m_prefix; //!< Prefix for multiple event lists | |
| 93 | + int m_seed; //!< Random number generator seed | |
| 94 | + double m_ra; //!< RA of pointing direction | |
| 95 | + double m_dec; //!< DEC of pointing direction | |
| 96 | + double m_rad; //!< FOV radius (degrees) | |
| 97 | + double m_tmin; //!< Start time (MET) | |
| 98 | + double m_tmax; //!< Stop time (MET) | |
| 99 | + double m_emin; //!< Lower energy (TeV) | |
| 100 | + double m_emax; //!< Upper energy (TeV) | |
| 101 | + bool m_apply_edisp; //!< Apply energy dispersion? | |
| 102 | + double m_deadc; //!< Average deadtime correction | |
| 103 | 103 | |
| 104 | 104 | // Protected members |
| 105 | 105 | double m_area; //!< Surface area for simulation (cm2) | ... | ... |