Commit d43f11d95f0a7fb09b8e82c763d71998f15ada8d

Authored by Jürgen Knödlseder
1 parent 5367f517

Add handling of background cube

src/ctmodel/ctmodel.cpp
@@ -524,16 +524,19 @@ void ctmodel::get_obs(void) @@ -524,16 +524,19 @@ void ctmodel::get_obs(void)
524 // Get response cube filenames 524 // Get response cube filenames
525 std::string expcube = (*this)["expcube"].filename(); 525 std::string expcube = (*this)["expcube"].filename();
526 std::string psfcube = (*this)["psfcube"].filename(); 526 std::string psfcube = (*this)["psfcube"].filename();
  527 + std::string bkgcube = (*this)["bkgcube"].filename();
527 528
528 // If the filenames are valid then build an observation from cube 529 // If the filenames are valid then build an observation from cube
529 // response information 530 // response information
530 - if ((expcube != "NONE") && (psfcube != "NONE") && 531 + if ((expcube != "NONE") && (psfcube != "NONE") && (bkgcube != "NONE") &&
531 (gammalib::strip_whitespace(expcube) != "") && 532 (gammalib::strip_whitespace(expcube) != "") &&
532 - (gammalib::strip_whitespace(psfcube) != "")) { 533 + (gammalib::strip_whitespace(psfcube) != "") &&
  534 + (gammalib::strip_whitespace(bkgcube) != "")) {
533 535
534 - // Get exposure and PSF cubes  
535 - GCTACubeExposure exposure(expcube);  
536 - GCTACubePsf psf(psfcube); 536 + // Get exposure, PSF and background cubes
  537 + GCTACubeExposure exposure(expcube);
  538 + GCTACubePsf psf(psfcube);
  539 + GCTACubeBackground background(bkgcube);
537 540
538 // Create energy boundaries 541 // Create energy boundaries
539 GEbounds ebounds = create_ebounds(); 542 GEbounds ebounds = create_ebounds();
@@ -548,7 +551,7 @@ void ctmodel::get_obs(void) @@ -548,7 +551,7 @@ void ctmodel::get_obs(void)
548 // Create CTA observation 551 // Create CTA observation
549 GCTAObservation cta; 552 GCTAObservation cta;
550 cta.events(cube); 553 cta.events(cube);
551 - cta.response(exposure, psf); 554 + cta.response(exposure, psf, background);
552 555
553 // Append observation to container 556 // Append observation to container
554 m_obs.append(cta); 557 m_obs.append(cta);
src/support/ctool.cpp
@@ -745,7 +745,7 @@ void ctool::set_obs_response(GCTAObservation* obs) @@ -745,7 +745,7 @@ void ctool::set_obs_response(GCTAObservation* obs)
745 (gammalib::strip_whitespace(psfcube) != "") && 745 (gammalib::strip_whitespace(psfcube) != "") &&
746 (gammalib::strip_whitespace(bkgcube) != "")) { 746 (gammalib::strip_whitespace(bkgcube) != "")) {
747 747
748 - // Get exposure and PSF cubes 748 + // Get exposure, PSF and background cubes
749 GCTACubeExposure exposure(expcube); 749 GCTACubeExposure exposure(expcube);
750 GCTACubePsf psf(psfcube); 750 GCTACubePsf psf(psfcube);
751 GCTACubeBackground background(bkgcube); 751 GCTACubeBackground background(bkgcube);
test/test_ctmodel.py
@@ -72,6 +72,7 @@ class Test(gammalib.GPythonTestSuite): @@ -72,6 +72,7 @@ class Test(gammalib.GPythonTestSuite):
72 model["inobs"].filename("NONE") 72 model["inobs"].filename("NONE")
73 model["expcube"].filename("NONE") 73 model["expcube"].filename("NONE")
74 model["psfcube"].filename("NONE") 74 model["psfcube"].filename("NONE")
  75 + model["bkgcube"].filename("NONE")
75 model["caldb"].string(self.caldb) 76 model["caldb"].string(self.caldb)
76 model["irf"].string(self.irf) 77 model["irf"].string(self.irf)
77 model["rad"].real(5.0) 78 model["rad"].real(5.0)