GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpectralComposite.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelSpectralComposite.cpp - Spectral composite model class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2016-2017 by Michael Mayer *
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 GModelSpectralComposite.cpp
23  * @brief Composite spectral model class implementation
24  * @author Michael Mayer
25  */
26 
27 /* __ Includes ___________________________________________________________ */
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 #include <cmath>
32 #include "GException.hpp"
33 #include "GTools.hpp"
34 #include "GRan.hpp"
37 
38 /* __ Constants __________________________________________________________ */
39 
40 /* __ Globals ____________________________________________________________ */
42 const GModelSpectralRegistry g_spectral_comp_registry(&g_spectral_comp_seed);
43 
44 /* __ Method name definitions ____________________________________________ */
45 #define G_MC "GModelSpectralComposite::mc(GEnergy&, GEnergy&, GTime&, GRan&)"
46 #define G_WRITE "GModelSpectralComposite::write(GXmlElement&)"
47 #define G_COMPONENT_INDEX "GModelSpectralComposite::component(int&)"
48 #define G_COMPONENT_NAME "GModelSpectralComposite::component(std::string&)"
49 #define G_APPEND "GModelSpectralComposite::append(GModelSpectral&, "\
50  "std::string&)"
51 
52 /* __ Macros _____________________________________________________________ */
53 
54 /* __ Coding definitions _________________________________________________ */
55 
56 /* __ Debug definitions __________________________________________________ */
57 
58 
59 /*==========================================================================
60  = =
61  = Constructors/destructors =
62  = =
63  ==========================================================================*/
64 
65 /***********************************************************************//**
66  * @brief Void constructor
67  ***************************************************************************/
69 {
70  // Initialise private members for clean destruction
71  init_members();
72 
73  // Return
74  return;
75 }
76 
77 
78 /***********************************************************************//**
79  * @brief XML constructor
80  *
81  * @param[in] xml XML element containing model information.
82  *
83  * Constructs a composite spectral model by extracting information from an
84  * XML element.
85  ***************************************************************************/
88 {
89  // Initialise members
90  init_members();
91 
92  // Read information from XML element
93  read(xml);
94 
95  // Return
96  return;
97 }
98 
99 
100 /***********************************************************************//**
101  * @brief Copy constructor
102  *
103  * @param[in] model Composite spectral model.
104  ***************************************************************************/
106  GModelSpectral(model)
107 {
108  // Initialise members
109  init_members();
110 
111  // Copy members
112  copy_members(model);
113 
114  // Return
115  return;
116 }
117 
118 
119 /***********************************************************************//**
120  * @brief Destructor
121  ***************************************************************************/
123 {
124  // Free members
125  free_members();
126 
127  // Return
128  return;
129 }
130 
131 
132 /*==========================================================================
133  = =
134  = Operators =
135  = =
136  ==========================================================================*/
137 
138 /***********************************************************************//**
139  * @brief Assignment operator
140  *
141  * @param[in] model Composite spectral model.
142  * @return Composite spectral model.
143  ***************************************************************************/
145 {
146  // Execute only if object is not identical
147  if (this != &model) {
148 
149  // Copy base class members
150  this->GModelSpectral::operator=(model);
151 
152  // Free members
153  free_members();
154 
155  // Initialise members
156  init_members();
157 
158  // Copy members
159  copy_members(model);
160 
161  } // endif: object was not identical
162 
163  // Return
164  return *this;
165 }
166 
167 
168 /*==========================================================================
169  = =
170  = Public methods =
171  = =
172  ==========================================================================*/
173 
174 /***********************************************************************//**
175  * @brief Clear composite spectral model
176  ***************************************************************************/
178 {
179  // Free class members (base and derived classes, derived class first)
180  free_members();
182 
183  // Initialise members
185  init_members();
186 
187  // Return
188  return;
189 }
190 
191 
192 /***********************************************************************//**
193  * @brief Clone composite spectral model
194  *
195  * @return Pointer to deep copy of composite spectral model.
196  ***************************************************************************/
198 {
199  // Clone spectral power law model
200  return new GModelSpectralComposite(*this);
201 }
202 
203 
204 /***********************************************************************//**
205  * @brief Evaluate function
206  *
207  * @param[in] srcEng True photon energy.
208  * @param[in] srcTime True photon arrival time.
209  * @param[in] gradients Compute gradients?
210  * @return Model value (ph/cm2/s/MeV).
211  *
212  * Evaluates
213  *
214  * \f[
215  * \sum_{i=0}^{N} {M_{\rm i}}(\rm srcEng, srcTime)
216  * \f]
217  *
218  * where \f${M_{\rm i}}\f$ is the model evaluation of the i-th model
219  *
220  * If the @p gradients flag is true the method will also compute the
221  * partial derivatives of each model component with respect to the
222  * parameters.
223  ***************************************************************************/
225  const GTime& srcTime,
226  const bool& gradients) const
227 {
228  // Initialise result
229  double value = 0.0;
230 
231  // Loop over model components
232  for (int i = 0; i < m_spectral.size(); ++i) {
233 
234  // Add model component
235  value += m_spectral[i]->eval(srcEng, srcTime, gradients);
236 
237  } // endfor: loop over model components
238 
239  // Compile option: Check for NaN/Inf
240  #if defined(G_NAN_CHECK)
241  if (gammalib::is_notanumber(value) || gammalib::is_infinite(value)) {
242  std::cout << "*** ERROR: GModelSpectralComposite::eval";
243  std::cout << "(srcEng=" << srcEng;
244  std::cout << ", srcTime=" << srcTime << "):";
245  std::cout << " NaN/Inf encountered";
246  std::cout << " (value=" << value;
247  std::cout << ")" << std::endl;
248  }
249  #endif
250 
251  // Return
252  return value;
253 }
254 
255 
256 /***********************************************************************//**
257  * @brief Returns model photon flux between [emin, emax] (units: ph/cm2/s)
258  *
259  * @param[in] emin Minimum photon energy.
260  * @param[in] emax Maximum photon energy.
261  * @return Photon flux (ph/cm2/s).
262  *
263  * Computes the sum of the photon fluxes in all components.
264  ***************************************************************************/
266  const GEnergy& emax) const
267 {
268  // Initialise flux
269  double flux = 0.0;
270 
271  // Compute only if integration range is valid
272  if (emin < emax) {
273 
274  // Loop over model components
275  for (int i = 0; i < m_spectral.size(); ++i) {
276 
277  // Add model component
278  flux += m_spectral[i]->flux(emin, emax);
279 
280  } // endfor: loop over model components
281 
282  } // endif: integration range was valid
283 
284  // Return flux
285  return flux;
286 }
287 
288 
289 /***********************************************************************//**
290  * @brief Returns model energy flux between [emin, emax] (units: erg/cm2/s)
291  *
292  * @param[in] emin Minimum photon energy.
293  * @param[in] emax Maximum photon energy.
294  * @return Energy flux (erg/cm2/s).
295  *
296  * Computes the sum of the energy fluxes in all components.
297  ***************************************************************************/
299  const GEnergy& emax) const
300 {
301  // Initialise eflux
302  double eflux = 0.0;
303 
304  // Compute only if integration range is valid
305  if (emin < emax) {
306 
307  // Loop over model components
308  for (int i = 0; i < m_spectral.size(); ++i) {
309 
310  // Add model component
311  eflux += m_spectral[i]->flux(emin, emax);
312 
313  } // endfor: loop over model components
314 
315  } // endif: integration range was valid
316 
317  // Return flux
318  return eflux;
319 }
320 
321 
322 /***********************************************************************//**
323  * @brief Returns Monte Carlo energy between [emin, emax]
324  *
325  * @param[in] emin Minimum photon energy.
326  * @param[in] emax Maximum photon energy.
327  * @param[in] time True photon arrival time.
328  * @param[in,out] ran Random number generator.
329  * @return Energy.
330  *
331  * @exception GException::erange_invalid
332  * Energy range is invalid (emin < emax required).
333  *
334  * Returns Monte Carlo energy by randomly drawing from a composite spectral
335  * model.
336  ***************************************************************************/
338  const GEnergy& emax,
339  const GTime& time,
340  GRan& ran) const
341 {
342  // Throw an exception if energy range is invalid
343  if (emin >= emax) {
344  throw GException::erange_invalid(G_MC, emin.MeV(), emax.MeV(),
345  "Minimum energy < maximum energy required.");
346  }
347 
348  // Throw exception if model container is empty
349  if (m_spectral.size() == 0) {
351  "Composite spectral model is empty. It is required to have at"\
352  " least one spectral model to run simulations");
353  }
354 
355  // Update MC cache
356  update_mc_cache(emin, emax);
357 
358  // Get random value
359  double u = ran.uniform();
360 
361  // Initialise index of model to use for simulation
362  int index = 0;
363 
364  // Loop over spectral components and compute relative probabilites
365  for (int i = 0; i < m_mc_probs.size(); ++i) {
366  if (u <= m_mc_probs[i]) {
367  index = i;
368  break;
369  }
370  }
371 
372  // Set energy
373  GEnergy energy = m_spectral[index]->mc(emin, emax, time, ran);
374 
375  // Return energy
376  return energy;
377 }
378 
379 
380 /***********************************************************************//**
381  * @brief Read model from XML element
382  *
383  * @param[in] xml XML element.
384  *
385  * Reads the spectral information from an XML element.
386  ***************************************************************************/
388 {
389  // Get number of spectral components
390  int n_spectrals = xml.elements("spectrum");
391 
392  // Loop over spectral elements
393  for (int i = 0; i < n_spectrals; ++i) {
394 
395  // Get spectral XML element
396  const GXmlElement* spec = xml.element("spectrum", i);
397 
398  // Initialise a spectral registry object
399  GModelSpectralRegistry registry;
400 
401  // Read spectral model
402  GModelSpectral* ptr = registry.alloc(*spec);
403 
404  // Get component attribute from XML file
405  std::string component_name = spec->attribute("component");
406 
407  // Append spectral component to container
408  append(*ptr, component_name);
409 
410  // Free spatial model
411  delete ptr;
412 
413  } // endfor: loop over components
414 
415  // Return
416  return;
417 }
418 
419 
420 /***********************************************************************//**
421  * @brief Write model into XML element
422  *
423  * @param[in] xml XML element.
424  *
425  * @exception GException::model_invalid_spectral
426  * Existing XML element is not of the expected type.
427  *
428  * Writes the spectral information into an XML element.
429  ***************************************************************************/
431 {
432  // Set model type
433  if (xml.attribute("type") == "") {
434  xml.attribute("type", type());
435  }
436 
437  // Verify model type
438  if (xml.attribute("type") != type()) {
440  "Spectral model is not of type \""+type()+"\".");
441  }
442 
443  // Loop over model components
444  for (int i = 0; i < m_spectral.size(); i++) {
445 
446  // Write spectral model
447  if (m_spectral[i] != NULL) {
448 
449  // Create new spectrum node
450  xml.append(GXmlElement("spectrum"));
451 
452  // Get new spectrum node
453  GXmlElement* spec = xml.element("spectrum", xml.elements("spectrum")-1);
454 
455  // Create temporary copy of the spectral model
456  // This is a kluge to write out the original parameters.
457  GModelSpectral* cpy = m_spectral[i]->clone();
458 
459  // Loop over parameters of model
460  for (int j = 0; j < cpy->size(); ++j) {
461 
462  // Get model parameter and name
463  GModelPar& par = (*cpy)[j];
464  std::string parname = par.name();
465 
466  // Check if name contains colon
467  if (gammalib::contains(parname, ":")) {
468 
469  // Split at the colon
470  std::vector<std::string> splits = gammalib::split(parname, ":");
471 
472  // Use second part of the string to recover original parameter name
473  par.name(splits[1]);
474  }
475 
476  } // endfor: loop over parameters
477 
478  // Write spectral component
479  cpy->write(*spec);
480 
481  // Add component name if previously available
482  if (m_components[i] != gammalib::str(i+1)) {
483  spec->attribute("component", m_components[i]);
484  }
485 
486  // Remove temporary copy
487  delete cpy;
488 
489  } // endif: spectral model was not NULL
490 
491  } // endfor: loop over model components
492 
493  // Return
494  return;
495 }
496 
497 
498 /***********************************************************************//**
499  * @brief Append spectral component
500  *
501  * @param[in] spec Spectral model component.
502  * @param[in] name Name of spectral component.
503  *
504  * Appends a spectral component to the composite model
505  ***************************************************************************/
507  const std::string& name)
508 {
509  // Append model container
510  m_spectral.push_back(spec.clone());
511 
512  // Get index of latest model
513  int index = m_spectral.size()-1;
514 
515  // Use model index if component name is empty
516  std::string component_name = !name.empty() ? name
517  : gammalib::str(m_spectral.size());
518 
519  // Check if component name is unique, throw exception if not
520  if (gammalib::contains(m_components, component_name)) {
521  std::string msg = "Attempt to append component \""+component_name+"\" "
522  "to composite spectral model, but a component with "
523  "the same name exists already. Each component needs "
524  "a unique name.";
526  }
527 
528  // Add component name (for now simple number)
529  m_components.push_back(component_name);
530 
531  // Get number of spectral parameters from model
532  int npars = m_spectral[index]->size();
533 
534  // Loop over model parameters
535  for (int ipar = 0; ipar < npars; ++ipar) {
536 
537  // Get model parameter
538  GModelPar* par = &(m_spectral[index]->operator[](ipar));
539 
540  // Modify parameter name
541  par->name(component_name+":"+par->name());
542 
543  // Append model parameter with new name to internal container
544  m_pars.push_back(par);
545 
546  } // endfor: loop over model parameters
547 
548  // Return
549  return;
550 }
551 
552 
553 /***********************************************************************//**
554  * @brief Returns spectral component element
555  *
556  * @param[in] index Index of spectral component.
557  * @return Spectral model.
558  *
559  * @exception GException::out_of_range
560  * Index is out of range.
561  *
562  * Returns a spectral component to the composite model
563  ***************************************************************************/
565 {
566  // Check if index is in validity range
567  if (index >= m_spectral.size() || index < 0) {
568  throw GException::out_of_range(G_COMPONENT_INDEX, "Component Index",
569  index, m_spectral.size());
570  }
571 
572  // Return spectral component
573  return m_spectral[index];
574 }
575 
576 
577 /***********************************************************************//**
578  * @brief Returns pointer to specific spectral component
579  *
580  * @param[in] name Name of spectral component.
581  * @return Spectral model.
582  *
583  * @exception GException::invalid_argument
584  * Spectral model not found.
585  *
586  * Returns a spectral component of the composite model
587  ***************************************************************************/
588 const GModelSpectral* GModelSpectralComposite::component(const std::string& name) const
589 {
590  // Check if model name is found
591  int index = -1;
592  for (int i = 0; i < m_components.size(); ++i) {
593  if (m_components[i] == name) {
594  index = i;
595  break;
596  }
597  }
598 
599  // Check if component name was found
600  if (index == -1) {
601  std::string msg = "Model component \""+name+"\" not found in composite "
602  "spectral model.";
604  }
605 
606  // Return spectral component
607  return m_spectral[index];
608 
609 }
610 
611 
612 /***********************************************************************//**
613  * @brief Print composite spectral model information
614  *
615  * @param[in] chatter Chattiness.
616  * @return String containing composite spectral model information.
617  ***************************************************************************/
618 std::string GModelSpectralComposite::print(const GChatter& chatter) const
619 {
620  // Initialise result string
621  std::string result;
622 
623  // Continue only if chatter is not silent
624  if (chatter != SILENT) {
625 
626  // Append header
627  result.append("=== GModelSpectralComposite ===");
628 
629  // Append information
630  result.append("\n"+gammalib::parformat("Number of components"));
631  result.append(gammalib::str(components()));
632  result.append("\n"+gammalib::parformat("Number of parameters"));
633  result.append(gammalib::str(size()));
634 
635  // Print parameter information
636  for (int i = 0; i < size(); ++i) {
637  result.append("\n"+m_pars[i]->print(chatter));
638  }
639 
640  } // endif: chatter was not silent
641 
642  // Return result
643  return result;
644 }
645 
646 
647 /*==========================================================================
648  = =
649  = Private methods =
650  = =
651  ==========================================================================*/
652 
653 /***********************************************************************//**
654  * @brief Initialise class members
655  ***************************************************************************/
657 {
658  // Initialise model type
659  m_type = "Composite";
660 
661  // Clear spectral models
662  m_spectral.clear();
663  m_components.clear();
664 
665  // Clear MC cache
666  m_mc_probs.clear();
667  m_mc_emin.clear();
668  m_mc_emax.clear();
669  m_mc_values.clear();
670  m_mc_flux = 0.0;
671 
672  // Return
673  return;
674 }
675 
676 
677 /***********************************************************************//**
678  * @brief Copy class members
679  *
680  * @param[in] model GModelSpectralComposite members which should be copied.
681  ***************************************************************************/
683 {
684  // Copy members
685  m_type = model.m_type;
686  m_components = model.m_components;
687 
688  // Copy MC cache
689  m_mc_probs = model.m_mc_probs;
690  m_mc_emin = model.m_mc_emin;
691  m_mc_emax = model.m_mc_emax;
692  m_mc_values = model.m_mc_values;
693  m_mc_flux = model.m_mc_flux;
694 
695  // Copy pointer(s) of spectral component
696  m_spectral.clear();
697 
698  // Clear parameters and copy the pointers from the clone
699  m_pars.clear();
700  for (int i = 0; i < model.components(); ++i) {
701 
702  // Clone spectral component
703  m_spectral.push_back(model.m_spectral[i]->clone());
704 
705  // Retrieve spectral model
706  GModelSpectral* spec = m_spectral[i];
707 
708  // Loop over parameters and store pointers
709  for (int ipar = 0; ipar < spec->size(); ++ipar) {
710 
711  // Get model parameter reference
712  GModelPar& par = spec->operator[](ipar);
713 
714  // Append model parameter pointer to internal container
715  m_pars.push_back(&par);
716 
717  } // endfor: loop over parameters
718 
719  } // endfor: loop over spectral models
720 
721  // Return
722  return;
723 }
724 
725 
726 /***********************************************************************//**
727  * @brief Delete class members
728  ***************************************************************************/
730 {
731  // Free memory
732  for (int i = 0; i < m_spectral.size(); ++i) {
733 
734  // Delete component i
735  if (m_spectral[i] != NULL) {
736  delete m_spectral[i];
737  }
738 
739  // Signal free pointer
740  m_spectral[i] = NULL;
741  }
742 
743  // Return
744  return;
745 }
746 
747 
748 /***********************************************************************//**
749  * @brief Update Monte Carlo pre computation cache
750  *
751  * @param[in] emin Minimum photon energy.
752  * @param[in] emax Maximum photon energy.
753  *
754  * Updates the precomputation cache for Monte Carlo simulations.
755  ***************************************************************************/
757  const GEnergy& emax) const
758 
759 {
760  // Check if one of the parameters has changed. If the dimension of the
761  // parameter value cache differs from the number of parameters then notify
762  // a change. This will clear the cache and store the parameter values
763  // later
764  bool par_changed = (m_mc_values.size() != size());
765  if (par_changed == false) {
766  for (int i = 0; i < size(); ++i) {
767  if (m_pars[i]->value() != m_mc_values[i]) {
768  par_changed = true;
769  break;
770  }
771  }
772  }
773 
774  // Update cache if energy range or parameters have changed
775  if (par_changed || emin != m_mc_emin || emax != m_mc_emax) {
776 
777  // Store energy range
778  m_mc_emin = emin;
779  m_mc_emax = emax;
780 
781  // If parameters have changed then store the current parameter
782  // values for a comparison check for the next method call
783  if (par_changed) {
784  m_mc_values.clear();
785  for (int i = 0; i < size(); ++i) {
786  m_mc_values.push_back(m_pars[i]->value());
787  }
788  }
789 
790  // Compute MC flux
792 
793  // Initialise sum and probabilites
794  double sum = 0.0;
795  m_mc_probs.clear();
796 
797  // Loop over spectral components and compute relative probabilites
798  for (int i = 0; i < m_spectral.size(); ++i) {
799 
800  // Relative probability
801  double prob = m_spectral[i]->flux(emin, emax) / m_mc_flux;
802 
803  // Add probability
804  m_mc_probs.push_back(prob + sum);
805 
806  // Increment sum
807  sum += prob;
808 
809  } //endfor: looped over spectral components
810 
811  } // endif: emin and emax have changed
812 
813  // Return
814  return;
815 }
virtual GEnergy mc(const GEnergy &emin, const GEnergy &emax, const GTime &time, GRan &ran) const
Returns Monte Carlo energy between [emin, emax].
virtual void write(GXmlElement &xml) const =0
#define G_MC
bool contains(const std::string &str, const std::string &substring)
Checks if a substring is in a string.
Definition: GTools.cpp:1221
GModelSpectralComposite(void)
Void constructor.
#define G_COMPONENT_INDEX
std::vector< double > m_mc_probs
Probailities of individual components.
std::vector< GModelSpectral * > m_spectral
Container of spectral models.
const std::string & name(void) const
Return parameter name.
Random number generator class definition.
Abstract spectral model base class.
int size(void) const
Return number of parameters.
virtual GModelSpectral & operator=(const GModelSpectral &model)
Assignment operator.
void init_members(void)
Initialise class members.
virtual double eflux(const GEnergy &emin, const GEnergy &emax) const
Returns model energy flux between emin, emax
std::vector< GModelPar * > m_pars
Parameter pointers.
#define G_WRITE
XML element node class.
Definition: GXmlElement.hpp:47
Spectral model registry class definition.
double sum(const GVector &vector)
Computes vector sum.
Definition: GVector.cpp:901
Random number generator class.
Definition: GRan.hpp:44
std::vector< std::string > split(const std::string &s, const std::string &sep)
Split string.
Definition: GTools.cpp:862
double MeV(void) const
Return energy in MeV.
Definition: GEnergy.cpp:321
virtual int elements(void) const
Return number of GXMLElement children of node.
Definition: GXmlNode.cpp:580
Time class.
Definition: GTime.hpp:54
std::string m_type
Model type.
Gammalib tools definition.
int components(void) const
Return number of spectral components.
virtual double eval(const GEnergy &srcEng, const GTime &srcTime=GTime(), const bool &gradients=false) const
Evaluate function.
bool is_notanumber(const double &x)
Signal if argument is not a number.
Definition: GTools.hpp:184
virtual void read(const GXmlElement &xml)
Read model from XML element.
bool is_infinite(const double &x)
Signal if argument is infinite.
Definition: GTools.hpp:167
Model parameter class.
Definition: GModelPar.hpp:87
void append(const GModelSpectral &spec, const std::string &name="")
Append spectral component.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
const GModelSpectralComposite g_spectral_comp_seed
virtual void clear(void)
Clear composite spectral model.
std::vector< double > m_mc_values
Parameter values.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
Definition: GRan.cpp:242
const GModelSpectral * component(const int &index) const
Returns spectral component element.
GModelSpectral * alloc(const GXmlElement &xml) const
Allocate spectral model that is found in XML element.
GChatter
Definition: GTypemaps.hpp:33
void update_mc_cache(const GEnergy &emin, const GEnergy &emax) const
Update Monte Carlo pre computation cache.
void free_members(void)
Delete class members.
Interface definition for the spectral model registry class.
virtual GModelSpectral * clone(void) const =0
Clones object.
#define G_COMPONENT_NAME
virtual void write(GXmlElement &xml) const
Write model into XML element.
void copy_members(const GModelSpectralComposite &model)
Copy class members.
Composite spectral model class.
virtual GXmlElement * element(const int &index)
Return pointer to GXMLElement child.
Definition: GXmlNode.cpp:634
void init_members(void)
Initialise class members.
Composite spectral model class interface definition.
Exception handler interface definition.
GEnergy m_mc_emax
Last maximum energy.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print composite spectral model information.
virtual std::string type(void) const
Return model type.
virtual GXmlNode * append(const GXmlNode &node)
Append XML child node.
Definition: GXmlNode.cpp:284
virtual double flux(const GEnergy &emin, const GEnergy &emax) const
Returns model photon flux between emin, emax
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
Definition: GTools.cpp:1022
virtual GModelSpectralComposite & operator=(const GModelSpectralComposite &model)
Assignment operator.
std::vector< std::string > m_components
Names of components.
virtual GModelSpectralComposite * clone(void) const
Clone composite spectral model.
virtual ~GModelSpectralComposite(void)
Destructor.
void free_members(void)
Delete class members.
void clear(void)
Clear instance.
Definition: GEnergy.cpp:261
GEnergy m_mc_emin
Last minimum energy.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
#define G_APPEND
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
Definition: GTools.cpp:413