53#define G_EVAL "GCTAModelBackground::eval(GEvent&, GObservation&, bool&)"
54#define G_NPRED "GCTAModelBackground::npred(GEnergy&, GTime&, GObservation&)"
55#define G_MC "GCTAModelBackground::mc(GObservation&, GRan&)"
56#define G_XML_SPATIAL "GCTAModelBackground::xml_spatial(GXmlElement&)"
57#define G_XML_SPECTRAL "GCTAModelBackground::xml_spectral(GXmlElement&)"
58#define G_XML_TEMPORAL "GCTAModelBackground::xml_temporal(GXmlElement&)"
237 if (
this != &model) {
406 const bool& gradients)
const
412 double spat = (
spatial() != NULL)
421 double value = spat * spec * temp;
428 double fact = spec * temp;
431 (*
spatial())[i].factor_gradient((*
spatial())[i].factor_gradient() * fact);
437 double fact = spat * temp;
440 (*
spectral())[i].factor_gradient((*
spectral())[i].factor_gradient() * fact);
446 double fact = spat * spec;
449 (*
temporal())[i].factor_gradient((*
temporal())[i].factor_gradient() * fact);
527 const GGti& gti = events.
gti();
545 for (
int ieng = 0; ieng < ebounds.
size(); ++ieng) {
553 double rate = flux * solidangle;
556 #if defined(G_DUMP_MC)
557 std::cout <<
"GCTAModelBackground::mc(\"" <<
name() <<
"\": ";
558 std::cout <<
"flux=" << flux <<
" cts/s/sr, ";
559 std::cout <<
"solidangle=" << solidangle <<
" sr, ";
560 std::cout <<
"rate=" << rate <<
" cts/s)" << std::endl;
569 for (
int itime = 0; itime < gti.
size(); ++itime) {
578 int n_events = times.
size();
587 #if defined(G_DUMP_MC)
588 std::cout <<
" Interval " << itime;
589 std::cout <<
" events=" << n_events << std::endl;
590 int n_trial_outside_roi = 0;
594 for (
int i = 0; i < n_events; ++i) {
605 for (
int k = 0; k < 100; ++k) {
615 event.energy(energy);
616 event.time(times[i]);
620 if (events.
roi().contains(event)) {
626 #if defined(G_DUMP_MC)
628 n_trial_outside_roi++;
637 #if defined(G_DUMP_MC)
638 std::cout <<
" Trials outside RoI=";
639 std::cout << n_trial_outside_roi << std::endl;
741 for (
int k = 0; k < n; ++k) {
753 if (cons->
norm() != 1.0) {
760 src = xml.
append(
"source");
780 if (
temporal() != NULL && cons == NULL) {
808 result.append(
"=== GCTAModelBackground ===");
825 if (n_spectral > 0 || n_temporal > 0) {
826 result.append(
" * ");
829 if (n_spectral > 0) {
831 if (n_temporal > 0) {
832 result.append(
" * ");
835 if (n_temporal > 0) {
844 for (
int i = 0; i < n_spatial; ++i) {
845 result.append(
"\n"+(*
spatial())[i].print());
849 for (
int i = 0; i < n_spectral; ++i) {
850 result.append(
"\n"+(*
spectral())[i].print());
854 for (
int i = 0; i < n_temporal; ++i) {
855 result.append(
"\n"+(*
temporal())[i].print());
941 int n_pars = n_spatial + n_spectral + n_temporal;
947 for (
int i = 0; i < n_spatial; ++i) {
952 for (
int i = 0; i < n_spectral; ++i) {
957 for (
int i = 0; i < n_temporal; ++i) {
1034 bool result = ((
spatial() != NULL) &&
CTA instrument direction class interface definition.
const GCTAModelBackground g_cta_background_seed
Background model class interface definition.
Spatial model registry class definition.
CTA observation class interface definition.
CTA pointing class interface definition.
CTA region of interest class interface definition.
Definition of support function used by CTA classes.
Integration class interface definition.
Mathematical function definitions.
Model registry class definition.
Spectral model registry class definition.
Constant temporal model class interface definition.
Temporal model registry class definition.
const GCTAInstDir & dir(void) const
Return instrument direction.
virtual void roi(const GRoi &roi)
Set ROI.
void reserve(const int &number)
Reserves space for events.
void append(const GCTAEventAtom &event)
Append event to event list.
CTA instrument direction class.
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual std::string type(void) const
Return model type.
GCTAModelSpatial * xml_spatial(const GXmlElement &spatial) const
Return pointer to spatial model from XML element.
virtual void clear(void)
Clear instance.
GModelTemporal * m_temporal
Temporal model.
virtual GCTAEventList * mc(const GObservation &obs, GRan &ran) const
Return simulated list of events.
GModelSpectral * m_spectral
Spectral model.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print model information.
void set_pointers(void)
Set pointers.
GModelTemporal * xml_temporal(const GXmlElement &temporal) const
Return pointer to temporal model from XML element.
GCTAModelSpatial * m_spatial
Spatial model.
void copy_members(const GCTAModelBackground &model)
Copy class members.
virtual GCTAModelBackground * clone(void) const
Clone instance.
GModelSpectral * xml_spectral(const GXmlElement &spectral) const
Return pointer to spectral model from XML element.
virtual double eval(const GEvent &event, const GObservation &obs, const bool &gradients=false) const
Return background rate in units of events MeV s sr .
GCTAModelSpatial * spatial(void) const
Return spatial model component.
GModelSpectral * spectral(void) const
Return spectral model component.
virtual GCTAModelBackground & operator=(const GCTAModelBackground &model)
Assignment operator.
virtual double npred(const GEnergy &energy, const GTime &time, const GObservation &obs) const
Return spatially integrated background rate in units of events MeV s .
GModelTemporal * temporal(void) const
Return temporal model component.
virtual ~GCTAModelBackground(void)
Destructor.
virtual void write(GXmlElement &xml) const
Write model into XML element.
void init_members(void)
Initialise class members.
bool valid_model(void) const
Verifies if model has all components.
GCTAModelBackground(void)
Void constructor.
void free_members(void)
Delete class members.
Interface definition for the spatial model registry class.
GCTAModelSpatial * alloc(const GXmlElement &xml) const
Allocate spatial model that is found in XML element.
Abstract spatial model class.
virtual std::string type(void) const =0
int size(void) const
Return number of model parameters.
virtual double eval(const GCTAInstDir &dir, const GEnergy &energy, const GTime &time, const bool &gradients=false) const =0
virtual double npred(const GEnergy &energy, const GTime &time, const GObservation &obs) const
Return integral of spatial model component.
virtual void write(GXmlElement &xml) const =0
virtual GCTAInstDir mc(const GEnergy &energy, const GTime &time, const GCTAObservation &obs, GRan &ran) const
Returns MC instrument direction.
virtual GCTAModelSpatial * clone(void) const =0
Clones object.
Interface for the CTA region of interest class.
Energy boundaries container class.
const GEnergy & emax(void) const
Return maximum energy of all intervals.
int size(void) const
Return number of energy boundaries.
const GEnergy & emin(void) const
Return minimum energy of all intervals.
Class that handles energies in a unit independent way.
Abstract interface for the event classes.
virtual const GEnergy & energy(void) const =0
virtual const GTime & time(void) const =0
void gti(const GGti >i)
Set Good Time Intervals.
void ebounds(const GEbounds &ebounds)
Set energy boundaries.
Good Time Interval class.
const GTime & tstop(void) const
Returns latest stop time in Good Time Intervals.
int size(void) const
Return number of Good Time Intervals.
const GTime & tstart(void) const
Returns earliest start time in Good Time Intervals.
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 GEnergy mc(const GEnergy &emin, const GEnergy &emax, const GTime &time, GRan &ran) const =0
virtual double flux(const GEnergy &emin, const GEnergy &emax) 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.
double norm(void) const
Return normalization factor.
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 GTimes mc(const double &rate, const GTime &tmin, const GTime &tmax, GRan &ran) 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.
void free_members(void)
Delete class members.
void init_members(void)
Initialise class members.
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.
Random number generator class.
int size(void) const
Return number of times.
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.
const GCTAObservation & cta_obs(const std::string &origin, const GObservation &obs)
Retrieve CTA observation from generic observation.
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.
const GCTAEventList & cta_event_list(const std::string &origin, const GObservation &obs)
Retrieve CTA event list from generic observation.