42#if defined(G_LEGACY_XML_FORMAT)
48#define G_CONSTRUCTOR "GModelSpatialRadialShell::GModelSpatialRadialShell("\
49 "GSkyDir&, double&, double&, std::string&)"
50#define G_MC "GModelSpatialRadialShell::mc(GEnergy&, GTime&, GRan&)"
51#define G_READ "GModelSpatialRadialShell::read(GXmlElement&)"
52#define G_WRITE "GModelSpatialRadialShell::write(GXmlElement&)"
92 const std::string& type) :
123 const double& radius,
125 const std::string& coordsys) :
130 std::string msg =
"Invalid coordinate system \""+
coordsys+
"\" "
131 "specified. Please specify either \"CEL\" or "
229 if (
this != &model) {
330 const bool& gradients)
const
336 double x = std::sin(theta);
342 result = std::sqrt(
m_x_out - x);
344 result -= std::sqrt(
m_x_in - x);
350 #if defined(G_NAN_CHECK)
352 std::cout <<
"*** ERROR: GModelSpatialRadialShell::eval";
353 std::cout <<
"(theta=" << theta <<
"): NaN/Inf encountered";
354 std::cout <<
" (result=" << result;
355 std::cout <<
", m_norm=" <<
m_norm;
356 std::cout <<
", x=" << x;
357 std::cout <<
", m_x_out=" <<
m_x_out;
358 std::cout <<
", m_x_in=" <<
m_x_in;
359 std::cout <<
")" << std::endl;
389 #if defined(G_DEBUG_MC)
399 std::string msg =
"Non positive maximum radial shell model value.";
406 value =
eval(theta, energy, time) * std::sin(theta);
408 #if defined(G_DEBUG_MC)
412 #if defined(G_DEBUG_MC)
413 std::cout <<
"#=" << n_samples <<
" ";
417 double phi = 360.0 * ran.
uniform();
438 const double& margin)
const
561 result.append(
"=== GModelSpatialRadialShell ===");
566 for (
int i = 0; i <
size(); ++i) {
717 m_norm = (denom > 0.0) ? 1.0 / denom : 0.0;
718 m_x_in = sin_theta_in * sin_theta_in;
719 m_x_out = sin_theta_out * sin_theta_out;
724 #if defined(G_NAN_CHECK)
726 std::cout <<
"*** ERROR: GModelSpatialRadialShell::update:";
727 std::cout <<
" NaN/Inf encountered";
728 std::cout <<
" (m_norm=" <<
m_norm;
729 std::cout <<
", radius=" <<
radius();
730 std::cout <<
", width=" <<
width();
736 std::cout <<
")" << std::endl;
753 double f1 = std::sqrt(1.0 - std::cos(2.0 * x));
771 double t1 = (1.0 + std::cos(2.0*x)) / 4.0;
774 double f2 = t1 * std::log(t2 / t3);
Exception handler interface definition.
Mathematical function definitions.
const GModelSpatialRadialShell g_radial_shell_seed
Radial shell model class interface definition.
Spatial model registry class definition.
Class that handles energies in a unit independent way.
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
double m_x_out
sin(m_theta_out)^2
double radius(void) const
Return shell radius.
void copy_members(const GModelSpatialRadialShell &model)
Copy class members.
virtual GModelSpatialRadialShell * clone(void) const
Clone radial shell model.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print information.
void free_members(void)
Delete class members.
double m_last_radius
Last shell radius (deg)
void update(void) const
Update precomputation cache.
double m_last_width
Last shell width (deg)
virtual ~GModelSpatialRadialShell(void)
Destructor.
GModelPar m_width
Shell thickness (deg)
static double f1(double x)
Return function 1 value needed for precomputation.
double m_x_in
sin(m_theta_in)^2
void init_members(void)
Initialise class members.
virtual void set_region(void) const
Set boundary sky region.
GModelPar m_radius
Inner shell radius (deg)
virtual double eval(const double &theta, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
Evaluate function (in units of sr^-1)
virtual void clear(void)
Clear radial shell model.
double m_norm
Shell normalization.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
virtual double theta_max(void) const
Return maximum model radius (in radians)
double width(void) const
Return shell width.
double m_theta_in
Inner shell radius (rad)
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks where model contains specified sky direction.
virtual GModelSpatialRadialShell & operator=(const GModelSpatialRadialShell &model)
Assignment operator.
virtual void write(GXmlElement &xml) const
Write model into XML element.
GModelSpatialRadialShell(void)
Void constructor.
double m_theta_out
Outer shell radius (rad)
virtual void read(const GXmlElement &xml)
Read model from XML element.
static double f2(double x)
Return function 2 value needed for precomputation.
Abstract radial spatial model base class.
void free_members(void)
Delete class members.
GModelPar m_lon
Right Ascension or Galactic longitude (deg)
virtual void write(GXmlElement &xml) const
Write model into XML element.
virtual void read(const GXmlElement &xml)
Read model from XML element.
std::string coordsys(void) const
Return coordinate system.
void init_members(void)
Initialise class members.
virtual GModelSpatialRadial & operator=(const GModelSpatialRadial &model)
Assignment operator.
const GSkyDir & dir(void) const
Return position of radial spatial model.
GModelPar m_lat
Declination or Galactic latitude (deg)
Interface definition for the spatial model registry class.
std::string m_type
Spatial model type.
std::string type(void) const
Return model type.
const GSkyRegion * region(void) const
Return boundary sky region.
std::vector< GModelPar * > m_pars
Parameter pointers.
void init_members(void)
Initialise class members.
int size(void) const
Return number of parameters.
void free_members(void)
Delete class members.
GSkyRegionCircle m_region
Bounding circle.
void free(void)
Free a parameter.
const double & scale(void) const
Return parameter scale.
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
const std::string & unit(void) const
Return parameter unit.
double min(void) const
Return parameter minimum boundary.
double gradient(void) const
Return parameter gradient.
void clear(void)
Clear parameter.
double value(void) const
Return parameter value.
const std::string & name(void) const
Return parameter name.
Random number generator class.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
void rotate_deg(const double &phi, const double &theta)
Rotate sky direction by zenith and azimuth angle.
double dist(const GSkyDir &dir) const
Compute angular distance between sky directions in radians.
Interface for the circular sky region class.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
bool is_infinite(const double &x)
Signal if argument is infinite.
bool is_notanumber(const double &x)
Signal if argument is not a number.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
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.
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
void xml_check_parnum(const std::string &origin, const GXmlElement &xml, const int &number)
Checks number of parameters.
void xml_check_type(const std::string &origin, GXmlElement &xml, const std::string &type)
Checks the model type.