From cd3a37c8011164927efb0bac2376dfa0ac5661fd Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Fri, 13 Mar 2015 08:36:30 +0000 Subject: [PATCH 1/7] Fix a doxygen warning. Refs #11350 --- .../Framework/MDEvents/inc/MantidMDEvents/MDBoxFlatTree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBoxFlatTree.h b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBoxFlatTree.h index 7ce65edab215..ef01cbbad77f 100644 --- a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBoxFlatTree.h +++ b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBoxFlatTree.h @@ -138,7 +138,7 @@ class DLLExport MDBoxFlatTree { static void loadExperimentInfos( ::NeXus::File *const file, const std::string & filename, - boost::shared_ptr ei, + boost::shared_ptr mei, bool lazy = false); static void saveAffineTransformMatricies(::NeXus::File *const file, From 7c670e0734ce2a58890b934280afe100426074e4 Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Fri, 13 Mar 2015 09:08:54 +0000 Subject: [PATCH 2/7] Don't populate a file-backed experiment info on cloning. Refs #11350 --- Code/Mantid/Framework/API/src/FileBackedExperimentInfo.cpp | 7 ++++--- .../Framework/API/test/FileBackedExperimentInfoTest.h | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Code/Mantid/Framework/API/src/FileBackedExperimentInfo.cpp b/Code/Mantid/Framework/API/src/FileBackedExperimentInfo.cpp index 79bff7b89c77..64c7084fdff3 100644 --- a/Code/Mantid/Framework/API/src/FileBackedExperimentInfo.cpp +++ b/Code/Mantid/Framework/API/src/FileBackedExperimentInfo.cpp @@ -28,11 +28,12 @@ FileBackedExperimentInfo::FileBackedExperimentInfo(const std::string &filename, : ExperimentInfo(), m_loaded(false), m_filename(filename), m_nxpath(nxpath) {} /** - * @return A clone of the object + * This clones the FileBackedExperimentInfo and will not cause a load + * of the information. + * @return A clone of the object. */ ExperimentInfo *FileBackedExperimentInfo::cloneExperimentInfo() const { - populateIfNotLoaded(); - return ExperimentInfo::cloneExperimentInfo(); + return new FileBackedExperimentInfo(*this); } /// @returns A human-readable description of the object diff --git a/Code/Mantid/Framework/API/test/FileBackedExperimentInfoTest.h b/Code/Mantid/Framework/API/test/FileBackedExperimentInfoTest.h index b7ec12deea26..f3fa9eb6c621 100644 --- a/Code/Mantid/Framework/API/test/FileBackedExperimentInfoTest.h +++ b/Code/Mantid/Framework/API/test/FileBackedExperimentInfoTest.h @@ -45,12 +45,12 @@ class FileBackedExperimentInfoTest : public CxxTest::TestSuite { TS_ASSERT_EQUALS(fileBacked->toString(), m_inMemoryExptInfo->toString()); } - void test_cloneExperimentInfo_populates_object() { + void test_cloneExperimentInfo_returns_new_file_backed_object_and_does_not_touch_file() { auto fileBacked = createTestObject(); auto *clonedFileBacked = fileBacked->cloneExperimentInfo(); - TS_ASSERT_EQUALS(clonedFileBacked->toString(), - m_inMemoryExptInfo->toString()); + TS_ASSERT(dynamic_cast(clonedFileBacked)); + delete clonedFileBacked; } From 2c2672d8e4b4a0b43fc4872c6d6b68cf394de051 Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Fri, 13 Mar 2015 09:25:16 +0000 Subject: [PATCH 3/7] Only copy meta data to most current experiment info If the workspace contains other experiments it is assumed that when they were converted they had their meta data copied at that point. Refs #11350 --- Code/Mantid/Framework/MDAlgorithms/src/ConvertToMD.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Code/Mantid/Framework/MDAlgorithms/src/ConvertToMD.cpp b/Code/Mantid/Framework/MDAlgorithms/src/ConvertToMD.cpp index 3f08264ba430..08c48d4408f3 100644 --- a/Code/Mantid/Framework/MDAlgorithms/src/ConvertToMD.cpp +++ b/Code/Mantid/Framework/MDAlgorithms/src/ConvertToMD.cpp @@ -326,9 +326,13 @@ void ConvertToMD::copyMetaData(API::IMDEventWorkspace_sptr &mdEventWS) const { } } + // The last experiment info should always be the one that refers + // to latest converting workspace. All others should have had this + // information set already uint16_t nexpts = mdEventWS->getNumExperimentInfo(); - for (uint16_t i = 0; i < nexpts; ++i) { - ExperimentInfo_sptr expt = mdEventWS->getExperimentInfo(i); + if (nexpts > 0) { + ExperimentInfo_sptr expt = + mdEventWS->getExperimentInfo(static_cast(nexpts - 1)); expt->mutableRun().storeHistogramBinBoundaries(binBoundaries); expt->cacheDetectorGroupings(*mapping); } From 825f650e152afb243ab7e9233a640a393e999bae Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Fri, 13 Mar 2015 09:25:43 +0000 Subject: [PATCH 4/7] Remove unused log entry. Refs #11350 --- Code/Mantid/Framework/MDEvents/src/MDWSDescription.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Code/Mantid/Framework/MDEvents/src/MDWSDescription.cpp b/Code/Mantid/Framework/MDEvents/src/MDWSDescription.cpp index 10b30e0d7135..43dc60fae2e7 100644 --- a/Code/Mantid/Framework/MDEvents/src/MDWSDescription.cpp +++ b/Code/Mantid/Framework/MDEvents/src/MDWSDescription.cpp @@ -156,16 +156,6 @@ MDWSDescription::buildFromMDWS(const API::IMDEventWorkspace_const_sptr &pWS) { m_DimMax[i] = pDim->getMaximum(); } m_Wtransf = Kernel::DblMatrix(pWS->getWTransf()); - // deal with the case when source MD workspace does not have any experiment - // infos - if (pWS->getNumExperimentInfo() != 0) { - this->addProperty( - "W_MATRIX", - pWS->getExperimentInfo(0) - ->run() - .getPropertyValueAsType>("W_MATRIX"), - true); - } } /** When the workspace has been build from existing MDWrokspace, some target *workspace parameters can not be defined, From 0984ed0b96ace5de867345e33be097f3b780c2d6 Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Fri, 13 Mar 2015 09:26:41 +0000 Subject: [PATCH 5/7] Use last experiment info to store coordinate system This will be the one in memory when using ConvertToMD to accumulate files. Refs #11350 --- .../MDEvents/src/MDEventWorkspace.cpp | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/Code/Mantid/Framework/MDEvents/src/MDEventWorkspace.cpp b/Code/Mantid/Framework/MDEvents/src/MDEventWorkspace.cpp index a81802c9df25..5c1f60e4a847 100644 --- a/Code/Mantid/Framework/MDEvents/src/MDEventWorkspace.cpp +++ b/Code/Mantid/Framework/MDEvents/src/MDEventWorkspace.cpp @@ -787,13 +787,18 @@ Set the special coordinate system (if any) to use. TMDE(void MDEventWorkspace)::setCoordinateSystem( const Mantid::Kernel::SpecialCoordinateSystem coordinateSystem) { // If there isn't an experiment info, create one. - if (this->getNumExperimentInfo() == 0) { - ExperimentInfo_sptr expInfo = - boost::shared_ptr(new ExperimentInfo()); + uint16_t nexpts = this->getNumExperimentInfo(); + ExperimentInfo_sptr expInfo; + if (nexpts == 0) { + expInfo = boost::make_shared(); this->addExperimentInfo(expInfo); } - this->getExperimentInfo(0)->mutableRun().addProperty( - "CoordinateSystem", (int)coordinateSystem, true); + else { + // The last experiment info should always be the one that refers + // to latest converting workspace to use this + expInfo = this->getExperimentInfo(static_cast(nexpts - 1)); + } + expInfo->mutableRun().addProperty("CoordinateSystem", (int)coordinateSystem, true); } /** @@ -806,11 +811,14 @@ TMDE(Mantid::Kernel::SpecialCoordinateSystem try { auto nInfos = this->getNumExperimentInfo(); if (nInfos > 0) { - Property *prop = - this->getExperimentInfo(0)->run().getProperty("CoordinateSystem"); - PropertyWithValue *p = dynamic_cast *>(prop); + // The last experiment info should always be the one that refers + // to latest converting workspace to use this + auto *prop = this->getExperimentInfo(static_cast(nInfos - 1)) + ->run() + .getProperty("CoordinateSystem"); + auto *p = dynamic_cast *>(prop); int temp = *p; - result = (SpecialCoordinateSystem)temp; + result = static_cast(temp); } } catch (Mantid::Kernel::Exception::NotFoundError &) { } From 497b59d286e58b5c4d24237ec4a67408b42987cf Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Fri, 13 Mar 2015 09:27:14 +0000 Subject: [PATCH 6/7] Clang format ConvertToMD. Refs #11350 --- .../MDAlgorithms/src/ConvertToMD.cpp | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/Code/Mantid/Framework/MDAlgorithms/src/ConvertToMD.cpp b/Code/Mantid/Framework/MDAlgorithms/src/ConvertToMD.cpp index 08c48d4408f3..36f8b333c09f 100644 --- a/Code/Mantid/Framework/MDAlgorithms/src/ConvertToMD.cpp +++ b/Code/Mantid/Framework/MDAlgorithms/src/ConvertToMD.cpp @@ -87,8 +87,9 @@ void ConvertToMD::init() { setPropertyGroup("MinRecursionDepth", getBoxSettingsGroupName()); declareProperty( - new PropertyWithValue("InitialSplitting", 0, Direction::Input), - "This option causes an initial split of 50 for the first four dimensions at level 0."); + new PropertyWithValue("InitialSplitting", 0, Direction::Input), + "This option causes an initial split of 50 for the first four dimensions " + "at level 0."); } //---------------------------------------------------------------------------------------------- /** Destructor @@ -475,13 +476,10 @@ API::IMDEventWorkspace_sptr ConvertToMD::createNewMDWorkspace( // Check if the user want sto force an initial split or not bool initialSplittingChecked = this->getProperty("InitialSplitting"); - if (!initialSplittingChecked) - { + if (!initialSplittingChecked) { // split boxes; spws->splitBox(); - } - else - { + } else { // Perform initial split with the forced settings performInitialSplitting(spws, bc); } @@ -498,26 +496,27 @@ API::IMDEventWorkspace_sptr ConvertToMD::createNewMDWorkspace( } /** - * Splits the initial box at level 0 into a defined number of subboxes for the the first level. + * Splits the initial box at level 0 into a defined number of subboxes for the + * the first level. * @param spws A pointer to the newly created event workspace. * @param bc A pointer to the box controller. */ -void ConvertToMD::performInitialSplitting(API::IMDEventWorkspace_sptr spws, Mantid::API::BoxController_sptr bc) -{ +void ConvertToMD::performInitialSplitting(API::IMDEventWorkspace_sptr spws, + Mantid::API::BoxController_sptr bc) { const size_t initialSplitSetting = 50; const size_t dimCutoff = 4; - // Record the split settings of the box controller in a buffer and set the new value + // Record the split settings of the box controller in a buffer and set the new + // value std::vector splitBuffer; - - for (size_t dim = 0; dim < bc->getNDims(); dim++) - { + + for (size_t dim = 0; dim < bc->getNDims(); dim++) { splitBuffer.push_back(bc->getSplitInto(dim)); - // Replace the box controller setting only for a max of the first three dimensions - if (dim < dimCutoff) - { - bc->setSplitInto(dim, initialSplitSetting); + // Replace the box controller setting only for a max of the first three + // dimensions + if (dim < dimCutoff) { + bc->setSplitInto(dim, initialSplitSetting); } } @@ -525,8 +524,7 @@ void ConvertToMD::performInitialSplitting(API::IMDEventWorkspace_sptr spws, Mant spws->splitBox(); // Revert changes on the box controller - for (size_t dim = 0; dim < bc->getNDims(); ++dim) - { + for (size_t dim = 0; dim < bc->getNDims(); ++dim) { bc->setSplitInto(dim, splitBuffer[dim]); } } From 41d3b6d60f5023dffb4ef1cdbe278d91613501fd Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Fri, 13 Mar 2015 15:35:07 +0000 Subject: [PATCH 7/7] Fix VatesAPI test that alters the number of ExperimentInfo objects Refs #11350 --- .../VatesAPI/test/vtkDataSetToNonOrthogonalDataSetTest.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Code/Mantid/Vates/VatesAPI/test/vtkDataSetToNonOrthogonalDataSetTest.h b/Code/Mantid/Vates/VatesAPI/test/vtkDataSetToNonOrthogonalDataSetTest.h index 7bdafe9ce686..742dfdc8acac 100644 --- a/Code/Mantid/Vates/VatesAPI/test/vtkDataSetToNonOrthogonalDataSetTest.h +++ b/Code/Mantid/Vates/VatesAPI/test/vtkDataSetToNonOrthogonalDataSetTest.h @@ -39,7 +39,6 @@ class vtkDataSetToNonOrthogonalDataSetTest : public CxxTest::TestSuite // information necessary for the non-orthogonal axes std::string wsName = "simpleWS"; IMDEventWorkspace_sptr ws = makeAnyMDEW, 4>(1, 0.0, 1.0, 1, wsName); - // Set the coordinate system if (!wrongCoords) { @@ -51,9 +50,6 @@ class vtkDataSetToNonOrthogonalDataSetTest : public CxxTest::TestSuite } // Set the UB matrix - ExperimentInfo_sptr expInfo = ExperimentInfo_sptr(new ExperimentInfo()); - ws->addExperimentInfo(expInfo); - if (!forgetUB) { IAlgorithm_sptr alg = AlgorithmManager::Instance().create("SetUB");