diff --git a/Framework/API/test/MatrixWorkspaceTest.h b/Framework/API/test/MatrixWorkspaceTest.h index 73a74dc9f39622807b139e9e818a02158c22e81b..0199d7c170fa63dcefbd490fe0c0ae5b1010bcab 100644 --- a/Framework/API/test/MatrixWorkspaceTest.h +++ b/Framework/API/test/MatrixWorkspaceTest.h @@ -1648,15 +1648,18 @@ public: auto ws2 = makeWorkspaceWithDetectors(1, 1); auto &detInfo1 = ws1->mutableDetectorInfo(); auto &detInfo2 = ws2->mutableDetectorInfo(); + // auto &compInfo2 = ws2->mutableComponentInfo(); detInfo1.setPosition(0, {1, 0, 0}); detInfo2.setPosition(0, {2, 0, 0}); - detInfo1.setScanInterval(0, {10, 20}); - detInfo2.setScanInterval(0, {20, 30}); + detInfo1.setScanInterval({10, 20}); + detInfo2.setScanInterval({20, 30}); // Merge auto merged = WorkspaceFactory::Instance().create(ws1, 2); - auto &detInfo = merged->mutableDetectorInfo(); - detInfo.merge(detInfo2); + // auto &detInfo = merged->mutableDetectorInfo(); + // detInfo.merge(detInfo2); + merged->mutableComponentInfo().merge(ws2->mutableComponentInfo()); + // Setting IndexInfo without spectrum definitions will set up a 1:1 mapping // such that each spectrum corresponds to 1 time index of a detector. diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MergeRuns.h b/Framework/Algorithms/inc/MantidAlgorithms/MergeRuns.h index 7481afb4dbe89636de774073e2eee990c3192cab..a9522620e4cef83f6b0c25997b365e987f80fcc8 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MergeRuns.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MergeRuns.h @@ -165,7 +165,6 @@ private: std::vector<SpectrumDefinition> buildScanIntervals(const std::vector<SpectrumDefinition> &addeeSpecDefs, const Geometry::DetectorInfo &addeeDetInfo, - const Geometry::DetectorInfo &outDetInfo, const Geometry::DetectorInfo &newOutDetInfo); }; diff --git a/Framework/Algorithms/src/MergeRuns.cpp b/Framework/Algorithms/src/MergeRuns.cpp index df70e3c88c57140f9eb4d4b572b60c12cf21de15..76233e0cc8db8e8073880613fd3277698c43233d 100644 --- a/Framework/Algorithms/src/MergeRuns.cpp +++ b/Framework/Algorithms/src/MergeRuns.cpp @@ -145,7 +145,7 @@ MergeRuns::buildScanningOutputWorkspace(const MatrixWorkspace_sptr &outWS, const auto newAddeeSpecDefs = buildScanIntervals(addeeSpecDefs, addeeWS->detectorInfo(), - outWS->detectorInfo(), newOutWS->detectorInfo()); + newOutWS->detectorInfo()); outSpecDefs.insert(outSpecDefs.end(), newAddeeSpecDefs.begin(), newAddeeSpecDefs.end()); @@ -711,58 +711,34 @@ void MergeRuns::fillHistory() { *the scan times for the addee workspace and output workspace are the same this *builds the same indexing as the workspace had before. Otherwise, the correct *time indexes are set here. + * + *This function translates time indices from the addee to the new workspace. */ std::vector<SpectrumDefinition> MergeRuns::buildScanIntervals( const std::vector<SpectrumDefinition> &addeeSpecDefs, - const DetectorInfo &addeeDetInfo, const DetectorInfo &outDetInfo, - const DetectorInfo &newOutDetInfo) { + const DetectorInfo &addeeDetInfo, const DetectorInfo &newOutDetInfo) { std::vector<SpectrumDefinition> newAddeeSpecDefs(addeeSpecDefs.size()); - const auto &addeeScanIntervals = addeeDetInfo.scanIntervals(); - const auto &outScanIntervals = outDetInfo.scanIntervals(); - const auto &newOutScanIntervals = newOutDetInfo.scanIntervals(); - PARALLEL_FOR_NO_WSP_CHECK() for (int64_t i = 0; i < int64_t(addeeSpecDefs.size()); ++i) { for (auto &index : addeeSpecDefs[i]) { SpectrumDefinition newSpecDef; - // const auto &addeeScanInterval = addeeDetInfo.scanInterval(index); - // if (addeeScanInterval == outDetInfo.scanInterval(index)) { - if (addeeScanIntervals[index] == outScanIntervals[index]) { - newSpecDef.add(index.first, index.second); - } else { + // const auto &addeeScanInterval = addeeDetInfo.scanIntervals()[index.second]; + // if (addeeScanInterval == outDetInfo.scanIntervals()[index.second]) { + // newSpecDef.add(index.first, index.second); + // } else { // Find the correct time index for this entry - for (size_t j = 0; j < newOutDetInfo.scanCount(); j++) { - if (addeeScanIntervals[index] == - newOutScanInterval[{index.first, j}]) { - newSpecDef.add(index.first, j); - } + for (size_t time_index = 0; time_index < newOutDetInfo.scanCount(); time_index++) { + if (addeeDetInfo.scanIntervals()[index.second] == + newOutDetInfo.scanIntervals()[time_index]) { + newSpecDef.add(index.first, time_index); } } + // } newAddeeSpecDefs[i] = newSpecDef; } } - // PARALLEL_FOR_NO_WSP_CHECK() - // for (int64_t i = 0; i < int64_t(addeeSpecDefs.size()); ++i) { - // for (auto &index : addeeSpecDefs[i]) { - // SpectrumDefinition newSpecDef; - // const auto &addeeScanInterval = addeeDetInfo.scanInterval(index); - // if (addeeScanInterval == outDetInfo.scanInterval(index)) { - // newSpecDef.add(index.first, index.second); - // } else { - // // Find the correct time index for this entry - // for (size_t i = 0; i < newOutDetInfo.scanCount(index.first); i++) { - // if (addeeScanInterval == - // newOutDetInfo.scanInterval({index.first, i})) { - // newSpecDef.add(index.first, i); - // } - // } - // } - // newAddeeSpecDefs[i] = newSpecDef; - // } - // } - return newAddeeSpecDefs; } diff --git a/Framework/Algorithms/src/NormaliseToMonitor.cpp b/Framework/Algorithms/src/NormaliseToMonitor.cpp index 1571e925a9f807f7c1eb00f2ab2f023127dc8133..760f55463f07edcf0b2b48aeb48389f1b0196b84 100644 --- a/Framework/Algorithms/src/NormaliseToMonitor.cpp +++ b/Framework/Algorithms/src/NormaliseToMonitor.cpp @@ -378,10 +378,10 @@ void NormaliseToMonitor::checkProperties( Property *monID = getProperty("MonitorID"); // Is the monitor spectrum within the main input workspace const bool inWS = !monSpec->isDefault(); - m_syncScanInput = inputWorkspace->detectorInfo().isSyncScan(); + // m_syncScanInput = inputWorkspace->detectorInfo().isSyncScan(); // Or is it in a separate workspace bool sepWS{monWS}; - if (m_syncScanInput && sepWS) + if (sepWS) throw std::runtime_error("Can not currently use a separate monitor " "workspace with a detector scan input workspace."); // or monitor ID @@ -428,10 +428,10 @@ void NormaliseToMonitor::checkProperties( "monitor - the instrument is not fully specified.\n " "Continuing with normalization regardless."); g_log.warning() << "Error was: " << e.what() << "\n"; - if (m_syncScanInput) - throw std::runtime_error("Can not continue, spectrum can not be obtained " - "for monitor workspace, but the input workspace " - "has a detector scan."); + // if (m_syncScanInput) + throw std::runtime_error("Can not continue, spectrum can not be obtained " + "for monitor workspace, but the input workspace " + "has a detector scan."); } } diff --git a/Framework/Algorithms/test/CreateSampleWorkspaceTest.h b/Framework/Algorithms/test/CreateSampleWorkspaceTest.h index 8795049171a096973df1995d7535e961dd7230f0..81ad70549d1941f9c369f88c49d318861d6e7fb2 100644 --- a/Framework/Algorithms/test/CreateSampleWorkspaceTest.h +++ b/Framework/Algorithms/test/CreateSampleWorkspaceTest.h @@ -540,7 +540,7 @@ public: const auto radiansToDegrees = 180.0 / M_PI; // The centre pixel should go from 0 -> 10 degrees, all at the same l2 - for (size_t j = 0; j < detectorInfo.scanCount(centreDetector); ++j) { + for (size_t j = 0; j < detectorInfo.scanCount(); ++j) { const auto index = std::pair<size_t, size_t>(centreDetector, j); TS_ASSERT_DELTA(10.0, detectorInfo.l2(index), 1e-10); TS_ASSERT_DELTA(j, detectorInfo.twoTheta(index) * radiansToDegrees, diff --git a/Framework/Algorithms/test/MergeRunsTest.h b/Framework/Algorithms/test/MergeRunsTest.h index 11be39dc86812b9e5fe52c96b31831da8a4d5b66..f1e54ceb5a7ad1405c83afe3b875e378f9924e35 100644 --- a/Framework/Algorithms/test/MergeRunsTest.h +++ b/Framework/Algorithms/test/MergeRunsTest.h @@ -1541,10 +1541,10 @@ public: const auto PAIR_1 = std::pair<DateAndTime, DateAndTime>(TIME_1, TIME_2); const auto PAIR_2 = std::pair<DateAndTime, DateAndTime>(TIME_2, TIME_3); - TS_ASSERT_EQUALS(detInfo.scanInterval({0, 0}), PAIR_1) - TS_ASSERT_EQUALS(detInfo.scanInterval({1, 0}), PAIR_1) - TS_ASSERT_EQUALS(detInfo.scanInterval({0, 1}), PAIR_2) - TS_ASSERT_EQUALS(detInfo.scanInterval({1, 1}), PAIR_2) + TS_ASSERT_EQUALS(detInfo.scanIntervals()[0], PAIR_1) + // TS_ASSERT_EQUALS(detInfo.scanIntervals()[0], PAIR_1) + TS_ASSERT_EQUALS(detInfo.scanIntervals()[1], PAIR_2) + // TS_ASSERT_EQUALS(detInfo.scanIntervals()[1], PAIR_2) if (extraTimes) { const auto TIME_4 = DateAndTime(20, 0); @@ -1554,10 +1554,10 @@ public: const auto PAIR_3 = std::pair<DateAndTime, DateAndTime>(TIME_4, TIME_5); const auto PAIR_4 = std::pair<DateAndTime, DateAndTime>(TIME_5, TIME_6); - TS_ASSERT_EQUALS(detInfo.scanInterval({0, 2}), PAIR_3) - TS_ASSERT_EQUALS(detInfo.scanInterval({1, 2}), PAIR_3) - TS_ASSERT_EQUALS(detInfo.scanInterval({0, 3}), PAIR_4) - TS_ASSERT_EQUALS(detInfo.scanInterval({1, 3}), PAIR_4) + TS_ASSERT_EQUALS(detInfo.scanIntervals()[2], PAIR_3) + // TS_ASSERT_EQUALS(detInfo.scanIntervals()[2], PAIR_3) + TS_ASSERT_EQUALS(detInfo.scanIntervals()[3], PAIR_4) + // TS_ASSERT_EQUALS(detInfo.scanIntervals()[3], PAIR_4) } } @@ -1612,8 +1612,8 @@ public: const auto &detInfo = outputWS->detectorInfo(); TS_ASSERT_EQUALS(detInfo.size(), 2) - TS_ASSERT_EQUALS(detInfo.scanCount(0), 4) - TS_ASSERT_EQUALS(detInfo.scanCount(1), 4) + TS_ASSERT_EQUALS(detInfo.scanCount(), 4) + // TS_ASSERT_EQUALS(detInfo.scanCount(1), 4) assert_scan_intervals_are_correct(detInfo, true); const auto &specInfo = outputWS->spectrumInfo(); @@ -1643,7 +1643,7 @@ public: auto outputWS = do_MergeRuns_with_scanning_workspaces(); TS_ASSERT_EQUALS(outputWS->detectorInfo().size(), 2) - TS_ASSERT_EQUALS(outputWS->detectorInfo().scanCount(0), 2) + TS_ASSERT_EQUALS(outputWS->detectorInfo().scanCount(), 2) TS_ASSERT_EQUALS(outputWS->getNumberHistograms(), 4) // Check bins are set correctly @@ -1721,7 +1721,7 @@ public: "outWS")); TS_ASSERT_EQUALS(outputWS->detectorInfo().size(), 2) - TS_ASSERT_EQUALS(outputWS->detectorInfo().scanCount(0), 2) + TS_ASSERT_EQUALS(outputWS->detectorInfo().scanCount(), 2) TS_ASSERT_EQUALS(outputWS->getNumberHistograms(), 4) // Check bins are set correctly diff --git a/Framework/Algorithms/test/NormaliseToMonitorTest.h b/Framework/Algorithms/test/NormaliseToMonitorTest.h index db6de5e655b4a023193e3317026813bc45edacc2..ac5f3380a7231e8979ec6d25f8070575903e9f7c 100644 --- a/Framework/Algorithms/test/NormaliseToMonitorTest.h +++ b/Framework/Algorithms/test/NormaliseToMonitorTest.h @@ -10,6 +10,7 @@ #include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/DetectorInfo.h" +#include "MantidGeometry/Instrument/ComponentInfo.h" #include "MantidHistogramData/BinEdges.h" #include "MantidHistogramData/Counts.h" #include "MantidHistogramData/LinearGenerator.h" @@ -511,14 +512,16 @@ public: N_DET, N_BINS, true); auto &detInfo1 = ws1->mutableDetectorInfo(); auto &detInfo2 = ws2->mutableDetectorInfo(); - for (size_t i = 0; i < N_DET; ++i) { - detInfo1.setScanInterval(i, {10, 20}); - detInfo2.setScanInterval(i, {20, 30}); - } + // auto &cmpInfo2 = ws2->mutableComponentInfo(); + + // for (size_t i = 0; i < N_DET; ++i) { + detInfo1.setScanInterval({10, 20}); + detInfo2.setScanInterval({20, 30}); + // } // Merge auto merged = WorkspaceFactory::Instance().create(ws1, 2 * N_DET); - auto &detInfo = merged->mutableDetectorInfo(); - detInfo.merge(detInfo2); + auto &cmpInfo = merged->mutableComponentInfo(); + cmpInfo.merge(ws2->mutableComponentInfo()); merged->setIndexInfo(Indexing::IndexInfo(merged->getNumberHistograms())); NormaliseToMonitor alg; diff --git a/Framework/Beamline/inc/MantidBeamline/ComponentInfo.h b/Framework/Beamline/inc/MantidBeamline/ComponentInfo.h index d3f0e88fc529066feb6ada16859a9e5f287d3288..b765ebfdd7a0937ebd92c84eaf35accb90992c0e 100644 --- a/Framework/Beamline/inc/MantidBeamline/ComponentInfo.h +++ b/Framework/Beamline/inc/MantidBeamline/ComponentInfo.h @@ -144,6 +144,7 @@ public: bool hasParent(const size_t componentIndex) const; bool hasDetectorInfo() const; void setDetectorInfo(DetectorInfo *detectorInfo); + // const DetectorInfo &getDetectorInfo() const {return *m_detectorInfo;} bool hasSource() const; bool hasSample() const; Eigen::Vector3d sourcePosition() const; @@ -165,7 +166,7 @@ public: bool isScanning() const; // std::pair<int64_t, int64_t> // scanInterval(const std::pair<size_t, size_t> &index) const; - const std::vector<std::pair<int64_t, int64_t>> &scanIntervals() const; + const std::vector<std::pair<int64_t, int64_t>> &scanIntervals() const {return m_scanIntervals;} void setScanInterval(const std::pair<int64_t, int64_t> &interval); void merge(const ComponentInfo &other); diff --git a/Framework/Beamline/src/ComponentInfo.cpp b/Framework/Beamline/src/ComponentInfo.cpp index da08cfdba2b5bb0c6b040b97be53b9d79bdcf663..684cc974a1de2623630d554c2b0c47e64d44a649 100644 --- a/Framework/Beamline/src/ComponentInfo.cpp +++ b/Framework/Beamline/src/ComponentInfo.cpp @@ -601,24 +601,24 @@ void ComponentInfo::checkNoTimeDependence() const { "beamline has time-dependent (moving) components."); } -/** - * Retrieve the scan interval for a component at a time index - * @param index component index, time index pair - * @return offset interval times since epoch - */ -const std::vector<std::pair<int64_t, int64_t>> &ComponentInfo::scanIntervals() const { -// if (!m_scanIntervals) { -// // // return &{0, 0}; -// std::vector<std::pair<int64_t, int64_t>>* dummy_vec = new std::vector<std::pair<int64_t, int64_t>> (1); -// // std::pair<int64_t, int64_t> dummy_pair = {0,0}; -// // dummy_vec[0] = dummy_pair; -// dummy_vec->push_back({0, 0}); -// return *dummy_vec; -// // return new std::vector<std::pair<int64_t, int64_t>> {{0,0}}; -// } else { - return m_scanIntervals; - // } -} +// /** +// * Retrieve the scan interval for a component at a time index +// * @param index component index, time index pair +// * @return offset interval times since epoch +// */ +// const std::vector<std::pair<int64_t, int64_t>> &ComponentInfo::scanIntervals() const { +// // if (!m_scanIntervals) { +// // // // return &{0, 0}; +// // std::vector<std::pair<int64_t, int64_t>>* dummy_vec = new std::vector<std::pair<int64_t, int64_t>> (1); +// // // std::pair<int64_t, int64_t> dummy_pair = {0,0}; +// // // dummy_vec[0] = dummy_pair; +// // dummy_vec->push_back({0, 0}); +// // return *dummy_vec; +// // // return new std::vector<std::pair<int64_t, int64_t>> {{0,0}}; +// // } else { +// return m_scanIntervals; +// // } +// } // std::pair<int64_t, int64_t> // ComponentInfo::scanInterval(const std::pair<size_t, size_t> &index) const { diff --git a/Framework/Beamline/test/ComponentInfoTest.h b/Framework/Beamline/test/ComponentInfoTest.h index 15dc0a64f57527659cdb875244a63db192781bdd..ab43b506f491d29ac051dedf0a72bcf26b17ce1c 100644 --- a/Framework/Beamline/test/ComponentInfoTest.h +++ b/Framework/Beamline/test/ComponentInfoTest.h @@ -845,7 +845,7 @@ public: void test_scan_count_no_scanning() { ComponentInfo info; - TS_ASSERT_EQUALS(info.scanCount(0), 1); + TS_ASSERT_EQUALS(info.scanCount(), 1); } void test_unmerged_is_not_scanning() { @@ -949,11 +949,11 @@ public: ComponentInfo &b = *std::get<0>(infos2); b.setScanInterval({0, 10}); - TSM_ASSERT_EQUALS("Scan size should be 1", b.scanCount(0), 1); + TSM_ASSERT_EQUALS("Scan size should be 1", b.scanCount(), 1); b.merge(a); TS_ASSERT_THROWS_NOTHING(b.merge(a)); TSM_ASSERT_EQUALS("Intervals identical. Scan size should not grow", - b.scanCount(0), 1) + b.scanCount(), 1) } void test_merge_identical_interval_when_positions_differ() { @@ -1048,22 +1048,22 @@ public: TS_ASSERT(a.isScanning()); TS_ASSERT_EQUALS(a.size(), 2); TS_ASSERT_EQUALS(a.scanSize(), a.size() + b.size()); - TS_ASSERT_EQUALS(a.scanCount(0), 2); + TS_ASSERT_EQUALS(a.scanCount(), 2); // Note that the order is not guaranteed, currently these are just in the // order in which the are merged. auto index1 = std::pair<size_t, size_t>(0 /*static index*/, 0 /*time index*/); auto index2 = std::pair<size_t, size_t>(0 /*static index*/, 1 /*time index*/); - TS_ASSERT_EQUALS(a.scanInterval(index1), interval1); - TS_ASSERT_EQUALS(a.scanInterval(index2), interval2); + TS_ASSERT_EQUALS(a.scanIntervals()[index1.second], interval1); + TS_ASSERT_EQUALS(a.scanIntervals()[index2.second], interval2); TS_ASSERT_EQUALS(a.position(index1), pos1); TS_ASSERT_EQUALS(a.position(index2), pos2); // Test Detector info is synched internally const DetectorInfo &mergeDetectorInfo = *std::get<1>(infos1); - TS_ASSERT_EQUALS(mergeDetectorInfo.scanCount(0), 2); - TS_ASSERT_EQUALS(mergeDetectorInfo.scanInterval(index1), interval1); - TS_ASSERT_EQUALS(mergeDetectorInfo.scanInterval(index2), interval2); + TS_ASSERT_EQUALS(mergeDetectorInfo.scanCount(), 2); + TS_ASSERT_EQUALS(mergeDetectorInfo.scanIntervals()[index1.second], interval1); + TS_ASSERT_EQUALS(mergeDetectorInfo.scanIntervals()[index2.second], interval2); TS_ASSERT_EQUALS(mergeDetectorInfo.position(index1), pos1); TS_ASSERT_EQUALS(mergeDetectorInfo.position(index2), pos2); } @@ -1090,23 +1090,23 @@ public: TS_ASSERT(a.isScanning()); TS_ASSERT_EQUALS(a.size(), 2); TS_ASSERT_EQUALS(a.scanSize(), 2 * 2); - TS_ASSERT_EQUALS(a.scanCount(a.root()), 2); + TS_ASSERT_EQUALS(a.scanCount(), 2); // Note that the order is not guaranteed, currently these are just in the // order in which the are merged. auto index1 = std::pair<size_t, size_t>(a.root() /*static index*/, 0 /*time index*/); auto index2 = std::pair<size_t, size_t>(a.root() /*static index*/, 1 /*time index*/); - TS_ASSERT_EQUALS(a.scanInterval(index1), interval1); - TS_ASSERT_EQUALS(a.scanInterval(index2), interval2); + TS_ASSERT_EQUALS(a.scanIntervals()[index1.second], interval1); + TS_ASSERT_EQUALS(a.scanIntervals()[index2.second], interval2); TS_ASSERT_EQUALS(a.position(index1), pos1); TS_ASSERT_EQUALS(a.position(index2), pos2); // Test Detector info is synched internally const DetectorInfo &mergeDetectorInfo = *std::get<1>(infos1); - TS_ASSERT_EQUALS(mergeDetectorInfo.scanCount(0), 1 * 2); - TS_ASSERT_EQUALS(mergeDetectorInfo.scanInterval({0, 0}), interval1); - TS_ASSERT_EQUALS(mergeDetectorInfo.scanInterval({0, 1}), interval2); + TS_ASSERT_EQUALS(mergeDetectorInfo.scanCount(), 1 * 2); + TS_ASSERT_EQUALS(mergeDetectorInfo.scanIntervals()[0], interval1); + TS_ASSERT_EQUALS(mergeDetectorInfo.scanIntervals()[1], interval2); // Check that the child detectors have been positioned according to the // correct offsets const auto rootOffsetA = pos1 - rootPosA; @@ -1136,22 +1136,22 @@ public: TS_ASSERT(a.isScanning()); TS_ASSERT_EQUALS(a.size(), 2); TS_ASSERT_EQUALS(a.scanSize(), 2 * 2); - TS_ASSERT_EQUALS(a.scanCount(a.root()), 2); + TS_ASSERT_EQUALS(a.scanCount(), 2); // Note that the order is not guaranteed, currently these are just in the // order in which the are merged. auto index1 = std::pair<size_t, size_t>(a.root() /*static index*/, 0 /*time index*/); auto index2 = std::pair<size_t, size_t>(a.root() /*static index*/, 1 /*time index*/); - TS_ASSERT_EQUALS(a.scanInterval(index1), interval1); - TS_ASSERT_EQUALS(a.scanInterval(index2), interval2); + TS_ASSERT_EQUALS(a.scanIntervals()[index1.second], interval1); + TS_ASSERT_EQUALS(a.scanIntervals()[index2.second], interval2); TS_ASSERT(a.rotation(index1).isApprox(rot1)); TS_ASSERT(a.rotation(index2).isApprox(rot2)); // Test Detector info is synched internally const DetectorInfo &mergeDetectorInfo = *std::get<1>(infos1); - TS_ASSERT_EQUALS(mergeDetectorInfo.scanCount(0), 1 * 2); - TS_ASSERT_EQUALS(mergeDetectorInfo.scanInterval({0, 0}), interval1); + TS_ASSERT_EQUALS(mergeDetectorInfo.scanCount(), 1 * 2); + TS_ASSERT_EQUALS(mergeDetectorInfo.scanIntervals()[0], interval1); // Check detectors moved correctly as a result of root rotation // Detector at x=1,y=0,z=0 rotated around root at x=0,y=0,z=0 with rotation // vector y=1, 90 degrees @@ -1187,7 +1187,7 @@ public: TS_ASSERT(a.isScanning()); TS_ASSERT_EQUALS(a.size(), 2); TS_ASSERT_EQUALS(a.scanSize(), 2 * 3); - TS_ASSERT_EQUALS(a.scanCount(a.root()), 3); + TS_ASSERT_EQUALS(a.scanCount(), 3); // Note that the order is not guaranteed, currently these are just in the // order in which the are merged. auto index1 = @@ -1196,19 +1196,19 @@ public: std::pair<size_t, size_t>(a.root() /*static index*/, 1 /*time index*/); auto index3 = std::pair<size_t, size_t>(a.root() /*static index*/, 2 /*time index*/); - TS_ASSERT_EQUALS(a.scanInterval(index1), interval1); - TS_ASSERT_EQUALS(a.scanInterval(index2), interval2); - TS_ASSERT_EQUALS(a.scanInterval(index3), interval3); + TS_ASSERT_EQUALS(a.scanIntervals()[index1.second], interval1); + TS_ASSERT_EQUALS(a.scanIntervals()[index2.second], interval2); + TS_ASSERT_EQUALS(a.scanIntervals()[index3.second], interval3); TS_ASSERT_EQUALS(a.position(index1), pos1); TS_ASSERT_EQUALS(a.position(index2), pos2); TS_ASSERT_EQUALS(a.position(index3), pos3); // Test Detector info is synched internally const DetectorInfo &mergeDetectorInfo = *std::get<1>(infos1); - TS_ASSERT_EQUALS(mergeDetectorInfo.scanCount(0), 1 * 3); - TS_ASSERT_EQUALS(mergeDetectorInfo.scanInterval({0, 0}), interval1); - TS_ASSERT_EQUALS(mergeDetectorInfo.scanInterval({0, 1}), interval2); - TS_ASSERT_EQUALS(mergeDetectorInfo.scanInterval({0, 2}), interval3); + TS_ASSERT_EQUALS(mergeDetectorInfo.scanCount(), 1 * 3); + TS_ASSERT_EQUALS(mergeDetectorInfo.scanIntervals()[0], interval1); + TS_ASSERT_EQUALS(mergeDetectorInfo.scanIntervals()[1], interval2); + TS_ASSERT_EQUALS(mergeDetectorInfo.scanIntervals()[2], interval3); } }; #endif /* MANTID_BEAMLINE_COMPONENTINFOTEST_H_ */ diff --git a/Framework/Beamline/test/DetectorInfoTest.h b/Framework/Beamline/test/DetectorInfoTest.h index b60c842ff99559d04275fd0d7453a256480dee12..081b6ec78a1ac175e90e0eff9c9c9f685f85175d 100644 --- a/Framework/Beamline/test/DetectorInfoTest.h +++ b/Framework/Beamline/test/DetectorInfoTest.h @@ -273,89 +273,97 @@ public: void test_scanCount() { DetectorInfo info(PosVec(1), RotVec(1)); - TS_ASSERT_EQUALS(info.scanCount(0), 1); + TS_ASSERT_EQUALS(info.scanCount(), 1); } void test_scanInterval() { DetectorInfo info(PosVec(1), RotVec(1)); - TS_ASSERT_EQUALS(info.scanInterval({0, 0}), + TS_ASSERT_EQUALS(info.scanIntervals()[0], (std::pair<int64_t, int64_t>(0, 0))); } - void test_setScanInterval() { - DetectorInfo info(PosVec(1), RotVec(1)); - info.setScanInterval(0, {1, 2}); - TS_ASSERT_EQUALS(info.scanInterval({0, 0}), - (std::pair<int64_t, int64_t>(1, 2))); - info.setScanInterval(0, {1, 3}); - TS_ASSERT_EQUALS(info.scanInterval({0, 0}), - (std::pair<int64_t, int64_t>(1, 3))); - } + // void test_setScanInterval() { + // DetectorInfo info(PosVec(1), RotVec(1)); + // info.setScanInterval(0, {1, 2}); + // TS_ASSERT_EQUALS(info.scanInterval({0, 0}), + // (std::pair<int64_t, int64_t>(1, 2))); + // info.setScanInterval(0, {1, 3}); + // TS_ASSERT_EQUALS(info.scanInterval({0, 0}), + // (std::pair<int64_t, int64_t>(1, 3))); + // } - void test_setScanInterval_sync() { + void test_setScanInterval() { DetectorInfo info(PosVec(2), RotVec(2)); std::pair<int64_t, int64_t> interval(1, 2); info.setScanInterval(interval); - TS_ASSERT_EQUALS(info.scanInterval({0, 0}), interval); - TS_ASSERT_EQUALS(info.scanInterval({1, 0}), interval); + TS_ASSERT_EQUALS(info.scanIntervals()[0], interval); + // TS_ASSERT_EQUALS(info.scanIntervals({1, 0}), interval); interval = {1, 3}; info.setScanInterval(interval); - TS_ASSERT_EQUALS(info.scanInterval({0, 0}), interval); - TS_ASSERT_EQUALS(info.scanInterval({1, 0}), interval); - } + TS_ASSERT_EQUALS(info.scanIntervals()[0], interval); + // TS_ASSERT_EQUALS(info.scanInterval({1, 0}), interval); + } + + // void test_setScanInterval_failures() { + // DetectorInfo info(PosVec(1), RotVec(1)); + // TS_ASSERT_THROWS_EQUALS( + // info.setScanInterval(0, {1, 1}), const std::runtime_error &err, + // std::string(err.what()), + // "DetectorInfo: cannot set scan interval with start >= end"); + // TS_ASSERT_THROWS_EQUALS( + // info.setScanInterval(0, {2, 1}), const std::runtime_error &err, + // std::string(err.what()), + // "DetectorInfo: cannot set scan interval with start >= end"); + // } void test_setScanInterval_failures() { DetectorInfo info(PosVec(1), RotVec(1)); TS_ASSERT_THROWS_EQUALS( - info.setScanInterval(0, {1, 1}), const std::runtime_error &e, - std::string(e.what()), - "DetectorInfo: cannot set scan interval with start >= end"); - TS_ASSERT_THROWS_EQUALS( - info.setScanInterval(0, {2, 1}), const std::runtime_error &e, - std::string(e.what()), - "DetectorInfo: cannot set scan interval with start >= end"); - } - - void test_setScanInterval_sync_failures() { - DetectorInfo info(PosVec(1), RotVec(1)); - TS_ASSERT_THROWS_EQUALS( - info.setScanInterval({1, 1}), const std::runtime_error &e, - std::string(e.what()), + info.setScanInterval({1, 1}), const std::runtime_error &err, + std::string(err.what()), "DetectorInfo: cannot set scan interval with start >= end"); TS_ASSERT_THROWS_EQUALS( - info.setScanInterval({2, 1}), const std::runtime_error &e, - std::string(e.what()), + info.setScanInterval({2, 1}), const std::runtime_error &err, + std::string(err.what()), "DetectorInfo: cannot set scan interval with start >= end"); } - void test_setScanInterval_sync_async_fail() { - DetectorInfo info(PosVec(1), RotVec(1)); - info.setScanInterval({1, 2}); - TS_ASSERT_THROWS_EQUALS(info.setScanInterval(0, {1, 2}), - const std::runtime_error &e, std::string(e.what()), - "DetectorInfo has been initialized with a " - "synchonous scan, cannot set scan interval for " - "individual detector."); - } - - void test_setScanInterval_async_sync_fail() { - DetectorInfo info(PosVec(1), RotVec(1)); - info.setScanInterval(0, {1, 2}); - TS_ASSERT_THROWS_EQUALS(info.setScanInterval({1, 2}), - const std::runtime_error &e, std::string(e.what()), - "DetectorInfo has been initialized with a " - "asynchonous scan, cannot set synchronous scan " - "interval."); - } + // void test_setScanInterval_sync_async_fail() { + // DetectorInfo info(PosVec(1), RotVec(1)); + // info.setScanInterval({1, 2}); + // TS_ASSERT_THROWS_EQUALS(info.setScanInterval(0, {1, 2}), + // const std::runtime_error &err, std::string(err.what()), + // "DetectorInfo has been initialized with a " + // "synchonous scan, cannot set scan interval for " + // "individual detector."); + // } + + // void test_setScanInterval_async_sync_fail() { + // DetectorInfo info(PosVec(1), RotVec(1)); + // info.setScanInterval(0, {1, 2}); + // TS_ASSERT_THROWS_EQUALS(info.setScanInterval({1, 2}), + // const std::runtime_error &err, std::string(err.what()), + // "DetectorInfo has been initialized with a " + // "asynchonous scan, cannot set synchronous scan " + // "interval."); + // } void test_merge_fail_size() { DetectorInfo a(PosVec(1), RotVec(1)); DetectorInfo b(PosVec(2), RotVec(2)); - a.setScanInterval(0, {0, 1}); - b.setScanInterval(0, {0, 1}); - b.setScanInterval(1, {0, 1}); - TS_ASSERT_THROWS_EQUALS(a.merge(b), const std::runtime_error &e, - std::string(e.what()), + a.setScanInterval({0, 1}); + b.setScanInterval({0, 1}); + // b.setScanInterval(1, {0, 1}); + Mantid::Beamline::ComponentInfo c; + Mantid::Beamline::ComponentInfo d; + c.setDetectorInfo(&a); + d.setDetectorInfo(&b); + + // TS_ASSERT_THROWS_EQUALS(a.merge(b), const std::runtime_error &err, + // std::string(err.what()), + // "Cannot merge DetectorInfo: size mismatch"); + TS_ASSERT_THROWS_EQUALS(c.merge(d), const std::runtime_error &err, + std::string(err.what()), "Cannot merge DetectorInfo: size mismatch"); } @@ -363,75 +371,97 @@ public: DetectorInfo a(PosVec(1), RotVec(1)); DetectorInfo b(PosVec(1), RotVec(1)); DetectorInfo c(PosVec(1), RotVec(1)); + Mantid::Beamline::ComponentInfo d; + Mantid::Beamline::ComponentInfo e; + Mantid::Beamline::ComponentInfo f; + d.setDetectorInfo(&a); + e.setDetectorInfo(&b); + f.setDetectorInfo(&c); TS_ASSERT_THROWS_EQUALS( - a.merge(b), const std::runtime_error &e, std::string(e.what()), + d.merge(e), const std::runtime_error &err, std::string(err.what()), "Cannot merge DetectorInfo: scan intervals not defined"); - c.setScanInterval(0, {0, 1}); + c.setScanInterval({0, 1}); TS_ASSERT_THROWS_EQUALS( - a.merge(c), const std::runtime_error &e, std::string(e.what()), + d.merge(f), const std::runtime_error &err, std::string(err.what()), "Cannot merge DetectorInfo: scan intervals not defined"); - a.setScanInterval(0, {0, 1}); + a.setScanInterval({0, 1}); TS_ASSERT_THROWS_EQUALS( - a.merge(b), const std::runtime_error &e, std::string(e.what()), + d.merge(e), const std::runtime_error &err, std::string(err.what()), "Cannot merge DetectorInfo: scan intervals not defined"); } - void test_merge_fail_sync_async_mismatch() { - DetectorInfo a(PosVec(1), RotVec(1)); - DetectorInfo b(PosVec(1), RotVec(1)); - a.setScanInterval(0, {0, 1}); - b.setScanInterval({0, 1}); - TS_ASSERT_THROWS_EQUALS(a.merge(b), const std::runtime_error &e, - std::string(e.what()), - "Cannot merge DetectorInfo: " - "both or none of the scans " - "must be synchronous"); - TS_ASSERT_THROWS_EQUALS(b.merge(a), const std::runtime_error &e, - std::string(e.what()), - "Cannot merge DetectorInfo: " - "both or none of the scans " - "must be synchronous"); - } + // void test_merge_fail_sync_async_mismatch() { + // DetectorInfo a(PosVec(1), RotVec(1)); + // DetectorInfo b(PosVec(1), RotVec(1)); + // a.setScanInterval({0, 1}); + // b.setScanInterval({0, 1}); + // Mantid::Beamline::ComponentInfo c; + // Mantid::Beamline::ComponentInfo d; + // c.setDetectorInfo(&a); + // d.setDetectorInfo(&b); + // TS_ASSERT_THROWS_EQUALS(c.merge(d), const std::runtime_error &err, + // std::string(err.what()), + // "Cannot merge DetectorInfo: " + // "both or none of the scans " + // "must be synchronous"); + // TS_ASSERT_THROWS_EQUALS(d.merge(a), const std::runtime_error &err, + // std::string(err.what()), + // "Cannot merge DetectorInfo: " + // "both or none of the scans " + // "must be synchronous"); + // } void test_merge_fail_monitor_mismatch() { DetectorInfo a(PosVec(2), RotVec(2)); DetectorInfo b(PosVec(2), RotVec(2), {1}); - a.setScanInterval(0, {0, 1}); - a.setScanInterval(1, {0, 1}); - b.setScanInterval(0, {0, 1}); - b.setScanInterval(1, {0, 1}); + a.setScanInterval({0, 1}); + // a.setScanInterval(1, {0, 1}); + b.setScanInterval({0, 1}); + // b.setScanInterval(1, {0, 1}); + Mantid::Beamline::ComponentInfo c; + Mantid::Beamline::ComponentInfo d; + c.setDetectorInfo(&a); + d.setDetectorInfo(&b); TS_ASSERT_THROWS_EQUALS( - a.merge(b), const std::runtime_error &e, std::string(e.what()), + c.merge(d), const std::runtime_error &err, std::string(err.what()), "Cannot merge DetectorInfo: monitor flags mismatch"); } - void test_merge_identical_sync() { + void test_merge_identical() { DetectorInfo a(PosVec(2), RotVec(2)); a.setScanInterval({0, 10}); auto b(a); - TS_ASSERT_THROWS_NOTHING(b.merge(a)); + Mantid::Beamline::ComponentInfo c; + Mantid::Beamline::ComponentInfo d; + c.setDetectorInfo(&a); + d.setDetectorInfo(&b); + TS_ASSERT_THROWS_NOTHING(d.merge(c)); } - void test_merge_fail_overlap_sync() { + void test_merge_fail_overlap() { DetectorInfo a(PosVec(2), RotVec(2)); a.setScanInterval({0, 10}); auto b(a); b = a; b.setScanInterval({-1, 5}); - TS_ASSERT_THROWS_EQUALS(b.merge(a), const std::runtime_error &e, - std::string(e.what()), + Mantid::Beamline::ComponentInfo c; + Mantid::Beamline::ComponentInfo d; + c.setDetectorInfo(&a); + d.setDetectorInfo(&b); + TS_ASSERT_THROWS_EQUALS(d.merge(c), const std::runtime_error &err, + std::string(err.what()), "Cannot merge DetectorInfo: " "sync scan intervals " "overlap but not identical"); b.setScanInterval({1, 5}); - TS_ASSERT_THROWS_EQUALS(b.merge(a), const std::runtime_error &e, - std::string(e.what()), + TS_ASSERT_THROWS_EQUALS(d.merge(c), const std::runtime_error &err, + std::string(err.what()), "Cannot merge DetectorInfo: " "sync scan intervals " "overlap but not identical"); b.setScanInterval({1, 11}); - TS_ASSERT_THROWS_EQUALS(b.merge(a), const std::runtime_error &e, - std::string(e.what()), + TS_ASSERT_THROWS_EQUALS(d.merge(c), const std::runtime_error &err, + std::string(err.what()), "Cannot merge DetectorInfo: " "sync scan intervals " "overlap but not identical"); @@ -448,93 +478,111 @@ public: a.setPosition(0, pos1); a.setRotation(0, rot1); auto b(a); - TS_ASSERT_THROWS_NOTHING(b.merge(a)); + + Mantid::Beamline::ComponentInfo c; + Mantid::Beamline::ComponentInfo d; + c.setDetectorInfo(&a); + d.setDetectorInfo(&b); + + TS_ASSERT_THROWS_NOTHING(d.merge(c)); b = a; b.setMasked(0, false); - TS_ASSERT_THROWS_EQUALS(b.merge(a), const std::runtime_error &e, - std::string(e.what()), + TS_ASSERT_THROWS_EQUALS(d.merge(c), const std::runtime_error &err, + std::string(err.what()), "Cannot merge DetectorInfo: " "matching scan interval but " "mask flags differ"); b.setMasked(0, true); - TS_ASSERT_THROWS_NOTHING(b.merge(a)); + TS_ASSERT_THROWS_NOTHING(d.merge(c)); b = a; b.setPosition(0, pos2); - TS_ASSERT_THROWS_EQUALS(b.merge(a), const std::runtime_error &e, - std::string(e.what()), + TS_ASSERT_THROWS_EQUALS(d.merge(c), const std::runtime_error &err, + std::string(err.what()), "Cannot merge DetectorInfo: " "matching scan interval but " "positions differ"); b.setPosition(0, pos1); - TS_ASSERT_THROWS_NOTHING(b.merge(a)); + TS_ASSERT_THROWS_NOTHING(d.merge(c)); b = a; b.setRotation(0, rot2); - TS_ASSERT_THROWS_EQUALS(b.merge(a), const std::runtime_error &e, - std::string(e.what()), + TS_ASSERT_THROWS_EQUALS(d.merge(c), const std::runtime_error &err, + std::string(err.what()), "Cannot merge DetectorInfo: " "matching scan interval but " "rotations differ"); b.setRotation(0, rot1); - TS_ASSERT_THROWS_NOTHING(b.merge(a)); + TS_ASSERT_THROWS_NOTHING(d.merge(c)); } - void test_merge_identical_interval_failures_async() { - DetectorInfo a(PosVec(1), RotVec(1)); - a.setScanInterval(0, {0, 1}); - do_test_merge_identical_interval_failures(a); - } + // void test_merge_identical_interval_failures_async() { + // DetectorInfo a(PosVec(1), RotVec(1)); + // a.setScanInterval({0, 1}); + // do_test_merge_identical_interval_failures(a); + // } - void test_merge_identical_interval_failures_sync() { + void test_merge_identical_interval_failures() { DetectorInfo a(PosVec(1), RotVec(1)); a.setScanInterval({0, 1}); do_test_merge_identical_interval_failures(a); } - void test_merge_identical_interval_async() { - DetectorInfo a(PosVec(1), RotVec(1)); - a.setScanInterval(0, {0, 1}); - const auto b(a); - TS_ASSERT_THROWS_NOTHING(a.merge(b)); - TS_ASSERT(a.isEquivalent(b)); - } + // void test_merge_identical_interval_async() { + // DetectorInfo a(PosVec(1), RotVec(1)); + // a.setScanInterval(0, {0, 1}); + // const auto b(a); + // TS_ASSERT_THROWS_NOTHING(a.merge(b)); + // TS_ASSERT(a.isEquivalent(b)); + // } - void test_merge_identical_interval_sync() { + void test_merge_identical_interval() { DetectorInfo a(PosVec(2), RotVec(2)); a.setScanInterval({0, 10}); auto b(a); - TS_ASSERT_THROWS_NOTHING(b.merge(a)); + Mantid::Beamline::ComponentInfo c; + Mantid::Beamline::ComponentInfo d; + c.setDetectorInfo(&a); + d.setDetectorInfo(&b); + TS_ASSERT_THROWS_NOTHING(d.merge(c)); } void test_merge_identical_interval_with_monitor() { DetectorInfo a(PosVec(2), RotVec(2), {1}); - a.setScanInterval(0, {0, 1}); - a.setScanInterval(1, {0, 1}); - const auto b(a); - TS_ASSERT_THROWS_NOTHING(a.merge(b)); + a.setScanInterval({0, 1}); + a.setScanInterval({0, 1}); + auto b(a); + Mantid::Beamline::ComponentInfo c; + Mantid::Beamline::ComponentInfo d; + c.setDetectorInfo(&a); + d.setDetectorInfo(&b); + TS_ASSERT_THROWS_NOTHING(c.merge(d)); TS_ASSERT(a.isEquivalent(b)); } void test_merge_fail_partial_overlap() { DetectorInfo a(PosVec(2), RotVec(2)); - a.setScanInterval(0, {0, 10}); - a.setScanInterval(1, {0, 10}); + a.setScanInterval({0, 10}); + a.setScanInterval({0, 10}); auto b(a); - TS_ASSERT_THROWS_NOTHING(b.merge(a)); + Mantid::Beamline::ComponentInfo c; + Mantid::Beamline::ComponentInfo d; + c.setDetectorInfo(&a); + d.setDetectorInfo(&b); + TS_ASSERT_THROWS_NOTHING(d.merge(c)); b = a; - b.setScanInterval(1, {-1, 5}); + b.setScanInterval({-1, 5}); TS_ASSERT_THROWS_EQUALS( - b.merge(a), const std::runtime_error &e, std::string(e.what()), + d.merge(c), const std::runtime_error &err, std::string(err.what()), "Cannot merge DetectorInfo: scan intervals overlap but not identical"); - b.setScanInterval(1, {1, 5}); + b.setScanInterval({1, 5}); TS_ASSERT_THROWS_EQUALS( - b.merge(a), const std::runtime_error &e, std::string(e.what()), + d.merge(c), const std::runtime_error &err, std::string(err.what()), "Cannot merge DetectorInfo: scan intervals overlap but not identical"); - b.setScanInterval(1, {1, 11}); + b.setScanInterval({1, 11}); TS_ASSERT_THROWS_EQUALS( - b.merge(a), const std::runtime_error &e, std::string(e.what()), + d.merge(c), const std::runtime_error &err, std::string(err.what()), "Cannot merge DetectorInfo: scan intervals overlap but not identical"); } @@ -542,7 +590,7 @@ public: DetectorInfo a(PosVec(2), RotVec(2), {1}); // Monitor at index 1, set up for identical interval std::pair<int64_t, int64_t> monitorInterval(0, 2); - a.setScanInterval(1, monitorInterval); + a.setScanInterval(monitorInterval); auto b(a); Eigen::Vector3d pos1(1, 0, 0); Eigen::Vector3d pos2(2, 0, 0); @@ -550,23 +598,28 @@ public: b.setPosition(0, pos2); std::pair<int64_t, int64_t> interval1(0, 1); std::pair<int64_t, int64_t> interval2(1, 2); - a.setScanInterval(0, interval1); - b.setScanInterval(0, interval2); - TS_ASSERT_THROWS_NOTHING(a.merge(b)); + a.setScanInterval(interval1); + b.setScanInterval(interval2); + Mantid::Beamline::ComponentInfo c; + Mantid::Beamline::ComponentInfo d; + c.setDetectorInfo(&a); + d.setDetectorInfo(&b); + + TS_ASSERT_THROWS_NOTHING(c.merge(d)); TS_ASSERT(a.isScanning()); - TS_ASSERT(!a.isSyncScan()); + // TS_ASSERT(!a.isSyncScan()); TS_ASSERT(!a.isEquivalent(b)); TS_ASSERT_EQUALS(a.size(), 2); TS_ASSERT_EQUALS(a.scanSize(), 3); - TS_ASSERT_EQUALS(a.scanCount(0), 2); + TS_ASSERT_EQUALS(a.scanCount(), 2); // Note that the order is not guaranteed, currently these are just in the // order in which the are merged. - TS_ASSERT_EQUALS(a.scanInterval({0, 0}), interval1); - TS_ASSERT_EQUALS(a.scanInterval({0, 1}), interval2); + TS_ASSERT_EQUALS(a.scanIntervals()[0], interval1); + TS_ASSERT_EQUALS(a.scanIntervals()[1], interval2); TS_ASSERT_EQUALS(a.position({0, 0}), pos1); TS_ASSERT_EQUALS(a.position({0, 1}), pos2); // Monitor is not scanning - TS_ASSERT_EQUALS(a.scanCount(1), 1); + TS_ASSERT_EQUALS(a.scanCount(), 1); } void test_merge_sync() { @@ -580,20 +633,25 @@ public: std::pair<int64_t, int64_t> interval2(1, 2); a.setScanInterval(interval1); b.setScanInterval(interval2); - TS_ASSERT_THROWS_NOTHING(a.merge(b)); + Mantid::Beamline::ComponentInfo c; + Mantid::Beamline::ComponentInfo d; + c.setDetectorInfo(&a); + d.setDetectorInfo(&b); + + TS_ASSERT_THROWS_NOTHING(c.merge(d)); TS_ASSERT(a.isScanning()); - TS_ASSERT(a.isSyncScan()); + // TS_ASSERT(a.isSyncScan()); TS_ASSERT(!a.isEquivalent(b)); TS_ASSERT_EQUALS(a.size(), 2); TS_ASSERT_EQUALS(a.scanSize(), 4); - TS_ASSERT_EQUALS(a.scanCount(0), 2); - TS_ASSERT_EQUALS(a.scanCount(1), 2); + TS_ASSERT_EQUALS(a.scanCount(), 2); + TS_ASSERT_EQUALS(a.scanCount(), 2); // Note that the order is not guaranteed, currently these are just in the // order in which the are merged. - TS_ASSERT_EQUALS(a.scanInterval({0, 0}), interval1); - TS_ASSERT_EQUALS(a.scanInterval({1, 0}), interval1); - TS_ASSERT_EQUALS(a.scanInterval({0, 1}), interval2); - TS_ASSERT_EQUALS(a.scanInterval({1, 1}), interval2); + TS_ASSERT_EQUALS(a.scanIntervals()[0], interval1); + // TS_ASSERT_EQUALS(a.scanIntervals()[0], interval1); + TS_ASSERT_EQUALS(a.scanIntervals()[1], interval2); + // TS_ASSERT_EQUALS(a.scanIntervals()[1], interval2); TS_ASSERT_EQUALS(a.position({0, 0}), pos1); TS_ASSERT_EQUALS(a.position({0, 1}), pos2); } @@ -603,7 +661,7 @@ public: DetectorInfo a(PosVec(2), RotVec(2), {1}); // Monitor at index 1, set up for identical interval std::pair<int64_t, int64_t> monitorInterval(0, 2); - a.setScanInterval(1, monitorInterval); + a.setScanInterval(monitorInterval); a.setPosition(1, {0, 0, 0}); auto b(a); Eigen::Vector3d pos1(1, 0, 0); @@ -612,54 +670,59 @@ public: b.setPosition(0, pos2); std::pair<int64_t, int64_t> interval1(0, 1); std::pair<int64_t, int64_t> interval2(1, 2); - a.setScanInterval(0, interval1); - b.setScanInterval(0, interval2); + a.setScanInterval(interval1); + b.setScanInterval(interval2); + Mantid::Beamline::ComponentInfo c; + Mantid::Beamline::ComponentInfo d; + c.setDetectorInfo(&a); + d.setDetectorInfo(&b); + - TS_ASSERT_THROWS_NOTHING(a.merge(b)); + TS_ASSERT_THROWS_NOTHING(c.merge(d)); auto a0(a); - TS_ASSERT_THROWS_NOTHING(a.merge(b)); + TS_ASSERT_THROWS_NOTHING(c.merge(d)); TS_ASSERT(a.isEquivalent(a0)); } - void test_merge_multiple() { - DetectorInfo a(PosVec(2), RotVec(2), {1}); - // Monitor at index 1, set up for identical interval - std::pair<int64_t, int64_t> monitorInterval(0, 3); - a.setScanInterval(1, monitorInterval); - auto b(a); - auto c(a); - Eigen::Vector3d pos1(1, 0, 0); - Eigen::Vector3d pos2(2, 0, 0); - Eigen::Vector3d pos3(3, 0, 0); - a.setPosition(0, pos1); - b.setPosition(0, pos2); - c.setPosition(0, pos3); - std::pair<int64_t, int64_t> interval1(0, 1); - std::pair<int64_t, int64_t> interval2(1, 2); - std::pair<int64_t, int64_t> interval3(2, 3); - a.setScanInterval(0, interval1); - b.setScanInterval(0, interval2); - c.setScanInterval(0, interval3); - TS_ASSERT_THROWS_NOTHING(a.merge(b)); - TS_ASSERT_THROWS_NOTHING(a.merge(c)); - TS_ASSERT(a.isScanning()); - TS_ASSERT(!a.isSyncScan()); - TS_ASSERT(!a.isEquivalent(b)); - TS_ASSERT(!a.isEquivalent(c)); - TS_ASSERT_EQUALS(a.size(), 2); - TS_ASSERT_EQUALS(a.scanSize(), 4); - TS_ASSERT_EQUALS(a.scanCount(0), 3); - TS_ASSERT_EQUALS(a.scanInterval({0, 0}), interval1); - TS_ASSERT_EQUALS(a.scanInterval({0, 1}), interval2); - TS_ASSERT_EQUALS(a.scanInterval({0, 2}), interval3); - TS_ASSERT_EQUALS(a.position({0, 0}), pos1); - TS_ASSERT_EQUALS(a.position({0, 1}), pos2); - TS_ASSERT_EQUALS(a.position({0, 2}), pos3); - // Monitor is not scanning - TS_ASSERT_EQUALS(a.scanCount(1), 1); - } + // void test_merge_multiple() { + // DetectorInfo a(PosVec(2), RotVec(2), {1}); + // // Monitor at index 1, set up for identical interval + // std::pair<int64_t, int64_t> monitorInterval(0, 3); + // a.setScanInterval(1, monitorInterval); + // auto b(a); + // auto c(a); + // Eigen::Vector3d pos1(1, 0, 0); + // Eigen::Vector3d pos2(2, 0, 0); + // Eigen::Vector3d pos3(3, 0, 0); + // a.setPosition(0, pos1); + // b.setPosition(0, pos2); + // c.setPosition(0, pos3); + // std::pair<int64_t, int64_t> interval1(0, 1); + // std::pair<int64_t, int64_t> interval2(1, 2); + // std::pair<int64_t, int64_t> interval3(2, 3); + // a.setScanInterval(0, interval1); + // b.setScanInterval(0, interval2); + // c.setScanInterval(0, interval3); + // TS_ASSERT_THROWS_NOTHING(a.merge(b)); + // TS_ASSERT_THROWS_NOTHING(a.merge(c)); + // TS_ASSERT(a.isScanning()); + // TS_ASSERT(!a.isSyncScan()); + // TS_ASSERT(!a.isEquivalent(b)); + // TS_ASSERT(!a.isEquivalent(c)); + // TS_ASSERT_EQUALS(a.size(), 2); + // TS_ASSERT_EQUALS(a.scanSize(), 4); + // TS_ASSERT_EQUALS(a.scanCount(), 3); + // TS_ASSERT_EQUALS(a.scanInterval({0, 0}), interval1); + // TS_ASSERT_EQUALS(a.scanInterval({0, 1}), interval2); + // TS_ASSERT_EQUALS(a.scanInterval({0, 2}), interval3); + // TS_ASSERT_EQUALS(a.position({0, 0}), pos1); + // TS_ASSERT_EQUALS(a.position({0, 1}), pos2); + // TS_ASSERT_EQUALS(a.position({0, 2}), pos3); + // // Monitor is not scanning + // TS_ASSERT_EQUALS(a.scanCount(), 1); + // } - void test_merge_multiple_sync() { + void test_merge_multiple() { DetectorInfo a(PosVec(2), RotVec(2), {1}); auto b(a); auto c(a); @@ -675,55 +738,62 @@ public: a.setScanInterval(interval1); b.setScanInterval(interval2); c.setScanInterval(interval3); - TS_ASSERT_THROWS_NOTHING(a.merge(b)); - TS_ASSERT_THROWS_NOTHING(a.merge(c)); + Mantid::Beamline::ComponentInfo d; + Mantid::Beamline::ComponentInfo e; + Mantid::Beamline::ComponentInfo f; + d.setDetectorInfo(&a); + e.setDetectorInfo(&b); + f.setDetectorInfo(&c); + + TS_ASSERT_THROWS_NOTHING(d.merge(e)); + TS_ASSERT_THROWS_NOTHING(d.merge(f)); TS_ASSERT(a.isScanning()); - TS_ASSERT(a.isSyncScan()); + // TS_ASSERT(a.isSyncScan()); TS_ASSERT(!a.isEquivalent(b)); TS_ASSERT(!a.isEquivalent(c)); TS_ASSERT_EQUALS(a.size(), 2); TS_ASSERT_EQUALS(a.scanSize(), 6); - TS_ASSERT_EQUALS(a.scanCount(0), 3); - TS_ASSERT_EQUALS(a.scanCount(1), 3); - TS_ASSERT_EQUALS(a.scanInterval({0, 0}), interval1); - TS_ASSERT_EQUALS(a.scanInterval({1, 0}), interval1); - TS_ASSERT_EQUALS(a.scanInterval({0, 1}), interval2); - TS_ASSERT_EQUALS(a.scanInterval({1, 1}), interval2); - TS_ASSERT_EQUALS(a.scanInterval({0, 2}), interval3); - TS_ASSERT_EQUALS(a.scanInterval({1, 2}), interval3); + TS_ASSERT_EQUALS(a.scanCount(), 3); + TS_ASSERT_EQUALS(a.scanCount(), 3); + TS_ASSERT_EQUALS(a.scanIntervals()[0], interval1); + TS_ASSERT_EQUALS(a.scanIntervals()[0], interval1); + TS_ASSERT_EQUALS(a.scanIntervals()[1], interval2); + TS_ASSERT_EQUALS(a.scanIntervals()[1], interval2); + TS_ASSERT_EQUALS(a.scanIntervals()[2], interval3); + TS_ASSERT_EQUALS(a.scanIntervals()[2], interval3); TS_ASSERT_EQUALS(a.position({0, 0}), pos1); TS_ASSERT_EQUALS(a.position({0, 1}), pos2); TS_ASSERT_EQUALS(a.position({0, 2}), pos3); } - void test_merge_multiple_associative() { - // Test that (A + B) + C == A + (B + C) - // This is implied by the ordering guaranteed by merge(). - DetectorInfo a1(PosVec(1), RotVec(1)); - a1.setRotation(0, Eigen::Quaterniond::Identity()); - auto b(a1); - auto c(a1); - Eigen::Vector3d pos1(1, 0, 0); - Eigen::Vector3d pos2(2, 0, 0); - Eigen::Vector3d pos3(3, 0, 0); - a1.setPosition(0, pos1); - b.setPosition(0, pos2); - c.setPosition(0, pos3); - std::pair<int64_t, int64_t> interval1(0, 1); - std::pair<int64_t, int64_t> interval2(1, 2); - std::pair<int64_t, int64_t> interval3(2, 3); - a1.setScanInterval(0, interval1); - b.setScanInterval(0, interval2); - c.setScanInterval(0, interval3); - auto a2(a1); - TS_ASSERT_THROWS_NOTHING(a1.merge(b)); - TS_ASSERT_THROWS_NOTHING(a1.merge(c)); - TS_ASSERT_THROWS_NOTHING(b.merge(c)); - TS_ASSERT_THROWS_NOTHING(a2.merge(b)); - TS_ASSERT(a1.isEquivalent(a2)); - } + // void test_merge_multiple_associative() { + // // Test that (A + B) + C == A + (B + C) + // // This is implied by the ordering guaranteed by merge(). + // DetectorInfo a1(PosVec(1), RotVec(1)); + // a1.setRotation(0, Eigen::Quaterniond::Identity()); + // auto b(a1); + // auto c(a1); + // Eigen::Vector3d pos1(1, 0, 0); + // Eigen::Vector3d pos2(2, 0, 0); + // Eigen::Vector3d pos3(3, 0, 0); + // a1.setPosition(0, pos1); + // b.setPosition(0, pos2); + // c.setPosition(0, pos3); + // std::pair<int64_t, int64_t> interval1(0, 1); + // std::pair<int64_t, int64_t> interval2(1, 2); + // std::pair<int64_t, int64_t> interval3(2, 3); + // a1.setScanInterval(0, interval1); + // b.setScanInterval(0, interval2); + // c.setScanInterval(0, interval3); + // auto a2(a1); + // TS_ASSERT_THROWS_NOTHING(a1.merge(b)); + // TS_ASSERT_THROWS_NOTHING(a1.merge(c)); + // TS_ASSERT_THROWS_NOTHING(b.merge(c)); + // TS_ASSERT_THROWS_NOTHING(a2.merge(b)); + // TS_ASSERT(a1.isEquivalent(a2)); + // } - void test_merge_multiple_associative_sync() { + void test_merge_multiple_associative() { // Test that (A + B) + C == A + (B + C) // This is implied by the ordering guaranteed by merge(). DetectorInfo a1(PosVec(1), RotVec(1)); @@ -743,10 +813,18 @@ public: b.setScanInterval(interval2); c.setScanInterval(interval3); auto a2(a1); - TS_ASSERT_THROWS_NOTHING(a1.merge(b)); - TS_ASSERT_THROWS_NOTHING(a1.merge(c)); - TS_ASSERT_THROWS_NOTHING(b.merge(c)); - TS_ASSERT_THROWS_NOTHING(a2.merge(b)); + Mantid::Beamline::ComponentInfo d1; + Mantid::Beamline::ComponentInfo d2; + Mantid::Beamline::ComponentInfo e; + Mantid::Beamline::ComponentInfo f; + d1.setDetectorInfo(&a1); + d2.setDetectorInfo(&a2); + e.setDetectorInfo(&b); + f.setDetectorInfo(&c); + TS_ASSERT_THROWS_NOTHING(d1.merge(e)); + TS_ASSERT_THROWS_NOTHING(d1.merge(f)); + TS_ASSERT_THROWS_NOTHING(e.merge(f)); + TS_ASSERT_THROWS_NOTHING(d2.merge(e)); TS_ASSERT(a1.isEquivalent(a2)); } }; diff --git a/Framework/DataHandling/test/LoadILLDiffractionTest.h b/Framework/DataHandling/test/LoadILLDiffractionTest.h index 917711f4bfdfff7b7071c9f02b376868093e96a7..d5893ba2adddc650350210bd31c27e8ad1355cd1 100644 --- a/Framework/DataHandling/test/LoadILLDiffractionTest.h +++ b/Framework/DataHandling/test/LoadILLDiffractionTest.h @@ -312,30 +312,50 @@ public: "2015-04-16T16:40:34.289000000"; const std::string EXPECTED_END_TIME = "2015-04-16T16:41:11.956000000"; - for (size_t i = 0; i < detInfo.size(); ++i) { - TS_ASSERT_EQUALS(detInfo.scanCount(i), SCAN_COUNT) - - const auto &startRange = detInfo.scanInterval({i, 0}); - const auto &secondRange = detInfo.scanInterval({i, 1}); - const auto &secondFromEndRange = - detInfo.scanInterval({i, detInfo.scanCount(i) - 2}); - const auto &endRange = - detInfo.scanInterval({i, detInfo.scanCount(i) - 1}); - - TS_ASSERT_EQUALS(startRange.first.toISO8601String(), EXPECTED_START_TIME) - TS_ASSERT_EQUALS(startRange.second.toISO8601String(), - EXPECTED_SECOND_TIME) - TS_ASSERT_EQUALS(secondRange.first.toISO8601String(), - EXPECTED_SECOND_TIME) - TS_ASSERT_EQUALS(secondFromEndRange.second.toISO8601String(), - EXPECTED_SECOND_FROM_END_TIME) - TS_ASSERT_EQUALS(endRange.first.toISO8601String(), - EXPECTED_SECOND_FROM_END_TIME) - TS_ASSERT_EQUALS(endRange.second.toISO8601String(), EXPECTED_END_TIME) - } + TS_ASSERT_EQUALS(detInfo.scanCount(), SCAN_COUNT) + + const auto &startRange = detInfo.scanIntervals()[0]; + const auto &secondRange = detInfo.scanIntervals()[1]; + const auto &secondFromEndRange = + detInfo.scanIntervals()[detInfo.scanCount() - 2]; + const auto &endRange = + detInfo.scanIntervals()[detInfo.scanCount() - 1]; + + TS_ASSERT_EQUALS(startRange.first.toISO8601String(), EXPECTED_START_TIME) + TS_ASSERT_EQUALS(startRange.second.toISO8601String(), + EXPECTED_SECOND_TIME) + TS_ASSERT_EQUALS(secondRange.first.toISO8601String(), + EXPECTED_SECOND_TIME) + TS_ASSERT_EQUALS(secondFromEndRange.second.toISO8601String(), + EXPECTED_SECOND_FROM_END_TIME) + TS_ASSERT_EQUALS(endRange.first.toISO8601String(), + EXPECTED_SECOND_FROM_END_TIME) + TS_ASSERT_EQUALS(endRange.second.toISO8601String(), EXPECTED_END_TIME) + + // for (size_t i = 0; i < detInfo.size(); ++i) { + // TS_ASSERT_EQUALS(detInfo.scanCount(), SCAN_COUNT) + + // const auto &startRange = detInfo.scanInterval({i, 0}); + // const auto &secondRange = detInfo.scanInterval({i, 1}); + // const auto &secondFromEndRange = + // detInfo.scanInterval({i, detInfo.scanCount(i) - 2}); + // const auto &endRange = + // detInfo.scanInterval({i, detInfo.scanCount(i) - 1}); + + // TS_ASSERT_EQUALS(startRange.first.toISO8601String(), EXPECTED_START_TIME) + // TS_ASSERT_EQUALS(startRange.second.toISO8601String(), + // EXPECTED_SECOND_TIME) + // TS_ASSERT_EQUALS(secondRange.first.toISO8601String(), + // EXPECTED_SECOND_TIME) + // TS_ASSERT_EQUALS(secondFromEndRange.second.toISO8601String(), + // EXPECTED_SECOND_FROM_END_TIME) + // TS_ASSERT_EQUALS(endRange.first.toISO8601String(), + // EXPECTED_SECOND_FROM_END_TIME) + // TS_ASSERT_EQUALS(endRange.second.toISO8601String(), EXPECTED_END_TIME) + // } // Check monitor does not move - for (size_t j = 0; j < detInfo.scanCount(0); ++j) { + for (size_t j = 0; j < detInfo.scanCount(); ++j) { TS_ASSERT(detInfo.isMonitor({0, j})) TS_ASSERT_EQUALS(detInfo.position({0, j}), detInfo.position({0, 0})) } @@ -346,7 +366,7 @@ public: const double TUBE_128_FIRST_ANGLE = 147.496; for (size_t i = 0; i < NUMBER_OF_TUBES; ++i) { - for (size_t j = 0; j < detInfo.scanCount(i); ++j) { + for (size_t j = 0; j < detInfo.scanCount(); ++j) { // Find two pixels just above and just below the centre, and take their // average position as the tube centre auto belowCentrePixel = i * NUMBER_OF_PIXELS + NUMBER_OF_PIXELS / 2; diff --git a/Framework/DataObjects/src/ScanningWorkspaceBuilder.cpp b/Framework/DataObjects/src/ScanningWorkspaceBuilder.cpp index c31f6acdb9399b944f08433c2681893e2c90865c..740b823672d55d3b8ec7fb7b80043300fad3ca36 100644 --- a/Framework/DataObjects/src/ScanningWorkspaceBuilder.cpp +++ b/Framework/DataObjects/src/ScanningWorkspaceBuilder.cpp @@ -196,7 +196,7 @@ MatrixWorkspace_sptr ScanningWorkspaceBuilder::buildWorkspace() const { m_instrument, m_nDetectors * m_nTimeIndexes, m_histogram); auto &outputComponentInfo = outputWorkspace->mutableComponentInfo(); - outputComponentInfo.setScanInterval(m_timeRanges[0]); + outputComponentInfo.setScanInterval({m_timeRanges[0].first.totalNanoseconds(),m_timeRanges[0].second.totalNanoseconds()}); buildOutputComponentInfo(outputComponentInfo); @@ -234,7 +234,7 @@ void ScanningWorkspaceBuilder::buildOutputComponentInfo( create<Workspace2D>(m_instrument, m_nDetectors, m_histogram.binEdges()); for (size_t i = 1; i < m_nTimeIndexes; ++i) { auto &mergeComponentInfo = mergeWorkspace->mutableComponentInfo(); - mergeComponentInfo.setScanInterval(m_timeRanges[i]); + mergeComponentInfo.setScanInterval({m_timeRanges[i].first.totalNanoseconds(),m_timeRanges[i].second.totalNanoseconds()}); outputComponentInfo.merge(mergeComponentInfo); } } diff --git a/Framework/DataObjects/test/ScanningWorkspaceBuilderTest.h b/Framework/DataObjects/test/ScanningWorkspaceBuilderTest.h index d2bcb60b7ab60ae463805cc30cc8775a61224f79..742f0718ba06577d4a09931e57c64d71387bd54d 100644 --- a/Framework/DataObjects/test/ScanningWorkspaceBuilderTest.h +++ b/Framework/DataObjects/test/ScanningWorkspaceBuilderTest.h @@ -593,7 +593,7 @@ private: void checkTimeRanges(const DetectorInfo &detectorInfo) { for (size_t i = 0; i < nDetectors; ++i) { for (size_t j = 0; j < nTimeIndexes; ++j) { - TS_ASSERT_EQUALS(detectorInfo.scanInterval({i, j}), timeRanges[j]); + TS_ASSERT_EQUALS(detectorInfo.scanIntervals()[j], timeRanges[j]); } } } diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/ComponentInfo.h b/Framework/Geometry/inc/MantidGeometry/Instrument/ComponentInfo.h index 9af0f004d79c45764f195b854a02e7a2c98f33c4..c6505ca552d9d0083c00aa73763601404c36211f 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/ComponentInfo.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/ComponentInfo.h @@ -151,8 +151,8 @@ public: const BoundingBox *reference = nullptr) const; Beamline::ComponentType componentType(const size_t componentIndex) const; void setScanInterval(const std::pair<int64_t, int64_t> &interval); - void setScanInterval(const std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime> - &interval); + // void setScanInterval(const std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime> + // &interval); void merge(const ComponentInfo &other); size_t scanSize() const; friend class Instrument; diff --git a/Framework/Geometry/src/Instrument/ComponentInfo.cpp b/Framework/Geometry/src/Instrument/ComponentInfo.cpp index a78088adba5ad472d844ba8ce8f33fa5720ecebf..99172aeaeaf9821ad9254a296dad5552726a25d6 100644 --- a/Framework/Geometry/src/Instrument/ComponentInfo.cpp +++ b/Framework/Geometry/src/Instrument/ComponentInfo.cpp @@ -426,12 +426,12 @@ void ComponentInfo::setScanInterval( m_componentInfo->setScanInterval(interval); } -void ComponentInfo::setScanInterval( - // const std::pair<int64_t, int64_t> &interval) { - const std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime> - &interval) { - m_componentInfo->setScanInterval({interval.first.totalNanoseconds(),interval.second.totalNanoseconds()}); -} +// void ComponentInfo::setScanInterval( +// // const std::pair<int64_t, int64_t> &interval) { +// const std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime> +// &interval) { +// m_componentInfo->setScanInterval({interval.first.totalNanoseconds(),interval.second.totalNanoseconds()}); +// } void ComponentInfo::merge(const ComponentInfo &other) { m_componentInfo->merge(*other.m_componentInfo); diff --git a/Framework/Kernel/src/ConfigService.cpp b/Framework/Kernel/src/ConfigService.cpp index aba2bb609451b8d5a02bff30bd2af6c8aedc3fd5..d79d1ab4f7f4cc8ca4fd2dd0d7bb37f07d0a336e 100644 --- a/Framework/Kernel/src/ConfigService.cpp +++ b/Framework/Kernel/src/ConfigService.cpp @@ -647,7 +647,7 @@ void ConfigServiceImpl::createUserPropertiesFile() const { filestr << "#algorithms.retained=90\n\n"; filestr << "## Set the maximum number of cores used to run algorithms over\n"; - filestr << "#MultiThreaded.MaxCores=4\n\n"; + filestr << "MultiThreaded.MaxCores=2\n\n"; filestr << "##\n"; filestr << "## FACILITY AND INSTRUMENT\n"; filestr << "##\n\n";