ctools 2.1.0.dev
Loading...
Searching...
No Matches
ctlike.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * ctlike - Maximum likelihood fitting tool *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2010-2022 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- *
6 * *
7 * This program is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19 * *
20 ***************************************************************************/
21/**
22 * @file ctlike.hpp
23 * @brief Maximum likelihood fitting tool definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef CTLIKE_HPP
28#define CTLIKE_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include "ctlikelihood.hpp"
32
33/* __Definitions _________________________________________________________ */
34#define CTLIKE_NAME "ctlike"
35
36
37/***********************************************************************//**
38 * @class ctlike
39 *
40 * @brief Maximum likelihood fitting tool
41 ***************************************************************************/
42class ctlike : public ctlikelihood {
43
44public:
45 // Constructors and destructors
46 ctlike(void);
47 explicit ctlike(const GObservations& obs);
48 ctlike(int argc, char *argv[]);
49 ctlike(const ctlike& app);
50 virtual ~ctlike(void);
51
52 // Operators
53 ctlike& operator=(const ctlike& app);
54
55 // Methods
56 void clear(void);
57 void process(void);
58 void save(void);
59 const int& iter(void) const;
60 const double& logL(void) const;
61 const double& nobs(void) const;
62 const double& npred(void) const;
63
64protected:
65 // Protected methods
66 void init_members(void);
67 void copy_members(const ctlike& app);
68 void free_members(void);
69 void get_parameters(void);
70 void optimize_lm(void);
71 double reoptimize_lm(void);
72 GXml xml_result(void) const;
73 bool refit(const GOptimizer* opt);
74
75 // User parameters
76 GFilename m_outmodel; //!< Source model output XML file name
77 GFilename m_outcovmat; //!< Covariance matrix output file name
78 int m_max_iter; //!< Maximum number of iterations
79 bool m_refit; //!< Refitting?
80 bool m_refit_if_failed; //!< Refitting in case of failure?
81 bool m_apply_edisp; //!< Apply energy dispersion?
82 bool m_fix_spat_for_ts; //!< Fix spatial parameters for TS computation?
83 GChatter m_chatter; //!< Chattiness
84
85 // Members
86 int m_iter; //!< Number of iterations
87 double m_logL; //!< Maximum log likelihood
88 double m_nobs; //!< Number of observed events
89 double m_npred; //!< Number of predicted events
90};
91
92
93/***********************************************************************//**
94 * @brief Return number of maximum likelihood iterations
95 *
96 * @return Number of maximum likelihood iterations.
97 ***************************************************************************/
98inline
99const int& ctlike::iter(void) const
100{
101 return (m_iter);
102}
103
104
105/***********************************************************************//**
106 * @brief Return maximum likelihood value
107 *
108 * @return Maximum likelihood value.
109 ***************************************************************************/
110inline
111const double& ctlike::logL(void) const
112{
113 return (m_logL);
114}
115
116
117/***********************************************************************//**
118 * @brief Return number of observed events
119 *
120 * @return Number of observed events.
121 ***************************************************************************/
122inline
123const double& ctlike::nobs(void) const
124{
125 return (m_nobs);
126}
127
128
129/***********************************************************************//**
130 * @brief Return number of predicted events
131 *
132 * @return Number of predicted events.
133 ***************************************************************************/
134inline
135const double& ctlike::npred(void) const
136{
137 return (m_npred);
138}
139
140#endif /* CTLIKE_HPP */
Maximum likelihood fitting tool.
Definition ctlike.hpp:42
void process(void)
Process maximum likelihood analysis.
Definition ctlike.cpp:216
GXml xml_result(void) const
Generate XML result.
Definition ctlike.cpp:681
int m_max_iter
Maximum number of iterations.
Definition ctlike.hpp:78
ctlike(void)
Void constructor.
Definition ctlike.cpp:56
void save(void)
Save results.
Definition ctlike.cpp:357
ctlike & operator=(const ctlike &app)
Assignment operator.
Definition ctlike.cpp:147
void copy_members(const ctlike &app)
Copy class members.
Definition ctlike.cpp:446
bool refit(const GOptimizer *opt)
Refit needed?
Definition ctlike.cpp:753
const double & npred(void) const
Return number of predicted events.
Definition ctlike.hpp:135
GFilename m_outmodel
Source model output XML file name.
Definition ctlike.hpp:76
void free_members(void)
Delete class members.
Definition ctlike.cpp:470
bool m_refit_if_failed
Refitting in case of failure?
Definition ctlike.hpp:80
void optimize_lm(void)
Optimise model parameters.
Definition ctlike.cpp:550
const int & iter(void) const
Return number of maximum likelihood iterations.
Definition ctlike.hpp:99
bool m_fix_spat_for_ts
Fix spatial parameters for TS computation?
Definition ctlike.hpp:82
bool m_refit
Refitting?
Definition ctlike.hpp:79
double m_npred
Number of predicted events.
Definition ctlike.hpp:89
void get_parameters(void)
Get application parameters.
Definition ctlike.cpp:482
double reoptimize_lm(void)
Re-optimise model parameters for TS computation.
Definition ctlike.cpp:625
GFilename m_outcovmat
Covariance matrix output file name.
Definition ctlike.hpp:77
double m_logL
Maximum log likelihood.
Definition ctlike.hpp:87
double m_nobs
Number of observed events.
Definition ctlike.hpp:88
void clear(void)
Clear ctlike tool.
Definition ctlike.cpp:182
int m_iter
Number of iterations.
Definition ctlike.hpp:86
bool m_apply_edisp
Apply energy dispersion?
Definition ctlike.hpp:81
const double & logL(void) const
Return maximum likelihood value.
Definition ctlike.hpp:111
GChatter m_chatter
Chattiness.
Definition ctlike.hpp:83
virtual ~ctlike(void)
Destructor.
Definition ctlike.cpp:125
const double & nobs(void) const
Return number of observed events.
Definition ctlike.hpp:123
void init_members(void)
Initialise class members.
Definition ctlike.cpp:417
Base class for likelihood tools.
const GOptimizer * opt(void) const
Return optimizer.
const GObservations & obs(void) const
Return observation container.
Likelihood tool base class interface definition.