Skip to content
Snippets Groups Projects
Commit c100ec33 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

suppress tiny bins that are most likely due to floating-point inaccuracy

parent c3321096
No related branches found
No related tags found
1 merge request!1621Scale (IAxis) now without children
...@@ -42,12 +42,21 @@ inline size_t ycoord(size_t index, size_t sizeY) ...@@ -42,12 +42,21 @@ inline size_t ycoord(size_t index, size_t sizeY)
IDetector::RoiOfAxis::RoiOfAxis(const Scale& axis, double _lower, double _upper) IDetector::RoiOfAxis::RoiOfAxis(const Scale& axis, double _lower, double _upper)
: lower(_lower) : lower(_lower)
, upper(_upper) , upper(_upper)
, lowerIndex(axis.closestIndex(lower))
, upperIndex(axis.closestIndex(upper))
, roiSize(upperIndex - lowerIndex + 1)
, detectorSize(axis.size())
{ {
ASSERT(lower < upper); ASSERT(lower < upper);
detectorSize = axis.size();
lowerIndex = axis.closestIndex(lower);
upperIndex = axis.closestIndex(upper);
// suppress tiny bins that are most likely due to floating-point inaccuracy
if (axis.bin(lowerIndex).binSize() < 1e-12 * axis.span() / axis.size()) {
ASSERT(lowerIndex < axis.size() - 1);
++lowerIndex;
}
if (axis.bin(upperIndex).binSize() < 1e-12 * axis.span() / axis.size()) {
ASSERT(upperIndex > 0);
--upperIndex;
}
roiSize = upperIndex - lowerIndex + 1;
} }
std::pair<double, double> IDetector::RoiOfAxis::bounds() const std::pair<double, double> IDetector::RoiOfAxis::bounds() const
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment