Skip to content

Commit

Permalink
Expose bin boundaries in Run. Refs #10698
Browse files Browse the repository at this point in the history
Needed to check the original limits for energy transfer, in case they
fall between the minimum and maximum of the MD workspace
  • Loading branch information
AndreiSavici committed Dec 10, 2014
1 parent 5989558 commit 0fd5234
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/Run.h
Expand Up @@ -77,6 +77,8 @@ namespace Mantid
void storeHistogramBinBoundaries(const std::vector<double> & energyBins);
/// Returns the bin boundaries for a given value
std::pair<double, double> histogramBinBoundaries(const double energyValue) const;
///Returns the vector of bin boundaries
std::vector<double> getBinBoundaries() const;

/// Set the gonoimeter & read the values from the logs if told to do so
void setGoniometer(const Geometry::Goniometer & goniometer, const bool useLogValues);
Expand Down
15 changes: 15 additions & 0 deletions Code/Mantid/Framework/API/src/Run.cpp
Expand Up @@ -298,6 +298,21 @@ namespace
return std::make_pair(m_histoBins[index], m_histoBins[index+1]);
}

/**
* Returns the energy bin boundaries. Throws a std::runtime_error
* if the energy bins have not been set.
* @return The bin boundaries vector
*/
std::vector<double> Run::getBinBoundaries() const
{
if(m_histoBins.empty())
{
throw std::runtime_error("Run::histogramBoundaries - No energy bins have been stored for this run");
}

return m_histoBins;
}

//-----------------------------------------------------------------------------------------------
/** Return the total memory used by the run object, in bytes.
*/
Expand Down
15 changes: 15 additions & 0 deletions Code/Mantid/Framework/API/test/RunTest.h
Expand Up @@ -366,6 +366,21 @@ class RunTest : public CxxTest::TestSuite
TS_ASSERT_DELTA(edges.second, 3.2, 1e-12);
}

void test_getBinBoundaries()
{
using namespace Mantid::Kernel;
Run runInfo;
runInfo.storeHistogramBinBoundaries(m_test_energy_bins);

std::vector<double> bounds;
TS_ASSERT_THROWS_NOTHING(bounds = runInfo.getBinBoundaries());
for(size_t i=0;i<m_test_energy_bins.size();++i)
{
TS_ASSERT_DELTA(bounds.at(i),m_test_energy_bins.at(i), 1e-12);
}

}

void test_getGoniometer()
{
Run runInfo;
Expand Down

0 comments on commit 0fd5234

Please sign in to comment.