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
Add Logarithmic event grouping to CompressEvents #37203
Add Logarithmic event grouping to CompressEvents #37203
Conversation
pre-commit.ci run |
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.
This does the job, but I think it could be reduce duplicate code it used a function pointer to calculate the upper bound for the current group of events being accumulated. For log binning
double [tolerance](const double lastTof){ return lastTof * (1 - tolerance); }
and for linear binning
double [tolerance](const double lastTof{ return lastTof + tolerance; }
with an analogous variant for the fat events. Using a function pointer would also make it much more obvious to future developers that it is only the right boundary that is different between the two branches.
It's not that simple, the comparator is also different, linear is using Finding the next bin_end is also more complicated for log binning. But I have it all working now with less code duplication. So take another look. |
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.
There is an infinite loop hiding in this, when the first event has time-of-flight is zero. This should only be valid for positive time-of-flight. My suggestion is that (for log compression) if the smallest "tof" is negative, throw an exception, if it is zero, move the smallest to be fabs(tolerance)
.
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.
Looks good to go. I like the extra test.
Description of work
Summary of work
SNAPRed would like to intelligently use
CompressEvents
where the criteria for Time-of-flight compression follows the logarithmic mode used for histogramming TOF/d-spacing. This allows the retention of progressively finer compression tolerance at low times-of-flight, where Bragg peaks are sharper. This should be done in a way that is consistent with the existing output of the histogram representation of the output ofRebin
. When possible, parameters should mimic the analogous versions in Rebin. This requires one additional parameter "BinningMode" with the possible values of "Linear" (the default) and "Logarithmic" (the new mode).For a single spectrum with a minimum TOF=TOFmin, the following two workspaces are expected to give the same y-values in the histogram representation
Fixes EWM3030
Further detail of work
To test:
Reviewer
Please comment on the points listed below (full description).
Your comments will be used as part of the gatekeeper process, so please comment clearly on what you have checked during your review. If changes are made to the PR during the review process then your final comment will be the most important for gatekeepers. In this comment you should make it clear why any earlier review is still valid, or confirm that all requested changes have been addressed.
Code Review
Functional Tests
Does everything look good? Mark the review as Approve. A member of
@mantidproject/gatekeepers
will take care of it.Gatekeeper
If you need to request changes to a PR then please add a comment and set the review status to "Request changes". This will stop the PR from showing up in the list for other gatekeepers.