-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Michael Reuter
committed
Sep 12, 2012
1 parent
35fbffe
commit 775d101
Showing
3 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
Code/Mantid/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/DgsRemap.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#ifndef MANTID_WORKFLOWALGORITHMS_DGSREMAP_H_ | ||
#define MANTID_WORKFLOWALGORITHMS_DGSREMAP_H_ | ||
|
||
#include "MantidKernel/System.h" | ||
#include "MantidAPI/Algorithm.h" | ||
|
||
namespace Mantid | ||
{ | ||
namespace WorkflowAlgorithms | ||
{ | ||
|
||
/** DgsRemap : TODO: DESCRIPTION | ||
Copyright © 2012 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory | ||
This file is part of Mantid. | ||
Mantid is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 3 of the License, or | ||
(at your option) any later version. | ||
Mantid is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid> | ||
Code Documentation is available at: <http://doxygen.mantidproject.org> | ||
*/ | ||
class DLLExport DgsRemap : public API::Algorithm | ||
{ | ||
public: | ||
DgsRemap(); | ||
virtual ~DgsRemap(); | ||
|
||
virtual const std::string name() const; | ||
virtual int version() const; | ||
virtual const std::string category() const; | ||
|
||
private: | ||
virtual void initDocs(); | ||
void init(); | ||
void exec(); | ||
|
||
|
||
}; | ||
|
||
|
||
} // namespace WorkflowAlgorithms | ||
} // namespace Mantid | ||
|
||
#endif /* MANTID_WORKFLOWALGORITHMS_DGSREMAP_H_ */ |
105 changes: 105 additions & 0 deletions
105
Code/Mantid/Framework/WorkflowAlgorithms/src/DgsRemap.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/*WIKI* | ||
This algorithm is responsible for masking and grouping the given input workspace. | ||
*WIKI*/ | ||
|
||
#include "MantidWorkflowAlgorithms/DgsRemap.h" | ||
#include "MantidDataObjects/GroupingWorkspace.h" | ||
|
||
using namespace Mantid::Kernel; | ||
using namespace Mantid::API; | ||
using namespace Mantid::DataObjects; | ||
|
||
namespace Mantid | ||
{ | ||
namespace WorkflowAlgorithms | ||
{ | ||
|
||
// Register the algorithm into the AlgorithmFactory | ||
DECLARE_ALGORITHM(DgsRemap) | ||
|
||
//---------------------------------------------------------------------------------------------- | ||
/** Constructor | ||
*/ | ||
DgsRemap::DgsRemap() | ||
{ | ||
} | ||
|
||
//---------------------------------------------------------------------------------------------- | ||
/** Destructor | ||
*/ | ||
DgsRemap::~DgsRemap() | ||
{ | ||
} | ||
|
||
//---------------------------------------------------------------------------------------------- | ||
/// Algorithm's name for identification. @see Algorithm::name | ||
const std::string DgsRemap::name() const { return "DgsRemap"; }; | ||
|
||
/// Algorithm's version for identification. @see Algorithm::version | ||
int DgsRemap::version() const { return 1; }; | ||
|
||
/// Algorithm's category for identification. @see Algorithm::category | ||
const std::string DgsRemap::category() const { return "Workflow\\Inelastic"; } | ||
|
||
//---------------------------------------------------------------------------------------------- | ||
/// Sets documentation strings for this algorithm | ||
void DgsRemap::initDocs() | ||
{ | ||
this->setWikiSummary("Mask and/or group the given workspace."); | ||
this->setOptionalMessage("Mask and/or group the given workspace."); | ||
} | ||
|
||
//---------------------------------------------------------------------------------------------- | ||
/** Initialize the algorithm's properties. | ||
*/ | ||
void DgsRemap::init() | ||
{ | ||
this->declareProperty(new WorkspaceProperty<MatrixWorkspace>("InputWorkspace", | ||
"", Direction::Input), "An input workspace to mask and group."); | ||
this->declareProperty(new WorkspaceProperty<MatrixWorkspace>("MaskWorkspace", | ||
"", Direction::Input), "A workspace containing masking information."); | ||
this->declareProperty(new WorkspaceProperty<MatrixWorkspace>("GroupingWorkspace", | ||
"", Direction::Input), "A workspace containing grouping information"); | ||
this->declareProperty(new WorkspaceProperty<MatrixWorkspace>("OutputWorkspace", | ||
"", Direction::Output), "The resulting workspace."); | ||
} | ||
|
||
//---------------------------------------------------------------------------------------------- | ||
/** Execute the algorithm. | ||
*/ | ||
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"); | ||
|
||
if (maskWS) | ||
{ | ||
IAlgorithm_sptr mask = this->createSubAlgorithm("MaskDetectors"); | ||
mask->setProperty("Workspace", inputWS); | ||
mask->setProperty("MaskedWorkspace", maskWS); | ||
mask->executeAsSubAlg(); | ||
} | ||
|
||
if (groupWS) | ||
{ | ||
int64_t ngroups = 0; | ||
std::vector<int> groupDetIdList; | ||
GroupingWorkspace_sptr gWS = boost::dynamic_pointer_cast<GroupingWorkspace>(groupWS); | ||
gWS->makeDetectorIDToGroupVector(groupDetIdList, ngroups); | ||
|
||
IAlgorithm_sptr group = this->createSubAlgorithm("GroupDetectors"); | ||
group->setProperty("InputWorkspace", inputWS); | ||
group->setProperty("OutputWorkspace", outputWS); | ||
group->setProperty("DetectorList", groupDetIdList); | ||
group->setProperty("Behaviour", "Average"); | ||
group->executeAsSubAlg(); | ||
} | ||
|
||
this->setProperty("OutputWorkspace", outputWS); | ||
} | ||
} // namespace WorkflowAlgorithms | ||
} // namespace Mantid |