43#define G_READ "GCTAPsf2D::read(GFitsTable&)"
44#define G_CONTAINMENT_RADIUS "GCTAPsf2D::containment_radius(double&,"\
45 " double&, double&, double&, double&, double&, bool&)"
191 const double& zenith,
192 const double& azimuth,
193 const bool& etrue)
const
195 #if defined(G_SMOOTH_PSF)
199 static const double offset = std::exp(-0.5*5.0*5.0);
212 double delta2 = delta * delta;
215 #if defined(G_SMOOTH_PSF)
216 psf = std::exp(
m_width1 * delta2) - offset;
234 #if defined(G_SMOOTH_PSF)
330 std::string msg =
"Expected two-dimensional point spread function "
331 "response table but found "+
333 " dimensions. Please specify a two-dimensional "
334 "point spread function.";
405 if (extname.empty()) {
458 table.extname(extname);
488 const double& zenith,
489 const double& azimuth,
490 const bool& etrue)
const
500 double sum = sum1 + sum2 + sum3;
502 if (sum2 > 0.0 && u >= sum2) {
505 else if (sum1 > 0.0 && u >= sum1) {
510 double delta = sigma * ran.
chisq2();
534 const double& zenith,
535 const double& azimuth,
536 const bool& etrue)
const
547 double radius = 5.0 * sigma;
590 const double& zenith,
591 const double& azimuth,
592 const bool& etrue)
const
596 const int itermax = 20;
597 const double convergence = 1.0e-6;
600 if (fraction <= 0.0 || fraction >= 1.0) {
601 std::string message =
"Containment fraction "+
603 "0.0 and 1.0, not inclusive.";
611 double amax =
delta_max(logE, theta, phi, zenith, azimuth, etrue);
612 double amin = 0.000001 * amax;
615 double a = 0.20 * amax;
624 for (; iter < itermax; ++iter) {
630 double exp1 = std::exp(
m_width1 * a2);
631 double exp2 = std::exp(
m_width2 * a2);
632 double exp3 = std::exp(
m_width3 * a2);
636 fa += norm1 * (1.0 - exp1);
637 fa += norm2 * (1.0 - exp2);
638 fa += norm3 * (1.0 - exp3);
643 if (std::abs(fa) < convergence) {
671 if (iter == itermax-1) {
672 std::string msg =
"Unable to converge within " +
698 result.append(
"=== GCTAPsf2D ===");
880 m_norm = (integral > 0.0) ? 1.0 / integral : 0.0;
#define G_CONTAINMENT_RADIUS
CTA 2D point spread function class definition.
Definition of support function used by CTA classes.
Exception handler interface definition.
Filename class interface definition.
FITS binary table class definition.
FITS file class interface definition.
Mathematical function definitions.
Random number generator class definition.
double sum(const GVector &vector)
Computes vector sum.
CTA 2D point spread function class.
int m_inx_sigma2
2nd Gaussian sigma
GCTAPsf2D & operator=(const GCTAPsf2D &psf)
Assignment operator.
double m_sigma3
Gaussian 3 sigma.
int m_inx_sigma3
3nd Gaussian sigma
double m_sigma2
Gaussian 2 sigma.
double m_par_theta
Cache offset angle.
double m_norm3
Gaussian 3 normalization.
void init_members(void)
Initialise class members.
GCTAPsf2D * clone(void) const
Clone point spread functions.
const GCTAResponseTable & table(void) const
Return response table.
void copy_members(const GCTAPsf2D &psf)
Copy class members.
double m_sigma1
Gaussian 1 sigma.
std::string print(const GChatter &chatter=NORMAL) const
Print point spread function information.
double m_norm2
Gaussian 2 normalization.
GCTAResponseTable m_psf
PSF response table.
double m_par_logE
Cache energy.
void free_members(void)
Delete class members.
double m_norm
Global normalization.
GFilename m_filename
Name of Aeff response file.
void save(const GFilename &filename, const bool &clobber=false) const
Save point spread function table into FITS file.
double m_width3
Gaussian 3 width.
int m_inx_theta
Theta index.
GFilename filename(void) const
Return filename.
void load(const GFilename &filename)
Load point spread function from FITS file.
double operator()(const double &delta, const double &logE, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0, const bool &etrue=true) const
Return point spread function (in units of sr^-1)
int m_inx_sigma1
1st Gaussian sigma
double m_width2
Gaussian 2 width.
void read(const GFitsTable &table)
Read point spread function from FITS table.
double containment_radius(const double &fraction, const double &logE, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0, const bool &etrue=true) const
Return the radius that contains a fraction of the events (radians)
double m_width1
Gaussian 1 width.
void update(const double &logE, const double &theta) const
Update PSF parameter cache.
GCTAPsf2D(void)
Void constructor.
int m_inx_energy
Energy index.
int m_inx_ampl3
3nd Gaussian relative amplitude
virtual ~GCTAPsf2D(void)
Destructor.
void write(GFitsBinTable &table) const
Write point spread function into FITS binary table.
void clear(void)
Clear point spread function.
double delta_max(const double &logE, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0, const bool &etrue=true) const
Return maximum size of PSF (radians)
int m_inx_ampl2
2nd Gaussian relative amplitude
double mc(GRan &ran, const double &logE, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0, const bool &etrue=true) const
Simulate PSF offset (radians)
Abstract base class for the CTA point spread function.
void free_members(void)
Delete class members.
void init_members(void)
Initialise class members.
GCTAPsf & operator=(const GCTAPsf &psf)
Assignment operator.
CTA response table class.
void read(const GFitsTable &table)
Read response table from FITS table HDU.
int table(const std::string &name) const
Determine index of table.
void axis_log10(const int &axis)
Set nodes for a logarithmic (base 10) axis.
const int & tables(void) const
Return number of tables.
void axis_radians(const int &axis)
Set nodes for a radians axis.
int axis(const std::string &name) const
Determine index of an axis.
const int & axes(void) const
Return number of axes of the tables.
void write(GFitsTable &table) const
Write response table into FITS table HDU.
int axis_bins(const int &axis) const
Return number bins in an axis.
const double & axis_hi(const int &axis, const int &bin) const
Return upper bin boundary for bin in axis.
void scale(const int &table, const double &scale)
Scale table.
void clear(void)
Clear response table.
const double & axis_lo(const int &axis, const int &bin) const
Return lower bin boundary for bin in axis.
std::string url(void) const
Return Uniform Resource Locator (URL)
std::string extname(const std::string &defaultname="") const
Return extension name.
void clear(void)
Clear file name.
Abstract interface for FITS table.
bool contains(const int &extno) const
Check if HDU exists in FITS file.
GFitsHDU * append(const GFitsHDU &hdu)
Append HDU to FITS file.
void close(void)
Close FITS file.
void remove(const int &extno)
Remove HDU from FITS file.
void save(const bool &clobber=false)
Saves FITS file.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
Random number generator class.
double chisq2(void)
Returns Chi2 deviates for 2 degrees of freedom.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
const std::string extname_cta_psf2d
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
std::string gadf_hduclas4(const GFits &fits, const std::string &hduclas4)
Return extension name for GADF response table of given HDU class 4.
void warning(const std::string &origin, const std::string &message)
Emits warning.