本文整理汇总了C++中TF1::GetNumberFreeParameters方法的典型用法代码示例。如果您正苦于以下问题:C++ TF1::GetNumberFreeParameters方法的具体用法?C++ TF1::GetNumberFreeParameters怎么用?C++ TF1::GetNumberFreeParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TF1
的用法示例。
在下文中一共展示了TF1::GetNumberFreeParameters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FitDijetMass_Data
void FitDijetMass_Data() {
TFile *inf = new TFile("MassResults_ak7calo.root");
TH1F *hCorMassDen = (TH1F*) inf->Get("DiJetMass");
hCorMassDen->SetXTitle("Corrected Dijet Mass (GeV)");
hCorMassDen->SetYTitle("Events/GeV");
hCorMassDen->GetYaxis()->SetTitleOffset(1.5);
hCorMassDen->SetMarkerStyle(20);
hCorMassDen->GetXaxis()->SetRangeUser(120.,900.);
gROOT->ProcessLine(".L tdrstyle.C");
setTDRStyle();
tdrStyle->SetErrorX(0.5);
tdrStyle->SetPadRightMargin(0.08);
tdrStyle->SetLegendBorderSize(0);
gStyle->SetOptFit(1111);
tdrStyle->SetOptStat(0);
TCanvas* c2 = new TCanvas("c2","DijetMass", 500, 500);
/////// perform 4 parameters fit
TF1 *func = new TF1("func", "[0]*((1-x/7000.+[3]*(x/7000)^2)^[1])/(x^[2])",
100., 1000.);
func->SetParameter(0, 1.0e+08);
func->SetParameter(1, -1.23);
func->SetParameter(2, 4.13);
func->SetParameter(3, 1.0);
func->SetLineColor(4);
func->SetLineWidth(3);
TVirtualFitter::SetMaxIterations( 10000 );
TVirtualFitter *fitter;
TMatrixDSym* cov_matrix;
int fitStatus = hCorMassDen->Fit("func","LLI","",130.0, 800.0); // QCD fit
TH1F *hFitUncertainty = hCorMassDen->Clone("hFitUncertainty");
hFitUncertainty->SetLineColor(5);
hFitUncertainty->SetFillColor(5);
hFitUncertainty->SetMarkerColor(5);
if (fitStatus == 0) {
fitter = TVirtualFitter::GetFitter();
double* m_elements = fitter->GetCovarianceMatrix();
cov_matrix = new TMatrixDSym( func->GetNumberFreeParameters(),m_elements);
cov_matrix->Print();
double x, y, e;
for(int i=0;i<hFitUncertainty->GetNbinsX();i++)
{
x = hFitUncertainty->GetBinCenter(i+1);
y = func->Eval(x);
e = QCDFitUncertainty( func, *cov_matrix, x);
hFitUncertainty->SetBinContent(i+1,y);
hFitUncertainty->SetBinError(i+1,e);
}
}
hCorMassDen->Draw("ep");
gPad->Update();
TPaveStats *st = (TPaveStats*)hCorMassDen->FindObject("stats");
st->SetName("stats1");
st->SetX1NDC(0.3); //new x start position
st->SetX2NDC(0.6); //new x end position
st->SetTextColor(4);
hCorMassDen->GetListOfFunctions()->Add(st);
/////// perform 2 parameters fit
TF1 *func2 = new TF1("func2", "[0]*(1-x/7000.)/(x^[1])", 100., 1000.);
func2->SetParameter(0, 10000.);
func2->SetParameter(1, 5.0);
func2->SetLineWidth(3);
fitStatus = hCorMassDen->Fit("func2","LLI","",130.0, 800.0); // QCD fit
TH1F *hFitUncertainty2 = hCorMassDen->Clone("hFitUncertainty2");
hFitUncertainty2->SetLineColor(kGray);
hFitUncertainty2->SetFillColor(kGray);
hFitUncertainty2->SetMarkerColor(kGray);
if (fitStatus == 0) {
fitter = TVirtualFitter::GetFitter();
double* m_elements = fitter->GetCovarianceMatrix();
cov_matrix = new TMatrixDSym( func2->GetNumberFreeParameters(),m_elements);
cov_matrix->Print();
double x, y, e;
for(int i=0;i<hFitUncertainty2->GetNbinsX();i++)
{
x = hFitUncertainty2->GetBinCenter(i+1);
y = func2->Eval(x);
e = QCDFitUncertainty( func2, *cov_matrix, x);
hFitUncertainty2->SetBinContent(i+1,y);
hFitUncertainty2->SetBinError(i+1,e);
//.........这里部分代码省略.........