Commit 378c62cb210470c6cc934a9b4c68cc35542fa84a
1 parent
530bfccc
cttsmap now derives from ctool base class.
Showing
4 changed files
with
23 additions
and
86 deletions
pyext/cttsmap.i
| 1 | 1 | /*************************************************************************** |
| 2 | - * cttsmap - TS map calculation tool * | |
| 2 | + * cttsmap - TS map calculation tool * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | 4 | * copyright (C) 2014 by Michael Mayer * |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| ... | ... | @@ -26,16 +26,15 @@ |
| 26 | 26 | %{ |
| 27 | 27 | /* Put headers and other declarations here that are needed for compilation */ |
| 28 | 28 | #include "cttsmap.hpp" |
| 29 | -#include "GTools.hpp" | |
| 30 | 29 | %} |
| 31 | 30 | |
| 32 | 31 | |
| 33 | 32 | /***********************************************************************//** |
| 34 | 33 | * @class cttsmap |
| 35 | 34 | * |
| 36 | - * @brief TS map calculation | |
| 35 | + * @brief TS map calculation tool | |
| 37 | 36 | ***************************************************************************/ |
| 38 | -class cttsmap : public GApplication { | |
| 37 | +class cttsmap : public ctool { | |
| 39 | 38 | public: |
| 40 | 39 | // Constructors and destructors |
| 41 | 40 | cttsmap(void); | ... | ... |
src/cttsmap/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 = cttsmap |
| 5 | 8 | |
| ... | ... | @@ -14,7 +17,7 @@ libcttsmap_la_SOURCES = $(sources) |
| 14 | 17 | cttsmap_SOURCES = main.cpp |
| 15 | 18 | cttsmap_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@ |
| 16 | 19 | cttsmap_CPPFLAGS = @CPPFLAGS@ |
| 17 | -cttsmap_LDADD = libcttsmap.la | |
| 20 | +cttsmap_LDADD = libcttsmap.la $(top_srcdir)/src/support/libsupport.la | |
| 18 | 21 | |
| 19 | 22 | # Parameter files |
| 20 | 23 | pfilesdir = $(prefix)/syspfiles | ... | ... |
src/cttsmap/cttsmap.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * cttsmap - TS map calculation tool * | |
| 2 | + * cttsmap - TS map calculation tool * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | 4 | * copyright (C) 2014 by Michael Mayer * |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| ... | ... | @@ -49,14 +49,11 @@ |
| 49 | 49 | /***********************************************************************//** |
| 50 | 50 | * @brief Void constructor |
| 51 | 51 | ***************************************************************************/ |
| 52 | -cttsmap::cttsmap(void) : GApplication(CTTSMAP_NAME, CTTSMAP_VERSION) | |
| 52 | +cttsmap::cttsmap(void) : ctool(CTTSMAP_NAME, CTTSMAP_VERSION) | |
| 53 | 53 | { |
| 54 | 54 | // Initialise members |
| 55 | 55 | init_members(); |
| 56 | 56 | |
| 57 | - // Write header into logger | |
| 58 | - log_header(); | |
| 59 | - | |
| 60 | 57 | // Return |
| 61 | 58 | return; |
| 62 | 59 | } |
| ... | ... | @@ -71,7 +68,7 @@ cttsmap::cttsmap(void) : GApplication(CTTSMAP_NAME, CTTSMAP_VERSION) |
| 71 | 68 | * observations container. |
| 72 | 69 | ***************************************************************************/ |
| 73 | 70 | cttsmap::cttsmap(const GObservations& obs) : |
| 74 | - GApplication(CTTSMAP_NAME, CTTSMAP_VERSION) | |
| 71 | + ctool(CTTSMAP_NAME, CTTSMAP_VERSION) | |
| 75 | 72 | { |
| 76 | 73 | // Initialise members |
| 77 | 74 | init_members(); |
| ... | ... | @@ -79,9 +76,6 @@ cttsmap::cttsmap(const GObservations& obs) : |
| 79 | 76 | // Set observations |
| 80 | 77 | m_obs = obs; |
| 81 | 78 | |
| 82 | - // Write header into logger | |
| 83 | - log_header(); | |
| 84 | - | |
| 85 | 79 | // Return |
| 86 | 80 | return; |
| 87 | 81 | } |
| ... | ... | @@ -95,14 +89,11 @@ cttsmap::cttsmap(const GObservations& obs) : |
| 95 | 89 | * @param[in] argv Array of command line arguments. |
| 96 | 90 | ***************************************************************************/ |
| 97 | 91 | cttsmap::cttsmap(int argc, char *argv[]) : |
| 98 | - GApplication(CTTSMAP_NAME, CTTSMAP_VERSION, argc, argv) | |
| 92 | + ctool(CTTSMAP_NAME, CTTSMAP_VERSION, argc, argv) | |
| 99 | 93 | { |
| 100 | 94 | // Initialise members |
| 101 | 95 | init_members(); |
| 102 | 96 | |
| 103 | - // Write header into logger | |
| 104 | - log_header(); | |
| 105 | - | |
| 106 | 97 | // Return |
| 107 | 98 | return; |
| 108 | 99 | } |
| ... | ... | @@ -113,7 +104,7 @@ cttsmap::cttsmap(int argc, char *argv[]) : |
| 113 | 104 | * |
| 114 | 105 | * @param[in] app Application. |
| 115 | 106 | ***************************************************************************/ |
| 116 | -cttsmap::cttsmap(const cttsmap& app) : GApplication(app) | |
| 107 | +cttsmap::cttsmap(const cttsmap& app) : ctool(app) | |
| 117 | 108 | { |
| 118 | 109 | // Initialise members |
| 119 | 110 | init_members(); |
| ... | ... | @@ -156,7 +147,7 @@ cttsmap& cttsmap::operator=(const cttsmap& app) |
| 156 | 147 | if (this != &app) { |
| 157 | 148 | |
| 158 | 149 | // Copy base class members |
| 159 | - this->GApplication::operator=(app); | |
| 150 | + this->ctool::operator=(app); | |
| 160 | 151 | |
| 161 | 152 | // Free members |
| 162 | 153 | free_members(); |
| ... | ... | @@ -187,10 +178,12 @@ void cttsmap::clear(void) |
| 187 | 178 | { |
| 188 | 179 | // Free members |
| 189 | 180 | free_members(); |
| 181 | + this->ctool::free_members(); | |
| 190 | 182 | this->GApplication::free_members(); |
| 191 | 183 | |
| 192 | 184 | // Initialise members |
| 193 | 185 | this->GApplication::init_members(); |
| 186 | + this->ctool::init_members(); | |
| 194 | 187 | init_members(); |
| 195 | 188 | |
| 196 | 189 | // Return |
| ... | ... | @@ -443,8 +436,6 @@ void cttsmap::init_members(void) |
| 443 | 436 | { |
| 444 | 437 | // Initialise members |
| 445 | 438 | m_infile.clear(); |
| 446 | - m_caldb.clear(); | |
| 447 | - m_irf.clear(); | |
| 448 | 439 | m_outfile.clear(); |
| 449 | 440 | m_proj.clear(); |
| 450 | 441 | m_coordsys.clear(); |
| ... | ... | @@ -483,8 +474,6 @@ void cttsmap::copy_members(const cttsmap& app) |
| 483 | 474 | { |
| 484 | 475 | // Copy attributes |
| 485 | 476 | m_infile = app.m_infile; |
| 486 | - m_caldb = app.m_caldb; | |
| 487 | - m_irf = app.m_irf; | |
| 488 | 477 | m_outfile = app.m_outfile; |
| 489 | 478 | m_proj = app.m_proj; |
| 490 | 479 | m_coordsys = app.m_coordsys; |
| ... | ... | @@ -518,11 +507,6 @@ void cttsmap::copy_members(const cttsmap& app) |
| 518 | 507 | ***************************************************************************/ |
| 519 | 508 | void cttsmap::free_members(void) |
| 520 | 509 | { |
| 521 | - // Write separator into logger | |
| 522 | - if (logTerse()) { | |
| 523 | - log << std::endl; | |
| 524 | - } | |
| 525 | - | |
| 526 | 510 | // Return |
| 527 | 511 | return; |
| 528 | 512 | } |
| ... | ... | @@ -559,24 +543,8 @@ void cttsmap::get_parameters(void) |
| 559 | 543 | // Load data |
| 560 | 544 | obs.load(filename); |
| 561 | 545 | |
| 562 | - // Get other task parameters | |
| 563 | - m_caldb = (*this)["caldb"].string(); | |
| 564 | - m_irf = (*this)["irf"].string(); | |
| 565 | - | |
| 566 | - // Set calibration database. If specified parameter is a | |
| 567 | - // directory then use this as the pathname to the calibration | |
| 568 | - // database. Otherwise interpret this as the instrument name, | |
| 569 | - // the mission being "cta" | |
| 570 | - GCaldb caldb; | |
| 571 | - if (gammalib::dir_exists(m_caldb)) { | |
| 572 | - caldb.rootdir(m_caldb); | |
| 573 | - } | |
| 574 | - else { | |
| 575 | - caldb.open("cta", m_caldb); | |
| 576 | - } | |
| 577 | - | |
| 578 | - // Set reponse | |
| 579 | - obs.response(m_irf, caldb); | |
| 546 | + // Set response | |
| 547 | + set_obs_response(&obs); | |
| 580 | 548 | |
| 581 | 549 | // Append observation to container |
| 582 | 550 | m_obs.append(obs); |
| ... | ... | @@ -592,40 +560,7 @@ void cttsmap::get_parameters(void) |
| 592 | 560 | // Check if all observations have response information. If |
| 593 | 561 | // not, get the calibration database parameters and set |
| 594 | 562 | // the response properly |
| 595 | - bool asked_for_response = false; | |
| 596 | - for (int i = 0; i < m_obs.size(); ++i) { | |
| 597 | - | |
| 598 | - // Get CTA observation | |
| 599 | - GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]); | |
| 600 | - | |
| 601 | - // Continue only if observation is a CTA observation | |
| 602 | - if (obs != NULL) { | |
| 603 | - | |
| 604 | - // If response is not valid then set response from | |
| 605 | - // task parameters | |
| 606 | - if (!obs->has_response()) { | |
| 607 | - | |
| 608 | - // Get calibration parameters | |
| 609 | - if (!asked_for_response) { | |
| 610 | - m_caldb = (*this)["caldb"].string(); | |
| 611 | - m_irf = (*this)["irf"].string(); | |
| 612 | - asked_for_response = true; | |
| 613 | - } | |
| 614 | - | |
| 615 | - // Set response | |
| 616 | - GCaldb caldb; | |
| 617 | - if (gammalib::dir_exists(m_caldb)) { | |
| 618 | - caldb.rootdir(m_caldb); | |
| 619 | - } | |
| 620 | - else { | |
| 621 | - caldb.open("cta", m_caldb); | |
| 622 | - } | |
| 623 | - obs->response(m_irf, caldb); | |
| 624 | - | |
| 625 | - } // endif: there was no response | |
| 626 | - } // endif: observation was a CTA observation | |
| 627 | - | |
| 628 | - } // endfor: looped over observations | |
| 563 | + set_response(m_obs); | |
| 629 | 564 | |
| 630 | 565 | } // endcatch: file was an XML file |
| 631 | 566 | ... | ... |
src/cttsmap/cttsmap.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * cttsmap - TS map calculation tool * | |
| 2 | + * cttsmap - TS map calculation tool * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | 4 | * copyright (C) 2014 by Michael Mayer * |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| ... | ... | @@ -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 CTTSMAP_NAME "cttsmap" |
| ... | ... | @@ -39,7 +40,7 @@ |
| 39 | 40 | /***********************************************************************//** |
| 40 | 41 | * @class cttsmap |
| 41 | 42 | * |
| 42 | - * @brief TS map calculation | |
| 43 | + * @brief TS map calculation tool | |
| 43 | 44 | * |
| 44 | 45 | * This class computes a set of maps from any kind of observations: |
| 45 | 46 | * |
| ... | ... | @@ -54,7 +55,8 @@ |
| 54 | 55 | * grid of coordinates. The best fit results (TS, flux, index) are stored in |
| 55 | 56 | * maps which are saved in the output FITS files. |
| 56 | 57 | ***************************************************************************/ |
| 57 | -class cttsmap : public GApplication { | |
| 58 | +class cttsmap : public ctool { | |
| 59 | + | |
| 58 | 60 | public: |
| 59 | 61 | // Constructors and destructors |
| 60 | 62 | cttsmap(void); |
| ... | ... | @@ -85,8 +87,6 @@ protected: |
| 85 | 87 | // User parameters |
| 86 | 88 | std::string m_infile; //!< Input file |
| 87 | 89 | std::string m_srcname; //!< Name of source which is moved around |
| 88 | - std::string m_caldb; //!< Calibration database | |
| 89 | - std::string m_irf; //!< Instrument response functions | |
| 90 | 90 | std::string m_outfile; //!< Output counts map or XML file |
| 91 | 91 | std::string m_proj; //!< WCS projection |
| 92 | 92 | std::string m_coordsys; //!< Coordinate system | ... | ... |