Why does FitSlices make histograms?

I’m reading the documentation about TH2::FitSlicesX/Y and I am confused as to why the fitted values are given to the user inside histograms. Shouldn’t these be TGraphErrors? The returned values are fit values and their uncertainties as a function of X/Y, not counts and their uncertainty.

I mean, I know histograms have more methods and are generally easier to code with in ROOT, but in terms of what kind of data they are meant to represent, this is not the appropriate container for fit results. It reminds me of some code I saw written by an undergrad where they represented an oscilloscope waveform as a TH1 with the X-axis as time, and the Y-axis voltage. Ok maybe you could argue that oscilloscope voltages are ADC counts, but it’s still inappropriate.

I’m guessing it is too late to change this, but maybe we can add an option that returns saner TGraphErrors? It’s easy to just convert the produced TH1s into TGraphErrors, there’s a constructor for that. For now I will do this conversion manually and move on with my life.

More importantly, how can we ensure that this kind of hard-to-reverse error isn’t continued? Maybe the ROOT people can convince me that this isn’t an error?



You are probably right that to represents generic points with error is more appropriate to use TGraphErrors than histograms. In ROOT often histogram are overused.
On the other hand in this particular the fitted parameter values are represented for each bin, so the fittest glided results and the original histogram share somehow the same axis. In general a TGraphErrors could represents randomly scattered points.
As you said, since this is an old method, I think it is not worth changing the interface. There is also the problem that the histogram in ROOT are added automatically in the current directory, why the Graph are not added, making them even more convenient for the user.
In conclusion, I don’t see the need to change the method, we could think eventually in the future in a global re-design of the histogram classes change this.
If you really wanted TGraphErrors, as you know, it is easy to create them from histograms.

Best Regards