diff --git a/pyext/ctbin.i b/pyext/ctbin.i index a485cee..76b70fc 100644 --- a/pyext/ctbin.i +++ b/pyext/ctbin.i @@ -45,7 +45,6 @@ public: // Methods void clear(void); - void execute(void); void run(void); void save(void); const GObservations& obs(void) const; diff --git a/pyext/ctbkgcube.i b/pyext/ctbkgcube.i index cc4cb1e..3c7d35e 100644 --- a/pyext/ctbkgcube.i +++ b/pyext/ctbkgcube.i @@ -45,7 +45,6 @@ public: // Methods void clear(void); - void execute(void); void run(void); void save(void); const GCTAEventCube& cube(void) const; diff --git a/pyext/ctcubemask.i b/pyext/ctcubemask.i index 5abf661..caeab73 100644 --- a/pyext/ctcubemask.i +++ b/pyext/ctcubemask.i @@ -45,7 +45,6 @@ public: // Methods void clear(void); - void execute(void); void run(void); void save(void); const GObservations& obs(void) const; diff --git a/pyext/ctexpcube.i b/pyext/ctexpcube.i index a2fe192..771384c 100644 --- a/pyext/ctexpcube.i +++ b/pyext/ctexpcube.i @@ -45,7 +45,6 @@ public: // Methods void clear(void); - void execute(void); void run(void); void save(void); const GCTAExposure& expcube(void) const; diff --git a/pyext/ctlike.i b/pyext/ctlike.i index ceca217..def8e83 100644 --- a/pyext/ctlike.i +++ b/pyext/ctlike.i @@ -32,7 +32,7 @@ /***********************************************************************//** * @class ctlike * - * @brief CTA maximum likelihood tool Python interface + * @brief Maximum likelihood fitting tool ***************************************************************************/ class ctlike : public ctool { public: @@ -45,7 +45,6 @@ public: // Methods void clear(void); - void execute(void); void run(void); void save(void); const GObservations& obs(void) const; diff --git a/pyext/ctmodel.i b/pyext/ctmodel.i index ad5792f..dd43f3d 100644 --- a/pyext/ctmodel.i +++ b/pyext/ctmodel.i @@ -45,7 +45,6 @@ public: // Methods void clear(void); - void execute(void); void run(void); void save(void); const GObservations& obs(void) const; diff --git a/pyext/ctobssim.i b/pyext/ctobssim.i index 5bda4da..eb3149d 100644 --- a/pyext/ctobssim.i +++ b/pyext/ctobssim.i @@ -45,7 +45,6 @@ public: // Methods void clear(void); - void execute(void); void run(void); void save(void); const GObservations& obs(void) const; diff --git a/pyext/ctool.i b/pyext/ctool.i index c308ddd..9923689 100644 --- a/pyext/ctool.i +++ b/pyext/ctool.i @@ -44,5 +44,11 @@ public: ctool(const ctool& app); virtual ~ctool(void); - // Methods + // Pure virtual methods + virtual void clear(void) = 0; + virtual void run(void) = 0; + virtual void save(void) = 0; + + // Public methods + virtual void execute(void); }; diff --git a/pyext/ctpsfcube.i b/pyext/ctpsfcube.i index 8b9f9ee..4548228 100644 --- a/pyext/ctpsfcube.i +++ b/pyext/ctpsfcube.i @@ -46,7 +46,6 @@ public: // Methods void clear(void); - void execute(void); void run(void); void save(void); const GCTAMeanPsf& psfcube(void) const; diff --git a/pyext/ctselect.i b/pyext/ctselect.i index 9661302..fa1eff9 100644 --- a/pyext/ctselect.i +++ b/pyext/ctselect.i @@ -45,7 +45,6 @@ public: // Methods void clear(void); - void execute(void); void run(void); void save(void); const GObservations& obs(void) const; diff --git a/pyext/ctskymap.i b/pyext/ctskymap.i index 1759b50..93a7384 100644 --- a/pyext/ctskymap.i +++ b/pyext/ctskymap.i @@ -45,7 +45,6 @@ public: // Methods void clear(void); - void execute(void); void run(void); void save(void); const GSkymap& map(void) const; diff --git a/pyext/cttsmap.i b/pyext/cttsmap.i index 7e95b64..4de65c9 100644 --- a/pyext/cttsmap.i +++ b/pyext/cttsmap.i @@ -45,7 +45,6 @@ public: // Methods void clear(void); - void execute(void); void run(void); void save(void); const GObservations& obs(void) const; diff --git a/src/ctbin/ctbin.cpp b/src/ctbin/ctbin.cpp index a534d8e..3435ea0 100644 --- a/src/ctbin/ctbin.cpp +++ b/src/ctbin/ctbin.cpp @@ -192,31 +192,6 @@ void ctbin::clear(void) /***********************************************************************//** - * @brief Execute application - * - * This is the main execution method of the ctbin class. It is invoked when - * the executable is called from command line. - * - * The method reads the task parameters, bins the event list(s) into counts - * map(s), and writes the results into FITS files on disk. - ***************************************************************************/ -void ctbin::execute(void) -{ - // Signal that some parameters should be read ahead - m_read_ahead = true; - - // Bin the event data - run(); - - // Save the counts map into FITS file - save(); - - // Return - return; -} - - -/***********************************************************************//** * @brief Bin the event data * * This method loops over all observations found in the observation conatiner @@ -371,16 +346,12 @@ void ctbin::init_members(void) // Initialise protected members m_obs.clear(); - m_read_ahead = false; m_cube.clear(); m_ebounds.clear(); m_gti.clear(); m_ontime = 0.0; m_livetime = 0.0; - // Set logger properties - log.date(true); - // Return return; } @@ -407,7 +378,6 @@ void ctbin::copy_members(const ctbin& app) // Copy protected members m_obs = app.m_obs; - m_read_ahead = app.m_read_ahead; m_cube = app.m_cube; m_ebounds = app.m_ebounds; m_gti = app.m_gti; @@ -491,7 +461,7 @@ void ctbin::get_parameters(void) // Optionally read ahead parameters so that they get correctly // dumped into the log file - if (m_read_ahead) { + if (read_ahead()) { m_outfile = (*this)["outfile"].filename(); } diff --git a/src/ctbin/ctbin.hpp b/src/ctbin/ctbin.hpp index fa8294f..7be2640 100644 --- a/src/ctbin/ctbin.hpp +++ b/src/ctbin/ctbin.hpp @@ -75,7 +75,6 @@ public: // Methods void clear(void); - void execute(void); void run(void); void save(void); const GObservations& obs(void) const; @@ -105,7 +104,6 @@ protected: // Protected members GObservations m_obs; //!< Observation container - bool m_read_ahead; //!< Read ahead parameters GSkymap m_cube; //!< Event cube GEbounds m_ebounds; //!< Energy boundaries GGti m_gti; //!< Good time intervals diff --git a/src/ctbkgcube/ctbkgcube.cpp b/src/ctbkgcube/ctbkgcube.cpp index 18f0cd9..85f587a 100644 --- a/src/ctbkgcube/ctbkgcube.cpp +++ b/src/ctbkgcube/ctbkgcube.cpp @@ -105,7 +105,7 @@ ctbkgcube::ctbkgcube(int argc, char *argv[]) : /***********************************************************************//** * @brief Copy constructor * - * @param[in] app ctbkgcube application. + * @param[in] app Application. ***************************************************************************/ ctbkgcube::ctbkgcube(const ctbkgcube& app) : ctool(app) { @@ -142,8 +142,8 @@ ctbkgcube::~ctbkgcube(void) /***********************************************************************//** * @brief Assignment operator * - * @param[in] app ctbkgcube application. - * @return Returns ctbkgcube application. + * @param[in] app Application. + * @return Returns application. ***************************************************************************/ ctbkgcube& ctbkgcube::operator=(const ctbkgcube& app) { @@ -196,29 +196,6 @@ void ctbkgcube::clear(void) /***********************************************************************//** - * @brief Execute application - * - * This is the main execution method of the ctbkgcube class. It is invoked - * when the executable is called from command line. The method generates - * the background cube and saves the result. - ***************************************************************************/ -void ctbkgcube::execute(void) -{ - // Signal that some parameters should be read ahead - m_read_ahead = true; - - // Create the background cube - run(); - - // Save the background cube into the output FITS file - save(); - - // Return - return; -} - - -/***********************************************************************//** * @brief Generate the background cube(s). * * This method reads the task parameters from the parfile, sets up the @@ -424,16 +401,12 @@ void ctbkgcube::save(void) void ctbkgcube::init_members(void) { // Initialise members - m_read_ahead = false; m_obs.clear(); m_bkgcube.clear(); m_bkgmdl.clear(); m_ebounds.clear(); m_livetime = 0.0; - // Set logger properties - log.date(true); - // Return return; } @@ -447,12 +420,11 @@ void ctbkgcube::init_members(void) void ctbkgcube::copy_members(const ctbkgcube& app) { // Copy members - m_read_ahead = app.m_read_ahead; - m_obs = app.m_obs; - m_bkgcube = app.m_bkgcube; - m_bkgmdl = app.m_bkgmdl; - m_ebounds = app.m_ebounds; - m_livetime = app.m_livetime; + m_obs = app.m_obs; + m_bkgcube = app.m_bkgcube; + m_bkgmdl = app.m_bkgmdl; + m_ebounds = app.m_ebounds; + m_livetime = app.m_livetime; // Return return; @@ -540,7 +512,7 @@ void ctbkgcube::get_parameters(void) } // Read output filename (if needed) - if (m_read_ahead) { + if (read_ahead()) { std::string filename = (*this)["outfile"].filename(); } diff --git a/src/ctbkgcube/ctbkgcube.hpp b/src/ctbkgcube/ctbkgcube.hpp index 4024237..04a27f3 100644 --- a/src/ctbkgcube/ctbkgcube.hpp +++ b/src/ctbkgcube/ctbkgcube.hpp @@ -57,7 +57,6 @@ public: // Methods void clear(void); - void execute(void); void run(void); void save(void); const GCTAEventCube& cube(void) const; @@ -73,7 +72,6 @@ protected: void fill_cube(GCTAObservation* obs); // Protected members - bool m_read_ahead; //!< Read ahead parameters GObservations m_obs; //!< Observation container GCTAEventCube m_bkgcube; //!< Background cube GModels m_bkgmdl; //!< CTA background models diff --git a/src/ctcubemask/ctcubemask.cpp b/src/ctcubemask/ctcubemask.cpp index d4a9348..fd57519 100644 --- a/src/ctcubemask/ctcubemask.cpp +++ b/src/ctcubemask/ctcubemask.cpp @@ -143,6 +143,7 @@ ctcubemask::~ctcubemask(void) * @brief Assignment operator * * @param[in] app Application. + * @return Application. ***************************************************************************/ ctcubemask& ctcubemask::operator=(const ctcubemask& app) { @@ -195,28 +196,6 @@ void ctcubemask::clear(void) /***********************************************************************//** - * @brief Execute application - * - * This method applies the cube mask and saves the result. - ***************************************************************************/ -void ctcubemask::execute(void) -{ - // Signal that some parameters should be read ahead - m_read_ahead = true; - - // Perform event selection - run(); - - // Save results - save(); - - // Return - return; -} - - - -/***********************************************************************//** * @brief mask data cube * * This method reads in the application parameters and loops over all @@ -416,7 +395,7 @@ void ctcubemask::get_parameters(void) // Optionally read ahead parameters so that they get correctly // dumped into the log file - if (m_read_ahead) { + if (read_ahead()) { m_outfile = (*this)["outfile"].filename(); } @@ -574,10 +553,6 @@ void ctcubemask::init_members(void) m_obs.clear(); m_infiles.clear(); m_use_xml = false; - m_read_ahead = false; - - // Set logger properties - log.date(true); // Return return; @@ -607,7 +582,6 @@ void ctcubemask::copy_members(const ctcubemask& app) m_obs = app.m_obs; m_infiles = app.m_infiles; m_use_xml = app.m_use_xml; - m_read_ahead = app.m_read_ahead; // Return return; @@ -619,11 +593,6 @@ void ctcubemask::copy_members(const ctcubemask& app) ***************************************************************************/ void ctcubemask::free_members(void) { - // Write separator into logger - if (logTerse()) { - log << std::endl; - } - // Return return; } diff --git a/src/ctcubemask/ctcubemask.hpp b/src/ctcubemask/ctcubemask.hpp index 30a11f8..5b2f961 100644 --- a/src/ctcubemask/ctcubemask.hpp +++ b/src/ctcubemask/ctcubemask.hpp @@ -59,7 +59,6 @@ public: // Methods void clear(void); - void execute(void); void run(void); void save(void); const GObservations& obs(void) const; @@ -94,7 +93,6 @@ protected: GObservations m_obs; //!< Observations container std::vector m_infiles; //!< Input event filenames bool m_use_xml; //!< Use XML file instead of FITS file - bool m_read_ahead; //!< Read ahead parameters }; diff --git a/src/ctexpcube/ctexpcube.cpp b/src/ctexpcube/ctexpcube.cpp index 2e09eba..bf69e38 100644 --- a/src/ctexpcube/ctexpcube.cpp +++ b/src/ctexpcube/ctexpcube.cpp @@ -113,7 +113,7 @@ ctexpcube::ctexpcube(int argc, char *argv[]) : /***********************************************************************//** * @brief Copy constructor * - * @param[in] app ctexpcube application. + * @param[in] app Application. ***************************************************************************/ ctexpcube::ctexpcube(const ctexpcube& app) : ctool(app) { @@ -150,8 +150,8 @@ ctexpcube::~ctexpcube(void) /***********************************************************************//** * @brief Assignment operator * - * @param[in] app ctexpcube application. - * @return Returns ctexpcube application. + * @param[in] app Application. + * @return Application. ***************************************************************************/ ctexpcube& ctexpcube::operator=(const ctexpcube& app) { @@ -204,29 +204,6 @@ void ctexpcube::clear(void) /***********************************************************************//** - * @brief Execute application - * - * This is the main execution method of the ctexpcube class. It is invoked - * when the executable is called from command line. The method generates - * the exposure cube and saves the result. - ***************************************************************************/ -void ctexpcube::execute(void) -{ - // Signal that some parameters should be read ahead - m_read_ahead = true; - - // Create the exposure cube - run(); - - // Save the exposure cube into the output FITS file - save(); - - // Return - return; -} - - -/***********************************************************************//** * @brief Generate the exposure cube(s). * * This method reads the task parameters from the parfile, sets up the @@ -333,14 +310,10 @@ void ctexpcube::init_members(void) m_apply_edisp = false; // Initialise protected members - m_read_ahead = false; m_obs.clear(); m_expcube.clear(); m_ebounds.clear(); - // Set logger properties - log.date(true); - // Return return; } @@ -358,7 +331,6 @@ void ctexpcube::copy_members(const ctexpcube& app) m_apply_edisp = app.m_apply_edisp; // Copy protected members - m_read_ahead = app.m_read_ahead; m_obs = app.m_obs; m_expcube = app.m_expcube; m_ebounds = app.m_ebounds; @@ -433,7 +405,7 @@ void ctexpcube::get_parameters(void) } // Read output filename (if needed) - if (m_read_ahead) { + if (read_ahead()) { m_outfile = (*this)["outfile"].filename(); } diff --git a/src/ctexpcube/ctexpcube.hpp b/src/ctexpcube/ctexpcube.hpp index a7d1de5..6a648d4 100644 --- a/src/ctexpcube/ctexpcube.hpp +++ b/src/ctexpcube/ctexpcube.hpp @@ -57,7 +57,6 @@ public: // Methods void clear(void); - void execute(void); void run(void); void save(void); const GCTAExposure& expcube(void) const; @@ -76,7 +75,6 @@ protected: bool m_apply_edisp; //!< Apply energy dispersion? // Protected members - bool m_read_ahead; //!< Read ahead parameters GObservations m_obs; //!< Observation container GCTAExposure m_expcube; //!< Exposure cube GEbounds m_ebounds; //!< Energy boundaries diff --git a/src/ctlike/ctlike.cpp b/src/ctlike/ctlike.cpp index eb28d59..aa30e52 100644 --- a/src/ctlike/ctlike.cpp +++ b/src/ctlike/ctlike.cpp @@ -138,6 +138,7 @@ ctlike::~ctlike(void) * @brief Assignment operator * * @param[in] app Application. + * @return Application. ***************************************************************************/ ctlike& ctlike::operator=(const ctlike& app) { @@ -190,28 +191,6 @@ void ctlike::clear(void) /***********************************************************************//** - * @brief Execute application - * - * This method performs a maximum likelihood analysis of a observation given - * in an observation container and saves the results in an XML file. - ***************************************************************************/ -void ctlike::execute(void) -{ - // Signal that some parameters should be read ahead - m_read_ahead = true; - - // Bin the event data - run(); - - // Save the results into XML file - save(); - - // Return - return; -} - - -/***********************************************************************//** * @brief Run maximum likelihood analysis * * The following analysis steps are performed: @@ -442,7 +421,7 @@ void ctlike::get_parameters(void) // Optionally read ahead parameters so that they get correctly // dumped into the log file - if (m_read_ahead) { + if (read_ahead()) { m_outmdl = (*this)["outmdl"].filename(); } @@ -572,7 +551,6 @@ void ctlike::init_members(void) m_max_stall = 10; // Set maximum number of stalls m_logL = 0.0; m_opt = NULL; - m_read_ahead = false; m_apply_edisp = false; // Set logger properties @@ -599,7 +577,6 @@ void ctlike::copy_members(const ctlike& app) m_max_stall = app.m_max_stall; m_logL = app.m_logL; m_opt = app.m_opt->clone(); - m_read_ahead = app.m_read_ahead; m_apply_edisp = app.m_apply_edisp; // Return @@ -618,11 +595,6 @@ void ctlike::free_members(void) // Mark pointers as free m_opt = NULL; - // Write separator into logger - if (logTerse()) { - log << std::endl; - } - // Return return; } diff --git a/src/ctlike/ctlike.hpp b/src/ctlike/ctlike.hpp index 2176d79..910ddff 100644 --- a/src/ctlike/ctlike.hpp +++ b/src/ctlike/ctlike.hpp @@ -58,7 +58,6 @@ public: // Methods void clear(void); - void execute(void); void run(void); void save(void); const GObservations& obs(void) const; @@ -85,7 +84,6 @@ protected: int m_max_stall; //!< Maximum number of stalls double m_logL; //!< Maximum log likelihood GOptimizer* m_opt; //!< Optimizer - bool m_read_ahead; //!< Read ahead parameters }; diff --git a/src/ctmodel/ctmodel.cpp b/src/ctmodel/ctmodel.cpp index c132386..43e5019 100644 --- a/src/ctmodel/ctmodel.cpp +++ b/src/ctmodel/ctmodel.cpp @@ -137,8 +137,8 @@ ctmodel::~ctmodel(void) /***********************************************************************//** * @brief Assignment operator * - * @param[in] app ctmodel application. - * @return Returns ctmodel application. + * @param[in] app Application. + * @return Application. ***************************************************************************/ ctmodel& ctmodel::operator=(const ctmodel& app) { @@ -191,29 +191,6 @@ void ctmodel::clear(void) /***********************************************************************//** - * @brief Execute application - * - * This is the main execution method of the ctmodel class. It is invoked - * when the executable is called from command line. The method generates - * the model maps and saves the results. - ***************************************************************************/ -void ctmodel::execute(void) -{ - // Signal that some parameters should be read ahead - m_read_ahead = true; - - // Create model cube - run(); - - // Save model cube into FITS file - save(); - - // Return - return; -} - - -/***********************************************************************//** * @brief Generate the model map(s) * * This method reads the task parameters from the parfile, sets up the @@ -385,10 +362,6 @@ void ctmodel::init_members(void) m_cube.clear(); m_ebounds.clear(); m_gti.clear(); - m_read_ahead = false; - - // Set logger properties - log.date(true); // Return return; @@ -433,7 +406,6 @@ void ctmodel::copy_members(const ctmodel& app) m_cube = app.m_cube; m_ebounds = app.m_ebounds; m_gti = app.m_gti; - m_read_ahead = app.m_read_ahead; // Return return; @@ -460,7 +432,7 @@ void ctmodel::get_parameters(void) { // Read input and optionally output cube filenames m_infile = (*this)["infile"].filename(); - if (m_read_ahead) { + if (read_ahead()) { m_outfile = (*this)["outfile"].filename(); } diff --git a/src/ctmodel/ctmodel.hpp b/src/ctmodel/ctmodel.hpp index cd3921b..52f71c7 100644 --- a/src/ctmodel/ctmodel.hpp +++ b/src/ctmodel/ctmodel.hpp @@ -66,7 +66,6 @@ public: // Methods void clear(void); - void execute(void); void run(void); void save(void); const GObservations& obs(void) const; @@ -113,7 +112,6 @@ protected: GCTAEventCube m_cube; //!< Model cube GEbounds m_ebounds; //!< Energy boundaries GGti m_gti; //!< Model cube GTIs - bool m_read_ahead; //!< Read ahead parameters }; diff --git a/src/ctobssim/ctobssim.cpp b/src/ctobssim/ctobssim.cpp index 9994d61..d70e096 100644 --- a/src/ctobssim/ctobssim.cpp +++ b/src/ctobssim/ctobssim.cpp @@ -197,27 +197,6 @@ void ctobssim::clear(void) /***********************************************************************//** - * @brief Execute application - * - * This method runs the simulation and saves the results. - ***************************************************************************/ -void ctobssim::execute(void) -{ - // Signal that some parameters should be read ahead - m_read_ahead = true; - - // Run the simulation - run(); - - // Save results - save(); - - // Return - return; -} - - -/***********************************************************************//** * @brief Simulate event data * * This method runs the simulation. Results are not saved by this method. @@ -489,7 +468,7 @@ void ctobssim::get_parameters(void) // Optionally read ahead parameters so that they get correctly // dumped into the log file - if (m_read_ahead) { + if (read_ahead()) { m_outfile = (*this)["outfile"].filename(); m_prefix = (*this)["prefix"].string(); } @@ -1038,7 +1017,6 @@ void ctobssim::init_members(void) m_rans.clear(); m_obs.clear(); m_use_xml = false; - m_read_ahead = false; // Set fixed parameters m_area = 19634954.0 * 1.0e4; //!< pi*(2500^2) m^2 @@ -1052,9 +1030,6 @@ void ctobssim::init_members(void) // Initialise first event identifier m_event_id = 1; - // Set logger properties - log.date(true); - // Return return; } @@ -1088,7 +1063,6 @@ void ctobssim::copy_members(const ctobssim& app) m_rans = app.m_rans; m_obs = app.m_obs; m_use_xml = app.m_use_xml; - m_read_ahead = app.m_read_ahead; m_cta_ref = app.m_cta_ref; m_event_id = app.m_event_id; diff --git a/src/ctobssim/ctobssim.hpp b/src/ctobssim/ctobssim.hpp index aaadb89..07a9de4 100644 --- a/src/ctobssim/ctobssim.hpp +++ b/src/ctobssim/ctobssim.hpp @@ -63,7 +63,6 @@ public: // Methods void clear(void); - void execute(void); void run(void); void save(void); const GObservations& obs(void) const; @@ -107,7 +106,6 @@ protected: std::vector m_rans; //!< Random number generators GObservations m_obs; //!< Observation container 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 int m_event_id; //!< Event identifier }; diff --git a/src/ctpsfcube/ctpsfcube.cpp b/src/ctpsfcube/ctpsfcube.cpp index c548d0f..64a6097 100644 --- a/src/ctpsfcube/ctpsfcube.cpp +++ b/src/ctpsfcube/ctpsfcube.cpp @@ -104,7 +104,7 @@ ctpsfcube::ctpsfcube(int argc, char *argv[]) : /***********************************************************************//** * @brief Copy constructor * - * @param[in] app ctpsfcube application. + * @param[in] app Application. ***************************************************************************/ ctpsfcube::ctpsfcube(const ctpsfcube& app) : ctool(app) { @@ -141,8 +141,8 @@ ctpsfcube::~ctpsfcube(void) /***********************************************************************//** * @brief Assignment operator * - * @param[in] app ctpsfcube application. - * @return Returns ctpsfcube application. + * @param[in] app Application. + * @return Application. ***************************************************************************/ ctpsfcube& ctpsfcube::operator=(const ctpsfcube& app) { @@ -195,29 +195,6 @@ void ctpsfcube::clear(void) /***********************************************************************//** - * @brief Execute application - * - * This is the main execution method of the ctpsfcube class. It is invoked - * when the executable is called from command line. The method generates - * the PSF cube and saves the result. - ***************************************************************************/ -void ctpsfcube::execute(void) -{ - // Signal that some parameters should be read ahead - m_read_ahead = true; - - // Create the PSF cube - run(); - - // Save the PSF cube into the output FITS file - save(); - - // Return - return; -} - - -/***********************************************************************//** * @brief Generate the model map(s) * * This method reads the task parameters from the parfile, sets up the @@ -324,14 +301,10 @@ void ctpsfcube::init_members(void) m_apply_edisp = false; // Initialise protected members - m_read_ahead = false; m_obs.clear(); m_psfcube.clear(); m_ebounds.clear(); - // Set logger properties - log.date(true); - // Return return; } @@ -349,7 +322,6 @@ void ctpsfcube::copy_members(const ctpsfcube& app) m_apply_edisp = app.m_apply_edisp; // Copy protected members - m_read_ahead = app.m_read_ahead; m_obs = app.m_obs; m_psfcube = app.m_psfcube; m_ebounds = app.m_ebounds; @@ -426,7 +398,7 @@ void ctpsfcube::get_parameters(void) } // Read output filename (if needed) - if (m_read_ahead) { + if (read_ahead()) { m_outfile = (*this)["outfile"].filename(); } diff --git a/src/ctpsfcube/ctpsfcube.hpp b/src/ctpsfcube/ctpsfcube.hpp index 9540f40..f626aac 100644 --- a/src/ctpsfcube/ctpsfcube.hpp +++ b/src/ctpsfcube/ctpsfcube.hpp @@ -57,7 +57,6 @@ public: // Methods void clear(void); - void execute(void); void run(void); void save(void); const GCTAMeanPsf& psfcube(void) const; @@ -76,7 +75,6 @@ protected: bool m_apply_edisp; //!< Apply energy dispersion? // Protected members - bool m_read_ahead; //!< Read ahead parameters GObservations m_obs; //!< Observation container GCTAMeanPsf m_psfcube; //!< PSF cube GEbounds m_ebounds; //!< Energy boundaries diff --git a/src/ctselect/ctselect.cpp b/src/ctselect/ctselect.cpp index 3b2195d..f11a12a 100644 --- a/src/ctselect/ctselect.cpp +++ b/src/ctselect/ctselect.cpp @@ -144,6 +144,7 @@ ctselect::~ctselect(void) * @brief Assignment operator * * @param[in] app Application. + * @return Application. ***************************************************************************/ ctselect& ctselect::operator=(const ctselect& app) { @@ -196,28 +197,6 @@ void ctselect::clear(void) /***********************************************************************//** - * @brief Execute application - * - * This method performs the event selection and saves the result - ***************************************************************************/ -void ctselect::execute(void) -{ - // Signal that some parameters should be read ahead - m_read_ahead = true; - - // Perform event selection - run(); - - // Save results - save(); - - // Return - return; -} - - - -/***********************************************************************//** * @brief Select event data * * This method reads in the application parameters and loops over all @@ -458,7 +437,7 @@ void ctselect::get_parameters(void) // Optionally read ahead parameters so that they get correctly // dumped into the log file - if (m_read_ahead) { + if (read_ahead()) { m_outfile = (*this)["outfile"].filename(); m_prefix = (*this)["prefix"].string(); } @@ -706,16 +685,12 @@ void ctselect::init_members(void) m_timemin.clear(); 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); - // Return return; } @@ -748,7 +723,6 @@ void ctselect::copy_members(const ctselect& app) m_timemin = app.m_timemin; 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 diff --git a/src/ctselect/ctselect.hpp b/src/ctselect/ctselect.hpp index d54d215..ad2364f 100644 --- a/src/ctselect/ctselect.hpp +++ b/src/ctselect/ctselect.hpp @@ -59,7 +59,6 @@ public: // Methods void clear(void); - void execute(void); void run(void); void save(void); const GObservations& obs(void) const; @@ -100,7 +99,6 @@ protected: GTime m_timemin; //!< Earliest time 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 }; diff --git a/src/ctskymap/ctskymap.cpp b/src/ctskymap/ctskymap.cpp index ae66925..898adc6 100644 --- a/src/ctskymap/ctskymap.cpp +++ b/src/ctskymap/ctskymap.cpp @@ -141,6 +141,7 @@ ctskymap::~ctskymap(void) * @brief Assignment operator * * @param[in] app Application. + * @return Application. ***************************************************************************/ ctskymap& ctskymap::operator=(const ctskymap& app) { @@ -193,28 +194,6 @@ void ctskymap::clear(void) /***********************************************************************//** - * @brief Execute application - * - * This method creates the sky map and saves the map into a FITS file. - ***************************************************************************/ -void ctskymap::execute(void) -{ - // Read ahead output filename so that it gets dumped correctly in the - // parameters log - m_outfile = (*this)["outfile"].filename(); - - // Create the sky map - run(); - - // Save the sky map into FITS file - save(); - - // Return - return; -} - - -/***********************************************************************//** * @brief Creates sky maps from data * * This method is the main code. It @@ -383,6 +362,11 @@ void ctskymap::get_parameters(void) m_nxpix = (*this)["nxpix"].integer(); m_nypix = (*this)["nypix"].integer(); + // Read ahead parameters + if (read_ahead()) { + m_outfile = (*this)["outfile"].filename(); + } + // Return return; } @@ -555,9 +539,6 @@ void ctskymap::init_members(void) m_nxpix = 0; m_nypix = 0; - // Set logger properties - log.date(true); - // Return return; } diff --git a/src/ctskymap/ctskymap.hpp b/src/ctskymap/ctskymap.hpp index 1b68317..193f0ba 100644 --- a/src/ctskymap/ctskymap.hpp +++ b/src/ctskymap/ctskymap.hpp @@ -59,7 +59,6 @@ public: // Methods void clear(void); - void execute(void); void run(void); void save(void); const GSkymap& map(void) const; diff --git a/src/cttsmap/cttsmap.cpp b/src/cttsmap/cttsmap.cpp index cc38a93..1248334 100644 --- a/src/cttsmap/cttsmap.cpp +++ b/src/cttsmap/cttsmap.cpp @@ -140,6 +140,7 @@ cttsmap::~cttsmap(void) * @brief Assignment operator * * @param[in] app Application. + * @return Application. ***************************************************************************/ cttsmap& cttsmap::operator=(const cttsmap& app) { @@ -192,31 +193,6 @@ void cttsmap::clear(void) /***********************************************************************//** - * @brief Execute application - * - * This is the main execution method of the cttsmap class. It is invoked when - * the executable is called from command line. - * - * The method reads the task parameters, computes the TS values, stores the - * results into map(s), and writes the maps into a FITS file on disk. - ***************************************************************************/ -void cttsmap::execute(void) -{ - // Signal that some parameters should be read ahead - m_read_ahead = true; - - // Compute the maps - run(); - - // Save the maps into FITS file - save(); - - // Return - return; -} - - -/***********************************************************************//** * @brief Computes the TS maps * * This method moves a source along a grid of coordinates and refits the @@ -447,7 +423,6 @@ void cttsmap::init_members(void) // Initialise protected members m_obs.clear(); - m_read_ahead = false; m_binmin = -1; m_binmax = -1; m_logL0 = 0.0; @@ -457,9 +432,6 @@ void cttsmap::init_members(void) m_maps.clear(); m_testsource = NULL; - // Set logger properties - log.date(true); - // Return return; } @@ -488,7 +460,6 @@ void cttsmap::copy_members(const cttsmap& app) m_binmax = app.m_binmax; m_logL0 = app.m_logL0; m_obs = app.m_obs; - m_read_ahead = app.m_read_ahead; m_tsmap = app.m_tsmap; m_mapnames = app.m_mapnames; m_maps = app.m_maps; @@ -624,7 +595,7 @@ void cttsmap::get_parameters(void) // Optionally read ahead parameters so that they get correctly // dumped into the log file - if (m_read_ahead) { + if (read_ahead()) { m_outfile = (*this)["outfile"].filename(); } diff --git a/src/cttsmap/cttsmap.hpp b/src/cttsmap/cttsmap.hpp index 8457ee5..f686a24 100644 --- a/src/cttsmap/cttsmap.hpp +++ b/src/cttsmap/cttsmap.hpp @@ -70,7 +70,6 @@ public: // Methods void clear(void); - void execute(void); void run(void); void save(void); const GObservations& obs(void) const; @@ -103,7 +102,6 @@ protected: // Protected members GObservations m_obs; //!< Observation container - bool m_read_ahead; //!< Read ahead parameters GSkymap m_tsmap; //!< TS map GSkymap m_statusmap; //!< Map of computed bins std::vector m_mapnames; //!< Names of free parameters diff --git a/src/support/ctool.cpp b/src/support/ctool.cpp index 2adf961..b11603c 100644 --- a/src/support/ctool.cpp +++ b/src/support/ctool.cpp @@ -176,6 +176,26 @@ ctool& ctool::operator=(const ctool& app) = = ==========================================================================*/ +/***********************************************************************//** + * @brief Execute application + * + * This is the main execution method of a ctool. The method is invoked when + * the executable is called from command line. + ***************************************************************************/ +void ctool::execute(void) +{ + // Signal that some parameters should be read ahead + m_read_ahead = true; + + // Run the tool + run(); + + // Save the results + save(); + + // Return + return; +} /*========================================================================== @@ -190,6 +210,10 @@ ctool& ctool::operator=(const ctool& app) void ctool::init_members(void) { // Initialise members + m_read_ahead = false; + + // Set logger properties + log.date(true); // Return return; @@ -203,7 +227,8 @@ void ctool::init_members(void) ***************************************************************************/ void ctool::copy_members(const ctool& app) { - // Copy attributes + // Copy members + m_read_ahead = app.m_read_ahead; // Return return; diff --git a/src/support/ctool.hpp b/src/support/ctool.hpp index 26f0c94..87b7f35 100644 --- a/src/support/ctool.hpp +++ b/src/support/ctool.hpp @@ -52,16 +52,38 @@ public: // Operators ctool& operator=(const ctool& app); + // Pure virtual methods + virtual void clear(void) = 0; + virtual void run(void) = 0; + virtual void save(void) = 0; + // Public methods + virtual void execute(void); protected: // Protected methods - void init_members(void); - void copy_members(const ctool& app); - void free_members(void); - GEbounds get_ebounds(void); - void set_response(GObservations& obs); - void set_obs_response(GCTAObservation* obs); + void init_members(void); + void copy_members(const ctool& app); + void free_members(void); + const bool& read_ahead(void) const; + GEbounds get_ebounds(void); + void set_response(GObservations& obs); + void set_obs_response(GCTAObservation* obs); + + // Protected members + bool m_read_ahead; //!< Read ahead parameters }; + +/***********************************************************************//** + * @brief Return observation container + * + * @return Reference to observation container + ***************************************************************************/ +inline +const bool& ctool::read_ahead(void) const +{ + return (m_read_ahead); +} + #endif /* CTOOL_HPP */