Fit, excluding specified bins

Hello Rooters

I want to perform a gaussian fit on TH2F histogram (lego plot). The top of the random gaussian distribution is cutted away (just a plateau around the center of the gaussian distrubion remains). Now I want to force root to take all bins into account for the fit except some specified bins at the center of the distribution.
So how can I force root to perfom a fit on a histogram without taking for example the bin content of bin [10][20] into account?

Thanks a lot for your help!



easy quick workaround is to set errors of unwanted bins to huge values compared to normal errors of other bins and then fit.

see tutorial $ROOTSYS/tutorials/fit/fitExclude.C


If you are doing a likelihood fit, this won’t change work.


Thanks for your replies. I used the method of setting large errors for all bins I wanted to exclude from the fit.