36#define G_GET_PARAMETERS "cttsmap::get_parameters()"
187 this->GApplication::clear();
220 log_header1(TERSE,
"Initialise TS map");
231 static_cast<GOptimizerLM*
>(&
m_opt)->logger(&log);
234 static_cast<GOptimizerLM*
>(&
m_opt)->logger(NULL);
238 GModels models_orig =
m_obs.models();
241 GModels models =
m_obs.models();
247 if ((*
this)[
"fix_spat"].boolean()) {
250 for (
int i = 0; i < models.size(); ++i) {
253 GModelSky* sky=
dynamic_cast<GModelSky*
>(models[i]);
257 GModelSpatial* spatial = sky->spatial();
258 for (
int j = 0; j < spatial->size(); j++) {
272 log_header1(TERSE,
"Compute NULL Hypothesis for TS computation");
275 m_obs.models(models);
283 if ((*
this)[
"use_h0_fit"].
boolean()) {
284 models =
m_obs.models();
290 log_header1(TERSE,
"Generate TS map");
293 for (
int i = binmin; i < binmax; ++i) {
296 GSkyDir bincentre =
m_tsmap.inx2dir(i);
299 log_header2(EXPLICIT,
"Computing TS for bin number "+gammalib::str(i)+
300 " at "+bincentre.print());
303 (*m_testsource)[
"RA"].value(bincentre.ra_deg());
304 (*m_testsource)[
"DEC"].value(bincentre.dec_deg());
308 m_obs.models(models);
322 int status =
m_opt.status();
325 double logL1 = -(
m_opt.value());
328 double ts = 2.0 * (logL1 -
m_logL0);
332 log_value(EXPLICIT,
"TS value", ts);
334 else if (logNormal()) {
335 log_value(NORMAL,
"TS value (bin "+gammalib::str(i)+
")",
336 gammalib::str(ts)+
" ("+bincentre.print()+
")");
340 GModels best_fit_model =
m_obs.models();
341 GModel* testsource = best_fit_model[
m_srcname];
356 m_maps[j](i) = (*testsource)[parname].error();
376 m_obs.models(models_orig);
399 log_header1(TERSE,
"Save TS map");
402 if ((*
this)[
"outmap"].is_valid() && !
m_tsmap.is_empty()) {
405 m_outmap = (*this)[
"outmap"].filename();
423 fits[fits.size()-1]->extname(
"STATUS MAP");
436 fname.append(
" (TS map is empty, no file created)");
438 log_value(NORMAL,
"TS map file", fname);
453 log_header1(TERSE,
"Publish TS map");
456 std::string user_name(name);
457 if (user_name.empty()) {
462 log_value(NORMAL,
"TS map name", user_name);
529 m_testsource = (app.m_testsource != NULL) ? app.m_testsource->clone()
583 std::string msg =
"Source \""+
m_srcname+
"\" has no \"RA\" and "
584 "\"DEC\" parameters. Only sources with \"RA\" "
585 "and \"DEC\" parameters can be used as test "
591 (*m_testsource)[
"RA"].fix();
592 (*m_testsource)[
"DEC"].fix();
598 m_errors = (*this)[
"errors"].boolean();
607 m_binmin = (*this)[
"binmin"].integer();
608 m_binmax = (*this)[
"binmax"].integer();
609 m_logL0 = (*this)[
"logL0"].real();
610 m_publish = (*this)[
"publish"].boolean();
613 (*this)[
"fix_spat"].boolean();
617 (*this)[
"outmap"].query();
Base class for likelihood tools.
GOptimizerLM m_opt
Optimizer.
ctlikelihood & operator=(const ctlikelihood &app)
Assignment operator.
void free_members(void)
Delete class members.
void init_members(void)
Initialise class members.
void free_members(void)
Delete class members.
GObservations m_obs
Observation container.
void init_members(void)
Initialise class members.
void set_obs_statistic(const std::string &statistic)
Set fit statistic for CTA observations.
std::string m_srcname
Name of source which is moved around.
int m_binmax
Map bin number where map computation should end.
cttsmap & operator=(const cttsmap &app)
Assignment operator.
void save(void)
Save maps.
void free_members(void)
Delete class members.
void clear(void)
Clear instance.
GSkyMap m_statusmap
Map of optimizer fit status.
bool m_errors
Compute and store parameter errors?
void copy_members(const cttsmap &app)
Copy class members.
int m_binmin
Map bin number from which computation should start.
std::vector< std::string > m_mapnames
Names of free parameters.
bool m_apply_edisp
Apply energy dispersion?
void init_members(void)
Initialise class members.
bool m_publish
Publish TS map?
cttsmap(void)
Void constructor.
double m_logL0
Likelihood value of null hypothesis.
std::vector< GSkyMap > m_maps
Sky maps for each free parameter.
void publish(const std::string &name="")
Publish TS map.
GFilename m_outmap
Output TS map file name.
virtual ~cttsmap(void)
Destructor.
GModel * m_testsource
Pointer to test source for TS computation.
void init_maps(const GSkyMap &map)
Initialise skymaps.
void get_parameters(void)
Get application parameters.
void process(void)
Computes the TS maps.
TS map calculation tool interface implementation.