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
db05e187
Commit
db05e187
authored
Feb 26, 2021
by
Whitfield, Ross
Browse files
Change return value to NaN for things we can't calculate
parent
c414caa1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Framework/DataObjects/src/LeanPeak.cpp
View file @
db05e187
...
...
@@ -177,9 +177,7 @@ void LeanPeak::setDetectorID([[maybe_unused]] int id) {
//----------------------------------------------------------------------------------------------
/** Get the ID of the detector at the center of the peak */
int
LeanPeak
::
getDetectorID
()
const
{
throw
std
::
runtime_error
(
"LeanPeak::getDetectorID(): Has no detector ID"
);
}
int
LeanPeak
::
getDetectorID
()
const
{
return
-
1
;
}
//----------------------------------------------------------------------------------------------
/** Set the instrument (and save the source/sample pos).
...
...
@@ -224,25 +222,25 @@ double LeanPeak::getWavelength() const {
/** Calculate the time of flight (in microseconds) of the neutrons for this
* peak,
* using the geometry of the detector */
double
LeanPeak
::
getTOF
()
const
{
throw
std
::
runtime_error
(
"not implemented"
);
}
double
LeanPeak
::
getTOF
()
const
{
return
std
::
numeric_limits
<
double
>::
quiet_NaN
();
}
// -------------------------------------------------------------------------------------
/** Calculate the scattering angle of the peak */
double
LeanPeak
::
getScattering
()
const
{
throw
std
::
runtime_error
(
"not implemented"
)
;
return
asin
(
getWavelength
()
/
(
2
*
getDSpacing
()))
*
2
;
}
// -------------------------------------------------------------------------------------
/** Calculate the azimuthal angle of the peak */
double
LeanPeak
::
getAzimuthal
()
const
{
throw
std
::
runtime_error
(
"not implemented"
);
return
std
::
numeric_limits
<
double
>::
quiet_NaN
(
);
}
// -------------------------------------------------------------------------------------
/** Calculate the d-spacing of the peak, in 1/Angstroms */
double
LeanPeak
::
getDSpacing
()
const
{
throw
std
::
runtime_error
(
"not implemented"
);
}
double
LeanPeak
::
getDSpacing
()
const
{
return
2
*
M_PI
/
m_Qsample
.
norm
();
}
//----------------------------------------------------------------------------------------------
/** Return the Q change (of the lattice, k_i - k_f) for this peak.
...
...
@@ -548,11 +546,15 @@ Mantid::Kernel::V3D LeanPeak::getSamplePos() const {
// -------------------------------------------------------------------------------------
/** Return the L1 flight path length (source to sample), in meters. */
double
LeanPeak
::
getL1
()
const
{
throw
std
::
runtime_error
(
"not implemented"
);
}
double
LeanPeak
::
getL1
()
const
{
return
std
::
numeric_limits
<
double
>::
quiet_NaN
();
}
// -------------------------------------------------------------------------------------
/** Return the L2 flight path length (sample to detector), in meters. */
double
LeanPeak
::
getL2
()
const
{
throw
std
::
runtime_error
(
"not implemented"
);
}
double
LeanPeak
::
getL2
()
const
{
return
std
::
numeric_limits
<
double
>::
quiet_NaN
();
}
// -------------------------------------------------------------------------------------
/** Helper function for displaying/sorting peaks
...
...
Framework/DataObjects/test/LeanPeakTest.h
View file @
db05e187
...
...
@@ -33,19 +33,19 @@ public:
TS_ASSERT_EQUALS
(
p
.
getQSampleFrame
(),
V3D
(
0
,
0
,
0
))
TS_ASSERT_EQUALS
(
p
.
getQLabFrame
(),
V3D
())
TS_ASSERT_
THROW
S
(
p
.
getDetectorID
(),
const
std
::
runtime_error
&
)
TS_ASSERT_
EQUAL
S
(
p
.
getDetectorID
(),
-
1
)
TS_ASSERT_THROWS
(
p
.
getDetector
(),
const
std
::
runtime_error
&
)
TS_ASSERT_THROWS
(
p
.
getInstrument
(),
const
std
::
runtime_error
&
)
TS_ASSERT_THROWS
(
p
.
findDetector
(),
const
std
::
runtime_error
&
)
TS_ASSERT_THROWS
(
p
.
getDetectorPosition
(),
const
std
::
runtime_error
&
)
TS_ASSERT_THROWS
(
p
.
getDetectorPositionNoCheck
(),
const
std
::
runtime_error
&
)
TS_ASSERT_THROWS
(
p
.
getScattering
(),
const
std
::
runtime_error
&
)
TS_ASSERT_THROWS
(
p
.
getAzimuthal
(),
const
std
::
runtime_error
&
)
TS_ASSERT_THROWS
(
p
.
getTOF
(),
const
std
::
runtime_error
&
)
TS_ASSERT_THROWS
(
p
.
getDetPos
(),
const
std
::
runtime_error
&
)
TS_ASSERT_THROWS
(
p
.
getSamplePos
(),
const
std
::
runtime_error
&
)
TS_ASSERT_THROWS
(
p
.
getL1
(),
const
std
::
runtime_error
&
)
TS_ASSERT_THROWS
(
p
.
getL2
(),
const
std
::
runtime_error
&
)
TS_ASSERT
(
std
::
isnan
(
p
.
getTOF
()))
TS_ASSERT
(
std
::
isnan
(
p
.
getScattering
()))
TS_ASSERT
(
std
::
isnan
(
p
.
getAzimuthal
()))
TS_ASSERT
(
std
::
isnan
(
p
.
getL1
()))
TS_ASSERT
(
std
::
isnan
(
p
.
getL2
()))
}
void
test_Qsample_constructor
()
{
...
...
@@ -90,6 +90,8 @@ public:
TS_ASSERT_DELTA
(
p
.
getInitialEnergy
(),
81.8042024359
,
1e-5
)
TS_ASSERT_DELTA
(
p
.
getFinalEnergy
(),
81.8042024359
,
1e-5
)
TS_ASSERT_DELTA
(
p
.
getWavelength
(),
1.
,
1e-9
)
TS_ASSERT_DELTA
(
p
.
getDSpacing
(),
1.679251908362714
,
1e-9
)
TS_ASSERT_DELTA
(
p
.
getScattering
(),
0.6046731932
,
1e-9
)
}
void
test_Qsample_gon_wavelength_constructor
()
{
...
...
@@ -108,4 +110,19 @@ public:
TS_ASSERT_DELTA
(
p
.
getFinalEnergy
(),
81.8042024359
,
1e-5
)
TS_ASSERT_DELTA
(
p
.
getWavelength
(),
1.
,
1e-9
)
}
void
test_copyConstructor
()
{
// This goniometer should just swap x and y of q
Mantid
::
Kernel
::
Matrix
<
double
>
gon
(
3
,
3
);
gon
[
0
][
1
]
=
1
;
gon
[
1
][
0
]
=
1
;
gon
[
2
][
2
]
=
1
;
LeanPeak
p
(
V3D
(
1
,
2
,
3
),
gon
,
1.
);
// Default (not-explicit) copy constructor
LeanPeak
p2
(
p
);
TS_ASSERT_EQUALS
(
p
.
getQSampleFrame
(),
p2
.
getQSampleFrame
());
TS_ASSERT_EQUALS
(
p
.
getQLabFrame
(),
p2
.
getQLabFrame
());
TS_ASSERT_EQUALS
(
p
.
getGoniometerMatrix
(),
p2
.
getGoniometerMatrix
());
}
};
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