GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCOMModelDRBPhibarNodes.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCOMModelDRBPhibarNodes.hpp - COMPTEL DRB model fitting class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2012-2022 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 GCOMModelDRBPhibarNodes.hpp
23  * @brief COMPTEL DRB Phibar nodes model fitting class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GCOMMODELDRBPHIBARNODES_HPP
28 #define GCOMMODELDRBPHIBARNODES_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 GCOMModelDRBPhibarNodes
43  *
44  * @brief COMPTEL DRB Phibar nodes 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
56  explicit GCOMModelDRBPhibarNodes(const GXmlElement& xml);
58  virtual ~GCOMModelDRBPhibarNodes(void);
59 
60  // Operators
62 
63  // Implemented pure virtual methods
64  virtual void clear(void);
65  virtual GCOMModelDRBPhibarNodes* 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 GCOMModelDRBPhibarNodes& 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 ("GCOMModelDRBPhibarNodes").
104  ***************************************************************************/
105 inline
106 std::string GCOMModelDRBPhibarNodes::classname(void) const
107 {
108  return ("GCOMModelDRBPhibarNodes");
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  * "DRBPhibarNodes".
119  ***************************************************************************/
120 inline
121 std::string GCOMModelDRBPhibarNodes::type(void) const
122 {
123  return ("DRBPhibarNodes");
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 /* GCOMMODELDRBPHIBARNODES_HPP */
virtual std::string classname(void) const
Return class name.
bool m_scale
Model is a scale factor.
Node array class.
Definition: GNodeArray.hpp:60
virtual void write(GXmlElement &xml) const
Write model into XML element.
XML element node class interface definition.
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual double npred(const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatially integrated data model.
virtual bool is_constant(void) const
Signals if model is temporally constant.
std::vector< double > m_old_phibars
Old Phibar values.
void init_members(void)
Initialise class members.
Abstract interface for the event classes.
Definition: GEvent.hpp:71
void set_cache(void) const
Set evaluation cache.
XML element node class.
Definition: GXmlElement.hpp:48
virtual GCOMModelDRBPhibarNodes * clone(void) const
Clone instance.
Random number generator class.
Definition: GRan.hpp:44
Time class.
Definition: GTime.hpp:55
std::vector< GModelPar > m_phibars
Node Phibar values.
virtual double eval(const GEvent &event, const GObservation &obs, const bool &gradients=false) const
Evaluate function.
virtual std::string type(void) const
Return model type.
Model parameter class interface definition.
void free_members(void)
Delete class members.
virtual GCOMModelDRBPhibarNodes & operator=(const GCOMModelDRBPhibarNodes &model)
Assignment operator.
Node array class interface definition.
COMPTEL DRB Phibar nodes model fitting class.
Abstract data model base class interface definition.
Abstract event base class definition.
Abstract data model class.
Definition: GModelData.hpp:55
virtual GCOMEventCube * mc(const GObservation &obs, GRan &ran) const
Return simulated list of events.
GChatter
Definition: GTypemaps.hpp:33
virtual ~GCOMModelDRBPhibarNodes(void)
Destructor.
GNodeArray m_nodes
Phibar node values.
Abstract observation base class.
COMPTEL event bin container class.
Abstract observation base class interface definition.
void update_cache(void) const
Update evaluation cache.
std::vector< GModelPar > m_values
Node values.
void set_pointers(void)
Set pointers.
void copy_members(const GCOMModelDRBPhibarNodes &model)
Copy class members.
COMPTEL event bin container class interface definition.
bool m_fixed
All Phibar values are fixed.
GCOMModelDRBPhibarNodes(void)
Void constructor.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
virtual void clear(void)
Clear instance.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print model information.