51 const GModelRegistry g_cta_radial_acceptance_registry(&g_cta_radial_acceptance_seed);
54 #define G_ACCESS "GCTAModelRadialAcceptance::operator() (int)"
55 #define G_EVAL "GCTAModelRadialAcceptance::eval(GEvent&, GObservation&, "\
57 #define G_NPRED "GCTAModelRadialAcceptance::npred(GEnergy&, GTime&,"\
59 #define G_MC "GCTAModelRadialAcceptance::mc(GObservation&, GRan&)"
60 #define G_XML_RADIAL "GCTAModelRadialAcceptance::xml_radial(GXmlElement&)"
61 #define G_XML_SPECTRAL "GCTAModelRadialAcceptance::xml_spectral(GXmlElement&)"
62 #define G_XML_TEMPORAL "GCTAModelRadialAcceptance::xml_temporal(GXmlElement&)"
243 if (
this != &model) {
412 const bool& gradients)
const
420 double offset = dir.
dir().dist_deg(pnt.
dir());
423 double rad = (
radial() != NULL)
432 double value = rad * spec * temp;
439 double fact = spec * temp;
442 (*
radial())[i].factor_gradient((*
radial())[i].factor_gradient() * fact);
448 double fact = rad * temp;
451 (*
spectral())[i].factor_gradient((*
spectral())[i].factor_gradient() * fact);
457 double fact = rad * spec;
460 (*
temporal())[i].factor_gradient((*
temporal())[i].factor_gradient() * fact);
486 const GTime& obsTime,
503 double roi_distance = events.
roi().centre().dir().dist(pnt.
dir());
512 double rmin = (roi_distance > roi_radius) ? roi_distance-roi_radius : 0.0;
513 double rmax = roi_radius + roi_distance;
516 npred = integral.
romberg(rmin, rmax);
558 for (
int ieng = 0; ieng < obs.
events()->
ebounds().size(); ++ieng) {
570 double rate = flux * area;
573 #if defined(G_DUMP_MC)
574 std::cout <<
"GCTAModelRadialAcceptance::mc(\"" <<
name() <<
"\": ";
575 std::cout <<
"flux=" << flux <<
" cts/s/sr, ";
576 std::cout <<
"area=" << area <<
" sr, ";
577 std::cout <<
"rate=" << rate <<
" cts/s)" << std::endl;
581 for (
int itime = 0; itime < obs.
events()->
gti().size(); ++itime) {
590 int n_events = times.
size();
598 for (
int i = 0; i < n_events; ++i) {
621 event.energy(energy);
622 event.time(times[i]);
660 rad = xml.
element(
"radialModel", 0);
661 spec = xml.
element(
"spectrum", 0);
702 for (
int k = 0; k < n; ++k) {
715 bool write_temporal = ((
m_temporal != NULL) &&
717 (*m_temporal)[0].value() != 1.0));
721 src = xml.
append(
"source");
740 if (write_temporal) {
741 if (dynamic_cast<GModelTemporalConst*>(
temporal()) == NULL) {
770 result.append(
"=== GCTAModelRadialAcceptance ===");
784 if (n_spectral > 0 || n_temporal > 0) {
785 result.append(
" * ");
788 if (n_spectral > 0) {
790 if (n_temporal > 0) {
791 result.append(
" * ");
794 if (n_temporal > 0) {
803 for (
int i = 0; i < n_radial; ++i) {
808 for (
int i = 0; i < n_spectral; ++i) {
813 for (
int i = 0; i < n_temporal; ++i) {
906 int n_pars = n_radial + n_spectral + n_temporal;
912 for (
int i = 0; i < n_radial; ++i) {
917 for (
int i = 0; i < n_spectral; ++i) {
922 for (
int i = 0; i < n_temporal; ++i) {
942 bool result = ((
radial() != NULL) &&
977 std::string msg =
"Invalid radial model type \""+type+
"\" encountered. "
978 "No such model exists in the registry of radial "
979 "models. Please specify valid radial model type.";
virtual void write(GXmlElement &xml) const =0
Constant temporal model class interface definition.
void free_members(void)
Delete class members.
double roi_arclength(const double &rad, const double &dist, const double &cosdist, const double &sindist, const double &roi, const double &cosroi)
Returns length of circular arc within circular ROI.
virtual GCTAInstDir mc(const GEnergy &energy, const GTime &time, const GCTAObservation &obs, GRan &ran) const
Returns MC instrument direction.
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
double romberg(std::vector< double > bounds, const int &order=5)
Perform Romberg integration.
void set_pointers(void)
Set pointers.
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.
Abstract temporal model base class.
virtual void roi(const GRoi &roi)
Set ROI.
void free_members(void)
Delete class members.
GSkyDir skydir(const GCTAInstDir &instdir) const
Get sky direction direction from instrument direction.
double m_roi
ROI radius in radians.
int size(void) const
Return number of parameters.
void ebounds(const GEbounds &ebounds)
Set energy boundaries.
virtual double eval(const GEnergy &srcEng, const GTime &srcTime=GTime(), const bool &gradients=false) const =0
virtual GCTAModelRadialAcceptance * clone(void) const
Clone instance.
void append(const GCTAEventAtom &event)
Append event to event list.
const GCTAPointing & cta_pnt(const std::string &origin, const GObservation &obs)
Retrieve CTA pointing from generic observation.
Abstract interface for the event classes.
void gti(const GGti >i)
Set Good Time Intervals.
GModelTemporal * m_temporal
Temporal model.
CTA pointing class interface definition.
void free_members(void)
Delete class members.
Spectral model registry class definition.
const GCTAModelRadial * m_parent
Pointer to radial model.
Radial acceptance model class interface definition.
GCTAModelRadial * radial(void) const
Return radial model component.
virtual void write(GXmlElement &xml) const =0
Random number generator class.
virtual GCTAEventList * mc(const GObservation &obs, GRan &ran) const
Return simulated list of events.
double eval(const double &r)
Integration kernel for the Npred method.
virtual int elements(void) const
Return number of GXMLElement children of node.
GIntegral class interface definition.
virtual GModelTemporalConst * clone(void) const
Clone constant temporal model.
CTA radial model registry class definition.
virtual GCTAModelRadial * clone(void) const =0
Clones object.
virtual const GTime & time(void) const =0
void dir(const GSkyDir &dir)
Set sky direction.
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< GModelPar * > m_pars
Pointers to all model parameters.
int size(void) const
Return number of parameters in model.
double m_cosdist
Cosine of distance.
void init_members(void)
Initialise class members.
Definition of support function used by CTA classes.
double m_dist
Distance between pointing and ROI centre in radians.
GModelSpectral * spectral(void) const
Return spectral model component.
GModelTemporal * temporal(void) const
Return temporal model component.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
GCTAModelRadial * m_radial
Radial model.
virtual void write(GXmlElement &xml) const
Write model into XML element.
const std::string & name(void) const
Return parameter name.
void reserve(const int &number)
Reserves space for events.
double m_sindist
Sinus of distance.
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
void copy_members(const GCTAModelRadialAcceptance &model)
Copy class members.
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.
GModelTemporal * xml_temporal(const GXmlElement &temporal) const
Return pointer to temporal model from XML element.
virtual GModelData & operator=(const GModelData &model)
Assignment operator.
int size(void) const
Return number of model parameters.
virtual void write(GXmlElement &xml) const =0
virtual double eval(const GTime &srcTime, const bool &gradients=false) const =0
Abstract observation base class.
CTA region of interest class interface definition.
GModelSpectral * m_spectral
Spectral model.
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.
const GCTAModelRadialAcceptance g_cta_radial_acceptance_seed
GCTAModelRadial * xml_radial(const GXmlElement &radial) const
Construct radial model from XML element.
virtual std::string type(void) const =0
void init_members(void)
Initialise class members.
virtual GXmlElement * element(const int &index)
Return pointer to GXMLElement child.
virtual ~GCTAModelRadialAcceptance(void)
Destructor.
Temporal model registry class definition.
GCTAModelRadial * alloc(const std::string &name) const
Allocate radial model of given name.
double m_cosroi
Cosine of ROI radius.
Interface definition for the CTA radial model registry class.
GVector sin(const GVector &vector)
Computes sine of vector elements.
virtual GEvents * events(void)
Return events.
Exception handler interface definition.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print model information.
Radial acceptance model class.
virtual GCTAModelRadialAcceptance & operator=(const GCTAModelRadialAcceptance &model)
Assignment operator.
virtual GModelTemporal * clone(void) const =0
Clones object.
void read_attributes(const GXmlElement &xml)
Read model attributes.
CTA instrument direction class.
const GSkyDir & dir(void) const
Return pointing sky direction.
virtual void read(const GXmlElement &xml)
Read model from XML element.
Abstract radial acceptance model class.
virtual double flux(const GEnergy &emin, const GEnergy &emax) const =0
virtual void read(const GXmlElement &xml)=0
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 void clear(void)
Clear instance.
Integration class interface definition.
virtual double omega(void) const =0
virtual double npred(const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatially integrated background rate in units of events MeV s .
GCTAModelRadialAcceptance(void)
Void constructor.
bool valid_model(void) const
Verifies if model has all components.
void init_members(void)
Initialise class members.
Constant temporal model class.
const GCTAInstDir & dir(void) const
Return instrument direction.
virtual std::string type(void) const
Return model type.
Mathematical function definitions.
Class that handles energies in a unit independent way.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
GModelSpectral * xml_spectral(const GXmlElement &spectral) const
Return pointer to spectral model from XML element.
virtual double eval(const GCTAInstDir &dir, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
Evaluate function.