Fitting a TH2F with non-rectangular bounds

I have a TH2F filled with x,y data that underwent an elliptical cut in x,y space – so there is an elliptical region in the TH2F filled with data, and the rest of the rectangular area is just unfilled. How can I fit the non-zero data ONLY to a TF2. In my case, I don’t want the zeros in the rectangular TH2F outside of the elliptical region contributing to the fit.

It would be great if I could do something like


but supressing contributions from the bins with no entries is fine too. I realize that if need be, I can make my own function that calculates and returns the chisqr using only the non-zero entries… but that sounds like a pain! :smiley:


See an example of excluding an area when fitting (1-d) in the tutorial fitExclude.C and see TF1::RejectPoint.


Wow, thanks!

As always, I’m am in awe of how responsive you guys are – jeez. And, I realize that I should check the examples more often… as I have another question I’m about to post.