Commit 9204bcf597d465aed1507729b372fb72be331ec8
1 parent
3ebe39c2
implement parameter file reading
Showing
2 changed files
with
165 additions
and
19 deletions
src/ctselect/ctselect.cpp
| @@ -24,23 +24,153 @@ | @@ -24,23 +24,153 @@ | ||
| 24 | #include "ctselect.hpp" | 24 | #include "ctselect.hpp" |
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | +/*========================================================================== | ||
| 28 | + = = | ||
| 29 | + = Constructors/destructors = | ||
| 30 | + = = | ||
| 31 | + ==========================================================================*/ | ||
| 32 | + | ||
| 33 | +/***********************************************************************//** | ||
| 34 | + * @brief Void constructor | ||
| 35 | + ***************************************************************************/ | ||
| 36 | +ctselect::ctselect(void) : GApplication(CTSELECT_NAME, CTSELECT_VERSION) | ||
| 37 | +{ | ||
| 38 | + // Initialise members | ||
| 39 | + init_members(); | ||
| 40 | + | ||
| 41 | + // Write header into logger | ||
| 42 | + log_header(); | ||
| 43 | + | ||
| 44 | + // Return | ||
| 45 | + return; | ||
| 46 | +} | ||
| 47 | + | ||
| 48 | + | ||
| 49 | +/***********************************************************************//** | ||
| 50 | + * @brief Command line constructor | ||
| 51 | + * | ||
| 52 | + * @param[in] argc Number of arguments in command line. | ||
| 53 | + * @param[in] argv Array of command line arguments. | ||
| 54 | + ***************************************************************************/ | ||
| 55 | +ctselect::ctselect(int argc, char *argv[]) : | ||
| 56 | + GApplication(CTSELECT_NAME, CTSELECT_VERSION, argc, argv) | ||
| 57 | +{ | ||
| 58 | + // Initialise members | ||
| 59 | + init_members(); | ||
| 60 | + | ||
| 61 | + // Write header into logger | ||
| 62 | + log_header(); | ||
| 63 | + | ||
| 64 | + // Return | ||
| 65 | + return; | ||
| 66 | +} | ||
| 67 | + | ||
| 68 | + | ||
| 69 | +/***********************************************************************//** | ||
| 70 | + * @brief Destructor | ||
| 71 | + ***************************************************************************/ | ||
| 72 | +ctselect::~ctselect(void) | ||
| 73 | +{ | ||
| 74 | + // Free members | ||
| 75 | + free_members(); | ||
| 76 | + | ||
| 77 | + // Return | ||
| 78 | + return; | ||
| 79 | +} | ||
| 80 | + | ||
| 81 | + | ||
| 82 | +/*========================================================================== | ||
| 83 | + = = | ||
| 84 | + = Operators = | ||
| 85 | + = = | ||
| 86 | + ==========================================================================*/ | ||
| 87 | + | ||
| 88 | +/*========================================================================== | ||
| 89 | + = = | ||
| 90 | + = Public methods = | ||
| 91 | + = = | ||
| 92 | + ==========================================================================*/ | ||
| 93 | + | ||
| 94 | +/***********************************************************************//** | ||
| 95 | + * @brief Select event data | ||
| 96 | + ***************************************************************************/ | ||
| 97 | +void ctselect::run(void) | ||
| 98 | +{ | ||
| 99 | + // Get parameters | ||
| 100 | + get_parameters(); | ||
| 101 | + | ||
| 102 | + // Write parameters into logger | ||
| 103 | + if (logTerse()) { | ||
| 104 | + log_parameters(); | ||
| 105 | + log << std::endl; | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + // Return | ||
| 109 | + return; | ||
| 110 | +} | ||
| 111 | + | ||
| 112 | + | ||
| 113 | +/***********************************************************************//** | ||
| 114 | + * @brief Get application parameters | ||
| 115 | + * | ||
| 116 | + * Get all task parameters from parameter file or (if required) by querying | ||
| 117 | + * the user. | ||
| 118 | + ***************************************************************************/ | ||
| 119 | +void ctselect::get_parameters(void) | ||
| 120 | +{ | ||
| 121 | + // Get parameters | ||
| 122 | + m_infile = par("infile")->value(); | ||
| 123 | + m_outfile = par("outfile")->value(); | ||
| 124 | + m_ra = par("ra")->real(); | ||
| 125 | + m_dec = par("dec")->real(); | ||
| 126 | + m_rad = par("rad")->real(); | ||
| 127 | + m_tmin = par("tmin")->real(); | ||
| 128 | + m_tmax = par("tmax")->real(); | ||
| 129 | + m_emin = par("emin")->real(); | ||
| 130 | + m_emax = par("emax")->real(); | ||
| 131 | + | ||
| 132 | + // Return | ||
| 133 | + return; | ||
| 134 | +} | ||
| 135 | + | ||
| 136 | + | ||
| 137 | +/*========================================================================== | ||
| 138 | + = = | ||
| 139 | + = Private methods = | ||
| 140 | + = = | ||
| 141 | + ==========================================================================*/ | ||
| 142 | + | ||
| 143 | +/***********************************************************************//** | ||
| 144 | + * @brief Initialise class members | ||
| 145 | + ***************************************************************************/ | ||
| 146 | +void ctselect::init_members(void) | ||
| 147 | +{ | ||
| 148 | + // Initialise members | ||
| 149 | + m_infile.clear(); | ||
| 150 | + m_outfile.clear(); | ||
| 151 | + m_ra = 0.0; | ||
| 152 | + m_dec = 0.0; | ||
| 153 | + m_rad = 0.0; | ||
| 154 | + m_tmin = 0.0; | ||
| 155 | + m_tmax = 0.0; | ||
| 156 | + m_emin = 0.0; | ||
| 157 | + m_emax = 0.0; | ||
| 158 | + | ||
| 159 | + // Set logger properties | ||
| 160 | + log.date(true); | ||
| 161 | + | ||
| 162 | + // Return | ||
| 163 | + return; | ||
| 164 | +} | ||
| 165 | + | ||
| 166 | + | ||
| 27 | /***********************************************************************//** | 167 | /***********************************************************************//** |
| 28 | - * @brief Application | 168 | + * @brief Delete class members |
| 29 | ***************************************************************************/ | 169 | ***************************************************************************/ |
| 30 | -int ctselect::run(void) | 170 | +void ctselect::free_members(void) |
| 31 | { | 171 | { |
| 32 | - // Test dump | ||
| 33 | - std::cout << *this << std::endl; | ||
| 34 | - | ||
| 35 | - // DUMMY FOR TESTING | ||
| 36 | - std::string value; | ||
| 37 | - value = par("string")->value(); | ||
| 38 | - std::cout << value << std::endl; | ||
| 39 | - value = par("chatter")->value(); | ||
| 40 | - std::cout << value << std::endl; | ||
| 41 | - value = par("clobber")->value(); | ||
| 42 | - std::cout << value << std::endl; | 172 | + // Free members |
| 43 | 173 | ||
| 44 | // Return | 174 | // Return |
| 45 | - return 0; | 175 | + return; |
| 46 | } | 176 | } |
src/ctselect/ctselect.hpp
| @@ -35,13 +35,29 @@ | @@ -35,13 +35,29 @@ | ||
| 35 | class ctselect : public GApplication { | 35 | class ctselect : public GApplication { |
| 36 | public: | 36 | public: |
| 37 | // Constructors and destructors | 37 | // Constructors and destructors |
| 38 | - ctselect(void) : | ||
| 39 | - GApplication(CTSELECT_NAME, CTSELECT_VERSION) { return; } | ||
| 40 | - ctselect(int argc, char *argv[]) : | ||
| 41 | - GApplication(CTSELECT_NAME, CTSELECT_VERSION, argc, argv) { return; } | 38 | + ctselect(void); |
| 39 | + ctselect(int argc, char *argv[]); | ||
| 40 | + ~ctselect(void); | ||
| 42 | 41 | ||
| 43 | // Methods | 42 | // Methods |
| 44 | - int run(void); | 43 | + void run(void); |
| 44 | + void get_parameters(void); | ||
| 45 | + | ||
| 46 | +protected: | ||
| 47 | + // Protected methods | ||
| 48 | + void init_members(void); | ||
| 49 | + void free_members(void); | ||
| 50 | + | ||
| 51 | + // User parameters | ||
| 52 | + std::string m_infile; //!< Input event list | ||
| 53 | + std::string m_outfile; //!< Output event list | ||
| 54 | + double m_ra; //!< RA of ROI centre | ||
| 55 | + double m_dec; //!< DEC of ROI centre | ||
| 56 | + double m_rad; //!< ROI radius | ||
| 57 | + double m_tmin; //!< Start time | ||
| 58 | + double m_tmax; //!< Stop time | ||
| 59 | + double m_emin; //!< Lower energy | ||
| 60 | + double m_emax; //!< Upper energy | ||
| 45 | }; | 61 | }; |
| 46 | 62 | ||
| 47 | #endif /* CTSELECT_HPP */ | 63 | #endif /* CTSELECT_HPP */ |