GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTAModelRadialAcceptance.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCTAModelRadialAcceptance.hpp - Radial acceptance model 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 GCTAModelRadialAcceptance.hpp
23  * @brief Radial acceptance model class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GCTAMODELRADIALACCEPTANCE_HPP
28 #define GCTAMODELRADIALACCEPTANCE_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include <cmath>
33 #include "GModelData.hpp"
34 #include "GModelPar.hpp"
35 #include "GModelSpectral.hpp"
36 #include "GModelTemporal.hpp"
37 #include "GEvent.hpp"
38 #include "GObservation.hpp"
39 #include "GXmlElement.hpp"
40 #include "GFunction.hpp"
41 #include "GCTAEventList.hpp"
42 #include "GCTAModelRadial.hpp"
43 
44 
45 /***********************************************************************//**
46  * @class GCTAModelRadialAcceptance
47  *
48  * @brief Radial acceptance model class
49  *
50  * This class implements a radial acceptance model for CTA.
51  ***************************************************************************/
53 
54 public:
55  // Constructors and destructors
57  explicit GCTAModelRadialAcceptance(const GXmlElement& xml);
59  const GModelSpectral& spectral);
61  const GModelSpectral& spectral,
62  const GModelTemporal& temporal);
64  virtual ~GCTAModelRadialAcceptance(void);
65 
66  // Operators
68 
69  // Implemented pure virtual methods
70  virtual void clear(void);
71  virtual GCTAModelRadialAcceptance* clone(void) const;
72  virtual std::string classname(void) const;
73  virtual std::string type(void) const;
74  virtual bool is_constant(void) const;
75  virtual double eval(const GEvent& event,
76  const GObservation& obs,
77  const bool& gradients = false) const;
78  virtual double npred(const GEnergy& obsEng, const GTime& obsTime,
79  const GObservation& obs) const;
80  virtual GCTAEventList* mc(const GObservation& obs, GRan& ran) const;
81  virtual void read(const GXmlElement& xml);
82  virtual void write(GXmlElement& xml) const;
83  virtual std::string print(const GChatter& chatter = NORMAL) const;
84 
85  // Other methods
86  GCTAModelRadial* radial(void) const;
87  GModelSpectral* spectral(void) const;
88  GModelTemporal* temporal(void) const;
89  void radial(const GCTAModelRadial* radial);
90  void spectral(const GModelSpectral* spectral);
91  void temporal(const GModelTemporal* temporal);
92 
93 protected:
94  // Protected methods
95  void init_members(void);
96  void copy_members(const GCTAModelRadialAcceptance& model);
97  void free_members(void);
98  void set_pointers(void);
99  bool valid_model(void) const;
100  GCTAModelRadial* xml_radial(const GXmlElement& radial) const;
101  GModelSpectral* xml_spectral(const GXmlElement& spectral) const;
102  GModelTemporal* xml_temporal(const GXmlElement& temporal) const;
103 
104  // ROI integration kernel
105  class roi_kern : public GFunction {
106  public:
107  roi_kern(const GCTAModelRadial* parent, const double& roi, const double& dist) :
108  m_parent(parent),
109  m_roi(roi),
110  m_cosroi(std::cos(roi)),
111  m_dist(dist),
112  m_cosdist(std::cos(dist)),
113  m_sindist(std::sin(dist)) { }
114  double eval(const double& r);
115  protected:
116  const GCTAModelRadial* m_parent; //!< Pointer to radial model
117  double m_roi; //!< ROI radius in radians
118  double m_cosroi; //!< Cosine of ROI radius
119  double m_dist; //!< Distance between pointing and ROI centre in radians
120  double m_cosdist; //!< Cosine of distance
121  double m_sindist; //!< Sinus of distance
122  };
123 
124  // Proteced data members
125  GCTAModelRadial* m_radial; //!< Radial model
126  GModelSpectral* m_spectral; //!< Spectral model
127  GModelTemporal* m_temporal; //!< Temporal model
128 };
129 
130 
131 /***********************************************************************//**
132  * @brief Return class name
133  *
134  * @return String containing the class name ("GCTAModelRadialAcceptance").
135  ***************************************************************************/
136 inline
138 {
139  return ("GCTAModelRadialAcceptance");
140 }
141 
142 
143 /***********************************************************************//**
144  * @brief Return model type
145  *
146  * @return Model type.
147  *
148  * Returns the type of the model. The type for a radial acceptance model is
149  * "RadialAcceptance".
150  ***************************************************************************/
151 inline
152 std::string GCTAModelRadialAcceptance::type(void) const
153 {
154  return ("RadialAcceptance");
155 }
156 
157 
158 /***********************************************************************//**
159  * @brief Signals if model is temporally constant
160  *
161  * @return True if model is temporally constant, false otherwise.
162  *
163  * Signals if the model is temporally constant. A temporally constant model
164  * is a model that has a temporal component of type "Constant".
165  ***************************************************************************/
166 inline
168 {
169  return (m_temporal != NULL && m_temporal->type() == "Constant");
170 }
171 
172 
173 /***********************************************************************//**
174  * @brief Return radial model component
175  *
176  * @return Pointer to radial model component.
177  *
178  * Returns a pointer to the radial model component of the model. The pointer
179  * is of type GCTAModelRadial. Note that a NULL pointer may be returned if
180  * the model has no radial model component.
181  ***************************************************************************/
182 inline
184 {
185  return (m_radial);
186 }
187 
188 
189 /***********************************************************************//**
190  * @brief Return spectral model component
191  *
192  * @return Pointer to spectral model component.
193  *
194  * Returns a pointer to the spectral model component of the model. The
195  * pointer is of type GModelSpectral. Note that a NULL pointer may be
196  * returned if the model has no spectral model component.
197  ***************************************************************************/
198 inline
200 {
201  return (m_spectral);
202 }
203 
204 
205 /***********************************************************************//**
206  * @brief Return temporal model component
207  *
208  * @return Pointer to temporal model component.
209  *
210  * Returns a pointer to the temporal model component of the model. The
211  * pointer is of type GModelTemporal. Note that a NULL pointer may be
212  * returned if the model has no temporal model component.
213  ***************************************************************************/
214 inline
216 {
217  return (m_temporal);
218 }
219 
220 #endif /* GCTAMODELRADIALACCEPTANCE_HPP */
CTA event list class interface definition.
void set_pointers(void)
Set pointers.
Abstract spectral model base class.
XML element node class interface definition.
Abstract temporal model base class.
void free_members(void)
Delete class members.
GVector cos(const GVector &vector)
Computes cosine of vector elements.
Definition: GVector.cpp:1190
virtual GCTAModelRadialAcceptance * clone(void) const
Clone instance.
Abstract interface for the event classes.
Definition: GEvent.hpp:71
CTA event list class.
XML element node class.
Definition: GXmlElement.hpp:48
GModelTemporal * m_temporal
Temporal model.
const GCTAModelRadial * m_parent
Pointer to radial model.
GCTAModelRadial * radial(void) const
Return radial model component.
Random number generator class.
Definition: GRan.hpp:44
virtual GCTAEventList * mc(const GObservation &obs, GRan &ran) const
Return simulated list of events.
double eval(const double &r)
Integration kernel for the Npred method.
Time class.
Definition: GTime.hpp:55
virtual double eval(const GEvent &event, const GObservation &obs, const bool &gradients=false) const
Return background rate in units of events MeV s sr .
Model parameter class interface definition.
double m_dist
Distance between pointing and ROI centre in radians.
Abstract temporal model base class interface definition.
GModelSpectral * spectral(void) const
Return spectral model component.
GModelTemporal * temporal(void) const
Return temporal model component.
Single parameter function abstract base class definition.
GCTAModelRadial * m_radial
Radial model.
virtual void write(GXmlElement &xml) const
Write model into XML element.
Abstract data model base class interface definition.
Abstract radial acceptance model class interface definition.
void copy_members(const GCTAModelRadialAcceptance &model)
Copy class members.
Abstract event base class definition.
Abstract data model class.
Definition: GModelData.hpp:55
GModelTemporal * xml_temporal(const GXmlElement &temporal) const
Return pointer to temporal model from XML element.
GChatter
Definition: GTypemaps.hpp:33
virtual std::string classname(void) const
Return class name.
Abstract observation base class.
GModelSpectral * m_spectral
Spectral model.
Abstract observation base class interface definition.
Abstract spectral model base class interface definition.
GCTAModelRadial * xml_radial(const GXmlElement &radial) const
Construct radial model from XML element.
virtual std::string type(void) const =0
void init_members(void)
Initialise class members.
virtual ~GCTAModelRadialAcceptance(void)
Destructor.
roi_kern(const GCTAModelRadial *parent, const double &roi, const double &dist)
Single parameter function abstract base class.
Definition: GFunction.hpp:44
GVector sin(const GVector &vector)
Computes sine of vector elements.
Definition: GVector.cpp:1316
virtual std::string print(const GChatter &chatter=NORMAL) const
Print model information.
Radial acceptance model class.
virtual GCTAModelRadialAcceptance & operator=(const GCTAModelRadialAcceptance &model)
Assignment operator.
virtual void read(const GXmlElement &xml)
Read model from XML element.
Abstract radial acceptance model class.
virtual bool is_constant(void) const
Signals if model is temporally constant.
virtual void clear(void)
Clear instance.
virtual double npred(const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatially integrated background rate in units of events MeV s .
GCTAModelRadialAcceptance(void)
Void constructor.
bool valid_model(void) const
Verifies if model has all components.
virtual std::string type(void) const
Return model type.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
GModelSpectral * xml_spectral(const GXmlElement &spectral) const
Return pointer to spectral model from XML element.