Skip to content

Commit

Permalink
Refs #4814. CreatePSDBleedMask outputs a SpecialWorkspace2D.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfpeterson committed Feb 21, 2012
1 parent e435bce commit 26fc5c3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ namespace Mantid
API::MatrixWorkspace_const_sptr inputWS);
/// Mask a tube with the given workspace indices
void maskTube(const std::vector<int> & tubeIndices, API::MatrixWorkspace_sptr workspace);
/// Mark a tubes data values as passing the tests
void markAsPassed(const std::vector<int> & tubeIndices, API::MatrixWorkspace_sptr workspace);

/// Maximum allowed rate
double m_maxRate;
Expand Down
38 changes: 7 additions & 31 deletions Code/Mantid/Framework/Algorithms/src/CreatePSDBleedMask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,7 @@ namespace Mantid
g_log.information() << "Found " << numTubes << " tubes.\n";
int numSpectraMasked(0), numTubesMasked(0);
// Create a mask workspace for output
MatrixWorkspace_sptr outputWorkspace =
API::WorkspaceFactory::Instance().create(inputWorkspace, numSpectra, 1, 1);
outputWorkspace->setYUnit("");
outputWorkspace->isDistribution(false);
outputWorkspace->setYUnitLabel("MaskValue");
MatrixWorkspace_sptr outputWorkspace = this->generateEmptyMask(inputWorkspace);

PARALLEL_FOR2(inputWorkspace, outputWorkspace)
for(int i = 0; i < numTubes; ++i )
Expand All @@ -183,10 +179,6 @@ namespace Mantid
PARALLEL_ATOMIC
numTubesMasked += 1;
}
else
{
markAsPassed(tubeIndices, outputWorkspace);
}

PARALLEL_END_INTERUPT_REGION
}
Expand Down Expand Up @@ -271,32 +263,16 @@ namespace Mantid
* @param tubeIndices :: A list of the workspaces indices for the tube
* @param workspace :: The workspace to accumulate the masking
*/
void CreatePSDBleedMask::maskTube(const std::vector<int> & tubeIndices,
API::MatrixWorkspace_sptr workspace)
void CreatePSDBleedMask::maskTube(const std::vector<int> & tubeIndices,
API::MatrixWorkspace_sptr workspace)
{
std::vector<int>::const_iterator cend = tubeIndices.end();
for(std::vector<int>::const_iterator citr = tubeIndices.begin();
citr != cend; ++citr)
{
workspace->maskWorkspaceIndex(*citr);
}
}
const double deadValue(1.0); // delete the data

/**
* Mark a tube's data values as passing the tests
* @param tubeIndices :: A list of the workspaces indices for the tube
* @param workspace :: The workspace's data values to change
*/
void CreatePSDBleedMask::markAsPassed(const std::vector<int> & tubeIndices,
API::MatrixWorkspace_sptr workspace)
{
// Mark as unmasked
std::vector<int>::const_iterator cend = tubeIndices.end();
for( std::vector<int>::const_iterator citr = tubeIndices.begin();
citr != cend; ++citr )
for(std::vector<int>::const_iterator citr = tubeIndices.begin();
citr != cend; ++citr)
{
workspace->dataY(*citr)[0] = 1.0;
workspace->dataE(*citr)[0] = 1.0;
workspace->dataY(*citr)[0] = deadValue;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,12 @@ class CreatePSDBleedMaskTest : public CxxTest::TestSuite
int failedIndexStart(50), failedIndexEnd(99);
for( int i = failedIndexStart; i <= failedIndexEnd; ++i )
{
IDetector_const_sptr det = outputWS->getDetector(i);
TS_ASSERT_EQUALS( det->isMasked(), true);
TS_ASSERT_EQUALS( outputWS->readY(i)[0], 1.);
}

for( int i = 0; i <= 49; ++i )
{
IDetector_const_sptr det = outputWS->getDetector(i);
TS_ASSERT_EQUALS( det->isMasked(), false );
TS_ASSERT_EQUALS( outputWS->readY(i)[0], 0.);
}

dataStore.remove(outputName);
Expand Down

0 comments on commit 26fc5c3

Please sign in to comment.