diff --git a/Device/Detector/IDetector.cpp b/Device/Detector/IDetector.cpp index 3cd6f46139643cad91b3dc7477caaef405991bac..5bf26d3aba45fb5059bac99023a7901f19a964f8 100644 --- a/Device/Detector/IDetector.cpp +++ b/Device/Detector/IDetector.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "Device/Detector/IDetector.h" +#include "Base/Utils/Assert.h" #include "Device/ProDetector/DetectorMask.h" #include "Device/Resolution/ConvolutionDetectorResolution.h" #include "Resample/Element/DiffuseElement.h" @@ -54,9 +55,8 @@ void IDetector::clear() const IAxis& IDetector::axis(size_t index) const { - if (index < dimension()) - return *m_axes[index]; - throw std::runtime_error("Error in IDetector::getAxis: not so many axes in this detector."); + ASSERT(index < dimension()); + return *m_axes[index]; } size_t IDetector::axisBinIndex(size_t index, size_t selected_axis) const @@ -70,8 +70,7 @@ size_t IDetector::axisBinIndex(size_t index, size_t selected_axis) const return remainder % m_axes[i_axis]->size(); remainder /= m_axes[i_axis]->size(); } - throw std::runtime_error("IDetector::getAxisBinIndex() -> " - "Error! No axis with given number"); + ASSERT(0); } std::unique_ptr<IAxis> IDetector::createAxis(size_t index, size_t n_bins, double min, @@ -98,14 +97,9 @@ size_t IDetector::sizeOfExplicitRegionOfInterest() const std::pair<double, double> IDetector::boundsOfExplicitRegionOfInterest(size_t iAxis) const { - if (iAxis >= dimension()) - throw std::runtime_error( - "IDetector::boundsOfExplicitRegionOfInterest() -> Error. iAxis must be smaller than " - + std::to_string(dimension())); - + ASSERT(iAxis < dimension()); if (iAxis < m_explicitROI.size()) return {m_explicitROI[iAxis].lower, m_explicitROI[iAxis].upper}; - return {0., 0.}; } @@ -186,9 +180,8 @@ void IDetector::resetRegionOfInterest() void IDetector::applyDetectorResolution(OutputData<double>* p_intensity_map) const { - if (!p_intensity_map) - throw std::runtime_error("IDetector::applyDetectorResolution() -> " - "Error! Null pointer to intensity map"); + ASSERT(p_intensity_map); + if (m_detector_resolution) { m_detector_resolution->applyDetectorResolution(p_intensity_map); if (detectorMask() && detectorMask()->hasMasks()) { @@ -213,10 +206,7 @@ OutputData<double>* IDetector::createDetectorIntensity(const std::vector<DiffuseElement>& elements) const { std::unique_ptr<OutputData<double>> detectorMap(createDetectorMap()); - if (!detectorMap) - throw std::runtime_error("Instrument::createDetectorIntensity:" - "can't create detector map."); - + ASSERT(detectorMap); setDataToDetectorMap(*detectorMap, elements); if (m_detector_resolution) applyDetectorResolution(detectorMap.get()); @@ -227,9 +217,7 @@ IDetector::createDetectorIntensity(const std::vector<DiffuseElement>& elements) std::unique_ptr<OutputData<double>> IDetector::createDetectorMap() const { const size_t dim = dimension(); - if (dim == 0) - throw std::runtime_error( - "Error in IDetector::createDetectorMap: dimensions of the detector are undefined"); + ASSERT(dim != 0); std::unique_ptr<OutputData<double>> result(new OutputData<double>); for (size_t iAxis = 0; iAxis < dim; ++iAxis) { @@ -261,10 +249,7 @@ size_t IDetector::numberOfDiffuseElements() const std::pair<double, double> IDetector::regionOfInterestBounds(size_t iAxis) const { - if (iAxis >= m_axes.size()) - throw std::runtime_error( - "IDetector::regionOfInterestBounds() -> Error. iAxis must be smaller than " - + std::to_string(m_axes.size())); + ASSERT(iAxis < m_axes.size()); const auto explicitBounds = boundsOfExplicitRegionOfInterest(iAxis); if (explicitBounds.first != 0 || explicitBounds.second != 0)