GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCOMModelDRBFitting.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCOMModelDRBFitting.cpp - COMPTEL DRB model fitting class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2012-2019 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.cpp
23  * @brief COMPTEL DRB model fitting class implementation
24  * @author Juergen Knoedlseder
25  */
26 
27 /* __ Includes ___________________________________________________________ */
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 #include <typeinfo>
32 #include "GException.hpp"
33 #include "GTools.hpp"
34 #include "GModelRegistry.hpp"
35 #include "GCOMModelDRBFitting.hpp"
36 #include "GCOMObservation.hpp"
37 #include "GCOMEventBin.hpp"
38 
39 /* __ Constants __________________________________________________________ */
40 
41 /* __ Globals ____________________________________________________________ */
43 const GModelRegistry g_com_drb_fitting_registry(&g_com_drb_fitting_seed);
44 
45 /* __ Method name definitions ____________________________________________ */
46 #define G_EVAL "GCOMModelDRBFitting::eval(GEvent&, GObservation&, bool&)"
47 #define G_READ "GCOMModelDRBFitting::read(GXmlElement&)"
48 #define G_WRITE "GCOMModelDRBFitting::write(GXmlElement&)"
49 
50 /* __ Macros _____________________________________________________________ */
51 
52 /* __ Coding definitions _________________________________________________ */
53 
54 /* __ Debug definitions __________________________________________________ */
55 //#define G_DUMP_MC //!< Dump MC information
56 
57 
58 /*==========================================================================
59  = =
60  = Constructors/destructors =
61  = =
62  ==========================================================================*/
63 
64 /***********************************************************************//**
65  * @brief Void constructor
66  *
67  * Constructs an empty COMPTEL DRB fitting model.
68  ***************************************************************************/
70 {
71  // Initialise members
72  init_members();
73 
74  // Return
75  return;
76 }
77 
78 
79 /***********************************************************************//**
80  * @brief XML constructor
81  *
82  * @param[in] xml XML element.
83  *
84  * Constructs a COMPTEL DRB fitting model from the information that is found
85  * in an XML element. Please refer to the method GCOMModelDRBFitting::read
86  * to learn more about the information that is expected in the XML element.
87  ***************************************************************************/
89  GModelData(xml)
90 {
91  // Initialise members
92  init_members();
93 
94  // Read XML
95  read(xml);
96 
97  // Return
98  return;
99 }
100 
101 
102 /***********************************************************************//**
103  * @brief Copy constructor
104  *
105  * @param[in] model COMPTEL DRB fitting model.
106  *
107  * Constructs a COMPTEL DRB fitting model by copying information from an
108  * existing model. Note that the copy is a deep copy, so the original object
109  * can be destroyed after the copy without any loss of information.
110  ***************************************************************************/
112  GModelData(model)
113 {
114  // Initialise private members for clean destruction
115  init_members();
116 
117  // Copy members
118  copy_members(model);
119 
120  // Return
121  return;
122 }
123 
124 
125 /***********************************************************************//**
126  * @brief Destructor
127  *
128  * Destroys a COMPTEL DRB fitting model.
129  ***************************************************************************/
131 {
132  // Free members
133  free_members();
134 
135  // Return
136  return;
137 }
138 
139 
140 /*==========================================================================
141  = =
142  = Operators =
143  = =
144  ==========================================================================*/
145 
146 /***********************************************************************//**
147  * @brief Assignment operator
148  *
149  * @param[in] model COMPTEL DRB fitting model.
150  * @return COMPTEL DRB fitting model
151  *
152  * Assigns the information from a COMPTEL DRB fitting model to the actual
153  * object. Note that a deep copy of the information is performed, so the
154  * original object can be destroyed after the assignment without any loss of
155  * information.
156  ***************************************************************************/
158 {
159  // Execute only if object is not identical
160  if (this != &model) {
161 
162  // Copy base class members
163  this->GModelData::operator=(model);
164 
165  // Free members
166  free_members();
167 
168  // Initialise members
169  init_members();
170 
171  // Copy members
172  copy_members(model);
173 
174  } // endif: object was not identical
175 
176  // Return
177  return *this;
178 }
179 
180 
181 /*==========================================================================
182  = =
183  = Public methods =
184  = =
185  ==========================================================================*/
186 
187 /***********************************************************************//**
188  * @brief Clear instance
189  *
190  * Resets the object to a clean initial state. All information that resided
191  * in the object will be lost.
192  ***************************************************************************/
194 {
195  // Free class members (base and derived classes, derived class first)
196  free_members();
197  this->GModelData::free_members();
198  this->GModel::free_members();
199 
200  // Initialise members
201  this->GModel::init_members();
202  this->GModelData::init_members();
203  init_members();
204 
205  // Return
206  return;
207 }
208 
209 
210 /***********************************************************************//**
211  * @brief Clone instance
212  *
213  * @return Pointer to deep copy of COMPTEL DRB fitting model.
214  *
215  * Clone a COMPTEL DRB fitting model. Cloning performs a deep copy of the
216  * information, so the original object can be destroyed after cloning without
217  * any loss of information.
218  ***************************************************************************/
220 {
221  return new GCOMModelDRBFitting(*this);
222 }
223 
224 
225 /***********************************************************************//**
226  * @brief Evaluate function
227  *
228  * @param[in] event Observed event.
229  * @param[in] obs Observation.
230  * @param[in] gradients Compute gradients?
231  * @return Background model value.
232  *
233  * @exception GException::invalid_argument
234  * Observation is not a COMPTEL observation.
235  * Event is not a COMPTEL event bin.
236  *
237  * Evaluates the COMPTEL DRB fitting model.
238  ***************************************************************************/
239 double GCOMModelDRBFitting::eval(const GEvent& event,
240  const GObservation& obs,
241  const bool& gradients) const
242 {
243  // Extract COMPTEL observation
244  const GCOMObservation* observation = dynamic_cast<const GCOMObservation*>(&obs);
245  if (observation == NULL) {
246  std::string cls = std::string(typeid(&obs).name());
247  std::string msg = "Observation of type \""+cls+"\" is not a COMPTEL "
248  "observations. Please specify a COMPTEL observation "
249  "as argument.";
251  }
252 
253  // Extract COMPTEL event bin
254  const GCOMEventBin* bin = dynamic_cast<const GCOMEventBin*>(&event);
255  if (bin == NULL) {
256  std::string cls = std::string(typeid(&event).name());
257  std::string msg = "Event of type \""+cls+"\" is not a COMPTEL event. "
258  "Please specify a COMPTEL event as argument.";
260  }
261 
262  // Initialise value
263  double value = 0.0;
264 
265  // Optionally initialise gradients
266  if (gradients) {
267  for (int i = 0; i < m_values.size(); ++i) {
268  m_values[i].factor_gradient(0.0);
269  }
270  }
271 
272  // Get bin index
273  int index = bin->index();
274 
275  // Get bin size.
276  double size = bin->size();
277 
278  // Continue only if bin size is positive
279  if (size > 0.0) {
280 
281  // Initialise scaling factor
282  double scale = 1.0;
283 
284  // Get DRB model value
285  value = observation->drb().pixels()[index] / size;
286 
287  // If the model has a single scaling factor then use the first
288  // parameter as scaling factor of the model
289  if (m_scale) {
290 
291  // Get scale factor
292  scale = m_values[0].value();
293 
294  // Optionally compute gradients
295  if (gradients) {
296 
297  // Compute partial derivative
298  double grad = (m_values[0].is_free())
299  ? value * m_values[0].scale() : 0.0;
300 
301  // Set gradient
302  m_values[0].factor_gradient(grad);
303 
304  } // endif: gradient computation was requested
305 
306  } // endif: model is a scaling factor
307 
308  // ... otherwise perform a linear interpolation
309  else {
310 
311  // Get Phibar value
312  double phibar = bin->dir().phibar();
313 
314  // Update evaluation cache
315  update_cache();
316 
317  // Set node array for linear interpolation
318  m_nodes.set_value(phibar);
319 
320  // Get indices and weights for interpolation
321  int inx_left = m_nodes.inx_left();
322  int inx_right = m_nodes.inx_right();
323  double wgt_left = m_nodes.wgt_left();
324  double wgt_right = m_nodes.wgt_right();
325 
326  // Get scale factor
327  scale = m_values[inx_left].value() * wgt_left +
328  m_values[inx_right].value() * wgt_right;
329 
330  // Optionally compute gradients
331  if (gradients) {
332 
333  // Compute partial derivatives
334  double g_left = (m_values[inx_left].is_free())
335  ? wgt_left * value * m_values[inx_left].scale()
336  : 0.0;
337  double g_right = (m_values[inx_right].is_free())
338  ? wgt_right * value * m_values[inx_right].scale()
339  : 0.0;
340 
341  // Set gradients
342  m_values[inx_left].factor_gradient(g_left);
343  m_values[inx_right].factor_gradient(g_right);
344 
345  } // endif: gradient computation was requested
346 
347  } // endelse: performed linear interpolation
348 
349  // Compute background value
350  value *= scale;
351 
352  // Compile option: Check for NaN/Inf
353  #if defined(G_NAN_CHECK)
354  if (gammalib::is_notanumber(value) || gammalib::is_infinite(value)) {
355  std::cout << "*** ERROR: GCOMModelDRBFitting::eval";
356  std::cout << "(index=" << index << "):";
357  std::cout << " NaN/Inf encountered";
358  std::cout << " (value=" << value;
359  std::cout << ", scale=" << scale;
360  std::cout << ")" << std::endl;
361  }
362  #endif
363 
364  } // endif: binsize was positive
365 
366  // Return
367  return value;
368 }
369 
370 
371 /***********************************************************************//**
372  * @brief Return spatially integrated data model
373  *
374  * @param[in] obsEng Measured event energy.
375  * @param[in] obsTime Measured event time.
376  * @param[in] obs Observation.
377  *
378  * Spatially integrates the data model for a given measured event energy and
379  * event time.
380  *
381  * @todo Implement method.
382  ***************************************************************************/
383 double GCOMModelDRBFitting::npred(const GEnergy& obsEng,
384  const GTime& obsTime,
385  const GObservation& obs) const
386 {
387  // Initialise result
388  double npred = 0.0;
389 
390  // Return
391  return npred;
392 }
393 
394 
395 /***********************************************************************//**
396  * @brief Return simulated list of events
397  *
398  * @param[in] obs Observation.
399  * @param[in] ran Random number generator.
400  *
401  * Draws a sample of events from the COMPTEL DRB fitting model using a Monte
402  * Carlo simulation.
403  *
404  * @todo Implement method.
405  ***************************************************************************/
407  GRan& ran) const
408 {
409  // Initialise new event cube
410  GCOMEventCube* cube = new GCOMEventCube;
411 
412  // Return
413  return cube;
414 }
415 
416 
417 /***********************************************************************//**
418  * @brief Read model from XML element
419  *
420  * @param[in] xml XML element.
421  *
422  * @exception GException::invalid_value
423  * Model definition requires at least one node.
424  *
425  * Read the COMPTEL DRB fitting model from an XML element.
426  *
427  * The model is composed of nodes that define the normalization value as
428  * function of Phibar value. The following XML file syntax is expected:
429  *
430  * <source name="Background" type="DRBFitting" instrument="COM">
431  * <node>
432  * <parameter name="Phibar" .../>
433  * <parameter name="Normalization" .../>
434  * </node>
435  * ...
436  * <node>
437  * <parameter name="Phibar" .../>
438  * <parameter name="Normalization" .../>
439  * </node>
440  * </source>
441  ***************************************************************************/
443 {
444  // Free space for nodes
445  m_phibars.clear();
446  m_values.clear();
447 
448  // Get number of nodes from XML file
449  int nodes = xml.elements("node");
450 
451  // Throw an error if there are no nodes
452  if (nodes < 1) {
453  std::string msg = "DRB fitting model requires at least one Phibar "
454  "node. Please correct XML format.";
455  throw GException::invalid_value(G_READ, msg);
456  }
457 
458  // Loop over all nodes
459  for (int i = 0; i < nodes; ++i) {
460 
461  // Allocate node parameters
462  GModelPar phibar;
463  GModelPar normalization;
464 
465  // Get node
466  const GXmlElement* node = xml.element("node", i);
467 
468  // Read Phibar parameter
469  const GXmlElement* par = gammalib::xml_get_par(G_READ, *node, "Phibar");
470  phibar.read(*par);
471 
472  // Read Normalization parameter
473  par = gammalib::xml_get_par(G_READ, *node, "Normalization");
474  normalization.read(*par);
475 
476  // Set parameter names
477  std::string phibar_name = "Phibar layer "+gammalib::str(i);
478  std::string normalization_name = "Scale factor "+gammalib::str(i);
479 
480  // Set Phibar attributes
481  phibar.name(phibar_name);
482  phibar.unit("deg");
483  phibar.has_grad(false);
484 
485  // Set normalization attributes
486  normalization.name(normalization_name);
487  normalization.unit("");
488  normalization.has_grad(true);
489 
490  // Push node parameters on list
491  m_phibars.push_back(phibar);
492  m_values.push_back(normalization);
493 
494  } // endfor: looped over nodes
495 
496  // Read model attributes
497  read_attributes(xml);
498 
499  // Set pointers
500  set_pointers();
501 
502  // Set evluation cache
503  set_cache();
504 
505  // Return
506  return;
507 }
508 
509 
510 /***********************************************************************//**
511  * @brief Write model into XML element
512  *
513  * @param[in] xml XML element.
514  *
515  * @exception GException::model_invalid_spectral
516  * Existing XML element is not of required type
517  * @exception GException::model_invalid_parnum
518  * Invalid number of model parameters or nodes found in XML element.
519  * @exception GException::model_invalid_parnames
520  * Invalid model parameter names found in XML element.
521  *
522  * Write the COMPTEL DRB fitting model into an XML element.
523  *
524  * The model is composed of nodes that define the normalization value as
525  * function of Phibar value. The following XML file syntax is expected:
526  *
527  * <source name="Background" type="DRBFitting" instrument="COM">
528  * <node>
529  * <parameter name="Phibar" .../>
530  * <parameter name="Normalization" .../>
531  * </node>
532  * ...
533  * <node>
534  * <parameter name="Phibar" .../>
535  * <parameter name="Normalization" .../>
536  * </node>
537  * </source>
538  ***************************************************************************/
540 {
541  // Initialise pointer on source
542  GXmlElement* src = NULL;
543 
544  // Search corresponding source
545  int n = xml.elements("source");
546  for (int k = 0; k < n; ++k) {
547  GXmlElement* element = xml.element("source", k);
548  if (element->attribute("name") == name()) {
549  src = element;
550  break;
551  }
552  }
553 
554  // If no source with corresponding name was found then append one.
555  // Set also the type and the instrument.
556  if (src == NULL) {
557  src = xml.append("source");
558  src->attribute("name", name());
559  src->attribute("type", type());
560  if (instruments().length() > 0) {
561  src->attribute("instrument", instruments());
562  }
563  }
564 
565  // Verify model type
566  if (src->attribute("type") != type()) {
567  std::string msg = "Invalid model type \""+src->attribute("type")+"\" "
568  "found in XML file. Model type \""+type()+"\" "
569  "expected.";
571  }
572 
573  // Determine number of nodes
574  int nodes = m_phibars.size();
575 
576  // If XML element has 0 nodes then append nodes
577  if (src->elements() == 0) {
578  for (int i = 0; i < nodes; ++i) {
579  src->append(GXmlElement("node"));
580  }
581  }
582 
583  // Verify that XML element has the required number of nodes
584  if (src->elements() != nodes || src->elements("node") != nodes) {
585  std::string msg = "Invalid number of nodes "+
586  gammalib::str(src->elements("node"))+
587  " found in XML file, but model requires exactly "+
588  gammalib::str(nodes)+" nodes.";
590  }
591 
592  // Loop over all nodes
593  for (int i = 0; i < nodes; ++i) {
594 
595  // Get node
596  GXmlElement* node = src->element("node", i);
597 
598  // Write Phibar parameter
599  GXmlElement* par = gammalib::xml_need_par(G_WRITE, *node, "Phibar");
600  GModelPar mpar = m_phibars[i];
601  mpar.name("Phibar");
602  mpar.write(*par);
603 
604  // Write Normalization parameter
605  par = gammalib::xml_need_par(G_WRITE, *node, "Normalization");
606  mpar = m_values[i];
607  mpar.name("Normalization");
608  mpar.write(*par);
609 
610  } // endfor: looped over nodes
611 
612  // Write model attributes
613  write_attributes(*src);
614 
615  // Return
616  return;
617 }
618 
619 
620 /***********************************************************************//**
621  * @brief Print model information
622  *
623  * @param[in] chatter Chattiness (defaults to NORMAL).
624  * @return String containing model information.
625  ***************************************************************************/
626 std::string GCOMModelDRBFitting::print(const GChatter& chatter) const
627 {
628  // Initialise result string
629  std::string result;
630 
631  // Continue only if chatter is not silent
632  if (chatter != SILENT) {
633 
634  // Append header
635  result.append("=== GCOMModelDRBFitting ===");
636 
637  // Append attributes
638  result.append("\n"+print_attributes());
639 
640  // Append node summary
641  result.append("\n"+gammalib::parformat("Number of nodes"));
642  result.append(gammalib::str(m_phibars.size()));
643  result.append("\n"+gammalib::parformat("Number of parameters"));
644  result.append(gammalib::str(size()));
645  for (int i = 0; i < size(); ++i) {
646  result.append("\n"+m_pars[i]->print(chatter));
647  }
648 
649  } // endif: chatter was not silent
650 
651  // Return result
652  return result;
653 }
654 
655 
656 /*==========================================================================
657  = =
658  = Private methods =
659  = =
660  ==========================================================================*/
661 
662 /***********************************************************************//**
663  * @brief Initialise class members
664  ***************************************************************************/
666 {
667  // Initialise members
668  m_phibars.clear();
669  m_values.clear();
670 
671  // Initialise cache
672  m_scale = true;
673  m_fixed = true;
674  m_old_phibars.clear();
675  m_nodes.clear();
676 
677  // Return
678  return;
679 }
680 
681 
682 /***********************************************************************//**
683  * @brief Copy class members
684  *
685  * @param[in] model Model.
686  ***************************************************************************/
688 {
689  // Copy members
690  m_phibars = model.m_phibars;
691  m_values = model.m_values;
692 
693  // Copy cache
694  m_scale = model.m_scale;
695  m_fixed = model.m_fixed;
697  m_nodes = model.m_nodes;
698 
699  // Set parameter pointers
700  set_pointers();
701 
702  // Return
703  return;
704 }
705 
706 
707 /***********************************************************************//**
708  * @brief Delete class members
709  ***************************************************************************/
711 {
712  // Return
713  return;
714 }
715 
716 
717 /***********************************************************************//**
718  * @brief Set pointers
719  *
720  * Set pointers to all model parameters. The pointers are stored in a vector
721  * that is member of the GModel base class.
722  ***************************************************************************/
724 {
725  // Clear parameter pointer(s)
726  m_pars.clear();
727 
728  // Get number of nodes
729  int nodes = m_phibars.size();
730 
731  // Set parameter pointers for all nodes
732  for (int i = 0; i < nodes; ++i) {
733 
734  // Signal that Phibar values have no gradients
735  m_phibars[i].has_grad(false);
736 
737  // Signal that values have gradients
738  m_values[i].has_grad(true);
739 
740  // Set pointer
741  m_pars.push_back(&(m_phibars[i]));
742  m_pars.push_back(&(m_values[i]));
743 
744  } // endfor: looped over nodes
745 
746  // Return
747  return;
748 }
749 
750 
751 /***********************************************************************//**
752  * @brief Set evaluation cache
753  *
754  * Set the evaluation cache for fast computations. The evaluation cache
755  * consists of the Phibar values stored in a node array. The evaluation
756  * cache is only filled if at least 2 nodes are available. If only a single
757  * node is available, the model is considered as a simple scaling factor.
758  ***************************************************************************/
760 {
761  // Clear any existing values
762  m_old_phibars.clear();
763  m_nodes.clear();
764  m_fixed = true;
765  m_scale = true; // Signals that model is a scale factor
766 
767  // Determine number of parameters
768  int num = m_phibars.size();
769 
770  // Continue only if we have at least two nodes
771  if (num >= 2) {
772 
773  // Signal that model is not a scale factor
774  m_scale = false;
775 
776  // Set Phibar node array. Signal if one of the Phibar values is free
777  for (int i = 0; i < num; ++i) {
778  double phibar = m_phibars[i].value();
779  m_nodes.append(phibar);
780  m_old_phibars.push_back(phibar);
781  if (m_phibars[i].is_free()) {
782  m_fixed = false;
783  }
784  }
785 
786  } // endif: there were at least two nodes
787 
788  // Return
789  return;
790 }
791 
792 
793 /***********************************************************************//**
794  * @brief Update evaluation cache
795  *
796  * Updates the evaluation cache by computing the
797  * changed.
798  ***************************************************************************/
800 {
801  // Determine number of parameters
802  int num = m_phibars.size();
803 
804  // Continue only if we have at least two nodes
805  if (num >= 2) {
806 
807  // Update Phibar values
808  for (int i = 0; i < num; ++i) {
809  double phibar = m_phibars[i].value();
810  if (phibar != m_old_phibars[i]) {
811  m_nodes[i] = phibar;
812  m_old_phibars[i] = phibar;
813  }
814  }
815 
816  } // endif: there were at least two nodes
817 
818  // Return
819  return;
820 }
COMPTEL DRB model fitting class.
void phibar(const double &phibar)
Set event Compton scatter angle.
void free_members(void)
Delete class members.
Definition: GModel.cpp:656
const int & index(void) const
Return bin index.
const std::string & name(void) const
Return parameter name.
std::string print_attributes(void) const
Print model attributes.
Definition: GModel.cpp:748
virtual void read(const GXmlElement &xml)
Read model from XML element.
Interface definition for the model registry class.
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
Definition: GModelPar.cpp:353
virtual GCOMModelDRBFitting * clone(void) const
Clone instance.
COMPTEL observation class interface definition.
Abstract interface for the event classes.
Definition: GEvent.hpp:71
XML element node class.
Definition: GXmlElement.hpp:47
const double & wgt_left(void) const
Returns left node weight.
Definition: GNodeArray.hpp:260
void free_members(void)
Delete class members.
Definition: GModelData.cpp:181
bool m_fixed
All Phibar values are fixed.
void clear(void)
Clear node array.
Definition: GNodeArray.cpp:235
Random number generator class.
Definition: GRan.hpp:44
virtual std::string type(void) const
Return model type.
virtual int elements(void) const
Return number of GXMLElement children of node.
Definition: GXmlNode.cpp:580
Time class.
Definition: GTime.hpp:54
Gammalib tools definition.
void set_value(const double &value) const
Set indices and weighting factors for interpolation.
Definition: GNodeArray.cpp:580
virtual GCOMModelDRBFitting & operator=(const GCOMModelDRBFitting &model)
Assignment operator.
COMPTEL event bin class.
virtual void clear(void)
Clear instance.
virtual GCOMEventCube * mc(const GObservation &obs, GRan &ran) const
Return simulated list of events.
COMPTEL event bin class interface definition.
bool is_notanumber(const double &x)
Signal if argument is not a number.
Definition: GTools.hpp:184
std::vector< GModelPar * > m_pars
Pointers to all model parameters.
Definition: GModel.hpp:169
int size(void) const
Return number of parameters in model.
Definition: GModel.hpp:217
bool is_infinite(const double &x)
Signal if argument is infinite.
Definition: GTools.hpp:167
void init_members(void)
Initialise class members.
Definition: GModel.cpp:612
Model parameter class.
Definition: GModelPar.hpp:87
#define G_WRITE
void init_members(void)
Initialise class members.
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
const double & wgt_right(void) const
Returns right node weight.
Definition: GNodeArray.hpp:275
const GXmlAttribute * attribute(const int &index) const
Return attribute.
const std::string & name(void) const
Return parameter name.
Definition: GModel.hpp:245
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
Definition: GTools.cpp:1513
virtual std::string print(const GChatter &chatter=NORMAL) const
Print model information.
Abstract data model class.
Definition: GModelData.hpp:53
virtual GModelData & operator=(const GModelData &model)
Assignment operator.
Definition: GModelData.cpp:120
void free_members(void)
Delete class members.
std::string instruments(void) const
Returns instruments to which model applies.
Definition: GModel.cpp:304
GChatter
Definition: GTypemaps.hpp:33
void update_cache(void) const
Update evaluation cache.
const int & inx_left(void) const
Returns left node index.
Definition: GNodeArray.hpp:231
Abstract observation base class.
COMPTEL event bin container class.
GModelPar & scale(const int &index)
Returns reference to scale parameter by index.
Definition: GModel.cpp:363
GCOMModelDRBFitting(void)
Void constructor.
const int & inx_right(void) const
Returns right node index.
Definition: GNodeArray.hpp:245
void write_attributes(GXmlElement &xml) const
Write model attributes.
Definition: GModel.cpp:704
bool m_scale
Model is a scale factor.
virtual GXmlElement * element(const int &index)
Return pointer to GXMLElement child.
Definition: GXmlNode.cpp:634
COMPTEL DRB model fitting class interface definition.
#define G_EVAL
virtual const GCOMInstDir & dir(void) const
Return instrument direction of event bin.
virtual double npred(const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatially integrated data model.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
Definition: GModelPar.cpp:229
Interface class for COMPTEL observations.
const std::string & unit(void) const
Return parameter unit.
const GCOMModelDRBFitting g_com_drb_fitting_seed
Exception handler interface definition.
std::vector< GModelPar > m_values
Node values.
void read_attributes(const GXmlElement &xml)
Read model attributes.
Definition: GModel.cpp:668
virtual double eval(const GEvent &event, const GObservation &obs, const bool &gradients=false) const
Evaluate function.
const GSkyMap & drb(void) const
Return background model.
std::vector< double > m_old_phibars
Old Phibar values.
virtual void write(GXmlElement &xml) const
Write model into XML element.
Model registry class definition.
void set_cache(void) const
Set evaluation cache.
virtual GXmlNode * append(const GXmlNode &node)
Append XML child node.
Definition: GXmlNode.cpp:284
std::vector< GModelPar > m_phibars
Node Phibar values.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
Definition: GTools.cpp:1022
virtual double size(void) const
Return size of event bin.
void append(const double &node)
Append one node to array.
Definition: GNodeArray.cpp:351
GNodeArray m_nodes
Phibar node values.
virtual ~GCOMModelDRBFitting(void)
Destructor.
const GXmlElement * xml_get_par(const std::string &origin, const GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
Definition: GTools.cpp:1562
const double * pixels(void) const
Returns pointer to pixel data.
Definition: GSkyMap.hpp:426
void set_pointers(void)
Set pointers.
void init_members(void)
Initialise class members.
Definition: GModelData.cpp:159
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
void copy_members(const GCOMModelDRBFitting &model)
Copy class members.
#define G_READ
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
Definition: GTools.cpp:413