Skip to content

Commit

Permalink
Refs #5855. Allow reverse running order.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Reuter committed Sep 13, 2012
1 parent d25413c commit ed912ff
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ namespace WorkflowAlgorithms
virtual void initDocs();
void init();
void exec();
void execGrouping(API::MatrixWorkspace_sptr iWS, API::MatrixWorkspace_sptr &oWS);
void execMasking(API::MatrixWorkspace_sptr iWS);


};
Expand All @@ -53,4 +55,4 @@ namespace WorkflowAlgorithms
} // namespace WorkflowAlgorithms
} // namespace Mantid

#endif /* MANTID_WORKFLOWALGORITHMS_DGSREMAP_H_ */
#endif /* MANTID_WORKFLOWALGORITHMS_DGSREMAP_H_ */
38 changes: 30 additions & 8 deletions Code/Mantid/Framework/WorkflowAlgorithms/src/DgsRemap.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*WIKI*
This algorithm is responsible for masking and grouping the given input workspace.
One can use the ExecuteOppositeOrder to do grouping first then masking.
*WIKI*/

Expand Down Expand Up @@ -64,6 +65,8 @@ namespace WorkflowAlgorithms
this->declareProperty(new WorkspaceProperty<MatrixWorkspace>("GroupingWorkspace",
"", Direction::Input, PropertyMode::Optional),
"A workspace containing grouping information");
this->declareProperty("ExecuteOppositeOrder", false,
"Execute grouping before masking.");
this->declareProperty(new WorkspaceProperty<MatrixWorkspace>("OutputWorkspace",
"", Direction::Output), "The resulting workspace.");
}
Expand All @@ -74,18 +77,38 @@ namespace WorkflowAlgorithms
void DgsRemap::exec()
{
MatrixWorkspace_sptr inputWS = this->getProperty("InputWorkspace");
MatrixWorkspace_sptr maskWS = this->getProperty("MaskWorkspace");
MatrixWorkspace_sptr groupWS = this->getProperty("GroupingWorkspace");
MatrixWorkspace_sptr outputWS = this->getProperty("OutputWorkspace");

bool runOpposite = this->getProperty("ExecuteOppositeOrder");
if (!runOpposite)
{
this->execMasking(inputWS);
this->execGrouping(inputWS, outputWS);
}
else
{
this->execGrouping(inputWS, outputWS);
this->execMasking(inputWS);
}

this->setProperty("OutputWorkspace", outputWS);
}

void DgsRemap::execMasking(MatrixWorkspace_sptr iWS)
{
MatrixWorkspace_sptr maskWS = this->getProperty("MaskWorkspace");
if (maskWS)
{
IAlgorithm_sptr mask = this->createSubAlgorithm("MaskDetectors");
mask->setProperty("Workspace", inputWS);
mask->setProperty("Workspace", iWS);
mask->setProperty("MaskedWorkspace", maskWS);
mask->executeAsSubAlg();
}
}

void DgsRemap::execGrouping(MatrixWorkspace_sptr iWS, MatrixWorkspace_sptr &oWS)
{
MatrixWorkspace_sptr groupWS = this->getProperty("GroupingWorkspace");
if (groupWS)
{
int64_t ngroups = 0;
Expand All @@ -94,15 +117,14 @@ namespace WorkflowAlgorithms
gWS->makeDetectorIDToGroupVector(groupDetIdList, ngroups);

IAlgorithm_sptr group = this->createSubAlgorithm("GroupDetectors");
group->setProperty("InputWorkspace", inputWS);
group->setProperty("OutputWorkspace", inputWS);
group->setProperty("InputWorkspace", iWS);
group->setProperty("OutputWorkspace", iWS);
group->setProperty("DetectorList", groupDetIdList);
group->setProperty("Behaviour", "Average");
group->executeAsSubAlg();
outputWS = group->getProperty("OutputWorkspace");
oWS = group->getProperty("OutputWorkspace");
}

this->setProperty("OutputWorkspace", outputWS);
}

} // namespace WorkflowAlgorithms
} // namespace Mantid

0 comments on commit ed912ff

Please sign in to comment.