Skip to content

Commit

Permalink
Refs #4814. DetectorEfficiencyVariation outputs SpecialWorkspace2D.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfpeterson committed Feb 21, 2012
1 parent 26fc5c3 commit 610b806
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,16 @@ namespace Mantid
const int progStep = static_cast<int>(std::ceil(numSpec/30.0));

// Create a workspace for the output
MatrixWorkspace_sptr maskWS = WorkspaceFactory::Instance().create(counts1);
// Make sure the output is simple
maskWS->isDistribution(false);
maskWS->setYUnit("");
MatrixWorkspace_sptr maskWS = this->generateEmptyMask(counts1);

const double liveValue(1.0);
bool checkForMask = false;
Geometry::Instrument_const_sptr instrument = counts1->getInstrument();
if (instrument != NULL)
{
checkForMask = ((instrument->getSource() != NULL) && (instrument->getSample() != NULL));
}

const double deadValue(1.0);
int numFailed(0);
PARALLEL_FOR3(counts1, counts2, maskWS)
for (int i = 0; i < numSpec; ++i)
Expand All @@ -233,28 +237,26 @@ namespace Mantid
interruption_point();
}

IDetector_const_sptr det;
try
if (checkForMask)
{
det = counts1->getDetector(i);
}
catch(Exception::NotFoundError &)
{}
if(!det || det->isMonitor()) continue;
if( det->isMasked() )
{
// Ensure it is masked on the output
maskWS->maskWorkspaceIndex(i);
continue;
if(instrument->isMonitor(i))
continue;
if(instrument->isDetectorMasked(i))
{
// Ensure it is masked on the output
maskWS->dataY(i)[0] = deadValue;
continue;
}
}

const double signal1 = counts1->readY(i)[0];
const double signal2 = counts2->readY(i)[0];

// Mask out NaN and infinite
if( boost::math::isinf(signal1) || boost::math::isnan(signal1) ||
boost::math::isinf(signal2) || boost::math::isnan(signal2))
{
maskWS->maskWorkspaceIndex(i);
maskWS->dataY(i)[0] = deadValue;
PARALLEL_ATOMIC
++numFailed;
continue;
Expand All @@ -265,15 +267,10 @@ namespace Mantid
const double ratio = signal1/signal2;
if( ratio < lowest || ratio > largest )
{
maskWS->maskWorkspaceIndex(i);
maskWS->dataY(i)[0] = deadValue;
PARALLEL_ATOMIC
++numFailed;
}
else
{
// Mark it with the "live" value
maskWS->dataY(i)[0] = liveValue;
}

PARALLEL_END_INTERUPT_REGION
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class DetectorEfficiencyVariationTest : public CxxTest::TestSuite
double m_ramp, m_LargeValue;
enum { Nhist = 84, NXs = 34,
//these values must match the values in DetectorEfficiencyVariation.h
BadVal = 0, GoodVal = 1 };
BadVal = 1, GoodVal = 0 };
};


Expand Down

0 comments on commit 610b806

Please sign in to comment.