Commit 378c62cb210470c6cc934a9b4c68cc35542fa84a

Authored by Jürgen Knödlseder
1 parent 530bfccc

cttsmap now derives from ctool base class.

pyext/cttsmap.i
1 /*************************************************************************** 1 /***************************************************************************
2 - * cttsmap - TS map calculation tool * 2 + * cttsmap - TS map calculation tool *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2014 by Michael Mayer * 4 * copyright (C) 2014 by Michael Mayer *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
@@ -26,16 +26,15 @@ @@ -26,16 +26,15 @@
26 %{ 26 %{
27 /* Put headers and other declarations here that are needed for compilation */ 27 /* Put headers and other declarations here that are needed for compilation */
28 #include "cttsmap.hpp" 28 #include "cttsmap.hpp"
29 -#include "GTools.hpp"  
30 %} 29 %}
31 30
32 31
33 /***********************************************************************//** 32 /***********************************************************************//**
34 * @class cttsmap 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 public: 38 public:
40 // Constructors and destructors 39 // Constructors and destructors
41 cttsmap(void); 40 cttsmap(void);
src/cttsmap/Makefile.am
1 ## Process this file with automake to produce Makefile.in 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 # Program name 6 # Program name
4 bin_PROGRAMS = cttsmap 7 bin_PROGRAMS = cttsmap
5 8
@@ -14,7 +17,7 @@ libcttsmap_la_SOURCES = $(sources) @@ -14,7 +17,7 @@ libcttsmap_la_SOURCES = $(sources)
14 cttsmap_SOURCES = main.cpp 17 cttsmap_SOURCES = main.cpp
15 cttsmap_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@ 18 cttsmap_LDFLAGS = $(LIB_LINK_OPTION) @LDFLAGS@
16 cttsmap_CPPFLAGS = @CPPFLAGS@ 19 cttsmap_CPPFLAGS = @CPPFLAGS@
17 -cttsmap_LDADD = libcttsmap.la 20 +cttsmap_LDADD = libcttsmap.la $(top_srcdir)/src/support/libsupport.la
18 21
19 # Parameter files 22 # Parameter files
20 pfilesdir = $(prefix)/syspfiles 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 * copyright (C) 2014 by Michael Mayer * 4 * copyright (C) 2014 by Michael Mayer *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
@@ -49,14 +49,11 @@ @@ -49,14 +49,11 @@
49 /***********************************************************************//** 49 /***********************************************************************//**
50 * @brief Void constructor 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 // Initialise members 54 // Initialise members
55 init_members(); 55 init_members();
56 56
57 - // Write header into logger  
58 - log_header();  
59 -  
60 // Return 57 // Return
61 return; 58 return;
62 } 59 }
@@ -71,7 +68,7 @@ cttsmap::cttsmap(void) : GApplication(CTTSMAP_NAME, CTTSMAP_VERSION) @@ -71,7 +68,7 @@ cttsmap::cttsmap(void) : GApplication(CTTSMAP_NAME, CTTSMAP_VERSION)
71 * observations container. 68 * observations container.
72 ***************************************************************************/ 69 ***************************************************************************/
73 cttsmap::cttsmap(const GObservations& obs) : 70 cttsmap::cttsmap(const GObservations& obs) :
74 - GApplication(CTTSMAP_NAME, CTTSMAP_VERSION) 71 + ctool(CTTSMAP_NAME, CTTSMAP_VERSION)
75 { 72 {
76 // Initialise members 73 // Initialise members
77 init_members(); 74 init_members();
@@ -79,9 +76,6 @@ cttsmap::cttsmap(const GObservations& obs) : @@ -79,9 +76,6 @@ cttsmap::cttsmap(const GObservations& obs) :
79 // Set observations 76 // Set observations
80 m_obs = obs; 77 m_obs = obs;
81 78
82 - // Write header into logger  
83 - log_header();  
84 -  
85 // Return 79 // Return
86 return; 80 return;
87 } 81 }
@@ -95,14 +89,11 @@ cttsmap::cttsmap(const GObservations& obs) : @@ -95,14 +89,11 @@ cttsmap::cttsmap(const GObservations& obs) :
95 * @param[in] argv Array of command line arguments. 89 * @param[in] argv Array of command line arguments.
96 ***************************************************************************/ 90 ***************************************************************************/
97 cttsmap::cttsmap(int argc, char *argv[]) : 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 // Initialise members 94 // Initialise members
101 init_members(); 95 init_members();
102 96
103 - // Write header into logger  
104 - log_header();  
105 -  
106 // Return 97 // Return
107 return; 98 return;
108 } 99 }
@@ -113,7 +104,7 @@ cttsmap::cttsmap(int argc, char *argv[]) : @@ -113,7 +104,7 @@ cttsmap::cttsmap(int argc, char *argv[]) :
113 * 104 *
114 * @param[in] app Application. 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 // Initialise members 109 // Initialise members
119 init_members(); 110 init_members();
@@ -156,7 +147,7 @@ cttsmap& cttsmap::operator=(const cttsmap& app) @@ -156,7 +147,7 @@ cttsmap& cttsmap::operator=(const cttsmap& app)
156 if (this != &app) { 147 if (this != &app) {
157 148
158 // Copy base class members 149 // Copy base class members
159 - this->GApplication::operator=(app); 150 + this->ctool::operator=(app);
160 151
161 // Free members 152 // Free members
162 free_members(); 153 free_members();
@@ -187,10 +178,12 @@ void cttsmap::clear(void) @@ -187,10 +178,12 @@ void cttsmap::clear(void)
187 { 178 {
188 // Free members 179 // Free members
189 free_members(); 180 free_members();
  181 + this->ctool::free_members();
190 this->GApplication::free_members(); 182 this->GApplication::free_members();
191 183
192 // Initialise members 184 // Initialise members
193 this->GApplication::init_members(); 185 this->GApplication::init_members();
  186 + this->ctool::init_members();
194 init_members(); 187 init_members();
195 188
196 // Return 189 // Return
@@ -443,8 +436,6 @@ void cttsmap::init_members(void) @@ -443,8 +436,6 @@ void cttsmap::init_members(void)
443 { 436 {
444 // Initialise members 437 // Initialise members
445 m_infile.clear(); 438 m_infile.clear();
446 - m_caldb.clear();  
447 - m_irf.clear();  
448 m_outfile.clear(); 439 m_outfile.clear();
449 m_proj.clear(); 440 m_proj.clear();
450 m_coordsys.clear(); 441 m_coordsys.clear();
@@ -483,8 +474,6 @@ void cttsmap::copy_members(const cttsmap& app) @@ -483,8 +474,6 @@ void cttsmap::copy_members(const cttsmap& app)
483 { 474 {
484 // Copy attributes 475 // Copy attributes
485 m_infile = app.m_infile; 476 m_infile = app.m_infile;
486 - m_caldb = app.m_caldb;  
487 - m_irf = app.m_irf;  
488 m_outfile = app.m_outfile; 477 m_outfile = app.m_outfile;
489 m_proj = app.m_proj; 478 m_proj = app.m_proj;
490 m_coordsys = app.m_coordsys; 479 m_coordsys = app.m_coordsys;
@@ -518,11 +507,6 @@ void cttsmap::copy_members(const cttsmap& app) @@ -518,11 +507,6 @@ void cttsmap::copy_members(const cttsmap& app)
518 ***************************************************************************/ 507 ***************************************************************************/
519 void cttsmap::free_members(void) 508 void cttsmap::free_members(void)
520 { 509 {
521 - // Write separator into logger  
522 - if (logTerse()) {  
523 - log << std::endl;  
524 - }  
525 -  
526 // Return 510 // Return
527 return; 511 return;
528 } 512 }
@@ -559,24 +543,8 @@ void cttsmap::get_parameters(void) @@ -559,24 +543,8 @@ void cttsmap::get_parameters(void)
559 // Load data 543 // Load data
560 obs.load(filename); 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 // Append observation to container 549 // Append observation to container
582 m_obs.append(obs); 550 m_obs.append(obs);
@@ -592,40 +560,7 @@ void cttsmap::get_parameters(void) @@ -592,40 +560,7 @@ void cttsmap::get_parameters(void)
592 // Check if all observations have response information. If 560 // Check if all observations have response information. If
593 // not, get the calibration database parameters and set 561 // not, get the calibration database parameters and set
594 // the response properly 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 } // endcatch: file was an XML file 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 * copyright (C) 2014 by Michael Mayer * 4 * copyright (C) 2014 by Michael Mayer *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
@@ -30,6 +30,7 @@ @@ -30,6 +30,7 @@
30 /* __ Includes ___________________________________________________________ */ 30 /* __ Includes ___________________________________________________________ */
31 #include "GammaLib.hpp" 31 #include "GammaLib.hpp"
32 #include "GCTALib.hpp" 32 #include "GCTALib.hpp"
  33 +#include "ctool.hpp"
33 34
34 /* __Definitions _________________________________________________________ */ 35 /* __Definitions _________________________________________________________ */
35 #define CTTSMAP_NAME "cttsmap" 36 #define CTTSMAP_NAME "cttsmap"
@@ -39,7 +40,7 @@ @@ -39,7 +40,7 @@
39 /***********************************************************************//** 40 /***********************************************************************//**
40 * @class cttsmap 41 * @class cttsmap
41 * 42 *
42 - * @brief TS map calculation 43 + * @brief TS map calculation tool
43 * 44 *
44 * This class computes a set of maps from any kind of observations: 45 * This class computes a set of maps from any kind of observations:
45 * 46 *
@@ -54,7 +55,8 @@ @@ -54,7 +55,8 @@
54 * grid of coordinates. The best fit results (TS, flux, index) are stored in 55 * grid of coordinates. The best fit results (TS, flux, index) are stored in
55 * maps which are saved in the output FITS files. 56 * maps which are saved in the output FITS files.
56 ***************************************************************************/ 57 ***************************************************************************/
57 -class cttsmap : public GApplication { 58 +class cttsmap : public ctool {
  59 +
58 public: 60 public:
59 // Constructors and destructors 61 // Constructors and destructors
60 cttsmap(void); 62 cttsmap(void);
@@ -85,8 +87,6 @@ protected: @@ -85,8 +87,6 @@ protected:
85 // User parameters 87 // User parameters
86 std::string m_infile; //!< Input file 88 std::string m_infile; //!< Input file
87 std::string m_srcname; //!< Name of source which is moved around 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 std::string m_outfile; //!< Output counts map or XML file 90 std::string m_outfile; //!< Output counts map or XML file
91 std::string m_proj; //!< WCS projection 91 std::string m_proj; //!< WCS projection
92 std::string m_coordsys; //!< Coordinate system 92 std::string m_coordsys; //!< Coordinate system