-
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 8h 58m 31s ⏱️ For more details on these failures, see this check. Results for commit e48467f. ♻️ 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. |
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/
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");
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/
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. |
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--; | |
} |
auto h = (TH1 *)gROOT->FindObject("htemp"); | ||
ASSERT_NE(h, nullptr); | ||
EXPECT_EQ(h->GetEntries(), h->GetEffectiveEntries()); | ||
delete h; |
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.
delete h; | |
delete h; | |
delete gROOT->FindObject("c1"); |
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