diff --git a/Framework/Algorithms/src/CreateSampleWorkspace.cpp b/Framework/Algorithms/src/CreateSampleWorkspace.cpp index 4976102fe9062d9729b35fd29b8bb71cf05e25f1..3394e539cf9717dbb619be889ef347f4e4ec976c 100644 --- a/Framework/Algorithms/src/CreateSampleWorkspace.cpp +++ b/Framework/Algorithms/src/CreateSampleWorkspace.cpp @@ -349,7 +349,7 @@ EventWorkspace_sptr CreateSampleWorkspace::createEventWorkspace( // we need to normalise the results and then multiply by the number of events // to find the events per bin - double sum_of_elems = std::accumulate(yValues.begin(), yValues.end(), 0); + double sum_of_elems = std::accumulate(yValues.begin(), yValues.end(), 0.0); double event_distrib_factor = numEvents / sum_of_elems; std::transform(yValues.begin(), yValues.end(), yValues.begin(), std::bind1st(std::multiplies<double>(), event_distrib_factor)); diff --git a/Framework/Algorithms/test/CreateSampleWorkspaceTest.h b/Framework/Algorithms/test/CreateSampleWorkspaceTest.h index 4b93b2303a22207c79de16b0b6171d1166d12f15..2049f1706b790402f4dac8b21a533a6d6f7053a4 100644 --- a/Framework/Algorithms/test/CreateSampleWorkspaceTest.h +++ b/Framework/Algorithms/test/CreateSampleWorkspaceTest.h @@ -217,16 +217,25 @@ public: // Name of the output workspace. std::string outWSName("CreateSampleWorkspaceTest_OutputWS_event"); - // Retrieve the workspace from data service. TODO: Change to your desired - // type - MatrixWorkspace_sptr ws = createSampleWorkspace(outWSName, "Event"); - if (!ws) - return; - TS_ASSERT_DELTA(ws->readY(0)[20], 30, 0.0001); - TS_ASSERT_DELTA(ws->readY(0)[40], 30, 0.0001); - TS_ASSERT_DELTA(ws->readY(0)[50], 1030, 0.0001); - TS_ASSERT_DELTA(ws->readY(0)[60], 30, 0.0001); - TS_ASSERT_DELTA(ws->readY(0)[80], 30, 0.0001); + auto ws = boost::dynamic_pointer_cast<IEventWorkspace>(createSampleWorkspace(outWSName, "Event")); + TS_ASSERT(ws); + if(!ws) return; + + // The number of events per spectrum is not simply nhist*events_per_hist + // The algorithm computes the number of events required per bin to give the + // total per spectrum as requested but can only add integer numbers of events + // so the number added will always be less than expected. + // In this case the background has 99 bins at 0.3 & 1 bin at 10.3 => total sum=40 + // signal_scale_factor = events_per_spec/40 = 1000/40=25 => + // background Y = 0.3*25 = 7.5 => int(7.5)=7 + // peak Y = 10.3*25 = 257.5 => int(257.5)=257 + // Therefore in total we lose 0.5*100*200=10000 events + TS_ASSERT_EQUALS(ws->getNumberEvents(), 190000); + TS_ASSERT_DELTA(ws->readY(0)[20], 7, 0.0001); + TS_ASSERT_DELTA(ws->readY(0)[40], 7, 0.0001); + TS_ASSERT_DELTA(ws->readY(0)[50], 257, 0.0001); + TS_ASSERT_DELTA(ws->readY(0)[60], 7, 0.0001); + TS_ASSERT_DELTA(ws->readY(0)[80], 7, 0.0001); // Remove workspace from the data service. AnalysisDataService::Instance().remove(outWSName); @@ -354,11 +363,11 @@ public: MatrixWorkspace_sptr ws = createSampleWorkspace(outWSName, "Event"); if (!ws) return; - TS_ASSERT_DELTA(ws->readY(0)[20], 30, 50); - TS_ASSERT_DELTA(ws->readY(0)[40], 30, 50); - TS_ASSERT_DELTA(ws->readY(0)[50], 1030, 50); - TS_ASSERT_DELTA(ws->readY(0)[60], 30, 50); - TS_ASSERT_DELTA(ws->readY(0)[80], 3, 50); + TS_ASSERT_DELTA(ws->readY(0)[20], 7, 50); + TS_ASSERT_DELTA(ws->readY(0)[40], 7, 50); + TS_ASSERT_DELTA(ws->readY(0)[50], 257, 50); + TS_ASSERT_DELTA(ws->readY(0)[60], 7, 50); + TS_ASSERT_DELTA(ws->readY(0)[80], 7, 50); // Remove workspace from the data service. AnalysisDataService::Instance().remove(outWSName); diff --git a/docs/source/algorithms/AlignDetectors-v1.rst b/docs/source/algorithms/AlignDetectors-v1.rst index 556b10a9def077c89cd9e559130d0012c8ef701b..d628974076629339a35bf6e98344e1b1c4760b1a 100644 --- a/docs/source/algorithms/AlignDetectors-v1.rst +++ b/docs/source/algorithms/AlignDetectors-v1.rst @@ -79,7 +79,7 @@ Output: .. testoutput:: ExAlignDetectors Peak in dSpace 2.66413186052 - Peak from calibration 2.56009958218 + Peak from calibration 2.5596132087 .. categories:: diff --git a/docs/source/algorithms/CompressEvents-v1.rst b/docs/source/algorithms/CompressEvents-v1.rst index af0a11a7a80f6750521c788f5c773dab12f25c1f..d716a23eec6765f0a1d4ab356025cc8388146eb0 100644 --- a/docs/source/algorithms/CompressEvents-v1.rst +++ b/docs/source/algorithms/CompressEvents-v1.rst @@ -54,8 +54,8 @@ Output: .. testoutput:: CompressEvents :options: +NORMALIZE_WHITESPACE - The unfiltered workspace ws has 8000 events and a peak value of 1030.00 - The compressed workspace ws still has 8000 events and a peak value of 1030.00 + The unfiltered workspace ws has 1900 events and a peak value of 257.00 + The compressed workspace ws still has 1900 events and a peak value of 257.00 However it now takes up less memory. diff --git a/docs/source/algorithms/CreateFlatEventWorkspace-v1.rst b/docs/source/algorithms/CreateFlatEventWorkspace-v1.rst index 305a3ea415f62c3972b8c10105f53c527690901a..4f92d24c4e00f8588a18dbab9f64e235b18bf180 100644 --- a/docs/source/algorithms/CreateFlatEventWorkspace-v1.rst +++ b/docs/source/algorithms/CreateFlatEventWorkspace-v1.rst @@ -38,16 +38,16 @@ Output: The values for every 10th bin. bin ws wsOut - 0 16.00 16.00 - 10 16.00 16.00 - 20 16.00 16.00 - 30 572.00 16.00 - 40 16.00 16.00 - 50 16.00 16.00 - 60 461.00 16.00 - 70 16.00 16.00 - 80 16.00 16.00 - 90 16.00 16.00 + 0 6.00 6.00 + 10 6.00 6.00 + 20 6.00 6.00 + 30 214.00 6.00 + 40 6.00 6.00 + 50 6.00 6.00 + 60 172.00 6.00 + 70 6.00 6.00 + 80 6.00 6.00 + 90 6.00 6.00 diff --git a/docs/source/algorithms/CreateSampleWorkspace-v1.rst b/docs/source/algorithms/CreateSampleWorkspace-v1.rst index 04e566cc4a19110d6f8e8a7f2b16380e7a08fe26..8c1e5387d56f96ae05bff9e595012e80f046ff41 100644 --- a/docs/source/algorithms/CreateSampleWorkspace-v1.rst +++ b/docs/source/algorithms/CreateSampleWorkspace-v1.rst @@ -99,9 +99,9 @@ Output: Number of spectra: 200 Number of bins: 100 - Number of events: 800000 + Number of events: 190000 Event Workspaces come with bins set by default to a bin width of 200.0 - Each spectra has a level backgound of 30.0 counts and a peak in the centre of 1030.0 counts. + Each spectra has a level backgound of 7.0 counts and a peak in the centre of 257.0 counts. **Example - Using the preset functions:** diff --git a/docs/source/algorithms/DiffractionEventCalibrateDetectors-v1.rst b/docs/source/algorithms/DiffractionEventCalibrateDetectors-v1.rst index 6989dace535142a370bf21e74d7f782265c51daf..521f4ad05d89d96d2f2273e01cadce96246d392f 100644 --- a/docs/source/algorithms/DiffractionEventCalibrateDetectors-v1.rst +++ b/docs/source/algorithms/DiffractionEventCalibrateDetectors-v1.rst @@ -39,7 +39,7 @@ Output: .. testoutput:: ExDiffractionEventCalibrateDetectors Peak in dSpace 2.69077317913 - Peak from calibration 2.67124691143 + Peak from calibration 2.68342207235 .. categories:: diff --git a/docs/source/algorithms/FilterBadPulses-v1.rst b/docs/source/algorithms/FilterBadPulses-v1.rst index af338711ecedcd3cce06e87bdc5578cb4ac46b8a..c46cd5a239e90cf9541e0ca4f4d8a8aa55c3c7ef 100644 --- a/docs/source/algorithms/FilterBadPulses-v1.rst +++ b/docs/source/algorithms/FilterBadPulses-v1.rst @@ -40,8 +40,8 @@ Output: .. testoutput:: Filter - The number of events that remain: 4058 - compared to the number in the unfiltered workspace: 8000 + The number of events that remain: 950 + compared to the number in the unfiltered workspace: 1900 .. categories:: diff --git a/docs/source/algorithms/FilterByLogValue-v1.rst b/docs/source/algorithms/FilterByLogValue-v1.rst index 5f12dab6a6384329314f75c6eaf382d374274ceb..30ffb52cc8d973c2f876ce0c6f28b37db55b5e8f 100644 --- a/docs/source/algorithms/FilterByLogValue-v1.rst +++ b/docs/source/algorithms/FilterByLogValue-v1.rst @@ -108,8 +108,8 @@ Output: .. testoutput:: FilterByLogValue - The unfiltered workspace ws has 8000 events and a peak value of 1030.00 - The filtered workspace wsOut has 4058 events and a peak value of 502.00 + The unfiltered workspace ws has 1900 events and a peak value of 257.00 + The filtered workspace wsOut has 950 events and a peak value of 131.00 .. categories:: diff --git a/docs/source/algorithms/FilterByTime-v1.rst b/docs/source/algorithms/FilterByTime-v1.rst index 3274a8a26f75197a28fee021a829c4938376d4fb..ee384e793509c5d12ab549e2c1e376db40404da6 100644 --- a/docs/source/algorithms/FilterByTime-v1.rst +++ b/docs/source/algorithms/FilterByTime-v1.rst @@ -61,9 +61,9 @@ Output: .. testoutput:: ExFilter - The number of events within the relative Filter: 4058 - The number of events within the Aboslute Filter: 1322 - Compared to the number in the unfiltered workspace: 8000 + The number of events within the relative Filter: 950 + The number of events within the Aboslute Filter: 315 + Compared to the number in the unfiltered workspace: 1900 .. categories:: diff --git a/docs/source/algorithms/FilterByXValue-v1.rst b/docs/source/algorithms/FilterByXValue-v1.rst index fdfa8866e9e52217890382b7f8f613c04186643c..0870c0cbf37ceab576e58cc352ce6012a1e15107 100644 --- a/docs/source/algorithms/FilterByXValue-v1.rst +++ b/docs/source/algorithms/FilterByXValue-v1.rst @@ -35,8 +35,8 @@ Output: .. testoutput:: ExFilterTofByMax - 8000 events before filtering - 6500 events after filtering + 1900 events before filtering + 1550 events after filtering **Example: Applying Max and Min in Wavelength** @@ -53,8 +53,8 @@ Output: .. testoutput:: ExFilterWavelengthByMinMax - 8000 events before filtering - 4653 events after filtering + 1900 events before filtering + 1118 events after filtering .. categories:: diff --git a/docs/source/algorithms/SignalOverError-v1.rst b/docs/source/algorithms/SignalOverError-v1.rst index 7af4426cfe1ff071cd4055ccbdc6966ff4ebb995..2b5d42cabf81850d5aa29cf92ff7c5ed400889a9 100644 --- a/docs/source/algorithms/SignalOverError-v1.rst +++ b/docs/source/algorithms/SignalOverError-v1.rst @@ -36,16 +36,16 @@ Output: Values from every 10th bin bin Y E Y_New - 0 30.00 5.48 5.48 - 10 30.00 5.48 5.48 - 20 30.00 5.48 5.48 - 30 30.00 5.48 5.48 - 40 30.00 5.48 5.48 - 50 1030.00 32.09 32.09 - 60 30.00 5.48 5.48 - 70 30.00 5.48 5.48 - 80 30.00 5.48 5.48 - 90 30.00 5.48 5.48 + 0 7.00 2.65 2.65 + 10 7.00 2.65 2.65 + 20 7.00 2.65 2.65 + 30 7.00 2.65 2.65 + 40 7.00 2.65 2.65 + 50 257.00 16.03 16.03 + 60 7.00 2.65 2.65 + 70 7.00 2.65 2.65 + 80 7.00 2.65 2.65 + 90 7.00 2.65 2.65 .. categories:: diff --git a/docs/source/algorithms/SumEventsByLogValue-v1.rst b/docs/source/algorithms/SumEventsByLogValue-v1.rst index 77a9b2cbdfa958c15c54fa6f89a354b759e83431..5ec1435e499d252d31bae1f68ea24beac05dc2da 100644 --- a/docs/source/algorithms/SumEventsByLogValue-v1.rst +++ b/docs/source/algorithms/SumEventsByLogValue-v1.rst @@ -80,10 +80,10 @@ Output: .. testoutput:: Single-Spectrum Events were split into 3 sections based on the log 'Log2FilterBy'. - section 1: 2720.00 - section 2: 2643.00 - section 3: 2637.00 - Totalling 8000 events, matching the 8000 events in the input workspace + section 1: 615.00 + section 2: 629.00 + section 3: 656.00 + Totalling 1900 events, matching the 1900 events in the input workspace .. categories:: diff --git a/docs/source/algorithms/UnwrapSNS-v1.rst b/docs/source/algorithms/UnwrapSNS-v1.rst index 985747860f3600590319c7feed0415d4c5f8fdc2..7331b37c348018d3b5d04c5c440b50813aec8b0b 100644 --- a/docs/source/algorithms/UnwrapSNS-v1.rst +++ b/docs/source/algorithms/UnwrapSNS-v1.rst @@ -61,7 +61,7 @@ Output: .. testoutput:: ExUnwrapSNS - Input 30.0 + Input 7.0 Output 0.0 .. categories::