Skip to content
Snippets Groups Projects
Commit 506ae6ec authored by Russell Taylor's avatar Russell Taylor
Browse files

Merge remote branch 'origin/feature/7707_NewMedianDetectorTest'

parents 7376f05b 6da8f978
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceFactory.h"
#include "MantidDataObjects/Workspace2D.h" #include "MantidDataObjects/Workspace2D.h"
#include "MantidDataHandling/LoadInstrument.h" #include "MantidDataHandling/LoadInstrument.h"
#include "MantidDataHandling/LoadEmptyInstrument.h" //#include "MantidDataHandling/LoadEmptyInstrument.h"
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <Poco/File.h> #include <Poco/File.h>
...@@ -96,79 +96,71 @@ public: ...@@ -96,79 +96,71 @@ public:
void testSolidAngle() void testSolidAngle()
{ {
//load ARCS instrument, with all detectors 1 Mantid::DataObjects::Workspace2D_sptr ws=WorkspaceCreationHelper::create2DWorkspaceWithRectangularInstrument(5, 10, 1);
//Median Detector test with solid angle correction turned off should have no failures.
//With the correction turned on, and SignificanceTest = 0.01 should mask the short banks
// Load the empty instrument for(size_t i=0;i<ws->getNumberHistograms();i++)
Mantid::DataHandling::LoadEmptyInstrument loader; {
loader.initialize(); ws->dataY(i)[0]=std::floor(1e9*ws->getDetector(i)->solidAngle(V3D(0,0,0)));
// TODO: (ticket #5973) Update the next line to not have a hard coded value for the filename }
std::string inputFile = "ARCS_Definition_20121011-.xml"; AnalysisDataService::Instance().addOrReplace("MDTSolidAngle",ws);
loader.setPropertyValue("Filename", inputFile);
loader.setPropertyValue("OutputWorkspace", "SolidAngle");
loader.execute();
MedianDetectorTest alg; MedianDetectorTest alg;
TS_ASSERT_THROWS_NOTHING(alg.initialize()); TS_ASSERT_THROWS_NOTHING(alg.initialize());
TS_ASSERT(alg.isInitialized()); TS_ASSERT(alg.isInitialized());
// Set the properties // Set the properties
alg.setPropertyValue("InputWorkspace", "SolidAngle"); alg.setPropertyValue("InputWorkspace", "MDTSolidAngle");
alg.setPropertyValue("OutputWorkspace","MedianDetectorTestOutput"); alg.setPropertyValue("OutputWorkspace","MedianDetectorTestOutput");
// set significance test to small // set significance test to small
alg.setProperty("StartWorkspaceIndex",2);//no monitors alg.setProperty("SignificanceTest", 0.00001);
alg.setProperty("SignificanceTest", 0.01); alg.setProperty("CorrectForSolidAngle",false);
alg.setProperty("CorrectForSolidAngle",true);
TS_ASSERT_THROWS_NOTHING( alg.execute()); TS_ASSERT_THROWS_NOTHING( alg.execute());
TS_ASSERT( alg.isExecuted() ); TS_ASSERT( alg.isExecuted() );
int numFailed = alg.getProperty("NumberOfFailures"); int numFailed = alg.getProperty("NumberOfFailures");
TS_ASSERT_EQUALS(numFailed, 2048); TS_ASSERT_EQUALS(numFailed, 200);
alg.setProperty("CorrectForSolidAngle",false); alg.setProperty("CorrectForSolidAngle",true);
TS_ASSERT_THROWS_NOTHING( alg.execute()); TS_ASSERT_THROWS_NOTHING( alg.execute());
TS_ASSERT( alg.isExecuted() ); TS_ASSERT( alg.isExecuted() );
numFailed = alg.getProperty("NumberOfFailures"); numFailed = alg.getProperty("NumberOfFailures");
TS_ASSERT_EQUALS(numFailed, 0); TS_ASSERT_EQUALS(numFailed, 0);
AnalysisDataService::Instance().remove("MDTSolidAngle");
} }
void testLevelsUp() void testLevelsUp()
{ {
//load ARCS instrument, with all detectors 1 Mantid::DataObjects::Workspace2D_sptr ws=WorkspaceCreationHelper::create2DWorkspaceWithRectangularInstrument(5, 10, 1);
//With the solid angle correction turned on, and SignificanceTest = 0.01 should mask the short banks
//With the solid angle corection on, and LevelsUp=1, should be no failures for(size_t i=0;i<ws->getNumberHistograms();i++)
// Load the empty instrument {
Mantid::DataHandling::LoadEmptyInstrument loader; ws->dataY(i)[0]=std::floor(1e9*ws->getDetector(i)->solidAngle(V3D(0,0,0)));
loader.initialize(); }
// TODO: (ticket #5973) Update the next line to not have a hard coded value for the filename AnalysisDataService::Instance().addOrReplace("MDTLevelsUp",ws);
std::string inputFile = "ARCS_Definition_20121011-.xml";
loader.setPropertyValue("Filename", inputFile);
loader.setPropertyValue("OutputWorkspace", "SolidAngle");
loader.execute();
MedianDetectorTest alg; MedianDetectorTest alg;
TS_ASSERT_THROWS_NOTHING(alg.initialize()); TS_ASSERT_THROWS_NOTHING(alg.initialize());
TS_ASSERT(alg.isInitialized()); TS_ASSERT(alg.isInitialized());
// Set the properties // Set the properties
alg.setPropertyValue("InputWorkspace", "SolidAngle"); alg.setPropertyValue("InputWorkspace", "MDTLevelsUp");
alg.setPropertyValue("OutputWorkspace","MedianDetectorTestOutput"); alg.setPropertyValue("OutputWorkspace","MedianDetectorTestOutput");
// set significance test to small // set significance test to small
alg.setProperty("StartWorkspaceIndex",2);//no monitors alg.setProperty("SignificanceTest", 0.00001);
alg.setProperty("SignificanceTest", 0.01); alg.setProperty("CorrectForSolidAngle",false);
alg.setProperty("CorrectForSolidAngle",true); alg.setProperty("LevelsUp","0");
TS_ASSERT_THROWS_NOTHING( alg.execute()); TS_ASSERT_THROWS_NOTHING( alg.execute());
TS_ASSERT( alg.isExecuted() ); TS_ASSERT( alg.isExecuted() );
int numFailed = alg.getProperty("NumberOfFailures"); int numFailed = alg.getProperty("NumberOfFailures");
TS_ASSERT_EQUALS(numFailed, 2048); TS_ASSERT_EQUALS(numFailed, 200);
alg.setProperty("LevelsUp","1"); alg.setProperty("LevelsUp","1");
TS_ASSERT_THROWS_NOTHING( alg.execute()); TS_ASSERT_THROWS_NOTHING( alg.execute());
TS_ASSERT( alg.isExecuted() ); TS_ASSERT( alg.isExecuted() );
numFailed = alg.getProperty("NumberOfFailures"); numFailed = alg.getProperty("NumberOfFailures");
TS_ASSERT_EQUALS(numFailed, 0); TS_ASSERT_EQUALS(numFailed, 0);
AnalysisDataService::Instance().remove("MDTLevelsUp");
} }
MedianDetectorTestTest() : m_IWSName("MedianDetectorTestInput") MedianDetectorTestTest() : m_IWSName("MedianDetectorTestInput")
...@@ -219,7 +211,7 @@ public: ...@@ -219,7 +211,7 @@ public:
// Register the workspace in the data service // Register the workspace in the data service
AnalysisDataService::Instance().add(m_IWSName, space); AnalysisDataService::Instance().add(m_IWSName, space);
// Load the instrument data // Load the instrument data
Mantid::DataHandling::LoadInstrument loader; Mantid::DataHandling::LoadInstrument loader;
loader.initialize(); loader.initialize();
......
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