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
f0b62a97
Commit
f0b62a97
authored
14 years ago
by
Michael Whitty
Browse files
Options
Downloads
Patches
Plain Diff
re #1684 - hopefully fix tests
parent
77292d95
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Code/Mantid/Algorithms/src/ConvertUnits.cpp
+42
-21
42 additions, 21 deletions
Code/Mantid/Algorithms/src/ConvertUnits.cpp
with
42 additions
and
21 deletions
Code/Mantid/Algorithms/src/ConvertUnits.cpp
+
42
−
21
View file @
f0b62a97
...
@@ -284,33 +284,41 @@ void ConvertUnits::convertViaEventsTOF(const int& numberOfSpectra, Kernel::Unit_
...
@@ -284,33 +284,41 @@ void ConvertUnits::convertViaEventsTOF(const int& numberOfSpectra, Kernel::Unit_
// Not doing anything with the Y vector in to/fromTOF yet, so just pass empty vector
// Not doing anything with the Y vector in to/fromTOF yet, so just pass empty vector
std
::
vector
<
double
>
emptyVec
;
std
::
vector
<
double
>
emptyVec
;
const
bool
needEfixed
=
(
outputUnit
->
unitID
().
find
(
"DeltaE"
)
!=
std
::
string
::
npos
);
double
efixedProp
=
getProperty
(
"Efixed"
);
double
efixedProp
=
getProperty
(
"Efixed"
);
if
(
emode
==
1
)
if
(
needEfixed
)
{
{
//... direct efixed gather
if
(
emode
==
1
)
if
(
efixedProp
==
EMPTY_DBL
()
)
{
{
// try and get the value from the run parameters
//... direct efixed gather
const
API
::
Run
&
run
=
outputWS
->
run
();
if
(
efixedProp
==
EMPTY_DBL
()
)
if
(
run
.
hasProperty
(
"Ei"
)
)
{
{
Kernel
::
Property
*
prop
=
run
.
getProperty
(
"Ei"
);
// try and get the value from the run parameters
efixedProp
=
boost
::
lexical_cast
<
double
,
std
::
string
>
(
prop
->
value
());
const
API
::
Run
&
run
=
outputWS
->
run
();
if
(
run
.
hasProperty
(
"Ei"
)
)
{
Kernel
::
Property
*
prop
=
run
.
getProperty
(
"Ei"
);
efixedProp
=
boost
::
lexical_cast
<
double
,
std
::
string
>
(
prop
->
value
());
}
else
{
if
(
needEfixed
)
throw
std
::
invalid_argument
(
"Could not retrieve incident energy from run object"
);
else
efixedProp
=
0.0
;
}
}
}
else
else
{
{
throw
std
::
invalid_argument
(
"Could not retrieve incident energy from run object"
);
// set the Ei value in the run parameters
API
::
Run
&
run
=
outputWS
->
mutableRun
();
run
.
addProperty
<
double
>
(
"Ei"
,
efixedProp
);
}
}
}
}
else
else
if
(
emode
==
0
&&
efixedProp
==
EMPTY_DBL
()
)
// Elastic
{
{
// set the Ei value in the run parameters
efixedProp
=
0.0
;
API
::
Run
&
run
=
outputWS
->
mutableRun
();
run
.
addProperty
<
double
>
(
"Ei"
,
efixedProp
);
}
}
}
}
else
if
(
emode
==
0
&&
efixedProp
==
EMPTY_DBL
()
)
// Elastic
else
{
{
efixedProp
=
0.0
;
efixedProp
=
0.0
;
}
}
...
@@ -324,7 +332,8 @@ void ConvertUnits::convertViaEventsTOF(const int& numberOfSpectra, Kernel::Unit_
...
@@ -324,7 +332,8 @@ void ConvertUnits::convertViaEventsTOF(const int& numberOfSpectra, Kernel::Unit_
/// @todo Don't yet consider hold-off (delta)
/// @todo Don't yet consider hold-off (delta)
const
double
delta
=
0.0
;
const
double
delta
=
0.0
;
try
{
try
{
// Now get the detector object for this histogram
// Now get the detector object for this histogram
IDetector_sptr
det
=
outputWS
->
getDetector
(
i
);
IDetector_sptr
det
=
outputWS
->
getDetector
(
i
);
// Get the sample-detector distance for this detector (in metres)
// Get the sample-detector distance for this detector (in metres)
...
@@ -337,14 +346,16 @@ void ConvertUnits::convertViaEventsTOF(const int& numberOfSpectra, Kernel::Unit_
...
@@ -337,14 +346,16 @@ void ConvertUnits::convertViaEventsTOF(const int& numberOfSpectra, Kernel::Unit_
// If an indirect instrument, try getting Efixed from the geometry
// If an indirect instrument, try getting Efixed from the geometry
if
(
emode
==
2
)
if
(
emode
==
2
)
{
{
try
{
try
{
Parameter_sptr
par
=
pmap
.
get
(
det
->
getComponent
(),
"Efixed"
);
Parameter_sptr
par
=
pmap
.
get
(
det
->
getComponent
(),
"Efixed"
);
if
(
par
)
if
(
par
)
{
{
efixed
=
par
->
value
<
double
>
();
efixed
=
par
->
value
<
double
>
();
g_log
.
debug
()
<<
"Detector: "
<<
det
->
getID
()
<<
" EFixed: "
<<
efixed
<<
"
\n
"
;
g_log
.
debug
()
<<
"Detector: "
<<
det
->
getID
()
<<
" EFixed: "
<<
efixed
<<
"
\n
"
;
}
}
}
catch
(
std
::
runtime_error
)
{
/* Throws if a DetectorGroup, use single provided value */
}
}
catch
(
std
::
runtime_error
&
)
{
/* Throws if a DetectorGroup, use single provided value */
}
}
}
}
}
else
// If this is a monitor then make l2 = source-detector distance, l1=0 and twoTheta=0
else
// If this is a monitor then make l2 = source-detector distance, l1=0 and twoTheta=0
...
@@ -353,7 +364,7 @@ void ConvertUnits::convertViaEventsTOF(const int& numberOfSpectra, Kernel::Unit_
...
@@ -353,7 +364,7 @@ void ConvertUnits::convertViaEventsTOF(const int& numberOfSpectra, Kernel::Unit_
l2
=
l2
-
l1
;
l2
=
l2
-
l1
;
twoTheta
=
0.0
;
twoTheta
=
0.0
;
// Energy transfer is meaningless for a monitor, so set l2 to 0.
// Energy transfer is meaningless for a monitor, so set l2 to 0.
if
(
outputUnit
->
unitID
().
find
(
"Delta"
)
==
0
)
if
(
needEfixed
)
{
{
l2
=
0.0
;
l2
=
0.0
;
efixed
=
DBL_MIN
;
efixed
=
DBL_MIN
;
...
@@ -376,7 +387,9 @@ void ConvertUnits::convertViaEventsTOF(const int& numberOfSpectra, Kernel::Unit_
...
@@ -376,7 +387,9 @@ void ConvertUnits::convertViaEventsTOF(const int& numberOfSpectra, Kernel::Unit_
if
((
!
x
.
empty
())
&&
(
*
(
x
.
begin
())
>
*
(
x
.
end
()
-
1
)))
if
((
!
x
.
empty
())
&&
(
*
(
x
.
begin
())
>
*
(
x
.
end
()
-
1
)))
outputWS
->
getEventList
(
i
).
reverse
();
outputWS
->
getEventList
(
i
).
reverse
();
}
catch
(
Exception
::
NotFoundError
&
)
{
}
catch
(
Exception
::
NotFoundError
&
)
{
// Get to here if exception thrown when calculating distance to detector
// Get to here if exception thrown when calculating distance to detector
failedDetectorCount
++
;
failedDetectorCount
++
;
outputWS
->
getEventList
(
i
).
clear
();
outputWS
->
getEventList
(
i
).
clear
();
...
@@ -501,6 +514,7 @@ void ConvertUnits::convertViaTOF(const int& numberOfSpectra, Kernel::Unit_const_
...
@@ -501,6 +514,7 @@ void ConvertUnits::convertViaTOF(const int& numberOfSpectra, Kernel::Unit_const_
// Not doing anything with the Y vector in to/fromTOF yet, so just pass empty vector
// Not doing anything with the Y vector in to/fromTOF yet, so just pass empty vector
std
::
vector
<
double
>
emptyVec
;
std
::
vector
<
double
>
emptyVec
;
const
bool
needEfixed
=
(
outputUnit
->
unitID
().
find
(
"DeltaE"
)
!=
std
::
string
::
npos
);
double
efixedProp
=
getProperty
(
"Efixed"
);
double
efixedProp
=
getProperty
(
"Efixed"
);
if
(
emode
==
1
)
if
(
emode
==
1
)
{
{
...
@@ -516,7 +530,14 @@ void ConvertUnits::convertViaTOF(const int& numberOfSpectra, Kernel::Unit_const_
...
@@ -516,7 +530,14 @@ void ConvertUnits::convertViaTOF(const int& numberOfSpectra, Kernel::Unit_const_
}
}
else
else
{
{
if
(
needEfixed
)
{
throw
std
::
invalid_argument
(
"Could not retrieve incident energy from run object"
);
throw
std
::
invalid_argument
(
"Could not retrieve incident energy from run object"
);
}
else
{
efixedProp
=
0.0
;
}
}
}
}
}
else
else
...
@@ -573,7 +594,7 @@ void ConvertUnits::convertViaTOF(const int& numberOfSpectra, Kernel::Unit_const_
...
@@ -573,7 +594,7 @@ void ConvertUnits::convertViaTOF(const int& numberOfSpectra, Kernel::Unit_const_
l2
=
l2
-
l1
;
l2
=
l2
-
l1
;
twoTheta
=
0.0
;
twoTheta
=
0.0
;
// Energy transfer is meaningless for a monitor, so set l2 to 0.
// Energy transfer is meaningless for a monitor, so set l2 to 0.
if
(
outputUnit
->
unitID
().
find
(
"Delta"
)
==
0
)
if
(
needEfixed
)
{
{
l2
=
0.0
;
l2
=
0.0
;
efixed
=
DBL_MIN
;
efixed
=
DBL_MIN
;
...
...
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