本文整理汇总了C++中TPaveText::SetFillStyle方法的典型用法代码示例。如果您正苦于以下问题:C++ TPaveText::SetFillStyle方法的具体用法?C++ TPaveText::SetFillStyle怎么用?C++ TPaveText::SetFillStyle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPaveText
的用法示例。
在下文中一共展示了TPaveText::SetFillStyle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showEfficiency
//.........这里部分代码省略.........
yAxis->SetTitleOffset(yAxisOffset);
dummyHistogram->Draw();
int colors[6] = { 1, 2, 3, 4, 6, 7 };
int markerStyles[6] = { 22, 32, 20, 24, 21, 25 };
int numGraphs = 1;
if ( histogram2_numerator && histogram2_denominator ) ++numGraphs;
if ( histogram3_numerator && histogram3_denominator ) ++numGraphs;
if ( histogram4_numerator && histogram4_denominator ) ++numGraphs;
if ( histogram5_numerator && histogram5_denominator ) ++numGraphs;
if ( histogram6_numerator && histogram6_denominator ) ++numGraphs;
TLegend* legend = new TLegend(legendX0, legendY0, legendX0 + 0.18, legendY0 + 0.05*numGraphs, "", "brNDC");
legend->SetBorderSize(0);
legend->SetFillColor(0);
TGraphAsymmErrors* graph1 = getEfficiency(histogram1_numerator, histogram1_denominator);
graph1->SetLineColor(colors[0]);
graph1->SetMarkerColor(colors[0]);
graph1->SetMarkerStyle(markerStyles[0]);
graph1->Draw("p");
legend->AddEntry(graph1, legendEntry1.data(), "p");
TGraphAsymmErrors* graph2 = 0;
if ( histogram2_numerator && histogram2_denominator ) {
graph2 = getEfficiency(histogram2_numerator, histogram2_denominator);
graph2->SetLineColor(colors[1]);
graph2->SetMarkerColor(colors[1]);
graph2->SetMarkerStyle(markerStyles[1]);
graph2->Draw("p");
legend->AddEntry(graph2, legendEntry2.data(), "p");
}
TGraphAsymmErrors* graph3 = 0;
if ( histogram3_numerator && histogram3_denominator ) {
graph3 = getEfficiency(histogram3_numerator, histogram3_denominator);
graph3->SetLineColor(colors[2]);
graph3->SetMarkerColor(colors[2]);
graph3->SetMarkerStyle(markerStyles[2]);
graph3->Draw("p");
legend->AddEntry(graph3, legendEntry3.data(), "p");
}
TGraphAsymmErrors* graph4 = 0;
if ( histogram4_numerator && histogram4_denominator ) {
graph4 = getEfficiency(histogram4_numerator, histogram4_denominator);
graph4->SetLineColor(colors[3]);
graph4->SetMarkerColor(colors[3]);
graph4->SetMarkerStyle(markerStyles[3]);
graph4->Draw("p");
legend->AddEntry(graph4, legendEntry4.data(), "p");
}
TGraphAsymmErrors* graph5 = 0;
if ( histogram5_numerator && histogram5_denominator ) {
graph5 = getEfficiency(histogram5_numerator, histogram5_denominator);
graph5->SetLineColor(colors[4]);
graph5->SetMarkerColor(colors[4]);
graph5->SetMarkerStyle(markerStyles[4]);
graph5->Draw("p");
legend->AddEntry(graph5, legendEntry5.data(), "p");
}
TGraphAsymmErrors* graph6 = 0;
if ( histogram6_numerator && histogram6_denominator ) {
graph6 = getEfficiency(histogram6_numerator, histogram6_denominator);
graph6->SetLineColor(colors[5]);
graph6->SetMarkerColor(colors[5]);
graph6->SetMarkerStyle(markerStyles[5]);
graph6->Draw("p");
legend->AddEntry(graph6, legendEntry6.data(), "p");
}
legend->Draw();
TPaveText* label = 0;
if ( title.Length() > 0 ) {
label = new TPaveText(0.175, 0.925, 0.48, 0.98, "NDC");
label->AddText(title.Data());
label->SetTextAlign(13);
label->SetTextSize(0.045);
label->SetFillStyle(0);
label->SetBorderSize(0);
label->Draw();
}
canvas->Update();
size_t idx = outputFileName.find_last_of('.');
std::string outputFileName_plot = std::string(outputFileName, 0, idx);
if ( idx != std::string::npos ) canvas->Print(std::string(outputFileName_plot).append(std::string(outputFileName, idx)).data());
canvas->Print(std::string(outputFileName_plot).append(".png").data());
canvas->Print(std::string(outputFileName_plot).append(".pdf").data());
delete legend;
delete label;
delete dummyHistogram;
delete canvas;
}
示例2: ptPlots
//.........这里部分代码省略.........
cSingle->cd(2)->SetTicks(0,1);
single1->SetStats(kFALSE);
single1->SetTitle("");
single1->GetYaxis()->SetTitleOffset(1.50);
single1->GetYaxis()->SetLabelSize(0.05);
single1->GetYaxis()->SetTitleSize(0.06);
single1->GetYaxis()->SetTitleFont(42);
single1->GetYaxis()->SetLabelFont(42);
single1->GetYaxis()->SetTitle("Counts / 8 MeV/c^{2}");
single1->GetXaxis()->SetRangeUser(0.61, 1.09);
single1->GetXaxis()->SetLabelSize(0.05);
single1->GetXaxis()->SetTitleSize(0.06);
single1->GetXaxis()->SetLabelFont(42);
single1->GetXaxis()->SetTitleFont(42);
single1->GetXaxis()->SetTitle("K^{-}#pi^{+} invariant mass (GeV/c^{2})");
single1->Draw("E Y+");
single2->SetStats(kFALSE);
single2->GetXaxis()->SetRangeUser(0.61, 1.09);
single2->Draw("SAME E2");
fit1->Draw("SAME");
fit2->Draw("SAME");
fit3->Draw("SAME");
fit5->Draw("SAME");
exec1->Draw();
single1->Draw("E SAME");
exec2->Draw();
//fit7->Draw("SAME");
TPaveText *text = new TPaveText(0.3715, 0.7592, 0.6586, 0.8901, "NDC");
text->AddText("Reconstructed #bar{K}*^{0}");
text->AddText("2.0 < p_{T} < 2.2 GeV/c");
text->SetBorderSize(0);
text->SetFillStyle(0);
text->GetLine(1)->SetTextSizePixels(28);
text->GetLine(0)->SetTextSizePixels(32);
text->Draw();
//Do DECAY part
cSingle->cd(1)->SetMargin(0.1727, 0.0, 0.1326, 0.0977);
cSingle->cd(1)->SetTicks(0,1);
TLegend *singleLegend = new TLegend(0.2048, 0.4223, 0.5884, 0.7400);
singleLegend->AddEntry(fit1, "Mass Dep. Width", "l");
singleLegend->AddEntry(fit2, "#splitline{Mass Dep. Width}{+5% Error}", "l");
singleLegend->AddEntry(fit3, "#splitline{Simple Width}{+5% Error}", "l");
singleLegend->AddEntry(fit5, "#splitline{Fixed #Gamma = 50 MeV/c^{2}}{+5% Error}", "l");
singleLegend->SetTextSizePixels(20);
TLegend *singleLegend2 = new TLegend(0.2430, 0.3351, 0.4940, 0.3892);
singleLegend2->AddEntry(single2, "#splitline{Added Error}{(5% of peak bin)}", "f");
singleLegend2->SetFillStyle(0);
singleLegend2->SetBorderSize(0);
singleLegend2->SetTextSizePixels(20);
decaysingle1->SetStats(kFALSE);
decaysingle1->SetTitle("");
decaysingle1->GetYaxis()->SetTitleOffset(1.50);
decaysingle1->GetYaxis()->SetLabelSize(0.05);
decaysingle1->GetYaxis()->SetTitleSize(0.06);
decaysingle1->GetYaxis()->SetTitleFont(42);
decaysingle1->GetYaxis()->SetLabelFont(42);
decaysingle1->GetYaxis()->SetTitle("Counts / 8 MeV/c^{2}");
decaysingle1->GetXaxis()->SetRangeUser(0.61, 1.09);
decaysingle1->GetXaxis()->SetLabelSize(0.05);
decaysingle1->GetXaxis()->SetTitleSize(0.06);
示例3: SetStyle
//.........这里部分代码省略.........
#else
#ifndef DROP_SIGNAL
VH ->Add(Ztt);
qqH ->Add(VH );
ggH ->Add(qqH);
#endif
#endif
}
/*
Mass plot before and after fit
*/
TCanvas *canv = MakeCanvas("canv", "histograms", 600, 600);
canv->cd();
if(log){ canv->SetLogy(1); }
#if defined MSSM
if(!log){ data->GetXaxis()->SetRange(0, data->FindBin(345)); } else{ data->GetXaxis()->SetRange(0, data->FindBin(UPPER_EDGE)); };
#else
data->GetXaxis()->SetRange(0, data->FindBin(345));
#endif
data->SetNdivisions(505);
data->SetMinimum(min);
#ifndef DROP_SIGNAL
data->SetMaximum(max>0 ? max : std::max(std::max(maximum(data, log), maximum(Ztt, log)), maximum(ggH, log)));
#else
data->SetMaximum(max>0 ? max : std::max(maximum(data, log), maximum(Ztt, log)));
#endif
data->Draw("e");
TH1F* errorBand = (TH1F*)Ztt ->Clone("errorBand");
errorBand ->SetMarkerSize(0);
errorBand ->SetFillColor(1);
errorBand ->SetFillStyle(3013);
errorBand ->SetLineWidth(1);
for(int idx=0; idx<errorBand->GetNbinsX(); ++idx){
if(errorBand->GetBinContent(idx)>0){
std::cout << "Uncertainties on summed background samples: " << errorBand->GetBinError(idx)/errorBand->GetBinContent(idx) << std::endl;
break;
}
}
if(log){
Ztt ->Draw("histsame");
ttbar->Draw("histsame");
EWK ->Draw("histsame");
EWK1 ->Draw("histsame");
Fakes->Draw("histsame");
$DRAW_ERROR
#ifndef DROP_SIGNAL
ggH ->Draw("histsame");
#endif
}
else{
#ifndef DROP_SIGNAL
ggH ->Draw("histsame");
#endif
Ztt ->Draw("histsame");
ttbar->Draw("histsame");
EWK ->Draw("histsame");
EWK1 ->Draw("histsame");
Fakes->Draw("histsame");
$DRAW_ERROR
}
data->Draw("esame");
canv->RedrawAxis();
示例4: extractSignificanceStats
//.........这里部分代码省略.........
cout << "\n\nOBSERVED SIGNIFICANCE" << endl;
cout << "observation: " << vObs[0] << endl;
cout << "bin: " << hObs->GetMaximumBin() << endl;
cout << " --------------- " << endl;
double obsPvalSM = 1-hSM->Integral(0,hObs->GetMaximumBin())/integralSM;
cout << "pvalue SM : " << obsPvalSM << endl;
cout << "signif SM : " << ROOT::Math::normal_quantile_c(obsPvalSM,1.0) << endl;
double obsPvalALT = hALT->Integral(0,hObs->GetMaximumBin())/integralALT;
cout << "pvalue ALT: " << obsPvalALT << endl;
cout << "signif ALT: " << ROOT::Math::normal_quantile_c(obsPvalALT,1.0) << endl<<endl<<endl;
}//end if unblinding
//Plotting
gStyle->SetOptStat(0);
TCanvas *c1=new TCanvas("c","c",500,500);
c1->cd();
//hSM->Rebin(20e7/ntoysSM);
//hALT->Rebin(20e7/ntoysALT);
hSM->Rebin(rebin);
hALT->Rebin(rebin);
TString xtitle=" -2 #times ln(L_{"+legALT+"} / L_{0^{+}})";
hSM->SetXTitle(xtitle);
hSM->SetYTitle("Probability density");
hALT->SetXTitle(xtitle);
hALT->SetYTitle("Probability density");
hSM->SetLineColor(kRed+2);
hSM->SetLineStyle(2);
hSM->SetFillColor(798);
hSM->SetLineWidth(2);
hALT->SetFillColor(kAzure+7);
hALT->SetLineColor(kBlue);
hALT->SetLineWidth(1);
hALT->SetFillStyle(3001);
hObs->SetLineColor(kRed);
hObs->SetLineWidth(2);
hSM->GetXaxis()->SetRangeUser(-30.0,30.0);
hSM->GetXaxis()->SetLabelFont(42);
hSM->GetXaxis()->SetLabelOffset(0.007);
hSM->GetXaxis()->SetLabelSize(0.045);
hSM->GetXaxis()->SetTitleSize(0.05);
hSM->GetXaxis()->SetTitleOffset(1.15);
hSM->GetXaxis()->SetTitleFont(42);
hSM->GetYaxis()->SetLabelFont(42);
hSM->GetYaxis()->SetLabelOffset(0.007);
hSM->GetYaxis()->SetLabelSize(0.045);
hSM->GetYaxis()->SetTitleSize(0.05);
hSM->GetYaxis()->SetTitleOffset(1.8);
hSM->GetYaxis()->SetTitleFont(42);
//TGaxis::SetMaxDigits(2);
hSM->Scale(1./hSM->Integral("width"));
hALT->Scale(1./hALT->Integral("width"));
float maxhSM=hSM->GetBinContent(hSM->GetMaximumBin());
float maxhALT=hALT->GetBinContent(hALT->GetMaximumBin());
if(maxhALT>maxhSM){
hSM->SetMaximum(maxhALT*1.3);
hALT->SetMaximum(maxhALT*1.3);
}
else{
hSM->SetMaximum(maxhSM*1.3);
hALT->SetMaximum(maxhSM*1.3);
}
TH1F* hSM2= (TH1F*)(hSM->Clone("hSM2"));
示例5: plot3
//.........这里部分代码省略.........
NPplot->SetLineStyle(2);
NPplot->SetMarkerStyle(20);
NPplot->SetMarkerSize(0.4);
SMplot->SetMarkerStyle(20);
SMplot->SetMarkerSize(0.4);
if(strpltmd.compare("cos") == 0) {yMin = 0.0; yMax = 1.0;}
if(strpltmd.compare("sin") == 0) {yMin = 0.0; yMax = 1.0;}
if(strpltmd.compare("mmp") == 0) {xMin = 0.0; xMax = 5.0; yMin = 0.0; yMax = 5;}
TH1F* frame = MyC->DrawFrame(0.9*xMin,0.9*yMin,1.1*xMax,1.0*yMax);
frame->SetTitle(plottitle.c_str());
TAxis *xaxis = frame->GetXaxis();
TAxis *yaxis = frame->GetYaxis();
xaxis->SetTitle(xtitle.c_str());
xaxis->CenterTitle();
xaxis->SetTitleOffset(1.);
xaxis->SetDecimals();
xaxis->SetLabelSize(0.03);
xaxis->SetLabelOffset(0.01);
yaxis->SetTitle(ytitle.c_str());
yaxis->CenterTitle();
yaxis->SetTitleOffset(1.2);
yaxis->SetDecimals();
yaxis->SetLabelSize(0.03);
yaxis->SetLabelOffset(0.01);
TLegend *mmleg = new TLegend(mmlegxmin,mmlegymin,mmlegxmax,mmlegymax);
mmleg->AddEntry(NPplot,NPleg.c_str(),"l");
mmleg->AddEntry(SMplot,SMleg.c_str(),"l");
mmleg->SetTextSize(0.025);
mmleg->SetFillStyle(0);
if( (strfile.compare("uu-d") != 0) && (strfile.compare("nu-d") != 0) ) {
for(tphStep=0; tphStep<tphSteps; tphStep++){NPmrk[tphStep]->Draw(); SMmrk[tphStep]->Draw();}
}
Float_t xdummy[1] = {0.0}, ydummy[1] = {0.0};
TGraph *circle = new TGraph(1,xdummy,ydummy);
circle->SetMarkerStyle(24);
circle->SetMarkerColor(kGreen+1);
circle->SetMarkerSize(0.8);
TGraph *square = new TGraph(1,xdummy,ydummy);
square->SetMarkerStyle(25);
square->SetMarkerColor(kCyan+1);
square->SetMarkerSize(0.8);
TGraph *triangle = new TGraph(1,xdummy,ydummy);
triangle->SetMarkerStyle(26);
triangle->SetMarkerColor(kBlue+1);
triangle->SetMarkerSize(0.8);
TGraph *diamond = new TGraph(1,xdummy,ydummy);
diamond->SetMarkerStyle(27);
diamond->SetMarkerColor(kMagenta+1);
diamond->SetMarkerSize(0.8);
TLegend *s2bleg = new TLegend(s2blegxmin,s2blegymin,s2blegxmax,s2blegymax);
s2bleg->AddEntry(circle,"#font[42]{0.00 < sin^{2}(2#tilde{#beta}) #leq 0.25}","p");
示例6: TCanvas
//.........这里部分代码省略.........
}
cout << "Drawing -1s" << endl;
contLevel = m_contours["-1s"];
curv = (TGraph*)(contLevel->First());
for (int i=0; i<contLevel->GetSize(); i++) {
curv->SetLineColor(kYellow);
curv->SetFillColor(kYellow);
curv->Draw("SAME CF");
curv=(TGraph *)(contLevel->After(curv));
}
cout << "Drawing -2s" << endl;
contLevel = m_contours["-2s"];
if (!contLevel)
// this can happen more often for this contour if there is insufficient
// sensitivity close to the SM
cerr << "No contour level for +2s, have to fill in the central region" << endl;
else {
curv = (TGraph*)(contLevel->First());
for (int i=0; i<contLevel->GetSize(); i++) {
curv->SetFillColor(kWhite);
curv->SetLineColor(kYellow);
curv->Draw("SAME CF");
curv=(TGraph *)(contLevel->After(curv));
}
}
cout << "Drawing median" << endl;
curv = (TGraph*)(m_contours["median"]->First());
curv->SetLineColor(kBlack);
curv->SetLineWidth(2);
curv->SetLineStyle(2);
curv->Draw("SAME C");
legend->AddEntry(curv,"Expected","L");
cout << "Drawing obs" << endl;
contLevel = m_contours["obs"];
curv = (TGraph*)(contLevel->First());
for (int i=0; i<contLevel->GetSize(); i++) {
curv->SetLineColor(kBlack);
curv->SetLineWidth(2);
curv->Draw("SAME C");
if (!i) legend->AddEntry(curv,"Observed","L");
curv=(TGraph *)(contLevel->After(curv));
}
TGraph *SMpoint = new TGraph(1);
SMpoint->SetPoint(1,0,0);
SMpoint->Draw("SAME Po");
// smLabel = TPaveText(0,
// m_contours["-2s"]->GetYaxis()->GetXmax()/8,
// m_contours["-2s"]->GetXaxis()->GetXmax()/3->5,
// -m_contours["-2s"]->GetYaxis()->GetXmax()/8);
// smLabel->SetFillStyle(0);
// smLabel->SetBorderSize(0);
// smLabel->AddText(" SM");
// smLabel->Draw();
legend->Draw();
TPaveText *text = new TPaveText(0.566,0.87,0.965,1.101,"NDC");
text->SetFillStyle(0);
text->SetBorderSize(0);
text->AddText(Form("95%% CL Limit on %s and %s",par2latex(par1).Data(),par2latex(par2).Data()));
text->AddText(0,0.35,Form("#intL dt= %.1f fb^{-1}, #sqrt{s} = %d TeV",intlumifbinv,beamcometev));
text->Draw();
// text2 = TPaveText(0.155,0.199,0.974,0.244,"NDC");
// text2->SetFillStyle(0);
// text2->SetBorderSize(0);
// text2->AddText("Values outside contour excluded");
// text2->Draw();
//text3 = TPaveText(0.506,0.699,0.905,0.758,"NDC");
//text3->SetFillStyle(0);
//text3->SetBorderSize(0);
//text3->AddText(options.flavorText);
//text3->Draw();
finalPlot->RedrawAxis();
finalPlot->ResetAttPad();
finalPlot->Update();
finalPlot->Draw();
finalPlot->Update();
finalPlot->Modified();
finalPlot->Update();
finalPlot->Print(Form("%s.pdf",plotprefix.Data()));
finalPlot->Print(Form("%s.eps",plotprefix.Data()));
finalPlot->Print(Form("%s.png",plotprefix.Data()));
} // draw2DlimitBFstyle
示例7: m
std::pair<double, double> fit_mass(RooDataSet* ds, string oFile, string cut, string massvar = "Z_M"){
RooRealVar m( massvar.c_str(), massvar.c_str(), 60., 120. );
RooPlot* plot = m.frame();
// Breit Wigner - Z Lineshape
RooRealVar m0( "m0", "m0", 0 );
RooRealVar width( "width", "width", 1.5, 0, 5 );
RooBreitWigner bw( "gauss", "gauss", m, m0, width );
// Crystal-Ball - Detector response + FSR
RooRealVar mean( "mean", "mean", 90.3, 70, 110 );
RooRealVar sigma( "sigma", "sigma", 0.5, 0, 5);
RooRealVar alpha( "alpha", "alpha", 2.2, 0.01, 5 );
RooRealVar n( "n", "n", 1, 0.01, 80 );
RooCBShape cb( "cb", "cb", m, mean, sigma, alpha, n );
//exponential - DY component + background
RooRealVar lambda("lambda", "slope", -2e-2, -30., 0.);
RooExponential expo("expo", "exponential PDF", m, lambda);
//Set cache for FFT convolution
m.setBins(10000, "cache");
m.setMin("cache", 50.5);
m.setMax("cache", 129.5);
//convolve PDFs
RooFFTConvPdf pdf( "pdf", "pdf", m, cb, bw );
//Background fraction
RooRealVar b("b", "background", 0.7, 0, 1);
RooAddPdf sum("sum", "crystal ball + gaussian + expo", RooArgList(pdf, expo), RooArgList(b));
//sum.fitTo(*ds, RooFit::Extended());
sum.fitTo(*ds);
//Make mass plot
TCanvas* canv = new TCanvas( "canv", "canv", 800.0, 600.0 );
plot -> GetXaxis() -> SetTitle( "M_{#mu#mu} [GeV]" );
plot -> GetYaxis() -> SetTitleOffset( 1.5 );
ds->plotOn( plot );
sum.plotOn(plot);
//print chi2 on plot and add tpavetext
ostringstream sstream;
sstream<<"#chi^{2}/nDoF = "<<plot->chiSquare();
TPaveText* p = new TPaveText(0.15, 0.7, 0.5, 0.9, "NDC");
p->SetFillStyle(0);
p->SetBorderSize(0.0);
plot->addObject(p);
p->AddText(cut.c_str());
p->AddText(sstream.str().c_str());
plot->Draw();
p->Draw();
canv->SaveAs( ("BWxCB_"+oFile+".pdf").c_str() );
// return as pair with value and error of mean
std::pair<double, double> a(mean.getVal(), mean.getError());
return a;
}
示例8: makeGenLevel_pTRatios
//.........这里部分代码省略.........
TF1* fitratio;
if (p != 4){
fitratio = new TF1(Form("%s_fit", hratio_pt[p - 1]->GetName()), "([0]-[1]*exp(-pow(x/[2],2)))*exp(-x/[3])", hratio_pt[p - 1]->GetXaxis()->GetXmin(), hratio_pt[p - 1]->GetXaxis()->GetXmax());
if (p==1) fitratio->SetParameters(8.76, 8.69, 0.98, 4.3);
else fitratio->SetParameters(8.76, 8.69, 0.98, -24);
}
else{
fitratio = new TF1(Form("%s_fit", hratio_pt[p - 1]->GetName()), "([0]-[1]*exp(-pow(x/[2],2)))", hratio_pt[p - 1]->GetXaxis()->GetXmin(), hratio_pt[p - 1]->GetXaxis()->GetXmax());
fitratio->SetParameters(4.2, 4.0, 0.7);
}
fitratio->SetParameters(6, 5.77, 1, 5);
fitratio->SetTitle("");
fitratio->SetLineColor(hratio_pt[p - 1]->GetLineColor());
fitratio->SetLineStyle(7);
fitratio->SetLineWidth(3);
hratio_pt[p - 1]->GetYaxis()->SetRangeUser(1e-3, 1000);
tgratio_pt[p - 1]->Fit(fitratio, "N");
cout << "Writing ratio fit at " << p << endl;
foutput->WriteTObject(fitratio);
cout << "Writing ratio at " << p << endl;
foutput->WriteTObject(hratio_pt[p - 1]);
foutput->WriteTObject(tgratio_pt[p - 1]);
fratio_pt[p - 1] = fitratio;
}
}
foutput->cd();
gStyle->SetTitleFont(62, "t");
gROOT->SetStyle(gStyle->GetName());
gROOT->ForceStyle();
TPaveText* pt = new TPaveText(0.15, 0.93, 0.85, 1, "brNDC");
pt->SetBorderSize(0);
pt->SetFillStyle(0);
pt->SetTextAlign(12);
pt->SetTextFont(42);
pt->SetTextSize(0.045);
TText* text = pt->AddText(0.025, 0.45, "#font[61]{CMS}");
text->SetTextSize(0.044);
text = pt->AddText(0.165, 0.42, "#font[52]{Simulation}");
text->SetTextSize(0.0315);
if (erg_tev==8) text = pt->AddText(0.837, 0.45, "#font[42]{ 8 TeV}");
else if (erg_tev==7) text = pt->AddText(0.837, 0.45, "#font[42]{ 7 TeV}");
// if (erg_tev==7) text = pt->AddText(0.837, 0.45, "#font[42]{5.1 fb^{-1} (7 TeV)}");
text->SetTextSize(0.0315);
TString canvasname_2D = Form("cCompare_SignalProductionMC_AllChannels_%iTeV", erg_tev);
canvasname_2D.Append(Form("_%s_ratio", csuffix));
TCanvas* c2D = new TCanvas(canvasname_2D, "", 8, 30, 800, 800);
c2D->cd();
gStyle->SetOptStat(0);
c2D->SetFillColor(0);
c2D->SetBorderMode(0);
c2D->SetBorderSize(2);
c2D->SetTickx(1);
c2D->SetTicky(1);
// c2D->SetLogy();
c2D->SetLeftMargin(0.17);
c2D->SetRightMargin(0.05);
c2D->SetTopMargin(0.07);
c2D->SetBottomMargin(0.13);
c2D->SetFrameFillStyle(0);
c2D->SetFrameBorderMode(0);
c2D->SetFrameFillStyle(0);
c2D->SetFrameBorderMode(0);
示例9: plot_BSM_MCFM
//.........这里部分代码省略.........
}
double maxplot=0;
for (int t=0; t<4; t++){
for (int ac=0; ac<9; ac++){
if (SignalOnly==0 && ac<5) maxplot = max(maxplot, hfill[t][ac]->GetMaximum());
else if (SignalOnly==1 && !(ac<5 && ac>0) && t==0) maxplot = max(maxplot, hfill[t][ac]->GetMaximum());
hfill[t][ac]->SetLineWidth(2);
if (t==0 && ac>=5){
hfill[t][ac]->SetLineStyle(7);
// hfill[t][ac]->Add(hfill[1][ac]);
}
if (t==1) hfill[t][ac]->SetLineStyle(3);
if (t==3) hfill[t][ac]->SetLineStyle(9);
hfill[t][ac]->GetXaxis()->SetLabelFont(42);
hfill[t][ac]->GetXaxis()->SetLabelOffset(0.007);
hfill[t][ac]->GetXaxis()->SetLabelSize(0.04);
hfill[t][ac]->GetXaxis()->SetTitleSize(0.06);
hfill[t][ac]->GetXaxis()->SetTitleOffset(0.9);
hfill[t][ac]->GetXaxis()->SetTitleFont(42);
hfill[t][ac]->GetYaxis()->SetNdivisions(505);
hfill[t][ac]->GetYaxis()->SetLabelFont(42);
hfill[t][ac]->GetYaxis()->SetLabelOffset(0.007);
hfill[t][ac]->GetYaxis()->SetLabelSize(0.04);
hfill[t][ac]->GetYaxis()->SetTitleSize(0.06);
hfill[t][ac]->GetYaxis()->SetTitleOffset(1.1);
hfill[t][ac]->GetYaxis()->SetTitleFont(42);
}
}
TPaveText* pt = new TPaveText(0.15, 0.93, 0.85, 1, "brNDC");
pt->SetBorderSize(0);
pt->SetFillStyle(0);
pt->SetTextAlign(12);
pt->SetTextFont(42);
pt->SetTextSize(0.045);
TText* text = pt->AddText(0.025, 0.45, "#font[61]{CMS}");
text->SetTextSize(0.044);
text = pt->AddText(0.165, 0.42, "#font[52]{Simulation}");
text->SetTextSize(0.0315);
TString cErgTev = "#font[42]{19.7 fb^{-1} (8 TeV) + 5.1 fb^{-1} (7 TeV)}";
text = pt->AddText(0.537, 0.45, cErgTev);
text->SetTextSize(0.0315);
float lxmin = 0.22;
float lxwidth = 0.38;
float lymax = 0.9;
float lywidth = 0.3;
float lxmax = lxmin + lxwidth;
float lymin = lymax;
if (SignalOnly==0) lymin -= lywidth*4./5.;
else lymin -= lywidth;
float lxmin2 = 0.22+0.39;
float lymax2 = lymax;
float lxmax2 = lxmin2 + lxwidth;
float lymin2 = lymax2;
if (SignalOnly==0) lymin2 -= lywidth*2./5.;
else lymin2 -= lywidth*4./5.;
if (SignalOnly==1){
float lxmin3 = lxmin2;
float lymax3 = lymax2;
float lxmax3 = lxmax2;
float lymin3 = lymin2;
示例10: picture2
//.........这里部分代码省略.........
Graph_Graph13->GetXaxis()->SetTitleFont(42);
Graph_Graph13->GetYaxis()->SetLabelFont(42);
Graph_Graph13->GetYaxis()->SetLabelSize(0.035);
Graph_Graph13->GetYaxis()->SetTitleSize(0.035);
Graph_Graph13->GetYaxis()->SetTitleFont(42);
Graph_Graph13->GetZaxis()->SetLabelFont(42);
Graph_Graph13->GetZaxis()->SetLabelSize(0.035);
Graph_Graph13->GetZaxis()->SetTitleSize(0.035);
Graph_Graph13->GetZaxis()->SetTitleFont(42);
graph->SetHistogram(Graph_Graph13);
graph->Draw("p");
Double_t _fx14[1] = {
801.6865};
Double_t _fy14[1] = {
111.6076};
graph = new TGraph(1,_fx14,_fy14);
graph->SetName("");
graph->SetTitle("");
graph->SetFillColor(1);
ci = TColor::GetColor("#00ff00");
graph->SetMarkerColor(ci);
graph->SetMarkerStyle(20);
TH1F *Graph_Graph_Graph1314 = new TH1F("Graph_Graph_Graph1314","",100,801.5865,802.7865);
Graph_Graph_Graph1314->SetMinimum(-120);
Graph_Graph_Graph1314->SetMaximum(120);
Graph_Graph_Graph1314->SetDirectory(0);
Graph_Graph_Graph1314->SetStats(0);
ci = TColor::GetColor("#000099");
Graph_Graph_Graph1314->SetLineColor(ci);
Graph_Graph_Graph1314->GetXaxis()->SetRange(0,101);
Graph_Graph_Graph1314->GetXaxis()->SetLabelFont(42);
Graph_Graph_Graph1314->GetXaxis()->SetLabelSize(0.035);
Graph_Graph_Graph1314->GetXaxis()->SetTitleSize(0.035);
Graph_Graph_Graph1314->GetXaxis()->SetTitleFont(42);
Graph_Graph_Graph1314->GetYaxis()->SetLabelFont(42);
Graph_Graph_Graph1314->GetYaxis()->SetLabelSize(0.035);
Graph_Graph_Graph1314->GetYaxis()->SetTitleSize(0.035);
Graph_Graph_Graph1314->GetYaxis()->SetTitleFont(42);
Graph_Graph_Graph1314->GetZaxis()->SetLabelFont(42);
Graph_Graph_Graph1314->GetZaxis()->SetLabelSize(0.035);
Graph_Graph_Graph1314->GetZaxis()->SetTitleSize(0.035);
Graph_Graph_Graph1314->GetZaxis()->SetTitleFont(42);
graph->SetHistogram(Graph_Graph_Graph1314);
graph->Draw("p");
Double_t _fx15[1] = {
823.7501};
Double_t _fy15[1] = {
86.87169};
graph = new TGraph(1,_fx15,_fy15);
graph->SetName("");
graph->SetTitle("");
graph->SetFillColor(1);
ci = TColor::GetColor("#ff0000");
graph->SetMarkerColor(ci);
graph->SetMarkerStyle(20);
TH1F *Graph_Graph15 = new TH1F("Graph_Graph15","",100,823.6501,824.8501);
Graph_Graph15->SetMinimum(-120);
Graph_Graph15->SetMaximum(120);
Graph_Graph15->SetDirectory(0);
Graph_Graph15->SetStats(0);
ci = TColor::GetColor("#000099");
Graph_Graph15->SetLineColor(ci);
Graph_Graph15->GetXaxis()->SetLabelFont(42);
Graph_Graph15->GetXaxis()->SetLabelSize(0.035);
Graph_Graph15->GetXaxis()->SetTitleSize(0.035);
Graph_Graph15->GetXaxis()->SetTitleFont(42);
Graph_Graph15->GetYaxis()->SetLabelFont(42);
Graph_Graph15->GetYaxis()->SetLabelSize(0.035);
Graph_Graph15->GetYaxis()->SetTitleSize(0.035);
Graph_Graph15->GetYaxis()->SetTitleFont(42);
Graph_Graph15->GetZaxis()->SetLabelFont(42);
Graph_Graph15->GetZaxis()->SetLabelSize(0.035);
Graph_Graph15->GetZaxis()->SetTitleSize(0.035);
Graph_Graph15->GetZaxis()->SetTitleFont(42);
graph->SetHistogram(Graph_Graph15);
graph->Draw("p");
TPaveText *pt = new TPaveText(0.4189298,0.94,0.5810702,0.995,"blNDC");
pt->SetName("title");
pt->SetBorderSize(0);
pt->SetFillColor(0);
pt->SetFillStyle(0);
pt->SetTextFont(42);
TText *AText = pt->AddText("Event 2");
pt->Draw();
c->Modified();
c->cd();
c->SetSelected(c);
}
示例11: getExtrapolFak
TCanvas* getExtrapolFak(TString plotName, TString label, int verbose, TString outputFileFull, TString outputFileParton, TString outputFileHadron){
// ============================
// Set Root Style
// ============================
TStyle myStyle("HHStyle","HHStyle");
setHHStyle(myStyle);
TGaxis::SetMaxDigits(2);
myStyle.cd();
gROOT->SetStyle("HHStyle");
// open files
TFile* fileFull = TFile::Open(outputFileFull , "READ");
TFile* fileParton = TFile::Open(outputFileParton, "READ");
TFile* fileHadron = TFile::Open(outputFileHadron, "READ");
// dont associate new objects with file to be able to close it in the end
gROOT->cd();
// get canvas^3 for chosen cross section
TCanvas* canvasFull = (TCanvas*)(fileFull ->Get("xSec/sysNo/"+plotName+"Norm")->Clone());
TCanvas* canvasParton = (TCanvas*)(fileParton->Get("xSec/sysNo/"+plotName+"Norm")->Clone());
TCanvas* canvasHadron = (TCanvas*)(fileHadron->Get("xSec/sysNo/"+plotName+"Norm")->Clone());
// get data histos
TH1F* dataFull = killEmptyBins((TH1F*)((canvasFull ->GetPrimitive(plotName+"kData"))->Clone()));
TH1F* dataRawParton = killEmptyBins((TH1F*)((canvasParton->GetPrimitive(plotName+"kData"))->Clone()));
TH1F* dataRawHadron = killEmptyBins((TH1F*)((canvasHadron->GetPrimitive(plotName+"kData"))->Clone()));
// use always the correct PS definition:
// hadron level for b-quarks and lepton
// parton level for all others
TH1F* dataPS = ( (plotName.Contains("bq")||plotName.Contains("lep")) ? (TH1F*)dataRawHadron->Clone() : (TH1F*)dataRawParton->Clone() );
// adjust style and labels
TString PSlabel = ( (plotName.Contains("bq")||plotName.Contains("lep")) ? "hadron" : "parton" );
int color = kBlue;
if(PSlabel=="hadron") color-=4;
dataPS->SetLineColor(color);
dataPS->SetMarkerColor(color);
histogramStyle(*dataFull, kData);
dataFull->SetLineWidth(3);
dataPS->SetLineWidth(3);
if (plotName=="lepPt") dataFull->GetXaxis()->SetRangeUser(0.,199.);
else if(plotName=="bqPt" ) dataFull->GetXaxis()->SetRangeUser(0.,399.);
else setXAxisRange(dataFull, plotName);
double max=dataFull->GetMaximum();
if(max<dataPS->GetMaximum()) max=dataPS->GetMaximum();
dataFull->SetMaximum(1.3*max);
dataFull->GetXaxis()->SetTitle(xSecLabelName(plotName));
TString label2=label;
TString label3="";
if(label.Contains("/[GeV]")){
label2.ReplaceAll("/[GeV]","");
label3=" / [GeV]";
}
label2.ReplaceAll("/ ","");
dataFull->GetYaxis()->SetTitle("#frac{1}{#sigma} #frac{d#sigma}{d"+label2+"}"+label3);
dataFull->GetYaxis()->SetNoExponent(false);
dataFull->GetXaxis()->SetNoExponent(true);
dataFull->SetTitle("");
// create legend
TLegend *leg0 = new TLegend(0.65, 0.762, 0.95, 0.89);
leg0->SetFillStyle(0);
leg0->SetBorderSize(0);
leg0->SetHeader("phase spaces");
leg0->AddEntry(dataFull, "extrapol. parton lv","L");
leg0->AddEntry(dataPS , "restricted "+PSlabel+" lv","L");
// create label
TPaveText *headerlabel = new TPaveText();
headerlabel -> SetX1NDC(gStyle->GetPadLeftMargin());
headerlabel -> SetY1NDC(1.0-gStyle->GetPadTopMargin());
headerlabel -> SetX2NDC(1.0-gStyle->GetPadRightMargin());
headerlabel -> SetY2NDC(1.0);
headerlabel -> SetTextFont(42);
headerlabel -> AddText("comparing 2011 data results");
headerlabel->SetFillStyle(0);
headerlabel->SetBorderSize(0);
headerlabel->SetTextSize(0.04);
headerlabel->SetTextAlign(32);
// create extrapolation factor / ratio canvas
std::vector<TCanvas*> plotCanvas_;
addCanvas(plotCanvas_);
plotCanvas_[0]->cd();
plotCanvas_[0]->Draw();
dataFull->Draw("hist");
dataPS->Draw("hist same");
leg0->Draw("same");
headerlabel->Draw("same");
DrawDecayChLabel("e/#mu + Jets Combined");
drawRatio(dataPS, dataFull, 0., 2.4, myStyle, verbose, std::vector<double>(0), PSlabel+" PS", "extrapolated", "hist", kBlack);
// close files
fileFull ->Close();
fileParton->Close();
fileHadron->Close();
// return
//.........这里部分代码省略.........
示例12: showGraphs
void showGraphs(const TString& title, double canvasSizeX, double canvasSizeY,
TGraph* graph1, const std::string& legendEntry1,
TGraph* graph2, const std::string& legendEntry2,
TGraph* graph3, const std::string& legendEntry3,
TGraph* graph4, const std::string& legendEntry4,
TGraph* graph5, const std::string& legendEntry5,
TGraph* graph6, const std::string& legendEntry6,
double xMin, double xMax, unsigned numBinsX, const std::string& xAxisTitle, double xAxisOffset,
double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset,
double legendX0, double legendY0,
const std::string& outputFileName)
{
TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY);
canvas->SetFillColor(10);
canvas->SetBorderSize(2);
canvas->SetLeftMargin(0.12);
canvas->SetBottomMargin(0.12);
int colors[6] = { 1, 2, 3, 4, 6, 7 };
int markerStyles[6] = { 22, 32, 20, 24, 21, 25 };
TLegend* legend = new TLegend(legendX0, legendY0, legendX0 + 0.44, legendY0 + 0.20, "", "brNDC");
legend->SetBorderSize(0);
legend->SetFillColor(0);
TH1* dummyHistogram = new TH1D("dummyHistogram", "dummyHistogram", numBinsX, xMin, xMax);
dummyHistogram->SetTitle("");
dummyHistogram->SetStats(false);
dummyHistogram->SetMinimum(yMin);
dummyHistogram->SetMaximum(yMax);
TAxis* xAxis = dummyHistogram->GetXaxis();
xAxis->SetTitle(xAxisTitle.data());
xAxis->SetTitleOffset(xAxisOffset);
TAxis* yAxis = dummyHistogram->GetYaxis();
yAxis->SetTitle(yAxisTitle.data());
yAxis->SetTitleOffset(yAxisOffset);
dummyHistogram->Draw("axis");
graph1->SetLineColor(colors[0]);
graph1->SetLineWidth(2);
graph1->Draw("L");
legend->AddEntry(graph1, legendEntry1.data(), "l");
if ( graph2 ) {
graph2->SetLineColor(colors[1]);
graph2->SetLineWidth(2);
graph2->Draw("L");
legend->AddEntry(graph2, legendEntry2.data(), "l");
}
if ( graph3 ) {
graph3->SetLineColor(colors[2]);
graph3->SetLineWidth(2);
graph3->Draw("L");
legend->AddEntry(graph3, legendEntry3.data(), "l");
}
if ( graph4 ) {
graph4->SetLineColor(colors[3]);
graph4->SetLineWidth(2);
graph4->Draw("L");
legend->AddEntry(graph4, legendEntry4.data(), "l");
}
if ( graph5 ) {
graph5->SetLineColor(colors[4]);
graph5->SetLineWidth(2);
graph5->Draw("L");
legend->AddEntry(graph5, legendEntry5.data(), "l");
}
if ( graph6 ) {
graph6->SetLineColor(colors[5]);
graph6->SetLineWidth(2);
graph6->Draw("L");
legend->AddEntry(graph6, legendEntry6.data(), "l");
}
legend->Draw();
TPaveText* label = 0;
if ( title.Length() > 0 ) {
label = new TPaveText(0.175, 0.925, 0.48, 0.98, "NDC");
label->AddText(title.Data());
label->SetTextAlign(13);
label->SetTextSize(0.045);
label->SetFillStyle(0);
label->SetBorderSize(0);
label->Draw();
}
canvas->Update();
size_t idx = outputFileName.find_last_of('.');
std::string outputFileName_plot = std::string(outputFileName, 0, idx);
if ( idx != std::string::npos ) canvas->Print(std::string(outputFileName_plot).append(std::string(outputFileName, idx)).data());
canvas->Print(std::string(outputFileName_plot).append(".png").data());
canvas->Print(std::string(outputFileName_plot).append(".pdf").data());
//.........这里部分代码省略.........
示例13: showDistribution
//-------------------------------------------------------------------------------
void showDistribution(const TString& title, double canvasSizeX, double canvasSizeY,
TH1* histogram1, const std::string& legendEntry1,
TH1* histogram2, const std::string& legendEntry2,
TH1* histogram3, const std::string& legendEntry3,
TH1* histogram4, const std::string& legendEntry4,
const std::string& xAxisTitle, double xAxisOffset,
bool useLogScale, double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset,
double legendX0, double legendY0,
const std::string& outputFileName)
{
TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY);
canvas->SetFillColor(10);
canvas->SetBorderSize(2);
canvas->SetLeftMargin(0.12);
canvas->SetBottomMargin(0.12);
canvas->SetLogy(useLogScale);
int colors[6] = { 1, 2, 3, 4, 6, 7 };
int markerStyles[6] = { 22, 32, 20, 24, 21, 25 };
int numHistograms = 1;
if ( histogram2 ) ++numHistograms;
if ( histogram3 ) ++numHistograms;
if ( histogram4 ) ++numHistograms;
TLegend* legend = new TLegend(legendX0, legendY0, legendX0 + 0.44, legendY0 + 0.05*numHistograms, "", "brNDC");
legend->SetBorderSize(0);
legend->SetFillColor(0);
histogram1->SetTitle("");
histogram1->SetStats(false);
histogram1->SetMinimum(yMin);
histogram1->SetMaximum(yMax);
histogram1->SetLineColor(colors[0]);
histogram1->SetLineWidth(2);
histogram1->SetMarkerColor(colors[0]);
histogram1->SetMarkerStyle(markerStyles[0]);
histogram1->Draw("e1p");
legend->AddEntry(histogram1, legendEntry1.data(), "p");
TAxis* xAxis = histogram1->GetXaxis();
xAxis->SetTitle(xAxisTitle.data());
xAxis->SetTitleOffset(xAxisOffset);
TAxis* yAxis = histogram1->GetYaxis();
yAxis->SetTitle(yAxisTitle.data());
yAxis->SetTitleOffset(yAxisOffset);
if ( histogram2 ) {
histogram2->SetLineColor(colors[1]);
histogram2->SetLineWidth(2);
histogram2->SetMarkerColor(colors[1]);
histogram2->SetMarkerStyle(markerStyles[1]);
histogram2->Draw("e1psame");
legend->AddEntry(histogram2, legendEntry2.data(), "p");
}
if ( histogram3 ) {
histogram3->SetLineColor(colors[2]);
histogram3->SetLineWidth(2);
histogram3->SetMarkerColor(colors[2]);
histogram3->SetMarkerStyle(markerStyles[2]);
histogram3->Draw("e1psame");
legend->AddEntry(histogram3, legendEntry3.data(), "p");
}
if ( histogram4 ) {
histogram4->SetLineColor(colors[3]);
histogram4->SetLineWidth(2);
histogram4->SetMarkerColor(colors[3]);
histogram4->SetMarkerStyle(markerStyles[3]);
histogram4->Draw("e1psame");
legend->AddEntry(histogram4, legendEntry4.data(), "p");
}
legend->Draw();
TPaveText* label = 0;
if ( title.Length() > 0 ) {
label = new TPaveText(0.175, 0.925, 0.48, 0.98, "NDC");
label->AddText(title.Data());
label->SetTextAlign(13);
label->SetTextSize(0.045);
label->SetFillStyle(0);
label->SetBorderSize(0);
label->Draw();
}
canvas->Update();
size_t idx = outputFileName.find_last_of('.');
std::string outputFileName_plot = std::string(outputFileName, 0, idx);
if ( idx != std::string::npos ) canvas->Print(std::string(outputFileName_plot).append(std::string(outputFileName, idx)).data());
canvas->Print(std::string(outputFileName_plot).append(".png").data());
canvas->Print(std::string(outputFileName_plot).append(".pdf").data());
delete legend;
delete label;
delete canvas;
}
示例14: compare
//.........这里部分代码省略.........
selection->SetAxisRange(MinX, MaxX, "X");
selection->GetYaxis()->SetRangeUser(YRangeMin, YRangeMax);
selection->SetMarkerStyle(20);
selection->SetMarkerSize(0.9);
selection->SetMarkerColor(kBlack);
selection->SetXTitle(xTitle);
selection->SetYTitle(yTitle);
prediction->SetAxisRange(MinX, MaxX, "X");
prediction->GetYaxis()->SetRangeUser(YRangeMin, YRangeMax);
prediction->SetFillColor(c_LightGray);
prediction->SetTitle("");
prediction->SetXTitle(xTitle);
prediction->SetYTitle(yTitle);
background->SetAxisRange(MinX, MaxX, "X");
background->GetYaxis()->SetRangeUser(YRangeMin, YRangeMax);
background->SetTitle("");
background->SetLineColor(kRed);
background->SetLineWidth(2);
background->SetXTitle(xTitle);
background->SetYTitle(yTitle);
TCanvas *c = new TCanvas("ca", "Comparison and ratio of two histos", 700, 700);
TPad *pad1 = new TPad("pad1a", "pad1a", 0, 0.35, 1, 1);
pad1->SetLogy();
pad1->SetBottomMargin(0);
pad1->Draw();
pad1->cd();
prediction->DrawCopy("hist");
selection->Draw("same");
prediction->SetFillColor(kAzure-3);
prediction->SetFillStyle(3354);
prediction->DrawCopy("e2same");
background->Scale(36.1/32.6);
background->Draw("same");
prediction->SetFillStyle(1001);
//prediction->SetFillColor(c_LightBrown);
prediction->SetFillColor(c_LightGray);
//TLegend* leg1 = new TLegend(0.48, 0.63, 0.95, 0.83);
TLegend* leg1 = new TLegend(0.44, 0.63, 0.91, 0.83);
leg1->SetFillStyle(0);
leg1->SetLineStyle(1);
leg1->SetTextFont(42);
//leg1->SetTextSize(0.04);
leg1->SetTextSize(0.045);
leg1->AddEntry(prediction, titlePrediction, "lf");
leg1->AddEntry(selection, titleSelection, "lep");
leg1->AddEntry(background, titleBackground, "l");
leg1->Draw("same");
TPaveText* pt = new TPaveText(0.11, 0.98, 0.95, 0.86, "NDC");
pt->SetBorderSize(0);
pt->SetFillStyle(0);
pt->SetTextAlign(12);
pt->SetTextSize(0.045);
pt->AddText(Title);
pt->AddText(LumiTitle);
pt->Draw();
c->cd();
TPad *pad2 = new TPad("pad2a", "pad2a", 0, 0, 1, 0.35);
pad2->SetTopMargin(0);
pad2->Draw();
pad2->cd();
TH1F* r = new TH1F(*prediction);
r->SetTitle("");
r->SetLabelSize(0.08, "XYZ");
r->SetLabelOffset(0.01, "XYZ");
// r->SetTitleSize(0.09, "XYZ");
r->SetTitleSize(0.125, "XYZ");
r->SetTitleOffset(0.95, "X");
r->SetTitleOffset(0.53, "Y");
// r->SetTitleOffset(0.65, "Y");
r->SetTickLength(0.05);
r->SetYTitle(RatioTitle);
r->SetStats(0);
r->SetMarkerStyle(20);
r->SetMarkerSize(0.9);
r->SetMarkerColor(kBlack);
r->Reset();
r->Add(prediction, 1);
r->Add(background, 1);
r->Add(selection, -1);
r->Divide(selection);
r->SetMaximum(2.2);
r->SetMinimum(-2.2);
r->Draw("ep");
TLine l;
l.DrawLine(MinX, 0., MaxX+BinWidth, 0.);
c->cd();
c->SaveAs("compare.pdf");
return 0;
}
示例15: bfractionFit
//.........这里部分代码省略.........
RooDataHist xCL("xCL","xCL",s,hCL);
RooHistPdf charmlight("charmlight","charmlight PDF",s,xCL);
/*
cout<<"hB "<<hB->Integral()<<endl;
cout<<"hC "<<hC->Integral()<<endl;
cout<<"hL "<<hL->Integral()<<endl;
cout<<"hCL "<<hCL->Integral()<<endl;
//*/
// --- Construct signal+background PDF ---
//Double_t bInitFrac = hB->Integral()/(hB->Integral()+hCL->Integral());
//Double_t cInitFrac = hC->Integral()/(hB->Integral()+hCL->Integral());
RooRealVar Bfraction("Bfraction","#light events",0.3,0.,1);
RooRealVar Cfraction("Cfraction","#background events",0.3,0.,1);
if(fixCL) RooAddPdf model("model","",bottom,charmlight,Bfraction);
else RooAddPdf model("model","",RooArgList(bottom,charm,light),RooArgList(Bfraction,Cfraction));
// --- Data sample ---
//RooDataSet *data = new RooDataSet("data","data",tdata,RooArgSet(s,jtpt,discriminator),Form("jtpt>=%f&&jtpt<%f&&%s>=%f&&%s<%f",ptMin,ptMax,discr,minXdiscr,discr,maxXdiscr));
//RooDataSet *data = new RooDataSet("data","data",tdata,RooArgSet(s,jtpt,discriminator),Form("jtpt>=%f&&jtpt<%f&&%s>=%f&&%s<%f&&bin>=%d&&bin<%d&&fabs(jteta)>%f&&fabs(jteta)<%f",ptMin,ptMax,discr,minXdiscr,discr,maxXdiscr,cbinlo,cbinhi,etalo,etahi));
RooDataSet *data = new RooDataSet("data","data",tdata,RooArgSet(s,jtpt,jteta,bin,discriminator),Form("jtpt>=%f&&jtpt<%f&&%s>=%f&&%s<%f&&abs(jteta)>%f&&abs(jteta)<%f&&bin>=%d&&bin<%d",ptMin,ptMax,discr,minXdiscr,discr,maxXdiscr,etalo,etahi,cbinlo,cbinhi));
TPaveText *header = new TPaveText(0.05,0.9,0.95,0.99);
header->AddText(Form("%s - ROOFIT ML unbinned fit of %s",var,fixCL?"2 components : bottom and (charm + light)":"3 components : bottom, charm and light"));
header->AddText(Form("Pb-Pb data - %s",comment));
header->AddText(Form("%s%.0f <= jet pT < %.0f",(var=="muptrel")?"deltaR < 0.5 ; muon pT > 5 ; ":"",ptMin,ptMax));
header->SetTextSize(0.027);
header->SetTextAlign(12);
header->SetBorderSize(0);
header->SetFillStyle(0);
//header->Draw();
//RooPlot* sframe = s.frame();
TH2D *htemp = new TH2D(Form("%s%.0f%.0f",var,ptMin,ptMax),Form("%s%.0f%.0f",var,ptMin,ptMax),100,minXvar,maxXvar,100,0.5,maxYaxis) ;
//htemp->SetXTitle(Form("%s %.0f < p_{T} < %.0f GeV/c",var,ptMin,ptMax));
if(var=="svtxm")htemp->SetXTitle("SV mass (GeV/c^{2})");
else htemp->SetXTitle("JP Disc.");
htemp->SetYTitle("Entries");
/*
htemp->Draw();
data->plotOn(sframe,Binning(25));
if(fixCL) {
model.plotOn(sframe,Components(charmlight),LineStyle(kDashed),LineColor(30),LineWidth(2));
} else {
model.plotOn(sframe,Components(light),LineStyle(kDashed),LineColor(kBlue),LineWidth(2));
model.plotOn(sframe,Components(charm),LineStyle(kDashed),LineColor(kGreen),LineWidth(2));
model.plotOn(sframe,Components(RooArgSet(charm,light)),LineStyle(kDashed),LineColor(30),LineWidth(2));
}
model.plotOn(sframe,Components(bottom),LineStyle(kDashed),LineColor(kRed),LineWidth(2),FillColor(kRed),FillStyle(1));
model.plotOn(sframe,LineWidth(2),LineColor(13));
data->plotOn(sframe,Binning(25));
model.paramOn(sframe,Layout(0.4,0.9,0.9),Format("NEU",FixedPrecision(3)));
sframe->Draw("same");
*/
// --- Perform extended ML fit of composite PDF to data ---
//RooFitResult *fitresult = model.fitTo(*data,Save(),PrintLevel(-1));
RooFitResult *fitresult = model.fitTo(*data,Save());
RooPlot* sframe = s.frame();