50 const GModelRegistry g_cta_background_registry(&g_cta_background_seed);
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) {
549 double flux = spectral->
flux(ebounds.
emin(ieng), ebounds.
emax(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) {
849 for (
int i = 0; i < n_spectral; ++i) {
854 for (
int i = 0; i < n_temporal; ++i) {
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) &&
virtual void write(GXmlElement &xml) const =0
Constant temporal model class interface definition.
GCTAModelBackground(void)
Void constructor.
virtual GCTAInstDir mc(const GEnergy &energy, const GTime &time, const GCTAObservation &obs, GRan &ran) const
Returns MC instrument direction.
Abstract spatial model class.
void free_members(void)
Delete class members.
GModelTemporal * xml_temporal(const GXmlElement &temporal) const
Return pointer to temporal model from XML element.
virtual GTimes mc(const double &rate, const GTime &tmin, const GTime &tmax, GRan &ran) const =0
virtual GEnergy mc(const GEnergy &emin, const GEnergy &emax, const GTime &time, GRan &ran) const =0
const GCTAInstDir & cta_dir(const std::string &origin, const GEvent &event)
Retrieve CTA instrument direction from generic event.
int size(void) const
Return number of times.
std::string print_attributes(void) const
Print model attributes.
Abstract spectral model base class.
Interface definition for the model registry class.
virtual void read(const GXmlElement &xml)
Read model from XML element.
Abstract temporal model base class.
virtual void roi(const GRoi &roi)
Set ROI.
GModelTemporal * m_temporal
Temporal model.
int size(void) const
Return number of parameters.
void ebounds(const GEbounds &ebounds)
Set energy boundaries.
int size(void) const
Return number of energy boundaries.
virtual double eval(const GEnergy &srcEng, const GTime &srcTime=GTime(), const bool &gradients=false) const =0
virtual void write(GXmlElement &xml) const =0
void append(const GCTAEventAtom &event)
Append event to event list.
virtual double npred(const GEnergy &energy, const GTime &time, const GObservation &obs) const
Return spatially integrated background rate in units of events MeV s .
bool valid_model(void) const
Verifies if model has all components.
Abstract interface for the event classes.
void gti(const GGti >i)
Set Good Time Intervals.
CTA pointing class interface definition.
void free_members(void)
Delete class members.
Spectral model registry class definition.
virtual void write(GXmlElement &xml) const =0
GModelSpectral * spectral(void) const
Return spectral model component.
Random number generator class.
Interface for the CTA region of interest class.
virtual int elements(void) const
Return number of GXMLElement children of node.
virtual GModelTemporalConst * clone(void) const
Clone constant temporal model.
virtual const GTime & time(void) const =0
GModelSpectral * m_spectral
Spectral model.
int size(void) const
Return number of Good Time Intervals.
Interface definition for the spatial model registry class.
std::vector< GModelPar * > m_pars
Pointers to all model parameters.
int size(void) const
Return number of parameters in model.
void init_members(void)
Initialise class members.
void copy_members(const GCTAModelBackground &model)
Copy class members.
Definition of support function used by CTA classes.
void free_members(void)
Delete class members.
virtual GCTAEventList * mc(const GObservation &obs, GRan &ran) const
Return simulated list of events.
Energy boundaries container class.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
const std::string & name(void) const
Return parameter name.
void reserve(const int &number)
Reserves space for events.
const GEnergy & emin(void) const
Return minimum energy of all intervals.
GCTAModelSpatial * spatial(void) const
Return spatial model component.
void set_pointers(void)
Set pointers.
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
Abstract data model class.
CTA instrument direction class interface definition.
const GCTAEventList & cta_event_list(const std::string &origin, const GObservation &obs)
Retrieve CTA event list from generic observation.
GModelSpectral * alloc(const GXmlElement &xml) const
Allocate spectral model that is found in XML element.
virtual GCTAModelBackground & operator=(const GCTAModelBackground &model)
Assignment operator.
virtual GModelData & operator=(const GModelData &model)
Assignment operator.
int size(void) const
Return number of model parameters.
Good Time Interval class.
GCTAModelSpatial * xml_spatial(const GXmlElement &spatial) const
Return pointer to spatial model from XML element.
virtual double eval(const GTime &srcTime, const bool &gradients=false) const =0
const GCTAObservation & cta_obs(const std::string &origin, const GObservation &obs)
Retrieve CTA observation from generic observation.
Abstract observation base class.
void init_members(void)
Initialise class members.
const GTime & tstop(void) const
Returns latest stop time in Good Time Intervals.
const GTime & tstart(void) const
Returns earliest start time in Good Time Intervals.
CTA region of interest class interface definition.
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 GCTAModelBackground * clone(void) const
Clone instance.
virtual void write(GXmlElement &xml) const
Write model into XML element.
virtual GXmlElement * element(const int &index)
Return pointer to GXMLElement child.
GCTAModelSpatial * m_spatial
Spatial model.
GModelTemporal * temporal(void) const
Return temporal model component.
Temporal model registry class definition.
const GCTAModelBackground g_cta_background_seed
virtual double eval(const GCTAInstDir &dir, const GEnergy &energy, const GTime &time, const bool &gradients=false) const =0
virtual GModelTemporal * clone(void) const =0
Clones object.
void read_attributes(const GXmlElement &xml)
Read model attributes.
CTA instrument direction class.
GCTAModelSpatial * alloc(const GXmlElement &xml) const
Allocate spatial model that is found in XML element.
double norm(void) const
Return normalization factor.
const GEnergy & emax(void) const
Return maximum energy of all intervals.
virtual double flux(const GEnergy &emin, const GEnergy &emax) const =0
Model registry class definition.
virtual GCTAModelSpatial * clone(void) const =0
Clones object.
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.
GModelSpectral * xml_spectral(const GXmlElement &spectral) const
Return pointer to spectral model from XML element.
virtual double npred(const GEnergy &energy, const GTime &time, const GObservation &obs) const
Return integral of spatial model component.
Integration class interface definition.
virtual double eval(const GEvent &event, const GObservation &obs, const bool &gradients=false) const
Return background rate in units of events MeV s sr .
Spatial model registry class definition.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print model information.
void init_members(void)
Initialise class members.
virtual ~GCTAModelBackground(void)
Destructor.
Constant temporal model class.
const GCTAInstDir & dir(void) const
Return instrument direction.
Mathematical function definitions.
virtual void clear(void)
Clear instance.
Class that handles energies in a unit independent way.
virtual std::string type(void) const
Return model type.
Background model class interface definition.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.