本文整理汇总了C++中TLegend::SetX1NDC方法的典型用法代码示例。如果您正苦于以下问题:C++ TLegend::SetX1NDC方法的具体用法?C++ TLegend::SetX1NDC怎么用?C++ TLegend::SetX1NDC使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TLegend
的用法示例。
在下文中一共展示了TLegend::SetX1NDC方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: F
void
sobWeightedPlot(TString filename,const char* dataset , const char* channel,const char* cat)
{
TFile F((TString("Plot_")+filename+".root").Data(),"READ");
gROOT->cd();
TH1F* data=(TH1F*)F.Get("data_obs");
TH1F* Ztt=(TH1F*)F.Get("Ztt");
TH1F* ggH=(TH1F*)F.Get("ggH");
TH1F* sig=(TH1F*)F.Get("signal");
TH1F* tt=(TH1F*)F.Get("ttbar");
TH1F* ewk=(TH1F*)F.Get("EWK");
TH1F* fakes=(TH1F*)F.Get("Fakes");
if(!sig){cout<<"No input histograms in file: "<<filename.Data()<<endl; return;}
float xmininset=60; float xmaxinset=180;
//float xmininset=0; float xmaxinset=340;//full range
////Format the histograms
Ztt->GetYaxis()->SetRangeUser(0.,1.3*findMaxY(data,0));
Ztt->GetXaxis()->SetTitle("#bf{m_{#tau#tau} [GeV]}");
Ztt->GetYaxis()->SetTitle("#bf{S/B Weighted dN/dm_{#tau#tau} [1/GeV]}");
Ztt->SetTitleOffset(1.300, "Y");
Ztt->SetTitleOffset(1.000, "X");
Ztt->SetNdivisions(505);
for(Int_t b=0;b<=sig->GetNbinsX()+1;b++){
//remove red line on top of y axis in plot
if(sig->GetBinCenter(b)<xmininset||xmaxinset<sig->GetBinCenter(b)){
sig->SetBinContent(b,0);
sig->SetBinError(b,0);
}
}
sig->SetName("sig");
sig->SetFillStyle(3353);//1001=solid , 3004,3005=diagonal
sig->SetFillColor(2);
sig->SetLineColor(2);
sig->SetLineStyle(1);
sig->SetLineWidth(0.);
ggH->SetBinContent(0,0);//remove red line on top of y axis in plot
ggH->SetBinContent(ggH->GetNbinsX()+1,0);
ggH->SetBinError(0,0);
ggH->SetBinError(ggH->GetNbinsX()+1,0);
ggH->SetName("ggH");
ggH->SetFillStyle(3353);//1001=solid , 3004,3005=diagonal
ggH->SetFillColor(2);
ggH->SetLineColor(2);
ggH->SetLineStyle(1);
ggH->SetLineWidth(0.);
TH1F* errorBand = (TH1F*)Ztt->Clone("errorBand");
errorBand->SetMarkerSize(0);
errorBand->SetFillColor(1);
errorBand->SetFillStyle(3013);
errorBand->SetLineWidth(1);
TLegend legend;
TString higgslabel="H(125 GeV)#rightarrow#tau#tau";
legend.SetFillStyle(0);
legend.SetFillColor(0);
legend.SetBorderSize(0);
legend.AddEntry(ggH,higgslabel,"F");
legend.AddEntry(data,"observed","LP");
legend.AddEntry(Ztt,"Z#rightarrow#tau#tau","F");
legend.AddEntry(tt,"t#bar{t}","F");
legend.AddEntry(ewk,"electroweak","F");
legend.AddEntry(fakes,"QCD","F");
legend.SetX1NDC(0.63);
legend.SetX2NDC(1.05);
legend.SetY1NDC(0.27);
legend.SetY2NDC(0.48);
legend.SetTextSize(.028);
legend.SetTextAlign( 12 );
//TH1F* dataDiff=diffPlot(data,Ztt,2);
TH1F* dataDiff=diffPlot(data,Ztt,1);
TH1F* errBand=getErrorBand(Ztt);
errBand->SetFillStyle(3013);//1001=solid , 3004,3005=diagonal, 3013=hatched official for H->tau tau
errBand->SetFillColor(1);
errBand->SetLineStyle(1);
errBand->SetLineColor(1);
errBand->SetLineWidth(1);
TH1F errBandFrame("errBandFrame","",(xmaxinset-xmininset)/dataDiff->GetBinWidth(1),xmininset,xmaxinset);
errBandFrame.GetYaxis()->SetTitle("");
errBandFrame.GetYaxis()->SetRangeUser(-1.1*findMinY(dataDiff,0,xmininset,xmaxinset),2.0*findMaxY(dataDiff,0,xmininset,xmaxinset));
errBandFrame.GetYaxis()->SetNdivisions(5);
errBandFrame.GetYaxis()->SetLabelSize(0.06);
errBandFrame.GetXaxis()->SetTitle("#bf{m_{#tau#tau} [GeV]} ");
errBandFrame.GetXaxis()->SetTitleColor(kBlack);
errBandFrame.GetXaxis()->SetTitleSize(0.07);
errBandFrame.GetXaxis()->SetTitleOffset(0.95);
errBandFrame.GetXaxis()->SetLabelSize(0.06);
errBandFrame.SetNdivisions(505);
TLegend legendDiff;
legendDiff.SetFillStyle(0);
//.........这里部分代码省略.........
示例2: defStyle
//------------------------------------------------------------------------------
void PlotAlignmentValidation::plotChi2(const char *inputFile)
{
// Opens the file (it should be OfflineValidation(Parallel)_result.root)
// and reads and plots the norm_chi^2 and h_chi2Prob -distributions.
// First set default style: plots are already formatted
TStyle defStyle("Default","Default Style");
defStyle.cd();
gStyle->SetOptStat(1);
TGaxis::SetMaxDigits(3);
Bool_t errorflag = kTRUE;
TFile* fi1 = new TFile(inputFile,"read");
TDirectoryFile* mta1 = NULL;
TDirectoryFile* mtb1 = NULL;
TCanvas* normchi = NULL;
TCanvas* chiprob = NULL;
if (fi1 != NULL) {
mta1 = (TDirectoryFile*) fi1->Get("TrackerOfflineValidationStandalone");
if(mta1 != NULL) {
mtb1 = (TDirectoryFile*) mta1->Get("GlobalTrackVariables");
if(mtb1 != NULL) {
normchi = (TCanvas*) mtb1->Get("h_normchi2");
chiprob = (TCanvas*) mtb1->Get("h_chi2Prob");
if (normchi != NULL && chiprob != NULL) {
errorflag = kFALSE;
}
}
}
}
if(errorflag)
{
std::cout << "PlotAlignmentValidation::plotChi2: Can't find data from given file,"
<< " no chi^2-plots produced" << std::endl;
return;
}
// Small adjustments: move the legend right so that it doesn't block
// the exponent of the y-axis scale
TLegend* l = (TLegend*)findObjectFromCanvas(normchi, "TLegend");
if (l != 0) {
l->SetX1NDC(0.25);
}
l = (TLegend*)findObjectFromCanvas(chiprob, "TLegend");
if (l != 0) {
l->SetX1NDC(0.25);
}
chiprob->Draw();
normchi->Draw();
// EPS-files
normchi->Print((outputDir + "/h_normchi2.eps").c_str());
chiprob->Print((outputDir + "/h_chi2Prob.eps").c_str());
// ROOT-files
TFile fi2((outputDir + "/h_normchi2.root").c_str(), "recreate");
normchi->Write();
fi2.Close();
TFile fi3((outputDir + "/h_chi2Prob.root").c_str(), "recreate");
chiprob->Write();
fi3.Close();
fi1->Close();
TGaxis::SetMaxDigits(4);
}
示例3: plotNLLMassToys
//.........这里部分代码省略.........
}
TGraph GData;
for(Int_t m=0;m<8;m++){
double x; double y;
DataInput->GetPoint(m*5,x,y);
GData.SetPoint(m,x,y-mindata);
}
GData.Draw("plsame");
//DataInput->Draw("plsame");
//GScanToy[0]->Draw("lsame");
C.RedrawAxis();
line.DrawLine(110,0.5,145,0.5);
line.DrawLine(110,1.92,145,1.92);
float datasigmahigh=8.55;
float datasigmalow=5.85;
TLine verticalline;
verticalline.SetLineStyle(2);
verticalline.DrawLine(minmassdata-datasigmalow,0,minmassdata-datasigmalow,0.5);
verticalline.DrawLine(minmassdata+datasigmahigh,0,minmassdata+datasigmahigh,0.5);
TLegend legend;
legend.SetFillStyle(0);
legend.SetFillColor(0);
legend.SetBorderSize(0);
legend.AddEntry(&GData,"observed","LP");
legend.AddEntry(&GScan,"H(125 GeV) expected","L");
legend.AddEntry(HBands[3],"#pm 1#sigma expected","F");
legend.AddEntry(HBands[4],"#pm 2#sigma expected","F");
legend.SetX1NDC(0.37);
legend.SetX2NDC(0.85);
legend.SetY1NDC(0.67);
legend.SetY2NDC(0.88);
legend.SetTextSize(.04);
legend.SetTextAlign(12);
legend.Draw();
TLatex text;
text.SetTextColor(2);
text.SetTextSize(0.04);
text.DrawLatex(142,0.5+0.05,"1#sigma");
text.DrawLatex(142,1.92+0.05,"2#sigma");
//CMSPrelim("CMS Preliminary, H#rightarrow#tau#tau, L = 24.3 fb^{-1}"); //#sqrt{s} = 7 - 8 TeV , L = 24.3 fb^{-1}
//CMSPrelim("CMS Prelim., H#rightarrow#tau#tau, #sqrt{s} = 7 - 8 TeV, L = 24.3 fb^{-1}");
//CMSPrelim("");
//CMSPrelim("CMS Preliminary, #sqrt{s}=7 TeV, L=4.9 fb^{-1}, #sqrt{s}=8 TeV, L=19.3 fb^{-1}, H#rightarrow#tau#tau");
CMSPrelim();
C.Print(filenamesb+".ps");
C.Print(filenamesb+"_DNLL.png");
C.Print(filenamesb+"_DNLL.pdf");
//////////////////////Pull distribution
TH1F HMassFrame("HMassFrame","",1,100,155);
HMassFrame.GetYaxis()->SetRangeUser(0,HMass.GetMaximum()*1.3);
HMassFrame.GetYaxis()->SetTitle("# of toys");
HMassFrame.GetXaxis()->SetTitle("m_{H} [GeV]");
cout<<" Fit with 3 gaussians "<<endl;
示例4: compareThreeVersions
void compareThreeVersions(TimeInfoAllSteps TIAS_1,TimeInfoAllSteps TIAS_2,TimeInfoAllSteps TIAS_3,TString file_postfix) {
gStyle->SetOptStat(0);
TPaveText* labelcms = new TPaveText(0.20,0.79,0.54,0.92,"NDCBR");
labelcms->SetTextAlign(12);
labelcms->SetTextSize(0.04);
labelcms->SetFillColor(kWhite);
labelcms->AddText("CMS Preliminary Simulation");
//labelcms->AddText("CMS Preliminary");
//labelcms->AddText("Simulation");
labelcms->AddText("#sqrt{s} = 8 TeV, t#bar{t}+PU");
labelcms->SetBorderSize(0);
labelcms->SetTextFont(42);
labelcms->SetLineWidth(2);
TH1F *htime_iter_1 = new TH1F("time_iter_1"+file_postfix,"time_iter_1",8,0,8);
timingTestPerIter(TIAS_1,htime_iter_1);
htime_iter_1->SetLineStyle(TIAS_1.style());
htime_iter_1->SetLineColor(TIAS_1.color());
TH1F *htime_iter_2 = new TH1F("time_iter_2"+file_postfix,"time_iter_2",8,0,8);
timingTestPerIter(TIAS_2,htime_iter_2);
htime_iter_2->SetLineStyle(TIAS_2.style());
htime_iter_2->SetLineColor(TIAS_2.color());
TH1F *htime_iter_3 = new TH1F("time_iter_3"+file_postfix,"time_iter_3",8,0,8);
timingTestPerIter(TIAS_3,htime_iter_3);
htime_iter_3->SetLineStyle(TIAS_3.style());
htime_iter_3->SetLineColor(TIAS_3.color());
float iter_Iter0PU20 = htime_iter_1->GetBinContent(1);
htime_iter_1->Scale(1./iter_Iter0PU20);
htime_iter_2->Scale(1./iter_Iter0PU20);
htime_iter_3->Scale(1./iter_Iter0PU20);
htime_iter_1->GetYaxis()->SetRangeUser(0,1.1*TMath::Max(htime_iter_1->GetBinContent(htime_iter_1->GetMaximumBin()),TMath::Max(htime_iter_2->GetBinContent(htime_iter_2->GetMaximumBin()),htime_iter_3->GetBinContent(htime_iter_3->GetMaximumBin()))));
TLegend* leg = new TLegend(0.2,0.59,0.45,0.79);
leg->SetNColumns(1);
leg->SetFillColor(kWhite);
leg->SetLineColor(kWhite);
leg->SetBorderSize(0);
leg->SetTextSize(0.04);
leg->SetTextFont(42);
leg->AddEntry(htime_iter_1,TIAS_1.legend(),"L");
leg->AddEntry(htime_iter_2,TIAS_2.legend(),"L");
leg->AddEntry(htime_iter_3,TIAS_3.legend(),"L");
htime_iter_1->GetYaxis()->SetTitleOffset(1.2);
htime_iter_1->GetXaxis()->SetRangeUser(0,7);
htime_iter_1->GetYaxis()->SetTitle("time [1/[email protected]<PU>=20]");
htime_iter_1->GetYaxis()->SetTitleSize(0.04);
htime_iter_1->GetXaxis()->SetTitleSize(0.04);
htime_iter_1->GetYaxis()->SetLabelSize(0.04);
TCanvas c0;
c0.SetTicks(1,1);
htime_iter_1->Draw("H");
htime_iter_2->Draw("H,same");
htime_iter_3->Draw("H,same");
leg->Draw();
labelcms->Draw();
c0.SetGridy();
c0.SaveAs("timingNew_iter_"+file_postfix+".png");
TH1F *htime_step_1 = new TH1F("time_step_1"+file_postfix,"time_step_1",5,0,5);
timingTestPerStep(TIAS_1,htime_step_1);
htime_step_1->SetLineStyle(TIAS_1.style());
htime_step_1->SetLineColor(TIAS_1.color());
htime_step_1->GetYaxis()->SetTitle("time [1/[email protected]<PU>=20]");
TH1F *htime_step_2 = new TH1F("time_step_2"+file_postfix,"time_step_2",5,0,5);
timingTestPerStep(TIAS_2,htime_step_2);
htime_step_2->SetLineStyle(TIAS_2.style());
htime_step_2->SetLineColor(TIAS_2.color());
TH1F *htime_step_3 = new TH1F("time_step_3"+file_postfix,"time_step_3",5,0,5);
timingTestPerStep(TIAS_3,htime_step_3);
htime_step_3->SetLineStyle(TIAS_3.style());
htime_step_3->SetLineColor(TIAS_3.color());
float step_BuildPU20 = htime_step_1->GetBinContent(3);
htime_step_1->Scale(1./step_BuildPU20);
htime_step_2->Scale(1./step_BuildPU20);
htime_step_3->Scale(1./step_BuildPU20);
htime_step_1->GetYaxis()->SetTitleOffset(1.2);
htime_step_1->GetXaxis()->SetRangeUser(0,7);
htime_step_1->GetYaxis()->SetTitleSize(0.04);
htime_step_1->GetXaxis()->SetTitleSize(0.04);
htime_step_1->GetYaxis()->SetLabelSize(0.04);
TCanvas c1;
c1.SetTicks(1,1);
//htime_step_1->Scale(1./htime_step_1->Integral());
//htime_step_2->Scale(1./htime_step_2->Integral());
//htime_step_3->Scale(1./htime_step_3->Integral());
htime_step_1->GetYaxis()->SetRangeUser(0,1.1*TMath::Max(htime_step_1->GetBinContent(htime_step_1->GetMaximumBin()),TMath::Max(htime_step_2->GetBinContent(htime_step_2->GetMaximumBin()),htime_step_3->GetBinContent(htime_step_3->GetMaximumBin()))));
htime_step_1->GetXaxis()->SetRangeUser(1,5);
htime_step_1->Draw("H");
htime_step_2->Draw("H,same");
htime_step_3->Draw("H,same");
leg->SetX1NDC(0.60);
leg->SetX2NDC(0.85);
labelcms->SetX1NDC(0.60);
labelcms->SetX2NDC(0.94);
leg->Draw();
labelcms->Draw();
c1.SetGridy();
c1.SaveAs("timingNew_step_"+file_postfix+".png");
//.........这里部分代码省略.........