Skip to content

Commit

Permalink
Refs #5855. Handle old grouping file format.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Reuter committed Sep 25, 2012
1 parent 0c4d01b commit 4a0c80d
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions Code/Mantid/Framework/WorkflowAlgorithms/src/DgsRemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ One can use the ExecuteOppositeOrder to do grouping first then masking.
*WIKI*/

#include "MantidWorkflowAlgorithms/DgsRemap.h"
#include "MantidAPI/FileProperty.h"
#include "MantidDataObjects/GroupingWorkspace.h"

using namespace Mantid::Kernel;
Expand Down Expand Up @@ -65,6 +66,8 @@ namespace WorkflowAlgorithms
this->declareProperty(new WorkspaceProperty<MatrixWorkspace>("GroupingWorkspace",
"", Direction::Input, PropertyMode::Optional),
"A workspace containing grouping information");
this->declareProperty(new FileProperty("OldGroupingFile", "",
FileProperty::OptionalLoad), "Name of an old grouping format (not XML) file.");
this->declareProperty("ExecuteOppositeOrder", false,
"Execute grouping before masking.");
this->declareProperty(new WorkspaceProperty<MatrixWorkspace>("OutputWorkspace",
Expand Down Expand Up @@ -109,17 +112,29 @@ namespace WorkflowAlgorithms
void DgsRemap::execGrouping(MatrixWorkspace_sptr iWS, MatrixWorkspace_sptr &oWS)
{
MatrixWorkspace_sptr groupWS = this->getProperty("GroupingWorkspace");
if (groupWS)
std::string oldGroupingFile = this->getProperty("OldGroupingFile");
if (groupWS && !oldGroupingFile.empty())
{
int64_t ngroups = 0;
std::vector<int> groupDetIdList;
GroupingWorkspace_sptr gWS = boost::dynamic_pointer_cast<GroupingWorkspace>(groupWS);
gWS->makeDetectorIDToGroupVector(groupDetIdList, ngroups);
throw std::runtime_error("Choose either GroupingWorkspace or OldGroupingFile property!");
}

if (groupWS || !oldGroupingFile.empty())
{
IAlgorithm_sptr group = this->createSubAlgorithm("GroupDetectors");
group->setProperty("InputWorkspace", iWS);
group->setProperty("OutputWorkspace", iWS);
group->setProperty("DetectorList", groupDetIdList);
if (groupWS)
{
int64_t ngroups = 0;
std::vector<int> groupDetIdList;
GroupingWorkspace_sptr gWS = boost::dynamic_pointer_cast<GroupingWorkspace>(groupWS);
gWS->makeDetectorIDToGroupVector(groupDetIdList, ngroups);
group->setProperty("DetectorList", groupDetIdList);
}
if (!oldGroupingFile.empty())
{
group->setProperty("MapFile", oldGroupingFile);
}
group->setProperty("Behaviour", "Average");
group->executeAsSubAlg();
oWS = group->getProperty("OutputWorkspace");
Expand Down

0 comments on commit 4a0c80d

Please sign in to comment.