From cb76c462fb2b5344c9019b139d484e419e8fa743 Mon Sep 17 00:00:00 2001 From: Moore <lamar.moore@stfc.ac.uk> Date: Thu, 21 Jul 2016 15:20:16 +0100 Subject: [PATCH] review improvements re #16882 --- Framework/Algorithms/src/ConvertUnits.cpp | 6 +- .../src/ConvertUnitsUsingDetectorTable.cpp | 6 +- Framework/Algorithms/src/FFTSmooth.cpp | 27 +- Framework/Algorithms/src/FFTSmooth2.cpp | 21 +- Framework/Algorithms/src/FilterEvents.cpp | 3 +- .../Algorithms/src/FindPeakBackground.cpp | 2 +- Framework/Algorithms/src/FindPeaks.cpp | 2 +- Framework/Algorithms/src/FitPeak.cpp | 4 +- .../Algorithms/test/FindPeakBackgroundTest.h | 36 +-- Framework/Algorithms/test/FindPeaksTest.h | 89 +++--- Framework/Algorithms/test/FitPeakTest.h | 301 ++++++------------ 11 files changed, 187 insertions(+), 310 deletions(-) diff --git a/Framework/Algorithms/src/ConvertUnits.cpp b/Framework/Algorithms/src/ConvertUnits.cpp index c3bd4fe93f8..5c1e9236536 100644 --- a/Framework/Algorithms/src/ConvertUnits.cpp +++ b/Framework/Algorithms/src/ConvertUnits.cpp @@ -682,8 +682,10 @@ API::MatrixWorkspace_sptr ConvertUnits::removeUnphysicalBins( result->mutableX(j).assign(edges.cbegin(), edges.cbegin() + k); // If the entire X range is not covered, generate fake values. - std::iota(result->mutableX(j).begin() + k, result->mutableX(j).end(), - workspace->x(j)[k] + 1); + if (k < maxBins) { + std::iota(result->mutableX(j).begin() + k, result->mutableX(j).end(), + workspace->x(j)[k] + 1); + } result->mutableY(j) .assign(workspace->y(j).cbegin(), workspace->y(j).cbegin() + (k - 1)); diff --git a/Framework/Algorithms/src/ConvertUnitsUsingDetectorTable.cpp b/Framework/Algorithms/src/ConvertUnitsUsingDetectorTable.cpp index 86bae193404..662a4ee511c 100644 --- a/Framework/Algorithms/src/ConvertUnitsUsingDetectorTable.cpp +++ b/Framework/Algorithms/src/ConvertUnitsUsingDetectorTable.cpp @@ -649,8 +649,10 @@ API::MatrixWorkspace_sptr ConvertUnitsUsingDetectorTable::removeUnphysicalBins( result->mutableX(j).assign(edges.cbegin(), edges.cbegin() + k); // If the entire X range is not covered, generate fake values. - std::iota(result->mutableX(j).begin() + k, result->mutableX(j).end(), - workspace->x(j)[k] + 1); + if (k < maxBins) { + std::iota(result->mutableX(j).begin() + k, result->mutableX(j).end(), + workspace->x(j)[k] + 1); + } result->mutableY(j) .assign(workspace->y(j).cbegin(), workspace->y(j).cbegin() + (k - 1)); diff --git a/Framework/Algorithms/src/FFTSmooth.cpp b/Framework/Algorithms/src/FFTSmooth.cpp index d91c916dac3..62206be0f57 100644 --- a/Framework/Algorithms/src/FFTSmooth.cpp +++ b/Framework/Algorithms/src/FFTSmooth.cpp @@ -57,12 +57,16 @@ void FFTSmooth::exec() { double dx = (m_inWS->x(spec).back() - m_inWS->x(spec).front()) / static_cast<double>(m_inWS->x(spec).size() - 1); + + auto &symX = symmWS->mutableX(0); + auto &symY = symmWS->mutableY(0); + for (int i = 0; i < dn; i++) { - symmWS->mutableX(0)[dn + i] = m_inWS->x(spec)[i]; - symmWS->mutableY(0)[dn + i] = m_inWS->y(spec)[i]; + symX[dn + i] = m_inWS->x(spec)[i]; + symY[dn + i] = m_inWS->y(spec)[i]; - symmWS->mutableX(0)[dn - i] = x0 - dx * i; - symmWS->mutableY(0)[dn - i] = m_inWS->y(spec)[i]; + symX[dn - i] = x0 - dx * i; + symY[dn - i] = m_inWS->y(spec)[i]; } symmWS->mutableY(0).front() = m_inWS->y(spec).back(); symmWS->mutableX(0).front() = x0 - dx * dn; @@ -171,17 +175,10 @@ void FFTSmooth::zero(int n) { m_filteredWS = API::WorkspaceFactory::Instance().create(m_unfilteredWS, 2, mx, my); - m_filteredWS->setSharedX(0, m_unfilteredWS->sharedX(0)); - m_filteredWS->setSharedX(1, m_unfilteredWS->sharedX(0)); - - m_filteredWS->mutableY(0).assign(m_unfilteredWS->y(0).size(), 0); - m_filteredWS->mutableY(1).assign(m_unfilteredWS->y(0).size(), 0); - - std::copy(m_unfilteredWS->y(0).cbegin(), m_unfilteredWS->y(0).begin() + ny, - m_filteredWS->mutableY(0).begin()); - - std::copy(m_unfilteredWS->y(1).cbegin(), m_unfilteredWS->y(1).begin() + ny, - m_filteredWS->mutableY(1).begin()); + m_filteredWS->mutableY(0).assign(m_unfilteredWS->y(0).cbegin(), + m_unfilteredWS->y(0).cbegin() + ny); + m_filteredWS->mutableY(1).assign(m_unfilteredWS->y(1).cbegin(), + m_unfilteredWS->y(1).cbegin() + ny); } } // namespace Algorithm diff --git a/Framework/Algorithms/src/FFTSmooth2.cpp b/Framework/Algorithms/src/FFTSmooth2.cpp index aac161459e2..f81cc05c025 100644 --- a/Framework/Algorithms/src/FFTSmooth2.cpp +++ b/Framework/Algorithms/src/FFTSmooth2.cpp @@ -90,13 +90,16 @@ void FFTSmooth2::exec() { progress.report(); - for (int i = 0; i < dn; i++) { - symmWS->mutableX(0)[dn + i] = inWS->x(spec)[i]; - symmWS->mutableY(0)[dn + i] = inWS->y(spec)[i]; + auto &symX = symmWS->mutableX(0); + auto &symY = symmWS->mutableY(0); - symmWS->mutableX(0)[dn - i] = x0 - dx * i; - symmWS->mutableY(0)[dn - i] = inWS->y(spec)[i]; - } + for (int i = 0; i < dn; i++) { + symX[dn + i] = inWS->x(spec)[i]; + symY[dn + i] = inWS->y(spec)[i]; + + symX[dn - i] = x0 - dx * i; + symY[dn - i] = inWS->y(spec)[i]; + } symmWS->mutableY(0).front() = inWS->y(spec).back(); symmWS->mutableX(0).front() = x0 - dx * dn; if (inWS->isHistogramData()) @@ -218,9 +221,6 @@ void FFTSmooth2::zero(int n, API::MatrixWorkspace_sptr &unfilteredWS, filteredWS->setSharedX(0, unfilteredWS->sharedX(0)); filteredWS->setSharedX(1, unfilteredWS->sharedX(0)); - filteredWS->mutableY(0).assign(unfilteredWS->y(0).size(), 0); - filteredWS->mutableY(1).assign(unfilteredWS->y(0).size(), 0); - std::copy(unfilteredWS->y(0).cbegin(), unfilteredWS->y(0).begin() + ny, filteredWS->mutableY(0).begin()); @@ -262,9 +262,6 @@ void FFTSmooth2::Butterworth(int n, int order, auto &Y0 = filteredWS->mutableY(0); auto &Y1 = filteredWS->mutableY(1); - Y0.assign(uY0.size(), 0); - Y1.assign(uY0.size(), 0); - double cutoff = ny; for (int i = 0; i < my; i++) { diff --git a/Framework/Algorithms/src/FilterEvents.cpp b/Framework/Algorithms/src/FilterEvents.cpp index 4f8590b8605..cb215e080cc 100644 --- a/Framework/Algorithms/src/FilterEvents.cpp +++ b/Framework/Algorithms/src/FilterEvents.cpp @@ -447,11 +447,10 @@ void FilterEvents::processMatrixSplitterWorkspace() { // Check input workspace validity assert(m_matrixSplitterWS); - auto &X = m_matrixSplitterWS->x(0); + auto X = m_matrixSplitterWS->binEdges(0); auto &Y = m_matrixSplitterWS->y(0); size_t sizex = X.size(); size_t sizey = Y.size(); - assert(sizex - sizey == 1); // Assign vectors for time comparison m_vecSplitterTime.assign(X.size(), 0); diff --git a/Framework/Algorithms/src/FindPeakBackground.cpp b/Framework/Algorithms/src/FindPeakBackground.cpp index 5c6a28cadb9..baa9eae793b 100644 --- a/Framework/Algorithms/src/FindPeakBackground.cpp +++ b/Framework/Algorithms/src/FindPeakBackground.cpp @@ -94,7 +94,7 @@ void FindPeakBackground::exec() { // Generate output auto &inpX = inpWS->x(inpwsindex); size_t sizex = inpWS->x(inpwsindex).size(); - size_t sizey = inpWS->x(inpwsindex).size(); + size_t sizey = inpWS->y(inpwsindex).size(); size_t n = sizey; size_t l0 = 0; diff --git a/Framework/Algorithms/src/FindPeaks.cpp b/Framework/Algorithms/src/FindPeaks.cpp index 373ed835952..500ee0f25ce 100644 --- a/Framework/Algorithms/src/FindPeaks.cpp +++ b/Framework/Algorithms/src/FindPeaks.cpp @@ -700,7 +700,7 @@ void FindPeaks::calculateStandardDeviation( const size_t numHists = smoothed->getNumberHistograms(); for (size_t i = 0; i < size_t(numHists); ++i) { - smoothed->mutableE(i).assign(input->e(i).cbegin(), input->e(i).cend()); + smoothed->setSharedE(i, input->sharedE(i)); std::transform(smoothed->e(i).cbegin(), smoothed->e(i).cend(), smoothed->mutableE(i).begin(), std::bind2nd(std::multiplies<double>(), constant)); diff --git a/Framework/Algorithms/src/FitPeak.cpp b/Framework/Algorithms/src/FitPeak.cpp index 5b4461d925f..f28a19783e1 100644 --- a/Framework/Algorithms/src/FitPeak.cpp +++ b/Framework/Algorithms/src/FitPeak.cpp @@ -427,7 +427,7 @@ void FitOneSinglePeak::removeBackground(MatrixWorkspace_sptr purePeakWS) { std::transform(purePeakWS->y(0).cbegin(), purePeakWS->y(0).cend(), purePeakWS->mutableY(0).begin(), [=](const double &y) mutable { double newY = y - bkgdvalues[i++]; - return newY > 0. ? newY : 0.; + return std::max(0.0, newY); }); } @@ -1513,7 +1513,7 @@ void FitPeak::setupOutput( compfunc->function(domain, values); const auto domainVec = domain.toVector(); - outws->mutableX(0).assign(domainVec.cbegin(), domainVec.cbegin() + sizex); + outws->mutableX(0).assign(domainVec.cbegin(), domainVec.cend()); outws->setSharedX(1, outws->sharedX(0)); outws->setSharedX(2, outws->sharedX(0)); diff --git a/Framework/Algorithms/test/FindPeakBackgroundTest.h b/Framework/Algorithms/test/FindPeakBackgroundTest.h index 99bfbf488e0..f6cd5eac0cd 100644 --- a/Framework/Algorithms/test/FindPeakBackgroundTest.h +++ b/Framework/Algorithms/test/FindPeakBackgroundTest.h @@ -16,6 +16,8 @@ using namespace Mantid; using namespace Mantid::API; using namespace Mantid::Kernel; using namespace Mantid::DataObjects; +using HistogramData::Points; +using HistogramData::Counts; using namespace std; @@ -71,17 +73,15 @@ public: const size_t size = 20; - std::array<double, size> data = {{1, 2, 1, 1, 9, 11, 13, 20, 24, 32, 28, 48, - 42, 77, 67, 33, 27, 20, 9, 2}}; - MatrixWorkspace_sptr ws = boost::dynamic_pointer_cast<MatrixWorkspace>( WorkspaceFactory::Instance().create("Workspace2D", 1, size, size)); - ws->mutableY(0).assign(data.begin(), data.end()); - std::iota(ws->mutableX(0).begin(), ws->mutableX(0).end(), 0); - std::transform(ws->y(0).cbegin(), ws->y(0).cend(), ws->mutableE(0).begin(), - [](const double &y) { return sqrt(y); }); + MantidVec xdata(size); + std::iota(xdata.begin(), xdata.end(), 0); + ws->setHistogram(0, Points(xdata), + Counts{1, 2, 1, 1, 9, 11, 13, 20, 24, 32, + 28, 48, 42, 77, 67, 33, 27, 20, 9, 2}); return ws; } @@ -180,23 +180,23 @@ public: /** Generate a workspace with 2 spectra for test */ MatrixWorkspace_sptr generate2SpectraTestWorkspace() { - vector<double> data{1, 2, 1, 1, 9, 11, 13, 20, 24, 32, - 28, 48, 42, 77, 67, 33, 27, 20, 9, 2}; + + const size_t size = 20; MatrixWorkspace_sptr ws = boost::dynamic_pointer_cast<MatrixWorkspace>( - WorkspaceFactory::Instance().create("Workspace2D", 2, data.size(), - data.size())); + WorkspaceFactory::Instance().create("Workspace2D", 2, size, size)); // Workspace index = 0 - ws->mutableY(0).assign(data.size(), 0.0); - ws->mutableE(0).assign(data.size(), 1.0); - std::iota(ws->mutableX(0).begin(), ws->mutableX(0).end(), 0); + MantidVec xdata(size); + std::iota(xdata.begin(), xdata.end(), 0); + ws->mutableX(0) = std::move(xdata); + ws->mutableE(0).assign(size, 1.0); // Workspace index = 1 - ws->mutableY(1).assign(data.cbegin(), data.cend()); - std::iota(ws->mutableX(1).begin(), ws->mutableX(1).end(), 0); - std::transform(ws->y(1).cbegin(), ws->y(1).cend(), ws->mutableE(1).begin(), - [](const double &y) { return sqrt(y); }); + ws->setSharedX(1, ws->sharedX(0)); + ws->setCounts(1, Counts{1, 2, 1, 1, 9, 11, 13, 20, 24, 32, + 28, 48, 42, 77, 67, 33, 27, 20, 9, 2}); + return ws; } }; diff --git a/Framework/Algorithms/test/FindPeaksTest.h b/Framework/Algorithms/test/FindPeaksTest.h index 1b42d918b5c..d203cff3c47 100644 --- a/Framework/Algorithms/test/FindPeaksTest.h +++ b/Framework/Algorithms/test/FindPeaksTest.h @@ -25,6 +25,10 @@ using namespace Mantid::DataObjects; using namespace std; +using Mantid::HistogramData::Points; +using Mantid::HistogramData::Counts; +using Mantid::HistogramData::CountStandardDeviations; + class FindPeaksTest : public CxxTest::TestSuite { public: static FindPeaksTest *createSuite() { return new FindPeaksTest(); } @@ -224,52 +228,51 @@ public: const size_t size = 83; - std::array<double, size> vecX = { - {1.210120, 1.210600, 1.211080, 1.211570, 1.212050, 1.212540, 1.213020, - 1.213510, 1.213990, 1.214480, 1.214970, 1.215450, 1.215940, 1.216420, - 1.216910, 1.217400, 1.217880, 1.218370, 1.218860, 1.219350, 1.219830, - 1.220320, 1.220810, 1.221300, 1.221790, 1.222280, 1.222760, 1.223250, - 1.223740, 1.224230, 1.224720, 1.225210, 1.225700, 1.226190, 1.226680, - 1.227170, 1.227660, 1.228160, 1.228650, 1.229140, 1.229630, 1.230120, - 1.230610, 1.231110, 1.231600, 1.232090, 1.232580, 1.233080, 1.233570, - 1.234060, 1.234560, 1.235050, 1.235540, 1.236040, 1.236530, 1.237030, - 1.237520, 1.238020, 1.238510, 1.239010, 1.239500, 1.240000, 1.240500, - 1.240990, 1.241490, 1.241990, 1.242480, 1.242980, 1.243480, 1.243970, - 1.244470, 1.244970, 1.245470, 1.245970, 1.246460, 1.246960, 1.247460, - 1.247960, 1.248460, 1.248960, 1.249460, 1.249960, 1.250460}}; - std::array<double, size> vecY = { - {1619.0, 1644.0, 1616.0, 1589.0, 1608.0, 1612.0, 1630.0, 1671.0, 1588.0, - 1577.0, 1616.0, 1556.0, 1625.0, 1655.0, 1552.0, 1539.0, 1538.0, 1542.0, - 1558.0, 1628.0, 1557.0, 1606.0, 1563.0, 1611.0, 1584.0, 1447.0, 1532.0, - 1580.0, 1539.0, 1513.0, 1601.0, 1558.0, 1567.0, 1573.0, 1551.0, 1465.0, - 1602.0, 1543.0, 1538.0, 1515.0, 1556.0, 1574.0, 1519.0, 1452.0, 1568.0, - 1522.0, 1518.0, 1603.0, 1538.0, 1659.0, 1685.0, 1763.0, 1846.0, 1872.0, - 2018.0, 2035.0, 2113.0, 2131.0, 1921.0, 1947.0, 1756.0, 1603.0, 1602.0, - 1552.0, 1558.0, 1518.0, 1512.0, 1511.0, 1466.0, 1474.0, 1368.0, 1463.0, - 1447.0, 1409.0, 1381.0, 1478.0, 1445.0, 1429.0, 1447.0, 1354.0, 1430.0, - 1440.0, 1423.0}}; - std::array<double, size> vecE = {{ - 40.236800, 40.546300, 40.199500, 39.862300, 40.099900, 40.149700, - 40.373300, 40.877900, 39.849700, 39.711500, 40.199500, 39.446200, - 40.311300, 40.681700, 39.395400, 39.230100, 39.217300, 39.268300, - 39.471500, 40.348500, 39.458800, 40.074900, 39.534800, 40.137300, - 39.799500, 38.039500, 39.140800, 39.749200, 39.230100, 38.897300, - 40.012500, 39.471500, 39.585400, 39.661100, 39.382700, 38.275300, - 40.025000, 39.281000, 39.217300, 38.923000, 39.446200, 39.673700, - 38.974400, 38.105100, 39.598000, 39.012800, 38.961500, 40.037500, - 39.217300, 40.730800, 41.048800, 41.988100, 42.965100, 43.266600, - 44.922200, 45.111000, 45.967400, 46.162800, 43.829200, 44.124800, - 41.904700, 40.037500, 40.025000, 39.395400, 39.471500, 38.961500, - 38.884400, 38.871600, 38.288400, 38.392700, 36.986500, 38.249200, - 38.039500, 37.536600, 37.161800, 38.444800, 38.013200, 37.802100, - 38.039500, 36.796700, 37.815300, 37.947300, 37.722700, }}; - MatrixWorkspace_sptr dataws = boost::dynamic_pointer_cast<MatrixWorkspace>( WorkspaceFactory::Instance().create("Workspace2D", 1, size, size)); - dataws->mutableX(0).assign(vecX.cbegin(), vecX.cend()); - dataws->mutableY(0).assign(vecY.cbegin(), vecY.cend()); - dataws->mutableE(0).assign(vecE.cbegin(), vecE.cend()); + dataws->setHistogram( + 0, Points{1.210120, 1.210600, 1.211080, 1.211570, 1.212050, 1.212540, + 1.213020, 1.213510, 1.213990, 1.214480, 1.214970, 1.215450, + 1.215940, 1.216420, 1.216910, 1.217400, 1.217880, 1.218370, + 1.218860, 1.219350, 1.219830, 1.220320, 1.220810, 1.221300, + 1.221790, 1.222280, 1.222760, 1.223250, 1.223740, 1.224230, + 1.224720, 1.225210, 1.225700, 1.226190, 1.226680, 1.227170, + 1.227660, 1.228160, 1.228650, 1.229140, 1.229630, 1.230120, + 1.230610, 1.231110, 1.231600, 1.232090, 1.232580, 1.233080, + 1.233570, 1.234060, 1.234560, 1.235050, 1.235540, 1.236040, + 1.236530, 1.237030, 1.237520, 1.238020, 1.238510, 1.239010, + 1.239500, 1.240000, 1.240500, 1.240990, 1.241490, 1.241990, + 1.242480, 1.242980, 1.243480, 1.243970, 1.244470, 1.244970, + 1.245470, 1.245970, 1.246460, 1.246960, 1.247460, 1.247960, + 1.248460, 1.248960, 1.249460, 1.249960, 1.250460}, + Counts{1619.0, 1644.0, 1616.0, 1589.0, 1608.0, 1612.0, 1630.0, 1671.0, + 1588.0, 1577.0, 1616.0, 1556.0, 1625.0, 1655.0, 1552.0, 1539.0, + 1538.0, 1542.0, 1558.0, 1628.0, 1557.0, 1606.0, 1563.0, 1611.0, + 1584.0, 1447.0, 1532.0, 1580.0, 1539.0, 1513.0, 1601.0, 1558.0, + 1567.0, 1573.0, 1551.0, 1465.0, 1602.0, 1543.0, 1538.0, 1515.0, + 1556.0, 1574.0, 1519.0, 1452.0, 1568.0, 1522.0, 1518.0, 1603.0, + 1538.0, 1659.0, 1685.0, 1763.0, 1846.0, 1872.0, 2018.0, 2035.0, + 2113.0, 2131.0, 1921.0, 1947.0, 1756.0, 1603.0, 1602.0, 1552.0, + 1558.0, 1518.0, 1512.0, 1511.0, 1466.0, 1474.0, 1368.0, 1463.0, + 1447.0, 1409.0, 1381.0, 1478.0, 1445.0, 1429.0, 1447.0, 1354.0, + 1430.0, 1440.0, 1423.0}, + CountStandardDeviations{ + 40.236800, 40.546300, 40.199500, 39.862300, 40.099900, 40.149700, + 40.373300, 40.877900, 39.849700, 39.711500, 40.199500, 39.446200, + 40.311300, 40.681700, 39.395400, 39.230100, 39.217300, 39.268300, + 39.471500, 40.348500, 39.458800, 40.074900, 39.534800, 40.137300, + 39.799500, 38.039500, 39.140800, 39.749200, 39.230100, 38.897300, + 40.012500, 39.471500, 39.585400, 39.661100, 39.382700, 38.275300, + 40.025000, 39.281000, 39.217300, 38.923000, 39.446200, 39.673700, + 38.974400, 38.105100, 39.598000, 39.012800, 38.961500, 40.037500, + 39.217300, 40.730800, 41.048800, 41.988100, 42.965100, 43.266600, + 44.922200, 45.111000, 45.967400, 46.162800, 43.829200, 44.124800, + 41.904700, 40.037500, 40.025000, 39.395400, 39.471500, 38.961500, + 38.884400, 38.871600, 38.288400, 38.392700, 36.986500, 38.249200, + 38.039500, 37.536600, 37.161800, 38.444800, 38.013200, 37.802100, + 38.039500, 36.796700, 37.815300, 37.947300, 37.722700, + }); return dataws; } diff --git a/Framework/Algorithms/test/FitPeakTest.h b/Framework/Algorithms/test/FitPeakTest.h index 4f6bd1c1386..1148d4e2c26 100644 --- a/Framework/Algorithms/test/FitPeakTest.h +++ b/Framework/Algorithms/test/FitPeakTest.h @@ -19,6 +19,10 @@ using namespace Mantid::DataObjects; using namespace std; +using Mantid::HistogramData::Points; +using Mantid::HistogramData::Counts; +using Mantid::HistogramData::CountStandardDeviations; + class FitPeakTest : public CxxTest::TestSuite { public: // This pair of boilerplate methods prevent the suite being created statically @@ -196,57 +200,57 @@ public: const size_t size = 84; - std::array<double, size> vecx = { - {0.585120, 0.585354, 0.585588, 0.585822, 0.586057, 0.586291, 0.586526, - 0.586760, 0.586995, 0.587230, 0.587465, 0.587700, 0.587935, 0.588170, - 0.588405, 0.588641, 0.588876, 0.589112, 0.589347, 0.589583, 0.589819, - 0.590055, 0.590291, 0.590527, 0.590763, 0.590999, 0.591236, 0.591472, - 0.591709, 0.591946, 0.592182, 0.592419, 0.592656, 0.592893, 0.593130, - 0.593368, 0.593605, 0.593842, 0.594080, 0.594318, 0.594555, 0.594793, - 0.595031, 0.595269, 0.595507, 0.595745, 0.595984, 0.596222, 0.596461, - 0.596699, 0.596938, 0.597177, 0.597415, 0.597654, 0.597893, 0.598133, - 0.598372, 0.598611, 0.598851, 0.599090, 0.599330, 0.599570, 0.599809, - 0.600049, 0.600289, 0.600529, 0.600770, 0.601010, 0.601250, 0.601491, - 0.601731, 0.601972, 0.602213, 0.602454, 0.602695, 0.602936, 0.603177, - 0.603418, 0.603660, 0.603901, 0.604143, 0.604384, 0.604626, 0.604868}}; - std::array<double, size> vecy = { - {15917.0, 16048.0, 16098.0, 15855.0, 15822.0, 15891.0, 15772.0, 15951.0, - 15860.0, 15813.0, 15742.0, 15733.0, 15594.0, 15644.0, 15850.0, 15623.0, - 15552.0, 15586.0, 15524.0, 15257.0, 15718.0, 15427.0, 15651.0, 15500.0, - 15611.0, 15508.0, 15230.0, 15111.0, 15483.0, 15316.0, 15256.0, 15152.0, - 15212.0, 15282.0, 15390.0, 15176.0, 15374.0, 15499.0, 16064.0, 16324.0, - 16240.0, 15972.0, 15770.0, 15449.0, 15644.0, 14972.0, 15146.0, 14799.0, - 15151.0, 14883.0, 14878.0, 14891.0, 14782.0, 14746.0, 15020.0, 14721.0, - 14813.0, 14744.0, 14786.0, 14783.0, 14876.0, 14776.0, 14729.0, 14806.0, - 14801.0, 14344.0, 14675.0, 14762.0, 14589.0, 14561.0, 14742.0, 14682.0, - 14634.0, 14542.0, 14758.0, 14667.0, 14586.0, 14729.0, 14581.0, 14445.0, - 14408.0, 14569.0, 14659.0, 14500.0}}; - std::array<double, size> vece = { - {126.163000, 126.681000, 126.878000, 125.917000, 125.786000, 126.060000, - 125.587000, 126.297000, 125.936000, 125.750000, 125.467000, 125.431000, - 124.876000, 125.076000, 125.897000, 124.992000, 124.708000, 124.844000, - 124.595000, 123.519000, 125.371000, 124.205000, 125.104000, 124.499000, - 124.944000, 124.531000, 123.410000, 122.927000, 124.431000, 123.758000, - 123.515000, 123.093000, 123.337000, 123.620000, 124.056000, 123.191000, - 123.992000, 124.495000, 126.744000, 127.765000, 127.436000, 126.380000, - 125.579000, 124.294000, 125.076000, 122.360000, 123.069000, 121.651000, - 123.089000, 121.996000, 121.975000, 122.029000, 121.581000, 121.433000, - 122.556000, 121.330000, 121.709000, 121.425000, 121.598000, 121.585000, - 121.967000, 121.557000, 121.363000, 121.680000, 121.659000, 119.766000, - 121.140000, 121.499000, 120.785000, 120.669000, 121.417000, 121.169000, - 120.971000, 120.590000, 121.483000, 121.107000, 120.773000, 121.363000, - 120.752000, 120.187000, 120.033000, 120.702000, 121.074000, - 120.416000}}; - const size_t NVectors = 1; MatrixWorkspace_sptr ws = boost::dynamic_pointer_cast<MatrixWorkspace>( WorkspaceFactory::Instance().create("Workspace2D", NVectors, size, size)); - ws->mutableX(0).assign(vecx.cbegin(), vecx.cend()); - ws->mutableY(0).assign(vecy.cbegin(), vecy.cend()); - ws->mutableE(0).assign(vece.cbegin(), vece.cend()); + ws->setHistogram( + 0, Points{0.585120, 0.585354, 0.585588, 0.585822, 0.586057, 0.586291, + 0.586526, 0.586760, 0.586995, 0.587230, 0.587465, 0.587700, + 0.587935, 0.588170, 0.588405, 0.588641, 0.588876, 0.589112, + 0.589347, 0.589583, 0.589819, 0.590055, 0.590291, 0.590527, + 0.590763, 0.590999, 0.591236, 0.591472, 0.591709, 0.591946, + 0.592182, 0.592419, 0.592656, 0.592893, 0.593130, 0.593368, + 0.593605, 0.593842, 0.594080, 0.594318, 0.594555, 0.594793, + 0.595031, 0.595269, 0.595507, 0.595745, 0.595984, 0.596222, + 0.596461, 0.596699, 0.596938, 0.597177, 0.597415, 0.597654, + 0.597893, 0.598133, 0.598372, 0.598611, 0.598851, 0.599090, + 0.599330, 0.599570, 0.599809, 0.600049, 0.600289, 0.600529, + 0.600770, 0.601010, 0.601250, 0.601491, 0.601731, 0.601972, + 0.602213, 0.602454, 0.602695, 0.602936, 0.603177, 0.603418, + 0.603660, 0.603901, 0.604143, 0.604384, 0.604626, 0.604868}, + Counts{15917.0, 16048.0, 16098.0, 15855.0, 15822.0, 15891.0, 15772.0, + 15951.0, 15860.0, 15813.0, 15742.0, 15733.0, 15594.0, 15644.0, + 15850.0, 15623.0, 15552.0, 15586.0, 15524.0, 15257.0, 15718.0, + 15427.0, 15651.0, 15500.0, 15611.0, 15508.0, 15230.0, 15111.0, + 15483.0, 15316.0, 15256.0, 15152.0, 15212.0, 15282.0, 15390.0, + 15176.0, 15374.0, 15499.0, 16064.0, 16324.0, 16240.0, 15972.0, + 15770.0, 15449.0, 15644.0, 14972.0, 15146.0, 14799.0, 15151.0, + 14883.0, 14878.0, 14891.0, 14782.0, 14746.0, 15020.0, 14721.0, + 14813.0, 14744.0, 14786.0, 14783.0, 14876.0, 14776.0, 14729.0, + 14806.0, 14801.0, 14344.0, 14675.0, 14762.0, 14589.0, 14561.0, + 14742.0, 14682.0, 14634.0, 14542.0, 14758.0, 14667.0, 14586.0, + 14729.0, 14581.0, 14445.0, 14408.0, 14569.0, 14659.0, 14500.0}, + CountStandardDeviations{ + 126.163000, 126.681000, 126.878000, 125.917000, 125.786000, + 126.060000, 125.587000, 126.297000, 125.936000, 125.750000, + 125.467000, 125.431000, 124.876000, 125.076000, 125.897000, + 124.992000, 124.708000, 124.844000, 124.595000, 123.519000, + 125.371000, 124.205000, 125.104000, 124.499000, 124.944000, + 124.531000, 123.410000, 122.927000, 124.431000, 123.758000, + 123.515000, 123.093000, 123.337000, 123.620000, 124.056000, + 123.191000, 123.992000, 124.495000, 126.744000, 127.765000, + 127.436000, 126.380000, 125.579000, 124.294000, 125.076000, + 122.360000, 123.069000, 121.651000, 123.089000, 121.996000, + 121.975000, 122.029000, 121.581000, 121.433000, 122.556000, + 121.330000, 121.709000, 121.425000, 121.598000, 121.585000, + 121.967000, 121.557000, 121.363000, 121.680000, 121.659000, + 119.766000, 121.140000, 121.499000, 120.785000, 120.669000, + 121.417000, 121.169000, 120.971000, 120.590000, 121.483000, + 121.107000, 120.773000, 121.363000, 120.752000, 120.187000, + 120.033000, 120.702000, 121.074000, 120.416000}); return ws; } @@ -368,176 +372,49 @@ public: MatrixWorkspace_sptr gen_PG3DiamondData() { vector<double> vecx, vecy, vece; - vecx.push_back(2.050678); - vecy.push_back(1.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.051498); - vecy.push_back(0.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.052319); - vecy.push_back(0.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.053140); - vecy.push_back(2.000000); - vece.push_back(1.41421E+00); - vecx.push_back(2.053961); - vecy.push_back(0.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.054783); - vecy.push_back(0.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.055605); - vecy.push_back(2.000000); - vece.push_back(1.41421E+00); - vecx.push_back(2.056427); - vecy.push_back(2.000000); - vece.push_back(1.41421E+00); - vecx.push_back(2.057250); - vecy.push_back(3.000000); - vece.push_back(1.73205E+00); - vecx.push_back(2.058072); - vecy.push_back(4.000000); - vece.push_back(2.00000E+00); - vecx.push_back(2.058896); - vecy.push_back(5.000000); - vece.push_back(2.23607E+00); - vecx.push_back(2.059719); - vecy.push_back(16.000000); - vece.push_back(4.00000E+00); - vecx.push_back(2.060543); - vecy.push_back(20.000000); - vece.push_back(4.47214E+00); - vecx.push_back(2.061367); - vecy.push_back(31.000000); - vece.push_back(5.56776E+00); - vecx.push_back(2.062192); - vecy.push_back(26.000000); - vece.push_back(5.09902E+00); - vecx.push_back(2.063017); - vecy.push_back(28.000000); - vece.push_back(5.29150E+00); - vecx.push_back(2.063842); - vecy.push_back(29.000000); - vece.push_back(5.38516E+00); - vecx.push_back(2.064668); - vecy.push_back(41.000000); - vece.push_back(6.40312E+00); - vecx.push_back(2.065493); - vecy.push_back(40.000000); - vece.push_back(6.32456E+00); - vecx.push_back(2.066320); - vecy.push_back(38.000000); - vece.push_back(6.16441E+00); - vecx.push_back(2.067146); - vecy.push_back(40.000000); - vece.push_back(6.32456E+00); - vecx.push_back(2.067973); - vecy.push_back(34.000000); - vece.push_back(5.83095E+00); - vecx.push_back(2.068800); - vecy.push_back(35.000000); - vece.push_back(5.91608E+00); - vecx.push_back(2.069628); - vecy.push_back(18.000000); - vece.push_back(4.24264E+00); - vecx.push_back(2.070456); - vecy.push_back(21.000000); - vece.push_back(4.58258E+00); - vecx.push_back(2.071284); - vecy.push_back(9.000000); - vece.push_back(3.00000E+00); - vecx.push_back(2.072112); - vecy.push_back(6.000000); - vece.push_back(2.44949E+00); - vecx.push_back(2.072941); - vecy.push_back(6.000000); - vece.push_back(2.44949E+00); - vecx.push_back(2.073770); - vecy.push_back(11.000000); - vece.push_back(3.31662E+00); - vecx.push_back(2.074600); - vecy.push_back(10.000000); - vece.push_back(3.16228E+00); - vecx.push_back(2.075430); - vecy.push_back(4.000000); - vece.push_back(2.00000E+00); - vecx.push_back(2.076260); - vecy.push_back(7.000000); - vece.push_back(2.64575E+00); - vecx.push_back(2.077090); - vecy.push_back(0.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.077921); - vecy.push_back(1.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.078752); - vecy.push_back(1.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.079584); - vecy.push_back(1.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.080416); - vecy.push_back(0.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.081248); - vecy.push_back(0.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.082080); - vecy.push_back(0.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.082913); - vecy.push_back(0.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.083746); - vecy.push_back(2.000000); - vece.push_back(1.41421E+00); - vecx.push_back(2.084580); - vecy.push_back(1.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.085414); - vecy.push_back(1.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.086248); - vecy.push_back(1.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.087082); - vecy.push_back(0.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.087917); - vecy.push_back(1.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.088752); - vecy.push_back(0.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.089588); - vecy.push_back(0.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.090424); - vecy.push_back(0.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.091260); - vecy.push_back(0.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.092096); - vecy.push_back(0.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.092933); - vecy.push_back(0.000000); - vece.push_back(1.00000E+00); - vecx.push_back(2.093770); - vecy.push_back(0.000000); - vece.push_back(1.00000E+00); - size_t NVectors = 1; - size_t sizex = vecx.size(); - size_t sizey = vecy.size(); + size_t size = 53; MatrixWorkspace_sptr ws = boost::dynamic_pointer_cast<MatrixWorkspace>( - WorkspaceFactory::Instance().create("Workspace2D", NVectors, sizex, - sizey)); + WorkspaceFactory::Instance().create("Workspace2D", NVectors, size, + size)); - ws->mutableX(0).assign(vecx.cbegin(), vecx.cend()); - ws->mutableY(0).assign(vecy.cbegin(), vecy.cend()); - ws->mutableE(0).assign(vece.cbegin(), vece.cend()); + ws->setHistogram( + 0, + Points{ + 2.050678, 2.051498, 2.052319, 2.053140, 2.053961, 2.054783, + 2.055605, 2.056427, 2.057250, 2.058072, 2.058896, 2.059719, + 2.060543, 2.061367, 2.062192, 2.063017, 2.063842, 2.064668, + 2.065493, 2.066320, 2.067146, 2.067973, 2.068800, 2.069628, + 2.070456, 2.071284, 2.072112, 2.072941, 2.073770, 2.074600, + 2.075430, 2.076260, 2.077090, 2.077921, 2.078752, 2.079584, + 2.080416, 2.081248, 2.082080, 2.082913, 2.083746, 2.084580, + 2.085414, 2.086248, 2.087082, 2.087917, 2.088752, 2.089588, + 2.090424, 2.091260, 2.092096, 2.092933, 2.093770, + }, + Counts{ + 1.000000, 0.000000, 0.000000, 2.000000, 0.000000, 0.000000, + 2.000000, 2.000000, 3.000000, 4.000000, 5.000000, 16.000000, + 20.000000, 31.000000, 26.000000, 28.000000, 29.000000, 41.000000, + 40.000000, 38.000000, 40.000000, 34.000000, 35.000000, 18.000000, + 21.000000, 9.000000, 6.000000, 6.000000, 11.000000, 10.000000, + 4.000000, 7.000000, 0.000000, 1.000000, 1.000000, 1.000000, + 0.000000, 0.000000, 0.000000, 0.000000, 2.000000, 1.000000, + 1.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, + }, + CountStandardDeviations{ + 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.41421E+00, 1.00000E+00, + 1.00000E+00, 1.41421E+00, 1.41421E+00, 1.73205E+00, 2.00000E+00, + 2.23607E+00, 4.00000E+00, 4.47214E+00, 5.56776E+00, 5.09902E+00, + 5.29150E+00, 5.38516E+00, 6.40312E+00, 6.32456E+00, 6.16441E+00, + 6.32456E+00, 5.83095E+00, 5.91608E+00, 4.24264E+00, 4.58258E+00, + 3.00000E+00, 2.44949E+00, 2.44949E+00, 3.31662E+00, 3.16228E+00, + 2.00000E+00, 2.64575E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, + 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, + 1.41421E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, + 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, 1.00000E+00, + 1.00000E+00, 1.00000E+00, 1.00000E+00, + }); return ws; } -- GitLab