Commit 1eac539098c8b91fd199d00ccb0c3ac02e6d021d

Authored by Jürgen Knödlseder
1 parent 55a5da08

Correct background rate interpolation in GCTACubeBackground::operator() (#2268)

inst/cta/src/GCTACubeBackground.cpp
... ... @@ -257,9 +257,14 @@ double GCTACubeBackground::operator()(const GCTAInstDir& dir,
257 257 // Set indices and weighting factors for interpolation
258 258 update(energy.log10TeV());
259 259  
260   - // Perform interpolation
261   - double background = m_wgt_left * m_cube(dir.dir(), m_inx_left) +
262   - m_wgt_right * m_cube(dir.dir(), m_inx_right);
  260 + // Perform logarithmic interpolation
  261 + double background = 0.0;
  262 + double background_left = m_cube(dir.dir(), m_inx_left);
  263 + double background_right = m_cube(dir.dir(), m_inx_right);
  264 + if (background_left > 0.0 && background_right > 0.0) {
  265 + background = std::exp(m_wgt_left * std::log(background_left) +
  266 + m_wgt_right * std::log(background_right));
  267 + }
263 268  
264 269 // Make sure that background rate does not become negative
265 270 if (background < 0.0) {
... ... @@ -330,9 +335,9 @@ void GCTACubeBackground::fill(const GObservations&amp; obs, GLog* log)
330 335 ebounds.append(m_energies[i], m_energies[i]);
331 336 }
332 337  
333   - // Set dummy GTI needed to genrate an event cube. It is not important what
334   - // the actually value is since it will be overwritten later in any case,
335   - // but it's important that there is one time slice
  338 + // Set dummy GTI needed to generate an event cube. It is not important
  339 + // what the actually value is since it will be overwritten later in any
  340 + // case, but it's important that there is one time slice
336 341 GGti gti(GTime(0.0), GTime(1.0));
337 342  
338 343 // Initialise event cube to evaluate models
... ...