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
9190342e
Commit
9190342e
authored
Sep 02, 2016
by
Simon Heybrock
Browse files
Re #17322. Added SpectrumInfo::hasUniqueDetector.
parent
5d67a621
Changes
3
Hide whitespace changes
Inline
Side-by-side
Framework/API/inc/MantidAPI/SpectrumInfo.h
View file @
9190342e
...
...
@@ -63,6 +63,7 @@ public:
double
l2
(
const
size_t
index
)
const
;
double
twoTheta
(
const
size_t
index
)
const
;
double
signedTwoTheta
(
const
size_t
index
)
const
;
bool
hasUniqueDetector
(
const
size_t
index
)
const
;
// This does not really belong into SpectrumInfo, but it seems to be useful
// while Instrument-2.0 does not exist.
...
...
Framework/API/src/SpectrumInfo.cpp
View file @
9190342e
...
...
@@ -79,6 +79,10 @@ double SpectrumInfo::signedTwoTheta(const size_t index) const {
.
getSignedTwoTheta
(
samplePos
,
beamLine
,
instrumentUpAxis
);
}
bool
SpectrumInfo
::
hasUniqueDetector
(
const
size_t
index
)
const
{
return
m_workspace
.
getSpectrum
(
index
).
getDetectorIDs
().
size
()
==
1
;
}
/// Returns L1 (distance from source to sample).
double
SpectrumInfo
::
l1
()
const
{
std
::
call_once
(
m_L1Cached
,
&
SpectrumInfo
::
cacheL1
,
this
);
...
...
Framework/Algorithms/src/GetEi.cpp
View file @
9190342e
#include
"MantidAlgorithms/GetEi.h"
#include
"MantidAPI/HistogramValidator.h"
#include
"MantidAPI/InstrumentValidator.h"
#include
"MantidAPI/SpectrumInfo.h"
#include
"MantidAPI/WorkspaceUnitValidator.h"
#include
"MantidGeometry/Instrument.h"
#include
"MantidKernel/Exception.h"
...
...
@@ -171,17 +172,17 @@ void GetEi::getGeometry(API::MatrixWorkspace_const_sptr WS, specnum_t mon0Spec,
g_log
.
error
()
<<
"Error retrieving data for the first monitor
\n
"
;
throw
std
::
bad_cast
();
}
const
auto
&
dets
=
WS
->
getSpectrum
(
monWI
).
getDetectorIDs
();
if
(
dets
.
size
()
!=
1
)
{
const
auto
&
spectrumInfo
=
WS
->
spectrumInfo
();
if
(
!
spectrumInfo
.
hasUniqueDetector
(
monWI
))
{
g_log
.
error
()
<<
"The detector for spectrum number "
<<
mon0Spec
<<
" was either not found or is a group, grouped monitors "
"are not supported by this algorithm
\n
"
;
g_log
.
error
()
<<
"Error retrieving data for the first monitor
\n
"
;
throw
std
::
bad_cast
();
}
IDetector_const_sptr
det
=
WS
->
getInstrument
()
->
getDetector
(
*
dets
.
begin
());
monitor0Dist
=
det
->
getDistance
(
*
(
source
.
get
()));
monitor0Dist
=
spectrumInfo
.
l1
()
+
spectrumInfo
.
l2
(
monWI
);
// repeat for the second detector
try
{
...
...
@@ -193,16 +194,14 @@ void GetEi::getGeometry(API::MatrixWorkspace_const_sptr WS, specnum_t mon0Spec,
g_log
.
error
()
<<
"Error retrieving data for the second monitor
\n
"
;
throw
std
::
bad_cast
();
}
const
auto
&
dets2
=
WS
->
getSpectrum
(
monWI
).
getDetectorIDs
();
if
(
dets2
.
size
()
!=
1
)
{
if
(
!
spectrumInfo
.
hasUniqueDetector
(
monWI
))
{
g_log
.
error
()
<<
"The detector for spectrum number "
<<
mon1Spec
<<
" was either not found or is a group, grouped monitors "
"are not supported by this algorithm
\n
"
;
g_log
.
error
()
<<
"Error retrieving data for the second monitor
\n
"
;
throw
std
::
bad_cast
();
}
det
=
WS
->
getInstrument
()
->
getDetector
(
*
dets2
.
begin
());
monitor1Dist
=
det
->
getDistance
(
*
(
source
.
get
()));
monitor1Dist
=
spectrumInfo
.
l1
()
+
spectrumInfo
.
l2
(
monWI
);
}
/** Converts detector IDs to spectra indexes
* @param WS :: the workspace on which the calculations are being performed
...
...
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