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) :
129 if ((coordsys !=
"CEL") && (coordsys !=
"GAL")) {
130 std::string msg =
"Invalid coordinate system \""+coordsys+
"\" "
131 "specified. Please specify either \"CEL\" or "
140 if (coordsys ==
"CEL") {
229 if (
this != &model) {
330 const bool& gradients)
const
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.";
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
441 double distance = dir.
dist(this->
dir());
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();
733 std::cout <<
", term1=" << (
f1(m_theta_out) -
f1(m_theta_in)) * c2;
734 std::cout <<
", term2=" <<
f2(m_theta_out);
735 std::cout <<
", term3=" <<
f2(m_theta_in);
736 std::cout <<
")" << std::endl;
771 double t1 = (1.0 +
std::cos(2.0*x)) / 4.0;
double width(void) const
Return shell width.
GModelPar m_width
Shell thickness (deg)
virtual GModelSpatialRadialShell & operator=(const GModelSpatialRadialShell &model)
Assignment operator.
Radial shell model class interface definition.
const std::string & name(void) const
Return parameter name.
double gradient(void) const
Return parameter gradient.
int size(void) const
Return number of parameters.
double m_last_width
Last shell width (deg)
void init_members(void)
Initialise class members.
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
GVector cos(const GVector &vector)
Computes cosine of vector elements.
const GModelSpatialRadialShell g_radial_shell_seed
virtual void set_region(void) const
Set boundary sky region.
virtual void read(const GXmlElement &xml)
Read model from XML element.
Random number generator class.
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.
static double f2(double x)
Return function 2 value needed for precomputation.
GSkyRegionCircle m_region
Bounding circle.
bool is_notanumber(const double &x)
Signal if argument is not a number.
double m_x_in
sin(m_theta_in)^2
const double & scale(void) const
Return parameter scale.
bool is_infinite(const double &x)
Signal if argument is infinite.
double radius(void) const
Return shell radius.
void free_members(void)
Delete class members.
GVector sqrt(const GVector &vector)
Computes square root of vector elements.
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
void copy_members(const GModelSpatialRadialShell &model)
Copy class members.
void update(void) const
Update precomputation cache.
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.
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.
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
void clear(void)
Clear parameter.
virtual double theta_max(void) const
Return maximum model radius (in radians)
virtual void write(GXmlElement &xml) const
Write model into XML element.
virtual ~GModelSpatialRadialShell(void)
Destructor.
Spatial model registry class definition.
virtual GModelSpatialRadialShell * clone(void) const
Clone radial shell model.
double m_last_radius
Last shell radius (deg)
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks where model contains specified sky direction.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
std::string type(void) const
Return model type.
GModelPar m_radius
Inner shell radius (deg)
void xml_check_parnum(const std::string &origin, const GXmlElement &xml, const int &number)
Checks number of parameters.
virtual void write(GXmlElement &xml) const
Write model into XML element.
GModelSpatialRadialShell(void)
Void constructor.
virtual void clear(void)
Clear radial shell model.
double m_theta_in
Inner shell radius (rad)
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 double eval(const double &theta, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
Evaluate function (in units of sr^-1)
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.
double m_theta_out
Outer shell radius (rad)
GVector sin(const GVector &vector)
Computes sine of vector elements.
Exception handler interface definition.
double dist(const GSkyDir &dir) const
Compute angular distance between sky directions in radians.
static double f1(double x)
Return function 1 value needed for precomputation.
Abstract radial spatial model base class.
void init_members(void)
Initialise class members.
double m_norm
Shell normalization.
double m_x_out
sin(m_theta_out)^2
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
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.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print information.
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.