48#define G_EVAL "GCTAModelCubeBackground::eval(GEvent&, GObservation&, bool&)"
49#define G_NPRED "GCTAModelCubeBackground::npred(GEnergy&, GTime&,"\
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&)"
58#define G_USE_NPRED_CACHE
345 const bool& gradients)
const
356 double spat = bgd(dir, event.
energy());
365 double value = spat * spec * temp;
373 double fact = spat * temp;
376 (*
spectral())[i].factor_gradient((*
spectral())[i].factor_gradient() * fact);
382 double fact = spat * spec;
385 (*
temporal())[i].factor_gradient((*
temporal())[i].factor_gradient() * fact);
411 const GTime& obsTime,
416 bool has_npred =
false;
422 #if defined(G_USE_NPRED_CACHE)
431 #if defined(G_DEBUG_NPRED)
432 std::cout <<
"GCTAModelCubeBackground::npred:";
433 std::cout <<
" cache=" << i;
434 std::cout <<
" npred=" <<
npred << std::endl;
462 #if defined(G_USE_NPRED_CACHE)
470 #if defined(G_NAN_CHECK)
472 std::string origin =
"GCTAModelCubeBackground::npred";
473 std::string message =
" NaN/Inf encountered (npred=" +
510 "MC computation not implemented for binned analysis.");
617 for (
int k = 0; k < n; ++k) {
630 bool write_temporal = ((
m_temporal != NULL) &&
632 (*m_temporal)[0].value() != 1.0));
636 src = xml.
append(
"source");
648 if (write_temporal) {
678 result.append(
"=== GCTAModelCubeBackground ===");
689 if (n_spectral > 0) {
691 if (n_temporal > 0) {
692 result.append(
" * ");
695 if (n_temporal > 0) {
704 for (
int i = 0; i < n_spectral; ++i) {
705 result.append(
"\n"+(*
spectral())[i].print());
709 for (
int i = 0; i < n_temporal; ++i) {
710 result.append(
"\n"+(*
temporal())[i].print());
803 int n_pars = n_spectral + n_temporal;
809 for (
int i = 0; i < n_spectral; ++i) {
814 for (
int i = 0; i < n_temporal; ++i) {
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.
Model registry class definition.
Spectral nodes model class definition.
Spectral model registry class definition.
Constant temporal model class interface definition.
Temporal model registry class definition.
CTA cube background class.
double integral(const double &logE) const
Return spatially integrated background rate in units of events MeV s .
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.
double log10TeV(void) const
Return log10 of energy in TeV.
Abstract interface for the event classes.
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.
void write_attributes(GXmlElement &xml) const
Write model attributes.
std::string print_attributes(void) const
Print model attributes.
int size(void) const
Return number of parameters in model.
void read_attributes(const GXmlElement &xml)
Read model attributes.
const std::string & name(void) const
Return parameter name.
Abstract observation base class.
virtual std::string instrument(void) const =0
void id(const std::string &id)
Set observation identifier.
Random number generator class.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
virtual GXmlNode * append(const GXmlNode &node)
Append XML child node.
virtual GXmlElement * element(const int &index)
Return pointer to GXMLElement child.
virtual int elements(void) const
Return number of GXMLElement children of node.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
bool is_infinite(const double &x)
Signal if argument is infinite.
bool is_notanumber(const double &x)
Signal if argument is not a number.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
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.
const GCTAResponseCube & cta_rsp_cube(const std::string &origin, const GObservation &obs)
Retrieve CTA cube response from generic observation.