Commit 29d283991d86e4465d020fb7342bfbd508000911
Merge branch '1568-TS-for-closeby-sources' into integration
Showing
4 changed files
with
62 additions
and
31 deletions
doc/source/reference_manual/ctlike.rst
| @@ -60,7 +60,10 @@ General parameters | @@ -60,7 +60,10 @@ General parameters | ||
| 60 | Applies energy dispersion to response computation. | 60 | Applies energy dispersion to response computation. |
| 61 | 61 | ||
| 62 | ``(refit = no) [boolean]`` | 62 | ``(refit = no) [boolean]`` |
| 63 | - Performs refitting of solution after initial fit. | 63 | + Perform refitting of solution after initial fit. |
| 64 | + | ||
| 65 | +``(fix_spat_for_ts = no) [boolean]`` | ||
| 66 | + Fix spatial parameters for TS computation. | ||
| 64 | 67 | ||
| 65 | 68 | ||
| 66 | 69 |
src/ctlike/ctlike.cpp
| @@ -262,6 +262,28 @@ void ctlike::run(void) | @@ -262,6 +262,28 @@ void ctlike::run(void) | ||
| 262 | double logL_src = m_logL; | 262 | double logL_src = m_logL; |
| 263 | GModels models = m_obs.models(); | 263 | GModels models = m_obs.models(); |
| 264 | 264 | ||
| 265 | + // Fix spatial parameters if requested | ||
| 266 | + if (m_fix_spat_for_ts) { | ||
| 267 | + | ||
| 268 | + // Loop over all models | ||
| 269 | + for (int i = 0; i < models.size(); ++i) { | ||
| 270 | + | ||
| 271 | + // Continue only if model is skymodel | ||
| 272 | + GModelSky* sky= dynamic_cast<GModelSky*>(models[i]); | ||
| 273 | + if (sky != NULL) { | ||
| 274 | + | ||
| 275 | + // Fix spatial parameters | ||
| 276 | + GModelSpatial* spatial = sky->spatial(); | ||
| 277 | + for (int j = 0; j < spatial->size(); j++) { | ||
| 278 | + (*spatial)[j].fix(); | ||
| 279 | + } // endfor: looped over spatial parameters | ||
| 280 | + | ||
| 281 | + } // endif: there was a sky model | ||
| 282 | + | ||
| 283 | + } // endfor: looped over models | ||
| 284 | + | ||
| 285 | + } // endif: spatial parameter should be fixed | ||
| 286 | + | ||
| 265 | // Loop over stored models, remove source and refit | 287 | // Loop over stored models, remove source and refit |
| 266 | for (int i = 0; i < ts_srcs.size(); ++i) { | 288 | for (int i = 0; i < ts_srcs.size(); ++i) { |
| 267 | models.remove(ts_srcs[i]); | 289 | models.remove(ts_srcs[i]); |
| @@ -392,8 +414,9 @@ void ctlike::get_parameters(void) | @@ -392,8 +414,9 @@ void ctlike::get_parameters(void) | ||
| 392 | } // endif: no models were associated with observations | 414 | } // endif: no models were associated with observations |
| 393 | 415 | ||
| 394 | // Get other parameters | 416 | // Get other parameters |
| 395 | - m_refit = (*this)["refit"].boolean(); | ||
| 396 | - m_apply_edisp = (*this)["edisp"].boolean(); | 417 | + m_refit = (*this)["refit"].boolean(); |
| 418 | + m_apply_edisp = (*this)["edisp"].boolean(); | ||
| 419 | + m_fix_spat_for_ts = (*this)["fix_spat_for_ts"].boolean(); | ||
| 397 | 420 | ||
| 398 | // Optionally read ahead parameters so that they get correctly | 421 | // Optionally read ahead parameters so that they get correctly |
| 399 | // dumped into the log file | 422 | // dumped into the log file |
| @@ -542,12 +565,13 @@ void ctlike::init_members(void) | @@ -542,12 +565,13 @@ void ctlike::init_members(void) | ||
| 542 | // Initialise members | 565 | // Initialise members |
| 543 | m_outmodel.clear(); | 566 | m_outmodel.clear(); |
| 544 | m_obs.clear(); | 567 | m_obs.clear(); |
| 545 | - m_refit = false; | ||
| 546 | - m_max_iter = 100; // Set maximum number of iterations | ||
| 547 | - m_max_stall = 10; // Set maximum number of stalls | ||
| 548 | - m_logL = 0.0; | ||
| 549 | - m_opt = NULL; | ||
| 550 | - m_apply_edisp = false; | 568 | + m_refit = false; |
| 569 | + m_max_iter = 100; // Set maximum number of iterations | ||
| 570 | + m_max_stall = 10; // Set maximum number of stalls | ||
| 571 | + m_logL = 0.0; | ||
| 572 | + m_opt = NULL; | ||
| 573 | + m_apply_edisp = false; | ||
| 574 | + m_fix_spat_for_ts = false; | ||
| 551 | 575 | ||
| 552 | // Set logger properties | 576 | // Set logger properties |
| 553 | log.date(true); | 577 | log.date(true); |
| @@ -575,14 +599,15 @@ void ctlike::init_members(void) | @@ -575,14 +599,15 @@ void ctlike::init_members(void) | ||
| 575 | void ctlike::copy_members(const ctlike& app) | 599 | void ctlike::copy_members(const ctlike& app) |
| 576 | { | 600 | { |
| 577 | // Copy attributes | 601 | // Copy attributes |
| 578 | - m_refit = app.m_refit; | ||
| 579 | - m_outmodel = app.m_outmodel; | ||
| 580 | - m_obs = app.m_obs; | ||
| 581 | - m_max_iter = app.m_max_iter; | ||
| 582 | - m_max_stall = app.m_max_stall; | ||
| 583 | - m_logL = app.m_logL; | ||
| 584 | - m_opt = app.m_opt->clone(); | ||
| 585 | - m_apply_edisp = app.m_apply_edisp; | 602 | + m_refit = app.m_refit; |
| 603 | + m_outmodel = app.m_outmodel; | ||
| 604 | + m_obs = app.m_obs; | ||
| 605 | + m_max_iter = app.m_max_iter; | ||
| 606 | + m_max_stall = app.m_max_stall; | ||
| 607 | + m_logL = app.m_logL; | ||
| 608 | + m_opt = app.m_opt->clone(); | ||
| 609 | + m_apply_edisp = app.m_apply_edisp; | ||
| 610 | + m_fix_spat_for_ts = app.m_fix_spat_for_ts; | ||
| 586 | 611 | ||
| 587 | // Return | 612 | // Return |
| 588 | return; | 613 | return; |
src/ctlike/ctlike.hpp
| @@ -73,9 +73,10 @@ protected: | @@ -73,9 +73,10 @@ protected: | ||
| 73 | double reoptimize_lm(void); | 73 | double reoptimize_lm(void); |
| 74 | 74 | ||
| 75 | // User parameters | 75 | // User parameters |
| 76 | - bool m_refit; //!< Refitting | ||
| 77 | - std::string m_outmodel; //!< Source model output XML file | ||
| 78 | - bool m_apply_edisp; //!< Apply energy dispersion? | 76 | + bool m_refit; //!< Refitting |
| 77 | + std::string m_outmodel; //!< Source model output XML file | ||
| 78 | + bool m_apply_edisp; //!< Apply energy dispersion? | ||
| 79 | + bool m_fix_spat_for_ts; //!< Fix spatial parameters for TS computation? | ||
| 79 | 80 | ||
| 80 | // Members | 81 | // Members |
| 81 | GObservations m_obs; //!< Observations | 82 | GObservations m_obs; //!< Observations |
src/ctlike/ctlike.par
| @@ -17,17 +17,19 @@ | @@ -17,17 +17,19 @@ | ||
| 17 | # | 17 | # |
| 18 | # General parameters | 18 | # General parameters |
| 19 | #=================== | 19 | #=================== |
| 20 | -inobs, f, a, "events.fits",,, "Event list, counts cube or observation definition file" | ||
| 21 | -inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Source model" | ||
| 22 | -expcube, f, a, "NONE",,, "Exposure cube file (only needed for stacked analysis)" | ||
| 23 | -psfcube, f, a, "NONE",,, "PSF cube file (only needed for stacked analysis)" | ||
| 24 | -bkgcube, f, a, "NONE",,, "Background cube file (only needed for stacked analysis)" | ||
| 25 | -caldb, s, a, "prod2",,, "Calibration database" | ||
| 26 | -irf, s, a, "South_50h",,, "Instrument response function" | ||
| 27 | -outmodel, f, a, "crab_results.xml",,, "Source model output file" | ||
| 28 | -stat, s, h, "POISSON",,, "Optimization statistics" | ||
| 29 | -edisp, b, h, no,,, "Apply energy dispersion?" | ||
| 30 | -refit, b, h, no,,, "Do refitting?" | 20 | +inobs, f, a, "events.fits",,, "Event list, counts cube or observation definition file" |
| 21 | +inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Source model" | ||
| 22 | +expcube, f, a, "NONE",,, "Exposure cube file (only needed for stacked analysis)" | ||
| 23 | +psfcube, f, a, "NONE",,, "PSF cube file (only needed for stacked analysis)" | ||
| 24 | +bkgcube, f, a, "NONE",,, "Background cube file (only needed for stacked analysis)" | ||
| 25 | +caldb, s, a, "prod2",,, "Calibration database" | ||
| 26 | +irf, s, a, "South_50h",,, "Instrument response function" | ||
| 27 | +outmodel, f, a, "crab_results.xml",,, "Source model output file" | ||
| 28 | +stat, s, h, "POISSON",,, "Optimization statistics" | ||
| 29 | +edisp, b, h, no,,, "Apply energy dispersion?" | ||
| 30 | +refit, b, h, no,,, "Do refitting?" | ||
| 31 | +fix_spat_for_ts, b, h, no,,,"Fix spatial parameters for TS computation?" | ||
| 32 | + | ||
| 31 | # | 33 | # |
| 32 | # Standard parameters | 34 | # Standard parameters |
| 33 | #==================== | 35 | #==================== |