From ab65d3fcae067f9378be8bee75009013ea88d6d5 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Wed, 2 Dec 2020 08:14:08 +0100 Subject: [PATCH] Remove GCTAEventBin::emin() and emax() methods (no interface change in bugfix release) --- inst/cta/include/GCTAEventBin.hpp | 16 ---------------- inst/cta/pyext/GCTAEventBin.i | 2 -- inst/cta/src/GCTAEventBin.cpp | 34 ---------------------------------- inst/cta/src/GCTAModelIrfBackground.cpp | 21 +++++++++++++++++---- inst/cta/test/test_CTA.cpp | 2 -- 5 files changed, 17 insertions(+), 58 deletions(-) diff --git a/inst/cta/include/GCTAEventBin.hpp b/inst/cta/include/GCTAEventBin.hpp index b1cbeb4..bae035d 100644 --- a/inst/cta/include/GCTAEventBin.hpp +++ b/inst/cta/include/GCTAEventBin.hpp @@ -80,8 +80,6 @@ public: const int& ipix(void) const; const int& ieng(void) const; const double& solidangle(void) const; - GEnergy emin(void) const; - GEnergy emax(void) const; const GEnergy& ewidth(void) const; const double& ontime(void) const; const double& weight(void) const; @@ -187,18 +185,4 @@ void GCTAEventBin::ieng(const int& ieng) return; } - -/***********************************************************************//** - * @brief Return maximum energy of event bin - * - * @return Maximum energy of event bin. - * - * Returns the maximum energy of event bin. - ***************************************************************************/ -inline -GEnergy GCTAEventBin::emax(void) const -{ - return (emin() + ewidth()); -} - #endif /* GCTAEVENTBIN_HPP */ diff --git a/inst/cta/pyext/GCTAEventBin.i b/inst/cta/pyext/GCTAEventBin.i index 2b6e217..545360b 100644 --- a/inst/cta/pyext/GCTAEventBin.i +++ b/inst/cta/pyext/GCTAEventBin.i @@ -61,8 +61,6 @@ public: const int& ipix(void) const; const int& ieng(void) const; const double& solidangle(void) const; - GEnergy emin(void) const; - GEnergy emax(void) const; const GEnergy& ewidth(void) const; const double& ontime(void) const; const double& weight(void) const; diff --git a/inst/cta/src/GCTAEventBin.cpp b/inst/cta/src/GCTAEventBin.cpp index 81c3f78..23acacd 100644 --- a/inst/cta/src/GCTAEventBin.cpp +++ b/inst/cta/src/GCTAEventBin.cpp @@ -342,40 +342,6 @@ const double& GCTAEventBin::solidangle(void) const /***********************************************************************//** - * @brief Return minimum energy of event bin - * - * @return Minimum energy of event bin - * - * Returns minimum energy of event bin, computed using - * - * \f[ - * E_{\rm min} = \frac{-\Delta E + sqrt{\Delta E^2 + 4 E^2}}{2} - * \f] - * - * where - * \f$\Delta E\f$ is the energy bin width, returned by ewidth() and - * \f$E\f$ is the energy, returned by energy(). - ***************************************************************************/ -GEnergy GCTAEventBin::emin(void) const -{ - // Get energy and energy width in MeV - double energy = this->energy().MeV(); - double ewidth = this->ewidth().MeV(); - - // Compute minimum energy in MeV - double arg = ewidth * ewidth + 4.0 * energy * energy; - double e_min = 0.5 * (-ewidth + std::sqrt(arg)); - - // Set minimum energy - GEnergy emin; - emin.MeV(e_min); - - // Return minimum energy - return emin; -} - - -/***********************************************************************//** * @brief Return energy width of event bin * * @return Energy width of event bin diff --git a/inst/cta/src/GCTAModelIrfBackground.cpp b/inst/cta/src/GCTAModelIrfBackground.cpp index 250bca6..3c9baa2 100644 --- a/inst/cta/src/GCTAModelIrfBackground.cpp +++ b/inst/cta/src/GCTAModelIrfBackground.cpp @@ -360,11 +360,24 @@ double GCTAModelIrfBackground::eval(const GEvent& event, spat = bgd(logE, inst_dir.detx(), inst_dir.dety()); } else { + // Get pointer to event bin const GCTAEventBin* bin = static_cast(&event); - GEnergy emin = bin->emin(); - GEnergy emax = emin + bin->ewidth(); - double norm = 1.0 / bin->ewidth().MeV(); - spat = bgd.rate_ebin(inst_dir, emin, emax) * norm; + + // Get energy and energy width in MeV + double energy = bin->energy().MeV(); + double ewidth = bin->ewidth().MeV(); + + // Compute minimum energy in MeV + double arg = ewidth * ewidth + 4.0 * energy * energy; + double e_min = 0.5 * (-ewidth + std::sqrt(arg)); + + // Set minimum and maximumenergy + GEnergy emin; + emin.MeV(e_min); + GEnergy emax = emin + bin->ewidth(); + + // Compute spatial component + spat = bgd.rate_ebin(inst_dir, emin, emax) / ewidth; } #else double logE = event.energy().log10TeV(); diff --git a/inst/cta/test/test_CTA.cpp b/inst/cta/test/test_CTA.cpp index f11978d..32fc81d 100644 --- a/inst/cta/test/test_CTA.cpp +++ b/inst/cta/test/test_CTA.cpp @@ -2229,8 +2229,6 @@ void TestGCTAObservation::test_event_bin(void) test_value(bin.ieng(), 7, "Check ieng() for filled bin"); test_value(bin.solidangle(), 3.14, 1.0e-10, "Check solidangle() for filled bin"); - test_value(bin.emin().TeV(), 1.996503, "Check emin() for filled bin"); - test_value(bin.emax().TeV(), 2.003503, "Check emax() for filled bin"); test_value(bin.ewidth().GeV(), 7.0, 1.0e-10, "Check ewidth() for filled bin"); test_value(bin.ontime(), 101.0, 1.0e-10, "Check ontime() for filled bin"); -- libgit2 0.21.4