Skip to content

Commit

Permalink
Simple test in ApplyCalibrationTest.h written re #5797
Browse files Browse the repository at this point in the history
This test is passed by current version of ApplyCalibration.
A more demanding test is needed in which a tube is rotated before calibration.

Signed-off-by: Karl Palmen <karl.palmen@stfc.ac.uk>
  • Loading branch information
KarlPalmen committed Feb 27, 2013
1 parent afa7bf6 commit 96531e6
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions Code/Mantid/Framework/Algorithms/test/ApplyCalibrationTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ using namespace Mantid::Algorithms;
using namespace Mantid::API;
using namespace Mantid::Kernel;
using namespace Mantid::DataObjects;
using Mantid::Geometry::IDetector_const_sptr;

class ApplyCalibrationTest : public CxxTest::TestSuite
{
Expand All @@ -40,8 +41,11 @@ class ApplyCalibrationTest : public CxxTest::TestSuite

void testExec()
{

int ndets = 3;

// Create workspace with paremeterised instrument and put into data store
Workspace2D_sptr ws = WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(3, 10, true);
Workspace2D_sptr ws = WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(ndets, 10, true);
const std::string wsName("ApplyCabrationWs");
AnalysisDataServiceImpl & dataStore = AnalysisDataService::Instance();
dataStore.add(wsName, ws);
Expand All @@ -51,17 +55,32 @@ class ApplyCalibrationTest : public CxxTest::TestSuite
posTableWs->addColumn("int","Detector ID");
posTableWs->addColumn("V3D","Detector Position");

for(int i=0; i < 3; ++i)
for(int i=0; i < ndets; ++i)
{
TableRow row = posTableWs->appendRow();
row << i+1 << V3D(1.0,0.01*i,1.0);
row << i+1 << V3D(1.0,0.01*i,2.0);
}
TS_ASSERT_THROWS_NOTHING(appCalib.setPropertyValue("Workspace", wsName ));
TS_ASSERT_THROWS_NOTHING(appCalib.setProperty<ITableWorkspace_sptr>("PositionTable", posTableWs ));
TS_ASSERT_THROWS_NOTHING(appCalib.execute());

TS_ASSERT( appCalib.isExecuted() );

IDetector_const_sptr det = ws->getDetector(0);
int id = det->getID();
V3D newPos = det->getPos();
TS_ASSERT_EQUALS( id, 1);
TS_ASSERT_DELTA( newPos.X() , 1.0, 0.0001);
TS_ASSERT_DELTA( newPos.Y() , 0.0, 0.0001);
TS_ASSERT_DELTA( newPos.Z() , 2.0, 0.0001);

det = ws->getDetector(ndets-1);
id = det->getID();
newPos = det->getPos();
TS_ASSERT_EQUALS( id, ndets);
TS_ASSERT_DELTA( newPos.X() , 1.0, 0.0001);
TS_ASSERT_DELTA( newPos.Y() , 0.01*(ndets-1), 0.0001);
TS_ASSERT_DELTA( newPos.Z() , 2.0, 0.0001);
}

private:
Expand Down

0 comments on commit 96531e6

Please sign in to comment.