Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
12069dcd
Commit
12069dcd
authored
Dec 05, 2016
by
Antti Soininen
Browse files
Code beautification.
Re #18091
parent
58af0b7c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Framework/DataHandling/inc/MantidDataHandling/LoadILLTOF.h
View file @
12069dcd
...
...
@@ -37,7 +37,8 @@ namespace DataHandling {
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class
DLLExport
LoadILLTOF
:
public
API
::
IFileLoader
<
Kernel
::
NexusDescriptor
>
,
public
API
::
DeprecatedAlgorithm
{
class
DLLExport
LoadILLTOF
:
public
API
::
IFileLoader
<
Kernel
::
NexusDescriptor
>
,
public
API
::
DeprecatedAlgorithm
{
public:
/// Constructor
LoadILLTOF
();
...
...
Framework/DataHandling/inc/MantidDataHandling/LoadILLTOF2.h
View file @
12069dcd
...
...
@@ -70,12 +70,12 @@ private:
void
addPulseInterval
();
void
loadTimeDetails
(
NeXus
::
NXEntry
&
entry
);
void
loadDataIntoTheWorkSpace
(
NeXus
::
NXEntry
&
entry
,
const
std
::
vector
<
std
::
vector
<
int
>>
&
);
void
loadSpectra
(
size_t
&
spec
,
const
size_t
numberOfMonitors
,
const
size_t
numberOfTubes
,
const
std
::
vector
<
Mantid
::
detid_t
>
&
detectorIDs
,
NeXus
::
NXInt
data
,
Mantid
::
API
::
Progress
progress
);
void
loadDataIntoTheWorkSpace
(
NeXus
::
NXEntry
&
entry
,
const
std
::
vector
<
std
::
vector
<
int
>>
&
);
void
loadSpectra
(
size_t
&
spec
,
const
size_t
numberOfMonitors
,
const
size_t
numberOfTubes
,
const
std
::
vector
<
Mantid
::
detid_t
>
&
detectorIDs
,
NeXus
::
NXInt
data
,
Mantid
::
API
::
Progress
progress
);
void
runLoadInstrument
();
...
...
Framework/DataHandling/src/LoadILL.cpp
View file @
12069dcd
...
...
@@ -10,7 +10,7 @@ namespace DataHandling {
DECLARE_NEXUS_FILELOADER_ALGORITHM
(
LoadILL
)
/// Constructor
LoadILL
::
LoadILL
()
:
LoadILLTOF
()
{
}
LoadILL
::
LoadILL
()
:
LoadILLTOF
()
{}
}
// namespace DataHandling
}
// namespace Mantid
Framework/DataHandling/src/LoadILLTOF.cpp
View file @
12069dcd
...
...
@@ -32,7 +32,7 @@ DECLARE_NEXUS_FILELOADER_ALGORITHM(LoadILLTOF)
* be used
*/
int
LoadILLTOF
::
confidence
(
Kernel
::
NexusDescriptor
&
descriptor
)
const
{
UNUSED_ARG
(
descriptor
)
UNUSED_ARG
(
descriptor
)
// This loader is deprecated.
return
0
;
}
...
...
Framework/DataHandling/src/LoadILLTOF2.cpp
View file @
12069dcd
...
...
@@ -19,7 +19,8 @@ using namespace HistogramData;
DECLARE_NEXUS_FILELOADER_ALGORITHM
(
LoadILLTOF2
)
/// A vector containing the supported instrument names
const
std
::
vector
<
std
::
string
>
LoadILLTOF2
::
SUPPORTED_INSTRUMENTS
=
{
"IN4"
,
"IN5"
,
"IN6"
};
const
std
::
vector
<
std
::
string
>
LoadILLTOF2
::
SUPPORTED_INSTRUMENTS
=
{
"IN4"
,
"IN5"
,
"IN6"
};
/**
* Return the confidence with with this algorithm can load the file
...
...
@@ -48,8 +49,7 @@ int LoadILLTOF2::confidence(Kernel::NexusDescriptor &descriptor) const {
}
}
LoadILLTOF2
::
LoadILLTOF2
()
:
API
::
IFileLoader
<
Kernel
::
NexusDescriptor
>
()
{
}
LoadILLTOF2
::
LoadILLTOF2
()
:
API
::
IFileLoader
<
Kernel
::
NexusDescriptor
>
()
{}
/**
* Initialises the algorithm
...
...
@@ -167,7 +167,7 @@ void LoadILLTOF2::loadInstrumentDetails(NeXus::NXEntry &firstEntry) {
* @param monitors List of monitor data
*/
void
LoadILLTOF2
::
initWorkSpace
(
NeXus
::
NXEntry
&
entry
,
const
std
::
vector
<
std
::
vector
<
int
>>
&
monitors
)
{
const
std
::
vector
<
std
::
vector
<
int
>>
&
monitors
)
{
// read in the data
NXData
dataGroup
=
entry
.
openNXData
(
"data"
);
...
...
@@ -343,11 +343,8 @@ void LoadILLTOF2::loadDataIntoTheWorkSpace(
// Put tof in an array
auto
&
X0
=
m_localWorkspace
->
mutableX
(
0
);
for
(
size_t
i
=
0
;
i
<
m_numberOfChannels
+
1
;
++
i
)
{
X0
[
i
]
=
m_timeOfFlightDelay
+
m_channelWidth
*
static_cast
<
double
>
(
i
)
-
m_channelWidth
/
2
;
// to make sure the bin centre is correct
X0
[
i
]
=
m_timeOfFlightDelay
+
m_channelWidth
*
static_cast
<
double
>
(
i
)
-
m_channelWidth
/
2
;
// to make sure the bin centre is correct
}
// The binning for monitors is considered the same as for detectors
...
...
@@ -407,9 +404,9 @@ void LoadILLTOF2::loadDataIntoTheWorkSpace(
* @param progress The progress monitor
*/
void
LoadILLTOF2
::
loadSpectra
(
size_t
&
spec
,
const
size_t
numberOfMonitors
,
const
size_t
numberOfTubes
,
const
std
::
vector
<
detid_t
>
&
detectorIDs
,
NXInt
data
,
Progress
progress
)
{
const
size_t
numberOfTubes
,
const
std
::
vector
<
detid_t
>
&
detectorIDs
,
NXInt
data
,
Progress
progress
)
{
for
(
size_t
i
=
0
;
i
<
numberOfTubes
;
++
i
)
{
for
(
size_t
j
=
0
;
j
<
m_numberOfPixelsPerTube
;
++
j
)
{
int
*
data_p
=
&
data
(
static_cast
<
int
>
(
i
),
static_cast
<
int
>
(
j
),
0
);
...
...
Framework/DataHandling/test/LoadILLTOF2Test.h
View file @
12069dcd
...
...
@@ -20,19 +20,19 @@ public:
void
testName
()
{
LoadILLTOF2
loader
;
TS_ASSERT_EQUALS
(
loader
.
name
(),
"LoadILLTOF"
)
TS_ASSERT_EQUALS
(
loader
.
name
(),
"LoadILLTOF"
)
}
void
testVersion
()
{
LoadILLTOF2
loader
;
TS_ASSERT_EQUALS
(
loader
.
version
(),
2
)
TS_ASSERT_EQUALS
(
loader
.
version
(),
2
)
}
void
testInit
()
{
LoadILLTOF2
loader
;
loader
.
setRethrows
(
true
);
TS_ASSERT_THROWS_NOTHING
(
loader
.
initialize
()
)
TS_ASSERT
(
loader
.
isInitialized
()
)
TS_ASSERT_THROWS_NOTHING
(
loader
.
initialize
())
TS_ASSERT
(
loader
.
isInitialized
())
}
/*
...
...
@@ -40,48 +40,57 @@ public:
* The elastic peak is obtained on the fly from the sample data.
*/
MatrixWorkspace_sptr
loadDataFile
(
const
std
::
string
dataFile
,
const
size_t
numberOfHistograms
,
const
size_t
numberOfChannels
,
const
double
tofDelay
,
const
double
tofChannelWidth
)
{
const
size_t
numberOfHistograms
,
const
size_t
numberOfChannels
,
const
double
tofDelay
,
const
double
tofChannelWidth
)
{
LoadILLTOF2
loader
;
loader
.
setRethrows
(
true
);
TS_ASSERT_THROWS_NOTHING
(
loader
.
initialize
()
)
TS_ASSERT_THROWS_NOTHING
(
loader
.
setPropertyValue
(
"Filename"
,
dataFile
)
)
TS_ASSERT_THROWS_NOTHING
(
loader
.
initialize
())
TS_ASSERT_THROWS_NOTHING
(
loader
.
setPropertyValue
(
"Filename"
,
dataFile
))
std
::
string
outputSpace
=
"LoadILLTOFTest_out"
;
TS_ASSERT_THROWS_NOTHING
(
loader
.
setPropertyValue
(
"OutputWorkspace"
,
outputSpace
)
)
TS_ASSERT_THROWS_NOTHING
(
loader
.
execute
()
)
TS_ASSERT_THROWS_NOTHING
(
loader
.
setPropertyValue
(
"OutputWorkspace"
,
outputSpace
))
TS_ASSERT_THROWS_NOTHING
(
loader
.
execute
())
MatrixWorkspace_sptr
output
=
AnalysisDataService
::
Instance
().
retrieveWS
<
MatrixWorkspace
>
(
outputSpace
);
TS_ASSERT_EQUALS
(
output
->
getNumberHistograms
(),
numberOfHistograms
)
for
(
size_t
wsIndex
=
0
;
wsIndex
!=
output
->
getNumberHistograms
();
++
wsIndex
)
{
TS_ASSERT_EQUALS
(
output
->
getNumberHistograms
(),
numberOfHistograms
)
for
(
size_t
wsIndex
=
0
;
wsIndex
!=
output
->
getNumberHistograms
();
++
wsIndex
)
{
const
auto
histogram
=
output
->
histogram
(
wsIndex
);
TS_ASSERT_EQUALS
(
histogram
.
xMode
(),
Mantid
::
HistogramData
::
Histogram
::
XMode
::
BinEdges
)
TS_ASSERT_EQUALS
(
histogram
.
yMode
(),
Mantid
::
HistogramData
::
Histogram
::
YMode
::
Counts
)
TS_ASSERT_EQUALS
(
histogram
.
size
(),
numberOfChannels
)
TS_ASSERT_EQUALS
(
histogram
.
xMode
(),
Mantid
::
HistogramData
::
Histogram
::
XMode
::
BinEdges
)
TS_ASSERT_EQUALS
(
histogram
.
yMode
(),
Mantid
::
HistogramData
::
Histogram
::
YMode
::
Counts
)
TS_ASSERT_EQUALS
(
histogram
.
size
(),
numberOfChannels
)
const
auto
&
xs
=
histogram
.
x
();
for
(
size_t
channelIndex
=
0
;
channelIndex
!=
xs
.
size
();
++
channelIndex
)
{
const
double
binEdge
=
tofDelay
+
static_cast
<
double
>
(
channelIndex
)
*
tofChannelWidth
-
tofChannelWidth
/
2
;
TS_ASSERT_DELTA
(
xs
[
channelIndex
],
binEdge
,
1e-3
)
const
double
binEdge
=
tofDelay
+
static_cast
<
double
>
(
channelIndex
)
*
tofChannelWidth
-
tofChannelWidth
/
2
;
TS_ASSERT_DELTA
(
xs
[
channelIndex
],
binEdge
,
1e-3
)
}
const
auto
&
ys
=
histogram
.
y
();
const
auto
&
es
=
histogram
.
e
();
for
(
size_t
channelIndex
=
0
;
channelIndex
!=
es
.
size
();
++
channelIndex
)
{
TS_ASSERT_EQUALS
(
es
[
channelIndex
],
std
::
sqrt
(
ys
[
channelIndex
])
)
TS_ASSERT_EQUALS
(
es
[
channelIndex
],
std
::
sqrt
(
ys
[
channelIndex
]))
}
}
// Check all detectors have a defined detector ID >= 0
Mantid
::
detid2index_map
detectorMap
;
TS_ASSERT_THROWS_NOTHING
(
detectorMap
=
output
->
getDetectorIDToWorkspaceIndexMap
(
true
)
)
TS_ASSERT_THROWS_NOTHING
(
detectorMap
=
output
->
getDetectorIDToWorkspaceIndexMap
(
true
))
// Check all detectors have a unique detector ID
TS_ASSERT_EQUALS
(
detectorMap
.
size
(),
output
->
getNumberHistograms
()
)
TS_ASSERT_EQUALS
(
detectorMap
.
size
(),
output
->
getNumberHistograms
())
for
(
const
auto
value
:
detectorMap
)
{
TS_ASSERT
(
value
.
first
>=
0
)
TS_ASSERT
(
value
.
first
>=
0
)
}
return
output
;
...
...
@@ -93,10 +102,13 @@ public:
const
double
tofChannelWidth
=
5.85
;
const
size_t
channelCount
=
512
;
const
size_t
histogramCount
=
397
;
MatrixWorkspace_sptr
ws
=
loadDataFile
(
"ILL/IN4/084446.nxs"
,
histogramCount
,
channelCount
,
tofDelay
,
tofChannelWidth
);
MatrixWorkspace_sptr
ws
=
loadDataFile
(
"ILL/IN4/084446.nxs"
,
histogramCount
,
channelCount
,
tofDelay
,
tofChannelWidth
);
const
double
pulseInterval
=
ws
->
run
().
getLogAsSingleValue
(
"pulse_interval"
);
TS_ASSERT_DELTA
(
0.003
,
pulseInterval
,
1e-10
)
const
double
pulseInterval
=
ws
->
run
().
getLogAsSingleValue
(
"pulse_interval"
);
TS_ASSERT_DELTA
(
0.003
,
pulseInterval
,
1e-10
)
}
void
test_IN5_load
()
{
...
...
@@ -105,7 +117,8 @@ public:
const
double
tofChannelWidth
=
14.6349
;
const
size_t
channelCount
=
512
;
const
size_t
histogramCount
=
98305
;
loadDataFile
(
"ILL/IN5/104007.nxs"
,
histogramCount
,
channelCount
,
tofDelay
,
tofChannelWidth
);
loadDataFile
(
"ILL/IN5/104007.nxs"
,
histogramCount
,
channelCount
,
tofDelay
,
tofChannelWidth
);
}
void
test_IN6_load
()
{
...
...
@@ -114,10 +127,13 @@ public:
const
double
tofChannelWidth
=
5.8
;
const
size_t
channelCount
=
1024
;
const
size_t
histogramCount
=
340
;
MatrixWorkspace_sptr
ws
=
loadDataFile
(
"ILL/IN6/164192.nxs"
,
histogramCount
,
channelCount
,
tofDelay
,
tofChannelWidth
);
MatrixWorkspace_sptr
ws
=
loadDataFile
(
"ILL/IN6/164192.nxs"
,
histogramCount
,
channelCount
,
tofDelay
,
tofChannelWidth
);
const
double
pulseInterval
=
ws
->
run
().
getLogAsSingleValue
(
"pulse_interval"
);
TS_ASSERT_DELTA
(
0.0060337892
,
pulseInterval
,
1e-10
)
const
double
pulseInterval
=
ws
->
run
().
getLogAsSingleValue
(
"pulse_interval"
);
TS_ASSERT_DELTA
(
0.0060337892
,
pulseInterval
,
1e-10
)
}
};
...
...
@@ -132,11 +148,11 @@ public:
void
testDefaultLoad
()
{
Mantid
::
DataHandling
::
LoadILLTOF2
loader
;
loader
.
setRethrows
(
true
);
TS_ASSERT_THROWS_NOTHING
(
loader
.
initialize
()
)
TS_ASSERT_THROWS_NOTHING
(
loader
.
setPropertyValue
(
"Filename"
,
m_dataFile
)
)
TS_ASSERT_THROWS_NOTHING
(
loader
.
setPropertyValue
(
"OutputWorkspace"
,
"ws"
)
)
TS_ASSERT_THROWS_NOTHING
(
loader
.
execute
()
)
TS_ASSERT
(
loader
.
isExecuted
()
)
TS_ASSERT_THROWS_NOTHING
(
loader
.
initialize
())
TS_ASSERT_THROWS_NOTHING
(
loader
.
setPropertyValue
(
"Filename"
,
m_dataFile
))
TS_ASSERT_THROWS_NOTHING
(
loader
.
setPropertyValue
(
"OutputWorkspace"
,
"ws"
))
TS_ASSERT_THROWS_NOTHING
(
loader
.
execute
())
TS_ASSERT
(
loader
.
isExecuted
())
}
private:
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment