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