Commit 07a1fa16 authored by Peterson, Peter's avatar Peterson, Peter
Browse files

Rename functions to clarify what they do

parent d77371db
...@@ -66,7 +66,7 @@ private: ...@@ -66,7 +66,7 @@ private:
void appendChunk(Mantid::API::Workspace_sptr chunkWS); void appendChunk(Mantid::API::Workspace_sptr chunkWS);
API::Workspace_sptr appendMatrixWSChunk(API::Workspace_sptr accumWS, API::Workspace_sptr appendMatrixWSChunk(API::Workspace_sptr accumWS,
Mantid::API::Workspace_sptr chunkWS); Mantid::API::Workspace_sptr chunkWS);
void resetAllXToSingleBin(API::Workspace *workspace); void updateDefaultBinBoundaries(API::Workspace *workspace);
/// The "accumulation" workspace = after adding, but before post-processing /// The "accumulation" workspace = after adding, but before post-processing
Mantid::API::Workspace_sptr m_accumWS; Mantid::API::Workspace_sptr m_accumWS;
......
...@@ -418,7 +418,7 @@ Workspace_sptr LoadLiveData::appendMatrixWSChunk(Workspace_sptr accumWS, ...@@ -418,7 +418,7 @@ Workspace_sptr LoadLiveData::appendMatrixWSChunk(Workspace_sptr accumWS,
} }
namespace { namespace {
bool shouldResetAllXToSingleBin(const EventWorkspace *workspace) { bool isUsingDefaultBinBoundaries(const EventWorkspace *workspace) {
// only check first spectrum // only check first spectrum
const auto &x = workspace->binEdges(0); const auto &x = workspace->binEdges(0);
if (x.size() > 2) if (x.size() > 2)
...@@ -439,16 +439,16 @@ bool shouldResetAllXToSingleBin(const EventWorkspace *workspace) { ...@@ -439,16 +439,16 @@ bool shouldResetAllXToSingleBin(const EventWorkspace *workspace) {
* *
* @param workspace :: Workspace(Group) that will have its bins reset * @param workspace :: Workspace(Group) that will have its bins reset
*/ */
void LoadLiveData::resetAllXToSingleBin(API::Workspace *workspace) { void LoadLiveData::updateDefaultBinBoundaries(API::Workspace *workspace) {
if (auto *ws_event = dynamic_cast<EventWorkspace *>(workspace)) { if (auto *ws_event = dynamic_cast<EventWorkspace *>(workspace)) {
if (shouldResetAllXToSingleBin(ws_event)) if (isUsingDefaultBinBoundaries(ws_event))
ws_event->resetAllXToSingleBin(); ws_event->resetAllXToSingleBin();
} else if (auto *ws_group = dynamic_cast<WorkspaceGroup *>(workspace)) { } else if (auto *ws_group = dynamic_cast<WorkspaceGroup *>(workspace)) {
auto num_entries = static_cast<size_t>(ws_group->getNumberOfEntries()); auto num_entries = static_cast<size_t>(ws_group->getNumberOfEntries());
for (size_t i = 0; i < num_entries; ++i) { for (size_t i = 0; i < num_entries; ++i) {
auto ws = ws_group->getItem(i); auto ws = ws_group->getItem(i);
if (auto *ws_event = dynamic_cast<EventWorkspace *>(ws.get())) if (auto *ws_event = dynamic_cast<EventWorkspace *>(ws.get()))
if (shouldResetAllXToSingleBin(ws_event)) if (isUsingDefaultBinBoundaries(ws_event))
ws_event->resetAllXToSingleBin(); ws_event->resetAllXToSingleBin();
} }
} }
...@@ -505,11 +505,10 @@ void LoadLiveData::exec() { ...@@ -505,11 +505,10 @@ void LoadLiveData::exec() {
this->setPropertyValue("LastTimeStamp", lastTimeStamp.toISO8601String()); this->setPropertyValue("LastTimeStamp", lastTimeStamp.toISO8601String());
// For EventWorkspaces, we adjust the X values such that all events fit // For EventWorkspaces, we adjust the X values such that all events fit
// within the bin boundaries. This is done both before and after the // within the bin boundaries
// "Process" step. Any custom rebinning should be done in Post-Processing.
const bool preserveEvents = this->getProperty("PreserveEvents"); const bool preserveEvents = this->getProperty("PreserveEvents");
if (preserveEvents) if (preserveEvents)
this->resetAllXToSingleBin(chunkWS.get()); this->updateDefaultBinBoundaries(chunkWS.get());
// Now we process the chunk // Now we process the chunk
Workspace_sptr processed = this->processChunk(chunkWS); Workspace_sptr processed = this->processChunk(chunkWS);
...@@ -569,11 +568,10 @@ void LoadLiveData::exec() { ...@@ -569,11 +568,10 @@ void LoadLiveData::exec() {
// Default to Add. // Default to Add.
this->addChunk(processed); this->addChunk(processed);
// For EventWorkspaces, we adjust the X values such that all events fit // When adding events, the default bin boundaries may need to be updated.
// within the bin boundaries. This is done both before and after the // The function itself checks to see if it is appropriate
// "Process" step. Any custom rebinning should be done in Post-Processing.
if (preserveEvents) { if (preserveEvents) {
this->resetAllXToSingleBin(m_accumWS.get()); this->updateDefaultBinBoundaries(m_accumWS.get());
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment