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