本文整理汇总了C++中TLegend::SetColumnSeparation方法的典型用法代码示例。如果您正苦于以下问题:C++ TLegend::SetColumnSeparation方法的具体用法?C++ TLegend::SetColumnSeparation怎么用?C++ TLegend::SetColumnSeparation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TLegend
的用法示例。
在下文中一共展示了TLegend::SetColumnSeparation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
void
printYieldPlot(const string origName="../../../WprimeWZ.root"){
TFile *fOrig = TFile::Open(origName.c_str(), "read"); assert(fOrig);
map<string, TH1F*> hists[nch];
vector<string> bkgSamples = BkgSamples();
for(int iBkg=0; iBkg<(int)bkgSamples.size(); ++iBkg){
for(int ch=0; ch<nch; ++ch){
hists[ch][bkgSamples[iBkg]] = new TH1F(Form("%s_ch%i", bkgSamples[iBkg].c_str(), ch), "", 40, 0, 2000);
for(int mass=0; mass<=2000; mass+=50){
//cout<<bkgSamples[iBkg]<<" "<<ch<<" "<<mass<<endl;
string cuts = Form("weight*(%s)*(EvtType == %i)", AnalysisCuts(mass).c_str(), ch);
Value origYield = GetNEvtsAndError(fOrig, bkgSamples[iBkg], "tEvts_MET", cuts);
hists[ch][bkgSamples[iBkg]]->Fill(mass, origYield.val);
}
}
}
//Data
for(int ch=0; ch<nch; ++ch){
hists[ch]["data"] = new TH1F(Form("%s_ch%i", "data", ch), "", 40, 0, 2000);
for(int mass=0; mass<=2000; mass+=50){
//cout<<"data"<<" "<<ch<<" "<<mass<<endl;
string cuts = Form("weight*(%s)*(EvtType == %i)", AnalysisCuts(mass).c_str(), ch);
Value origYield = GetNEvtsAndError(fOrig, "data", "tEvts_MET", cuts);
hists[ch]["data"]->Fill(mass, origYield.val);
}
}
TCanvas* c = new TCanvas("c", "");
c->Divide(2,2);
TLegend *leg = new TLegend(0.5, 0.55,0.9, 0.89,"");
prepLegend(leg);
leg->SetNColumns(2);
leg->SetColumnSeparation(0.05);
THStack* stacks[nch];
for(int ch=0; ch<nch; ++ch){
c->cd(1+ch)->SetLogy();
stacks[ch] = new THStack(Form("BkgCh%i", ch), Form("Background Yield By Mass Point (%s)", binLatex(ch).c_str()));
for(int iBkg=bkgSamples.size()-1; iBkg>=0; --iBkg){
int fillColor;
if(iBkg==0) fillColor = kOrange-2;
if(iBkg==1) fillColor = kOrange+7;
if(iBkg==2) fillColor = kViolet+2;
if(iBkg==3) fillColor = kGray;
if(iBkg==4) fillColor = kOrange+3;
string legName;
if(iBkg==0) legName = "WZ";
if(iBkg==1) legName = "Z+Jets";
if(iBkg==2) legName = "t\\bar{t}";
if(iBkg==3) legName = "Z#gamma";
if(iBkg==4) legName = "ZZ";
hists[ch][bkgSamples[iBkg]]->SetFillColor(fillColor);
//hists[ch][bkgSamples[iBkg]]->SetLineColor(fillColor);
stacks[ch]->Add(hists[ch][bkgSamples[iBkg]]);
if(ch==0) leg->AddEntry(hists[ch][bkgSamples[iBkg]], legName.c_str(), "F");
}
//Data
hists[ch]["data"]->SetMarkerStyle(20);
//hists[ch]["data"]->SetLineColor(fillColor);
if(ch==0) leg->AddEntry(hists[ch]["data"], "Data", "PE");
stacks[ch]->Draw("hist");
stacks[ch]->SetMaximum(50);
stacks[ch]->SetMinimum(1e-2);
hists[ch]["data"]->Draw("E SAME");
leg->Draw();
}
c->SaveAs("BkgYieldByMassPoint.png");
}
示例2: plot_eff_vs_general_var_grand_pas
//.........这里部分代码省略.........
th1Style1(FR7,19,4,binsize,19,1,1,1);
TGraphAsymmErrors* FR7_dum = FR7->Clone("FR7_dum");
th1Style1(FR7_dum,10,20,binsize2,19,1,1,1);
th1Style1(Eff8,17,24,binsize,17,1,1,1);
th1Style1(FR8,20,4,binsize,20,1,1,1);
TGraphAsymmErrors* FR8_dum = FR7->Clone("FR8_dum");
th1Style1(FR8_dum,10,20,binsize2,19,1,1,1);
}
*/
if(!MBonly){
//TLegend *leg = new TLegend(0.54,0.4,0.89,0.62);
//TLegend *leg = new TLegend(0.54,0.36,0.89,0.62);
//TLegend *leg = new TLegend(0.19,0.37,0.93,0.63);
//TLegend *leg = new TLegend(0.19,0.4,0.65,0.63);
//TLegend *leg = new TLegend(0.23,0.3,0.69,0.52);
TLegend *leg = new TLegend(0.23,0.25,0.69,0.47);
leg->SetBorderSize(1);
leg->SetFillColor(kWhite);
//leg->SetFillStyle(0);
leg->SetTextSize(0.031);
leg->SetMargin(0.55);
//leg->SetMargin(0.5);
/*
char jetrange1[100];
sprintf(jetrange1," %1.0f<E_{T}<%1.0f",minjet,maxjet);
char jetrange2[100];
sprintf(jetrange2," %1.0f<E_{T}<%1.0f",minjet2,maxjet2);
char header[100];
sprintf(header," p_{T}^{hat}>15 p_{T}^{hat}>30 p_{T}^{hat}>80");
leg->SetHeader(header);
*/
leg->SetNColumns(2);
leg->SetColumnSeparation(0.000);
leg->AddEntry(Eff1Skm,jetrange1,"lp");
leg->AddEntry(dum,"MB ","");
leg->AddEntry(Eff2Skm,jetrange2,"lp");
leg->AddEntry(dum,"MB ","");
leg->AddEntry(Eff4Skm,jetrange3,"lp");
leg->AddEntry(dum,"Pt15 ","");
leg->AddEntry(Eff6Skm,jetrange4,"lp");
leg->AddEntry(dum,"Pt30 ","");
leg->AddEntry(Eff7Skm,jetrange5,"lp");
leg->AddEntry(dum,"Pt30 ","");
leg->AddEntry(Eff8Skm,jetrange6,"lp");
leg->AddEntry(dum,"Pt80 ","");
leg->AddEntry(Eff10Skm,jetrange7,"lp");
leg->AddEntry(dum,"Pt170 ","");
leg->AddEntry(Eff12Skm,jetrange9,"lp");
leg->AddEntry(dum,"Pt300 ","");
}else{
TLegend *leg = new TLegend(0.54,0.4,0.89,0.62);
leg->SetBorderSize(1);
leg->SetFillColor(kWhite);
leg->SetTextSize(0.031);
leg->SetMargin(0.35);
//leg->SetHeader(" 0 < Jet E_{T}< 20 ");
leg->AddEntry(Eff3,"PYTHIA 7 TeV","lp");
}
leg->Draw();
TLatex *tex = new TLatex(0.19,0.20,"Fake rate");
tex->SetTextSize(0.04);
tex->SetLineWidth(2);
tex->SetNDC();
//tex->Draw();
Char_t outName1[100];
//sprintf(outName1,"Eff_FR_GRAND_%s",VARIABLE);
sprintf(outName1,"Eff_FR_GRAND_wider_v2");
Char_t outName2[100];
//sprintf(outName2,"Eff_FR_GRAND_logx_%s",VARIABLE);
sprintf(outName2,"Eff_FR_GRAND_logx_wider_v2");
tex->Draw();
dum->SetMaximum(0.91);
//dum->SetMinimum(0.65);
dum->SetMinimum(0.50);
printCanvases(call,outName1,0);
dum->SetMinimum(-0.05);
dum->SetMaximum(1.0);
printCanvases(call,outName2,1);
}