I have a TH2 for which I need to fit the histogram of y for each bin of x. So right now I call TH2::ProjectionX() for each xbin, fit as a Gaussian in y, then look at it.

I noticed that I can get the histogram of each respective fit parameter (constant, mean, sigma) using TH2::FitSlicesY(), which is convenient. However I still would like to draw each slice and its respective fit to check how the fit is in that bin. Is there an easy way to do this using TH2::FitSlicesY()? Or should I stick to my original procedure above?

I may also need to fit iteratively on each projection, so I imagine maybe that FitSlicesY() doesn’t apply so much to my use case.



sorry for the very late reply - I simply did not see your posting :frowning:

I had the exact same problem a while ago - and since then FitSlicesX/Y has a new, last parameter"arr": FirSlices will put all generated histograms into the TObjArray you pass.

Cheers, Axel.