Skip to content
Snippets Groups Projects
Commit a815776f authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

Simplify detector mask handling

parent afb39989
No related branches found
No related tags found
No related merge requests found
...@@ -81,13 +81,7 @@ void DetectorMask::initMaskData(const OutputData<double>& data) ...@@ -81,13 +81,7 @@ void DetectorMask::initMaskData(const OutputData<double>& data)
bool DetectorMask::isMasked(size_t index) const bool DetectorMask::isMasked(size_t index) const
{ {
if(!m_mask_data.isInitialized()) return m_number_of_masked_channels == 0 ? false : m_mask_data[index];
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];
} }
Histogram2D* DetectorMask::createHistogram() const Histogram2D* DetectorMask::createHistogram() const
......
...@@ -53,7 +53,7 @@ public: ...@@ -53,7 +53,7 @@ public:
void removeMasks(); void removeMasks();
//! returns true if has masks //! 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; } int numberOfMaskedChannels() const { return m_number_of_masked_channels; }
......
...@@ -52,15 +52,8 @@ SimulationAreaIterator SimulationArea::end() ...@@ -52,15 +52,8 @@ SimulationAreaIterator SimulationArea::end()
bool SimulationArea::isMasked(size_t index) const bool SimulationArea::isMasked(size_t index) const
{ {
if(index >= totalSize()) { auto masks = m_detector->detectorMask();
std::ostringstream message; return (masks && masks->hasMasks() && masks->isMasked(detectorIndex(index)));
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)));
} }
size_t SimulationArea::roiIndex(size_t index) const size_t SimulationArea::roiIndex(size_t index) 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