Skip to content
Snippets Groups Projects
Commit d4ae0982 authored by Dennis Mikkelson's avatar Dennis Mikkelson
Browse files

Added test for SelectCellOfType algorithm

Also added number indexed and average error output
properties fof SelectCellOfType algorithm.
refs #3666
parent 8727b813
No related branches found
No related tags found
No related merge requests found
...@@ -77,6 +77,7 @@ set ( TEST_FILES ...@@ -77,6 +77,7 @@ set ( TEST_FILES
test/FindUBUsingMinMaxDTest.h test/FindUBUsingMinMaxDTest.h
test/IndexPeaksTest.h test/IndexPeaksTest.h
test/ShowPossibleCellsTest.h test/ShowPossibleCellsTest.h
test/SelectCellOfTypeTest.h
test/IndexSXPeaksTest.h test/IndexSXPeaksTest.h
test/IntegratePeakTimeSlicesTest.h test/IntegratePeakTimeSlicesTest.h
test/LoadIsawPeaksTest.h test/LoadIsawPeaksTest.h
......
...@@ -110,6 +110,12 @@ namespace Crystal ...@@ -110,6 +110,12 @@ namespace Crystal
this->declareProperty( "Apply", false, "Update UB and re-index the peaks"); this->declareProperty( "Apply", false, "Update UB and re-index the peaks");
this->declareProperty( "Tolerance", 0.12, "Indexing Tolerance"); this->declareProperty( "Tolerance", 0.12, "Indexing Tolerance");
this->declareProperty(new PropertyWithValue<int>( "NumIndexed", 0,
Direction::Output), "The number of indexed peaks if apply==true.");
this->declareProperty(new PropertyWithValue<double>( "AverageError", 0.0,
Direction::Output), "The average HKL indexing error if apply==true.");
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
...@@ -203,6 +209,9 @@ namespace Crystal ...@@ -203,6 +209,9 @@ namespace Crystal
for ( size_t i = 0; i < n_peaks; i++ ) for ( size_t i = 0; i < n_peaks; i++ )
peaks[i].setHKL( miller_indices[i] ); peaks[i].setHKL( miller_indices[i] );
this->setProperty("NumIndexed", num_indexed);
this->setProperty("AverageError", average_error);
} }
} }
......
#ifndef MANTID_CRYSTAL_SELECT_CELL_OF_TYPE_TEST_H_
#define MANTID_CRYSTAL_SELECT_CELL_OF_TYPE_TEST_H_
#include <cxxtest/TestSuite.h>
#include "MantidKernel/Timer.h"
#include "MantidKernel/System.h"
#include <iostream>
#include <iomanip>
#include "MantidCrystal/SelectCellOfType.h"
#include "MantidCrystal/LoadIsawPeaks.h"
#include "MantidGeometry/Crystal/IndexingUtils.h"
#include "MantidGeometry/Crystal/OrientedLattice.h"
#include "MantidCrystal/LoadIsawUB.h"
using namespace Mantid;
using namespace Mantid::Crystal;
using namespace Mantid::API;
using namespace Mantid::DataObjects;
using namespace Mantid::Kernel;
using namespace Mantid::Geometry;
class SelectCellOfTypeTest : public CxxTest::TestSuite
{
public:
void test_Init()
{
SelectCellOfType alg;
TS_ASSERT_THROWS_NOTHING( alg.initialize() )
TS_ASSERT( alg.isInitialized() )
}
void test_exec()
{
// Name of the loader's output workspace.
std::string WSName("peaks");
LoadIsawPeaks loader;
TS_ASSERT_THROWS_NOTHING( loader.initialize() );
TS_ASSERT( loader.isInitialized() );
loader.setPropertyValue("Filename", "TOPAZ_3007.peaks");
loader.setPropertyValue("OutputWorkspace", WSName);
TS_ASSERT( loader.execute() );
TS_ASSERT( loader.isExecuted() );
PeaksWorkspace_sptr ws;
TS_ASSERT_THROWS_NOTHING( ws = boost::dynamic_pointer_cast<PeaksWorkspace>(
AnalysisDataService::Instance().retrieve(WSName) ) );
TS_ASSERT(ws);
// set a Niggli UB for run 3007
// (CuTCA) in the oriented lattice
V3D row_0( 0.0122354, 0.00480056, 0.0860404 );
V3D row_1( -0.1165450, 0.00178145, -0.0045884 );
V3D row_2( -0.0273738, -0.08973560, -0.0252595 );
Matrix<double> UB(3,3,false);
UB.setRow( 0, row_0 );
UB.setRow( 1, row_1 );
UB.setRow( 2, row_2 );
OrientedLattice o_lattice;
o_lattice.setUB( UB );
ws->mutableSample().setOrientedLattice( new OrientedLattice(o_lattice) );
// now get the UB back from the WS
UB = o_lattice.getUB();
SelectCellOfType alg;
TS_ASSERT_THROWS_NOTHING( alg.initialize() )
TS_ASSERT( alg.isInitialized() )
TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("PeaksWorkspace", WSName) );
TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("CellType","Monoclinic") );
TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("Centering","C") );
TS_ASSERT_THROWS_NOTHING( alg.setProperty("Apply",true) );
TS_ASSERT_THROWS_NOTHING( alg.setProperty("Tolerance",0.12) );
TS_ASSERT_THROWS_NOTHING( alg.execute(); );
TS_ASSERT( alg.isExecuted() );
int num_indexed = alg.getProperty("NumIndexed");
TS_ASSERT_EQUALS( num_indexed, 43 );
double average_error = alg.getProperty("AverageError");
TS_ASSERT_DELTA( average_error, 0.0119856, 1e-5 );
AnalysisDataService::Instance().remove(WSName);
}
};
#endif /* MANTID_CRYSTAL_SELECT_CELL_OF_TYPE_TEST_H_ */
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