GammaLib 2.0.0
Loading...
Searching...
No Matches
GCTABackgroundPerfTable.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCTABackgroundPerfTable.hpp - CTA performance table background class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2014-2020 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 GCTABackgroundPerfTable.hpp
23 * @brief CTA performance table background class definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GCTABACKGROUNDPERFTABLE_HPP
28#define GCTABACKGROUNDPERFTABLE_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include "GFilename.hpp"
33#include "GFunction.hpp"
34#include "GEnergies.hpp"
35#include "GNodeArray.hpp"
37#include "GCTABackground.hpp"
38
39/* __ Forward declarations _______________________________________________ */
40
41
42/***********************************************************************//**
43 * @class GCTABackgroundPerfTable
44 *
45 * @brief CTA performance table background class
46 ***************************************************************************/
48
49public:
50 // Constructors and destructors
54 virtual ~GCTABackgroundPerfTable(void);
55
56 // Implemented pure virtual operators
57 virtual double operator()(const double& logE,
58 const double& detx,
59 const double& dety) const;
60
61 // Operators
63
64 // Implemented pure virtual methods
65 void clear(void);
66 GCTABackgroundPerfTable* clone(void) const;
67 std::string classname(void) const;
68 void load(const GFilename& filename);
69 GFilename filename(void) const;
70 GCTAInstDir mc(const GEnergy& energy,
71 const GTime& time,
72 GRan& ran) const;
73 const GModelSpectralNodes& spectrum(void) const;
74 double rate_ebin(const GCTAInstDir& dir,
75 const GEnergy& emin,
76 const GEnergy& emax) const;
77 std::string print(const GChatter& chatter = NORMAL) const;
78
79 // Methods
80 int size(void) const;
81 void sigma(const double& sigma);
82 const double& sigma(void) const;
83
84private:
85 // Methods
86 void init_members(void);
88 void free_members(void);
89 double solidangle(void) const;
90 void init_mc_cache(void) const;
91 double rate(const double& logE) const;
92
93 // Radial integration class (used by solidangle() method). Note that
94 // the sigma parameter is given in rad^2
95 class integrand : public GFunction {
96 public:
97 integrand(const double& sigma) : m_sigma(sigma) { }
98 double eval(const double& x) {
99 double arg = x * x / m_sigma;
100 double arg2 = arg * arg;
101 double f = std::exp(-0.5 * arg2);
102 return (f*std::sin(x));
103 }
104 private:
105 double m_sigma;
106 };
107
108 // Members
109 GFilename m_filename; //!< Name of background response file
110 GEnergies m_energy; //!< Vector of energies
111 GNodeArray m_log10_energy; //!< log10(E) nodes for background interpolation
112 std::vector<double> m_background; //!< Background rate
113 std::vector<double> m_log_background; //!< log(background rate)
114 double m_sigma; //!< Sigma for offset angle computation (0=none)
115
116 // Monte Carlo cache
117 mutable GModelSpectralNodes m_mc_spectrum; //!< Background spectrum
118};
119
120
121/***********************************************************************//**
122 * @brief Return class name
123 *
124 * @return String containing the class name ("GCTABackgroundPerfTable").
125 ***************************************************************************/
126inline
128{
129 return ("GCTABackgroundPerfTable");
130}
131
132
133/***********************************************************************//**
134 * @brief Return filename
135 *
136 * @return Returns filename from which the background was loaded.
137 ***************************************************************************/
138inline
140{
141 // Return filename
142 return m_filename;
143}
144
145
146/***********************************************************************//**
147 * @brief Return number of node energies in response
148 *
149 * @return Number of node energies.
150 ***************************************************************************/
151inline
153{
154 return (m_energy.size());
155}
156
157
158/***********************************************************************//**
159 * @brief Set sigma for offset angle dependence
160 *
161 * @param[in] sigma Sigma for offset angle dependence.
162 *
163 * Sets the sigma parameter for the offset angle dependence of the effective
164 * area. If @p sigma is 0, no offset angle dependency will be assumed. By
165 * default, @p sigma = 3.
166 ***************************************************************************/
167inline
168void GCTABackgroundPerfTable::sigma(const double& sigma)
169{
170 m_sigma = sigma;
171 return;
172}
173
174
175/***********************************************************************//**
176 * @brief Return sigma for offset angle dependence
177 *
178 * @return Sigma for offset angle dependence.
179 ***************************************************************************/
180inline
181const double& GCTABackgroundPerfTable::sigma(void) const
182{
183 return (m_sigma);
184}
185
186
187/***********************************************************************//**
188 * @brief Get response cube spectrum
189 *
190 * @return Response cube spectrum.
191 *
192 * Returns the response cube spectrum.
193 ***************************************************************************/
194inline
196{
197 if (m_mc_spectrum.nodes() == 0) {
199 }
200 return (m_mc_spectrum);
201}
202
203#endif /* GCTABACKGROUNDPERFTABLE_HPP */
CTA background model base class definition.
Energy container class definition.
Filename class interface definition.
Single parameter function abstract base class definition.
Spectral nodes model class definition.
Node array class interface definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
CTA performance table background class.
double rate_ebin(const GCTAInstDir &dir, const GEnergy &emin, const GEnergy &emax) const
Returns background rate integrated over energy interval in units of events s sr .
double rate(const double &logE) const
Return background rate for a given energy (events/s/MeV/sr)
void copy_members(const GCTABackgroundPerfTable &bgd)
Copy class members.
GModelSpectralNodes m_mc_spectrum
Background spectrum.
void load(const GFilename &filename)
Load background from performance table.
std::vector< double > m_log_background
log(background rate)
GFilename filename(void) const
Return filename.
std::string classname(void) const
Return class name.
std::string print(const GChatter &chatter=NORMAL) const
Print background information.
void init_members(void)
Initialise class members.
virtual double operator()(const double &logE, const double &detx, const double &dety) const
Return background rate in units of events MeV s sr .
GCTABackgroundPerfTable & operator=(const GCTABackgroundPerfTable &bgd)
Assignment operator.
virtual ~GCTABackgroundPerfTable(void)
Destructor.
double m_sigma
Sigma for offset angle computation (0=none)
std::vector< double > m_background
Background rate.
GEnergies m_energy
Vector of energies.
void init_mc_cache(void) const
Initialise Monte Carlo cache.
GCTABackgroundPerfTable * clone(void) const
Clone background.
const GModelSpectralNodes & spectrum(void) const
Get response cube spectrum.
GCTABackgroundPerfTable(void)
Void constructor.
void clear(void)
Clear background.
GNodeArray m_log10_energy
log10(E) nodes for background interpolation
int size(void) const
Return number of node energies in response.
void free_members(void)
Delete class members.
GCTAInstDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC instrument direction.
double solidangle(void) const
Returns integral over radial model (in steradians)
const double & sigma(void) const
Return sigma for offset angle dependence.
GFilename m_filename
Name of background response file.
Abstract base class for the CTA background model.
CTA instrument direction class.
Energy container class.
Definition GEnergies.hpp:60
int size(void) const
Return number of energies in container.
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Filename class.
Definition GFilename.hpp:62
Single parameter function abstract base class.
Definition GFunction.hpp:44
Spectral nodes model class.
int nodes(void) const
Return number of nodes.
Node array class.
Random number generator class.
Definition GRan.hpp:44
Time class.
Definition GTime.hpp:55