GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCOMModelDRBFitting.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCOMModelDRBFitting.hpp - COMPTEL DRB model fitting class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2012-2016 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 GCOMModelDRBFitting.hpp
23  * @brief COMPTEL DRB model fitting class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GCOMMODELDRBFITTING_HPP
28 #define GCOMMODELDRBFITTING_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GModelData.hpp"
33 #include "GModelPar.hpp"
34 #include "GEvent.hpp"
35 #include "GObservation.hpp"
36 #include "GNodeArray.hpp"
37 #include "GXmlElement.hpp"
38 #include "GCOMEventCube.hpp"
39 
40 
41 /***********************************************************************//**
42  * @class GCOMModelDRBFitting
43  *
44  * @brief COMPTEL DRB model fitting class
45  *
46  * This class implements a COMPTEL background model that is based on fitting
47  * of a DRB model. The model parameters are a set of normalization parameters
48  * defined for a given Phibar value, and linear interpolations are performed
49  * between these values.
50  ***************************************************************************/
52 
53 public:
54  // Constructors and destructors
55  GCOMModelDRBFitting(void);
56  explicit GCOMModelDRBFitting(const GXmlElement& xml);
58  virtual ~GCOMModelDRBFitting(void);
59 
60  // Operators
61  virtual GCOMModelDRBFitting& operator=(const GCOMModelDRBFitting& model);
62 
63  // Implemented pure virtual methods
64  virtual void clear(void);
65  virtual GCOMModelDRBFitting* clone(void) const;
66  virtual std::string classname(void) const;
67  virtual std::string type(void) const;
68  virtual bool is_constant(void) const;
69  virtual double eval(const GEvent& event,
70  const GObservation& obs,
71  const bool& gradients = false) const;
72  virtual double npred(const GEnergy& obsEng, const GTime& obsTime,
73  const GObservation& obs) const;
74  virtual GCOMEventCube* mc(const GObservation& obs, GRan& ran) const;
75  virtual void read(const GXmlElement& xml);
76  virtual void write(GXmlElement& xml) const;
77  virtual std::string print(const GChatter& chatter = NORMAL) const;
78 
79 protected:
80  // Protected methods
81  void init_members(void);
82  void copy_members(const GCOMModelDRBFitting& model);
83  void free_members(void);
84  void set_pointers(void);
85  void set_cache(void) const;
86  void update_cache(void) const;
87 
88  // Proteced data members
89  std::vector<GModelPar> m_phibars; //!< Node Phibar values
90  std::vector<GModelPar> m_values; //!< Node values
91 
92  // Evaluation cache
93  mutable bool m_scale; //!< Model is a scale factor
94  mutable bool m_fixed; //!< All Phibar values are fixed
95  mutable std::vector<double> m_old_phibars; //!< Old Phibar values
96  mutable GNodeArray m_nodes; //!< Phibar node values
97 };
98 
99 
100 /***********************************************************************//**
101  * @brief Return class name
102  *
103  * @return String containing the class name ("GCOMModelDRBFitting").
104  ***************************************************************************/
105 inline
106 std::string GCOMModelDRBFitting::classname(void) const
107 {
108  return ("GCOMModelDRBFitting");
109 }
110 
111 
112 /***********************************************************************//**
113  * @brief Return model type
114  *
115  * @return Model type.
116  *
117  * Returns the type of the model. The type for a DRB fitting model is
118  * "DRBFitting".
119  ***************************************************************************/
120 inline
121 std::string GCOMModelDRBFitting::type(void) const
122 {
123  return ("DRBFitting");
124 }
125 
126 
127 /***********************************************************************//**
128  * @brief Signals if model is temporally constant
129  *
130  * @return True if model is temporally constant, false otherwise.
131  *
132  * Signals if the model is temporally constant. By definition, a DRB fitting
133  * model is always temporally constant.
134  ***************************************************************************/
135 inline
137 {
138  return (true);
139 }
140 
141 #endif /* GCOMMODELDRBFITTING_HPP */
COMPTEL DRB model fitting class.
Node array class.
Definition: GNodeArray.hpp:60
virtual void read(const GXmlElement &xml)
Read model from XML element.
XML element node class interface definition.
virtual GCOMModelDRBFitting * clone(void) const
Clone instance.
Abstract interface for the event classes.
Definition: GEvent.hpp:71
XML element node class.
Definition: GXmlElement.hpp:47
bool m_fixed
All Phibar values are fixed.
Random number generator class.
Definition: GRan.hpp:44
virtual std::string type(void) const
Return model type.
Time class.
Definition: GTime.hpp:54
virtual GCOMModelDRBFitting & operator=(const GCOMModelDRBFitting &model)
Assignment operator.
virtual bool is_constant(void) const
Signals if model is temporally constant.
virtual void clear(void)
Clear instance.
virtual GCOMEventCube * mc(const GObservation &obs, GRan &ran) const
Return simulated list of events.
Model parameter class interface definition.
void init_members(void)
Initialise class members.
Node array class interface definition.
Abstract data model base class interface definition.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print model information.
Abstract event base class definition.
Abstract data model class.
Definition: GModelData.hpp:53
void free_members(void)
Delete class members.
GChatter
Definition: GTypemaps.hpp:33
void update_cache(void) const
Update evaluation cache.
Abstract observation base class.
COMPTEL event bin container class.
Abstract observation base class interface definition.
GCOMModelDRBFitting(void)
Void constructor.
bool m_scale
Model is a scale factor.
virtual std::string classname(void) const
Return class name.
virtual double npred(const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatially integrated data model.
std::vector< GModelPar > m_values
Node values.
virtual double eval(const GEvent &event, const GObservation &obs, const bool &gradients=false) const
Evaluate function.
std::vector< double > m_old_phibars
Old Phibar values.
virtual void write(GXmlElement &xml) const
Write model into XML element.
void set_cache(void) const
Set evaluation cache.
std::vector< GModelPar > m_phibars
Node Phibar values.
COMPTEL event bin container class interface definition.
GNodeArray m_nodes
Phibar node values.
virtual ~GCOMModelDRBFitting(void)
Destructor.
void set_pointers(void)
Set pointers.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
void copy_members(const GCOMModelDRBFitting &model)
Copy class members.