diff --git a/pyext/ctobssim.i b/pyext/ctobssim.i index fee00cc..5bda4da 100644 --- a/pyext/ctobssim.i +++ b/pyext/ctobssim.i @@ -1,5 +1,5 @@ /*************************************************************************** - * ctobssim - CTA observation simulation tool * + * ctobssim - Observation simulator tool * * ----------------------------------------------------------------------- * * copyright (C) 2011-2014 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * @@ -20,22 +20,21 @@ ***************************************************************************/ /** * @file ctobssim.i - * @brief CTA observation simulation tool Python interface definition + * @brief Observation simulator tool definition * @author Juergen Knoedlseder */ %{ /* Put headers and other declarations here that are needed for compilation */ #include "ctobssim.hpp" -#include "GTools.hpp" %} /***********************************************************************//** * @class ctobssim * - * @brief CTA data selection tool Python interface + * @brief Observation simulator tool ***************************************************************************/ -class ctobssim : public GApplication { +class ctobssim : public ctool { public: // Constructors and destructors ctobssim(void); @@ -54,7 +53,7 @@ public: /***********************************************************************//** - * @brief CTA observation simulation tool Python extension + * @brief Observation simulation tool Python extension ***************************************************************************/ %extend ctobssim { ctobssim copy() { diff --git a/src/ctobssim/Makefile.am b/src/ctobssim/Makefile.am index 1545fe1..6f39ece 100644 --- a/src/ctobssim/Makefile.am +++ b/src/ctobssim/Makefile.am @@ -1,5 +1,8 @@ ## Process this file with automake to produce Makefile.in +# Set include directories +INCLUDES = -I$(top_srcdir)/src/support + # Program name bin_PROGRAMS = ctobssim @@ -15,7 +18,7 @@ libctobssim_la_LDFLAGS = @OPENMP_LIB_LDFLAGS@ ctobssim_SOURCES = main.cpp ctobssim_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@ ctobssim_CPPFLAGS = @CPPFLAGS@ -ctobssim_LDADD = libctobssim.la +ctobssim_LDADD = libctobssim.la $(top_srcdir)/src/support/libsupport.la # Parameter files pfilesdir = $(prefix)/syspfiles diff --git a/src/ctobssim/ctobssim.cpp b/src/ctobssim/ctobssim.cpp index cac0f25..9994d61 100644 --- a/src/ctobssim/ctobssim.cpp +++ b/src/ctobssim/ctobssim.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * ctobssim - CTA observation simulator tool * + * ctobssim - Observation simulator tool * * ----------------------------------------------------------------------- * * copyright (C) 2011-2014 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * @@ -20,7 +20,7 @@ ***************************************************************************/ /** * @file ctobssim.cpp - * @brief CTA observation simulator tool implementation + * @brief Observation simulator tool implementation * @author Juergen Knoedlseder */ @@ -53,14 +53,11 @@ const double g_roi_margin = 0.5; //!< Simulation radius margin (degrees) /***********************************************************************//** * @brief Void constructor ***************************************************************************/ -ctobssim::ctobssim(void) : GApplication(CTOBSSIM_NAME, CTOBSSIM_VERSION) +ctobssim::ctobssim(void) : ctool(CTOBSSIM_NAME, CTOBSSIM_VERSION) { // Initialise members init_members(); - // Write header into logger - log_header(); - // Return return; } @@ -74,7 +71,7 @@ ctobssim::ctobssim(void) : GApplication(CTOBSSIM_NAME, CTOBSSIM_VERSION) * Constructs application by initialising from an observation container. ***************************************************************************/ ctobssim::ctobssim(const GObservations& obs) : - GApplication(CTOBSSIM_NAME, CTOBSSIM_VERSION) + ctool(CTOBSSIM_NAME, CTOBSSIM_VERSION) { // Initialise members init_members(); @@ -82,9 +79,6 @@ ctobssim::ctobssim(const GObservations& obs) : // Set observations m_obs = obs; - // Write header into logger - log_header(); - // Return return; } @@ -99,14 +93,11 @@ ctobssim::ctobssim(const GObservations& obs) : * Constructs application using command line arguments for parameter setting. ***************************************************************************/ ctobssim::ctobssim(int argc, char *argv[]) : - GApplication(CTOBSSIM_NAME, CTOBSSIM_VERSION, argc, argv) + ctool(CTOBSSIM_NAME, CTOBSSIM_VERSION, argc, argv) { // Initialise members init_members(); - // Write header into logger - log_header(); - // Return return; } @@ -117,7 +108,7 @@ ctobssim::ctobssim(int argc, char *argv[]) : * * @param[in] app Application. ***************************************************************************/ -ctobssim::ctobssim(const ctobssim& app) : GApplication(app) +ctobssim::ctobssim(const ctobssim& app) : ctool(app) { // Initialise members init_members(); @@ -155,13 +146,13 @@ ctobssim::~ctobssim(void) * @param[in] app Application. * @return Application. ***************************************************************************/ -ctobssim& ctobssim::operator= (const ctobssim& app) +ctobssim& ctobssim::operator=(const ctobssim& app) { // Execute only if object is not identical if (this != &app) { // Copy base class members - this->GApplication::operator=(app); + this->ctool::operator=(app); // Free members free_members(); @@ -192,10 +183,12 @@ void ctobssim::clear(void) { // Free members free_members(); + this->ctool::free_members(); this->GApplication::free_members(); // Initialise members this->GApplication::init_members(); + this->ctool::init_members(); init_members(); // Return @@ -453,8 +446,6 @@ void ctobssim::get_parameters(void) // Get CTA observation parameters m_infile = (*this)["infile"].filename(); - m_caldb = (*this)["caldb"].string(); - m_irf = (*this)["irf"].string(); m_ra = (*this)["ra"].real(); m_dec = (*this)["dec"].real(); @@ -467,21 +458,11 @@ void ctobssim::get_parameters(void) // Allocate CTA observation GCTAObservation obs; - // Set calibration database. If specified parameter is a directory - // then use this as the pathname to the calibration database. Other- - // wise interpret this as the instrument name, the mission being - // "cta" - GCaldb caldb; - if (gammalib::dir_exists(m_caldb)) { - caldb.rootdir(m_caldb); - } - else { - caldb.open("cta", m_caldb); - } + // Set response + set_obs_response(&obs); - // Set CTA observation attributes + // Set pointing obs.pointing(pnt); - obs.response(m_irf, caldb); // Set event list (queries remaining parameters) set_list(&obs); @@ -1042,8 +1023,6 @@ void ctobssim::init_members(void) m_infile.clear(); m_outfile.clear(); m_prefix.clear(); - m_caldb.clear(); - m_irf.clear(); m_seed = 1; m_ra = 0.0; m_dec = 0.0; @@ -1092,8 +1071,6 @@ void ctobssim::copy_members(const ctobssim& app) m_infile = app.m_infile; m_outfile = app.m_outfile; m_prefix = app.m_prefix; - m_caldb = app.m_caldb; - m_irf = app.m_irf; m_seed = app.m_seed; m_ra = app.m_ra; m_dec = app.m_dec; @@ -1125,11 +1102,6 @@ void ctobssim::copy_members(const ctobssim& app) ***************************************************************************/ void ctobssim::free_members(void) { - // Write separator into logger - if (logTerse()) { - log << std::endl; - } - // Return return; } diff --git a/src/ctobssim/ctobssim.hpp b/src/ctobssim/ctobssim.hpp index 9ff8210..aaadb89 100644 --- a/src/ctobssim/ctobssim.hpp +++ b/src/ctobssim/ctobssim.hpp @@ -1,5 +1,5 @@ /*************************************************************************** - * ctobssim - CTA observation simulator tool * + * ctobssim - Observation simulator tool * * ----------------------------------------------------------------------- * * copyright (C) 2011-2014 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * @@ -20,7 +20,7 @@ ***************************************************************************/ /** * @file ctobssim.hpp - * @brief CTA observation simulator tool definition + * @brief Observation simulator tool definition * @author Juergen Knoedlseder */ @@ -30,6 +30,7 @@ /* __ Includes ___________________________________________________________ */ #include "GammaLib.hpp" #include "GCTALib.hpp" +#include "ctool.hpp" /* __Definitions _________________________________________________________ */ #define CTOBSSIM_NAME "ctobssim" @@ -39,7 +40,7 @@ /***********************************************************************//** * @class ctobssim * - * @brief CTA observation simulator tool interface definition + * @brief Observation simulator tool * * This class simulates CTA observation(s) using Monte Carlo sampling of the * source and background models. The class supports simulation of data of @@ -47,7 +48,8 @@ * processed and the save method is called, events FITS files will be written * for each observation. ***************************************************************************/ -class ctobssim : public GApplication { +class ctobssim : public ctool { + public: // Constructors and destructors ctobssim(void); @@ -85,21 +87,19 @@ protected: void save_xml(void); // User parameters - std::string m_infile; //!< Input model - std::string m_outfile; //!< Output events file - std::string m_prefix; //!< Prefix for multiple event lists - std::string m_caldb; //!< Calibration database repository - std::string m_irf; //!< Instrument response function - int m_seed; //!< Random number generator seed - double m_ra; //!< RA of pointing direction - double m_dec; //!< DEC of pointing direction - double m_rad; //!< FOV radius (degrees) - double m_tmin; //!< Start time (MET) - double m_tmax; //!< Stop time (MET) - double m_emin; //!< Lower energy (TeV) - double m_emax; //!< Upper energy (TeV) - bool m_apply_edisp; //!< Apply energy dispersion? - double m_deadc; //!< Average deadtime correction + std::string m_infile; //!< Input model + std::string m_outfile; //!< Output events file + std::string m_prefix; //!< Prefix for multiple event lists + int m_seed; //!< Random number generator seed + double m_ra; //!< RA of pointing direction + double m_dec; //!< DEC of pointing direction + double m_rad; //!< FOV radius (degrees) + double m_tmin; //!< Start time (MET) + double m_tmax; //!< Stop time (MET) + double m_emin; //!< Lower energy (TeV) + double m_emax; //!< Upper energy (TeV) + bool m_apply_edisp; //!< Apply energy dispersion? + double m_deadc; //!< Average deadtime correction // Protected members double m_area; //!< Surface area for simulation (cm2)