45#define G_LOAD "GCTAEdispRmf::load(GFilename&)"
46#define G_MC "GCTAEdispRmf::mc(GRan&, GEnergy&, double&, double&, double&, "\
144 if (
this != &edisp) {
190 const double& zenith,
191 const double& azimuth)
const
300 const double& zenith,
301 const double& azimuth)
const
308 double emin = ebounds.
emin().
TeV();
309 double emax = ebounds.
emax().
TeV();
315 if (max_edisp <= 0.0) {
316 std::string msg =
"Energy dispersion matrix is empty. Please provide "
317 "a valid energy dispersion matrix.";
322 double ewidth = emax - emin;
323 if (max_edisp > 0.0) {
328 f =
operator()(ereco, etrue, theta, phi, zenith, azimuth);
329 ftest = ran.
uniform() * max_edisp;
354 const double& zenith,
355 const double& azimuth)
const
376 double etrue_TeV = etrue.
TeV();
381 while ((high-low) > 1) {
382 int mid = (low+high) / 2;
418 const double& zenith,
419 const double& azimuth)
const
440 double ereco_TeV = ereco.
TeV();
445 while ((high-low) > 1) {
446 int mid = (low+high) / 2;
490 const double& theta)
const
497 #if defined(G_LINEAR_ERECO_INTERPOLATION)
498 double logEobs_min = ereco_min.
TeV();
499 double logEobs_max = ereco_max.
TeV();
501 double logEobs_min = ereco_min.
log10TeV();
502 double logEobs_max = ereco_max.
log10TeV();
524 if (
m_ereco[i] <= logEobs_min) {
530 if (
m_ereco[i] > logEobs_max) {
537 #if defined(G_LINEAR_ERECO_INTERPOLATION)
542 f2 = wgt_left *
m_matrix(inx_left, i) +
550 prob += 0.5 * (f1 + f2) * (x2.
MeV() - x1.
MeV());
557 if (
m_ereco[i] > logEobs_max) {
565 if (x1 < ereco_max) {
568 prob += 0.5 * (f1 + f2) * (x2.
MeV() - x1.
MeV());
591 result.append(
"=== GCTAEdispRmf ===");
601 result.append(
" - ");
605 result.append(
" - ");
730 for (
int ireco = 0; ireco < columns; ++ireco) {
733 double ewidth = ebounds.
emax(ireco).
MeV() - ebounds.
emin(ireco).
MeV();
739 for (
int itrue = 0; itrue < rows; ++itrue) {
747 std::vector<double> row_sums(rows, 0.0);
750 for (
int itrue = 0; itrue < rows; ++itrue) {
760 for (
int i = 0; i < ebounds.
size(); ++i) {
765 row_sums.push_back(
sum);
770 for (
int itrue = 0; itrue < rows; ++itrue) {
771 double sum = row_sums[itrue];
773 for (
int ireco = 0; ireco < columns; ++ireco) {
802 #if defined(G_LINEAR_ERECO_INTERPOLATION)
825 double value =
m_matrix(itrue, ireco);
858 #if defined(G_LINEAR_ERECO_INTERPOLATION)
859 double logEobs = ereco.
TeV();
CTA RMF energy dispersion class definition.
Energy value class definition.
Filename class interface definition.
Single parameter function abstract base class definition.
Integration class interface definition.
Mathematical function definitions.
Sparse matrix class definition.
Node array class interface definition.
Random number generator class definition.
XSPEC Redistribution Matrix File class definition.
double sum(const GVector &vector)
Computes vector sum.
CTA Redistribution Matrix File (RMF) energy dispersion class.
bool m_ereco_bounds_computed
int m_itrue2
Index of right Etrue.
void compute_ereco_bounds(void) const
Compute m_ereco_bounds vector.
bool m_etrue_bounds_computed
void compute_etrue_bounds(void) const
Compute m_etrue_bounds vector.
GCTAEdispRmf & operator=(const GCTAEdispRmf &edisp)
Assignment operator.
GCTAEdispRmf(void)
Void constructor.
GNodeArray m_ereco
Array of log10(Ereco)
GFilename filename(void) const
Return filename.
std::vector< GEbounds > m_ereco_bounds
double operator()(const GEnergy &ereco, const GEnergy &etrue, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0) const
Return energy dispersion in units of MeV .
int m_itrue1
Index of left Etrue.
double m_wgt3
Weight of lower right node.
void set_cache(void) const
Set interpolation cache.
GNodeArray m_etrue
Array of log10(Etrue)
void set_max_edisp(void)
Set maximum energy dispersion value.
virtual ~GCTAEdispRmf(void)
Destructor.
double m_wgt2
Weight of upper left node.
void init_members(void)
Initialise class members.
void set_matrix(void)
Set redistribution matrix.
GEbounds ereco_bounds(const GEnergy &etrue, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0) const
Return observed energy interval that contains the energy dispersion.
GRmf m_rmf
Redistribution matrix file.
std::vector< GEbounds > m_etrue_bounds
GEnergy m_last_etrue
Last true energy.
GEbounds etrue_bounds(const GEnergy &ereco, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0) const
Return true energy interval that contains the energy dispersion.
double m_wgt1
Weight of lower left node.
GCTAEdispRmf * clone(void) const
Clone instance.
std::string print(const GChatter &chatter=NORMAL) const
Print RMF information.
int m_ireco1
Index of left Ereco.
GFilename m_filename
Name of response file.
void load(const GFilename &filename)
Load energy dispersion from RMF file.
GMatrixSparse m_matrix
Normalised redistribution matrix.
GEnergy m_last_ereco_bounds
void copy_members(const GCTAEdispRmf &psf)
Copy class members.
GEnergy mc(GRan &ran, const GEnergy &etrue, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0) const
Simulate energy dispersion.
double prob_erecobin(const GEnergy &ereco_min, const GEnergy &ereco_max, const GEnergy &etrue, const double &theta) const
Return energy dispersion probability for reconstructed energy interval.
void update(const GEnergy &ereco, const GEnergy &etrue) const
Update cache.
GEnergy m_last_ereco
Last reconstructed energy.
GEnergy m_last_etrue_bounds
int m_ireco2
Index of right Ereco.
double m_max_edisp
Maximum energy dispersion value for MC.
void clear(void)
Clear instance.
double m_wgt4
Weight of upper right node.
void free_members(void)
Delete class members.
Abstract base class for the CTA energy dispersion.
GCTAEdisp & operator=(const GCTAEdisp &edisp)
Assignment operator.
void free_members(void)
Delete class members.
void init_members(void)
Initialise class members.
Energy boundaries container class.
const GEnergy & emax(void) const
Return maximum energy of all intervals.
int size(void) const
Return number of energy boundaries.
GEnergy elogmean(const int &index) const
Returns logarithmic mean energy for a given energy interval.
const GEnergy & emin(void) const
Return minimum energy of all intervals.
Class that handles energies in a unit independent way.
double log10TeV(void) const
Return log10 of energy in TeV.
double MeV(void) const
Return energy in MeV.
std::string print(const GChatter &chatter=NORMAL) const
Print energy.
void clear(void)
Clear instance.
double TeV(void) const
Return energy in TeV.
void clear(void)
Clear file name.
const int & rows(void) const
Return number of matrix rows.
const int & columns(void) const
Return number of matrix columns.
Sparse matrix class interface definition.
virtual void clear(void)
Clear matrix.
void set_value(const double &value) const
Set indices and weighting factors for interpolation.
const int & inx_right(void) const
Returns right node index.
const int & inx_left(void) const
Returns left node index.
const double & wgt_right(void) const
Returns right node weight.
const double & wgt_left(void) const
Returns left node weight.
void clear(void)
Clear node array.
int size(void) const
Return number of nodes in node array.
void append(const double &node)
Append one node to array.
Random number generator class.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
const GEbounds & etrue(void) const
Return true energy boundaries.
const GEbounds & emeasured(void) const
Return measured energy boundaries.
int nmeasured(void) const
Return number of measured energy bins in redistribution matrix.
void clear(void)
Clear object.
int ntrue(void) const
Return number of true energy bins in redistribution matrix.
void load(const GFilename &filename)
Load Redistribution Matrix File.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.