ctools  2.0.0
 All Classes Namespaces Files Functions Variables Macros Pages
ctulimit.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * ctulimit - Upper limit calculation tool *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2015-2022 by Michael Mayer *
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 ctulimit.hpp
23  * @brief Upper limit calculation tool interface definition
24  * @author Michael Mayer
25  */
26 
27 #ifndef CTULIMIT_HPP
28 #define CTULIMIT_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include "ctlikelihood.hpp"
32 
33 /* __Definitions _________________________________________________________ */
34 #define CTULIMIT_NAME "ctulimit"
35 
36 
37 /***********************************************************************//**
38  * @class ctulimit
39  *
40  * @brief Upper limit calculation tool
41  *
42  * This class computes and upper limit for a given source.
43  *
44  * The class operates on predefined observation containers, an individual
45  * event list or an observation definition XML file.
46  *
47  * During the computation the likelihood function is inspected to find the
48  * best value for the upper limit.
49  ***************************************************************************/
50 class ctulimit : public ctlikelihood {
51 
52 public:
53  // Constructors and destructors
54  ctulimit(void);
55  explicit ctulimit(const GObservations& obs);
56  ctulimit(int argc, char *argv[]);
57  ctulimit(const ctulimit& app);
58  virtual ~ctulimit(void);
59 
60  // Operators
61  ctulimit& operator=(const ctulimit& app);
62 
63  // Methods
64  void clear(void);
65  void process(void);
66  void save(void);
67  const double& diff_ulimit(void) const;
68  const double& flux_ulimit(void) const;
69  const double& eflux_ulimit(void) const;
70 
71 protected:
72  // Protected methods
73  void init_members(void);
74  void copy_members(const ctulimit& app);
75  void free_members(void);
76  void get_parameters(void);
77  void get_model_parameter(void);
78  void get_parameter_brackets(double& parmin, double& parmax);
79  void ulimit_bisection(const double& parmin, const double& parmax);
80  void compute_ulimit(void);
81 
82  // User parameters
83  std::string m_srcname; //!< Name of source for upper limit computation
84  std::string m_parname; //!< Name of parameter for upper limit computation
85  double m_confidence; //!< Confidence level
86  double m_sigma_min; //!< Starting value minimum (multiple fit errors above fit values)
87  double m_sigma_max; //!< Starting value maximum (multiple fit errors above fit values)
88  double m_eref; //!< Reference energy for flux limits (TeV)
89  double m_emin; //!< Minimum energy for flux limits (TeV)
90  double m_emax; //!< Maximum energy for flux limits (TeV)
91  double m_tol; //!< Tolerance for limit determination
92  int m_max_iter; //!< Maximum number of iterations
93  bool m_apply_edisp; //!< Apply energy dispersion?
94  GChatter m_chatter; //!< Chattiness
95 
96  // Protected members
97  double m_dlogL; //!< Likelihood difference for upper limit computation
98  double m_best_logL; //!< Best fit log likelihood of given model
99  double m_best_value; //!< Best parameter value factor
100  double m_best_error; //!< Best parameter value error
101  double m_diff_ulimit; //!< Differential upper limit value
102  double m_flux_ulimit; //!< Flux upper limit value
103  double m_eflux_ulimit; //!< Energy flux upper limits
104  GModelSky* m_skymodel; //!< Pointer to sky model
105  GModelPar* m_model_par; //!< Pointer to model parameter
106  bool m_is_spatial; //!< Signal that model parameter is spatial parameter
107 };
108 
109 
110 /***********************************************************************//**
111  * @brief Return differential upper limit
112  *
113  * @return Differential upper flux limit.
114  ***************************************************************************/
115 inline
116 const double& ctulimit::diff_ulimit(void) const
117 {
118  return m_diff_ulimit;
119 }
120 
121 
122 /***********************************************************************//**
123  * @brief Return flux upper limit
124  *
125  * @return Upper flux limit.
126  ***************************************************************************/
127 inline
128 const double& ctulimit::flux_ulimit(void) const
129 {
130  return m_flux_ulimit;
131 }
132 
133 
134 /***********************************************************************//**
135  * @brief return energy flux upper limit
136  *
137  * @return Upper energy flux limit.
138  ***************************************************************************/
139 inline
140 const double& ctulimit::eflux_ulimit(void) const
141 {
142  return m_eflux_ulimit;
143 }
144 
145 #endif /* CTULIMIT_HPP */
const double & flux_ulimit(void) const
Return flux upper limit.
Definition: ctulimit.hpp:128
ctulimit(void)
Void constructor.
Definition: ctulimit.cpp:58
GChatter m_chatter
Chattiness.
Definition: ctulimit.hpp:94
void get_model_parameter(void)
Get model parameter.
Definition: ctulimit.cpp:510
const GObservations & obs(void) const
Return observation container.
double m_dlogL
Likelihood difference for upper limit computation.
Definition: ctulimit.hpp:97
double m_diff_ulimit
Differential upper limit value.
Definition: ctulimit.hpp:101
Upper limit calculation tool.
Definition: ctulimit.hpp:50
void copy_members(const ctulimit &app)
Copy class members.
Definition: ctulimit.cpp:398
virtual ~ctulimit(void)
Destructor.
Definition: ctulimit.cpp:133
Likelihood tool base class interface definition.
double m_emax
Maximum energy for flux limits (TeV)
Definition: ctulimit.hpp:90
void free_members(void)
Delete class members.
Definition: ctulimit.cpp:434
double m_sigma_max
Starting value maximum (multiple fit errors above fit values)
Definition: ctulimit.hpp:87
double m_sigma_min
Starting value minimum (multiple fit errors above fit values)
Definition: ctulimit.hpp:86
GModelSky * m_skymodel
Pointer to sky model.
Definition: ctulimit.hpp:104
const double & diff_ulimit(void) const
Return differential upper limit.
Definition: ctulimit.hpp:116
std::string m_parname
Name of parameter for upper limit computation.
Definition: ctulimit.hpp:84
ctulimit & operator=(const ctulimit &app)
Assignment operator.
Definition: ctulimit.cpp:157
bool m_is_spatial
Signal that model parameter is spatial parameter.
Definition: ctulimit.hpp:106
void clear(void)
Clear ctulimit tool.
Definition: ctulimit.cpp:192
double m_eflux_ulimit
Energy flux upper limits.
Definition: ctulimit.hpp:103
GModelPar * m_model_par
Pointer to model parameter.
Definition: ctulimit.hpp:105
void get_parameter_brackets(double &parmin, double &parmax)
Determine parameter brackets.
Definition: ctulimit.cpp:620
double m_emin
Minimum energy for flux limits (TeV)
Definition: ctulimit.hpp:89
bool m_apply_edisp
Apply energy dispersion?
Definition: ctulimit.hpp:93
void get_parameters(void)
Get application parameters.
Definition: ctulimit.cpp:446
double m_confidence
Confidence level.
Definition: ctulimit.hpp:85
int m_max_iter
Maximum number of iterations.
Definition: ctulimit.hpp:92
const double & eflux_ulimit(void) const
return energy flux upper limit
Definition: ctulimit.hpp:140
void save(void)
Save upper limits.
Definition: ctulimit.cpp:344
void init_members(void)
Initialise class members.
Definition: ctulimit.cpp:360
double m_best_value
Best parameter value factor.
Definition: ctulimit.hpp:99
double m_tol
Tolerance for limit determination.
Definition: ctulimit.hpp:91
void process(void)
Compute upper limit.
Definition: ctulimit.cpp:222
double m_eref
Reference energy for flux limits (TeV)
Definition: ctulimit.hpp:88
double m_best_error
Best parameter value error.
Definition: ctulimit.hpp:100
Base class for likelihood tools.
void compute_ulimit(void)
Compute upper limit intensity and fluxes.
Definition: ctulimit.cpp:834
std::string m_srcname
Name of source for upper limit computation.
Definition: ctulimit.hpp:83
double m_flux_ulimit
Flux upper limit value.
Definition: ctulimit.hpp:102
double m_best_logL
Best fit log likelihood of given model.
Definition: ctulimit.hpp:98
void ulimit_bisection(const double &parmin, const double &parmax)
Calculate upper limit using a bisection method.
Definition: ctulimit.cpp:709