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
fca79c49
Commit
fca79c49
authored
Mar 02, 2017
by
Samuel Jackson
Browse files
Refs #18920 Fix issues from code review
parent
e4923b8a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Framework/Crystal/inc/MantidCrystal/PredictPeaks.h
View file @
fca79c49
...
...
@@ -63,6 +63,8 @@ private:
const
Kernel
::
DblMatrix
&
goniometerMatrix
);
private:
void
logNumberOfPeaksFound
(
size_t
allowedPeakCount
)
const
;
/// Reflection conditions possible
std
::
vector
<
Mantid
::
Geometry
::
ReflectionCondition_sptr
>
m_refConds
;
...
...
Framework/Crystal/src/PredictPeaks.cpp
View file @
fca79c49
...
...
@@ -102,10 +102,6 @@ void PredictPeaks::init() {
"checked.
\n
"
"Keep unchecked to use the original values"
);
declareProperty
(
"PredictPeaksOutsideDetectors"
,
false
,
"Use an extended detector space (if defined for the"
" instrument) to predict peaks which do not fall onto any"
"detector. This may produce a very high number of results."
);
setPropertySettings
(
"RoundHKL"
,
make_unique
<
EnabledWhenProperty
>
(
"HKLPeaksWorkspace"
,
IS_NOT_DEFAULT
));
...
...
@@ -125,6 +121,11 @@ void PredictPeaks::init() {
declareProperty
(
make_unique
<
WorkspaceProperty
<
PeaksWorkspace
>>
(
"OutputWorkspace"
,
""
,
Direction
::
Output
),
"An output PeaksWorkspace."
);
declareProperty
(
"PredictPeaksOutsideDetectors"
,
false
,
"Use an extended detector space (if defined for the"
" instrument) to predict peaks which do not fall onto any"
"detector. This may produce a very high number of results."
);
}
/** Execute the algorithm.
...
...
@@ -261,7 +262,7 @@ void PredictPeaks::exec() {
bool
useExtendedDetectorSpace
=
getProperty
(
"PredictPeaksOutsideDetectors"
);
if
(
useExtendedDetectorSpace
&&
!
m_inst
->
getComponentByName
(
"extended-detector-space"
))
{
g_log
.
warning
()
<<
"Attempting to find peaks outside of detectors but"
g_log
.
warning
()
<<
"Attempting to find peaks outside of detectors but
"
"no extended detector space has been defined"
;
}
...
...
@@ -273,15 +274,44 @@ void PredictPeaks::exec() {
prog
.
report
();
}
g_log
.
notice
()
<<
"Out of "
<<
allowedPeakCount
<<
" allowed peaks within parameters, "
<<
m_pw
->
getNumberPeaks
()
<<
" were found to hit a detector.
\n
"
;
logNumberOfPeaksFound
(
allowedPeakCount
);
}
setProperty
<
PeaksWorkspace_sptr
>
(
"OutputWorkspace"
,
m_pw
);
}
/**
* Log the number of peaks found to fall on and off detectors
*
* @param allowedPeakCount :: number of candidate peaks found
*/
void
PredictPeaks
::
logNumberOfPeaksFound
(
size_t
allowedPeakCount
)
const
{
const
bool
usingExtendedDetectorSpace
=
getProperty
(
"PredictPeaksOutsideDetectors"
);
const
auto
&
peaks
=
m_pw
->
getPeaks
();
size_t
offDetectorPeakCount
=
0
;
size_t
onDetectorPeakCount
=
0
;
for
(
const
auto
&
peak
:
peaks
)
{
if
(
peak
.
getDetectorID
()
==
-
1
)
{
offDetectorPeakCount
++
;
}
else
{
onDetectorPeakCount
++
;
}
}
g_log
.
notice
()
<<
"Out of "
<<
allowedPeakCount
<<
" allowed peaks within parameters, "
<<
onDetectorPeakCount
<<
" were found to hit a detector "
;
if
(
usingExtendedDetectorSpace
)
{
g_log
.
notice
()
<<
" and "
<<
offDetectorPeakCount
<<
" were found in "
<<
"extended detector space."
;
}
g_log
.
notice
()
<<
"
\n
"
;
}
/// Tries to set the internally stored instrument from an ExperimentInfo-object.
void
PredictPeaks
::
setInstrumentFromInputWorkspace
(
const
ExperimentInfo_sptr
&
inWS
)
{
...
...
Framework/DataObjects/test/PeakTest.h
View file @
fca79c49
...
...
@@ -381,10 +381,10 @@ public:
ComponentCreationHelper
::
createTestInstrumentRectangular
(
5
,
100
);
auto
extendedSpaceObj
=
ComponentCreationHelper
::
createSphere
(
10.
,
V3D
(
0
,
0
,
0
));
auto
extendedSpace
=
new
ObjComponent
(
"extended-detector-space"
,
extendedSpaceObj
,
sphereInst
.
get
());
auto
extendedSpace
=
std
::
make_unique
<
ObjComponent
>
(
"extended-detector-space"
,
extendedSpaceObj
,
sphereInst
.
get
());
extendedSpace
->
setPos
(
V3D
(
0.0
,
0.0
,
0.0
));
sphereInst
->
add
(
extendedSpace
);
sphereInst
->
add
(
extendedSpace
.
release
()
);
const
auto
refFrame
=
sphereInst
->
getReferenceFrame
();
const
auto
refBeamDir
=
refFrame
->
vecPointingAlongBeam
();
...
...
@@ -458,10 +458,10 @@ public:
ComponentCreationHelper
::
createTestInstrumentRectangular
(
5
,
100
);
auto
extendedSpaceObj
=
ComponentCreationHelper
::
createSphere
(
10.
,
V3D
(
0
,
0
,
0
));
auto
extendedSpace
=
new
ObjComponent
(
"extended-detector-space"
,
extendedSpaceObj
,
sphereInst
.
get
());
auto
extendedSpace
=
std
::
make_unique
<
ObjComponent
>
(
"extended-detector-space"
,
extendedSpaceObj
,
sphereInst
.
get
());
extendedSpace
->
setPos
(
V3D
(
0.0
,
0.0
,
0.0
));
sphereInst
->
add
(
extendedSpace
);
sphereInst
->
add
(
extendedSpace
.
release
()
);
// test with & without extended detector space
// extended space is a sphere, so all points should fall radius*detector
...
...
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