Fitting one function to multiple ranges simultaneously

I am trying to fit a function to background both above and below a peak. I have a single function (let’s say a simple linear p[0] + p[1]*x), and I want to fit it to a TH1 with multiple discontiguous ranges simultaneously - something like [50, 100] and [150, 200], where the peak is in [100, 150] and thus excluded from the background fit.

Reading the documentation here,

"The ROOT::Fit::DataRange class supports defining multiple rectangular ranges in each dimension, and supports n-dimension. The function DataRange::AddRange(icoord,xmin,xmax) adds a range in the coordinate icoord with lower value xmin and upper value xmax"

However when I attempt to add multiple ranges in the same dimension:

range.AddRange(0, 50, 100);
range.AddRange(0, 150, 200);

I get a warning: Warning in <ROOT::Fit::FillData>: support only one range interval for X coordinate.

Which seems to indicate that only one interval can be specified (per coordinate). My questions are:

  1. Is there another way to achieve multiple discontiguous regions for a single fit
  2. Is there a reason for this limitation in the ROOT::Fit framework

N.B. I can achieve something close by creating a TGraphErrors and putting the relevant points into that and fitting it. However, I would like to be able to do a likelihood fit to handle low statistics correctly. As I understand it, this isn’t possible for a TGraph object.

Thanks
Tim


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.27
Platform: macOS
Compiler: clang


Hi,

Thank you for your post. There is no special reasons for this limitation, it should be implemented correctly the fit for multiple ranges, at least when using the Fitter class. It has not yet been done probably because the TH1 interface does not support fit for multiple ranges.
For the time being, there is a possible solution, although not very nice, but it is working, using the TF1::RejectPoint. Here is a simple example, it requires a modification of your fit function.
https://cernbox.cern.ch/index.php/s/IS3pAsW89LE5WEo

Cheers

Lorenzo

Hi,

Thanks for the info on TF1::RejectPoint - that’s very useful.

Is implementing multiple ranges in the Fitter class something that I can contribute towards? It seems that changing Fit::FillData to handle multiple ranges in each axis is not a particularly large job, I could see if I can get it working.

Tim

Hi,
This would be great, if you would like to contribute to this with a PR. If you need any help or if you have any questions, please let us know
Cheers

Lorenzo

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.