当前位置: 首页>>代码示例>>C++>>正文


C++ TLegend::SetY2NDC方法代码示例

本文整理汇总了C++中TLegend::SetY2NDC方法的典型用法代码示例。如果您正苦于以下问题:C++ TLegend::SetY2NDC方法的具体用法?C++ TLegend::SetY2NDC怎么用?C++ TLegend::SetY2NDC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TLegend的用法示例。


在下文中一共展示了TLegend::SetY2NDC方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
//.........这里部分代码省略.........
开发者ID:ekfriis,项目名称:HiggsTauTauLimits,代码行数:101,代码来源:sobWeightedCombine.C

示例2: plotNLLMassToys


//.........这里部分代码省略.........
  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;
  TF1 Gaus("Gaus","[0]*exp(-0.5*(x-[1])**2/([2]*[2])) + [3]*exp(-0.5*(x-[5])**2/([2]*[2])) + [4]*exp(-0.5*(x-[6])**2/([2]*[2]))",110,145);
  Gaus.SetParLimits(0,0,10000);
  Gaus.SetParLimits(1,110,145);
开发者ID:12345ieee,项目名称:cmg-cmssw,代码行数:67,代码来源:plotNLLMassToys.C


注:本文中的TLegend::SetY2NDC方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。