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
ad30b644
Commit
ad30b644
authored
6 years ago
by
Samuel Jones
Browse files
Options
Downloads
Patches
Plain Diff
Re #22896 Implement SortXAxis in Stitch1D
parent
98d01d0b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Framework/Algorithms/src/Stitch1D.cpp
+10
-26
10 additions, 26 deletions
Framework/Algorithms/src/Stitch1D.cpp
with
10 additions
and
26 deletions
Framework/Algorithms/src/Stitch1D.cpp
+
10
−
26
View file @
ad30b644
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include
"MantidAPI/MatrixWorkspace.h"
#include
"MantidAPI/MatrixWorkspace.h"
#include
"MantidAPI/WorkspaceProperty.h"
#include
"MantidAPI/WorkspaceProperty.h"
#include
"MantidAlgorithms/RunCombinationHelpers/RunCombinationHelper.h"
#include
"MantidAlgorithms/RunCombinationHelpers/RunCombinationHelper.h"
#include
"MantidAlgorithms/SortXAxis.h"
#include
"MantidHistogramData/HistogramDx.h"
#include
"MantidHistogramData/HistogramDx.h"
#include
"MantidHistogramData/HistogramE.h"
#include
"MantidHistogramData/HistogramE.h"
#include
"MantidHistogramData/HistogramX.h"
#include
"MantidHistogramData/HistogramX.h"
...
@@ -41,32 +42,11 @@ bool isNonzero(double i) { return (0 != i); }
...
@@ -41,32 +42,11 @@ bool isNonzero(double i) { return (0 != i); }
@return A shared pointer to the resulting MatrixWorkspace
@return A shared pointer to the resulting MatrixWorkspace
*/
*/
void
sortXAxis
(
MatrixWorkspace_sptr
&
ws
)
{
void
sortXAxis
(
MatrixWorkspace_sptr
&
ws
)
{
// using a std::multimap (keys are sorted)
Mantid
::
Algorithms
::
SortXAxis
alg
;
std
::
multimap
<
double
,
double
>
sorter
;
alg
.
initialize
();
double
x_value
;
alg
.
setProperty
(
"InputWorkspace"
,
ws
);
const
int
nHists
=
static_cast
<
int
>
(
ws
->
getNumberHistograms
());
alg
.
setProperty
(
"OutputWorkspace"
,
"outputSearch"
);
for
(
int
i
=
0
;
i
<
nHists
;
++
i
)
{
alg
.
execute
();
for
(
size_t
k
=
0
;
k
<
ws
->
size
();
++
k
)
{
x_value
=
ws
->
x
(
i
)[
k
];
sorter
.
insert
(
std
::
pair
<
double
,
double
>
(
x_value
,
ws
->
y
(
i
)[
k
]));
sorter
.
insert
(
std
::
pair
<
double
,
double
>
(
x_value
,
ws
->
e
(
i
)[
k
]));
// histograms: no recalculation of Dx implemented -> skip
if
(
ws
->
hasDx
(
i
)
&&
!
ws
->
isHistogramData
())
sorter
.
insert
(
std
::
pair
<
double
,
double
>
(
x_value
,
ws
->
dx
(
i
)[
k
]));
}
int
l
=
0
;
auto
it
=
sorter
.
cbegin
();
while
(
it
!=
sorter
.
cend
())
{
ws
->
mutableX
(
i
)[
l
]
=
it
->
first
;
ws
->
mutableY
(
i
)[
l
]
=
it
->
second
;
ws
->
mutableE
(
i
)[
l
]
=
(
++
it
)
->
second
;
// histograms: no recalculation of Dx implemented -> skip
if
(
ws
->
hasDx
(
i
)
&&
!
ws
->
isHistogramData
())
ws
->
mutableDx
(
i
)[
l
]
=
(
++
it
)
->
second
;
++
l
;
++
it
;
}
}
}
}
}
// namespace
}
// namespace
...
@@ -658,6 +638,10 @@ void Stitch1D::exec() {
...
@@ -658,6 +638,10 @@ void Stitch1D::exec() {
if
(
!
result
)
if
(
!
result
)
g_log
.
error
(
"Could not retrieve joined workspace."
);
g_log
.
error
(
"Could not retrieve joined workspace."
);
sortXAxis
(
result
);
sortXAxis
(
result
);
MatrixWorkspace_sptr
outputSearch
=
boost
::
dynamic_pointer_cast
<
MatrixWorkspace
>
(
AnalysisDataService
::
Instance
().
retrieve
(
"outputSearch"
));
result
=
outputSearch
;
}
}
setProperty
(
"OutputWorkspace"
,
result
);
setProperty
(
"OutputWorkspace"
,
result
);
setProperty
(
"OutScaleFactor"
,
m_scaleFactor
);
setProperty
(
"OutScaleFactor"
,
m_scaleFactor
);
...
...
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