diff --git a/doc/source/reference_manual/ctlike.rst b/doc/source/reference_manual/ctlike.rst index c0aeeec..0e0732f 100644 --- a/doc/source/reference_manual/ctlike.rst +++ b/doc/source/reference_manual/ctlike.rst @@ -60,7 +60,10 @@ General parameters Applies energy dispersion to response computation. ``(refit = no) [boolean]`` - Performs refitting of solution after initial fit. + Perform refitting of solution after initial fit. + +``(fix_spat_for_ts = no) [boolean]`` + Fix spatial parameters for TS computation. diff --git a/src/ctlike/ctlike.cpp b/src/ctlike/ctlike.cpp index d34e80f..ea01a20 100644 --- a/src/ctlike/ctlike.cpp +++ b/src/ctlike/ctlike.cpp @@ -262,6 +262,28 @@ void ctlike::run(void) double logL_src = m_logL; GModels models = m_obs.models(); + // Fix spatial parameters if requested + if (m_fix_spat_for_ts) { + + // Loop over all models + for (int i = 0; i < models.size(); ++i) { + + // Continue only if model is skymodel + GModelSky* sky= dynamic_cast(models[i]); + if (sky != NULL) { + + // Fix spatial parameters + GModelSpatial* spatial = sky->spatial(); + for (int j = 0; j < spatial->size(); j++) { + (*spatial)[j].fix(); + } // endfor: looped over spatial parameters + + } // endif: there was a sky model + + } // endfor: looped over models + + } // endif: spatial parameter should be fixed + // Loop over stored models, remove source and refit for (int i = 0; i < ts_srcs.size(); ++i) { models.remove(ts_srcs[i]); @@ -392,8 +414,9 @@ void ctlike::get_parameters(void) } // endif: no models were associated with observations // Get other parameters - m_refit = (*this)["refit"].boolean(); - m_apply_edisp = (*this)["edisp"].boolean(); + m_refit = (*this)["refit"].boolean(); + m_apply_edisp = (*this)["edisp"].boolean(); + m_fix_spat_for_ts = (*this)["fix_spat_for_ts"].boolean(); // Optionally read ahead parameters so that they get correctly // dumped into the log file @@ -542,12 +565,13 @@ void ctlike::init_members(void) // Initialise members m_outmodel.clear(); m_obs.clear(); - m_refit = false; - m_max_iter = 100; // Set maximum number of iterations - m_max_stall = 10; // Set maximum number of stalls - m_logL = 0.0; - m_opt = NULL; - m_apply_edisp = false; + m_refit = false; + m_max_iter = 100; // Set maximum number of iterations + m_max_stall = 10; // Set maximum number of stalls + m_logL = 0.0; + m_opt = NULL; + m_apply_edisp = false; + m_fix_spat_for_ts = false; // Set logger properties log.date(true); @@ -575,14 +599,15 @@ void ctlike::init_members(void) void ctlike::copy_members(const ctlike& app) { // Copy attributes - m_refit = app.m_refit; - m_outmodel = app.m_outmodel; - m_obs = app.m_obs; - m_max_iter = app.m_max_iter; - m_max_stall = app.m_max_stall; - m_logL = app.m_logL; - m_opt = app.m_opt->clone(); - m_apply_edisp = app.m_apply_edisp; + m_refit = app.m_refit; + m_outmodel = app.m_outmodel; + m_obs = app.m_obs; + m_max_iter = app.m_max_iter; + m_max_stall = app.m_max_stall; + m_logL = app.m_logL; + m_opt = app.m_opt->clone(); + m_apply_edisp = app.m_apply_edisp; + m_fix_spat_for_ts = app.m_fix_spat_for_ts; // Return return; diff --git a/src/ctlike/ctlike.hpp b/src/ctlike/ctlike.hpp index 88a7fb0..ae3a846 100644 --- a/src/ctlike/ctlike.hpp +++ b/src/ctlike/ctlike.hpp @@ -73,9 +73,10 @@ protected: double reoptimize_lm(void); // User parameters - bool m_refit; //!< Refitting - std::string m_outmodel; //!< Source model output XML file - bool m_apply_edisp; //!< Apply energy dispersion? + bool m_refit; //!< Refitting + std::string m_outmodel; //!< Source model output XML file + bool m_apply_edisp; //!< Apply energy dispersion? + bool m_fix_spat_for_ts; //!< Fix spatial parameters for TS computation? // Members GObservations m_obs; //!< Observations diff --git a/src/ctlike/ctlike.par b/src/ctlike/ctlike.par index 5ae14f0..2fd8286 100644 --- a/src/ctlike/ctlike.par +++ b/src/ctlike/ctlike.par @@ -17,17 +17,19 @@ # # General parameters #=================== -inobs, f, a, "events.fits",,, "Event list, counts cube or observation definition file" -inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Source model" -expcube, f, a, "NONE",,, "Exposure cube file (only needed for stacked analysis)" -psfcube, f, a, "NONE",,, "PSF cube file (only needed for stacked analysis)" -bkgcube, f, a, "NONE",,, "Background cube file (only needed for stacked analysis)" -caldb, s, a, "prod2",,, "Calibration database" -irf, s, a, "South_50h",,, "Instrument response function" -outmodel, f, a, "crab_results.xml",,, "Source model output file" -stat, s, h, "POISSON",,, "Optimization statistics" -edisp, b, h, no,,, "Apply energy dispersion?" -refit, b, h, no,,, "Do refitting?" +inobs, f, a, "events.fits",,, "Event list, counts cube or observation definition file" +inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Source model" +expcube, f, a, "NONE",,, "Exposure cube file (only needed for stacked analysis)" +psfcube, f, a, "NONE",,, "PSF cube file (only needed for stacked analysis)" +bkgcube, f, a, "NONE",,, "Background cube file (only needed for stacked analysis)" +caldb, s, a, "prod2",,, "Calibration database" +irf, s, a, "South_50h",,, "Instrument response function" +outmodel, f, a, "crab_results.xml",,, "Source model output file" +stat, s, h, "POISSON",,, "Optimization statistics" +edisp, b, h, no,,, "Apply energy dispersion?" +refit, b, h, no,,, "Do refitting?" +fix_spat_for_ts, b, h, no,,,"Fix spatial parameters for TS computation?" + # # Standard parameters #====================