Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
506ae6ec
Commit
506ae6ec
authored
11 years ago
by
Russell Taylor
Browse files
Options
Downloads
Plain Diff
Merge remote branch 'origin/feature/7707_NewMedianDetectorTest'
parents
7376f05b
6da8f978
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Code/Mantid/Framework/Algorithms/test/MedianDetectorTestTest.h
+28
-36
28 additions, 36 deletions
...Mantid/Framework/Algorithms/test/MedianDetectorTestTest.h
with
28 additions
and
36 deletions
Code/Mantid/Framework/Algorithms/test/MedianDetectorTestTest.h
+
28
−
36
View file @
506ae6ec
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
#include
"MantidAPI/WorkspaceFactory.h"
#include
"MantidAPI/WorkspaceFactory.h"
#include
"MantidDataObjects/Workspace2D.h"
#include
"MantidDataObjects/Workspace2D.h"
#include
"MantidDataHandling/LoadInstrument.h"
#include
"MantidDataHandling/LoadInstrument.h"
#include
"MantidDataHandling/LoadEmptyInstrument.h"
//
#include "MantidDataHandling/LoadEmptyInstrument.h"
#include
<boost/shared_ptr.hpp>
#include
<boost/shared_ptr.hpp>
#include
<boost/lexical_cast.hpp>
#include
<boost/lexical_cast.hpp>
#include
<Poco/File.h>
#include
<Poco/File.h>
...
@@ -96,79 +96,71 @@ public:
...
@@ -96,79 +96,71 @@ public:
void
testSolidAngle
()
void
testSolidAngle
()
{
{
//load ARCS instrument, with all detectors 1
Mantid
::
DataObjects
::
Workspace2D_sptr
ws
=
WorkspaceCreationHelper
::
create2DWorkspaceWithRectangularInstrument
(
5
,
10
,
1
);
//Median Detector test with solid angle correction turned off should have no failures.
//With the correction turned on, and SignificanceTest = 0.01 should mask the short banks
// Load the empty instrument
for
(
size_t
i
=
0
;
i
<
ws
->
getNumberHistograms
();
i
++
)
Mantid
::
DataHandling
::
LoadEmptyInstrument
loader
;
{
loader
.
initialize
();
ws
->
dataY
(
i
)[
0
]
=
std
::
floor
(
1e9
*
ws
->
getDetector
(
i
)
->
solidAngle
(
V3D
(
0
,
0
,
0
)));
// TODO: (ticket #5973) Update the next line to not have a hard coded value for the filename
}
std
::
string
inputFile
=
"ARCS_Definition_20121011-.xml"
;
AnalysisDataService
::
Instance
().
addOrReplace
(
"MDTSolidAngle"
,
ws
);
loader
.
setPropertyValue
(
"Filename"
,
inputFile
);
loader
.
setPropertyValue
(
"OutputWorkspace"
,
"SolidAngle"
);
loader
.
execute
();
MedianDetectorTest
alg
;
MedianDetectorTest
alg
;
TS_ASSERT_THROWS_NOTHING
(
alg
.
initialize
());
TS_ASSERT_THROWS_NOTHING
(
alg
.
initialize
());
TS_ASSERT
(
alg
.
isInitialized
());
TS_ASSERT
(
alg
.
isInitialized
());
// Set the properties
// Set the properties
alg
.
setPropertyValue
(
"InputWorkspace"
,
"SolidAngle"
);
alg
.
setPropertyValue
(
"InputWorkspace"
,
"
MDT
SolidAngle"
);
alg
.
setPropertyValue
(
"OutputWorkspace"
,
"MedianDetectorTestOutput"
);
alg
.
setPropertyValue
(
"OutputWorkspace"
,
"MedianDetectorTestOutput"
);
// set significance test to small
// set significance test to small
alg
.
setProperty
(
"StartWorkspaceIndex"
,
2
);
//no monitors
alg
.
setProperty
(
"SignificanceTest"
,
0.00001
);
alg
.
setProperty
(
"SignificanceTest"
,
0.01
);
alg
.
setProperty
(
"CorrectForSolidAngle"
,
false
);
alg
.
setProperty
(
"CorrectForSolidAngle"
,
true
);
TS_ASSERT_THROWS_NOTHING
(
alg
.
execute
());
TS_ASSERT_THROWS_NOTHING
(
alg
.
execute
());
TS_ASSERT
(
alg
.
isExecuted
()
);
TS_ASSERT
(
alg
.
isExecuted
()
);
int
numFailed
=
alg
.
getProperty
(
"NumberOfFailures"
);
int
numFailed
=
alg
.
getProperty
(
"NumberOfFailures"
);
TS_ASSERT_EQUALS
(
numFailed
,
20
48
);
TS_ASSERT_EQUALS
(
numFailed
,
20
0
);
alg
.
setProperty
(
"CorrectForSolidAngle"
,
fals
e
);
alg
.
setProperty
(
"CorrectForSolidAngle"
,
tru
e
);
TS_ASSERT_THROWS_NOTHING
(
alg
.
execute
());
TS_ASSERT_THROWS_NOTHING
(
alg
.
execute
());
TS_ASSERT
(
alg
.
isExecuted
()
);
TS_ASSERT
(
alg
.
isExecuted
()
);
numFailed
=
alg
.
getProperty
(
"NumberOfFailures"
);
numFailed
=
alg
.
getProperty
(
"NumberOfFailures"
);
TS_ASSERT_EQUALS
(
numFailed
,
0
);
TS_ASSERT_EQUALS
(
numFailed
,
0
);
AnalysisDataService
::
Instance
().
remove
(
"MDTSolidAngle"
);
}
}
void
testLevelsUp
()
void
testLevelsUp
()
{
{
//load ARCS instrument, with all detectors 1
Mantid
::
DataObjects
::
Workspace2D_sptr
ws
=
WorkspaceCreationHelper
::
create2DWorkspaceWithRectangularInstrument
(
5
,
10
,
1
);
//With the solid angle correction turned on, and SignificanceTest = 0.01 should mask the short banks
//With the solid angle corection on, and LevelsUp=1, should be no failures
for
(
size_t
i
=
0
;
i
<
ws
->
getNumberHistograms
();
i
++
)
// Load the empty instrument
{
Mantid
::
DataHandling
::
LoadEmptyInstrument
loader
;
ws
->
dataY
(
i
)[
0
]
=
std
::
floor
(
1e9
*
ws
->
getDetector
(
i
)
->
solidAngle
(
V3D
(
0
,
0
,
0
)));
loader
.
initialize
();
}
// TODO: (ticket #5973) Update the next line to not have a hard coded value for the filename
AnalysisDataService
::
Instance
().
addOrReplace
(
"MDTLevelsUp"
,
ws
);
std
::
string
inputFile
=
"ARCS_Definition_20121011-.xml"
;
loader
.
setPropertyValue
(
"Filename"
,
inputFile
);
loader
.
setPropertyValue
(
"OutputWorkspace"
,
"SolidAngle"
);
loader
.
execute
();
MedianDetectorTest
alg
;
MedianDetectorTest
alg
;
TS_ASSERT_THROWS_NOTHING
(
alg
.
initialize
());
TS_ASSERT_THROWS_NOTHING
(
alg
.
initialize
());
TS_ASSERT
(
alg
.
isInitialized
());
TS_ASSERT
(
alg
.
isInitialized
());
// Set the properties
// Set the properties
alg
.
setPropertyValue
(
"InputWorkspace"
,
"
SolidAngle
"
);
alg
.
setPropertyValue
(
"InputWorkspace"
,
"
MDTLevelsUp
"
);
alg
.
setPropertyValue
(
"OutputWorkspace"
,
"MedianDetectorTestOutput"
);
alg
.
setPropertyValue
(
"OutputWorkspace"
,
"MedianDetectorTestOutput"
);
// set significance test to small
// set significance test to small
alg
.
setProperty
(
"StartWorkspaceIndex"
,
2
);
//no monitors
alg
.
setProperty
(
"SignificanceTest"
,
0.00001
);
alg
.
setProperty
(
"SignificanceTest"
,
0.01
);
alg
.
setProperty
(
"CorrectForSolidAngle"
,
false
);
alg
.
setProperty
(
"CorrectForSolidAngle"
,
true
);
alg
.
setProperty
(
"LevelsUp"
,
"0"
);
TS_ASSERT_THROWS_NOTHING
(
alg
.
execute
());
TS_ASSERT_THROWS_NOTHING
(
alg
.
execute
());
TS_ASSERT
(
alg
.
isExecuted
()
);
TS_ASSERT
(
alg
.
isExecuted
()
);
int
numFailed
=
alg
.
getProperty
(
"NumberOfFailures"
);
int
numFailed
=
alg
.
getProperty
(
"NumberOfFailures"
);
TS_ASSERT_EQUALS
(
numFailed
,
20
48
);
TS_ASSERT_EQUALS
(
numFailed
,
20
0
);
alg
.
setProperty
(
"LevelsUp"
,
"1"
);
alg
.
setProperty
(
"LevelsUp"
,
"1"
);
TS_ASSERT_THROWS_NOTHING
(
alg
.
execute
());
TS_ASSERT_THROWS_NOTHING
(
alg
.
execute
());
TS_ASSERT
(
alg
.
isExecuted
()
);
TS_ASSERT
(
alg
.
isExecuted
()
);
numFailed
=
alg
.
getProperty
(
"NumberOfFailures"
);
numFailed
=
alg
.
getProperty
(
"NumberOfFailures"
);
TS_ASSERT_EQUALS
(
numFailed
,
0
);
TS_ASSERT_EQUALS
(
numFailed
,
0
);
AnalysisDataService
::
Instance
().
remove
(
"MDTLevelsUp"
);
}
}
MedianDetectorTestTest
()
:
m_IWSName
(
"MedianDetectorTestInput"
)
MedianDetectorTestTest
()
:
m_IWSName
(
"MedianDetectorTestInput"
)
...
@@ -219,7 +211,7 @@ public:
...
@@ -219,7 +211,7 @@ public:
// Register the workspace in the data service
// Register the workspace in the data service
AnalysisDataService
::
Instance
().
add
(
m_IWSName
,
space
);
AnalysisDataService
::
Instance
().
add
(
m_IWSName
,
space
);
// Load the instrument data
// Load the instrument data
Mantid
::
DataHandling
::
LoadInstrument
loader
;
Mantid
::
DataHandling
::
LoadInstrument
loader
;
loader
.
initialize
();
loader
.
initialize
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment