GammaLib 2.0.0
Loading...
Searching...
No Matches
GCTAModelCubeBackground.cpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCTAModelCubeBackground.cpp - CTA cube background model class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2013-2020 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 GCTAModelCubeBackground.cpp
23 * @brief CTA cube background model class implementation
24 * @author Michael Mayer
25 */
26
27/* __ Includes ___________________________________________________________ */
28#ifdef HAVE_CONFIG_H
29#include <config.h>
30#endif
31#include "GTools.hpp"
32#include "GModelRegistry.hpp"
38#include "GCTAObservation.hpp"
39#include "GCTAResponseCube.hpp"
41#include "GCTASupport.hpp"
42
43/* __ Globals ____________________________________________________________ */
45const GModelRegistry g_cta_inst_background_registry(&g_cta_inst_background_seed);
46
47/* __ Method name definitions ____________________________________________ */
48#define G_EVAL "GCTAModelCubeBackground::eval(GEvent&, GObservation&, bool&)"
49#define G_NPRED "GCTAModelCubeBackground::npred(GEnergy&, GTime&,"\
50 " GObservation&)"
51#define G_MC "GCTAModelCubeBackground::mc(GObservation&, GRan&)"
52#define G_XML_SPECTRAL "GCTAModelCubeBackground::xml_spectral(GXmlElement&)"
53#define G_XML_TEMPORAL "GCTAModelCubeBackground::xml_temporal(GXmlElement&)"
54
55/* __ Macros _____________________________________________________________ */
56
57/* __ Coding definitions _________________________________________________ */
58#define G_USE_NPRED_CACHE
59
60/* __ Debug definitions __________________________________________________ */
61//#define G_DUMP_MC
62//#define G_DEBUG_NPRED
63
64/* __ Constants __________________________________________________________ */
65
66
67/*==========================================================================
68 = =
69 = Constructors/destructors =
70 = =
71 ==========================================================================*/
72
73/***********************************************************************//**
74 * @brief Void constructor
75 ***************************************************************************/
77{
78 // Initialise class members
80
81 // Return
82 return;
83}
84
85
86/***********************************************************************//**
87 * @brief XML constructor
88 *
89 * @param[in] xml XML element.
90 *
91 * Constructs a CTA cube background model from the information provided by
92 * an XML elements (see GCTAModelCubeBackground::read method).
93 ***************************************************************************/
95 GModelData(xml)
96{
97 // Initialise members
99
100 // Read XML
101 read(xml);
102
103 // Set parameter pointers
104 set_pointers();
105
106 // Return
107 return;
108}
109
110
111/***********************************************************************//**
112 * @brief Construct from spectral component
113 *
114 * @param[in] spectral Spectral model component.
115 *
116 * Constructs a CTA cube background model from a @p spectral model component.
117 * The temporal component is assumed to be constant.
118 ***************************************************************************/
120 GModelData()
121{
122 // Initialise members
123 init_members();
124
125 // Allocate temporal constant model
127
128 // Clone model components
131
132 // Set parameter pointers
133 set_pointers();
134
135 // Return
136 return;
137}
138
139
140/***********************************************************************//**
141 * @brief Construct from model components
142 *
143 * @param[in] spectral Spectral model component.
144 * @param[in] temporal Temporal model component.
145 *
146 * Constructs a CTA cube background model from a @p spectral and a
147 * @p temporal component.
148 ***************************************************************************/
150 const GModelTemporal& temporal) :
151 GModelData()
152{
153 // Initialise members
154 init_members();
155
156 // Clone model components
159
160 // Set parameter pointers
161 set_pointers();
162
163 // Return
164 return;
165}
166
167
168/***********************************************************************//**
169 * @brief Copy constructor
170 *
171 * @param[in] bgd CTA cube background model.
172 ***************************************************************************/
174 GModelData(bgd)
175{
176 // Initialise class members
177 init_members();
178
179 // Copy members
180 copy_members(bgd);
181
182 // Return
183 return;
184}
185
186
187/***********************************************************************//**
188 * @brief Destructor
189 ***************************************************************************/
191{
192 // Free members
193 free_members();
194
195 // Return
196 return;
197}
198
199
200/*==========================================================================
201 = =
202 = Operators =
203 = =
204 ==========================================================================*/
205
206/***********************************************************************//**
207 * @brief Assignment operator
208 *
209 * @param[in] bgd CTA cube background model.
210 * @return CTA cube background model.
211 ***************************************************************************/
213{
214 // Execute only if object is not identical
215 if (this != &bgd) {
216
217 // Copy base class members
218 this->GModelData::operator=(bgd);
219
220 // Free members
221 free_members();
222
223 // Initialise private members
224 init_members();
225
226 // Copy members
227 copy_members(bgd);
228
229 } // endif: object was not identical
230
231 // Return this object
232 return *this;
233}
234
235
236/*==========================================================================
237 = =
238 = Public methods =
239 = =
240 ==========================================================================*/
241
242/***********************************************************************//**
243 * @brief Clear CTA cube background model
244 *
245 * This method properly resets the CTA cube background model to an
246 * initial state.
247 ***************************************************************************/
249{
250 // Free class members (base and derived classes, derived class first)
251 free_members();
253
254 // Initialise members
256 init_members();
257
258 // Return
259 return;
260}
261
262
263/***********************************************************************//**
264 * @brief Clone CTA cube background model
265 *
266 * @return Pointer to deep copy of CTA cube background model.
267 ***************************************************************************/
272
273
274/***********************************************************************//**
275 * @brief Set spectral model component
276 *
277 * @param[in] spectral Pointer to spectral model component.
278 *
279 * Sets the spectral model component of the model.
280 ***************************************************************************/
282{
283 // Free spectral model component only if it differs from current
284 // component. This prevents unintential deallocation of the argument
285 if ((m_spectral != NULL) && (m_spectral != spectral)) {
286 delete m_spectral;
287 }
288
289 // Clone spectral model component if it exists, otherwise set pointer
290 // to NULL
291 m_spectral = (spectral != NULL) ? spectral->clone() : NULL;
292
293 // Set parameter pointers
294 set_pointers();
295
296 // Return
297 return;
298}
299
300
301/***********************************************************************//**
302 * @brief Set temporal model component
303 *
304 * @param[in] temporal Pointer to temporal model component.
305 *
306 * Sets the temporal model component of the model.
307 ***************************************************************************/
309{
310 // Free temporal model component only if it differs from current
311 // component. This prevents unintential deallocation of the argument
312 if ((m_temporal != NULL) && (m_temporal != temporal)) {
313 delete m_temporal;
314 }
315
316 // Clone temporal model component if it exists, otherwise set pointer
317 // to NULL
318 m_temporal = (temporal != NULL) ? temporal->clone() : NULL;
319
320 // Set parameter pointers
321 set_pointers();
322
323 // Return
324 return;
325}
326
327
328/***********************************************************************//**
329 * @brief Return background rate in units of events MeV\f$^{-1}\f$
330 * s\f$^{-1}\f$ sr\f$^{-1}\f$
331 *
332 * @param[in] event Observed event.
333 * @param[in] obs Observation.
334 * @param[in] gradients Compute gradients?
335 * @return Background rate (events MeV\f$^{-1}\f$ s\f$^{-1}\f$ sr\f$^{-1}\f$).
336 *
337 * Evaluates the background model. The method returns a real rate, defined
338 * as the number of counts per MeV, steradian and ontime.
339 *
340 * If the @p gradients flag is true the method will also set the parameter
341 * gradients of the model parameters.
342 ***************************************************************************/
344 const GObservation& obs,
345 const bool& gradients) const
346{
347 // Get reference on CTA response cube from observation and reference on
348 // CTA instrument direction from event
350 const GCTAInstDir& dir = gammalib::cta_dir(G_EVAL, event);
351
352 // Retrieve reference to CTA cube background
353 const GCTACubeBackground& bgd = rsp.background();
354
355 // Evaluate function
356 double spat = bgd(dir, event.energy());
357 double spec = (spectral() != NULL)
358 ? spectral()->eval(event.energy(), event.time(), gradients)
359 : 1.0;
360 double temp = (temporal() != NULL)
361 ? temporal()->eval(event.time(), gradients) : 1.0;
362
363 // Compute value. Note that background rates are already per
364 // livetime, hence no deadtime correction is needed here.
365 double value = spat * spec * temp;
366
367 // If gradients were requested then multiply factors to spectral and
368 // temporal gradients
369 if (gradients) {
370
371 // Multiply factors to spectral gradients
372 if (spectral() != NULL) {
373 double fact = spat * temp;
374 if (fact != 1.0) {
375 for (int i = 0; i < spectral()->size(); ++i)
376 (*spectral())[i].factor_gradient((*spectral())[i].factor_gradient() * fact);
377 }
378 }
379
380 // Multiply factors to temporal gradients
381 if (temporal() != NULL) {
382 double fact = spat * spec;
383 if (fact != 1.0) {
384 for (int i = 0; i < temporal()->size(); ++i)
385 (*temporal())[i].factor_gradient((*temporal())[i].factor_gradient() * fact);
386 }
387 }
388
389 } // endif: gradients were requested
390
391 // Return value
392 return value;
393}
394
395
396/***********************************************************************//**
397 * @brief Return spatially integrated background rate in units of
398 * events MeV\f$^{-1}\f$ s\f$^{-1}\f$
399 *
400 * @param[in] obsEng Measured event energy.
401 * @param[in] obsTime Measured event time.
402 * @param[in] obs Observation.
403 * @return Spatially integrated background rate
404 * (events MeV\f$^{-1}\f$ s\f$^{-1}\f$)
405 *
406 * Spatially integrates the cube background model for a given measured event
407 * energy and event time. The method returns a real rate,
408 * defined as the number of counts per MeV and ontime.
409 ***************************************************************************/
411 const GTime& obsTime,
412 const GObservation& obs) const
413{
414 // Initialise result
415 double npred = 0.0;
416 bool has_npred = false;
417
418 // Build unique identifier
419 std::string id = obs.instrument() + "::" + obs.id();
420
421 // Check if Npred value is already in cache
422 #if defined(G_USE_NPRED_CACHE)
423 if (!m_npred_names.empty()) {
424
425 // Search for unique identifier, and if found, recover Npred value
426 // and break
427 for (int i = 0; i < m_npred_names.size(); ++i) {
428 if (m_npred_names[i] == id && m_npred_energies[i] == obsEng) {
430 has_npred = true;
431 #if defined(G_DEBUG_NPRED)
432 std::cout << "GCTAModelCubeBackground::npred:";
433 std::cout << " cache=" << i;
434 std::cout << " npred=" << npred << std::endl;
435 #endif
436 break;
437 }
438 }
439
440 } // endif: there were values in the Npred cache
441 #endif
442
443 // Continue only if no Npred cache value has been found
444 if (!has_npred) {
445
446 // Evaluate only if model is valid
447 if (valid_model()) {
448
449 // Get reference on CTA response cube from observation
451
452 // Retrieve CTA background
453 const GCTACubeBackground& bgd = rsp.background();
454
455 // Get log10 of energy in TeV
456 double logE = obsEng.log10TeV();
457
458 // Integrate the background map at a certain energy
459 npred = bgd.integral(logE);
460
461 // Store result in Npred cache
462 #if defined(G_USE_NPRED_CACHE)
463 m_npred_names.push_back(id);
464 m_npred_energies.push_back(obsEng);
465 m_npred_times.push_back(obsTime);
466 m_npred_values.push_back(npred);
467 #endif
468
469 // Debug: Check for NaN
470 #if defined(G_NAN_CHECK)
472 std::string origin = "GCTAModelCubeBackground::npred";
473 std::string message = " NaN/Inf encountered (npred=" +
474 gammalib::str(npred) + ")";
475 gammalib::warning(origin, message);
476 }
477 #endif
478
479 } // endif: model was valid
480
481 } // endif: Npred computation required
482
483 // Multiply in spectral and temporal components
484 npred *= spectral()->eval(obsEng, obsTime);
485 npred *= temporal()->eval(obsTime);
486
487 // Return Npred
488 return npred;
489}
490
491
492/***********************************************************************//**
493 * @brief Return simulated list of events
494 *
495 * @param[in] obs Observation.
496 * @param[in] ran Random number generator.
497 * @return Pointer to list of simulated events (needs to be de-allocated by
498 * client)
499 *
500 * @exception GException::feature_not_implemented
501 * Specified observation is not a CTA observation.
502 *
503 * The simulation of an event list from a cube background model is not
504 * implemented, hence the method will always throw an exception.
505 ***************************************************************************/
507{
508 // Feature not yet implemented
510 "MC computation not implemented for binned analysis.");
511
512 // Return NULL pointer
513 return NULL;
514
515}
516
517
518/***********************************************************************//**
519 * @brief Read CTA cube background model from XML element
520 *
521 * @param[in] xml XML element.
522 *
523 * Set up CTA cube background model from the information provided by
524 * an XML element. The XML element is expected to have the following
525 * structure
526 *
527 * <source name="..." type="..." instrument="...">
528 * <spectrum type="...">
529 * ...
530 * </spectrum>
531 * </source>
532 *
533 * Optionally, a temporal model may be provided using the following
534 * syntax
535 *
536 * <source name="..." type="..." instrument="...">
537 * <spectrum type="...">
538 * ...
539 * </spectrum>
540 * <temporal type="...">
541 * ...
542 * </temporal>
543 * </source>
544 *
545 * If no temporal component is found a constant model is assumed.
546 ***************************************************************************/
548{
549 // Clear model
550 clear();
551
552 // Initialise XML elements
553 const GXmlElement* spectral = NULL;
554
555 // Get pointer on spectrum
556 spectral = xml.element("spectrum", 0);
557
558 // Extract spectral model
560
561 // Optionally get temporal model
562 if (xml.elements("temporal")) {
563 const GXmlElement* temporal = xml.element("temporal", 0);
565 }
566 else {
567 GModelTemporalConst constant;
568 m_temporal = constant.clone();
569 }
570
571 // Read model attributes
572 read_attributes(xml);
573
574 // Set parameter pointers
575 set_pointers();
576
577 // Return
578 return;
579}
580
581
582/***********************************************************************//**
583 * @brief Write CTA cube background model into XML element
584 *
585 * @param[in] xml XML element.
586 *
587 * Write CTA cube background model information into an XML element.
588 * The XML element will have the following structure
589 *
590 * <source name="..." type="..." instrument="...">
591 * <spectrum type="...">
592 * ...
593 * </spectrum>
594 * </source>
595 *
596 * If the model contains a non-constant temporal model, the temporal
597 * component will also be written following the syntax
598 *
599 * <source name="..." type="..." instrument="...">
600 * <spectrum type="...">
601 * ...
602 * </spectrum>
603 * <temporal type="...">
604 * ...
605 * </temporal>
606 * </source>
607 *
608 * If no temporal component is found a constant model is assumed.
609 ***************************************************************************/
611{
612 // Initialise pointer on source
613 GXmlElement* src = NULL;
614
615 // Search corresponding source
616 int n = xml.elements("source");
617 for (int k = 0; k < n; ++k) {
618 GXmlElement* element = xml.element("source", k);
619 if (element->attribute("name") == name()) {
620 src = element;
621 break;
622 }
623 }
624
625 // If we have a temporal model that is either not a constant, or a
626 // constant with a normalization value that differs from 1.0 then
627 // write the temporal component into the XML element. This logic
628 // assures compatibility with the Fermi/LAT format as this format
629 // does not handle temporal components.
630 bool write_temporal = ((m_temporal != NULL) &&
631 (m_temporal->type() != "Constant" ||
632 (*m_temporal)[0].value() != 1.0));
633
634 // If no source with corresponding name was found then append one
635 if (src == NULL) {
636 src = xml.append("source");
637 if (spectral() != NULL) src->append(GXmlElement("spectrum"));
638 if (write_temporal) src->append(GXmlElement("temporal"));
639 }
640
641 // Write spectral model
642 if (spectral() != NULL) {
643 GXmlElement* spec = src->element("spectrum", 0);
644 spectral()->write(*spec);
645 }
646
647 // Optionally write temporal model
648 if (write_temporal) {
649 if (dynamic_cast<GModelTemporalConst*>(temporal()) == NULL) {
650 GXmlElement* temp = src->element("temporal", 0);
651 temporal()->write(*temp);
652 }
653 }
654
655 // Write model attributes
656 write_attributes(*src);
657
658 // Return
659 return;
660}
661
662
663/***********************************************************************//**
664 * @brief Print CTA cube background model information
665 *
666 * @param[in] chatter Chattiness.
667 * @return String containing CTA cube background model information.
668 ***************************************************************************/
669std::string GCTAModelCubeBackground::print(const GChatter& chatter) const
670{
671 // Initialise result string
672 std::string result;
673
674 // Continue only if chatter is not silent
675 if (chatter != SILENT) {
676
677 // Append header
678 result.append("=== GCTAModelCubeBackground ===");
679
680 // Determine number of parameters per type
681 int n_spectral = (spectral() != NULL) ? spectral()->size() : 0;
682 int n_temporal = (temporal() != NULL) ? temporal()->size() : 0;
683
684 // Append attributes
685 result.append("\n"+print_attributes());
686
687 // Append model type
688 result.append("\n"+gammalib::parformat("Model type"));
689 if (n_spectral > 0) {
690 result.append("\""+spectral()->type()+"\"");
691 if (n_temporal > 0) {
692 result.append(" * ");
693 }
694 }
695 if (n_temporal > 0) {
696 result.append("\""+temporal()->type()+"\"");
697 }
698
699 // Append parameters
700 result.append("\n"+gammalib::parformat("Number of parameters") +
702 result.append("\n"+gammalib::parformat("Number of spectral par's") +
703 gammalib::str(n_spectral));
704 for (int i = 0; i < n_spectral; ++i) {
705 result.append("\n"+(*spectral())[i].print());
706 }
707 result.append("\n"+gammalib::parformat("Number of temporal par's") +
708 gammalib::str(n_temporal));
709 for (int i = 0; i < n_temporal; ++i) {
710 result.append("\n"+(*temporal())[i].print());
711 }
712
713 } // endif: chatter was not silent
714
715 // Return result
716 return result;
717}
718
719
720/*==========================================================================
721 = =
722 = Private methods =
723 = =
724 ==========================================================================*/
725
726/***********************************************************************//**
727 * @brief Initialise class members
728 ***************************************************************************/
730{
731 // Initialise members
732 m_spectral = NULL;
733 m_temporal = NULL;
734
735 // Initialise Npred cache
736 m_npred_names.clear();
737 m_npred_energies.clear();
738 m_npred_times.clear();
739 m_npred_values.clear();
740
741 // Return
742 return;
743}
744
745
746/***********************************************************************//**
747 * @brief Copy class members
748 *
749 * @param[in] bgd CTA background model.
750 ***************************************************************************/
752{
753 // Copy cache
758
759 // Clone spectral and temporal model components
760 m_spectral = (bgd.m_spectral != NULL) ? bgd.m_spectral->clone() : NULL;
761 m_temporal = (bgd.m_temporal != NULL) ? bgd.m_temporal->clone() : NULL;
762
763 // Set parameter pointers
764 set_pointers();
765
766 // Return
767 return;
768}
769
770
771/***********************************************************************//**
772 * @brief Delete class members
773 ***************************************************************************/
775{
776 // Free memory
777 if (m_spectral != NULL) delete m_spectral;
778 if (m_temporal != NULL) delete m_temporal;
779
780 // Signal free pointers
781 m_spectral = NULL;
782 m_temporal = NULL;
783
784 // Return
785 return;
786}
787
788
789/***********************************************************************//**
790 * @brief Set pointers
791 *
792 * Set pointers to all model parameters. The pointers are stored in a vector
793 * that is member of the GModelData base class.
794 ***************************************************************************/
796{
797 // Clear parameters
798 m_pars.clear();
799
800 // Determine the number of parameters
801 int n_spectral = (spectral() != NULL) ? spectral()->size() : 0;
802 int n_temporal = (temporal() != NULL) ? temporal()->size() : 0;
803 int n_pars = n_spectral + n_temporal;
804
805 // Continue only if there are parameters
806 if (n_pars > 0) {
807
808 // Gather spectral parameters
809 for (int i = 0; i < n_spectral; ++i) {
810 m_pars.push_back(&((*spectral())[i]));
811 }
812
813 // Gather temporal parameters
814 for (int i = 0; i < n_temporal; ++i) {
815 m_pars.push_back(&((*temporal())[i]));
816 }
817
818 }
819
820 // Return
821 return;
822}
823
824
825/***********************************************************************//**
826 * @brief Verifies if model has all components
827 *
828 * Returns 'true' if models has a spectral and a temporal component.
829 * Otherwise returns 'false'.
830 ***************************************************************************/
832{
833 // Set result
834 bool result = ((spectral() != NULL) && (temporal() != NULL));
835
836 // Return result
837 return result;
838}
839
840
841/***********************************************************************//**
842 * @brief Return pointer to spectral model from XML element
843 *
844 * @param[in] spectral XML element.
845 * @return Pointer to spectral model.
846 *
847 * Returns pointer to spectral model that is defined in an XML element.
848 ***************************************************************************/
850{
851 // Get spectral model
852 GModelSpectralRegistry registry;
853 GModelSpectral* ptr = registry.alloc(spectral);
854
855 // Return pointer
856 return ptr;
857}
858
859
860/***********************************************************************//**
861 * @brief Return pointer to temporal model from XML element
862 *
863 * @param[in] temporal XML element.
864 * @return Pointer to temporal model.
865 *
866 * Returns pointer to temporal model that is defined in an XML element.
867 ***************************************************************************/
869{
870 // Get temporal model
871 GModelTemporalRegistry registry;
872 GModelTemporal* ptr = registry.alloc(temporal);
873
874 // Return pointer
875 return ptr;
876}
877
CTA cube background class definition.
const GCTAModelCubeBackground g_cta_inst_background_seed
CTA cube background model class interface definition.
CTA observation class interface definition.
CTA cube-style response function class definition.
Definition of support function used by CTA classes.
#define G_EVAL
Model registry class definition.
#define G_NPRED
Definition GModelSky.cpp:60
Spectral nodes model class definition.
Spectral model registry class definition.
Constant temporal model class interface definition.
Temporal model registry class definition.
Gammalib tools definition.
GChatter
Definition GTypemaps.hpp:33
@ SILENT
Definition GTypemaps.hpp:34
CTA cube background class.
double integral(const double &logE) const
Return spatially integrated background rate in units of events MeV s .
CTA event list class.
CTA instrument direction class.
CTA cube background model class.
GModelTemporal * xml_temporal(const GXmlElement &temporal) const
Return pointer to temporal model from XML element.
std::vector< double > m_npred_values
Model values.
GModelSpectral * spectral(void) const
Return spectral model component.
virtual ~GCTAModelCubeBackground(void)
Destructor.
void free_members(void)
Delete class members.
virtual GCTAModelCubeBackground * clone(void) const
Clone CTA cube background model.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print CTA cube background model information.
GCTAModelCubeBackground(void)
Void constructor.
void init_members(void)
Initialise class members.
virtual GCTAEventList * mc(const GObservation &obs, GRan &ran) const
Return simulated list of events.
GModelTemporal * temporal(void) const
Return temporal model component.
void copy_members(const GCTAModelCubeBackground &bgd)
Copy class members.
bool valid_model(void) const
Verifies if model has all components.
virtual void clear(void)
Clear CTA cube background model.
virtual void read(const GXmlElement &xml)
Read CTA cube background model from XML element.
std::vector< std::string > m_npred_names
Model names.
virtual double npred(const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatially integrated background rate in units of events MeV s .
GModelSpectral * xml_spectral(const GXmlElement &spectral) const
Return pointer to spectral model from XML element.
std::vector< GEnergy > m_npred_energies
Model energy.
virtual GCTAModelCubeBackground & operator=(const GCTAModelCubeBackground &model)
Assignment operator.
virtual void write(GXmlElement &xml) const
Write CTA cube background model into XML element.
GModelTemporal * m_temporal
Temporal model.
void set_pointers(void)
Set pointers.
GModelSpectral * m_spectral
Spectral model.
virtual double eval(const GEvent &event, const GObservation &obs, const bool &gradients=false) const
Return background rate in units of events MeV s sr .
std::vector< GTime > m_npred_times
Model time.
CTA cube-style response function class.
const GCTACubeBackground & background(void) const
Return cube analysis background cube.
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
double log10TeV(void) const
Return log10 of energy in TeV.
Definition GEnergy.cpp:457
Abstract interface for the event classes.
Definition GEvent.hpp:71
virtual const GEnergy & energy(void) const =0
virtual const GTime & time(void) const =0
Abstract data model class.
void init_members(void)
Initialise class members.
void free_members(void)
Delete class members.
virtual GModelData & operator=(const GModelData &model)
Assignment operator.
Interface definition for the model registry class.
Interface definition for the spectral model registry class.
GModelSpectral * alloc(const GXmlElement &xml) const
Allocate spectral model that is found in XML element.
Abstract spectral model base class.
virtual double eval(const GEnergy &srcEng, const GTime &srcTime=GTime(), const bool &gradients=false) const =0
virtual GModelSpectral * clone(void) const =0
Clones object.
virtual void write(GXmlElement &xml) const =0
virtual std::string type(void) const =0
int size(void) const
Return number of parameters.
Constant temporal model class.
virtual GModelTemporalConst * clone(void) const
Clone constant temporal model.
Interface definition for the temporal model registry class.
GModelTemporal * alloc(const GXmlElement &xml) const
Allocate temporal model that is found in XML element.
Abstract temporal model base class.
virtual GModelTemporal * clone(void) const =0
Clones object.
virtual double eval(const GTime &srcTime, const bool &gradients=false) const =0
int size(void) const
Return number of parameters.
virtual std::string type(void) const =0
virtual void write(GXmlElement &xml) const =0
std::vector< GModelPar * > m_pars
Pointers to all model parameters.
Definition GModel.hpp:178
void write_attributes(GXmlElement &xml) const
Write model attributes.
Definition GModel.cpp:723
std::string print_attributes(void) const
Print model attributes.
Definition GModel.cpp:770
int size(void) const
Return number of parameters in model.
Definition GModel.hpp:233
void read_attributes(const GXmlElement &xml)
Read model attributes.
Definition GModel.cpp:684
const std::string & name(void) const
Return parameter name.
Definition GModel.hpp:261
Abstract observation base class.
virtual std::string instrument(void) const =0
void id(const std::string &id)
Set observation identifier.
Random number generator class.
Definition GRan.hpp:44
Time class.
Definition GTime.hpp:55
XML element node class.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
virtual GXmlNode * append(const GXmlNode &node)
Append XML child node.
Definition GXmlNode.cpp:287
virtual GXmlElement * element(const int &index)
Return pointer to GXMLElement child.
Definition GXmlNode.cpp:640
virtual int elements(void) const
Return number of GXMLElement children of node.
Definition GXmlNode.cpp:586
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
Definition GTools.cpp:1143
bool is_infinite(const double &x)
Signal if argument is infinite.
Definition GTools.hpp:184
bool is_notanumber(const double &x)
Signal if argument is not a number.
Definition GTools.hpp:201
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
Definition GTools.cpp:489
const GCTAInstDir & cta_dir(const std::string &origin, const GEvent &event)
Retrieve CTA instrument direction from generic event.
void warning(const std::string &origin, const std::string &message)
Emits warning.
Definition GTools.cpp:1386
const GCTAResponseCube & cta_rsp_cube(const std::string &origin, const GObservation &obs)
Retrieve CTA cube response from generic observation.