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();
virtual ~GCTAEdispRmf(void)
Destructor.
int size(void) const
Return number of nodes in node array.
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.
Energy value class definition.
Random number generator class definition.
Sparse matrix class interface definition.
void clear(void)
Clear instance.
void set_max_edisp(void)
Set maximum energy dispersion value.
int size(void) const
Return number of energy boundaries.
int m_itrue2
Index of right Etrue.
void free_members(void)
Delete class members.
const double & wgt_left(void) const
Returns left node weight.
Abstract base class for the CTA energy dispersion.
void clear(void)
Clear node array.
CTA Redistribution Matrix File (RMF) energy dispersion class.
double TeV(void) const
Return energy in TeV.
double sum(const GVector &vector)
Computes vector sum.
double log10TeV(void) const
Return log10 of energy in TeV.
Random number generator class.
void init_members(void)
Initialise class members.
double MeV(void) const
Return energy in MeV.
double m_wgt3
Weight of lower right node.
GCTAEdispRmf(void)
Void constructor.
int nmeasured(void) const
Return number of measured energy bins in redistribution matrix.
void set_value(const double &value) const
Set indices and weighting factors for interpolation.
virtual void clear(void)
Clear matrix.
void copy_members(const GCTAEdispRmf &psf)
Copy class members.
void free_members(void)
Delete 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.
const GEbounds & emeasured(void) const
Return measured energy boundaries.
void compute_ereco_bounds(void) const
Compute m_ereco_bounds vector.
GMatrixSparse m_matrix
Normalised redistribution matrix.
int m_itrue1
Index of left Etrue.
GEnergy m_last_ereco
Last reconstructed energy.
Node array class interface definition.
XSPEC Redistribution Matrix File class definition.
const double & wgt_right(void) const
Returns right node weight.
Energy boundaries container class.
Single parameter function abstract base class definition.
std::string print(const GChatter &chatter=NORMAL) const
Print energy.
GFilename m_filename
Name of response file.
const int & rows(void) const
Return number of matrix rows.
std::vector< GEbounds > m_etrue_bounds
const GEnergy & emin(void) const
Return minimum energy of all intervals.
GNodeArray m_etrue
Array of log10(Etrue)
double uniform(void)
Returns random double precision floating value in range 0 to 1.
GCTAEdispRmf & operator=(const GCTAEdispRmf &edisp)
Assignment operator.
CTA RMF energy dispersion class definition.
int ntrue(void) const
Return number of true energy bins in 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.
GEnergy elogmean(const int &index) const
Returns logarithmic mean energy for a given energy interval.
const int & inx_left(void) const
Returns left node index.
bool m_ereco_bounds_computed
void clear(void)
Clear object.
void load(const GFilename &filename)
Load energy dispersion from RMF file.
GFilename filename(void) const
Return filename.
const int & inx_right(void) const
Returns right node index.
GCTAEdispRmf * clone(void) const
Clone instance.
int m_ireco2
Index of right Ereco.
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 .
GCTAEdisp & operator=(const GCTAEdisp &edisp)
Assignment operator.
bool m_etrue_bounds_computed
void set_cache(void) const
Set interpolation cache.
void clear(void)
Clear file name.
void update(const GEnergy &ereco, const GEnergy &etrue) const
Update cache.
GEnergy m_last_etrue
Last true energy.
double m_wgt1
Weight of lower left node.
Sparse matrix class definition.
double m_wgt2
Weight of upper left node.
void compute_etrue_bounds(void) const
Compute m_etrue_bounds vector.
GEnergy m_last_etrue_bounds
void init_members(void)
Initialise class members.
GNodeArray m_ereco
Array of log10(Ereco)
GEnergy m_last_ereco_bounds
const GEnergy & emax(void) const
Return maximum energy of all intervals.
const GEbounds & etrue(void) const
Return true energy boundaries.
int m_ireco1
Index of left Ereco.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
void append(const double &node)
Append one node to array.
double m_wgt4
Weight of upper right node.
void set_matrix(void)
Set redistribution matrix.
GRmf m_rmf
Redistribution matrix file.
double m_max_edisp
Maximum energy dispersion value for MC.
Integration class interface definition.
std::vector< GEbounds > m_ereco_bounds
const int & columns(void) const
Return number of matrix columns.
std::string print(const GChatter &chatter=NORMAL) const
Print RMF information.
void clear(void)
Clear instance.
Filename class interface definition.
void load(const GFilename &filename)
Load Redistribution Matrix File.
Mathematical function definitions.
Class that handles energies in a unit independent way.
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.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.