-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[hist] Improve limits of THLimitsFinder. #19605
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
base: master
Are you sure you want to change the base?
Conversation
Test Results 21 files 21 suites 3d 12h 18m 41s ⏱️ For more details on these failures, see this check. Results for commit 99a5fe0. ♻️ This comment has been updated with latest results. |
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.
LGTM thanks!
I would propose this test:
TTree t;
Float_t x;
t.Branch("x", &x);
x = -999;
t.Fill();
x = 0;
t.Fill();
t.Draw("x");
auto h = (TH1*)gROOT->FindObject("htemp");
ASSERT_EQ(h->GetEntries(), h->GetEffectiveEntries());
@ferdymercury good test! It's added now. |
7c66106
to
18f560e
Compare
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.
Thanks! Just a nitpick at the end of DrawAutoBinning:
delete h;
delete gROOT->FindObject("c1");
18f560e
to
e48467f
Compare
👍, updated for h. The canvas isn't created in batch mode, though, so that should be be unnecessary in this test. |
Are you sure?
|
The test failures for the graphics are real. This will require more investigation. |
hist/hist/src/THLimitsFinder.cxx
Outdated
if (al - BinLow >= atest && al < BinLow + BinWidth) { | ||
// Suppress the first bin, but only if al doesn't fall into it | ||
BinLow += BinWidth; | ||
nbins--; | ||
} | ||
if (BinHigh - ah >= atest && BinHigh - BinWidth > ah) { | ||
// Suppress the last bin, but only if ah doesn't fall into it | ||
BinHigh -= BinWidth; | ||
nbins--; | ||
} |
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.
Shouldn't it be al > BinLow + BinWidth
? instead of <
?
Or maybe even easier:
if (al - BinLow >= atest && al < BinLow + BinWidth) { | |
// Suppress the first bin, but only if al doesn't fall into it | |
BinLow += BinWidth; | |
nbins--; | |
} | |
if (BinHigh - ah >= atest && BinHigh - BinWidth > ah) { | |
// Suppress the last bin, but only if ah doesn't fall into it | |
BinHigh -= BinWidth; | |
nbins--; | |
} | |
if (al >= BinLow + BinWidth + atest) { | |
// Suppress the first bin, but only if al doesn't fall into it | |
BinLow += BinWidth; | |
nbins--; | |
} | |
if (ah <= BinHigh - BinWidth - atest) { | |
// Suppress the last bin, but only if ah doesn't fall into it | |
BinHigh -= BinWidth; | |
nbins--; | |
} |
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.
Yes, indeed.
But looking at this logic again, it's clear that it may truncate the axis range, so one shouldn't use it. At the same time, I cannot remove it (I tested), because this breaks the "looks" of other graphics components.
I think I now found a solution that works. It's already pushed.
f81d9b6
to
6397529
Compare
During the merge of histograms with automatic axis ranges, the axis range was computed when the default fill buffer overflows. In this case, this was halfway during the merge. The resulting histogram was compared to one whose axis range was computed on the full statistics, leading to slightly different axes. By chance, the differences were within the tolerance, but due to the axis range being extended slightly in the next commit, the test started failing. To avoid this, the buffer of the first histogram to be merged is like for the others in this test, ensuring that all histograms compute their axes on the same events.
- When asking THLimitsFinder to optimise axis limits, ask for a maximum slightly right of the actual maximum of the distribution. Otherwise, since the maximum may coincide with the maximum of the axis range, values may fall into the overflow. - Use std::min / std::max to ensure that OptimizeLimits never drops a value. This fixes the problem observed in https://root-forum.cern.ch/t/bug-or-feature-in-ttree-draw/62862
THLimitFinder tries to trim empty bins close to the end of an axis range, but sometimes, the min/max was trimmed as well, so not all data would be visible in the histogram. Here, the case from the following post is tested: https://root-forum.cern.ch/t/bug-or-feature-in-ttree-draw/ Co-authored-by: ferdymercury <[email protected]>
6397529
to
1a81a93
Compare
THLimitsFinder sometimes removes the first/last bin of an axis range. Here, it is ensured that the min and max of a buffered range is part of the axis range, and not removed by accident.
This fixes issues with TTree::Draw such as the one described in https://root-forum.cern.ch/t/bug-or-feature-in-ttree-draw/62862/
This supersedes #17689