diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/SampleLogsBehaviour.h b/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/SampleLogsBehaviour.h index 842a7c343786ac743d5e3284c44387d6cf540199..9ac1533d055d502b1a3e9474e6c2ee88a3a6b8ce 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/SampleLogsBehaviour.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/SampleLogsBehaviour.h @@ -23,6 +23,7 @@ class MANTID_ALGORITHMS_DLL SampleLogsBehaviour { public: enum class MergeLogType { Sum, TimeSeries, List, Warn, Fail }; + // names of parameters in IPF const std::string SUM_MERGE; const std::string TIME_SERIES_MERGE; const std::string LIST_MERGE; diff --git a/Framework/Algorithms/test/SampleLogsBehaviourTest.h b/Framework/Algorithms/test/SampleLogsBehaviourTest.h index f5e92a8aad47f212ba10b22ac8ace5c768028796..7b44c0eb11879bb05f783695b1b61055a4b84a1e 100644 --- a/Framework/Algorithms/test/SampleLogsBehaviourTest.h +++ b/Framework/Algorithms/test/SampleLogsBehaviourTest.h @@ -24,12 +24,18 @@ #include "MantidKernel/make_cow.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" +#include "MantidDataHandling/LoadParameterFile.h" +#include "MantidGeometry/Instrument.h" +#include "MantidGeometry/Instrument/ParameterMap.h" + using Mantid::Algorithms::CreateSampleWorkspace; using Mantid::Algorithms::GroupWorkspaces; using Mantid::Algorithms::SampleLogsBehaviour; using namespace Mantid::API; +using namespace Mantid::DataHandling; using namespace Mantid::DataObjects; using namespace Mantid::HistogramData; +using namespace Mantid::Geometry; using namespace Mantid::Kernel; using namespace WorkspaceCreationHelper; @@ -42,9 +48,65 @@ public: } static void destroySuite(SampleLogsBehaviourTest *suite) { delete suite; } + // Please note that many tests are currently present in MergeRunsTest. -private: + void testMergeRunsIPFNames() { + // Using default values of the constructor + Logger log("testLog"); + MatrixWorkspace_sptr ws = create2DWorkspaceWithFullInstrument( + 3, 3, true, false, true, "INSTRUMENT"); + // Add sample logs + ws->mutableRun().addLogData(new PropertyWithValue<double>("A", 2.65)); + ws->mutableRun().addLogData(new PropertyWithValue<double>("B", 1.56)); + ws->mutableRun().addLogData(new PropertyWithValue<double>("C", 8.55)); + // Load test parameter file + LoadParameterFile paramLoader; + paramLoader.initialize(); + paramLoader.setPropertyValue( + "Filename", "IDFs_for_UNIT_TESTING/SampleLogsBehaviour_Parameters.xml"); + paramLoader.setProperty("Workspace", ws); + paramLoader.execute(); + SampleLogsBehaviour sbh = SampleLogsBehaviour(ws, log); + sbh.mergeSampleLogs(ws, ws); + const std::string A = ws->run().getLogData("A")->value(); + const std::string B = ws->run().getLogData("B")->value(); + const std::string C = ws->run().getLogData("C")->value(); + TS_ASSERT_EQUALS(A, "2.6499999999999999") + TS_ASSERT_EQUALS(B, "1.5600000000000001") + TS_ASSERT_EQUALS(C, "8.5500000000000007") + } + void testConjoinXRunsIPFNames() { + // Using suffix conjoin_ + default value names for constructing + Logger log("testLog"); + MatrixWorkspace_sptr ws = create2DWorkspaceWithFullInstrument( + 3, 3, true, false, true, "INSTRUMENT"); + // Add sample logs + ws->mutableRun().addLogData(new PropertyWithValue<double>("A", 2.65)); + ws->mutableRun().addLogData(new PropertyWithValue<double>("B", 1.56)); + ws->mutableRun().addLogData(new PropertyWithValue<double>("C", 8.55)); + // Load test parameter file + LoadParameterFile paramLoader; + paramLoader.initialize(); + paramLoader.setPropertyValue( + "Filename", "IDFs_for_UNIT_TESTING/SampleLogsBehaviour_Parameters.xml"); + paramLoader.setProperty("Workspace", ws); + paramLoader.execute(); + SampleLogsBehaviour sbh = SampleLogsBehaviour( + ws, log, "", "", "", "", "", "", "", "conjoin_sample_logs_sum", + "conjoin_sample_logs_time_series", "conjoin_sample_logs_list", + "conjoin_sample_logs_warn", "conjoin_sample_logs_warn_tolerances", + "conjoin_sample_logs_fail", "conjoin_sample_logs_fail_tolerances"); + sbh.mergeSampleLogs(ws, ws); + const std::string A = ws->run().getLogData("A")->value(); + const std::string B = ws->run().getLogData("B")->value(); + const std::string C = ws->run().getLogData("C")->value(); + TS_ASSERT_EQUALS(A, "2.6499999999999999") + TS_ASSERT_EQUALS(B, "1.5600000000000001") + TS_ASSERT_EQUALS(C, "8.5500000000000007") + } + +private: }; #endif /* MANTID_ALGORITHMS_SAMPLELOGSBEHAVIOURTEST_H_ */