Commit 8829b597ed5038ff9ea45e57d4d385e50253200a
1 parent
30df25df
Move parameter reloading to ctool constructors.
A specific parameter reloading is needed in case that command line parameters are provided.
Showing
1 changed file
with
33 additions
and
18 deletions
src/support/ctool.cpp
| ... | ... | @@ -92,6 +92,20 @@ ctool::ctool(const std::string& name, |
| 92 | 92 | // Initialise members |
| 93 | 93 | init_members(); |
| 94 | 94 | |
| 95 | + // If CTOOLS environment variable is set and if a parameter exists in | |
| 96 | + // the syspfiles folder then set syspfiles folder and reload parameter | |
| 97 | + // file | |
| 98 | + char* ptr = std::getenv("CTOOLS"); | |
| 99 | + if (ptr != NULL) { | |
| 100 | + std::string path = std::string(ptr) + "/syspfiles"; | |
| 101 | + std::string filename = path + "/" + par_filename(); | |
| 102 | + if (access(filename.c_str(), R_OK) == 0) { | |
| 103 | + m_pars.clear(); | |
| 104 | + m_pars.syspfiles(path); | |
| 105 | + m_pars.load(par_filename()); | |
| 106 | + } | |
| 107 | + } | |
| 108 | + | |
| 95 | 109 | // Return |
| 96 | 110 | return; |
| 97 | 111 | } |
| ... | ... | @@ -125,10 +139,24 @@ ctool::ctool(const std::string& name, |
| 125 | 139 | provide_help(); |
| 126 | 140 | exit(0); |
| 127 | 141 | } |
| 128 | - | |
| 142 | + | |
| 129 | 143 | // Initialise members |
| 130 | 144 | init_members(); |
| 131 | 145 | |
| 146 | + // If CTOOLS environment variable is set and if a parameter exists in | |
| 147 | + // the syspfiles folder then set syspfiles folder and reload parameter | |
| 148 | + // file | |
| 149 | + char* ptr = std::getenv("CTOOLS"); | |
| 150 | + if (ptr != NULL) { | |
| 151 | + std::string path = std::string(ptr) + "/syspfiles"; | |
| 152 | + std::string filename = path + "/" + par_filename(); | |
| 153 | + if (access(filename.c_str(), R_OK) == 0) { | |
| 154 | + m_pars.clear(); | |
| 155 | + m_pars.syspfiles(path); | |
| 156 | + m_pars.load(par_filename(), m_args); | |
| 157 | + } | |
| 158 | + } | |
| 159 | + | |
| 132 | 160 | // Open the log file |
| 133 | 161 | logFileOpen(); |
| 134 | 162 | |
| ... | ... | @@ -258,19 +286,6 @@ void ctool::init_members(void) |
| 258 | 286 | // Set language to english to make sure that a dot is a dot |
| 259 | 287 | std::setlocale(LC_ALL, "en_US.UTF-8"); |
| 260 | 288 | |
| 261 | - // If CTOOLS environment variable is set and if a parameter exists in | |
| 262 | - // the syspfiles folder then set syspfiles folder and reload parameter file | |
| 263 | - char* ptr = std::getenv("CTOOLS"); | |
| 264 | - if (ptr != NULL) { | |
| 265 | - std::string path = std::string(ptr) + "/syspfiles"; | |
| 266 | - std::string filename = path + "/" + par_filename(); | |
| 267 | - if (access(filename.c_str(), R_OK) == 0) { | |
| 268 | - m_pars.clear(); | |
| 269 | - m_pars.syspfiles(path); | |
| 270 | - m_pars.load(par_filename()); | |
| 271 | - } | |
| 272 | - } | |
| 273 | - | |
| 274 | 289 | // Return |
| 275 | 290 | return; |
| 276 | 291 | } |
| ... | ... | @@ -610,7 +625,7 @@ GEbounds ctool::create_ebounds(void) |
| 610 | 625 | } |
| 611 | 626 | |
| 612 | 627 | } // endelse: loaded energy boundaries from table extension |
| 613 | - | |
| 628 | + | |
| 614 | 629 | } // endif: ebinalg was "FILE" |
| 615 | 630 | |
| 616 | 631 | // ... otherwise use a linear or a logarithmically-spaced energy binning |
| ... | ... | @@ -681,7 +696,7 @@ GSkyMap ctool::create_map(const GObservations& obs) |
| 681 | 696 | |
| 682 | 697 | // If requested, get pointing from observations |
| 683 | 698 | if (usepnt) { |
| 684 | - | |
| 699 | + | |
| 685 | 700 | // Get mean pointing |
| 686 | 701 | GSkyDir pnt = get_mean_pointing(obs); |
| 687 | 702 | |
| ... | ... | @@ -1247,10 +1262,10 @@ bool ctool::is_onoff(void) |
| 1247 | 1262 | { |
| 1248 | 1263 | // Set onoff flag |
| 1249 | 1264 | bool onoff = ((*this)["method"].string() == "ONOFF"); |
| 1250 | - | |
| 1265 | + | |
| 1251 | 1266 | // Query analysis method chosen |
| 1252 | 1267 | if (onoff) { |
| 1253 | - | |
| 1268 | + | |
| 1254 | 1269 | // Query csphagen parameters |
| 1255 | 1270 | (*this)["inexclusion"].query(); |
| 1256 | 1271 | (*this)["emin"].real(); | ... | ... |