Skip to content

Commit

Permalink
Refs #8506. Multi-period dead times.
Browse files Browse the repository at this point in the history
  • Loading branch information
arturbekasov committed Nov 26, 2013
1 parent 3ac4a46 commit 0648adc
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Code/Mantid/Framework/DataHandling/src/LoadMuonNexus1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,23 @@ namespace Mantid
else
{
// More complex case - different dead times for different periods

if( numDeadTimes != m_numberOfSpectra * m_numberOfPeriods )
{
throw Exception::FileError("Number of dead times doesn't cover every spectra in every period",
m_filename);
}

WorkspaceGroup_sptr tableGroup = boost::make_shared<WorkspaceGroup>();

for(auto it = deadTimes.begin(); it != deadTimes.end(); it += m_numberOfSpectra)
{
TableWorkspace_sptr table = createDeadTimeTable(it, it + m_numberOfSpectra);

tableGroup->addWorkspace(table);
}

setProperty("DeadTimesTable", tableGroup);
}
}

Expand Down
68 changes: 68 additions & 0 deletions Code/Mantid/Framework/DataHandling/test/LoadMuonNexus1Test.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,74 @@ class LoadMuonNexus1Test : public CxxTest::TestSuite
AnalysisDataService::Instance().remove(outWSName);
AnalysisDataService::Instance().remove(deadTimesWSName);
}

void test_loadingDeadTimes_multiPeriod()
{

const std::string outWSName = "LoadMuonNexus1Test_OutputWS";
const std::string deadTimesWSName = "LoadMuonNexus1Test_DeadTimes";

LoadMuonNexus1 alg;

TS_ASSERT_THROWS_NOTHING( alg.initialize() );
TS_ASSERT( alg.isInitialized() );

TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("Filename", "MUSR00015189.nxs") );
TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("OutputWorkspace", outWSName) );
TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("DeadTimesTable", deadTimesWSName) );

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

WorkspaceGroup_sptr deadTimesGroup;

TS_ASSERT_THROWS_NOTHING( deadTimesGroup =
AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>( deadTimesWSName ) );

TS_ASSERT( deadTimesGroup );

if ( deadTimesGroup )
{
TS_ASSERT_EQUALS( deadTimesGroup->size(), 2 );

TableWorkspace_sptr table1 = boost::dynamic_pointer_cast<TableWorkspace>( deadTimesGroup->getItem(0) );
TS_ASSERT( table1 );

if ( table1 )
{
TS_ASSERT_EQUALS( table1->columnCount(), 2 );
TS_ASSERT_EQUALS( table1->rowCount(), 64 );

TS_ASSERT_EQUALS( table1->Int(0,0), 1 );
TS_ASSERT_EQUALS( table1->Int(31,0), 32 );
TS_ASSERT_EQUALS( table1->Int(63,0), 64 );

TS_ASSERT_DELTA( table1->Double(0,1), 0.01285629, 0.00000001 );
TS_ASSERT_DELTA( table1->Double(31,1), 0.01893649, 0.00000001 );
TS_ASSERT_DELTA( table1->Double(63,1), 0.01245339, 0.00000001 );
}

TableWorkspace_sptr table2 = boost::dynamic_pointer_cast<TableWorkspace>( deadTimesGroup->getItem(1) );
TS_ASSERT( table2 );

if ( table2 )
{
TS_ASSERT_EQUALS( table2->columnCount(), 2 );
TS_ASSERT_EQUALS( table2->rowCount(), 64 );

TS_ASSERT_EQUALS( table2->Int(0,0), 1 );
TS_ASSERT_EQUALS( table2->Int(31,0), 32 );
TS_ASSERT_EQUALS( table2->Int(63,0), 64 );

TS_ASSERT_DELTA( table2->Double(0,1), 0.01285629, 0.00000001 );
TS_ASSERT_DELTA( table2->Double(31,1),0.01893649, 0.00000001 );
TS_ASSERT_DELTA( table2->Double(63,1), 0.01245339, 0.00000001 );
}
}

AnalysisDataService::Instance().deepRemoveGroup(outWSName);
AnalysisDataService::Instance().deepRemoveGroup(deadTimesWSName);
}

private:
LoadMuonNexus1 nxLoad,nxload2,nxload3;
Expand Down

0 comments on commit 0648adc

Please sign in to comment.