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
bc81b4b2
Commit
bc81b4b2
authored
7 years ago
by
Antti Soininen
Browse files
Options
Downloads
Patches
Plain Diff
Add validateInputs(), fix problem with workspaces not in the ADS.
Re #20540
parent
adcff5ba
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Framework/Algorithms/inc/MantidAlgorithms/NormaliseToMonitor.h
+1
-0
1 addition, 0 deletions
...work/Algorithms/inc/MantidAlgorithms/NormaliseToMonitor.h
Framework/Algorithms/src/NormaliseToMonitor.cpp
+27
-8
27 additions, 8 deletions
Framework/Algorithms/src/NormaliseToMonitor.cpp
with
28 additions
and
8 deletions
Framework/Algorithms/inc/MantidAlgorithms/NormaliseToMonitor.h
+
1
−
0
View file @
bc81b4b2
...
@@ -97,6 +97,7 @@ private:
...
@@ -97,6 +97,7 @@ private:
// Overridden Algorithm methods
// Overridden Algorithm methods
void
init
()
override
;
void
init
()
override
;
void
exec
()
override
;
void
exec
()
override
;
std
::
map
<
std
::
string
,
std
::
string
>
validateInputs
()
override
;
protected
:
// for testing
protected
:
// for testing
void
checkProperties
(
const
API
::
MatrixWorkspace_sptr
&
inputWorkspace
);
void
checkProperties
(
const
API
::
MatrixWorkspace_sptr
&
inputWorkspace
);
...
...
This diff is collapsed.
Click to expand it.
Framework/Algorithms/src/NormaliseToMonitor.cpp
+
27
−
8
View file @
bc81b4b2
...
@@ -283,6 +283,31 @@ void NormaliseToMonitor::exec() {
...
@@ -283,6 +283,31 @@ void NormaliseToMonitor::exec() {
}
}
}
}
/** Validates input properties.
* @return A map of input properties as keys and (error) messages as values.
*/
std
::
map
<
std
::
string
,
std
::
string
>
NormaliseToMonitor
::
validateInputs
()
{
std
::
map
<
std
::
string
,
std
::
string
>
issues
;
// Check where the monitor spectrum should come from
Property
*
monSpec
=
getProperty
(
"MonitorSpectrum"
);
Property
*
monID
=
getProperty
(
"MonitorID"
);
// Is the monitor spectrum within the main input workspace
const
bool
inWS
=
!
monSpec
->
isDefault
();
// Or is it in a separate workspace
MatrixWorkspace_sptr
monWS
=
getProperty
(
"MonitorWorkspace"
);
// or monitor ID
bool
monIDs
=
!
monID
->
isDefault
();
// something has to be set
if
(
!
inWS
&&
!
monWS
&&
!
monIDs
)
{
const
std
::
string
mess
(
"Either MonitorSpectrum, MonitorID or "
"MonitorWorkspace has to be provided."
);
issues
[
"MonitorSpectrum"
]
=
mess
;
issues
[
"MonitorID"
]
=
mess
;
issues
[
"MonitorWorkspace"
]
=
mess
;
}
return
issues
;
}
/** Makes sure that the input properties are set correctly
/** Makes sure that the input properties are set correctly
* @param inputWorkspace The input workspace
* @param inputWorkspace The input workspace
* @throw std::runtime_error If the properties are invalid
* @throw std::runtime_error If the properties are invalid
...
@@ -292,21 +317,15 @@ void NormaliseToMonitor::checkProperties(
...
@@ -292,21 +317,15 @@ void NormaliseToMonitor::checkProperties(
// Check where the monitor spectrum should come from
// Check where the monitor spectrum should come from
Property
*
monSpec
=
getProperty
(
"MonitorSpectrum"
);
Property
*
monSpec
=
getProperty
(
"MonitorSpectrum"
);
Property
*
monWS
=
getProperty
(
"MonitorWorkspace"
);
MatrixWorkspace_sptr
monWS
=
getProperty
(
"MonitorWorkspace"
);
Property
*
monID
=
getProperty
(
"MonitorID"
);
Property
*
monID
=
getProperty
(
"MonitorID"
);
// Is the monitor spectrum within the main input workspace
// Is the monitor spectrum within the main input workspace
const
bool
inWS
=
!
monSpec
->
isDefault
();
const
bool
inWS
=
!
monSpec
->
isDefault
();
// Or is it in a separate workspace
// Or is it in a separate workspace
bool
sepWS
=
!
monWS
->
isDefault
()
;
bool
sepWS
{
monWS
}
;
// or monitor ID
// or monitor ID
bool
monIDs
=
!
monID
->
isDefault
();
bool
monIDs
=
!
monID
->
isDefault
();
// something has to be set
// something has to be set
if
(
!
inWS
&&
!
sepWS
&&
!
monIDs
)
{
const
std
::
string
mess
(
"Neither the MonitorSpectrum, nor the MonitorID or "
"the MonitorWorkspace property has been set"
);
g_log
.
error
()
<<
mess
<<
'\n'
;
throw
std
::
runtime_error
(
mess
);
}
// One and only one of these properties should have been set
// One and only one of these properties should have been set
// input from separate workspace is overwritten by monitor spectrum
// input from separate workspace is overwritten by monitor spectrum
if
(
inWS
&&
sepWS
)
{
if
(
inWS
&&
sepWS
)
{
...
...
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