Commit 396a007ca517a1eb61a88f16ff4132351361c19a
1 parent
15a65dfd
Add energy margin to energy boundary containment check.
Without the energy margin, roundoff errors may lead to the exclusion of the energy bin in case that a single energy bin is used.
Showing
2 changed files
with
10 additions
and
4 deletions
src/ctbin/ctbin.cpp
| @@ -40,6 +40,9 @@ | @@ -40,6 +40,9 @@ | ||
| 40 | 40 | ||
| 41 | /* __ Coding definitions _________________________________________________ */ | 41 | /* __ Coding definitions _________________________________________________ */ |
| 42 | 42 | ||
| 43 | +/* __ Constants __________________________________________________________ */ | ||
| 44 | +const GEnergy g_energy_margin(1.0e-12, "TeV"); | ||
| 45 | + | ||
| 43 | 46 | ||
| 44 | /*========================================================================== | 47 | /*========================================================================== |
| 45 | = = | 48 | = = |
| @@ -530,8 +533,8 @@ void ctbin::fill_cube(GCTAObservation* obs) | @@ -530,8 +533,8 @@ void ctbin::fill_cube(GCTAObservation* obs) | ||
| 530 | // Determine energy bin. Skip if we are outside the energy range | 533 | // Determine energy bin. Skip if we are outside the energy range |
| 531 | int index = m_ebounds.index(event->energy()); | 534 | int index = m_ebounds.index(event->energy()); |
| 532 | if (index == -1 || | 535 | if (index == -1 || |
| 533 | - !obs_ebounds.contains(m_ebounds.emin(index), | ||
| 534 | - m_ebounds.emax(index))) { | 536 | + !obs_ebounds.contains(m_ebounds.emin(index)+g_energy_margin, |
| 537 | + m_ebounds.emax(index)-g_energy_margin)) { | ||
| 535 | num_outside_ebds++; | 538 | num_outside_ebds++; |
| 536 | continue; | 539 | continue; |
| 537 | } | 540 | } |
src/ctmodel/ctmodel.cpp
| @@ -39,6 +39,9 @@ | @@ -39,6 +39,9 @@ | ||
| 39 | 39 | ||
| 40 | /* __ Coding definitions _________________________________________________ */ | 40 | /* __ Coding definitions _________________________________________________ */ |
| 41 | 41 | ||
| 42 | +/* __ Constants __________________________________________________________ */ | ||
| 43 | +const GEnergy g_energy_margin(1.0e-12, "TeV"); | ||
| 44 | + | ||
| 42 | 45 | ||
| 43 | /*========================================================================== | 46 | /*========================================================================== |
| 44 | = = | 47 | = = |
| @@ -617,8 +620,8 @@ void ctmodel::fill_cube(const GCTAObservation* obs) | @@ -617,8 +620,8 @@ void ctmodel::fill_cube(const GCTAObservation* obs) | ||
| 617 | // Skip bin if it is outside the energy range of the observation | 620 | // Skip bin if it is outside the energy range of the observation |
| 618 | int index = cube_ebounds.index(bin->energy()); | 621 | int index = cube_ebounds.index(bin->energy()); |
| 619 | if (index == -1 || | 622 | if (index == -1 || |
| 620 | - !obs_ebounds.contains(cube_ebounds.emin(index), | ||
| 621 | - cube_ebounds.emax(index))) { | 623 | + !obs_ebounds.contains(cube_ebounds.emin(index)+g_energy_margin, |
| 624 | + cube_ebounds.emax(index)-g_energy_margin)) { | ||
| 622 | num_outside_ebds++; | 625 | num_outside_ebds++; |
| 623 | continue; | 626 | continue; |
| 624 | } | 627 | } |