本文整理汇总了C++中TMultiGraph::Fit方法的典型用法代码示例。如果您正苦于以下问题:C++ TMultiGraph::Fit方法的具体用法?C++ TMultiGraph::Fit怎么用?C++ TMultiGraph::Fit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TMultiGraph
的用法示例。
在下文中一共展示了TMultiGraph::Fit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: final_fit
void final_fit() {
TGraph *g1 = new TGraph("2013-02-01-beam-off-clean.dat","%lg %*lg %*lg %*lg %lg"," ");
TGraph *g2 = new TGraph("2013-02-15-beam-off-clean.dat","%lg %*lg %*lg %*lg %lg"," ");
TGraph *g3 = new TGraph("2013-02-28-beam-off_clean.dat","%lg %*lg %*lg %*lg %lg"," ");
TMultiGraph *mg = new TMultiGraph();
mg->Add(g1,"g1");
mg->Add(g2,"g2");
mg->Add(g3,"g3");
TGraph *cernGraph = new TGraph("CERN_guessed_data.dat");
TMultiGraph *mgaxes = new TMultiGraph();
mgaxes->Add(g1,"g12");
mgaxes->Add(g2,"g22");
mgaxes->Add(g3,"g32");
mgaxes->Add(cernGraph,"cernGraph");
// Creates a Root function based on function fitf above
// TF1 *func = new TF1("fitf",fitf,1E9,1E12,2);
// TF1 *func2 = new TF1("fitf",fitf,4E12,5E14,2);
TF1 *lambertfunc = new TF1("fitLambertW",fitLambertW,2e13,5E15,3);
TF1 *lambertCERNfunc = new TF1("fitLambertW",fitLambertW,5e12,1E16,3);
// TF1 *func2 = new TF1("fitLambertW",fitf,1E13,1.1E16,3);
// Sets initial values (guesses)
// func->SetParameters(0.5,0);
// func2->SetParameters(0.5,0);
// lambertfunc->SetParameters(4.27e-11,0.83,4.9e-6); // Based on the other straight line
// lambertfunc->SetParameters(1.9e-17,1.279,1.1e-5);
lambertCERNfunc->SetParameters(4.27e-18,1.289,4.9e-6); // Based on initial fits
lambertfunc->SetParameters(4.27e-18,1.289,4.9e-6); // Based on CERN paper
// Fit histogram in range defined by function
// h2->Fit(func2,"r+");
// lambertCERNfunc->SetLineColor(4);
// lambertCERNfunc->SetLineWidth(2);
// lambertCERNfunc->SetLineStyle(2);
mg->Fit(lambertfunc,"m+");
TCanvas *c1 = new TCanvas("c1","c1",800,800);
mgaxes->SetTitle("Final Fit (with CERN data in black)");
mgaxes->Draw("a");
// mgaxes->SetTicks(2,2);
g1->Draw("*");
g1->SetMarkerStyle(3);
g1->SetMarkerColor(kRed);
g2->Draw("*");
g2->SetMarkerStyle(25);
g2->SetMarkerColor(kBlue);
g3->Draw("*");
g3->SetMarkerStyle(27);
g3->SetMarkerColor(kGreen+3);
lambertfunc->Draw("same");
cernGraph->Draw("*");
lambertCERNfunc->Draw("same");
lambertCERNfunc->SetLineColor(kBlack);
// TH2F *hpx = new TH2F("hpx"," Forward Voltage V_{F} vs. Fluence n_{eq} (with CERN data)",10,1E10,6.4E16,100,0.2,210.0);
// // axis range
// hpx->SetStats(kFALSE);// no statistics
// hpx->Draw();
// g1->SetTitle("Fluence vs. Forward Voltage");
// g1->SetFillColor(1);
// g1->SetMarkerStyle(3);
// g1->Fit(func,"r");
// g1->Fit(lambertfunc,"r+");
// c1->Divide(1,2);
// c1->cd(1);
// h2->SetMarkerStyle(2);
// h2->SetMarkerSize(0.6);
// h2->Draw(); // minor change
// c1->cd(2);
// cernGraph->Draw("*");
// cernGraph->SetMarkerStyle(4);
// cernGraph->GetXaxis()->SetRangeUser(5E10,6.4E20);// axis1->Draw("same");
// g1->Draw("*");
// g1->GetXaxis()->SetRangeUser(5E10,6.4E20);// axis1->Draw("same");
// lambertCERNfunc->Draw("same");
// g1->Draw();
// c1->cd(2);
// lambertfunc->Draw();
c1->SetLogx(1); // Set Log scale in x
c1->SetLogy(1); // Set Log scale in y
//.........这里部分代码省略.........
示例2: drawAvsB
//.........这里部分代码省略.........
tex->SetTextColor(kBlack);
}
else if (samples[is]=="gamjet" && methods[im]=="ptchs" && nogjptb) {
tex->SetTextColor(kBlue);
tex->DrawLatex(0.20,0.63,"#gamma+jet p_{T}^{bal} excl. from fit");
tex->SetTextColor(kBlack);
}
else if ((samples[is]=="zmmjet" || samples[is]=="zeejet") &&
methods[im]=="ptchs" && nozjptb) {
tex->SetTextColor(kRed);
tex->DrawLatex(0.20,0.63,"Z+jet p_{T}^{bal} excl. from fit");
tex->SetTextColor(kBlack);
}
else if (samples[is]=="multijet") {
g->SetMarkerColor(kGray+1);
g->SetLineColor(kGray+1);
if (methods[im]=="ptchs") gmjb = g;
if (methods[im]=="mpfchs1") gmpf = g;
}
else
mg->Add(g);
} // for is
} // for im
if (nogjmpf) s += "_nogjmpf";
if (nogjptb) s += "_nogptb";
if (nozjptb) s += "_nozptb";
if (mjvsjes) {
s += "_mjvsjes";
tex->SetTextColor(kBlack);
tex->DrawLatex(0.20,0.58,"Multijet vs JES fit");
}
TF1 *fjes = new TF1("fjes",jesFit,30,2200,2);
fjes->SetParameters(0.99,0.05);
mg->Fit(fjes,"RN");
fjes->SetLineColor(kBlack);
fjes->SetLineStyle(kDashed);
fjes->SetLineWidth(2);
fjes->SetRange(10.,3500.);
fjes->Draw("SAME");
//TF1 *ft = new TF1("ft","1-[0]-[1]*pow(x,[2]) + ([3]+[4]*log(x))/x",30,2200);
//ft->SetParameters(0,0.05,-0.5,1,0.1);
//ft->FixParameter(3,0);
// Logarithmic sigmoid
//TF1 *ft = new TF1("ft","[0]+(1-[0])/(1. + exp(-(log(x)-log(abs([1])))"
// "/(log(abs([2])+abs([1]))-log(abs([1])))))", 30,2200);
//ft->SetParameters(0.98, 150, 50);
TF1 *ft = new TF1("ft","[0]+(1-[0])/(1. + exp(-(log(x)-[1])/[2]))",30,2200);
//ft->SetParameters(0.98,log(145),log(190)-log(145));
//ft->SetParameters(0.982,4.967,0.271);
//ft->SetParameters(0.976,5.040,0.370); // ENDCAP
//ft->SetParameters(0.985,5.0,0.3);
ft->SetParameters(0.985,5.025,0.3);
//ft->FixParameter(1,5.03); // semi-weighted average of BCD and EF
//ft->FixParameter(2,0.395); // combined fit to BCD+EF / G+H
// ( 12.9*5.055+6.8*5.000)/(12.9+6.8)
ft->FixParameter(1,5.036); // semi-weighted average of BCD/GH and EF/GH
// ( 12.9*0.344 + 6.8*0.455)/(12.9+6.8)
ft->FixParameter(2,0.391); // combined fit to BCD+EF / GH
// Log-sigmoid + powerlaw
//TF1 *ft = new TF1("ft","[0]+(1-[0])/(1. + exp(-(log(x)-[1])/[2]))"