Skip to content
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

Fitting Bernstein in multiple ranges #849

Open
Charlotte-Knight opened this issue Jul 11, 2023 · 1 comment
Open

Fitting Bernstein in multiple ranges #849

Charlotte-Knight opened this issue Jul 11, 2023 · 1 comment

Comments

@Charlotte-Knight
Copy link

The following is in the context of background modelling for a H->gg analysis in case that helps with understanding.

I would like to fit a Bernstein function in two sideband regions. Fitting a function in multiple regions is support by RooFit, and a good example of that can be found in this tutorial:
https://root.cern/doc/master/rf204b__extendedLikelihood__rangedFit_8py.html

I have found that both ROOT's implementation (RooBernstein) and combine's (RooBernsteinFast) do not work over multiple ranges. This is an issue that has been brought to ROOT's attention before:
https://root-forum.cern.ch/t/problem-with-fit-in-range-with-roobernstein/41593
but not solved. The issue is related to how the default range of a Bernstein polynomial which is [0,1], is extended to the range you are fitting over (100 -> 180 in my case). Both implementations of the Bernstein function infer the fitting range from the minimum and maximum values of the variable you are fitting to (mgg in my case). This is fine when fitting over a single range, but evidently causes issues when fitting over multiple.

A similar issue existed with RooChebychev:
https://sft.its.cern.ch/jira/browse/ROOT-6664
and was eventually patched by setting the range of the RooChebychev in the constructor, rather than in the evaluate function. I tried doing the same in ROOT and combine's different implementations. I found that for ROOT's implementation, the fix worked, whereas for combine's it is still broken. I haven't examined the differences in detail so I am not sure why.

Below are fits made between 100->120 and 170->180. Only the patched version of RooBernstein (ROOT's version) works as expected.

image
image

Patched version of RooBernsteinFast can be found here:
Charlotte-Knight@dc77011

Patched version of RooBernstein can be found here:
Charlotte-Knight@3bf38de

I have briefly played with ROOT v6.28 to see if the issue is now solved with RooBernstein. It appears that for a non-extended fit, it is, but for an extended, it is not.

image

Given that this issue persists in the latest version of ROOT, I would think I should report to them so it can be fixed in later versions. In the meantime, whilst combine is using 6.22 (on CMSSW_11_3), what should we do?

One option I see is to add the patched version of the RooBernstein and then make RooBernsteinFast a wrapper that redirects to RooBerstein for backwards compatibility reasons.

Another option would be to correctly patch RooBernsteinFast although I'm not sure if that's easily possible at this stage.

Does anyone have thoughts?

@ajgilbert
Copy link
Collaborator

We found the same problem with RooBernsteinFast when doing the Higgs->Zgamma analysis. You could try the patch developed here: /afs/cern.ch/work/a/agilbert/public/HZgammaFits/RooBernsteinFast.h.patch
Does two things:

  • Looks for an additional named range on the mass RoolRealVar called "full"
  • Disables the analytic integrals, these won't be calculated correctly when using subranges. I think this could probably be fixed, but would need more work. Numerical integration will be slower, but for simple fits it shouldn't matter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants