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
6ee778bc
Commit
6ee778bc
authored
Oct 04, 2016
by
Ian Bush
Browse files
Refs #17861 LoadILLTOF to calculate pulse intervals
parent
1ea083cc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Framework/DataHandling/inc/MantidDataHandling/LoadILLTOF.h
View file @
6ee778bc
...
...
@@ -68,6 +68,7 @@ private:
void
initInstrumentSpecific
();
void
addAllNexusFieldsAsProperties
(
std
::
string
filename
);
void
addEnergyToRun
();
void
addPulseInterval
();
int
getDetectorElasticPeakPosition
(
const
NeXus
::
NXInt
&
data
);
void
loadTimeDetails
(
NeXus
::
NXEntry
&
entry
);
...
...
Framework/DataHandling/src/LoadILLTOF.cpp
View file @
6ee778bc
...
...
@@ -119,6 +119,7 @@ void LoadILLTOF::exec() {
calculatedDetectorElasticPeakPosition
);
addEnergyToRun
();
addPulseInterval
();
// load the instrument from the IDF if it exists
runLoadInstrument
();
...
...
@@ -352,6 +353,35 @@ void LoadILLTOF::addEnergyToRun() {
runDetails
.
addProperty
<
double
>
(
"Ei"
,
ei
,
true
);
// overwrite
}
/**
* Calculate and add the pulse intervals for the run
*/
void
LoadILLTOF
::
addPulseInterval
()
{
API
::
Run
&
runDetails
=
m_localWorkspace
->
mutableRun
();
double
pulseInterval
;
if
(
m_instrumentName
==
"IN4"
)
{
double
fermiChopperSpeed
=
runDetails
.
getPropertyAsSingleValue
(
"FC.rotation_speed"
);
double
bkgChopper1Speed
=
runDetails
.
getPropertyAsSingleValue
(
"BC1.rotation_speed"
);
double
bkgChopper2Speed
=
runDetails
.
getPropertyAsSingleValue
(
"BC2.rotation_speed"
);
if
(
std
::
abs
(
bkgChopper1Speed
-
bkgChopper2Speed
)
>
1
)
{
throw
std
::
invalid_argument
(
"Background choppers 1 and 2 have different speeds"
);
}
double
n
=
fermiChopperSpeed
/
bkgChopper1Speed
/
4
;
pulseInterval
=
60.0
/
(
2
*
fermiChopperSpeed
)
*
n
;
}
else
if
(
m_instrumentName
==
"IN6"
)
{
double
fermiChopperSpeed
=
runDetails
.
getPropertyAsSingleValue
(
"Fermi.rotation_speed"
);
double
suppressorSpeed
=
runDetails
.
getPropertyAsSingleValue
(
"Suppressor.rotation_speed"
);
double
n
=
fermiChopperSpeed
/
suppressorSpeed
;
pulseInterval
=
60.0
/
(
2
*
fermiChopperSpeed
)
*
n
;
}
runDetails
.
addProperty
<
double
>
(
"pulse_interval"
,
pulseInterval
);
}
/**
* Gets the experimental Elastic Peak Position in the dectector
* as the value parsed from the nexus file might be wrong.
...
...
Framework/DataHandling/test/LoadILLTOFTest.h
View file @
6ee778bc
...
...
@@ -16,6 +16,10 @@ public:
static
LoadILLTOFTest
*
createSuite
()
{
return
new
LoadILLTOFTest
();
}
static
void
destroySuite
(
LoadILLTOFTest
*
suite
)
{
delete
suite
;
}
void
tearDown
()
override
{
AnalysisDataService
::
Instance
().
clear
();
}
void
testName
()
{
LoadILLTOF
loader
;
TS_ASSERT_EQUALS
(
loader
.
name
(),
"LoadILLTOF"
);
...
...
@@ -36,7 +40,7 @@ public:
* This test only loads the Sample Data
* The elastic peak is obtained on the fly from the sample data.
*/
void
loadDataFile
(
const
std
::
string
dataFile
,
const
int
numberOfHistograms
)
{
MatrixWorkspace_sptr
loadDataFile
(
const
std
::
string
dataFile
,
const
int
numberOfHistograms
)
{
LoadILLTOF
loader
;
loader
.
initialize
();
loader
.
setPropertyValue
(
"Filename"
,
dataFile
);
...
...
@@ -53,12 +57,26 @@ public:
TS_ASSERT_EQUALS
(
output2D
->
getNumberHistograms
(),
numberOfHistograms
);
AnalysisDataService
::
Instance
().
clear
()
;
return
output2D
;
}
void
test_IN4_load
()
{
loadDataFile
(
"ILL/IN4/084446.nxs"
,
397
);
}
void
test_IN5_load
()
{
loadDataFile
(
"ILL/IN5/104007.nxs"
,
98305
);
}
void
test_IN6_load
()
{
loadDataFile
(
"ILL/IN6/164192.nxs"
,
340
);
}
void
test_IN4_load
()
{
MatrixWorkspace_sptr
ws
=
loadDataFile
(
"ILL/IN4/084446.nxs"
,
397
);
double
pulseInterval
=
ws
->
run
().
getLogAsSingleValue
(
"pulse_interval"
);
TS_ASSERT_DELTA
(
0.003
,
pulseInterval
,
1e-10
);
}
void
test_IN5_load
()
{
loadDataFile
(
"ILL/IN5/104007.nxs"
,
98305
);
}
void
test_IN6_load
()
{
MatrixWorkspace_sptr
ws
=
loadDataFile
(
"ILL/IN6/164192.nxs"
,
340
);
double
pulseInterval
=
ws
->
run
().
getLogAsSingleValue
(
"pulse_interval"
);
TS_ASSERT_DELTA
(
0.0060337892
,
pulseInterval
,
1e-10
);
}
};
//------------------------------------------------------------------------------
...
...
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