diff --git a/Code/Mantid/Framework/MDAlgorithms/CMakeLists.txt b/Code/Mantid/Framework/MDAlgorithms/CMakeLists.txt index 9c78aae411c1..3fadb475b24f 100644 --- a/Code/Mantid/Framework/MDAlgorithms/CMakeLists.txt +++ b/Code/Mantid/Framework/MDAlgorithms/CMakeLists.txt @@ -19,6 +19,7 @@ set ( SRC_FILES src/ConvToMDHistoWS.cpp src/ConvToMDSelector.cpp src/ConvertCWPDMDToSpectra.cpp + src/ConvertMDHistoToMDEventWorkspace.cpp src/ConvertMDHistoToMatrixWorkspace.cpp src/ConvertSpiceDataToRealSpace.cpp src/ConvertToDetectorFaceMD.cpp @@ -136,6 +137,7 @@ set ( INC_FILES inc/MantidMDAlgorithms/CompareMDWorkspaces.h inc/MantidMDAlgorithms/ConvToMDBase.h inc/MantidMDAlgorithms/ConvertCWPDMDToSpectra.h + inc/MantidMDAlgorithms/ConvertMDHistoToMDEventWorkspace.h inc/MantidMDAlgorithms/ConvertMDHistoToMatrixWorkspace.h inc/MantidMDAlgorithms/ConvertSpiceDataToRealSpace.h inc/MantidMDAlgorithms/ConvertToDetectorFaceMD.h @@ -253,6 +255,7 @@ set ( TEST_FILES CompareMDWorkspacesTest.h ConvertCWPDMDToSpectraTest.h ConvertEventsToMDTest.h + ConvertMDHistoToMDEventWorkspaceTest.h ConvertMDHistoToMatrixWorkspaceTest.h ConvertSpiceDataToRealSpaceTest.h ConvertToDetectorFaceMDTest.h diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertMDHistoToMDEventWorkspace.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertMDHistoToMDEventWorkspace.h new file mode 100644 index 000000000000..06a9b641b90e --- /dev/null +++ b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertMDHistoToMDEventWorkspace.h @@ -0,0 +1,71 @@ +#ifndef MANTID_MDALGORITHMS_ConvertMDHistoToMDEventWorkspace_H_ +#define MANTID_MDALGORITHMS_ConvertMDHistoToMDEventWorkspace_H_ + +#include "MantidAPI/Algorithm.h" +#include "MantidDataObjects/MDEventWorkspace.h" +#include + +namespace Mantid { +namespace MDAlgorithms { + +/** ConvertMDHistoToMDEventWorkspace : Loads a file containing dimensionality and data for + an MDEventWorkspace. Handles either full mdevents for mdleanevents as input + data types. + + @date 2012-07-11 + + Copyright © 2012 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge + National Laboratory & European Spallation Source + + This file is part of Mantid. + + Mantid is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + Mantid is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + File change history is stored at: + Code Documentation is available at: +*/ +class DLLExport ConvertMDHistoToMDEventWorkspace : public API::Algorithm { +public: + ConvertMDHistoToMDEventWorkspace(); + virtual ~ConvertMDHistoToMDEventWorkspace(); + + virtual const std::string name() const; + /// Summary of algorithms purpose + virtual const std::string summary() const { + return "Reads an ASCII file containing MDEvent data and constructs an " + "MDEventWorkspace."; + } + + virtual int version() const; + virtual const std::string category() const; + +private: + + /// Actual number of dimensions specified + size_t m_nDimensions; + /// Actual number of md events provided. + size_t m_nDataObjects; + /// call back to add event data + template + void addEventsData(typename DataObjects::MDEventWorkspace::sptr outWs); + DataObjects::MDHistoWorkspace_sptr ws; + + void init(); + void exec(); +}; + +} // namespace MDAlgorithms +} // namespace Mantid + +#endif /* MANTID_MDALGORITHMS_ConvertMDHistoToMDEventWorkspace_H_ */ diff --git a/Code/Mantid/Framework/MDAlgorithms/src/ConvertMDHistoToMDEventWorkspace.cpp b/Code/Mantid/Framework/MDAlgorithms/src/ConvertMDHistoToMDEventWorkspace.cpp new file mode 100644 index 000000000000..3dc46d6d0430 --- /dev/null +++ b/Code/Mantid/Framework/MDAlgorithms/src/ConvertMDHistoToMDEventWorkspace.cpp @@ -0,0 +1,134 @@ +#include "MantidMDAlgorithms/ConvertMDHistoToMDEventWorkspace.h" + +#include +#include + +#include "MantidDataObjects/MDEventFactory.h" +#include "MantidDataObjects/MDEventInserter.h" +#include "MantidGeometry/MDGeometry/MDHistoDimension.h" + +#include +#include + + + +namespace Mantid { +namespace MDAlgorithms { + +using namespace API; +using namespace DataObjects; +using namespace Geometry; +using namespace Kernel; +// Register the algorithm into the AlgorithmFactory +DECLARE_ALGORITHM(ConvertMDHistoToMDEventWorkspace) + +//---------------------------------------------------------------------------------------------- +/** Constructor + */ +ConvertMDHistoToMDEventWorkspace::ConvertMDHistoToMDEventWorkspace() {} + +//---------------------------------------------------------------------------------------------- +/** Destructor + */ +ConvertMDHistoToMDEventWorkspace::~ConvertMDHistoToMDEventWorkspace() {} + +//---------------------------------------------------------------------------------------------- +/// Algorithm's name for identification. @see Algorithm::name +const std::string ConvertMDHistoToMDEventWorkspace::name() const { + return "ConvertMDHistoToMDEventWorkspace"; +} + +/// Algorithm's version for identification. @see Algorithm::version +int ConvertMDHistoToMDEventWorkspace::version() const { return 1; } + +/// Algorithm's category for identification. @see Algorithm::category +const std::string ConvertMDHistoToMDEventWorkspace::category() const { + return "MDAlgorithms"; +} + +//---------------------------------------------------------------------------------------------- + +//---------------------------------------------------------------------------------------------- +/** Initialize the algorithm's properties. + */ +void ConvertMDHistoToMDEventWorkspace::init() { + declareProperty(new WorkspaceProperty( + "InputWorkspace", "", Direction::Input), + "An input IMDHistoWorkspace."); + declareProperty(new WorkspaceProperty( + "OutputWorkspace", "", Direction::Output), + "An output workspace."); +} + +/** +Extracts mdevent information from the histo data and directs the creation of new +DataObjects on the workspace. +@param ws: Workspace to add the events to. +*/ +template +void ConvertMDHistoToMDEventWorkspace::addEventsData( + typename MDEventWorkspace::sptr outWs) { + /// Creates a new instance of the MDEventInserter. + MDEventInserter::sptr> inserter(outWs); + std::vector centers(nd); + + for (size_t i = 0; i < m_nDataObjects; ++i) { + float signal = static_cast(ws->getSignalAt(i)); + float error = static_cast(ws->getErrorAt(i)); + uint16_t run_no = 0; + int32_t detector_no = 0; + VMD boxCenter = ws->getCenter(i); + for (size_t j = 0; j < m_nDimensions; ++j) { + centers[j] = static_cast(boxCenter[j]); + } + // Actually add the mdevent. + inserter.insertMDEvent(signal, error * error, run_no, detector_no, + centers.data()); + } +} + +//---------------------------------------------------------------------------------------------- +/** Execute the algorithm. + */ +void ConvertMDHistoToMDEventWorkspace::exec() { + IMDHistoWorkspace_sptr inWS = getProperty("InputWorkspace"); + + ws = boost::dynamic_pointer_cast(inWS); + if (!ws) + throw std::runtime_error("InputWorkspace is not a MDHistoWorkspace"); + + // Calculate the dimensionality + m_nDimensions = ws->getNumDims(); + // Calculate the actual number of columns in the MDEvent data. + uint64_t numPoints = ws->getNPoints(); + m_nDataObjects = static_cast(numPoints); + + // Create a target output workspace. + IMDEventWorkspace_sptr outWs = MDEventFactory::CreateMDWorkspace( + m_nDimensions, "MDLeanEvent"); + if (ws->getNumExperimentInfo() > 0) { + ExperimentInfo_sptr ei = ws->getExperimentInfo(0); + outWs->addExperimentInfo(ei); + } + outWs->setCoordinateSystem(ws->getSpecialCoordinateSystem()); + // Extract Dimensions and add to the output workspace. + for (size_t i = 0; i < m_nDimensions; ++i) { + IMDDimension_const_sptr dim = ws->getDimension(i); + std::string id = dim->getDimensionId(); + std::string name = dim->getName(); + std::string units = dim->getUnits(); + size_t nbins = dim->getNBins(); + + outWs->addDimension(MDHistoDimension_sptr(new MDHistoDimension( + id, name, units, dim->getMinimum(), + dim->getMaximum(), nbins))); + } + + CALL_MDEVENT_FUNCTION(this->addEventsData, outWs) + + // set output + this->setProperty("OutputWorkspace", outWs); +} + +} // namespace Mantid +} // namespace MDAlgorithms diff --git a/Code/Mantid/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp b/Code/Mantid/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp index 297a3a9ac3e8..e5e6ea1d34c7 100644 --- a/Code/Mantid/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp +++ b/Code/Mantid/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp @@ -737,7 +737,7 @@ IntegratePeaksMD2::checkOverlap(int i, if (pos1.distance(pos2) < radius) { g_log.warning() << " Warning: Peak integration spheres for peaks " << i << " and " << j << " overlap. Distance between peaks is " - << pos1.distance(pos2) << std::endl; + << pos1.distance(pos2) <<" "< + +#include + +#include + + +using namespace Mantid; +using namespace Mantid::API; +using namespace Mantid::Geometry; +using namespace Mantid::MDAlgorithms; + +/* +This builder type provides a convenient way to create and change the contents of a virtual file of the type expected +by the ConvertMDHistoToMDEventWorkspace algorithm. + +This type is particularly useful when generating corrupt file contents, as it allows individual apects of the file contents to be modified independently. +*/ +class FileContentsBuilder +{ +private: + std::string m_DimensionBlock; + std::string m_MDEventsBlock; + std::string m_DimensionEntries; + std::string m_MDEventEntries; +public: + FileContentsBuilder() : + m_DimensionBlock(ConvertMDHistoToMDEventWorkspace::DimensionBlockFlag()), + m_MDEventsBlock(ConvertMDHistoToMDEventWorkspace::MDEventBlockFlag()), + m_DimensionEntries("a A U 10\nb B U 11"), + m_MDEventEntries("1 1 1 1") + { + } + + void setDimensionBlock(const std::string& value) + { + m_DimensionBlock = value; + } + + void setMDEventBlock(const std::string& value) + { + m_MDEventsBlock = value; + } + + void setDimensionEntries(const std::string& value) + { + m_DimensionEntries = value; + } + + void setMDEventEntries(const std::string& value) + { + m_MDEventEntries = value; + } + + std::string create() const + { + const std::string newline = "\n"; + return m_DimensionBlock + newline + m_DimensionEntries + newline + m_MDEventsBlock + newline + m_MDEventEntries + newline; + } +}; + + +/** +Helper type. Creates a test file, and also manages the resource to ensure that the file is closed and removed, no matter what the outcome of the test. + +Uses a +*/ +class MDFileObject +{ +public: + + /// Create a simple input file. + MDFileObject(const FileContentsBuilder& builder = FileContentsBuilder(), std::string filename="test_import_md_event_workspace_file.txt") + { + Poco::Path path(Mantid::Kernel::ConfigService::Instance().getTempDir().c_str()); + path.append(filename); + m_filename = path.toString(); + m_file.open (m_filename.c_str(), std::ios_base::out); + // Invoke the builder to create the contents of the file. + m_file << builder.create(); + m_file.close(); + } + + std::string getFileName() const + { + return m_filename; + } + + /// Free up resources. + ~MDFileObject() + { + m_file.close(); + if( remove( m_filename.c_str() ) != 0 ) + throw std::runtime_error("cannot remove " + m_filename); + } + +private: + std::string m_filename; + std::ofstream m_file; + // Following methods keeps us from being able to put objects of this type on the heap. + void *operator new(size_t); + void *operator new[](size_t); +}; + +class ConvertMDHistoToMDEventWorkspaceTest : public CxxTest::TestSuite +{ +private: + +/** +Helper method runs tests that should throw and invalid argument when the algorithm is executed. +*/ +void do_check_throws_invalid_alg_upon_execution(const MDFileObject& infile) +{ + ConvertMDHistoToMDEventWorkspace alg; + alg.initialize(); + alg.setRethrows(true); + alg.setPropertyValue("Filename", infile.getFileName()); + alg.setPropertyValue("OutputWorkspace", "test_out"); + TS_ASSERT_THROWS(alg.execute(), std::invalid_argument); +} + +public: + // This pair of boilerplate methods prevent the suite being created statically + // This means the constructor isn't called when running other tests + static ConvertMDHistoToMDEventWorkspaceTest *createSuite() { return new ConvertMDHistoToMDEventWorkspaceTest(); } + static void destroySuite( ConvertMDHistoToMDEventWorkspaceTest *suite ) { delete suite; } + + void test_catagory() + { + ConvertMDHistoToMDEventWorkspace alg; + TS_ASSERT_EQUALS("MDAlgorithms", alg.category()); + } + + void test_name() + { + ConvertMDHistoToMDEventWorkspace alg; + TS_ASSERT_EQUALS("ConvertMDHistoToMDEventWorkspace", alg.name()); + } + + void test_Init() + { + ConvertMDHistoToMDEventWorkspace alg; + TS_ASSERT_THROWS_NOTHING( alg.initialize() ) + TS_ASSERT( alg.isInitialized() ) + } + + void test_missing_dimension_block_throws() + { + // Setup the corrupt file + FileContentsBuilder fileContents; + fileContents.setDimensionBlock(""); + MDFileObject infile(fileContents); + // Run the test. + do_check_throws_invalid_alg_upon_execution(infile); + } + + void test_missing_mdevents_block_throws() + { + // Setup the corrupt file + FileContentsBuilder fileContents; + fileContents.setMDEventBlock(""); + MDFileObject infile(fileContents); + // Run the test. + do_check_throws_invalid_alg_upon_execution(infile); + } + + void test_mdevent_block_declared_before_dimension_block_throws() + { + // Setup the corrupt file. Notice that the DimensionBlockFlag and the MDEventBlockFlag arguments have been swapped over. + FileContentsBuilder fileContents; + fileContents.setDimensionBlock(ConvertMDHistoToMDEventWorkspace::MDEventBlockFlag()); + fileContents.setMDEventBlock(ConvertMDHistoToMDEventWorkspace::DimensionBlockFlag()); + MDFileObject infile(fileContents); + // Run the test. + do_check_throws_invalid_alg_upon_execution(infile); + } + + void test_dimension_block_has_corrupted_entries_throws() + { + // Setup the corrupt file. + FileContentsBuilder fileContents; + std::string dim1 = "a A U 10\n"; + std::string dim2 = "b B U 11\n"; + std::string dim3 = "b B U\n"; // Ooops, forgot to put in the number of bins for this dimension. + fileContents.setDimensionEntries(dim1 + dim2 + dim3); + MDFileObject infile(fileContents); + // Run the test. + do_check_throws_invalid_alg_upon_execution(infile); + } + + void test_type_of_entries_in_dimension_block_is_wrong() + { + // Setup the corrupt file. + FileContentsBuilder fileContents; + std::string dim1 = "a A U 10\n"; + std::string dim2 = "b B U 11\n"; + std::string dim3 = "b B U x\n"; // Ooops, correct number of entries, but nbins set to be x! + fileContents.setDimensionEntries(dim1 + dim2 + dim3); + MDFileObject infile(fileContents); + // Run the test. + do_check_throws_invalid_alg_upon_execution(infile); + } + + void test_event_type_not_specified_and_mdevent_block_wrong_size_throws() + { + // Setup the corrupt file. + FileContentsBuilder fileContents; + fileContents.setMDEventEntries("1 1 1 1 1"); // Should have 4 or 6 entries, but 5 given. + MDFileObject infile(fileContents); + // Run the test. + do_check_throws_invalid_alg_upon_execution(infile); + } + + void test_mdevent_block_contains_wrong_types_throws() + { + // Setup the corrupt file. + FileContentsBuilder fileContents; + fileContents.setMDEventEntries("1.0 1.0 2.1 2.1 1.0 1.0"); // The 3rd and 4th entries relate to run_no and detector_no, these should not be doubles! + MDFileObject infile(fileContents); + // Run the test. + do_check_throws_invalid_alg_upon_execution(infile); + } + + void test_loaded_dimensionality() + { + // Setup the corrupt file. + FileContentsBuilder fileContents; + fileContents.setMDEventEntries("1 1 -1 -2\n1 1 2 3"); // mins -1, -2, maxs 2, 3 + MDFileObject infile(fileContents); + // Run the algorithm. + ConvertMDHistoToMDEventWorkspace alg; + alg.initialize(); + alg.setPropertyValue("Filename", infile.getFileName()); + alg.setPropertyValue("OutputWorkspace", "test_out"); + TS_ASSERT_THROWS_NOTHING(alg.execute()); + TS_ASSERT(alg.isExecuted()); + + IMDEventWorkspace_sptr outWS = AnalysisDataService::Instance().retrieveWS("test_out"); + + TS_ASSERT_EQUALS(2, outWS->getNumDims()); + IMDDimension_const_sptr dim1 = outWS->getDimension(0); + IMDDimension_const_sptr dim2 = outWS->getDimension(1); + + TS_ASSERT_EQUALS("a", dim1->getName()); + TS_ASSERT_EQUALS("A", dim1->getDimensionId()); + TS_ASSERT_EQUALS("U", dim1->getUnits().ascii()); + TS_ASSERT_EQUALS(-1, dim1->getMinimum()); + TS_ASSERT_EQUALS(2, dim1->getMaximum()); + + TS_ASSERT_EQUALS("b", dim2->getName()); + TS_ASSERT_EQUALS("B", dim2->getDimensionId()); + TS_ASSERT_EQUALS("U", dim2->getUnits().ascii()); + TS_ASSERT_EQUALS(-2, dim2->getMinimum()); + TS_ASSERT_EQUALS(3, dim2->getMaximum()); + } + + void test_load_lean_mdevents_2d() + { + // Setup the corrupt file. + FileContentsBuilder fileContents; + fileContents.setMDEventEntries("1 1 -1 -2\n1 1 2 3"); // mins -1, -2, maxs 2, 3 + MDFileObject infile(fileContents); + // Run the algorithm. + ConvertMDHistoToMDEventWorkspace alg; + alg.initialize(); + alg.setPropertyValue("Filename", infile.getFileName()); + alg.setPropertyValue("OutputWorkspace", "test_out"); + TS_ASSERT_THROWS_NOTHING(alg.execute()); + + IMDEventWorkspace_sptr outWS = AnalysisDataService::Instance().retrieveWS("test_out"); + + TS_ASSERT(alg.isExecuted()); + TS_ASSERT_EQUALS(2, outWS->getNumDims()); + + TS_ASSERT_EQUALS(2, outWS->getNPoints()); + TS_ASSERT_EQUALS("MDLeanEvent", outWS->getEventTypeName()); + } + + void test_load_full_mdevents_2d() + { + // Setup the corrupt file. + FileContentsBuilder fileContents; + fileContents.setMDEventEntries("1 1 1 2 -1 -2\n1 1 2 3 2 3\n1 1 3 4 5 6"); // mins -1, -2, maxs 2, 3 + MDFileObject infile(fileContents); + // Run the algorithm. + ConvertMDHistoToMDEventWorkspace alg; + alg.initialize(); + alg.setPropertyValue("Filename", infile.getFileName()); + alg.setPropertyValue("OutputWorkspace", "test_out"); + TS_ASSERT_THROWS_NOTHING(alg.execute()); + TS_ASSERT(alg.isExecuted()); + + IMDEventWorkspace_sptr outWS = AnalysisDataService::Instance().retrieveWS("test_out"); + TS_ASSERT_EQUALS(2, outWS->getNumDims()); + + TS_ASSERT_EQUALS(3, outWS->getNPoints()); + TS_ASSERT_EQUALS("MDEvent", outWS->getEventTypeName()); + } + + void test_load_full_mdevents_3d() + { + // Setup the corrupt file. + FileContentsBuilder fileContents; + + const std::string dim1 = "a A U 10\n"; + const std::string dim2 = "b B U 11\n"; + const std::string dim3 = "c C U 12\n"; // Ooops, forgot to put in the number of bins for this dimension. + + fileContents.setDimensionEntries(dim1 + dim2 + dim3); + fileContents.setMDEventEntries("1 1 1 2 -1 -2 3\n1 1 2 3 2 3 3\n1 1 3 4 5 6 3"); // mins -1, -2, maxs 2, 3 + MDFileObject infile(fileContents); + // Run the algorithm. + ConvertMDHistoToMDEventWorkspace alg; + alg.initialize(); + alg.setPropertyValue("Filename", infile.getFileName()); + alg.setPropertyValue("OutputWorkspace", "test_out"); + TS_ASSERT_THROWS_NOTHING(alg.execute()); + TS_ASSERT(alg.isExecuted()); + + IMDEventWorkspace_sptr outWS = AnalysisDataService::Instance().retrieveWS("test_out"); + TS_ASSERT_EQUALS(3, outWS->getNumDims()); + + TS_ASSERT_EQUALS(3, outWS->getNPoints()); + TS_ASSERT_EQUALS("MDEvent", outWS->getEventTypeName()); + } + + void test_ignore_comment_lines() + { + // Setup the basic file. + FileContentsBuilder fileContents; + // Insert a few comment blocks into the file. + fileContents.setDimensionBlock("# Some Comment!\n" + ConvertMDHistoToMDEventWorkspace::DimensionBlockFlag()); + fileContents.setMDEventBlock("# Some Comment!\n" + ConvertMDHistoToMDEventWorkspace::MDEventBlockFlag()); + + MDFileObject infile(fileContents); + // Run the algorithm. + ConvertMDHistoToMDEventWorkspace alg; + alg.initialize(); + alg.setPropertyValue("Filename", infile.getFileName()); + alg.setPropertyValue("OutputWorkspace", "test_out"); + TS_ASSERT_THROWS_NOTHING(alg.execute()); + // These comment blocks are not being considered if execution completes without throwing + TS_ASSERT(alg.isExecuted()); + + // Sanity check the defaults for the FileContentsBuilder construction. + IMDEventWorkspace_sptr outWS = AnalysisDataService::Instance().retrieveWS("test_out"); + TS_ASSERT_EQUALS(2, outWS->getNumDims()); + TS_ASSERT_EQUALS(1, outWS->getNPoints()); + TS_ASSERT_EQUALS("MDLeanEvent", outWS->getEventTypeName()); + } +}; + +/** +Performance Tests +*/ +class ConvertMDHistoToMDEventWorkspaceTestPerformance : public CxxTest::TestSuite +{ +private: + + const size_t nRows; + boost::shared_ptr infile; + +public: + static ConvertMDHistoToMDEventWorkspaceTestPerformance *createSuite() { return new ConvertMDHistoToMDEventWorkspaceTestPerformance(); } + static void destroySuite( ConvertMDHistoToMDEventWorkspaceTestPerformance *suite ) { delete suite; } + + ConvertMDHistoToMDEventWorkspaceTestPerformance() : nRows(10000) + { + } + + void setUp() + { + // Create the file contents. + FileContentsBuilder fileContents; + std::string mdData; + for(size_t i = 0; i < nRows; ++i) + { + // Create MDEvents + std::stringstream stream; + stream << i << " " << i << " " << i << " " << i << " " << i << " " << i << "\n"; + mdData += stream.str(); + } + // Create a file from the contents. + fileContents.setMDEventEntries(mdData); + infile = boost::make_shared(fileContents); + } + + void testRead() + { + ConvertMDHistoToMDEventWorkspace alg; + alg.initialize(); + alg.setPropertyValue("Filename", infile->getFileName()); + alg.setPropertyValue("OutputWorkspace", "test_out"); + TS_ASSERT_THROWS_NOTHING(alg.execute()); + TS_ASSERT(alg.isExecuted()); + + IMDEventWorkspace_sptr outWS = AnalysisDataService::Instance().retrieveWS("test_out"); + TS_ASSERT_EQUALS(2, outWS->getNumDims()); + + TS_ASSERT_EQUALS(nRows, outWS->getNPoints()); + TS_ASSERT_EQUALS("MDEvent", outWS->getEventTypeName()); + } +}; + + +#endif /* MANTID_MDEVENTS_ConvertMDHistoToMDEventWorkspaceTEST_H_ */