Skip to content

[hist] Using TKDE::Fill works with empty tkde #14740

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions hist/hist/src/TKDE.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,15 @@ void TKDE::InitFromNewData() {
if (fUseMirroring) {
SetMirroredEvents();
}
else {
// to set fBinCount and fSumOfCounts
SetBinCountData();
}
// in case of I/O reset the kernel
if (!fKernelFunction) SetKernelFunction(nullptr);

SetKernel();

}

///////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1015,8 +1023,7 @@ Double_t TKDE::TKernel::operator()(Double_t x) const {
Bool_t useCount = (fKDE->fBinCount.size() == n);
// also in case of unbinned unweighted data fSumOfCounts is sum of events in range
// events outside range should be used to normalize the TKDE ??
Double_t nSum = fKDE->fSumOfCounts; //(useBins) ? fKDE->fSumOfCounts : fKDE->fNEvents;
//if (!useCount) nSum = fKDE->fNEvents;
Double_t nSum = (useCount) ? fKDE->fSumOfCounts : fKDE->fNEvents;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is causing a test to fail. The normalisation of the TKDE is wrong, because now nSum is (in case of unbinned, useCount=false) computed from all events, instead it should be computed from all the events in the range (see SetBinCounts).
This line has to be reverted as before.

We could add a warning (or error) , maybe better in SetKernel so it is not for every event when fKDE->fSumOfCounts is zero, so we avoid having inf values

// in case of non-adaptive fWeights is a vector of size 1
Bool_t hasAdaptiveWeights = (fWeights.size() == n);
Double_t invWeight = (!hasAdaptiveWeights) ? 1. / fWeights[0] : 0;
Expand Down