[ROOT Fitting] 複数のフィット関数を同時に表示する
ガンマ線スペクトル等をROOTのヒストグラムとして扱って、輝線放射に対してpol1+gausのような関数でフィットする際、複数の輝線のフィット結果を同時に描画したいことがあります。以下のように、Fit()メソッドの第二引数として、”+”を指定すると、ヒストグラムオブジェクトのフィット関数リストに追加されていき、Draw()したときに過去のフィット結果も同時にプロットされるようになります(デフォルトでは、ヒストグラムのフィット関数リストは、Fit()をコールするたびに毎回履歴がdeleteされます)。
具体的な例で実行すると、以下のような感じになります。以下の例では、4個の輝線に対してpol1+gausで構成される4個のTF1のインスタンスについてフィットしています。
1
2
3
4
TF1 *fitFunction1=new TF1("fitFunction1","gaus(0)+pol1(3)");
TF1 *fitFunction2=new TF1("fitFunction2","gaus(0)+pol1(3)");
histogram->Fit("fitFunction1", "+", "", fitRangeLower, fitRangeUpper);
histogram->Fit("fitFunction2", "+", "", fitRangeLower, fitRangeUpper);
詳細は、TH1のFitメソッドのAPIリファレンスを参照してください。
The list of fit options is given in parameter option.
option = "W" Set all weights to 1 for non empty bins; ignore error bars
= "WW" Set all weights to 1 including empty bins; ignore error bars
= "I" Use integral of function in bin, normalized by the bin volume,
instead of value at bin center
= "L" Use Loglikelihood method (default is chisquare method)
= "WL" Use Loglikelihood method and bin contents are not integer,
i.e. histogram is weighted (must have Sumw2() set)
= "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" User defined parameter settings are used for predefined functions
like "gaus", "expo", "poln", "landau".
Use this option when you want to fix one or more parameters for these functions.
= "M" More. Improve fit results.
It uses the IMPROVE command of TMinuit (see TMinuit::mnimpr).
This algorithm attempts to improve the found local minimum by searching for a
better one.
= "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)
= "C" In case of linear fitting, don't calculate the chisquare
(saves time)
= "F" If fitting a polN, switch to minuit fitter
= "S" The result of the fit is returned in the TFitResultPtr
(see below Access to the Fit Result)
