45 #define G_CONSTRUCTOR "GModelSpatialEllipticalDisk::"\
46 "GModelSpatialEllipticalDisk(GSkyDir&, double&, double&, "\
47 "double&, std::string&)"
48 #define G_READ "GModelSpatialEllipticalDisk::read(GXmlElement&)"
49 #define G_WRITE "GModelSpatialEllipticalDisk::write(GXmlElement&)"
97 const double& semimajor,
98 const double& semiminor,
99 const double& posangle,
100 const std::string& coordsys) :
104 if ((coordsys !=
"CEL") && (coordsys !=
"GAL")) {
105 std::string msg =
"Invalid coordinate system \""+coordsys+
"\" "
106 "specified. Please specify either \"CEL\" or "
115 if (coordsys ==
"CEL") {
205 if (
this != &model) {
318 const double& posangle,
321 const bool& gradients)
const
334 double cosinus =
std::cos(diff_angle);
335 double sinus =
std::sin(diff_angle);
342 value = (theta <= r_ell) ?
m_norm : 0.0;
345 #if defined(G_NAN_CHECK)
347 std::cout <<
"*** ERROR: GModelSpatialEllipticalDisk::eval";
348 std::cout <<
"(theta=" << theta <<
"): NaN/Inf encountered";
349 std::cout <<
"(posangle=" << posangle <<
"): NaN/Inf encountered";
350 std::cout <<
" (value=" << value;
351 std::cout <<
", R_ellipse=" << r_ell;
352 std::cout <<
", diff_angle=" << diff_angle;
353 std::cout <<
", m_norm=" <<
m_norm;
354 std::cout <<
")" << std::endl;
397 double phi = 360.0 * ran.
uniform();
409 return (photon.
dir());
427 const double& margin)
const
430 double distance = dir.
dist(this->
dir());
562 result.append(
"=== GModelSpatialEllipticalDisk ===");
567 for (
int i = 0; i <
size(); ++i) {
590 m_type =
"EllipticalDisk";
668 m_norm = (denom > 0.0) ? 1.0 / denom : 0.0;
GModelPar m_semimajor
Semi-major axis of ellipse (deg)
virtual void write(GXmlElement &xml) const
Write model into XML element.
void free_members(void)
Delete class members.
void update(void) const
Update precomputation cache.
Abstract elliptical spatial model base class.
const std::string & name(void) const
Return parameter name.
GModelPar m_lon
Right Ascension or Galactic longitude (deg)
virtual void set_region(void) const
Set boundary sky region.
int size(void) const
Return number of parameters.
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
GVector cos(const GVector &vector)
Computes cosine of vector elements.
Elliptical disk model class interface definition.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print information.
virtual double theta_max(void) const
Return maximum model radius (in radians)
virtual GModelSpatialElliptical & operator=(const GModelSpatialElliptical &model)
Assignment operator.
void init_members(void)
Initialise class members.
virtual void write(GXmlElement &xml) const
Write model into XML element.
void copy_members(const GModelSpatialEllipticalDisk &model)
Copy class members.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
const GSkyDir & dir(void) const
Return position of elliptical spatial model.
double acos(const double &arg)
Computes acos by avoiding NaN due to rounding errors.
Random number generator class.
GModelPar m_posangle
Position angle from North, counterclockwise (deg)
virtual void read(const GXmlElement &xml)
Read model from XML element.
Interface for the circular sky region class.
const GModelSpatialEllipticalDisk g_elliptical_disk_seed
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks where model contains specified sky direction.
double m_last_semiminor
Last semi-minor axis.
Interface definition for the spatial model registry class.
void free_members(void)
Delete class members.
void init_members(void)
Initialise class members.
GSkyRegionCircle m_region
Bounding circle.
bool is_notanumber(const double &x)
Signal if argument is not a number.
Class that handles photons.
bool is_infinite(const double &x)
Signal if argument is infinite.
double semiminor(void) const
Return semi-minor axis of ellipse.
GVector sqrt(const GVector &vector)
Computes square root of vector elements.
virtual GModelSpatialEllipticalDisk * clone(void) const
Clone elliptical disk model.
virtual void clear(void)
Clear elliptical disk model.
Radial disk model class interface definition.
double m_last_semimajor
Last semi-major axis.
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.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
Spatial model registry class definition.
GModelSpatialEllipticalDisk(void)
Void constructor.
const GTime & time(void) const
Return photon time.
double m_norm
Normalization.
virtual void read(const GXmlElement &xml)
Read model from XML element.
GModelPar m_semiminor
Semi-minor axis of ellipse (deg)
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.
double m_semimajor_rad
Radius in radians.
const GSkyRegion * region(void) const
Return boundary sky region.
void free_members(void)
Delete class members.
std::string m_type
Spatial model type.
double posangle(void) const
Return Position Angle of model.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
double value(void) const
Return parameter value.
GModelPar m_lat
Declination or Galactic latitude (deg)
GVector sin(const GVector &vector)
Computes sine of vector elements.
virtual double eval(const double &theta, const double &posangle, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
Evaluate function (in units of sr^-1)
const GEnergy & energy(void) const
Return photon energy.
Exception handler interface definition.
double dist(const GSkyDir &dir) const
Compute angular distance between sky directions in radians.
virtual GModelSpatialEllipticalDisk & operator=(const GModelSpatialEllipticalDisk &model)
Assignment operator.
virtual ~GModelSpatialEllipticalDisk(void)
Destructor.
void init_members(void)
Initialise class members.
virtual double eval(const double &theta, const double &posangle, const GEnergy &energy, const GTime &time, const bool &gradients=false) const =0
double m_semiminor_rad
Radius in radians.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
double semimajor(void) const
Return semi-major axis of ellipse.
const GSkyDir & dir(void) const
Return photon sky direction.
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.