Skip to content

Commit

Permalink
Refs #10090. POLDI chopper speed is rounded to next 500
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Wedel committed Sep 20, 2014
1 parent 1ed18e7 commit 90346cc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Expand Up @@ -105,6 +105,8 @@ class MANTID_SINQ_DLL PoldiInstrumentAdapter
void setSpectrum(const Geometry::Instrument_const_sptr &mantidInstrument);

double getChopperSpeedFromRun(const API::Run &runInformation);
double getCleanChopperSpeed(double rawChopperSpeed);

AbstractDoubleValueExtractor_sptr getExtractorForProperty(Kernel::Property *chopperSpeedProperty);

PoldiAbstractChopper_sptr m_chopper;
Expand Down
Expand Up @@ -127,7 +127,8 @@ void PoldiInstrumentAdapter::setDetector(const Instrument_const_sptr &mantidInst
*/
void PoldiInstrumentAdapter::setChopper(const Instrument_const_sptr &mantidInstrument, const Run &runInformation)
{
double chopperSpeed = getChopperSpeedFromRun(runInformation);
double rawChopperSpeed = getChopperSpeedFromRun(runInformation);
double chopperSpeed = getCleanChopperSpeed(rawChopperSpeed);

PoldiChopperFactory chopperFactory;
m_chopper = PoldiAbstractChopper_sptr(chopperFactory.createChopper(std::string("default-chopper")));
Expand All @@ -147,7 +148,7 @@ void PoldiInstrumentAdapter::setChopper(const Instrument_const_sptr &mantidInstr
double PoldiInstrumentAdapter::getChopperSpeedFromRun(const Run &runInformation)
{
if(!runInformation.hasProperty(m_chopperSpeedPropertyName)) {
throw std::runtime_error("Cannot construct instrument without " + m_chopperSpeedPropertyName + "property in log. Aborting.");
throw std::runtime_error("Cannot construct instrument without " + m_chopperSpeedPropertyName + "-property in log. Aborting.");
}

Kernel::Property *chopperSpeedProperty = runInformation.getProperty(m_chopperSpeedPropertyName);
Expand All @@ -161,6 +162,11 @@ double PoldiInstrumentAdapter::getChopperSpeedFromRun(const Run &runInformation)
return (*extractor)(runInformation);
}

double PoldiInstrumentAdapter::getCleanChopperSpeed(double rawChopperSpeed)
{
return floor((rawChopperSpeed + 250.0) / 500.0) * 500.0;
}

/**
* Returns appropriate extractor for supplied property
*
Expand Down
10 changes: 10 additions & 0 deletions Code/Mantid/Framework/SINQ/test/PoldiInstrumentAdapterTest.h
Expand Up @@ -79,6 +79,16 @@ class PoldiInstrumentAdapterTest : public CxxTest::TestSuite
TS_ASSERT_EQUALS(instrumentAdapter.getChopperSpeedFromRun(m_correctRun), 10000.0);
}

void testGetCleanChopperSpeed() {
TestablePoldiInstrumentAdapter instrumentAdapter;

TS_ASSERT_EQUALS(instrumentAdapter.getCleanChopperSpeed(4750.0), 5000.0);
TS_ASSERT_EQUALS(instrumentAdapter.getCleanChopperSpeed(4749.9), 4500.0);
TS_ASSERT_EQUALS(instrumentAdapter.getCleanChopperSpeed(4999.3), 5000.0);
TS_ASSERT_EQUALS(instrumentAdapter.getCleanChopperSpeed(5001.0), 5000.0);
TS_ASSERT_EQUALS(instrumentAdapter.getCleanChopperSpeed(12499.1), 12500.0);
}

void testGetExtractorForProperty() {
TestablePoldiInstrumentAdapter instrumentAdapter;

Expand Down

0 comments on commit 90346cc

Please sign in to comment.