GOnOffFitter.hpp
1 |
/***************************************************************************
|
---|---|
2 |
* GOnOffFitter.hpp - Abstract ON-OFF analysis fitter class *
|
3 |
* ----------------------------------------------------------------------- *
|
4 |
* copyright (C) 2009-2013 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 GOnOffFitter.hpp
|
23 |
* @brief Abstract ON-OFF analysis fitter class interface definition
|
24 |
* @author Pierrick Martin
|
25 |
*/
|
26 |
|
27 |
#ifndef GONOFFFITTER_HPP
|
28 |
#define GONOFFFITTER_HPP
|
29 |
|
30 |
/* __ Includes ___________________________________________________________ */
|
31 |
#include <string> |
32 |
#include <vector> |
33 |
#include "GBase.hpp" |
34 |
#include "GObservations.hpp" |
35 |
#include "GOnOffMaker.hpp" |
36 |
#include "GOptimizer.hpp" |
37 |
#include "GOptimizerFunction.hpp" |
38 |
|
39 |
|
40 |
/***********************************************************************//** |
41 |
* @class GOnOffFitter
|
42 |
*
|
43 |
* @brief Abstract ON-OFF analysis fitter class
|
44 |
*
|
45 |
* This class implements the interface for an ON-OFF analysis in the way
|
46 |
* adopted by existing Cherenkov telescopes such as HESS/VERITAS/MAGIC.
|
47 |
*
|
48 |
* It prepares ON and OFF data through the GOnOffMaker class for different
|
49 |
* background evaluation methods. The result is stored in the form of arrays
|
50 |
* of GOnOffBin elements (spectra or maps or cubes). The observed number of
|
51 |
* excess counts is obtained either through simple arithmetics or through
|
52 |
* obtained by proper rescaling from an expected number of counts for a
|
53 |
* given input source spectrum.
|
54 |
*
|
55 |
* The fit parameters can be accessed through operator[...] in a way
|
56 |
* similar to the implementation of GModel. Not sure it is desirable
|
57 |
* since we may have lots of expected numbers of hadrons and gammas
|
58 |
* to be fitted and it may not be relevant to have access to these.
|
59 |
*
|
60 |
* Also to be clarified:
|
61 |
* - Do we need a complete model=spatial*spectral*temporal here ?
|
62 |
* - Do we fix the background maker type in each derived GOnOffFitter class ?
|
63 |
* - In which format do we output some results (like significance) ?
|
64 |
* - Do we want a pointer to the GOnOffBin array as a member of this class ?
|
65 |
* - What about housekeeping of the parameter array ?
|
66 |
*
|
67 |
***************************************************************************/
|
68 |
class GOnOffFitter : public GBase { |
69 |
|
70 |
public:
|
71 |
// Constructors and destructors
|
72 |
GOnOffFitter(void);
|
73 |
GOnOffFitter(const GOnOffFitter& onoff);
|
74 |
explicit GOnOffFitter(const std::string& filename, const GOnOffMaker& maker); |
75 |
explicit GOnOffFitter(const GObservations& obs, const GOnOffMaker& maker); |
76 |
virtual ~GOnOffFitter(void); |
77 |
|
78 |
// Operators
|
79 |
virtual GOnOffFitter& operator=(const GOnOffFitter& onoff); |
80 |
virtual GModelPar& operator[](const int& index); |
81 |
virtual const GModelPar& operator[](const int& index) const; |
82 |
virtual GModelPar& operator[](const std::string& name); |
83 |
virtual const GModelPar& operator[](const std::string& name) const; |
84 |
|
85 |
// Pure virtual methods
|
86 |
virtual void clear(void) = 0; |
87 |
virtual GOnOffFitter* clone(void) const = 0; |
88 |
virtual int size(void) const = 0; |
89 |
virtual std::string type(void) const = 0; |
90 |
virtual std::string print(const GChatter& chatter = NORMAL) const = 0; |
91 |
virtual void optimize(GOptimizer& opt) = 0; |
92 |
|
93 |
// Implemented methods
|
94 |
GObservations* obs(void) const; |
95 |
void obs(const GObservations& obs); |
96 |
void obs(const std::string& filename); |
97 |
GOnOffMaker* maker(void) const; |
98 |
void maker(const GOnOffMaker& maker); |
99 |
|
100 |
// Optimizer
|
101 |
class optimizer : public GOptimizerFunction { |
102 |
public:
|
103 |
// Constructors and destructors
|
104 |
optimizer(void);
|
105 |
optimizer(GOnOffFitter* onoff); |
106 |
optimizer(const optimizer& fct);
|
107 |
~optimizer(void);
|
108 |
|
109 |
// Operators
|
110 |
optimizer& operator=(const optimizer& fct); |
111 |
|
112 |
// Implemented pure virtual base class methods
|
113 |
double value(void); |
114 |
double npred(void) const; |
115 |
GVector* gradient(void);
|
116 |
GMatrixSparse* covar(void);
|
117 |
|
118 |
// Other methods
|
119 |
void set(GOnOffFitter* obs);
|
120 |
void eval(const GOptimizerPars& pars); |
121 |
void poisson_binned(const GObservation& obs, |
122 |
const GOptimizerPars& pars);
|
123 |
|
124 |
protected:
|
125 |
// Protected methods
|
126 |
void init_members(void); |
127 |
void copy_members(const optimizer& fct); |
128 |
void free_members(void); |
129 |
|
130 |
// Protected data members
|
131 |
double m_value; //!< Function value |
132 |
double m_npred; //!< Total number of predicted events |
133 |
double m_minmod; //!< Minimum model value |
134 |
double m_minerr; //!< Minimum error value |
135 |
GVector* m_gradient; //!< Pointer to gradient vector
|
136 |
GMatrixSparse* m_covar; //!< Pointer to covariance matrix
|
137 |
GVector* m_wrk_grad; //!< Pointer to working gradient vector
|
138 |
GOnOffFitter* m_this; //!< Pointer to GOnOffFitter object
|
139 |
}; |
140 |
|
141 |
// Optimizer access method
|
142 |
const GOnOffFitter::optimizer& function(void) const; |
143 |
|
144 |
protected:
|
145 |
// Protected methods
|
146 |
void init_members(void); |
147 |
void copy_members(const GOnOffFitter& obs); |
148 |
void free_members(void); |
149 |
|
150 |
// Protected members
|
151 |
GObservations* m_obs; //!< Container of observations
|
152 |
GOnOffFitter::optimizer* m_fct; //!< Optimizer function
|
153 |
GOnOffMaker* m_maker; //!< Background maker containing ON-OFF data
|
154 |
std::vector<GModelPar*> m_pars; //!< Parameter pointers
|
155 |
}; |
156 |
|
157 |
#endif /* GONOFFFITTER_HPP */ |
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|