From e3d0c44d94f15f54de89427e4f410b5c5f0e894f Mon Sep 17 00:00:00 2001 From: Anton Piccardo-Selg <anton.piccardo-selg@tessella.com> Date: Mon, 12 Oct 2015 14:43:19 +0100 Subject: [PATCH] Refs #13872 Bring MDframe to more algorihtms --- Framework/API/test/MDGeometryTest.h | 2 - .../src/ReflectometryTransform.cpp | 3 +- .../DataObjects/test/MDEventWorkspaceTest.h | 12 ++-- .../DataObjects/test/MDHistoWorkspaceTest.h | 69 ++++++++++++------- .../MDGeometry/MDHistoDimension.h | 1 - .../test/MDHistoDimensionBuilderTest.h | 3 +- .../Geometry/test/MDHistoDimensionTest.h | 2 +- .../src/ConvertToReflectometryQ.cpp | 8 +-- .../test/ConvertToReflectometryQTest.h | 2 +- 9 files changed, 61 insertions(+), 41 deletions(-) diff --git a/Framework/API/test/MDGeometryTest.h b/Framework/API/test/MDGeometryTest.h index 26c77c4ea2e..a316a1e02a5 100644 --- a/Framework/API/test/MDGeometryTest.h +++ b/Framework/API/test/MDGeometryTest.h @@ -19,7 +19,6 @@ using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::Geometry; - class MDGeometryTest : public CxxTest::TestSuite { public: // This pair of boilerplate methods prevent the suite being created statically @@ -292,7 +291,6 @@ public: TSM_ASSERT("All basis vectors are normalized", geometry.allBasisNormalized()); } - }; #endif /* MANTID_API_MDGEOMETRYTEST_H_ */ diff --git a/Framework/DataObjects/src/ReflectometryTransform.cpp b/Framework/DataObjects/src/ReflectometryTransform.cpp index 67e826a32c6..d6d9dbc1e64 100644 --- a/Framework/DataObjects/src/ReflectometryTransform.cpp +++ b/Framework/DataObjects/src/ReflectometryTransform.cpp @@ -208,7 +208,8 @@ void createVerticalAxis(MatrixWorkspace *const ws, const MantidVec &xAxisVec, */ Mantid::API::IMDEventWorkspace_sptr ReflectometryTransform::executeMD( Mantid::API::MatrixWorkspace_const_sptr inputWs, - BoxController_sptr boxController, Mantid::Geometry::MDFrame_uptr frame) const { + BoxController_sptr boxController, + Mantid::Geometry::MDFrame_uptr frame) const { MDHistoDimension_sptr dim0 = MDHistoDimension_sptr(new MDHistoDimension( m_d0Label, m_d0ID, *frame, static_cast<Mantid::coord_t>(m_d0Min), static_cast<Mantid::coord_t>(m_d0Max), m_d0NumBins)); diff --git a/Framework/DataObjects/test/MDEventWorkspaceTest.h b/Framework/DataObjects/test/MDEventWorkspaceTest.h index 314e810a591..bdae3cfe51b 100644 --- a/Framework/DataObjects/test/MDEventWorkspaceTest.h +++ b/Framework/DataObjects/test/MDEventWorkspaceTest.h @@ -94,8 +94,8 @@ public: MDEventWorkspace<MDLeanEvent<3>, 3> ew3; Mantid::Geometry::GeneralFrame frame("m", "m"); for (size_t i = 0; i < 3; i++) { - ew3.addDimension( - MDHistoDimension_sptr(new MDHistoDimension("x", "x", frame, -1, 1, 0))); + ew3.addDimension(MDHistoDimension_sptr( + new MDHistoDimension("x", "x", frame, -1, 1, 0))); } ew3.initialize(); ew3.getBoxController()->setSplitThreshold(1); @@ -157,8 +157,8 @@ public: Mantid::Geometry::GeneralFrame frame("m", "m"); TS_ASSERT_THROWS(ew->initialize(), std::runtime_error); for (size_t i = 0; i < 5; i++) - ew->addDimension( - MDHistoDimension_sptr(new MDHistoDimension("x", "x", frame, -1, 1, 0))); + ew->addDimension(MDHistoDimension_sptr( + new MDHistoDimension("x", "x", frame, -1, 1, 0))); TS_ASSERT_THROWS(ew->initialize(), std::runtime_error); delete ew; } @@ -168,8 +168,8 @@ public: Mantid::Geometry::GeneralFrame frame("m", "m"); TS_ASSERT_THROWS(ew->initialize(), std::runtime_error); for (size_t i = 0; i < 3; i++) - ew->addDimension( - MDHistoDimension_sptr(new MDHistoDimension("x", "x", frame, -1, 1, 0))); + ew->addDimension(MDHistoDimension_sptr( + new MDHistoDimension("x", "x", frame, -1, 1, 0))); TS_ASSERT_THROWS_NOTHING(ew->initialize()); delete ew; } diff --git a/Framework/DataObjects/test/MDHistoWorkspaceTest.h b/Framework/DataObjects/test/MDHistoWorkspaceTest.h index cd95eb6326c..0352687ddae 100644 --- a/Framework/DataObjects/test/MDHistoWorkspaceTest.h +++ b/Framework/DataObjects/test/MDHistoWorkspaceTest.h @@ -80,10 +80,14 @@ public: //-------------------------------------------------------------------------------------- void test_constructor() { Mantid::Geometry::GeneralFrame frame("m", "m"); - MDHistoDimension_sptr dimX(new MDHistoDimension("X", "x", frame, -10, 10, 5)); - MDHistoDimension_sptr dimY(new MDHistoDimension("Y", "y", frame, -10, 10, 5)); - MDHistoDimension_sptr dimZ(new MDHistoDimension("Z", "z", frame, -10, 10, 5)); - MDHistoDimension_sptr dimT(new MDHistoDimension("T", "t", frame, -10, 10, 5)); + MDHistoDimension_sptr dimX( + new MDHistoDimension("X", "x", frame, -10, 10, 5)); + MDHistoDimension_sptr dimY( + new MDHistoDimension("Y", "y", frame, -10, 10, 5)); + MDHistoDimension_sptr dimZ( + new MDHistoDimension("Z", "z", frame, -10, 10, 5)); + MDHistoDimension_sptr dimT( + new MDHistoDimension("T", "t", frame, -10, 10, 5)); MDHistoWorkspace ws(dimX, dimY, dimZ, dimT); @@ -157,8 +161,10 @@ public: /** Create a dense histogram with only 2 dimensions */ void test_constructor_fewerDimensions() { Mantid::Geometry::GeneralFrame frame("m", "m"); - MDHistoDimension_sptr dimX(new MDHistoDimension("X", "x", frame, -10, 10, 5)); - MDHistoDimension_sptr dimY(new MDHistoDimension("Y", "y", frame, -10, 10, 5)); + MDHistoDimension_sptr dimX( + new MDHistoDimension("X", "x", frame, -10, 10, 5)); + MDHistoDimension_sptr dimY( + new MDHistoDimension("Y", "y", frame, -10, 10, 5)); MDHistoWorkspace ws(dimX, dimY); @@ -243,7 +249,8 @@ public: //--------------------------------------------------------------------------------------------------- void test_getVertexesArray_1D() { Mantid::Geometry::GeneralFrame frame("m", "m"); - MDHistoDimension_sptr dimX(new MDHistoDimension("X", "x", frame, -10, 10, 5)); + MDHistoDimension_sptr dimX( + new MDHistoDimension("X", "x", frame, -10, 10, 5)); MDHistoWorkspace ws(dimX); size_t numVertices; coord_t *v1 = ws.getVertexesArray(0, numVertices); @@ -261,8 +268,10 @@ public: //--------------------------------------------------------------------------------------------------- void test_getVertexesArray_2D() { Mantid::Geometry::GeneralFrame frame("m", "m"); - MDHistoDimension_sptr dimX(new MDHistoDimension("X", "x", frame, -10, 10, 5)); - MDHistoDimension_sptr dimY(new MDHistoDimension("Y", "y", frame, -10, 10, 5)); + MDHistoDimension_sptr dimX( + new MDHistoDimension("X", "x", frame, -10, 10, 5)); + MDHistoDimension_sptr dimY( + new MDHistoDimension("Y", "y", frame, -10, 10, 5)); MDHistoWorkspace ws(dimX, dimY); size_t numVertices, i; @@ -287,9 +296,12 @@ public: //--------------------------------------------------------------------------------------------------- void test_getVertexesArray_3D() { Mantid::Geometry::GeneralFrame frame("m", "m"); - MDHistoDimension_sptr dimX(new MDHistoDimension("X", "x", frame, -10, 10, 5)); - MDHistoDimension_sptr dimY(new MDHistoDimension("Y", "y", frame, -9, 10, 5)); - MDHistoDimension_sptr dimZ(new MDHistoDimension("Z", "z", frame, -8, 10, 5)); + MDHistoDimension_sptr dimX( + new MDHistoDimension("X", "x", frame, -10, 10, 5)); + MDHistoDimension_sptr dimY( + new MDHistoDimension("Y", "y", frame, -9, 10, 5)); + MDHistoDimension_sptr dimZ( + new MDHistoDimension("Z", "z", frame, -8, 10, 5)); MDHistoWorkspace ws(dimX, dimY, dimZ); size_t numVertices, i; @@ -306,8 +318,10 @@ public: Mantid::Geometry::GeneralFrame frame("m", "m"); MDHistoDimension_sptr dimX( new MDHistoDimension("X", "x", frame, -10, 10, 20)); - MDHistoDimension_sptr dimY(new MDHistoDimension("Y", "y", frame, -9, 10, 19)); - MDHistoDimension_sptr dimZ(new MDHistoDimension("Z", "z", frame, -8, 10, 18)); + MDHistoDimension_sptr dimY( + new MDHistoDimension("Y", "y", frame, -9, 10, 19)); + MDHistoDimension_sptr dimZ( + new MDHistoDimension("Z", "z", frame, -8, 10, 18)); MDHistoWorkspace ws(dimX, dimY, dimZ); VMD v = ws.getCenter(0); TS_ASSERT_DELTA(v[0], -9.5, 1e-5); @@ -319,7 +333,8 @@ public: /** Test for a possible seg-fault if nx != ny etc. */ void test_uneven_numbers_of_bins() { Mantid::Geometry::GeneralFrame frame("m", "m"); - MDHistoDimension_sptr dimX(new MDHistoDimension("X", "x", frame, -10, 10, 5)); + MDHistoDimension_sptr dimX( + new MDHistoDimension("X", "x", frame, -10, 10, 5)); MDHistoDimension_sptr dimY( new MDHistoDimension("Y", "y", frame, -10, 10, 10)); MDHistoDimension_sptr dimZ( @@ -359,8 +374,10 @@ public: Mantid::Geometry::GeneralFrame frame("m", "m"); MDHistoDimension_sptr dimX( new MDHistoDimension("X", "x", frame, -10, 10, 10)); - MDHistoDimension_sptr dimY(new MDHistoDimension("Y", "y", frame, -9, 10, 10)); - MDHistoDimension_sptr dimZ(new MDHistoDimension("Z", "z", frame, -8, 10, 10)); + MDHistoDimension_sptr dimY( + new MDHistoDimension("Y", "y", frame, -9, 10, 10)); + MDHistoDimension_sptr dimZ( + new MDHistoDimension("Z", "z", frame, -8, 10, 10)); MDHistoWorkspace ws(dimX, dimY, dimZ); IMDIterator *it = ws.createIterator(); TS_ASSERT(it); @@ -430,10 +447,14 @@ public: "<TDimension>" + "<RefDimensionId>t</RefDimensionId>" + "</TDimension>" + "</DimensionSet>"; Mantid::Geometry::GeneralFrame frame("m", "m"); - MDHistoDimension_sptr dimX(new MDHistoDimension("X", "x", frame, -10, 10, 5)); - MDHistoDimension_sptr dimY(new MDHistoDimension("Y", "y", frame, -10, 10, 5)); - MDHistoDimension_sptr dimZ(new MDHistoDimension("Z", "z", frame, -10, 10, 5)); - MDHistoDimension_sptr dimT(new MDHistoDimension("T", "t", frame, -10, 10, 5)); + MDHistoDimension_sptr dimX( + new MDHistoDimension("X", "x", frame, -10, 10, 5)); + MDHistoDimension_sptr dimY( + new MDHistoDimension("Y", "y", frame, -10, 10, 5)); + MDHistoDimension_sptr dimZ( + new MDHistoDimension("Z", "z", frame, -10, 10, 5)); + MDHistoDimension_sptr dimT( + new MDHistoDimension("T", "t", frame, -10, 10, 5)); MDHistoWorkspace ws(dimX, dimY, dimZ, dimT); @@ -1012,7 +1033,8 @@ public: void test_displayNormalizationDefault() { Mantid::Geometry::GeneralFrame frame("m", "m"); - MDHistoDimension_sptr dimX(new MDHistoDimension("X", "x", frame, -10, 10, 5)); + MDHistoDimension_sptr dimX( + new MDHistoDimension("X", "x", frame, -10, 10, 5)); // Constructor variant 1. MDHistoWorkspace ws1(dimX); TS_ASSERT_EQUALS(Mantid::API::NoNormalization, ws1.displayNormalization()); @@ -1031,7 +1053,8 @@ public: void test_setDisplayNormalization() { auto targetDisplayNormalization = Mantid::API::VolumeNormalization; Mantid::Geometry::GeneralFrame frame("m", "m"); - MDHistoDimension_sptr dimX(new MDHistoDimension("X", "x", frame, -10, 10, 5)); + MDHistoDimension_sptr dimX( + new MDHistoDimension("X", "x", frame, -10, 10, 5)); // Constructor variant 1. MDHistoWorkspace ws1(dimX, dimX, dimX, dimX, targetDisplayNormalization); TS_ASSERT_EQUALS(targetDisplayNormalization, ws1.displayNormalization()); diff --git a/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimension.h b/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimension.h index 6e719ea6833..b1f79d2c1cb 100644 --- a/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimension.h +++ b/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimension.h @@ -23,7 +23,6 @@ namespace Geometry { */ class MANTID_GEOMETRY_DLL MDHistoDimension : public IMDDimension { public: - /** Constructor for simple MDHistoDimension * @param name :: full name of the axis * @param ID :: identifier string diff --git a/Framework/Geometry/test/MDHistoDimensionBuilderTest.h b/Framework/Geometry/test/MDHistoDimensionBuilderTest.h index e627b4e7523..d0bf41995de 100644 --- a/Framework/Geometry/test/MDHistoDimensionBuilderTest.h +++ b/Framework/Geometry/test/MDHistoDimensionBuilderTest.h @@ -80,7 +80,8 @@ public: TS_ASSERT_EQUALS(1, product->getNBins()); TSM_ASSERT_THROWS_NOTHING( "Should have selected GeneralFrame as the frame", - dynamic_cast<const Mantid::Geometry::GeneralFrame &>(product->getMDFrame())); + dynamic_cast<const Mantid::Geometry::GeneralFrame &>( + product->getMDFrame())); } void testCopy() { diff --git a/Framework/Geometry/test/MDHistoDimensionTest.h b/Framework/Geometry/test/MDHistoDimensionTest.h index 65329f94d1f..64b793e19e4 100644 --- a/Framework/Geometry/test/MDHistoDimensionTest.h +++ b/Framework/Geometry/test/MDHistoDimensionTest.h @@ -66,7 +66,7 @@ public: void test_getMDUnits_gives_label_unit() { Kernel::UnitLabel unitLabel("Meters"); - Mantid::Geometry::GeneralFrame frame("Length", unitLabel); + Mantid::Geometry::GeneralFrame frame("Length", unitLabel); MDHistoDimension dimension("Distance", "Dist", frame, 0, 10, 1); const Mantid::Kernel::MDUnit &unit = dimension.getMDUnits(); TS_ASSERT_EQUALS(unit.getUnitLabel(), unitLabel); diff --git a/Framework/MDAlgorithms/src/ConvertToReflectometryQ.cpp b/Framework/MDAlgorithms/src/ConvertToReflectometryQ.cpp index 8ca7d86719f..241b4320ca9 100644 --- a/Framework/MDAlgorithms/src/ConvertToReflectometryQ.cpp +++ b/Framework/MDAlgorithms/src/ConvertToReflectometryQ.cpp @@ -346,22 +346,20 @@ void ConvertToReflectometryQ::exec() { dim0min, dim0max, dim1min, dim1max, incidentTheta, numberOfBinsQx, numberOfBinsQz); frame.reset(new Mantid::Geometry::GeneralFrame( - "P", - Mantid::Kernel::InverseAngstromsUnit().getUnitLabel())); + "P", Mantid::Kernel::InverseAngstromsUnit().getUnitLabel())); } else { transform = boost::make_shared<ReflectometryTransformKiKf>( dim0min, dim0max, dim1min, dim1max, incidentTheta, numberOfBinsQx, numberOfBinsQz); frame.reset(new Mantid::Geometry::GeneralFrame( - "KiKf", - Mantid::Kernel::InverseAngstromsUnit().getUnitLabel())); + "KiKf", Mantid::Kernel::InverseAngstromsUnit().getUnitLabel())); } IMDWorkspace_sptr outputWS; TableWorkspace_sptr vertexes = boost::make_shared<Mantid::DataObjects::TableWorkspace>(); - + if (outputAsMDWorkspace) { if (transMethod == centerTransform()) { auto outputMDWS = transform->executeMD(inputWs, bc, std::move(frame)); diff --git a/Framework/MDAlgorithms/test/ConvertToReflectometryQTest.h b/Framework/MDAlgorithms/test/ConvertToReflectometryQTest.h index c2ae270aed5..b436bca8ad3 100644 --- a/Framework/MDAlgorithms/test/ConvertToReflectometryQTest.h +++ b/Framework/MDAlgorithms/test/ConvertToReflectometryQTest.h @@ -155,7 +155,7 @@ public: "OutputTransformedWorkspace")); TS_ASSERT(ws != NULL); TS_ASSERT_EQUALS(2, ws->getExperimentInfo(0)->run().getLogData().size()); - // Assert that dimensions should be a general frame + // Assert that dimensions should be a general frame const auto &frame0 = ws->getDimension(0)->getMDFrame(); TSM_ASSERT_THROWS_NOTHING( "Should be a QLab frame", -- GitLab