Fit an histogram without drawing it

I am using the version 4.02 of root.
As is written in the Users Guide, by default, when you fit an histogram, the fitting function object is added to the histogram and is drawn in the current pad. I want to fit the histogram but without getting any canvas or pad?, how can I do it?.

Thank you very much,


Hi Berta,

Looking at the description of the TH1 method :

virtual Int_t Fit(TF1* f1, Option_t* option, Option_t* goption, Axis_t xmin = 0, Axis_t xmax = 0)

you have the following options:

The list of fit options is given in parameter option.
option = “W” Set all errors to 1
= “I” Use integral of function in bin instead of value at bin center
= “L” Use Loglikelihood method (default is chisquare method)
= “LL” Use Loglikelihood method and bin contents are not integers)
= “U” Use a User specified fitting algorithm (via SetFCN)
= “Q” Quiet mode (minimum printing)
= “V” Verbose mode (default is between Q and V)
= “E” Perform better Errors estimation using Minos technique
= “B” Use this option when you want to fix one or more parameters
and the fitting function is like “gaus”,“expo”,“poln”,“landau”.
= “M” More. Improve fit results
= “R” Use the Range specified in the function range
= “N” Do not store the graphics function, do not draw
= “0” Do not plot the result of the fit. By default the fitted function
is drawn unless the option"N" above is specified.
= “+” Add this new fitted function to the list of fitted functions
(by default, any previous function is deleted)

“0” is the one you want to add .