From d43f11d95f0a7fb09b8e82c763d71998f15ada8d Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Sat, 28 Mar 2015 18:37:06 +0100 Subject: [PATCH] Add handling of background cube --- src/ctmodel/ctmodel.cpp | 15 +++++++++------ src/support/ctool.cpp | 2 +- test/test_ctmodel.py | 1 + 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/ctmodel/ctmodel.cpp b/src/ctmodel/ctmodel.cpp index eb1cb5e..b1a9f08 100644 --- a/src/ctmodel/ctmodel.cpp +++ b/src/ctmodel/ctmodel.cpp @@ -524,16 +524,19 @@ void ctmodel::get_obs(void) // Get response cube filenames std::string expcube = (*this)["expcube"].filename(); std::string psfcube = (*this)["psfcube"].filename(); + std::string bkgcube = (*this)["bkgcube"].filename(); // If the filenames are valid then build an observation from cube // response information - if ((expcube != "NONE") && (psfcube != "NONE") && + if ((expcube != "NONE") && (psfcube != "NONE") && (bkgcube != "NONE") && (gammalib::strip_whitespace(expcube) != "") && - (gammalib::strip_whitespace(psfcube) != "")) { + (gammalib::strip_whitespace(psfcube) != "") && + (gammalib::strip_whitespace(bkgcube) != "")) { - // Get exposure and PSF cubes - GCTACubeExposure exposure(expcube); - GCTACubePsf psf(psfcube); + // Get exposure, PSF and background cubes + GCTACubeExposure exposure(expcube); + GCTACubePsf psf(psfcube); + GCTACubeBackground background(bkgcube); // Create energy boundaries GEbounds ebounds = create_ebounds(); @@ -548,7 +551,7 @@ void ctmodel::get_obs(void) // Create CTA observation GCTAObservation cta; cta.events(cube); - cta.response(exposure, psf); + cta.response(exposure, psf, background); // Append observation to container m_obs.append(cta); diff --git a/src/support/ctool.cpp b/src/support/ctool.cpp index c169bc5..aabab4e 100644 --- a/src/support/ctool.cpp +++ b/src/support/ctool.cpp @@ -745,7 +745,7 @@ void ctool::set_obs_response(GCTAObservation* obs) (gammalib::strip_whitespace(psfcube) != "") && (gammalib::strip_whitespace(bkgcube) != "")) { - // Get exposure and PSF cubes + // Get exposure, PSF and background cubes GCTACubeExposure exposure(expcube); GCTACubePsf psf(psfcube); GCTACubeBackground background(bkgcube); diff --git a/test/test_ctmodel.py b/test/test_ctmodel.py index 92b2e4f..1fe30e9 100755 --- a/test/test_ctmodel.py +++ b/test/test_ctmodel.py @@ -72,6 +72,7 @@ class Test(gammalib.GPythonTestSuite): model["inobs"].filename("NONE") model["expcube"].filename("NONE") model["psfcube"].filename("NONE") + model["bkgcube"].filename("NONE") model["caldb"].string(self.caldb) model["irf"].string(self.irf) model["rad"].real(5.0) -- libgit2 0.21.4