diff --git a/Core/Instrument/DetectorMask.cpp b/Core/Instrument/DetectorMask.cpp index cec19f9eab0a014a6b5d0db329fe023a768c26d9..309e5e1a60411eabb4d5868964b845b4e4cacb40 100644 --- a/Core/Instrument/DetectorMask.cpp +++ b/Core/Instrument/DetectorMask.cpp @@ -81,13 +81,7 @@ void DetectorMask::initMaskData(const OutputData<double>& data) bool DetectorMask::isMasked(size_t index) const { - if(!m_mask_data.isInitialized()) - return false; - - if(index >= m_mask_data.getAllocatedSize()) - throw Exceptions::RuntimeErrorException("DetectorMask::isMasked() -> Error. " - "Index is out of range "+std::to_string(index)); - return m_mask_data[index]; + return m_number_of_masked_channels == 0 ? false : m_mask_data[index]; } Histogram2D* DetectorMask::createHistogram() const diff --git a/Core/Instrument/DetectorMask.h b/Core/Instrument/DetectorMask.h index 25e7032fe3143777574107ad9b8c2abac1f4f2f2..2bfd0827dd90be8c780208005dfc9680d9895824 100644 --- a/Core/Instrument/DetectorMask.h +++ b/Core/Instrument/DetectorMask.h @@ -53,7 +53,7 @@ public: void removeMasks(); //! returns true if has masks - bool hasMasks() const { return numberOfMasks()>0; } + bool hasMasks() const { return !m_shapes.empty(); } int numberOfMaskedChannels() const { return m_number_of_masked_channels; } diff --git a/Core/Instrument/SimulationArea.cpp b/Core/Instrument/SimulationArea.cpp index d3a9eafc364be20f28c1cf7d8c90b5e85c94d559..7b097d637bbcaee371585ea5fd8cc4607c6711bd 100644 --- a/Core/Instrument/SimulationArea.cpp +++ b/Core/Instrument/SimulationArea.cpp @@ -52,15 +52,8 @@ SimulationAreaIterator SimulationArea::end() bool SimulationArea::isMasked(size_t index) const { - if(index >= totalSize()) { - std::ostringstream message; - message << "SimulationArea::isActive: index " << index << " is out of range, " - << "total size = " << totalSize(); - throw std::runtime_error(message.str()); - } - - return (m_detector->detectorMask() - && m_detector->detectorMask()->isMasked(detectorIndex(index))); + auto masks = m_detector->detectorMask(); + return (masks && masks->hasMasks() && masks->isMasked(detectorIndex(index))); } size_t SimulationArea::roiIndex(size_t index) const