Commit fb15d981e6d29dd83608880cab5fdb3c9ddd27f2

Authored by knodlseder
1 parent 94d82238

add refit and stat parameters

src/ctlike/ctlike.cpp
@@ -152,6 +152,8 @@ void ctlike::get_parameters(void) @@ -152,6 +152,8 @@ void ctlike::get_parameters(void)
152 { 152 {
153 // Get standard parameters 153 // Get standard parameters
154 m_method = toupper(par("method")->value()); 154 m_method = toupper(par("method")->value());
  155 + m_stat = toupper(par("stat")->value());
  156 + m_refit = par("refit")->boolean();
155 m_caldb = par("caldb")->value(); 157 m_caldb = par("caldb")->value();
156 m_irf = par("irf")->value(); 158 m_irf = par("irf")->value();
157 m_srcmdl = par("srcmdl")->value(); 159 m_srcmdl = par("srcmdl")->value();
@@ -179,8 +181,8 @@ void ctlike::optimize_lm(void) @@ -179,8 +181,8 @@ void ctlike::optimize_lm(void)
179 { 181 {
180 // Allocate optimizer. The logger is only passed to the optimizer 182 // Allocate optimizer. The logger is only passed to the optimizer
181 // constructor if optimizer logging is requested. 183 // constructor if optimizer logging is requested.
182 - GOptimizerLM* opt = (logExplicit()) ? new GOptimizerLM(log)  
183 - : new GOptimizerLM(); 184 + GOptimizerLM* opt = (logTerse()) ? new GOptimizerLM(log)
  185 + : new GOptimizerLM();
184 186
185 // Assign optimizer 187 // Assign optimizer
186 m_opt = opt; 188 m_opt = opt;
@@ -189,7 +191,7 @@ void ctlike::optimize_lm(void) @@ -189,7 +191,7 @@ void ctlike::optimize_lm(void)
189 opt->max_iter(m_max_iter); 191 opt->max_iter(m_max_iter);
190 192
191 // Write Header for optimization and indent for optimizer logging 193 // Write Header for optimization and indent for optimizer logging
192 - if (logExplicit()) { 194 + if (logTerse()) {
193 log << std::endl; 195 log << std::endl;
194 log.header1("Maximum likelihood optimisation"); 196 log.header1("Maximum likelihood optimisation");
195 log.indent(1); 197 log.indent(1);
@@ -198,6 +200,10 @@ void ctlike::optimize_lm(void) @@ -198,6 +200,10 @@ void ctlike::optimize_lm(void)
198 // Perform LM optimization 200 // Perform LM optimization
199 m_obs.optimize(*m_opt); 201 m_obs.optimize(*m_opt);
200 202
  203 + // Optionally refit
  204 + if (m_refit)
  205 + m_obs.optimize(*m_opt);
  206 +
201 // Get models back 207 // Get models back
202 m_models = *(m_obs.models()); 208 m_models = *(m_obs.models());
203 209
@@ -236,6 +242,7 @@ void ctlike::unbinned(const std::string&amp; evfile) @@ -236,6 +242,7 @@ void ctlike::unbinned(const std::string&amp; evfile)
236 { 242 {
237 // Declare observations 243 // Declare observations
238 GCTAObservation run; 244 GCTAObservation run;
  245 + run.statistics(m_stat);
239 246
240 // DUMMY: Setup ROI covered by data. This is needed since actual test 247 // DUMMY: Setup ROI covered by data. This is needed since actual test
241 // data do not contain any ROI informations. 248 // data do not contain any ROI informations.
@@ -282,6 +289,7 @@ void ctlike::binned(const std::string&amp; cntmap) @@ -282,6 +289,7 @@ void ctlike::binned(const std::string&amp; cntmap)
282 { 289 {
283 // Declare observations 290 // Declare observations
284 GCTAObservation run; 291 GCTAObservation run;
  292 + run.statistics(m_stat);
285 293
286 // Load binned CTA observation 294 // Load binned CTA observation
287 run.load_binned(cntmap); 295 run.load_binned(cntmap);
src/ctlike/ctlike.hpp
@@ -55,6 +55,8 @@ protected: @@ -55,6 +55,8 @@ protected:
55 55
56 // User parameters 56 // User parameters
57 std::string m_method; //!< Likelihood fitting method (binned/unbinned) 57 std::string m_method; //!< Likelihood fitting method (binned/unbinned)
  58 + std::string m_stat; //!< Optimisation statistics (poisson/gaussian)
  59 + bool m_refit; //!< Refitting
58 std::string m_caldb; //!< Calibration database 60 std::string m_caldb; //!< Calibration database
59 std::string m_irf; //!< Instrument response functions 61 std::string m_irf; //!< Instrument response functions
60 std::string m_srcmdl; //!< Source model XML file 62 std::string m_srcmdl; //!< Source model XML file
src/ctlike/ctlike.par
@@ -26,6 +26,8 @@ cntmap, f, a, &quot;test/data/run_00006028_cntmap.fits.gz&quot;,,, &quot;Counts map&quot; @@ -26,6 +26,8 @@ cntmap, f, a, &quot;test/data/run_00006028_cntmap.fits.gz&quot;,,, &quot;Counts map&quot;
26 # General parameters 26 # General parameters
27 #=================== 27 #===================
28 method, s, a, "UNBINNED",,, "Maximum likelihood method" 28 method, s, a, "UNBINNED",,, "Maximum likelihood method"
  29 +stat, s, a, "POISSON",,, "Optimization statistics"
  30 +refit, b, a, no,,, "Do refitting?"
29 caldb, s, a, "test/irf",,, "Calibration database" 31 caldb, s, a, "test/irf",,, "Calibration database"
30 irf, s, a, "kb_E_50h_v3",,, "Instrument response function" 32 irf, s, a, "kb_E_50h_v3",,, "Instrument response function"
31 srcmdl, f, a, "test/data/source1.xml",,, "Source model" 33 srcmdl, f, a, "test/data/source1.xml",,, "Source model"