本文整理汇总了C++中TF1::GetProb方法的典型用法代码示例。如果您正苦于以下问题:C++ TF1::GetProb方法的具体用法?C++ TF1::GetProb怎么用?C++ TF1::GetProb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TF1
的用法示例。
在下文中一共展示了TF1::GetProb方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FitSPE
int FitSPE(TH1* spe, int ntriggers)
{
double fitmin, fitmax;
double params[NPAR];
//find the likely place for the single p.e. peak
params[MEAN] = spe->GetMean();
params[SIGMA] = spe->GetRMS();
int bin = spe->FindBin(params[MEAN]);
if(spe->GetMaximumBin() == 1){
spe->Fit("gaus","Q0","",spe->GetBinCenter(bin),
spe->GetBinCenter(bin+20));
}
else{
spe->Fit("gaus","Q0","",spe->GetBinCenter(bin-10),
spe->GetBinCenter(bin+10));
}
TF1* gaus = spe->GetFunction("gaus");
if(gaus->GetParameter(1) > 0)
params[MEAN] = gaus->GetParameter(1);
if(gaus->GetParameter(2) > 0 && gaus->GetParameter(2) < params[SIGMA])
params[SIGMA] = gaus->GetParameter(2);
params[LAMBDA] = 0.5;
//find the maximum fit range
bin = spe->GetNbinsX();
while(spe->GetBinContent(--bin) < 2) {}
fitmax = spe->GetBinCenter(bin);
spe->Fit("expo","Q0","",spe->GetBinCenter(bin), spe->GetBinCenter(bin-10));
//find the best estimate for the exponentials
//the first is from the first few bins
bin = spe->FindBin(params[MEAN]) - 5;
double compval = spe->GetBinContent(bin--);
while(spe->GetBinContent(bin) < compval && spe->GetBinContent(bin) != 0){
compval = spe->GetBinContent(bin--);
}
if(spe->GetBinContent(bin) == 0){
fitmin = spe->GetBinCenter(bin+1);
}
else{
++bin;
//now find the max of the turnover
int minbin = bin;
compval = spe->GetBinContent(bin--);
while(spe->GetBinContent(bin) > compval && bin > 0 ){
compval = spe->GetBinContent(bin--);
}
++bin;
spe->Fit("expo","Q0","",spe->GetBinCenter(bin), spe->GetBinCenter(minbin));
params[AMP1] = spe->GetFunction("expo")->GetParameter(0);
params[L1] = spe->GetFunction("expo")->GetParameter(1);
fitmin = spe->GetBinCenter(bin+1);
}
//estimate the peak heights
params[CONSTANT] = ntriggers * spe->GetBinWidth(1);
fitmin = spe->GetBinCenter(4);
TF1* spefunc = new TF1("spefunc", SPEFunc, fitmin, fitmax, NPAR);
spefunc->SetParameters(params);
for(int i=0; i<NPAR; i++)
spefunc->SetParName(i, names[i]);
spefunc->SetParLimits(CONSTANT, 0 , params[CONSTANT]*100.);
spefunc->SetParLimits(LAMBDA, 0, 2);
spefunc->SetParLimits(MEAN, std::max(params[MEAN]-params[SIGMA],0.),
params[MEAN]+params[SIGMA]);
spefunc->SetParLimits(SIGMA, 0, spe->GetRMS());
spefunc->SetParLimits(L1, -30, 0);
spefunc->SetParLimits(AMP1, -30, 30);
spefunc->SetParLimits(L2, -30, 0);
spefunc->SetParLimits(AMP2, -30, 30);
//spefunc->FixParameter(CONSTANT, ntriggers * spe->GetBinWidth(1));
//return 0;
spefunc->SetLineStyle(1);
spefunc->SetLineColor(kBlue);
int result = spe->Fit(spefunc,"MRNI");
spefunc->DrawCopy("same");
std::cout<<"Fit results: \n"<<
"\t Chi2/NDF = "<<spefunc->GetChisquare()<<"/"<<spefunc->GetNDF()
<<"\n\t Prob = "<<spefunc->GetProb()<<std::endl;
for(int i=0; i<NPAR; i++)
params[i] = spefunc->GetParameter(i);
TF1* background = new TF1("background",background_func,fitmin,fitmax,NPAR);
background->SetLineColor(kRed);
background->SetParameters(spefunc->GetParameters());
background->DrawCopy("same");
TF1* signal = new TF1("signal",signal_func,fitmin,fitmax,NPAR);
signal->SetLineColor(kGreen);
signal->SetParameters(spefunc->GetParameters());
signal->DrawCopy("same");
TF1* apeak = new TF1("apeak","[0]*TMath::Gaus(x,[1],[2],1)",fitmin, fitmax);
//.........这里部分代码省略.........
示例2: Loop
//.........这里部分代码省略.........
accTimesEffPad->SetFillColor(0);
accTimesEffPad->SetFrameFillColor(0);
accTimesEffPad->SetLeftMargin(0.11);
accTimesEffPad->SetRightMargin(0.09);
accTimesEffPad->SetTopMargin(0.08);
accTimesEffPad->SetTickx(1);
accTimesEffPad->SetTicky(1);
accTimesEffPad->Draw();
accTimesEffPad->cd();
gStyle->SetTitleFont(font);
gStyle->SetLabelFont(font);
gStyle->SetLegendFont(font);
gStyle->SetOptStat(0);
gStyle->SetOptTitle(0);
gStyle->SetOptFit(1111);
gStyle->SetTitleXOffset(1.);
gStyle->SetTitleYOffset(1.3);
gPad->SetTicks(1, 1);
gPad->SetGrid(1, 1);
TH1F* hAccTimesEff2 = (TH1F*)hAccTimesEff->Clone("hAccTimesEff2");
TF1 *fitFunc = new TF1("fitFunc", "[0] + [1]/ (x + [2]) + [3]*x", 10., 5010.);
//TF1 *fitFuncEB = new TF1("fitFuncEB", "[0] + [1]/ (x + [2])", 10., 5010.);
TF1 *fitFuncEB = new TF1("fitFuncEB", "[0] + [1]/ (x + [2]) + [3]*x", 10., 5010.);
TF1 *fitFuncEE = new TF1("fitFuncEE", "[0] + [1]/ (x*x + [2])", 10., 5010.);
fitFunc->SetLineColor(kBlue);
fitFuncEB->SetLineColor(kBlue);
fitFuncEE->SetLineColor(kBlue);
hAccTimesEff->Fit("fitFunc", "", "", 480., 5010.);
hAccTimesEffEB->Fit("fitFuncEB", "", "", 480., 5010.);
hAccTimesEffEE->Fit("fitFuncEE", "", "", 480., 5010.);
cout << "Chi^2 / NDF: " << fitFunc->GetChisquare() << " / " << fitFunc->GetNDF() << ", prob: " << fitFunc->GetProb() << endl;
cout << "Chi^2 / NDF EB: " << fitFuncEB->GetChisquare() << " / " << fitFuncEB->GetNDF() << ", prob: " << fitFuncEB->GetProb() << endl;
cout << "Chi^2 / NDF EE: " << fitFuncEE->GetChisquare() << " / " << fitFuncEE->GetNDF() << ", prob: " << fitFuncEE->GetProb() << endl;
hAccTimesEff->GetYaxis()->SetTitle("acc x eff");
hAccTimesEff->GetYaxis()->SetRangeUser(0., 1.);
hAccTimesEff->Draw();
TLatex *tex = new TLatex(0.22, 0.21, "P(M|p0,p1,p2,p3) = p0 + #frac{p1}{M+p2} + p3*M");
tex->SetNDC();
tex->SetTextFont(font);
tex->SetLineWidth(2);
tex->SetTextSize(0.03);
tex->Draw();
tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV");
tex->DrawLatex(0.17, 0.85, "trg + electron + muon");
TCanvas *accTimesEffPlotEB = new TCanvas("accTimesEffPlotEB", "acc x eff, barrel electron + muon", 100, 100, 600, 600);
TPad *accTimesEffPadEB = (TPad*)accTimesEffPad->Clone("accTimesEffPadEB");
accTimesEffPadEB->Draw();
accTimesEffPadEB->cd();
hAccTimesEffEB->GetYaxis()->SetTitle("acc x eff");
hAccTimesEffEB->GetYaxis()->SetRangeUser(0., 1.);
hAccTimesEffEB->Draw();
tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV");
//tex->DrawLatex(0.46, 0.21, "P(M|p0,p1,p2) = p0 + #frac{p1}{M+p2}");
tex->DrawLatex(0.22, 0.21, "P(M|p0,p1,p2,p3) = p0 + #frac{p1}{M+p2} + p3*M");
tex->DrawLatex(0.17, 0.85, "trg + barrel electron + muon");
TCanvas *accTimesEffPlotEE = new TCanvas("accTimesEffPlotEE", "acc x eff, endcap electron + muon", 100, 100, 600, 600);
TPad *accTimesEffPadEE = (TPad*)accTimesEffPad->Clone("accTimesEffPadEE");
accTimesEffPadEE->Draw();
accTimesEffPadEE->cd();
hAccTimesEffEE->GetYaxis()->SetTitle("acc x eff");