-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log averaging muon analysis #18439
Log averaging muon analysis #18439
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The general form of the changes here is good. The variable names are nice and it is readable.
I think we're possibly over commenting a little bit and when comments are added they should be on the lines preceding the code and not at the end or this leads to logs of whitespace and oddly formatted lines. For example it's not necessary to comment on every line about what is intended. The comments will become out of date and we want readers to focus on the code.
I will edit the comments this afternoon and recommit it. |
const std::vector<Property *> &logData = ws->run().getLogData(); | ||
|
||
const TimeSeriesProperty<bool> *runningLog; // defined here to keep the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should always initialize variables to some known value. This is not guaranteed to be a nullptr so we should make it one:
const TimeSeriesProperty<bool> *runningLog(nullptr);
// applicable it is assigned a | ||
// value within an if statement. | ||
|
||
std::string running = "running"; // define the running log via a string to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest making this a static string constant at the top of the file to avoid repeated evaluations: Placing
const std::string RUNNING_LOG_NAME = "running"
in an anonymous namespace at the top of the file will achieve this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean like this:
namespace{
const std::string running = "running";
namespace MantidQt {
....code
}//close namespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nearly, except the anonymous namespace should be closed straight after the string is defined:
namespace{
const std::string RUNNING_LOG_NAME = "running";
} // end anonymous
I have upper cased the variable name to follow the convention of static constants being defined this way.
nullptr; // defined here to keep the object in scope. If applicable | ||
// it is assigned a value within an if statement. | ||
|
||
bool foundRunning = ws->run().hasProperty( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can make this const
@AnthonyLim23 I've added a few other minor comments but the method is sound. |
thank you. I will implement them this afternoon |
updated, that should be all of the changes you suggested. It still works for me. |
@@ -25,7 +25,9 @@ | |||
#include <QMessageBox> | |||
|
|||
#include <algorithm> | |||
|
|||
namespace { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to be picky but can we have a new line between the #include
& namespace
and also between the closing }
and the start of namespace MantidQt
.
Also, please use uppercase letters for static constants - I would suggest renaming running
to RUNNING_LOG_NAME
.
Mantid::Kernel::Logger g_log("MuonAnalysisResultTableTab"); | ||
g_log.warning( | ||
"No running log found. Filtering will not be applied to the data.\n"); | ||
} | ||
for (const auto prop : logData) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this isn't something you have changed but I would suggest adding a &
qualifier to the for
loop. It's only copying a pointer but I think it's good practice to avoid copies where possible:
for (const auto &prop : logData)
Updated the code |
The code changes look good now. I've tested the functionality and the results table is now consistent with applying the necessary running/status filters. Good to go. |
Within the muon analysis code the time averaging was incorrect. It has been altered to use the timeAverageValue function and if the running log is present then it is filtered accordingly.
To test: If the new time averaging is correct
Select: Interfaces -> Muon ->Muon Analysis and a new window should open.
Load some muon data (e.g. HIFI108376.nxs).
Click the Data Analysis tab.
Under functions right click and select "add function". In the new box select Background then LinearBackground.
Click the Fit button and select Fit from the options.
Click the Results Table tab.
Select the values that you want to investigate (I have found ICP_SYS_TD to be good).
Click Create Table.
To create the comparison data right click on MuonAnalysis in the workspaces and select Sample Logs...
A window should appear. Select the value that is being investigated.
The Time Avg: box should contain the same number as the results table.
It is worth checking that the results are different between Status + Period and None. The results should match Status + Period (which is the same as Status) if the running log is present.
Fixes #18061.
Release notes: see here
Reviewer
Please comment on the following (full description):
Code Review
Functional Tests
Do changes function as described? Add comments below that describe the tests performed?
How do the changes handle unexpected situations, e.g. bad input?
Has the relevant documentation been added/updated?
Is user-facing documentation written in a user-friendly manner?
Has developer documentation been updated if required?
Does everything look good? Comment with the ship it emoji but don't merge. A member of
@mantidproject/gatekeepers
will take care of it.