Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
859b9ed3
Commit
859b9ed3
authored
Jun 01, 2018
by
Gagik Vardanyan
Browse files
Re #22212 unit tests for D33, performance test
parent
cfa4513b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Framework/DataHandling/test/LoadILLSANSTest.h
View file @
859b9ed3
...
...
@@ -3,6 +3,7 @@
#include <cxxtest/TestSuite.h>
#include "MantidAPI/Axis.h"
#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidDataHandling/LoadILLSANS.h"
...
...
@@ -10,12 +11,15 @@
#include "MantidGeometry/Instrument.h"
#include "MantidGeometry/Instrument/DetectorInfo.h"
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/Unit.h"
using
Mantid
::
DataHandling
::
LoadILLSANS
;
using
Mantid
::
API
::
Axis
;
using
Mantid
::
API
::
MatrixWorkspace_const_sptr
;
using
Mantid
::
API
::
AnalysisDataService
;
using
Mantid
::
Kernel
::
ConfigService
;
using
Mantid
::
Kernel
::
V3D
;
using
Mantid
::
Kernel
::
Unit
;
using
Mantid
::
Geometry
::
IComponent_const_sptr
;
using
Mantid
::
Geometry
::
Instrument
;
...
...
@@ -37,12 +41,12 @@ public:
AnalysisDataService
::
Instance
().
clear
();
}
void
test
N
ame
()
{
void
test
_n
ame
()
{
LoadILLSANS
alg
;
TS_ASSERT_EQUALS
(
alg
.
name
(),
"LoadILLSANS"
);
}
void
test
V
ersion
()
{
void
test
_v
ersion
()
{
LoadILLSANS
alg
;
TS_ASSERT_EQUALS
(
alg
.
version
(),
1
);
}
...
...
@@ -53,7 +57,7 @@ public:
TS_ASSERT
(
alg
.
isInitialized
())
}
void
test_D11
()
{
void
test_D11
()
{
LoadILLSANS
alg
;
alg
.
setChild
(
true
);
alg
.
initialize
();
...
...
@@ -64,25 +68,30 @@ void test_D11() {
TS_ASSERT
(
alg
.
isExecuted
())
MatrixWorkspace_const_sptr
outputWS
=
alg
.
getProperty
(
"OutputWorkspace"
);
TS_ASSERT
(
outputWS
)
TS_ASSERT_EQUALS
(
outputWS
->
getNumberHistograms
(),
128
*
128
+
2
)
TS_ASSERT_EQUALS
(
outputWS
->
getNumberHistograms
(),
128
*
128
+
2
)
TS_ASSERT_EQUALS
(
outputWS
->
blocksize
(),
1
)
TS_ASSERT
(
outputWS
->
detectorInfo
().
isMonitor
(
128
*
128
))
TS_ASSERT
(
outputWS
->
detectorInfo
().
isMonitor
(
128
*
128
+
1
))
TS_ASSERT
(
outputWS
->
detectorInfo
().
isMonitor
(
128
*
128
))
TS_ASSERT
(
outputWS
->
detectorInfo
().
isMonitor
(
128
*
128
+
1
))
TS_ASSERT
(
outputWS
->
isHistogramData
())
TS_ASSERT
(
!
outputWS
->
isDistribution
())
const
auto
&
instrument
=
outputWS
->
getInstrument
();
IComponent_const_sptr
component
=
instrument
->
getComponentByName
(
"detector"
);
IComponent_const_sptr
component
=
instrument
->
getComponentByName
(
"detector"
);
V3D
pos
=
component
->
getPos
();
TS_ASSERT_DELTA
(
pos
.
Z
(),
20.007
,
1E-3
)
const
auto
&
xAxis
=
outputWS
->
x
(
0
).
rawData
();
const
auto
&
spec6
=
outputWS
->
y
(
6
).
rawData
();
const
auto
&
xAxis
=
outputWS
->
x
(
0
).
rawData
();
const
auto
&
spec6
=
outputWS
->
y
(
6
).
rawData
();
const
auto
&
err6
=
outputWS
->
e
(
6
).
rawData
();
TS_ASSERT_EQUALS
(
xAxis
.
size
(),
2
)
TS_ASSERT_DELTA
(
xAxis
[
0
],
5.72778
,
1E-5
)
TS_ASSERT_DELTA
(
xAxis
[
1
],
6.26757
,
1E-5
)
TS_ASSERT_EQUALS
(
spec6
[
0
],
20
)
}
TS_ASSERT_DELTA
(
err6
[
0
],
sqrt
(
20
),
1E-5
)
const
auto
unit
=
outputWS
->
getAxis
(
0
)
->
unit
()
->
unitID
();
TS_ASSERT_EQUALS
(
unit
,
"Wavelength"
);
}
void
test_D22
()
{
void
test_D22
()
{
LoadILLSANS
alg
;
alg
.
setChild
(
true
);
alg
.
initialize
();
...
...
@@ -93,67 +102,122 @@ void test_D22() {
TS_ASSERT
(
alg
.
isExecuted
())
MatrixWorkspace_const_sptr
outputWS
=
alg
.
getProperty
(
"OutputWorkspace"
);
TS_ASSERT
(
outputWS
)
TS_ASSERT_EQUALS
(
outputWS
->
getNumberHistograms
(),
128
*
256
+
2
)
TS_ASSERT_EQUALS
(
outputWS
->
getNumberHistograms
(),
128
*
256
+
2
)
TS_ASSERT_EQUALS
(
outputWS
->
blocksize
(),
1
)
TS_ASSERT
(
outputWS
->
detectorInfo
().
isMonitor
(
128
*
256
))
TS_ASSERT
(
outputWS
->
detectorInfo
().
isMonitor
(
128
*
256
+
1
))
TS_ASSERT
(
outputWS
->
detectorInfo
().
isMonitor
(
128
*
256
))
TS_ASSERT
(
outputWS
->
detectorInfo
().
isMonitor
(
128
*
256
+
1
))
TS_ASSERT
(
outputWS
->
isHistogramData
())
TS_ASSERT
(
!
outputWS
->
isDistribution
())
const
auto
&
instrument
=
outputWS
->
getInstrument
();
IComponent_const_sptr
component
=
instrument
->
getComponentByName
(
"detector"
);
IComponent_const_sptr
component
=
instrument
->
getComponentByName
(
"detector"
);
V3D
pos
=
component
->
getPos
();
TS_ASSERT_DELTA
(
pos
.
Z
(),
8
,
0.01
)
TS_ASSERT_DELTA
(
pos
.
X
(),
0.35
,
0.01
)
const
auto
&
xAxis
=
outputWS
->
x
(
0
).
rawData
();
const
auto
&
spec6
=
outputWS
->
y
(
6
).
rawData
();
const
auto
&
xAxis
=
outputWS
->
x
(
0
).
rawData
();
const
auto
&
spec6
=
outputWS
->
y
(
6
).
rawData
();
const
auto
&
err6
=
outputWS
->
e
(
6
).
rawData
();
TS_ASSERT_EQUALS
(
xAxis
.
size
(),
2
)
TS_ASSERT_DELTA
(
xAxis
[
0
],
4.75015
,
1E-5
)
TS_ASSERT_DELTA
(
xAxis
[
1
],
5.25016
,
1E-5
)
TS_ASSERT_EQUALS
(
spec6
[
0
],
45
)
}
TS_ASSERT_DELTA
(
err6
[
0
],
sqrt
(
45
),
1E-5
)
const
auto
unit
=
outputWS
->
getAxis
(
0
)
->
unit
()
->
unitID
();
TS_ASSERT_EQUALS
(
unit
,
"Wavelength"
);
}
void
test_D33
()
{
LoadILLSANS
alg
;
alg
.
setChild
(
true
);
alg
.
initialize
();
TS_ASSERT_THROWS_NOTHING
(
alg
.
setPropertyValue
(
"Filename"
,
"002294.nxs"
))
TS_ASSERT_THROWS_NOTHING
(
alg
.
setPropertyValue
(
"OutputWorkspace"
,
"__unused_for_child"
))
TS_ASSERT_THROWS_NOTHING
(
alg
.
execute
())
TS_ASSERT
(
alg
.
isExecuted
())
MatrixWorkspace_const_sptr
outputWS
=
alg
.
getProperty
(
"OutputWorkspace"
);
TS_ASSERT
(
outputWS
)
TS_ASSERT_EQUALS
(
outputWS
->
getNumberHistograms
(),
256
*
256
+
2
)
TS_ASSERT_EQUALS
(
outputWS
->
blocksize
(),
1
)
TS_ASSERT
(
outputWS
->
detectorInfo
().
isMonitor
(
256
*
256
))
TS_ASSERT
(
outputWS
->
detectorInfo
().
isMonitor
(
256
*
256
+
1
))
TS_ASSERT
(
outputWS
->
isHistogramData
())
TS_ASSERT
(
!
outputWS
->
isDistribution
())
const
auto
&
xAxis
=
outputWS
->
x
(
0
).
rawData
();
const
auto
&
spec
=
outputWS
->
y
(
15947
).
rawData
();
const
auto
&
err
=
outputWS
->
e
(
15947
).
rawData
();
TS_ASSERT_EQUALS
(
xAxis
.
size
(),
2
)
TS_ASSERT_DELTA
(
xAxis
[
0
],
9.5
,
1E-3
)
TS_ASSERT_DELTA
(
xAxis
[
1
],
10.5
,
1E-3
)
TS_ASSERT_EQUALS
(
spec
[
0
],
220
)
TS_ASSERT_DELTA
(
err
[
0
],
sqrt
(
220
),
1E-5
)
const
auto
&
instrument
=
outputWS
->
getInstrument
();
IComponent_const_sptr
back
=
instrument
->
getComponentByName
(
"back_detector"
);
TS_ASSERT_EQUALS
(
back
->
getPos
(),
V3D
(
0
,
0
,
10.1128
));
IComponent_const_sptr
right
=
instrument
->
getComponentByName
(
"front_detector_right"
);
TS_ASSERT_EQUALS
(
right
->
getPos
(),
V3D
(
-
0.41
,
0
,
1.4968
));
IComponent_const_sptr
left
=
instrument
->
getComponentByName
(
"front_detector_left"
);
TS_ASSERT_EQUALS
(
left
->
getPos
(),
V3D
(
0.41
,
0
,
1.4968
));
IComponent_const_sptr
top
=
instrument
->
getComponentByName
(
"front_detector_top"
);
TS_ASSERT_EQUALS
(
top
->
getPos
(),
V3D
(
0
,
0.41
,
1.3118
));
IComponent_const_sptr
bottom
=
instrument
->
getComponentByName
(
"front_detector_bottom"
);
TS_ASSERT_EQUALS
(
bottom
->
getPos
(),
V3D
(
0
,
-
0.41
,
1.3118
));
const
auto
unit
=
outputWS
->
getAxis
(
0
)
->
unit
()
->
unitID
();
TS_ASSERT_EQUALS
(
unit
,
"Wavelength"
);
}
void
test_D33_TOF
()
{
LoadILLSANS
alg
;
alg
.
setChild
(
true
);
alg
.
initialize
();
TS_ASSERT_THROWS_NOTHING
(
alg
.
setPropertyValue
(
"Filename"
,
"042610.nxs"
))
TS_ASSERT_THROWS_NOTHING
(
alg
.
setPropertyValue
(
"OutputWorkspace"
,
"__unused_for_child"
))
TS_ASSERT_THROWS_NOTHING
(
alg
.
execute
())
TS_ASSERT
(
alg
.
isExecuted
())
MatrixWorkspace_const_sptr
outputWS
=
alg
.
getProperty
(
"OutputWorkspace"
);
TS_ASSERT
(
outputWS
)
TS_ASSERT_EQUALS
(
outputWS
->
getNumberHistograms
(),
256
*
256
+
2
)
TS_ASSERT_EQUALS
(
outputWS
->
blocksize
(),
200
)
TS_ASSERT
(
outputWS
->
detectorInfo
().
isMonitor
(
256
*
256
))
TS_ASSERT
(
outputWS
->
detectorInfo
().
isMonitor
(
256
*
256
+
1
))
TS_ASSERT
(
outputWS
->
isHistogramData
())
TS_ASSERT
(
!
outputWS
->
isDistribution
())
const
auto
&
x
=
outputWS
->
x
(
0
).
rawData
();
TS_ASSERT_DELTA
(
x
[
0
],
0.04969
,
1E-5
)
TS_ASSERT_DELTA
(
x
[
1
],
0.14873
,
1E-5
)
TS_ASSERT_DELTA
(
x
[
200
],
19.85713
,
1E-5
)
const
auto
&
run
=
outputWS
->
run
();
TS_ASSERT
(
run
.
hasProperty
(
"tof_mode"
))
const
auto
tof
=
run
.
getLogData
(
"tof_mode"
);
TS_ASSERT_EQUALS
(
tof
->
value
(),
"TOF"
);
const
auto
unit
=
outputWS
->
getAxis
(
0
)
->
unit
()
->
unitID
();
TS_ASSERT_EQUALS
(
unit
,
"Wavelength"
);
}
};
class
LoadILLSANSTestPerformance
:
public
CxxTest
::
TestSuite
{
public:
void
setUp
()
override
{
for
(
int
i
=
0
;
i
<
numberOfIterations
;
++
i
)
{
loadAlgPtrs
.
emplace_back
(
setupAlg
());
}
m_alg
.
initialize
();
m_alg
.
setChild
(
true
);
m_alg
.
setPropertyValue
(
"Filename"
,
"ILL/D33/042610.nxs"
);
m_alg
.
setPropertyValue
(
"OutputWorkspace"
,
"__unused_for_child"
);
}
void
testLoadILLSANSPerformance
()
{
for
(
auto
alg
:
loadAlgPtrs
)
{
TS_ASSERT_THROWS_NOTHING
(
alg
->
execute
());
}
}
void
tearDown
()
override
{
for
(
int
i
=
0
;
i
<
numberOfIterations
;
i
++
)
{
delete
loadAlgPtrs
[
i
];
loadAlgPtrs
[
i
]
=
nullptr
;
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
TS_ASSERT_THROWS_NOTHING
(
m_alg
.
execute
());
}
Mantid
::
API
::
AnalysisDataService
::
Instance
().
remove
(
outWSName
);
}
void
tearDown
()
override
{
AnalysisDataService
::
Instance
().
clear
();
}
private:
std
::
vector
<
LoadILLSANS
*>
loadAlgPtrs
;
const
int
numberOfIterations
=
2
;
const
std
::
string
inFileName
=
"ILLD33_041714_NonTof.nxs"
;
const
std
::
string
outWSName
=
"LoadILLSANSWsOut"
;
LoadILLSANS
*
setupAlg
()
{
LoadILLSANS
*
loader
=
new
LoadILLSANS
;
loader
->
initialize
();
loader
->
isInitialized
();
loader
->
setPropertyValue
(
"Filename"
,
inFileName
);
loader
->
setPropertyValue
(
"OutputWorkspace"
,
outWSName
);
loader
->
setRethrows
(
true
);
return
loader
;
}
LoadILLSANS
m_alg
;
};
#endif
/* MANTID_DATAHANDLING_LOADILLSANSTEST_H_ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment