45 const GModelRegistry g_cta_inst_background_registry(&g_cta_inst_background_seed);
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.");
556 spectral = xml.
element(
"spectrum", 0);
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) {
649 if (dynamic_cast<GModelTemporalConst*>(
temporal()) == NULL) {
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) {
709 for (
int i = 0; i < n_temporal; ++i) {
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) {
virtual void write(GXmlElement &xml) const =0
Constant temporal model class interface definition.
void init_members(void)
Initialise class members.
const GCTAInstDir & cta_dir(const std::string &origin, const GEvent &event)
Retrieve CTA instrument direction from generic event.
CTA cube-style response function class definition.
std::string print_attributes(void) const
Print model attributes.
void warning(const std::string &origin, const std::string &message)
Emits warning.
Abstract spectral model base class.
Interface definition for the model registry class.
virtual std::string instrument(void) const =0
GModelSpectral * spectral(void) const
Return spectral model component.
void set_pointers(void)
Set pointers.
Abstract temporal model base class.
int size(void) const
Return number of parameters.
const GCTACubeBackground & background(void) const
Return cube analysis background cube.
virtual double eval(const GEnergy &srcEng, const GTime &srcTime=GTime(), const bool &gradients=false) const =0
CTA cube background class.
CTA cube-style response function class.
Abstract interface for the event classes.
void free_members(void)
Delete class members.
Spectral model registry class definition.
virtual void write(GXmlElement &xml) const =0
double log10TeV(void) const
Return log10 of energy in TeV.
Random number generator class.
Spectral nodes model class definition.
virtual int elements(void) const
Return number of GXMLElement children of node.
const GCTAResponseCube & cta_rsp_cube(const std::string &origin, const GObservation &obs)
Retrieve CTA cube response from generic observation.
std::vector< GEnergy > m_npred_energies
Model energy.
virtual GCTAEventList * mc(const GObservation &obs, GRan &ran) const
Return simulated list of events.
virtual GModelTemporalConst * clone(void) const
Clone constant temporal model.
virtual const GTime & time(void) const =0
GModelTemporal * m_temporal
Temporal model.
void id(const std::string &id)
Set observation identifier.
bool is_notanumber(const double &x)
Signal if argument is not a number.
CTA cube background class definition.
std::vector< GModelPar * > m_pars
Pointers to all model parameters.
int size(void) const
Return number of parameters in model.
bool is_infinite(const double &x)
Signal if argument is infinite.
bool valid_model(void) const
Verifies if model has all components.
Definition of support function used by CTA classes.
std::vector< std::string > m_npred_names
Model names.
GCTAModelCubeBackground(void)
Void constructor.
GModelSpectral * xml_spectral(const GXmlElement &spectral) const
Return pointer to spectral model from XML element.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
std::vector< GTime > m_npred_times
Model time.
const std::string & name(void) const
Return parameter name.
int size(void) const
Return number of parameters.
GModelTemporal * alloc(const GXmlElement &xml) const
Allocate temporal model that is found in XML element.
virtual const GEnergy & energy(void) const =0
CTA cube background model class.
Abstract data model class.
GModelSpectral * alloc(const GXmlElement &xml) const
Allocate spectral model that is found in XML element.
virtual GModelData & operator=(const GModelData &model)
Assignment operator.
virtual double eval(const GTime &srcTime, const bool &gradients=false) const =0
double integral(const double &logE) const
Return spatially integrated background rate in units of events MeV s .
Abstract observation base class.
virtual void read(const GXmlElement &xml)
Read CTA cube background model from XML element.
GModelTemporal * xml_temporal(const GXmlElement &temporal) const
Return pointer to temporal model from XML element.
std::vector< double > m_npred_values
Model values.
CTA observation class interface definition.
Interface definition for the spectral model registry class.
Interface definition for the temporal model registry class.
void write_attributes(GXmlElement &xml) const
Write model attributes.
virtual GModelSpectral * clone(void) const =0
Clones object.
virtual std::string type(void) const =0
virtual GXmlElement * element(const int &index)
Return pointer to GXMLElement child.
void free_members(void)
Delete class members.
Temporal model registry class definition.
void copy_members(const GCTAModelCubeBackground &bgd)
Copy class members.
virtual GCTAModelCubeBackground & operator=(const GCTAModelCubeBackground &model)
Assignment operator.
const GCTAModelCubeBackground g_cta_inst_background_seed
CTA cube background model class interface definition.
virtual GModelTemporal * clone(void) const =0
Clones object.
void read_attributes(const GXmlElement &xml)
Read model attributes.
CTA instrument direction class.
virtual GCTAModelCubeBackground * clone(void) const
Clone CTA cube background model.
Model registry class definition.
virtual GXmlNode * append(const GXmlNode &node)
Append XML child node.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
virtual std::string type(void) const
Return data model type.
virtual void write(GXmlElement &xml) const
Write CTA cube background model into XML element.
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 * m_spectral
Spectral model.
virtual void clear(void)
Clear CTA cube background model.
void init_members(void)
Initialise class members.
Constant temporal model class.
GModelTemporal * temporal(void) const
Return temporal model component.
virtual ~GCTAModelCubeBackground(void)
Destructor.
Class that handles energies in a unit independent way.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print CTA cube background model information.
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::string str(const unsigned short int &value)
Convert unsigned short integer value into string.