44 #define G_CONSTRUCTOR "GModelSpatialRadialRing::GModelSpatialRadialRing("\
45 "GSkyDir&, double&, double&, std::string&)"
46 #define G_READ "GModelSpatialRadialRing::read(GXmlElement&)"
47 #define G_WRITE "GModelSpatialRadialRing::write(GXmlElement&)"
96 const std::string& coordsys) :
100 if ((coordsys !=
"CEL") && (coordsys !=
"GAL")) {
101 std::string msg =
"Invalid coordinate system \""+coordsys+
"\" "
102 "specified. Please specify either \"CEL\" or "
111 if (coordsys ==
"CEL") {
200 if (
this != &model) {
296 const bool& gradients)
const
308 #if defined(G_NAN_CHECK)
310 std::cout <<
"*** ERROR: GModelSpatialRadialRing::eval";
311 std::cout <<
"(theta=" << theta <<
"): NaN/Inf encountered";
312 std::cout <<
" (value=" << value;
315 std::cout <<
", m_norm=" <<
m_norm;
316 std::cout <<
")" << std::endl;
347 double phi = 360.0 * ran.
uniform();
368 const double& margin)
const
371 double distance = dir.
dist(this->
dir());
375 double distance_min =
theta_min() - margin_rad;
376 double distance_max =
theta_max() + margin_rad;
377 if (distance_min < 0.0) {
382 return ((distance >= distance_min) && (distance <= distance_max));
510 result.append(
"=== GModelSpatialRadialRing ===");
515 for (
int i = 0; i <
size(); ++i) {
648 m_norm = (denom > 0.0) ? 1.0 / denom : 0.0;
double m_outer_radius_rad
Outer radius in radians.
const std::string & name(void) const
Return parameter name.
double gradient(void) const
Return parameter gradient.
int size(void) const
Return number of parameters.
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
virtual double theta_min(void) const
Return minimum model radius (in radians)
GVector cos(const GVector &vector)
Computes cosine of vector elements.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print information.
GModelPar m_width
Ring width (degrees)
double m_last_width
Last ring width.
double m_norm
Normalization.
double acos(const double &arg)
Computes acos by avoiding NaN due to rounding errors.
Random number generator class.
void init_members(void)
Initialise class members.
Interface for the circular sky region class.
Interface definition for the spatial model registry class.
double min(void) const
Return parameter minimum boundary.
void init_members(void)
Initialise class members.
void free_members(void)
Delete class members.
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual GModelSpatialRadialRing * clone(void) const
Clone radial ring model.
GSkyRegionCircle m_region
Bounding circle.
virtual ~GModelSpatialRadialRing(void)
Destructor.
GModelPar m_radius
Ring inner radius (degrees)
bool is_notanumber(const double &x)
Signal if argument is not a number.
const double & scale(void) const
Return parameter scale.
bool is_infinite(const double &x)
Signal if argument is infinite.
virtual double theta_max(void) const
Return maximum model radius (in radians)
void update(void) const
Update precomputation cache.
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
virtual void write(GXmlElement &xml) const
Write model into XML element.
virtual GModelSpatialRadialRing & operator=(const GModelSpatialRadialRing &model)
Assignment operator.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks whether model contains specified sky direction.
const GSkyDir & dir(void) const
Return position of radial spatial model.
void free_members(void)
Delete class members.
void free(void)
Free a parameter.
std::vector< GModelPar * > m_pars
Parameter pointers.
void rotate_deg(const double &phi, const double &theta)
Rotate sky direction by zenith and azimuth angle.
double width(void) const
Return ring width.
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
virtual void read(const GXmlElement &xml)
Read model from XML element.
Radial ring model class interface definition.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
void clear(void)
Clear parameter.
Spatial model registry class definition.
virtual double eval(const double &theta, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
Evaluate function (in units of sr^-1)
void copy_members(const GModelSpatialRadialRing &model)
Copy class members.
std::string type(void) const
Return model type.
void xml_check_parnum(const std::string &origin, const GXmlElement &xml, const int &number)
Checks number of parameters.
virtual void set_region(void) const
Set boundary sky region.
virtual void write(GXmlElement &xml) const
Write model into XML element.
double m_cos_outer_radius_rad
Cosine of outer radius in radians.
const GSkyRegion * region(void) const
Return boundary sky region.
virtual GModelSpatialRadial & operator=(const GModelSpatialRadial &model)
Assignment operator.
void free_members(void)
Delete class members.
std::string m_type
Spatial model type.
GModelPar m_lat
Declination or Galactic latitude (deg)
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Return MC sky direction.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
double value(void) const
Return parameter value.
GModelPar m_lon
Right Ascension or Galactic longitude (deg)
const std::string & unit(void) const
Return parameter unit.
Exception handler interface definition.
double dist(const GSkyDir &dir) const
Compute angular distance between sky directions in radians.
Abstract radial spatial model base class.
void init_members(void)
Initialise class members.
const GModelSpatialRadialRing g_radial_ring_seed
double radius(void) const
Return ring inner radius.
double m_last_radius
Last ring radius.
double m_inner_radius_rad
Inner radius in radians.
double m_cos_inner_radius_rad
Cosine of inner radius in radians.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
virtual void clear(void)
Clear radial ring model.
GModelSpatialRadialRing(void)
Void constructor.
const GXmlElement * xml_get_par(const std::string &origin, const GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
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.
void xml_check_type(const std::string &origin, GXmlElement &xml, const std::string &type)
Checks the model type.