Skip to content

Commit

Permalink
Refs #8839. Fix the multi-period grouping.
Browse files Browse the repository at this point in the history
For some reason, previous implementation was returning grouped
workspaces as OutputWorkspaceN while still returning ungrouped
workspaces as OutputWorkspace. I don't really understand why we would
need OutputWorkpsaceN properties at all when we can just return a
group.
  • Loading branch information
arturbekasov committed Feb 12, 2014
1 parent e7351da commit ed2eb05
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions Code/Mantid/Framework/DataHandling/src/LoadMuonNexus1.cpp
Expand Up @@ -254,10 +254,6 @@ namespace Mantid
localWorkspace->setYUnit("Counts");

WorkspaceGroup_sptr wsGrpSptr=WorkspaceGroup_sptr(new WorkspaceGroup);
if(m_numberOfPeriods>1)
{
setProperty("OutputWorkspace",boost::dynamic_pointer_cast<Workspace>(wsGrpSptr));
}

API::Progress progress(this,0.,1.,m_numberOfPeriods * total_specs);
// Loop over the number of periods in the Nexus file, putting each period in a separate workspace
Expand Down Expand Up @@ -286,22 +282,6 @@ namespace Mantid
(WorkspaceFactory::Instance().create(localWorkspace));
localWorkspace->setTitle(title);
localWorkspace->setComment(notes);
//localWorkspace->newInstrumentParameters(); ???

}


std::string outws("OutputWorkspace");
if(m_numberOfPeriods>1)
{
auto suffix = boost::lexical_cast<std::string>(period+1);
outws += "_" + suffix;
std::string WSName = localWSName + "_" + suffix;
declareProperty(new WorkspaceProperty<Workspace>(outws,WSName,Direction::Output));
if (wsGrpSptr)
{
wsGrpSptr->addWorkspace( localWorkspace );
}
}

size_t counter = 0;
Expand All @@ -326,6 +306,8 @@ namespace Mantid
// Just a sanity check
assert(counter == size_t(total_specs) );

Workspace_sptr outWs;

if (autoGroup && loadedGrouping)
{
TableWorkspace_sptr groupingTable;
Expand All @@ -346,15 +328,27 @@ namespace Mantid

MatrixWorkspace_sptr groupedWs = groupDet->getProperty("OutputWorkspace");

setProperty(outws, boost::dynamic_pointer_cast<Workspace>(groupedWs));
outWs = groupedWs;
}
else
{
setProperty(outws, boost::dynamic_pointer_cast<Workspace>(localWorkspace));
outWs = localWorkspace;
}

if ( m_numberOfPeriods == 1 )
setProperty("OutputWorkspace", outWs);
else
// In case of multiple periods, just add workspace to the group, and we will return the
// group later
wsGrpSptr->addWorkspace(outWs);

} // loop over periods

if(m_numberOfPeriods>1)
{
setProperty("OutputWorkspace", boost::dynamic_pointer_cast<Workspace>(wsGrpSptr));
}

// Clean up
delete[] timeChannels;
}
Expand Down

0 comments on commit ed2eb05

Please sign in to comment.