Skip to content
Snippets Groups Projects
Commit cc61d846 authored by Jose Borreguero's avatar Jose Borreguero
Browse files

Refs #23175 Add Number to Events workspaces

parent 4430f694
No related branches found
No related tags found
No related merge requests found
...@@ -86,15 +86,16 @@ void AppendSpectra::exec() { ...@@ -86,15 +86,16 @@ void AppendSpectra::exec() {
const int number = getProperty("Number"); const int number = getProperty("Number");
if (event_ws1 && event_ws2) { if (event_ws1 && event_ws2) {
// Both are event workspaces. Use the special method // Both are event workspaces. Use the special method
MatrixWorkspace_sptr output = this->execEvent(*event_ws1, *event_ws2); DataObjects::EventWorkspace_sptr output = this->execEvent(*event_ws1, *event_ws2);
if (number > 1) for (int i = 1; i < number; i++) {
g_log.warning("Number property is ignored for event workspaces"); output = this->execEvent(*output, *event_ws2);
if (mergeLogs) }
combineLogs(ws1->run(), ws2->run(), output->mutableRun()); if (mergeLogs)
// Set the output workspace combineLogs(ws1->run(), ws2->run(), output->mutableRun());
setProperty("OutputWorkspace", output); // Set the output workspace
return; setProperty("OutputWorkspace", boost::dynamic_pointer_cast<MatrixWorkspace>(output));
return;
} }
// So it is a workspace 2D. // So it is a workspace 2D.
......
...@@ -178,7 +178,7 @@ public: ...@@ -178,7 +178,7 @@ public:
} }
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
void doTest(bool event, bool combineLogs = false) { void doTest(bool event, bool combineLogs=false, int number=1) {
MatrixWorkspace_sptr ws1, ws2, out; MatrixWorkspace_sptr ws1, ws2, out;
int numBins = 20; int numBins = 20;
...@@ -212,6 +212,7 @@ public: ...@@ -212,6 +212,7 @@ public:
TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("InputWorkspace1", ws1Name)); TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("InputWorkspace1", ws1Name));
TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("InputWorkspace2", ws2Name)); TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("InputWorkspace2", ws2Name));
TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", ws1Name)); TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", ws1Name));
TS_ASSERT_THROWS_NOTHING(alg.setProperty("Number", number));
if (combineLogs) if (combineLogs)
alg.setProperty("MergeLogs", true); alg.setProperty("MergeLogs", true);
TS_ASSERT_THROWS_NOTHING(alg.execute();) TS_ASSERT_THROWS_NOTHING(alg.execute();)
...@@ -224,7 +225,7 @@ public: ...@@ -224,7 +225,7 @@ public:
if (!out) if (!out)
return; return;
TS_ASSERT_EQUALS(out->getNumberHistograms(), 15); TS_ASSERT_EQUALS(out->getNumberHistograms(), 10 + 5 * number);
TS_ASSERT_EQUALS(out->blocksize(), numBins); TS_ASSERT_EQUALS(out->blocksize(), numBins);
for (size_t wi = 0; wi < out->getNumberHistograms(); wi++) { for (size_t wi = 0; wi < out->getNumberHistograms(); wi++) {
...@@ -246,6 +247,8 @@ public: ...@@ -246,6 +247,8 @@ public:
void test_events() { doTest(true); } void test_events() { doTest(true); }
void test_number_events() {doTest(true, true, 3);}
void test_2D() { doTest(false); } void test_2D() { doTest(false); }
void test_events_mergeLogs() { doTest(true, true); } void test_events_mergeLogs() { doTest(true, true); }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment