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) :
105 std::string msg =
"Invalid coordinate system \""+
coordsys+
"\" "
106 "specified. Please specify either \"CEL\" or "
205 if (
this != &model) {
329 const double& posangle,
332 const bool& gradients)
const
346 double term1 =
m_term1 * cosphi * cosphi;
347 double term2 =
m_term2 * sinphi * sinphi;
348 double term3 =
m_term3 * sinphi * cosphi;
349 double theta0 = std::sqrt(1.0/(term1 + term2 + term3));
352 value = (theta <= theta0) ?
m_norm : 0.0;
355 #if defined(G_NAN_CHECK)
357 std::cout <<
"*** ERROR: GModelSpatialEllipticalDisk::eval";
358 std::cout <<
"(theta=" << theta <<
"): NaN/Inf encountered";
359 std::cout <<
"(posangle=" <<
posangle <<
"): NaN/Inf encountered";
360 std::cout <<
" (value=" << value;
361 std::cout <<
", m_term1=" <<
m_term1;
362 std::cout <<
", m_term2=" <<
m_term2;
363 std::cout <<
", m_term3=" <<
m_term3;
364 std::cout <<
", m_norm=" <<
m_norm;
365 std::cout <<
")" << std::endl;
406 double theta = std::acos(1.0 - ran.
uniform() * (1.0 - cosrad)) *
408 double phi = 360.0 * ran.
uniform();
420 return (photon.
dir());
437 const double& margin)
const
572 result.append(
"=== GModelSpatialEllipticalDisk ===");
577 for (
int i = 0; i <
size(); ++i) {
600 m_type =
"EllipticalDisk";
693 bool changed =
false;
717 m_norm = (denom > 0.0) ? 1.0 / denom : 0.0;
734 double cospos = std::cos(posangle_rad);
735 double sinpos = std::sin(posangle_rad);
740 m_sin2pos = std::sin(2.0 * posangle_rad);
Exception handler interface definition.
Mathematical function definitions.
const GModelSpatialEllipticalDisk g_elliptical_disk_seed
Elliptical disk model class interface definition.
Radial disk 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_last_major
Last semi-major axis.
virtual void set_region(void) const
Set boundary sky region.
virtual GModelSpatialEllipticalDisk * clone(void) const
Clone elliptical disk model.
double m_term2
Help term 2.
double m_term1
Help term 1.
double m_minor_rad
Minor axis in radians.
virtual void write(GXmlElement &xml) const
Write model into XML element.
double m_norm
Normalization.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks where model contains specified sky direction.
void init_members(void)
Initialise class members.
double m_cospos2
squared cosine of position angle
double m_last_minor
Last semi-minor axis.
double m_major_rad
Major axis in radians.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print information.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
double m_major2
square of major axis
void copy_members(const GModelSpatialEllipticalDisk &model)
Copy class members.
virtual GModelSpatialEllipticalDisk & operator=(const GModelSpatialEllipticalDisk &model)
Assignment operator.
double m_sinpos2
squared sine of position angle
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)
double m_term3
Help term 3.
double m_sin2pos
sine of twice the position angle
virtual ~GModelSpatialEllipticalDisk(void)
Destructor.
virtual void clear(void)
Clear elliptical disk model.
virtual double theta_max(void) const
Return maximum model radius (in radians)
double m_last_posangle
Last position angle.
void update(void) const
Update precomputation cache.
void free_members(void)
Delete class members.
double m_minor2
square of minor axis
GModelSpatialEllipticalDisk(void)
Void constructor.
virtual void read(const GXmlElement &xml)
Read model from XML element.
Abstract elliptical spatial model base class.
void init_members(void)
Initialise class members.
GModelPar m_semiminor
Semi-minor axis of ellipse (deg)
double semimajor(void) const
Return semi-major axis of ellipse.
virtual void write(GXmlElement &xml) const
Write model into XML element.
GModelPar m_semimajor
Semi-major axis of ellipse (deg)
GModelPar m_lat
Declination or Galactic latitude (deg)
virtual double eval(const double &theta, const double &posangle, const GEnergy &energy, const GTime &time, const bool &gradients=false) const =0
void free_members(void)
Delete class members.
double posangle(void) const
Return Position Angle of model.
virtual GModelSpatialElliptical & operator=(const GModelSpatialElliptical &model)
Assignment operator.
GModelPar m_lon
Right Ascension or Galactic longitude (deg)
const GSkyDir & dir(void) const
Return position of elliptical spatial model.
std::string coordsys(void) const
Return coordinate system.
double semiminor(void) const
Return semi-minor axis of ellipse.
virtual void read(const GXmlElement &xml)
Read model from XML element.
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.
const std::string & name(void) const
Return parameter name.
Class that handles photons.
const GTime & time(void) const
Return photon time.
const GSkyDir & dir(void) const
Return photon sky direction.
const GEnergy & energy(void) const
Return photon energy.
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.