本文整理汇总了C++中TLegend::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ TLegend::Clear方法的具体用法?C++ TLegend::Clear怎么用?C++ TLegend::Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TLegend
的用法示例。
在下文中一共展示了TLegend::Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: plotEfficiency
void plotEfficiency(TGraphAsymmErrors *eff1, string legend1, TGraphAsymmErrors *eff2, string legend2,
string plotname,
Double_t xmin = -99, Double_t xmax = -99,
Double_t ymin = -99 , Double_t ymax = -99 ) {
TCanvas *cv = MakeCanvas("cv", "cv", 800, 600);
TLegend *leg = new TLegend(0.60,0.80,0.90,0.90);
leg->SetBorderSize(0);
leg->SetTextSize(0.03);
eff1->SetTitle("");
eff2->SetTitle("");
eff1->SetLineColor(kRed);
eff1->SetMarkerColor(kRed);
eff2->SetLineColor(kBlue);
eff2->SetMarkerColor(kBlue);
leg->Clear();
leg->AddEntry(eff1, legend1.c_str(), "P");
leg->AddEntry(eff2, legend2.c_str(), "P");
if (xmin != -99 && xmax != -99) eff1->GetXaxis()->SetRangeUser(xmin,xmax);
if (ymin != -99) eff1->SetMinimum(ymin);
if (ymax != -99) eff1->SetMaximum(ymax);
eff1->Draw("AP");
eff2->Draw("Psame");
leg->Draw();
cv->SaveAs((plotname + ".gif").c_str());
cv->SaveAs((plotname + ".eps").c_str());
}
示例2: Limitd
void Limitd() {
setNCUStyle(true);
c1 = new TCanvas("c1","",800,600);
int width [nWidth]= {25,30,35,40};
int bmin[nBmin]= {100,105,110,115};
string masspoint[11]= {"1000","1200","1400","1600","1800","2000","2500","3000","3500","4000","4500"};
TLegend *leg = new TLegend(0.75, 0.68, 0.96, 0.95);
leg->SetBorderSize(0);
leg->SetFillColor(0);
leg->SetFillStyle(0);
leg->SetTextSize(0.04);
string categoryName[7]= {"0a","0c","1a","1c","2a","2b","2d"};
for(int k=0; k<3; k++) {
leg->Clear();
int lower=105,upper=135;
if(k==1) {
lower=110;
upper=140;
}
else if (k==2) {
lower=115;
upper=145;
}
for(int h=0; h<7; h++) {
TFile* tf1=TFile::Open(Form("%sW/MassPlotFineBins_subtr_Moriond_Silver%dto%d.root",categoryName[h].data(),lower,upper));
//if(h==2) tf1=TFile::Open(Form("%sW/MassPlotFineBins_subtr_Moriond_Silver110to145.root",categoryName[h].data()));
//if(h>=3) tf1=TFile::Open(Form("%sW/MassPlotFineBins_subtr_Moriond_Silver115to145.root",categoryName[h].data()));
if (!tf1 || !tf1->IsOpen())continue;
TGraphAsymmErrors* tg1=(TGraphAsymmErrors*)tf1->Get("LimitExpectedCLs");
tg1->GetYaxis()->SetTitle("95% CLs on #sigma(X#rightarrowHH)#timesBR(HH#rightarrowb#bar{b}b#bar{b})[fb]");
tg1->SetLineStyle(1);
tg1->SetFillColor(0);
tg1->SetLineColor(h+1);
leg->AddEntry(tg1,Form("%s %d-%d",categoryName[h].data(),lower,upper));
// else if(h==2)leg->AddEntry(tg1,Form("%s 110-145",categoryName[h].data()));
// else if(h>=3)leg->AddEntry(tg1,Form("%s 115-145",categoryName[h].data()));
tg1->SetMaximum(12);
tg1->SetMinimum(0.5);
// cout<<k<<","<<m<<endl;
//c1->SetLogy(1);
if(h==0)tg1->Draw("APL");
else tg1->Draw("PL same");
}
leg->Draw("same");
c1->Print(Form("limitPlots/%d-%d.pdf",lower,upper));
}
}
示例3: PlotFakePredictions
void PlotFakePredictions() {
TFile *fileSS = new TFile("WWSelectionPlotsFakePrediction_SS.root", "READ");
TFile *fileOS = new TFile("WWSelectionPlotsFakePrediction.root", "READ");
TH1F *LeptonPtMin_OS = (TH1F*)fileOS->Get("hLeptonPtMin");
TH1F *LeptonPtMin_SS = (TH1F*)fileSS->Get("hLeptonPtMin");
TLegend *legend = new TLegend(0.73,0.75,0.93,0.90);
legend->SetTextSize(0.03);
legend->SetBorderSize(1);
legend->Clear();
legend->AddEntry(LeptonPtMin_OS, "OppSign", "L");
legend->AddEntry(LeptonPtMin_SS, "SameSign", "LP");
TCanvas *cv = new TCanvas("cv","cv",800,600);
LeptonPtMin_OS->SetMaximum(0.4);
LeptonPtMin_OS->Draw("hist");
LeptonPtMin_SS->SetLineColor(kRed);
LeptonPtMin_SS->SetMarkerColor(kRed);
LeptonPtMin_SS->Draw("same,E1");
legend->Draw();
cv->SaveAs("LeptonPtMin_FakePrediction.gif");
// fileSS->Close();
// fileOS->Close();
TH1F *DileptonMass_OS = (TH1F*)fileOS->Get("dileptonMass");
TH1F *DileptonMass_SS = (TH1F*)fileSS->Get("dileptonMass");
DileptonMass_OS->SetMaximum(0.25);
DileptonMass_OS->Draw("hist");
DileptonMass_SS->SetLineColor(kRed);
DileptonMass_SS->SetMarkerColor(kRed);
DileptonMass_SS->Draw("same,E1");
legend->Draw();
cv->SaveAs("DileptonMass_FakePrediction.gif");
TH1F *DeltaPhiLeptons_OS = (TH1F*)fileOS->Get("hDeltaPhiLeptons");
TH1F *DeltaPhiLeptons_SS = (TH1F*)fileSS->Get("hDeltaPhiLeptons");
DeltaPhiLeptons_OS->SetMaximum(0.25);
DeltaPhiLeptons_OS->Draw("hist");
DeltaPhiLeptons_SS->SetLineColor(kRed);
DeltaPhiLeptons_SS->SetMarkerColor(kRed);
DeltaPhiLeptons_SS->Draw("same,E1");
legend->Draw();
cv->SaveAs("DeltaPhiLeptons_FakePrediction.gif");
}
示例4: plot_nhists
bool plot_nhists(vector<TH1F*> histo, TString epsname, TString* type)
{
set_style();
TCanvas* can = new TCanvas("can", "can", 600, 600);
can->cd();
can->Print(epsname+"[");
can->SetLogy();
TLegend * legend = new TLegend(0.7,0.8,.92,0.99);
legend->SetTextFont(72);
legend->SetTextSize(0.04);
legend->SetFillColor(kWhite);
TString histo_titel = histo[0]->GetTitle();
int b =0;
for(unsigned int i = 0; i<histo.size(); ++i){
if(histo_titel==histo[i]->GetTitle()){
histo[i]->SetMaximum(histo[i]->GetMaximum()<1 ? 1.2 : 1.4*histo[i]->GetMaximum());
histo[i]->Draw("same");
histo[i]->SetLineColor(b+2);
legend->AddEntry(histo[i],type[b]);
b+=1;
}
else{
legend->Draw();
can->Print(epsname);
legend->Clear();
b=0;
histo[i]->SetMaximum(histo[i]->GetMaximum()<1 ? 1.2 : 1.4*histo[i]->GetMaximum());
histo[i]->Draw();
histo[i]->SetLineColor(b+2);
legend->AddEntry(histo[i],type[b]);
b+=1;
histo_titel=histo[i]->GetTitle();
}
}
legend->Draw();
can->Print(epsname);
can->Print(epsname+"]");
can->Close();
return true;
}
示例5: ampPlot
//------------------------------------------//
// Format amplitude plots
//------------------------------------------//
void ampPlot(TFile* file, vector<TString> filters)
{
// Specify the titles
TString xtitle = "Amplitude [v]";
TString ytitle = "Entries";
// Histogram name
TString pname = "h_amp";
// Create canvas
TCanvas* c = makeCanvas("c");
c->SetLogx();
c->SetLogy();
// Make legend
TLegend* leg = makeLegend(0.7,0.8,0.8,0.9);
// Loop and plot
TH1* hist = NULL;
for(unsigned int i=0; i<filters.size(); ++i){
leg->Clear();
leg->SetHeader("Filter");
TString filter = filters.at(i);
hist = getHist(file,pname+"_"+filter,xtitle,ytitle,
m_colors[i], m_markers[i]);
leg->AddEntry(hist,(filter+"%").Data(),"l");
hist->Draw();
// Draw legend
leg->Draw("same");
c->SaveAs((savedir+"amp_filter"+filter+".png").Data());
}// end loop over filters
}
示例6: tDiffMaxPlotForMaxV
//------------------------------------------//
// Plotting the maximum time difference
// for the maximum amplitude wave
//------------------------------------------//
void tDiffMaxPlotForMaxV(TFile* file, vector<TString> filters)
{
// Specify the titles
TString xtitle = "Max(LEtime - wavetime) [ns]";
TString ytitle = "Entries";
// Histogram name
TString pname = "h_maxTDiff_forMaxV";
// Create canvas
TCanvas* c = makeCanvas("c");
//c->SetLogy();
// Make legend
TLegend* leg = makeLegend(0.7,0.8,0.8,0.9);
// Loop and plot
TH1* hist = NULL;
for(unsigned int i=0; i<filters.size(); ++i){
leg->Clear();
leg->SetHeader("Filter");
TString filter = filters.at(i);
hist = getHist(file,pname+"_"+filter,xtitle,ytitle,
m_colors[i], m_markers[i]);
leg->AddEntry(hist,(filter+"%").Data(),"l");
hist->Draw();
// Draw legend
leg->Draw("same");
// Save
//c->SaveAs((savedir+"maxTimeDiff_filter"+filter+"_nonlog.png").Data());
//c->SaveAs((savedir+"maxTimeDiff_cutOnCounter_filter"+filter+"_nonlog.png").Data());
}// end loop over filters
}
示例7: comp_crossSection_pt_LHCb_each_xErr
//.........这里部分代码省略.........
//legUR -> SetHeader("Prompt J/#psi");
//legUR -> AddEntry(gCross_pr_0,"CMS Preliminary :1.5 < y_{CM} < 1.93","lp");
legUR -> AddEntry(gCross_pr_0,"CMS : 1.5 < y_{CM} < 1.93","lp");
legUR -> AddEntry(gCross_lhcb_pr,"LHCb : 1.5 < y_{CM} < 2","lp");
legUR -> Draw();
globtex->SetTextSize(0.045);
globtex->SetTextFont(62);
globtex->DrawLatex(0.88, 0.88, "Prompt J/#psi");
latex->SetTextSize(0.04);
if (isLog) {
latex->DrawLatex(0.19, 0.31, "Preliminary");
latex->DrawLatex(0.19, 0.25, Form("%s",beamstring.c_str()));
}
else {
latex->DrawLatex(0.89, 0.31, "Preliminary");
latex->DrawLatex(0.89, 0.25, Form("%s",beamstring.c_str()));
}
// if (isLog) {
// latex->DrawLatex(0.20, 0.25, beamstring.c_str());
// }
// else {
// latex->DrawLatex(0.62, 0.25, beamstring.c_str());
// }
c_pr->Update();
c_pr->SaveAs(Form("compOtherExp/comp_crossSection_pt_LHCb_pr_isLog%d_isPtCut_%d_shifted_%d_each_xErr.pdf",(int)isLog,(int)isPtCut,(int)shifted));
c_pr->SaveAs(Form("compOtherExp/comp_crossSection_pt_LHCb_pr_isLog%d_isPtCut_%d_shifted_%d_each_xErr.png",(int)isLog,(int)isPtCut,(int)shifted));
legUR->Clear();
//c_pr->Clear();
////// 02 ////////
// non-prompt
TCanvas *c_np = new TCanvas("c_np","", 200, 10, 600, 600);
c_np->cd();
if (isLog) gPad->SetLogy(1);
else gPad->SetLogy(0);
gCross_np_sys_0->SetTitle("");
gCross_np_sys_0->GetXaxis()->SetTitle("p_{T} [GeV/c]");
gCross_np_sys_0->GetXaxis()->CenterTitle();
if(isPtCut) gCross_np_sys_0->GetXaxis()->SetLimits(3.0,20.0);
else gCross_np_sys_0->GetXaxis()->SetLimits(0.0,20.0);
gCross_np_sys_0->GetYaxis()->SetTitle("B x d^{2}#sigma/dp_{T}dy [ #mub/(GeV/c)]");
if (isLog){
gCross_np_sys_0->SetMinimum(0.001);
if (isPtCut) gCross_np_sys_0->SetMaximum(500.);
//else gCross_np_sys_0->SetMaximum(100.);
else gCross_np_sys_0->SetMaximum(10.);
}
else {
gCross_np_sys_0->SetMinimum(-0.1);
if (isPtCut) gCross_np_sys_0->SetMaximum(25.);
else gCross_np_sys_0->SetMaximum(2.5);
}
gCross_np_sys_0->SetFillColor(kTeal-9);
gCross_np_sys_0->Draw("A2");
gCross_lhcb_np_sys = new TGraphAsymmErrors(nBin_lhcb, lhcb_px, lhcb_py_np, lhcb_exsys, lhcb_exsys, lhcb_eysys_np, lhcb_eysys_np);
gCross_lhcb_np_sys->SetFillColor(kGray);
gCross_lhcb_np_sys->SetFillStyle(3001);
示例8: main
//.........这里部分代码省略.........
ratio->GetYaxis()->SetTitle("S/(#sqrt{S+B})");
ratio->SetMarkerSize(1.1);
ratioW = new TH1F(("ratioW_"+string(denominator.at(0)->GetName())).c_str(),"",numTotal->GetNbinsX(),numTotal->GetBinLowEdge(1),numTotal->GetBinLowEdge(numTotal->GetNbinsX()+1));
ratioW->GetYaxis()->SetTitle("weighted S/(#sqrt{S+B})");
ratioW->SetMarkerSize(1.1);
TString name = "norm_" ;
name += denTotal->GetName () ;
TH1F * norm_denTotal = (TH1F *) denTotal->Clone (name) ;
norm_denTotal->Scale (1. / norm_denTotal->GetMaximum ()) ;
// weight the S/sqrt (B) by the shape of the total,
// so that only bins with a lot of stats become visibly significant
for(int iBin = 0; iBin < ratio->GetNbinsX()+1; iBin++){
if(denTotal->GetBinContent(iBin) !=0){
ratioW->SetBinContent(iBin,
norm_denTotal->GetBinContent (iBin) * numTotal->GetBinContent(iBin) /
sqrt(denTotal->GetBinContent(iBin)));
ratio->SetBinContent(iBin,
numTotal->GetBinContent(iBin) / sqrt(denTotal->GetBinContent(iBin)));
}
else
ratio->SetBinContent(iBin,0.);
}
ratio->GetXaxis()->SetTitle("");
ratio->SetLineColor(kBlue);
ratio->SetLineStyle(2);
ratio->SetLineWidth(2);
ratio->GetXaxis()->SetLabelOffset(999);
ratio->GetXaxis()->SetLabelSize(0);
ratio->GetYaxis()->SetLabelSize(0.15);
ratio->GetYaxis()->SetTitleSize(0.15);
ratio->GetYaxis()->SetTitleOffset(0.30);
ratio->GetYaxis()->SetNdivisions(504);
ratioW->GetXaxis()->SetTitle("");
ratioW->SetLineColor(kBlack);
ratioW->SetLineWidth(2);
ratioW->GetXaxis()->SetLabelOffset(999);
ratioW->GetXaxis()->SetLabelSize(0);
ratioW->GetYaxis()->SetLabelSize(0.15);
ratioW->GetYaxis()->SetTitleSize(0.15);
ratioW->GetYaxis()->SetTitleOffset(0.30);
ratioW->GetYaxis()->SetNdivisions(504);
ratio->GetYaxis()->SetRange(min(ratio->GetMinimum(),ratioW->GetMinimum())*0.9,max(ratio->GetMaximum(),ratioW->GetMaximum())*1.1);
TH1F * frame = lowerPad->DrawFrame (ratio->GetXaxis ()->GetXmin (), 0.,
ratio->GetXaxis ()->GetXmax (), 2.) ;
frame->GetXaxis()->SetTitle (ratio->GetXaxis ()->GetTitle ()) ;
frame->GetYaxis()->SetTitle (ratio->GetYaxis ()->GetTitle ()) ;
frame->GetXaxis()->SetLabelOffset(999);
frame->GetXaxis()->SetLabelSize(0);
frame->GetYaxis()->SetLabelSize(0.15);
frame->GetYaxis()->SetTitleSize(0.15);
frame->GetYaxis()->SetTitleOffset(0.30);
frame->GetYaxis()->SetNdivisions(504);
ratio->Draw("P");
ratioW->Draw("Lsame");
upperPad->cd();
tex->Draw("same");
tex2->Draw("same");
tex3->Draw("same");
legend->Draw("same");
cCanvas->SaveAs(string("output/"+outputPlotDirectory+"/xs/"+variableList.at(iVar).variableName+".pdf").c_str(),"pdf");
cCanvas->SaveAs(string("output/"+outputPlotDirectory+"/xs/"+variableList.at(iVar).variableName+".png").c_str(),"png");
cCanvas->SaveAs(string("output/"+outputPlotDirectory+"/xs/"+variableList.at(iVar).variableName+".root").c_str(),"root");
cCanvasNorm->cd();
tex->Draw("same");
tex2->Draw("same");
tex3->Draw("same");
legend->Draw("same");
cCanvasNorm->SaveAs(string("output/"+outputPlotDirectory+"/norm/"+variableList.at(iVar).variableName+".pdf").c_str(),"pdf");
cCanvasNorm->SaveAs(string("output/"+outputPlotDirectory+"/norm/"+variableList.at(iVar).variableName+".png").c_str(),"png");
cCanvasNorm->SaveAs(string("output/"+outputPlotDirectory+"/norm/"+variableList.at(iVar).variableName+".root").c_str(),"root");
legend->Clear();
} // loop on var
cout<<"LHE filter efficiency : "<<passingLHEFilter<<" totEvent "<<totEvent<<" efficiency "<<float(passingLHEFilter)/float(totEvent)*100<<" % "<<endl;
//Normalize histograms
for(size_t ihisto = 0; ihisto < plotVector.size(); ihisto++){
if(plotVector.at(ihisto).varName == "DeltaPhi_LL")
cout<<"Events Histo "<<plotVector.at(ihisto).histogram->GetName()<<" unweighted "<<plotVector.at(ihisto).histogram->GetEntries()<<" weighted "<<plotVector.at(ihisto).histogram->Integral(0,plotVector.at(ihisto).histogram->GetNbinsX()+1)<<endl;
}
return 0 ;
}
示例9: stack_upgrade_42X
//.........这里部分代码省略.........
h_1d[iHist][iFile]->SetLineWidth(0);
h_1d[iHist][iFile]->SetFillStyle(3244);
if(iFile == 1){ h_1d[iHist][iFile]->SetFillColor(ZZ_Color); }
else if(iFile == 2){ h_1d[iHist][iFile]->SetFillColor(WZ_Color); }
else if(iFile == 3){ h_1d[iHist][iFile]->SetFillColor(TTbar_Color); }
else if(iFile == 4){ h_1d[iHist][iFile]->SetFillColor(Zjet_Color); }
else if(iFile == 5){
signal[iHist]->Add(h_1d[iHist][iFile+1]);
signal[iHist]->SetLineColor(kRed);
signal[iHist]->SetLineWidth(2.0);
}
if(iFile < 5) hs->Add(h_1d[iHist][iFile],"hist");
}
//hs->Add(signal[iHist],"hist");
h_1d[iHist][0]->SetMarkerStyle(21);
h_1d[iHist][0]->SetMarkerSize(0.7);
TLegend* leg = new TLegend(0.65,0.70,0.88,0.88,NULL,"brNDC");
leg->SetFillColor(0);
leg->SetTextSize(0.035);
leg->SetBorderSize(0);
leg->AddEntry(h_1d[iHist][0],"data 2011","p");
leg->AddEntry(h_1d[iHist][1],"ZZ","f");
leg->AddEntry(h_1d[iHist][2],"WZ","f");
leg->AddEntry(h_1d[iHist][3],"t#bar{t}","f");
leg->AddEntry(h_1d[iHist][4],"Zjet","f");
leg->AddEntry(signal[iHist],"ZH(120)#times 5","f");
TString lumist="4.9 fb^{-1}";
TPaveText *ll = new TPaveText(0.25, 0.95, 0.95, 0.99, "NDC");
ll->SetTextSize(0.03);
ll->SetTextFont(62);
ll->SetFillColor(0);
ll->SetBorderSize(0);
ll->SetMargin(0.01);
ll->SetTextAlign(12); // align left
TString text = PaveText[iHist];
ll->AddText(0.01,0.5,text);
text = "#sqrt{s} = 7 TeV L = ";
text = text + lumist;
// ll->SetTextAlign(32); // align right
ll->AddText(0.5, 0.5, text);
/*double max_dy = h_1d[iHist][4]->GetMaximum();
double max_data = h_1d[iHist][0]->GetMaximum();
double max = 0;
if (max_dy > max_data){
max = max_dy;}
else {
max = max_data;}
if (max != 0) hs->SetMaximum(max);
cout << "max data: " << max_data << endl;
cout << "max dy: " << max_dy << endl;
*/
h_1d[iHist][0]->Draw("PE01");
double max = h_1d[iHist][0]->GetMaximum();
h_1d[iHist][0]->GetYaxis()->SetRangeUser(1e-2,200*max);
// if(iHist > 0 && iHist < 4) h_1d[iHist][0]->GetXaxis()->SetRangeUser(0,150);
h_1d[iHist][0]->GetXaxis()->SetTitle(histTitles[iHist]);
hs->Draw("same");
signal[iHist]->Scale(10.);
signal[iHist]->Draw("histsame");
h_1d[iHist][0]->Draw("samePE01");
leg->Draw("same");
ll->Draw("same");
gPad->RedrawAxis();
c1->SetLogy();
c1->Print("NewCuts/Mu_"+histNames1[iHist]+"_all.png");
c1->Print("NewCuts/Mu_"+histNames1[iHist]+"_all.eps");
c1->SetLogy(0);
h_1d[iHist][0]->GetYaxis()->SetRangeUser(0,1.5*max);
c1->Print("NewCuts/Mu_"+histNames1[iHist]+"_all_normal.png");
c1->Print("NewCuts/Mu_"+histNames1[iHist]+"_all_normal.eps");
leg->Clear();
hs->Clear();
}
return 0;
}
示例10: tempSumm
void tempSumm()
{
const Int_t nx = 5;
char *labels[nx] = {"9/30","10/15","10/31","11/19","12/19"};
TH1F *probe1summ = new TH1F("probe1summ","",nx,0,nx);
TH1F *probe2summ = new TH1F("probe2summ","",nx,0,nx);
TH1F *probe3summ = new TH1F("probe3summ","",nx,0,nx);
TH1F *probe4summ = new TH1F("probe4summ","",nx,0,nx);
probe1summ->Fill(labels[0],0.910);//keep track of these from SC elog:36
probe1summ->SetBinError(1,0.057);
probe1summ->Fill(labels[1],1.088);
probe1summ->SetBinError(2,0.018);
probe1summ->Fill(labels[2],0.64);
probe1summ->SetBinError(3,0.12);
probe1summ->Fill(labels[3],0.72);
probe1summ->SetBinError(4,0.057);
probe1summ->Fill(labels[4],0.81);
probe1summ->SetBinError(5,0.043);
probe2summ->Fill(labels[0],1.280);
probe2summ->SetBinError(1,0.026);
probe2summ->Fill(labels[1],1.269);
probe2summ->SetBinError(2,0.021);
probe2summ->Fill(labels[2],1.05);
probe2summ->SetBinError(3,0.08);
probe2summ->Fill(labels[3],1.67);
probe2summ->SetBinError(4,0.050);
probe2summ->Fill(labels[4],1.42);
probe2summ->SetBinError(5,0.028);
probe3summ->Fill(labels[0],0.833);
probe3summ->SetBinError(1,0.026);
probe3summ->Fill(labels[1],1.423);
probe3summ->SetBinError(2,0.035);
probe3summ->Fill(labels[2],1.24);
probe3summ->SetBinError(3,0.118);
probe3summ->Fill(labels[3],1.60);
probe3summ->SetBinError(4,0.055);
probe3summ->Fill(labels[4],1.34);
probe3summ->SetBinError(5,0.038);
probe4summ->Fill(labels[0],-999);
probe4summ->SetBinError(1,-999);
probe4summ->Fill(labels[1],0.340);
probe4summ->SetBinError(2,0.071);
probe4summ->Fill(labels[2],0.38);
probe4summ->SetBinError(3,0.082);
probe4summ->Fill(labels[3],0.59);
probe4summ->SetBinError(4,0.054);
probe4summ->Fill(labels[4],0.48);
probe4summ->SetBinError(5,0.119);
probe1summ->GetXaxis()->SetTitle("run date");
probe1summ->GetXaxis()->CenterTitle(1);
probe1summ->GetYaxis()->SetTitle("temp. (C)");
probe1summ->GetYaxis()->CenterTitle(1);
probe1summ->SetMarkerColor(kBlue);
probe1summ->SetLineColor(kBlue);
probe2summ->SetMarkerColor(kRed);
probe2summ->SetLineColor(kRed);
probe3summ->SetMarkerColor(kGreen);
probe3summ->SetLineColor(kGreen);
probe4summ->SetMarkerColor(kCyan);
probe4summ->SetLineColor(kCyan);
probe1summ->SetMarkerStyle(20);
probe2summ->SetMarkerStyle(20);
probe3summ->SetMarkerStyle(20);
probe4summ->SetMarkerStyle(20);
probe1summ->SetMarkerSize(0.5);
probe2summ->SetMarkerSize(0.5);
probe3summ->SetMarkerSize(0.5);
probe4summ->SetMarkerSize(0.5);
probe1summ->SetMinimum(0);
probe1summ->SetMaximum(2);
probe1summ->GetXaxis()->SetLabelSize(0.05);
TLegend *leg = new TLegend(0.155,0.691,0.344,0.860);
leg->SetTextSize(0.035);
leg->SetTextColor(1);
leg->SetFillColor(0);
leg->Clear();
leg->AddEntry(probe1summ, "probe 1", "pl");
leg->AddEntry(probe2summ, "probe 2", "pl");
leg->AddEntry(probe3summ, "probe 3", "pl");
leg->AddEntry(probe4summ, "probe 4", "pl");
leg->SetFillColor(0);
leg->SetLineColor(0);
leg->SetTextFont(22);
gStyle->SetOptStat(0000);
TCanvas *tempSumm = new TCanvas();
//.........这里部分代码省略.........
示例11: vs_PlotQCDcomp
//.........这里部分代码省略.........
if ( hptFOR != 0 ) {
for (int b = 0; b < hptFOR->GetNbinsX(); b++) {
Double_t mainHistoContent = hptFOR->GetBinContent(b);
Double_t systUpHistoContent = hptSUR->GetBinContent(b);
Double_t systDnHistoContent = hptSDR->GetBinContent(b);
Double_t systDiffUp = fabs( (double) systUpHistoContent - mainHistoContent );
Double_t systDiffDn = fabs( (double) mainHistoContent - systDnHistoContent );
// use average error for histogram
Double_t systDiff = ( systDiffUp + systDiffDn ) / 2.;
Double_t statErr = hptFOR->GetBinError(b);
Double_t combError = sqrt( systDiff * systDiff + statErr * statErr );
hptFOR->SetBinError(b, combError);
} //for
}//if
cPt->SetLogy(1);
gPad->Update();
cPt->Update();
// hptR->Scale(1,"width");
// hptR->SetMinimum(0.02);
// hptR->SetMaximum(1000);
hptR->GetXaxis()->SetTitle("1^{st} photon p_{T} [GeV]");
hptR->GetYaxis()->SetTitle("Number of Events / GeV");
if(isMC) hptR->SetMarkerSize(0);
if(isMC) hptR->Draw("histE");
else hptR->Draw("E X0");
hptFOR->SetMarkerSize(0);
hptFOR->SetLineColor(2);
hptFOR->SetFillColor(2);
hptFOR->SetFillStyle(3004);
hptFOR->Draw("same hist ][ E2");
legend->Clear();
if(isMC) legend->SetHeader("#gamma/QCD (Sim)");
else legend->SetHeader("#gamma/QCD (Data)");
if(isMC) legend->AddEntry(hptR, "#gamma", "l");
else legend->AddEntry(hptR, "#gamma", "p");
legend->AddEntry(hptFOR, "Pred (from #gamma_{jet})", "f");
legend->Draw();
as->DrawLatex(0.17, 0.93, outLumi.c_str() );
cPt->Update();
cPt->SetBottomMargin(0.2 + 0.8 * cPt->GetBottomMargin() - 0.2 * cPt->GetTopMargin());
TPad *ratioPt = new TPad("BottomPad", "", 0, 0, 1, 1);
ratioPt->SetTopMargin(0.8 - 0.8 * ratioPt->GetBottomMargin() + 0.2 * ratioPt->GetTopMargin());
ratioPt->SetFillStyle(0);
ratioPt->SetFrameFillColor(10);
ratioPt->SetFrameBorderMode(0);
ratioPt->Draw();
ratioPt->cd();
ratioPt->SetLogy(0);
TH1F *hptRat = (TH1F*) divideHistosForRatio(hptR,hptFOR);
hptRat->SetMinimum(0.);
hptRat->SetMaximum(10.);
hptRat->GetXaxis()->SetNdivisions(505);
if(isMC) hptRat->GetYaxis()->SetTitle("Sim/Pred");
else hptRat->GetYaxis()->SetTitle("Data/Pred");
hptRat->GetYaxis()->SetTitleSize(0.04);
hptRat->GetYaxis()->SetLabelSize(0.03);
hptRat->GetYaxis()->SetTitleOffset(1.3);
hptRat->GetYaxis()->SetNdivisions(505);
hptRat->SetMarkerStyle(20);
hptRat->SetMarkerSize(1);
hptRat->SetMarkerColor(1);
hptRat->SetLineColor(1);
hptRat->Draw("E X0");
TH1F *hptFRat = (TH1F*) getSystErrForRatio(hptFOR);
hptFRat->SetLineColor(2);
hptFRat->SetFillColor(2);
hptFRat->SetFillStyle(3004);
hptFRat->Draw("same hist ][ E2");
TLine * line = new TLine( hptRat->GetXaxis()->GetXmin(), 1., hptRat->GetXaxis()->GetXmax(), 1. );
line->SetLineColor(1);
line->SetLineWidth(0.5);
line->SetLineStyle(1);
line->Draw("same");
hptR->GetXaxis()->SetLabelSize(0);
hptR->GetXaxis()->SetTitle("");
cPt->RedrawAxis();
gPad->Update();
cPt->Update();
return;
}
示例12: makeCorrRoofit2
//.........这里部分代码省略.........
for(int i=0;i<nMasspoint;i++)cout<<ptBinsCenterE[i]<<",";
cout<<endl;
for(int i=0;i<nMasspoint;i++)cout<<mean[1][i]<<",";
cout<<endl;
TLegend *leg = new TLegend(0.68, 0.65, 0.94, 0.90);
leg->SetBorderSize(0);
leg->SetFillColor(0);
leg->SetFillStyle(0);
leg->SetTextSize(0.04);
tg1[4]->GetXaxis()->SetTitle("jet Pt");
tg1[4]->GetYaxis()->SetTitle("M_{PDG}/M_{Reco}");
tg1[4]->SetTitle("Gen Correction");
tg1[4]->SetMinimum(1);
tg1[4]->SetMaximum(1.4);
tg1[4]->Draw("APL");
tg1[4]->SetFillColor(0);
tg1[5]->SetFillColor(0);
tg1[5]->SetLineColor(2);
tg1[5]->SetMarkerColor(2);
tg1[5]->Draw("PLsame");
tg1[4]->SetTitle("Higgs mass correction");
/*
TF1* recoOneBarel = new TF1("genBarel","[0]+[1]*pow(x*[2],-[3])");
recoOneBarel->SetParameters(
1.00626,
-1.06161,
0.07999,
1.20454
);
TF1* recoOneEndcap = new TF1("genEndcap","[0]+[1]*pow(x*[2],-[3])");
recoOneEndcap->SetParameters(
1.00626,
-1.06161,
0.07999,
1.20454
);
*/
leg->Clear();
TF1* puppisd_corrGEN = new TF1("puppisd_corrGEN","[0]+[1]*pow(x*[2],-[3])");
puppisd_corrGEN->SetParameters(
1.00626,
-1.06161,
0.07999,
1.20454
);
TF1* puppisd_corrRECO_cen = new TF1("puppisd_corrRECO_cen","([0]+[1]*x+[2]*pow(x,2)+[3]*pow(x,3)+[4]*pow(x,4)+[5]*pow(x,5))*([6]+[7]*pow(x*[8],-[9]))",200,2000);
puppisd_corrRECO_cen->SetParameters(
1.05807,
-5.91971e-05,
2.296e-07,
-1.98795e-10,
6.67382e-14,
-7.80604e-18,
1.00626,
-1.06161,
0.07999,
1.20454
);
TF1* puppisd_corrRECO_for = new TF1("puppisd_corrRECO_for","([0]+[1]*x+[2]*pow(x,2)+[3]*pow(x,3)+[4]*pow(x,4)+[5]*pow(x,5))*([6]+[7]*pow(x*[8],-[9]))",200,2000);
puppisd_corrRECO_for->SetParameters(
1.26638,
-0.000658496,
9.73779e-07,
-5.93843e-10,
1.61619e-13,
-1.6272e-17,
1.00626,
-1.06161,
0.07999,
1.20454);
leg->AddEntry(tg1[4],"H corr barrel");
leg->AddEntry(tg1[5],"H corr endcap");
leg->AddEntry(puppisd_corrRECO_cen,"Thea barrel");
leg->AddEntry(puppisd_corrRECO_for,"Thea endcap");
leg->Draw("same");
//genBarel->Draw("same");
// genEndcap->Draw("same");
puppisd_corrRECO_cen->SetLineColor(3);
puppisd_corrRECO_for->SetLineColor(4);
//tg1[2]->Draw("APL");
puppisd_corrRECO_cen->Draw("same");
puppisd_corrRECO_for->Draw("same");
c1->Print("plots/Correction.pdf");
}
示例13: makeEff
//.........这里部分代码省略.........
for(int i=0; i<13; i++) {
//cout<<tgraphSigEff[i]<<","<<tgraphSigEff145[i];
cout<<"i="<<i<<","<<tgraphSigEff[i]<<","<<tgraphBkgNum[i]<<","<<tgraphSgnEff[i]<<endl;
cout<<"i="<<i<<","<<tgraphSigEff145[i]<<","<<tgraphBkgNum145[i]<<","<<tgraphSgnEff145[i]<<endl;
tgraphSigEff[i]=tgraphSigEff[i]/tgraphSigEff145[i];
//cout<<tgraphSigEff[i]<<endl;
tgraphSigEffError[i]=sqrt((tgraphSigEffError[i]/tgraphSigEff[i])*(tgraphSigEffError[i]/tgraphSigEff[i])+(tgraphSigEffError145[i]/tgraphSigEff145[i])*(tgraphSigEffError145[i]/tgraphSigEff145[i]));
tgraphSigEffError[i]*=tgraphSigEff[i];
tgraphBkgEff[i]=tgraphBkgEff[i]/tgraphBkgEff145[i];
tgraphBkgEffError[i]=sqrt((tgraphBkgEffError[i]/tgraphBkgEff[i])*(tgraphBkgEffError[i]/tgraphBkgEff[i])+(tgraphBkgEffError145[i]/tgraphBkgEff145[i])*(tgraphBkgEffError145[i]/tgraphBkgEff145[i]));
tgraphBkgEffError[i]*=tgraphBkgEff[i];
tgraphSgnEff[i]=tgraphSgnEff[i]/tgraphSgnEff145[i];
tgraphSgnEffError[i]=sqrt((tgraphSgnEffError[i]/tgraphSgnEff[i])*(tgraphSgnEffError[i]/tgraphSgnEff[i])+(tgraphSgnEffError145[i]/tgraphSgnEff145[i])*(tgraphSgnEffError145[i]/tgraphSgnEff145[i]));
tgraphSgnEffError[i]*=tgraphSgnEff[i];
}
TGraphErrors* tg4= new TGraphErrors(13,tgraphMass,tgraphSigEff,tgraphMassError,tgraphSigEffError);
TGraphErrors* tg5= new TGraphErrors(13,tgraphMass,tgraphBkgEff,tgraphMassError,tgraphBkgEffError);
TGraphErrors* tg6= new TGraphErrors(13,tgraphMass,tgraphSgnEff,tgraphMassError,tgraphSgnEffError);
tg1->SetMaximum(1);
tg1->SetMinimum(0);
tg1->SetTitle("");
tg1->GetXaxis()->SetTitle("Mass of Z' [GeV]");
tg1->Draw("APL*");
tg2->SetLineColor(2);
tg3->SetLineColor(3);
tg1->SetMarkerStyle(20);
tg2->SetMarkerStyle(21);
tg3->SetMarkerStyle(22);
leg->Clear();
tg1->SetFillColor(kWhite);
tg2->SetFillColor(kWhite);
tg3->SetFillColor(kWhite);
gStyle->SetFillColor(kWhite) ;
leg->AddEntry(tg1,"signal eff.");
leg->AddEntry(tg2,"bkg. eff.");
leg->AddEntry(tg3,"significance");
tg2->Draw("PL,same");
tg3->Draw("PL,same");
leg->Draw("same");
c2->Print("png/1.png");
tg4->GetXaxis()->SetTitle("Mass of Z' [GeV]");
tg4->SetTitle("most significant window/105-145");
tg4->SetMaximum(2.2);
tg4->SetMinimum(0.3);
tg4->SetMarkerStyle(20);
tg5->SetMarkerStyle(21);
tg6->SetMarkerStyle(22);
tg4->Draw("APL");
tg5->SetLineColor(2);
tg6->SetLineColor(3);
leg->Clear();
tg4->SetFillColor(kWhite);
tg5->SetFillColor(kWhite);
tg6->SetFillColor(kWhite);
gStyle->SetFillColor(kWhite) ;
leg->AddEntry(tg4,"signal eff. ratio");
leg->AddEntry(tg5,"bkg. eff. ratio");
leg->AddEntry(tg6,"significance ratio");
示例14: plotHitEnergy
void plotHitEnergy(string inputDir, int hittype=1, float radius=0.4) {
setNCUStyle(true);
string decversion;
if(inputDir.find("rfull009")!=std::string::npos)decversion="rfull009";
else if(inputDir.find("rfull012")!=std::string::npos)decversion="rfull012";
TH1F* hecal;
TH1F* hhcal;
std::string ecalhitname = hittype==1? "EM_BARREL":"EcalBarrelHits";
std::string hcalhitname = hittype==1? "HAD_BARREL":"HcalBarrelHits";
TString energy=gSystem->GetFromPipe(Form("file=%s; test=${file##*/}; test2=${test%%mumu*}; echo \"${test2##*tev}\"",inputDir.data()));
cout << "energy = " << energy.Data() << endl;
string inputFile = inputDir + "/radius" + Form("%0.1f",radius)+ (hittype==1? "_rawhit.root": "_rawhit_new.root");
cout << "opening " << inputFile.data() << endl;
TFile *f = TFile::Open(inputFile.data());
hecal = (TH1F*)f->FindObjectAny("hecalhit_energy");
hecal->SetLineWidth(3);
hecal->SetFillStyle(1001);
hecal->SetFillColor(4);
hecal->SetLineColor(4);
hecal->SetXTitle(Form("%s hit energy [GeV]",ecalhitname.data()));
hecal->SetYTitle(Form("Number of hits per %.1f GeV",hecal->GetBinWidth(1)));
hecal->SetTitleOffset(1.2,"X");
hecal->SetTitleOffset(1.4,"Y");
hhcal = (TH1F*)f->FindObjectAny("hhcalhit_energy");
hhcal->SetLineWidth(3);
hhcal->SetFillStyle(1001);
hhcal->SetFillColor(2);
hhcal->SetLineColor(2);
hhcal->SetXTitle(Form("%s hit energy [GeV]",hcalhitname.data()));
hhcal->SetYTitle(Form("Number of hits per %.1f GeV",hhcal->GetBinWidth(1)));
hhcal->SetTitleOffset(1.2,"X");
hhcal->SetTitleOffset(1.4,"Y");
TLegend* leg = new TLegend(0.444,0.690,0.990,0.903);
leg->SetFillColor(0);
leg->SetFillStyle(0);
TCanvas* c1 = new TCanvas("c1","",500,500);
int lastbin=hecal->FindLastBinAbove(0)+20;
float xmax=hecal->GetBinLowEdge(lastbin);
hecal->GetXaxis()->SetRangeUser(0,xmax);
hecal->Draw("hist");
c1->SetLogy(1);
leg->SetHeader(decversion.data());
leg->AddEntry(hecal,Form("%s-TeV Z'#rightarrow qq",energy.Data()),"f");
leg->Draw("same");
std::string outputname = decversion + "/" + decversion + "_" + ecalhitname + "hit_energy_" + Form("%s",energy.Data()) + "TeVZp";
c1->Print(Form("%s.pdf",outputname.data()));
c1->Print(Form("%s.eps",outputname.data()));
leg->Clear();
lastbin=hhcal->FindLastBinAbove(0)+20;
xmax=hhcal->GetBinLowEdge(lastbin);
hhcal->GetXaxis()->SetRangeUser(0,xmax);
hhcal->Draw("hist");
c1->SetLogy(1);
leg->SetHeader(decversion.data());
leg->AddEntry(hhcal,Form("%s-TeV Z'#rightarrow qq",energy.Data()),"f");
leg->Draw("same");
outputname = decversion + "/" + decversion + "_" + hcalhitname + "hit_energy_" + Form("%s",energy.Data()) + "TeVZp";
c1->Print(Form("%s.pdf",outputname.data()));
c1->Print(Form("%s.eps",outputname.data()));
}
示例15: applySelectionTDC
//.........这里部分代码省略.........
//Loop Over the events passing ((*iterPlot).second).strSelLocal stored in eventList
//cout<<"i\tidx_EvtList\tSigma_Fit\n";
for (int i=0; i < listSelEvts->GetN(); ++i) { //Loop over events stored in eventList
//int iEvtIdx = listSelEvts->Next(); //Should probably use listSelEvts->GetEntry(i) because duplicate calls of Next() per loop iteration cause undesired iteration through the list
//treeInput->GetEntry( iEvtIdx );
treeInput->GetEntry( listSelEvts->GetEntry(i) );
//Skip this Event if the Histogram pointer is a null pointer
if (hTDC_Histo == nullptr){
continue;
}
else{ //Otherwise Set the Histogram Style
hTDC_Histo = getHistogram( (*iterPlot).second, hTDC_Histo);
}
//treeInput->Show();
//if(i==0) treeInput->Show();
//Set the Style
//Create the Canvas - Histogram w/Fit
//------------------------------------------------------
//set the style based on user input
//Make a copy of the CanvasInfo, reset the name, and then pass it to treeAnalyzer::getCanvas()
CanvasInfo tempCanvasInfo = (*iterCanvas).second;
tempCanvasInfo.strName = "canvas_DataHistoWithFit_R" + getString(iRun) + "_" + ((*iterPlot).second).strVarDepend + "_" + ((*iterPlot).second).strVarIndep + getString(fVarIndep);
TCanvas *cHistoWithFit = getCanvas(tempCanvasInfo);
cHistoWithFit->cd();
TLegend *leg = (TLegend *) ((*iterCanvas).second).leg->Clone( ("leg_HistoWithFit_" + getString(fVarIndep) ).c_str() );
leg->Clear(); //Wipe all previous entries
leg->AddEntry(hTDC_Histo,"Data","LPE");
//Plot Histogram on the Canvas
cHistoWithFit->cd();
hTDC_Histo->Draw("E1");
//Check that the fit function exists
if ( func_FriendBranch != nullptr) {
//Set the style
func_FriendBranch->SetLineColor( ((*iterPlot).second).iColor );
func_FriendBranch->SetLineStyle( ((*iterPlot).second).iStyleLine );
func_FriendBranch->SetLineWidth( ((*iterPlot).second).fSizeLine );
//Add to the Legend
leg->AddEntry(func_FriendBranch, "Fit", "L");
//Draw
func_FriendBranch->Draw("same");
}
//Draw the legend
leg->Draw("same");
//Store
dir_HistoWithFit->cd();
cHistoWithFit->Write();
hTDC_Histo->Write();
func_FriendBranch->Write();
//if ( func_FriendBranch != nullptr) func_FriendBranch->Write();
//Create the Canvas - Histogram DIVIDED by Fit