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
a0455df5
Commit
a0455df5
authored
Aug 30, 2017
by
Lynch, Vickie
Browse files
Refs #20355 check all edges; rewrite removePeaks
parent
7ae3cf94
Changes
3
Hide whitespace changes
Inline
Side-by-side
Framework/Crystal/inc/MantidCrystal/CentroidPeaks.h
View file @
a0455df5
...
...
@@ -39,6 +39,7 @@ private:
void
integrateEvent
();
int
findPixelID
(
std
::
string
bankName
,
int
col
,
int
row
);
void
removeEdgePeaks
(
Mantid
::
DataObjects
::
PeaksWorkspace
&
peakWS
);
void
sizeBanks
(
std
::
string
bankName
,
int
&
nCols
,
int
&
nRows
);
Geometry
::
Instrument_const_sptr
inst
;
/// Input 2D Workspace
...
...
Framework/Crystal/src/CentroidPeaks.cpp
View file @
a0455df5
...
...
@@ -106,6 +106,8 @@ void CentroidPeaks::integrate() {
const
auto
&
X
=
inWS
->
x
(
workspaceIndex
);
int
chan
=
Kernel
::
VectorHelper
::
getBinIndex
(
X
.
rawData
(),
TOFPeakd
);
std
::
string
bankName
=
peak
.
getBankName
();
int
nCols
=
0
,
nRows
=
0
;
sizeBanks
(
bankName
,
nCols
,
nRows
);
double
intensity
=
0.0
;
double
chancentroid
=
0.0
;
...
...
@@ -114,10 +116,10 @@ void CentroidPeaks::integrate() {
int
chanend
=
std
::
min
(
static_cast
<
int
>
(
X
.
size
()),
chan
+
PeakRadius
);
double
rowcentroid
=
0.0
;
int
rowstart
=
std
::
max
(
0
,
row
-
PeakRadius
);
int
rowend
=
row
+
PeakRadius
;
int
rowend
=
std
::
min
(
nRows
-
1
,
row
+
PeakRadius
)
;
double
colcentroid
=
0.0
;
int
colstart
=
col
-
PeakRadius
;
int
colend
=
col
+
PeakRadius
;
int
colstart
=
std
::
max
(
0
,
col
-
PeakRadius
)
;
int
colend
=
std
::
min
(
nCols
-
1
,
col
+
PeakRadius
)
;
for
(
int
ichan
=
chanstart
;
ichan
<=
chanend
;
++
ichan
)
{
for
(
int
irow
=
rowstart
;
irow
<=
rowend
;
++
irow
)
{
for
(
int
icol
=
colstart
;
icol
<=
colend
;
++
icol
)
{
...
...
@@ -141,15 +143,17 @@ void CentroidPeaks::integrate() {
// Set pixelID to change row and col
row
=
int
(
rowcentroid
/
intensity
);
row
=
std
::
max
(
0
,
row
);
row
=
std
::
min
(
nRows
-
1
,
row
);
col
=
int
(
colcentroid
/
intensity
);
col
=
std
::
max
(
0
,
col
);
col
=
std
::
min
(
nCols
-
1
,
col
);
chan
=
int
(
chancentroid
/
intensity
);
chan
=
std
::
max
(
0
,
chan
);
chan
=
std
::
min
(
static_cast
<
int
>
(
inWS
->
blocksize
()),
chan
);
peak
.
setDetectorID
(
findPixelID
(
bankName
,
col
,
row
));
// Set wavelength to change tof for peak object
if
(
!
edgePixel
(
inst
,
bankName
,
col
,
row
,
Edge
))
{
peak
.
setDetectorID
(
findPixelID
(
bankName
,
col
,
row
));
it
=
wi_to_detid_map
.
find
(
findPixelID
(
bankName
,
col
,
row
));
workspaceIndex
=
(
it
->
second
);
Mantid
::
Kernel
::
Units
::
Wavelength
wl
;
...
...
@@ -224,6 +228,8 @@ void CentroidPeaks::integrateEvent() {
int
row
=
peak
.
getRow
();
double
TOFPeakd
=
peak
.
getTOF
();
std
::
string
bankName
=
peak
.
getBankName
();
int
nCols
=
0
,
nRows
=
0
;
sizeBanks
(
bankName
,
nCols
,
nRows
);
double
intensity
=
0.0
;
double
tofcentroid
=
0.0
;
...
...
@@ -234,10 +240,10 @@ void CentroidPeaks::integrateEvent() {
double
tofend
=
TOFPeakd
*
std
::
pow
(
1.004
,
PeakRadius
);
double
rowcentroid
=
0.0
;
int
rowstart
=
std
::
max
(
0
,
row
-
PeakRadius
);
int
rowend
=
row
+
PeakRadius
;
int
rowend
=
std
::
min
(
nRows
-
1
,
row
+
PeakRadius
)
;
double
colcentroid
=
0.0
;
int
colstart
=
std
::
max
(
0
,
col
-
PeakRadius
);
int
colend
=
col
+
PeakRadius
;
int
colend
=
std
::
min
(
nCols
-
1
,
col
+
PeakRadius
)
;
for
(
int
irow
=
rowstart
;
irow
<=
rowend
;
++
irow
)
{
for
(
int
icol
=
colstart
;
icol
<=
colend
;
++
icol
)
{
if
(
edgePixel
(
inst
,
bankName
,
icol
,
irow
,
Edge
))
...
...
@@ -264,8 +270,10 @@ void CentroidPeaks::integrateEvent() {
// Set pixelID to change row and col
row
=
int
(
rowcentroid
/
intensity
);
row
=
std
::
max
(
0
,
row
);
row
=
std
::
min
(
nRows
-
1
,
row
);
col
=
int
(
colcentroid
/
intensity
);
col
=
std
::
max
(
0
,
col
);
col
=
std
::
min
(
nCols
-
1
,
col
);
if
(
!
edgePixel
(
inst
,
bankName
,
col
,
row
,
Edge
))
{
peak
.
setDetectorID
(
findPixelID
(
bankName
,
col
,
row
));
...
...
@@ -340,7 +348,7 @@ void CentroidPeaks::removeEdgePeaks(
Mantid
::
DataObjects
::
PeaksWorkspace
&
peakWS
)
{
int
Edge
=
getProperty
(
"EdgePixels"
);
std
::
vector
<
int
>
badPeaks
;
size_t
numPeaks
=
peakWS
.
getNumberPeaks
()
-
1
;
size_t
numPeaks
=
peakWS
.
getNumberPeaks
();
for
(
int
i
=
0
;
i
<
static_cast
<
int
>
(
numPeaks
);
i
++
)
{
// Get a direct ref to that peak.
const
auto
&
peak
=
peakWS
.
getPeak
(
i
);
...
...
@@ -355,5 +363,33 @@ void CentroidPeaks::removeEdgePeaks(
peakWS
.
removePeaks
(
std
::
move
(
badPeaks
));
}
void
CentroidPeaks
::
sizeBanks
(
std
::
string
bankName
,
int
&
nCols
,
int
&
nRows
)
{
if
(
bankName
==
"None"
)
return
;
boost
::
shared_ptr
<
const
IComponent
>
parent
=
inst
->
getComponentByName
(
bankName
);
if
(
!
parent
)
return
;
if
(
parent
->
type
()
==
"RectangularDetector"
)
{
boost
::
shared_ptr
<
const
RectangularDetector
>
RDet
=
boost
::
dynamic_pointer_cast
<
const
RectangularDetector
>
(
parent
);
nCols
=
RDet
->
xpixels
();
nRows
=
RDet
->
ypixels
();
}
else
{
std
::
vector
<
Geometry
::
IComponent_const_sptr
>
children
;
boost
::
shared_ptr
<
const
Geometry
::
ICompAssembly
>
asmb
=
boost
::
dynamic_pointer_cast
<
const
Geometry
::
ICompAssembly
>
(
parent
);
asmb
->
getChildren
(
children
,
false
);
boost
::
shared_ptr
<
const
Geometry
::
ICompAssembly
>
asmb2
=
boost
::
dynamic_pointer_cast
<
const
Geometry
::
ICompAssembly
>
(
children
[
0
]);
std
::
vector
<
Geometry
::
IComponent_const_sptr
>
grandchildren
;
asmb2
->
getChildren
(
grandchildren
,
false
);
nRows
=
static_cast
<
int
>
(
grandchildren
.
size
());
nCols
=
static_cast
<
int
>
(
children
.
size
());
}
}
}
// namespace Mantid
}
// namespace Crystal
Framework/DataObjects/src/PeaksWorkspace.cpp
View file @
a0455df5
...
...
@@ -157,19 +157,12 @@ void PeaksWorkspace::removePeaks(std::vector<int> badPeaks) {
if
(
badPeaks
.
empty
())
return
;
std
::
sort
(
badPeaks
.
begin
(),
badPeaks
.
end
());
auto
index
=
peaks
.
begin
();
auto
end
=
peaks
.
end
();
auto
result
=
index
;
for
(
int
i
=
0
;
index
<
end
;
++
index
,
++
i
)
{
// if index of peak is not in badPeaks
if
(
!
std
::
binary_search
(
badPeaks
.
begin
(),
badPeaks
.
end
(),
i
))
{
// include in result
*
result
=
std
::
move
(
*
index
);
++
result
;
for
(
int
i
=
static_cast
<
int
>
(
peaks
.
size
())
-
1
;
i
>=
0
;
i
--
)
{
// if index of peak is in badPeaks remove
if
(
std
::
binary_search
(
badPeaks
.
begin
(),
badPeaks
.
end
(),
i
))
{
removePeak
(
i
);
}
}
// erase peaks outside of result
peaks
.
erase
(
result
,
peaks
.
end
());
}
//---------------------------------------------------------------------------------------------
...
...
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