本文整理汇总了C++中TGraphErrors::GetErrorY方法的典型用法代码示例。如果您正苦于以下问题:C++ TGraphErrors::GetErrorY方法的具体用法?C++ TGraphErrors::GetErrorY怎么用?C++ TGraphErrors::GetErrorY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGraphErrors
的用法示例。
在下文中一共展示了TGraphErrors::GetErrorY方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: JEC_fit_Uncertainty
void JEC_fit_Uncertainty(int N)
{
TF1 *func[1000];
TFile *inf = new TFile("L3Graphs_test_Icone5.root");
TGraphErrors *g = (TGraphErrors*)inf->Get("Correction_vs_CaloPt");
TGraphErrors *vg[1000];
int i,k;
double x[20],y[20],ex[20],ey[20];
double vx[20],vy[20],vex[20],vey[20];
for(i=0;i<g->GetN();i++)
{
g->GetPoint(i,x[i],y[i]);
ex[i]=g->GetErrorX(i);
ey[i]=g->GetErrorY(i);
}
TRandom *rnd = new TRandom();
rnd->SetSeed(0);
for(k=0;k<N;k++)
{
for(i=0;i<g->GetN();i++)
{
vx[i] = rnd->Gaus(x[i],ex[i]);
//vx[i] = x[i];
vy[i] = rnd->Gaus(y[i],ey[i]);
vex[i] = ex[i];
vey[i] = ey[i];
}
vg[k] = new TGraphErrors(g->GetN(),vx,vy,vex,vey);
func[k] = new TF1("func","[0]+[1]/(pow(log10(x),[2])+[3])",1,2000);
func[k]->SetParameters(1,3,6,5);
vg[k]->Fit(func[k],"RQ");
}
TCanvas *c = new TCanvas("c","c");
gPad->SetLogx();
g->SetMarkerStyle(20);
g->SetMaximum(3.5);
g->Draw("AP");
for(k=0;k<N;k++)
{
func[k]->SetLineColor(5);
func[k]->SetLineWidth(1);
cout<<func[k]->GetChisquare()<<endl;
vg[k]->SetMarkerColor(2);
vg[k]->SetLineColor(2);
vg[k]->SetMarkerStyle(21);
//if (func[k]->GetChisquare()<0.1)
//vg[k]->Draw("sameP");
func[k]->Draw("same");
}
}
示例2: profileDistributions
//.........这里部分代码省略.........
MC->Sumw2();
std::vector<TH2 *> systMC;
for(size_t isyst=0; isyst<nSysts; isyst++)
{
TH2F *h=(TH2F *)inSystF->Get(systList[isyst]+"/"+ch[ich]+"_"+profs[i]) ;
h->Scale(totalTTbar/h->Integral());
h->Add(bckgMC);
h->Sumw2();
h->SetDirectory(0);
systMC.push_back(h);
}
//get the data
TH2 *Data = (TH2 *) inF->Get("data/"+ch[ich]+"_"+profs[i]);
Data->SetDirectory(0);
Data->Sumw2();
TGraphErrors *MCProf = new TGraphErrors(MC->ProfileX()); MCProf->SetMarkerStyle(24); MCProf->SetFillStyle(0); MCProf->SetName(ch[ich]+profs[i]+"mc");
TGraphErrors *DataProf = new TGraphErrors(Data->ProfileX()); DataProf->SetMarkerStyle(20); DataProf->SetFillStyle(0); DataProf->SetName(ch[ich]+profs[i]+"data");
//build data/MC scale factors
std::vector<TGraphErrors *> data2mcProfs;
for(size_t isyst=0; isyst<=systMC.size(); isyst++)
{
TGraphErrors *prof= (isyst==0 ? MCProf : new TGraphErrors(systMC[isyst-1]->ProfileX()));
TString baseName(ch[ich]+profs[i]);
if(isyst) baseName += systList[isyst];
prof = (TGraphErrors *) prof->Clone(baseName+"data2mc");
for(int ip=0; ip<DataProf->GetN(); ip++)
{
Double_t x,y,ydata,y_err,ydata_err;
prof->GetPoint(ip,x,y); y_err=prof->GetErrorY(ip);
DataProf->GetPoint(ip,x,ydata); ydata_err=DataProf->GetErrorY(ip);
if(y<=0) continue;
prof->SetPoint(ip,x,ydata/y);
prof->SetPointError(ip,0,sqrt(pow(ydata*y_err,2)+pow(ydata_err*y,2))/pow(y,2));
}
prof->SetFillColor(systColors[isyst]);
prof->SetFillStyle(3001+isyst%2);
prof->SetTitle( isyst==0 ? nomTTbarTitle : systLabels[isyst-1] );
//prof->SetMarkerStyle(24); prof->SetFillStyle(3001); prof->SetMarkerColor(1+isyst); prof->SetMarkerColor(1+isyst); prof->SetLineColor(1+isyst);
data2mcProfs.push_back(prof);
}
TH1D *MCProjY=MC->ProjectionY();
MCProjY->Scale(1./MCProjY->Integral());
TGraphErrors *MCProj = new TGraphErrors(MCProjY); MCProj->SetMarkerStyle(24); MCProj->SetFillStyle(0); MCProj->SetName(ch[ich]+profs[i]+"projmc");
TH1D *DataProjY=Data->ProjectionY();
DataProjY->Scale(1./DataProjY->Integral());
TGraphErrors *DataProj = new TGraphErrors(DataProjY); DataProj->SetMarkerStyle(20); DataProj->SetFillStyle(0); DataProj->SetName(ch[ich]+profs[i]+"projdata");
MCProj->SetLineColor(colors[i]); MCProj->SetMarkerColor(colors[i]); MCProj->SetFillColor(colors[i]); MCProj->SetFillStyle(1001);
DataProj->SetLineColor(colors[i]); DataProj->SetMarkerColor(colors[i]); DataProj->SetFillColor(colors[i]);
TPad *p=(TPad *)cproj->cd();
p->SetLeftMargin(0.15);
p->SetRightMargin(0.02);
p->SetTopMargin(0.05);
p->SetLogy();
MCProj->SetFillStyle(0);
MCProj->Draw(i==0 ? "al3" : "l3");
MCProj->GetYaxis()->SetRangeUser(1e-5,1.0);
MCProj->GetXaxis()->SetTitle( MC->GetYaxis()->GetTitle() );
MCProj->GetYaxis()->SetTitle( "1/N dN/dx" );
示例3: if
TGraphErrors *ReadMWGraph(const char *name, Int_t flag)
{
Double_t xreject = 0.49;
TGraphErrors *g = new TGraphErrors(name);
if (g->IsZombie()) return 0;
while (g->GetX()[0] < xreject)
g->RemovePoint(0);
TGraphErrors *g2 = new TGraphErrors(name);
if (g2->IsZombie()) return 0;
while (g2->GetX()[0] < xreject)
g2->RemovePoint(0);
g2->SetMarkerStyle(4);
g2->SetMarkerSize(1.00);
g2->SetMarkerColor(kBlack);
g2->SetLineColor(kBlack);
TGraphErrors *gsys = new TGraphErrors(name, "%lg %lg %lg %*lg %lg");
if (gsys->IsZombie()) return 0;
while (gsys->GetX()[0] < xreject)
gsys->RemovePoint(0);
for (Int_t i = 0; i < gsys->GetN(); i++)
gsys->SetPointError(i, gsys->GetErrorX(i)*0.75, gsys->GetErrorY(i));
gsys->SetFillColor(kGray+2);
gsys->SetLineColor(kGray+2);
gsys->SetFillStyle(3000);
if (flag == 1 || flag == 3) {
TGraphErrors *gt = new TGraphErrors(Form("%s_%s", name, "trues"));
if (gt->IsZombie()) return 0;
while (gt->GetX()[0] < xreject)
gt->RemovePoint(0);
gt->SetMarkerStyle(20);
gt->SetMarkerSize(0.75);
gt->SetMarkerColor(kGreen+1);
gt->SetLineColor(kGreen+1);
TGraphErrors *gbw = new TGraphErrors(Form("%s_%s", name, "gen"));
if (gbw->IsZombie()) return 0;
while (gbw->GetX()[0] < xreject)
gbw->RemovePoint(0);
gbw->SetMarkerStyle(20);
gbw->SetMarkerSize(0.75);
gbw->SetMarkerColor(kBlue+1);
gbw->SetLineColor(kBlue+1);
for (Int_t i = 0; i < g->GetN(); i++) {
g->SetPointError(i, g->GetEX()[i], 0.);
gt->SetPointError(i, gt->GetEX()[i], 0.);
gbw->SetPointError(i, gbw->GetEX()[i], 0.);
}
for (Int_t i = 0; i < g2->GetN(); i++) {
g2->SetPoint(i, g2->GetX()[i], g2->GetY()[i] - gt->GetY()[i] + gbw->GetY()[i]);
g2->SetPointError(i, g2->GetEX()[i], TMath::Sqrt(g2->GetEY()[i]*g2->GetEY()[i] + gt->GetEY()[i]*gt->GetEY()[i] +
gbw->GetEY()[i]*gbw->GetEY()[i]));
// g2->SetPoint(i, g2->GetX()[i], g2->GetY()[i] - gt->GetY()[i] + 1.01947);
// g2->SetPointError(i, g2->GetEX()[i], TMath::Sqrt(g2->GetEY()[i]*g2->GetEY()[i] + gt->GetEY()[i]*gt->GetEY()[i] +
// 7.78680e-06*7.78680e-06));
gsys->SetPoint(i, gsys->GetX()[i], g2->GetY()[i]);
}
}
g->SetTitle();
g->SetName(name);
g->GetXaxis()->SetTitle("p_{T}, GeV/c");
g->SetMarkerStyle(20);
g->SetMarkerSize(0.95);
g->SetMarkerColor(kRed+1);
g->SetLineColor(kRed+1);
const Double_t mass = 1.019455;
const Double_t mass_delta = 0.000020;
const Double_t width = 0.00426;
const Double_t width_delta = 0.00004;
if (flag == 1) { // mass
g->GetYaxis()->SetTitleOffset(1.50);
g->GetYaxis()->SetTitle("mass, GeV/c^{2}");
g->SetMaximum(mass+0.0015);
g->SetMinimum(mass-0.0015);
TBox *box = new TBox(g->GetXaxis()->GetXmin(), mass - mass_delta, g->GetXaxis()->GetXmax(), mass + mass_delta);
box->SetFillColor(kGray+1);
box->SetFillStyle(3001);
g->GetListOfFunctions()->Add(box);
g->GetListOfFunctions()->Add(g2, "CP");
g->GetListOfFunctions()->Add(gt, "CP");
g->GetListOfFunctions()->Add(gbw, "CP");
}
else if (flag == 3) { // mass simple
g2->SetTitle();
g2->SetName(Form("%s_only", name));
g2->GetXaxis()->SetTitle("p_{T}, GeV/c");
g2->SetMarkerStyle(20);
g2->SetMarkerSize(0.75);
g2->SetMarkerColor(kBlack);
g2->SetLineColor(kBlack);
g2->GetYaxis()->SetTitleOffset(1.50);
//.........这里部分代码省略.........
示例4: plot
//.........这里部分代码省略.........
uncert->SetLineStyle(0);
uncert->SetLineWidth(0);
TH1* hExpBkgTotalUncert = (TH1*)uncert->Clone();
hExpBkgTotalUncert->SetFillStyle(3354);
TH1* hAgreement = (TH1*)data->Clone();
hAgreement->Divide(hExpBkg);
TGraphErrors* hAgreementRelUncert = new TGraphErrors(hAgreement->GetNbinsX());
hAgreementRelUncert->SetLineWidth(2);
hAgreementRelUncert->SetLineColor(kBlack);
for (int i = 1; i <= hFrame->GetNbinsX(); ++i) {
double myQCDTotalUncert = TMath::Power(qcd->GetBinError(i), 2)
+ TMath::Power(qcd->GetBinContent(i)*myQCDRelUncert, 2);
double myEWKTotalUncert = TMath::Power(ewktau->GetBinError(i), 2)
+ TMath::Power(ewktau->GetBinContent(i)*myEWKRelUncert, 2);
double myFakesTotalUncert = TMath::Power(fakes->GetBinError(i), 2)
+ TMath::Power(fakes->GetBinContent(i)*myFakesRelUncert, 2);
hExpBkgTotalUncert->SetBinError(i, TMath::Sqrt(myQCDTotalUncert + myEWKTotalUncert + myFakesTotalUncert));
if (hExpBkg->GetBinContent(i) > 0) {
hAgreementRelUncert->SetPoint(i-1, hExpBkg->GetBinCenter(i), data->GetBinContent(i) / hExpBkg->GetBinContent(i));
double myUncertData = 0;
if (data->GetBinContent(i) > 0)
myUncertData = TMath::Power(data->GetBinError(i) / data->GetBinContent(i), 2);
double myUncertBkg = (myQCDTotalUncert + myEWKTotalUncert + myFakesTotalUncert) / TMath::Power(hExpBkg->GetBinContent(i), 2);
hAgreementRelUncert->SetPointError(i-1, 0, data->GetBinContent(i) / hExpBkg->GetBinContent(i) * TMath::Sqrt(myUncertData + myUncertBkg));
} else {
hAgreementRelUncert->SetPoint(i-1, hExpBkg->GetBinCenter(i), 0);
hAgreementRelUncert->SetPointError(i-1, 0, 0);
}
if (debug) {
cout << "Point: " << hAgreementRelUncert->GetX()[i-1]-10 << "-" << hAgreementRelUncert->GetX()[i-1]+10
<< " GeV/c2, agreement: " << hAgreementRelUncert->GetY()[i-1] << ", uncert: " << hAgreement->GetBinError(i) << ", " << hAgreementRelUncert->GetErrorY(i-1) << endl;
cout << " bkg. stat. uncert. " << hExpBkg->GetBinError(i) << " (i.e. " << hExpBkg->GetBinError(i) / hExpBkg->GetBinContent(i) * 100.0 << " %)"
<< ", stat+syst uncert. " << TMath::Sqrt(myQCDTotalUncert + myEWKTotalUncert + myFakesTotalUncert)
<< " (i.e. " << TMath::Sqrt(myQCDTotalUncert + myEWKTotalUncert + myFakesTotalUncert) / hExpBkg->GetBinContent(i) * 100.0 << " %)" << endl;
}
}
// Agreement pad
TPad* pad = new TPad("ratiopad","ratiopad",0.,0.,1.,.3);
pad->Draw();
pad->cd();
pad->Range(0,0,1,1);
pad->SetFillColor(0);
pad->SetFillStyle(4000);
pad->SetBorderMode(0);
pad->SetBorderSize(2);
pad->SetTickx(1);
pad->SetTicky(1);
pad->SetLeftMargin(0.16);
pad->SetRightMargin(0.05);
pad->SetTopMargin(0);
pad->SetBottomMargin(0.34);
pad->SetFrameFillStyle(0);
pad->SetFrameBorderMode(0);
// Plot here ratio
if (1.0-delta > 0)
hAgreement->SetMinimum(1.0-delta);
else
hAgreement->SetMinimum(0.);
hAgreement->SetMaximum(1.0+delta);
hAgreement->GetXaxis()->SetLabelOffset(0.007);
hAgreement->GetXaxis()->SetLabelFont(43);
hAgreement->GetXaxis()->SetLabelSize(27);