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

throw -> ASSERT

parent d529e413
No related branches found
No related tags found
1 merge request!227Core: minor cleanup in Instrument context
......@@ -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)
......
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