Skip to content

Commit

Permalink
Refs #8506. Initial version - no correction applied.
Browse files Browse the repository at this point in the history
  • Loading branch information
arturbekasov committed Nov 27, 2013
1 parent 0de0b86 commit 80a4803
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
/*WIKI*
TODO: Enter a full wiki-markup description of your algorithm here. You can then use the Build/wiki_maker.py script to generate your full wiki page.
Load Muon data with Dead Time Correction applied. Part of the Muon workflow.
*WIKI*/

#include "MantidWorkflowAlgorithms/MuonLoadCorrected.h"

#include "MantidAPI/FileProperty.h"
#include "MantidKernel/ListValidator.h"

namespace Mantid
{
namespace WorkflowAlgorithms
{
using namespace Kernel;
using namespace API;

// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(MuonLoadCorrected)
Expand Down Expand Up @@ -50,13 +55,38 @@ namespace WorkflowAlgorithms
*/
void MuonLoadCorrected::init()
{
declareProperty(new FileProperty("Filename", "", FileProperty::Load, ".nxs"),
"The name of the Nexus file to load" );

std::vector<std::string> dtcTypes;
dtcTypes.push_back("None");
dtcTypes.push_back("FromData");
dtcTypes.push_back("FromSpecifiedFile");

declareProperty("DtcType","None", boost::make_shared<StringListValidator>(dtcTypes),
"Type of dead time correction to apply");

declareProperty(new FileProperty("DtcFile", "", FileProperty::OptionalLoad, ".nxs"),
"File with dead time values. Used only when DtcType is FromSpecifiedFile.");

declareProperty(new WorkspaceProperty<Workspace>("OutputWorkspace","",Direction::Output),
"The name of the workspace to be created as the output of the algorithm.");
}

//----------------------------------------------------------------------------------------------
/** Execute the algorithm.
*/
void MuonLoadCorrected::exec()
{
std::string filename = getPropertyValue("Filename");

IAlgorithm_sptr loadAlg = createChildAlgorithm("LoadMuonNexus");
loadAlg->setPropertyValue("Filename", filename);
loadAlg->executeAsChildAlg();

Workspace_sptr outWS = loadAlg->getProperty("OutputWorkspace");

setProperty("OutputWorkspace", outWS);
}

} // namespace WorkflowAlgorithms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,40 @@ class MuonLoadCorrectedTest : public CxxTest::TestSuite
TS_ASSERT( alg.existsProperty("OutputWorkspace") )
}

void test_noCorrection()
void test_singlePeriod_noCorrection()
{
MuonLoadCorrected alg;
TS_ASSERT_THROWS_NOTHING( alg.initialize() )
TS_ASSERT( alg.isInitialized() )

TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("Filename", "MUSR00015189") );
TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("Filename", "emu00006473.nxs") );
TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("DTCType", "None") );
TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("OutputWorkspace", g_outWSName) );

TS_ASSERT_THROWS_NOTHING( alg.execute(); );
TS_ASSERT( alg.isExecuted() );

// Retrieve the workspace from data service. TODO: Change to your desired type
MatrixWorkspace_sptr ws;
TS_ASSERT_THROWS_NOTHING( ws = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(g_outWSName) );
TS_ASSERT(ws);
if (!ws) return;

TSM_ASSERT( "You have forgot to check the results", 0);

TS_ASSERT_EQUALS( ws->blocksize(), 2000 );
TS_ASSERT_EQUALS( ws->getNumberHistograms(), 32 );

TS_ASSERT_EQUALS( ws->readY(0)[0], 52);
TS_ASSERT_EQUALS( ws->readY(7)[500], 166);
TS_ASSERT_EQUALS( ws->readY(15)[1000], 7);
TS_ASSERT_EQUALS( ws->readY(20)[1500], 1);
TS_ASSERT_EQUALS( ws->readY(31)[1999], 0);

TS_ASSERT_DELTA( ws->readX(0)[0], -0.254, 0.001 );
TS_ASSERT_DELTA( ws->readX(15)[1000], 15.746, 0.001 );
TS_ASSERT_DELTA( ws->readX(31)[2000], 31.741, 0.001 );

TS_ASSERT_DELTA( ws->readE(0)[0], 7.211, 0.001 );
TS_ASSERT_DELTA( ws->readE(15)[1000], 2.646, 0.001 );
TS_ASSERT_DELTA( ws->readE(31)[1999], 0, 0.001);
}
};

Expand Down

0 comments on commit 80a4803

Please sign in to comment.