GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTAModelRadial.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCTAModelRadial.cpp - Abstract radial model base class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2011-2018 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 GCTAModelRadial.cpp
23  * @brief Abstract radial background model class implementation
24  * @author Juergen Knoedlseder
25  */
26 
27 /* __ Includes ___________________________________________________________ */
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 #include "GException.hpp"
32 #include "GTools.hpp"
33 #include "GCTAObservation.hpp"
34 #include "GCTAInstDir.hpp"
35 #include "GCTAModelRadial.hpp"
36 
37 /* __ Method name definitions ____________________________________________ */
38 
39 /* __ Macros _____________________________________________________________ */
40 
41 /* __ Coding definitions _________________________________________________ */
42 
43 /* __ Debug definitions __________________________________________________ */
44 
45 
46 /*==========================================================================
47  = =
48  = Constructors/destructors =
49  = =
50  ==========================================================================*/
51 
52 /***********************************************************************//**
53  * @brief Void constructor
54  ***************************************************************************/
56 {
57  // Initialise members
58  init_members();
59 
60  // Return
61  return;
62 }
63 
64 
65 /***********************************************************************//**
66  * @brief Copy constructor
67  *
68  * @param[in] model Radial background model.
69  ***************************************************************************/
71 {
72  // Initialise members
73  init_members();
74 
75  // Copy members
76  copy_members(model);
77 
78  // Return
79  return;
80 }
81 
82 
83 /***********************************************************************//**
84  * @brief Destructor
85  ***************************************************************************/
87 {
88  // Free members
89  free_members();
90 
91  // Return
92  return;
93 }
94 
95 
96 /*==========================================================================
97  = =
98  = Operators =
99  = =
100  ==========================================================================*/
101 
102 /***********************************************************************//**
103  * @brief Assignment operator
104  *
105  * @param[in] model Radial background model.
106  ***************************************************************************/
108 {
109  // Execute only if object is not identical
110  if (this != &model) {
111 
112  // Free members
113  free_members();
114 
115  // Initialise members
116  init_members();
117 
118  // Copy members
119  copy_members(model);
120 
121  } // endif: object was not identical
122 
123  // Return
124  return *this;
125 }
126 
127 
128 /*==========================================================================
129  = =
130  = Public methods =
131  = =
132  ==========================================================================*/
133 
134 /***********************************************************************//**
135  * @brief Evaluate function
136  *
137  * @param[in] dir Event direction.
138  * @param[in] energy Event energy (not used).
139  * @param[in] time Event time (not used).
140  * @param[in] gradients Compute gradients?
141  * @return Function value
142  *
143  * Evaluate radial model for a given event direction. The energy and time of
144  * the event are not used.
145  ***************************************************************************/
147  const GEnergy& energy,
148  const GTime& time,
149  const bool& gradients) const
150 {
151  // Compute offset angle in degrees
152  double offset = dir.theta() * gammalib::rad2deg;
153 
154  // Evaluate function
155  double value = eval(offset, gradients);
156 
157  // Return value
158  return value;
159 }
160 
161 
162 /***********************************************************************//**
163  * @brief Returns MC instrument direction
164  *
165  * @param[in] energy Event energy (not used).
166  * @param[in] time Event time (not used).
167  * @param[in] obs CTA observation.
168  * @param[in,out] ran Random number generator.
169  * @return Instrument direction
170  *
171  * Return random instrument direction. The method sets the sky direction and
172  * the instrument coordinates of the instrument direction.
173  *
174  * The energy and time of the event are not used.
175  ***************************************************************************/
177  const GTime& time,
178  const GCTAObservation& obs,
179  GRan& ran) const
180 {
181  // Get random instrument direction
182  GCTAInstDir dir = mc(ran);
183 
184  // Derive sky direction from instrument coordinates
185  GSkyDir skydir = obs.pointing().skydir(dir);
186 
187  // Set sky direction in GCTAInstDir object
188  dir.dir(skydir);
189 
190  // Return instrument direction
191  return dir;
192 }
193 
194 
195 /*==========================================================================
196  = =
197  = Private methods =
198  = =
199  ==========================================================================*/
200 
201 /***********************************************************************//**
202  * @brief Initialise class members
203  ***************************************************************************/
205 {
206  // Return
207  return;
208 }
209 
210 
211 /***********************************************************************//**
212  * @brief Copy class members
213  *
214  * @param[in] model Radial acceptance model.
215  ***************************************************************************/
217 {
218  // Return
219  return;
220 }
221 
222 
223 /***********************************************************************//**
224  * @brief Delete class members
225  ***************************************************************************/
227 {
228  // Return
229  return;
230 }
virtual GCTAInstDir mc(const GEnergy &energy, const GTime &time, const GCTAObservation &obs, GRan &ran) const
Returns MC instrument direction.
void free_members(void)
Delete class members.
GCTAModelRadial(void)
Void constructor.
Random number generator class.
Definition: GRan.hpp:44
void init_members(void)
Initialise class members.
Time class.
Definition: GTime.hpp:55
Gammalib tools definition.
void pointing(const GCTAPointing &pointing)
Set CTA pointing.
void dir(const GSkyDir &dir)
Set sky direction.
void copy_members(const GCTAModelRadial &model)
Copy class members.
double theta(void) const
Return offset angle (in radians)
Abstract radial acceptance model class interface definition.
CTA instrument direction class interface definition.
CTA observation class interface definition.
Exception handler interface definition.
CTA instrument direction class.
Definition: GCTAInstDir.hpp:63
Abstract radial acceptance model class.
const double rad2deg
Definition: GMath.hpp:44
CTA observation class.
Sky direction class.
Definition: GSkyDir.hpp:62
virtual GCTAModelRadial & operator=(const GCTAModelRadial &model)
Assignment operator.
virtual ~GCTAModelRadial(void)
Destructor.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
virtual double eval(const GCTAInstDir &dir, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
Evaluate function.