TFractionFitter for multiple histograms

Hi rooters,

I am using the TFractionFitter class to fit a Monte Carlo signal and background to data for many different histograms. It is a great package which does a fantastic job without much effort on my part.

I would like to do something more complex and I’m not sure whether it will be possible with the TFractionFitter class. Instead of fitting the proportions for each ‘set’ of Monte Carlo and data histograms individually, I would like to relate the proportions of all the ‘sets’ together with some smoothly varying function and then to fit the parameters of this function.

Is this possible with the the TFractionFitter class? If not, please would someone be so kind as to suggest a good way of doing what I am contemplating. I can’t quite decide if fitting a smoothly varying function to the results of the individual fits would be equivalent to the overall fit. It seems that I would loose out on the benefit of increased statistics that way.

Best Regards,

1 Like

I have mailed your question to the authors of TFractionFitter and received
the following answer from Frank Filthaut:

[quote]I’m not entirely sure what the question is exactly, so this may
require some iteration… On the other hand, I was anyway interested
in the possibility of using the same (smoothed) templates to fit
multiple histograms. So it might be that these interests nicely

So, I would suggest that you describe a bit more in details what you
would like to see. Since Frank seems to be willing to do some work,
may be you could iterate in this Forum and post the progress in the


Dear Rene and Frank,

In my particluar case, I have a data set which is binned in two variables (cm angle and invariant mass) . For each one of these bins there is filled a histogram of data in a third variable (missing mass squared) . For each one of these data histograms, there are two corresponding Monte Carlo simulations (signal and background) with probably two more to be added later (other sources of background). So I have many data histograms which each need to be fitted with their associated MCs, but the point is they are related to one another by a change in cm angle and invariant mass.

Currently, I fit each data histogram with its associated MC histograms individually using TFractionFitter. If I plot the results, there is a clear (almost linear) trend in the fractions - which is great although not as good as if it were flat. Currently the binning is quite coarse but it will be made finer in the future, which will mean more histograms with less statistics in each. In this case, where the histogram fractions vary smoothly and there may be a statistics limitation, it would be nice if I could rather fit a 2D function of the fractions to all the histograms, with all the data, at the same time.

I appreciate that this could be very technically demanding to implement and may not be worth it if there is some easier or better or equivalent way of accomplishing what I have discribed above. I look forward to your comments.



We have the intention to implement a THStack::Fit method.
THStack is a list of histograms.

But, I do not know if TFractionFitter can be adapted easilly to a THStack
in addition to TH1s. Frank input is welcome.


Dear Rene and Mark,

I suppose I must be a bit slow, as it’s still not exactly clear to me what you want to do. But if I interpret correctly your “related to one another by a change in cm angle and invariant mass”, this indeed agrees with what I was interested in myself, namely using the same template histograms to fit multiple data histograms simultaneously.

Unfortunately, it looks as if the simultaneous use of multiple data histograms does not allow anymore for the nice simiplification that can be obtained for a single histogram (where it turns out that the dimensionality of the problem can be reduced – see the original paper by Barlow & Beeston). So at the very least a substantial rewrite of the code would be required. At this point I’m not even sure that there would be any gain compared to a naive approach, where all parameters to be fit are declared as Minuit parameters.

                                     Best regards, 

Again, I’m not quite sure what you’re trying to do. But if you want to fit several histograms using one set of fractions then it is possible (even though not at all elegant) to pack the separate histograms into one and fit that.


Hi All,

I’ve realised that my previous “explanation” was not the simplest way of understanding what I would like to do.

Imagine that you have a 2D histogram of data, and then some others with identical size and shape which are Monte Carlo simulations. If you did a normal fit with the fraction fitter, you would essentially get a result that was one number for every MC histogram - that number being the fraction of the data that that particular MC represents.

What I want to do might in some ways actually be against the philosophy of this fitting routine. I want to change the shape of my histogram, but only along one axis. I have established that if I fit bin by bin along this axis, the resulting fractions vary smoothly, but they are not constant. If you imagine that the TFractionFitter class ordinarily fits the constant function multiplied by a histogram, perhaps it would be possible to fit a varying function of a few parameters.

The truth is, I’m not really sure how the class works. I haven’t read Roger and Christine’s publication because my university’s subscription only goes back to 1995 and so I’m not sure where to get it from. It’s conceivable that what I want to do is easier accomplished in another way and so any suggestions are welcome. Maybe the changes that would be required to the TFractionFitter class are prohibitively expensive to impliment, as Roger suggests. If so, my bin-by-bin fit would be acceptable - the major benefit that I envisage from an overall fit is the increased statistics.