本文整理汇总了C++中TLegend::AddEntry方法的典型用法代码示例。如果您正苦于以下问题:C++ TLegend::AddEntry方法的具体用法?C++ TLegend::AddEntry怎么用?C++ TLegend::AddEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TLegend
的用法示例。
在下文中一共展示了TLegend::AddEntry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: plotv2vspt_4p_sys
//.........这里部分代码省略.........
for(int j = 0;j<grProd->GetN();j++){
double x = grProd->GetX()[j];
double y = grProd->GetY()[j];
double y_sys = grProdtc->GetY()[j];
grProdtcr->SetPoint(j,x,y_sys/y);
grProdtcr->SetPointError(j,0,0);
double y_sys = grProdlc->GetY()[j];
grProdlcr->SetPoint(j,x,y_sys/y);
grProdlcr->SetPointError(j,0,0);
double y_sys = grProdzl->GetY()[j];
grProdzlr->SetPoint(j,x,y_sys/y);
grProdzlr->SetPointError(j,0,0);
double y_sys = grProdzs->GetY()[j];
grProdzsr->SetPoint(j,x,y_sys/y);
grProdzsr->SetPointError(j,0,0);
double y_sys = grProdpu->GetY()[j];
grProdpur->SetPoint(j,x,y_sys/y);
grProdpur->SetPointError(j,0,0);
grProdr->SetPoint(j,x,1.);
grProdr->SetPointError(j,0,0);
}
c1->cd(t);
hFrame->SetMaximum(0.35);
hFrame->SetMinimum(0);
hFrame->GetYaxis()->SetTitle("v_{2}");
hFrame->DrawCopy();
grProd->Draw("Psame");
grProdtc->Draw("Psame");
grProdlc->Draw("Psame");
TLegend *tl = new TLegend(0.2,0.70,0.4,0.95);
tl->SetFillColor(0);
tl->SetBorderSize(0);
tl->SetTextSize(0.055);
tl->AddEntry(grProd,"v_{2}{LYZ}","lp");
tl->AddEntry(grProdtc,"v_{2}{LYZ} loose cut ","lp");
tl->AddEntry(grProdlc,"v_{2}{LYZ} tight cut","lp");
TLatex *tlx0 = new TLatex(0.2,0.85,Form("CMS PbPb #sqrt{s_{NN}} = 2.76TeV"));
tlx0->SetNDC();
tlx0->SetTextSize(0.065);
if(t==1)
tlx0->Draw("same");
if(t==1)
TLatex *tlx2 = new TLatex(0.6,0.2,Form("%d<N_{trk}^{offline}<%d",trkbin[i+1],trkbin[i]));
else
TLatex *tlx2 = new TLatex(0.5,0.2,Form("%d<N_{trk}^{offline}<%d",trkbin[i+1],trkbin[i]));
if(t==2) tl->Draw("same");
tlx2->SetNDC();
tlx2->SetTextSize(0.055);
tlx2->Draw("same");
c2->cd(t);
hFrame->SetMaximum(0.35);
hFrame->SetMinimum(0);
hFrame->GetYaxis()->SetTitle("v_{2}");
hFrame->DrawCopy();
grProd->Draw("Psame");
grProdzl->Draw("Psame");
grProdzs->Draw("Psame");
TLegend *tl = new TLegend(0.2,0.70,0.4,0.95);
tl->SetFillColor(0);
tl->SetBorderSize(0);
tl->SetTextSize(0.055);
tl->AddEntry(grProd,"v_{2}{LYZ}","lp");
tl->AddEntry(grProdzl,"v_{2}{LYZ} 3 < zvertex < 15 ","lp");
tl->AddEntry(grProdzs,"v_{2}{LYZ} zvertex < 3","lp");
TLatex *tlx0 = new TLatex(0.2,0.85,Form("CMS PbPb #sqrt{s_{NN}} = 2.76TeV"));
示例2: compare3
//.........这里部分代码省略.........
binHi = nbins;
xmin = h[0]->GetBinLowEdge(1);
xmax = h[0]->GetBinLowEdge(nbins+1);
}
float scaleFactor[NHISTOS]={1};
for(int ih=0; ih < NHISTOS; ih++){
float integral = h[ih]->Integral(binLo,binHi);
scaleFactor[ih] = integral > 0? 1.0/integral: 1;
h[ih]->Sumw2();
h[ih]->Scale(scaleFactor[ih]);
}
for(int ih=0; ih < NHISTOS; ih++)
cout << "histogram " << ih << " integral = " << h[ih]->Integral() << endl;
for(int ih=0; ih < NHISTOS; ih++)
cout << "histogram " << ih << " integral = " << h[ih]->Integral(binLo,
binHi)
<< endl;
vector<float> maxArray;
maxArray.clear();
for(int ih=0; ih < NHISTOS; ih++){
h[ih]->GetXaxis()->SetRangeUser(xmin,xmax);
float max_this = h[ih]->GetBinError(h[ih]->GetMaximumBin()) + h[ih]->GetMaximum();
maxArray.push_back(max_this);
}
float max = *max_element(maxArray.begin(),maxArray.end());
cout << "Max = " << max << endl;
for(int ih=0; ih < NHISTOS; ih++){
h[ih]->SetMaximum(1.1*max);
}
cout << "here" << endl;
TCanvas* c1 = new TCanvas("c1","",600,500);
if(logScale)
gPad->SetLogy(1);
gStyle->SetTitleX(0.1);
h[0]->Draw("e");
for(int ih=0; ih < NHISTOS-1; ih++)
h[ih]->Draw("esame");
h[NHISTOS-1]->Draw("hesame");
TLine mLocation(MZ_PDG,0.0,MZ_PDG,h[0]->GetMaximum());
mLocation.SetLineStyle(2);
mLocation.SetLineColor(kMagenta-6);
mLocation.SetLineWidth(3);
if(var.find("mjj")!=std::string::npos || var.find("mll")!=std::string::npos)
mLocation.Draw("same");
float x1NDC = 0.669355;
float y1NDC = 0.708475;
float x2NDC = 0.889113;
float y2NDC = 0.925847;
std::string headertitle = "H^{0}#rightarrow ZZ#rightarrow 2l2q";
TLegend* leg = new TLegend(x1NDC,y1NDC,x2NDC,y2NDC);
leg->SetFillColor(0);
leg->SetFillStyle(0);
leg->SetTextSize(0.04);
leg->SetBorderSize(0);
leg->SetHeader("anti-kt05");
for(int i=0; i < NHISTOS; i++)
leg->AddEntry(h[i], mcName[i].data());
leg->Draw("same");
string dirName = "20120913_3histograms";
gSystem->mkdir(dirName.data());
std::string filename;
std::string psname = dirName + "/ak5" + var;
if(logScale)
psname += "_log";
filename = psname + ".eps";
c1->Print(filename.data());
filename = psname + ".gif";
c1->Print(filename.data());
filename = psname + ".pdf";
c1->Print(filename.data());
// c1->Close();
}
示例3: toy_bootstrap
void toy_bootstrap(){
// random number seed
GSLr.SetSeed(1);
// run measurements, fill graphs
TGraph *g1D = new TGraph();
TGraphErrors *g2D = new TGraphErrors();
TGraph *g1DIndPE = new TGraph();
TGraph *g2DIndPE = new TGraph();
TGraph *g1DBPE = new TGraph();
TGraph *g2DBPE = new TGraph();
TGraph *g1Dm = new TGraph();
TGraphErrors *g2Dm = new TGraphErrors();
TGraph *g1DIndPEm = new TGraph();
TGraph *g2DIndPEm = new TGraph();
TGraph *g1DBPEm = new TGraph();
TGraph *g2DBPEm = new TGraph();
for(int i=0; i < 10; i++){
rho12 = 1.0*i/10;
cout << "#################### rho = " << rho12 << " ####################" << endl;
run_measurement();
g2D->SetPoint(i, rho12+0.05, X2Drms);
g2D->SetPointError(i, 0.05, 0.0);
g1D->SetPoint(i, rho12+0.05, X1Drms);
g1DIndPE->SetPoint(i, rho12+0.02, XI1Drms);
g2DIndPE->SetPoint(i, rho12+0.04, XI2Drms);
g1DBPE->SetPoint(i, rho12+0.06, XB1Drms);
g2DBPE->SetPoint(i, rho12+0.08, XB2Drms);
g2Dm->SetPoint(i, rho12+0.05, X2Dmean);
g2Dm->SetPointError(i, 0.05, 0.0);
g1Dm->SetPoint(i, rho12+0.05, X1Dmean);
g1DIndPEm->SetPoint(i, rho12+0.02, XI1Dmean);
g2DIndPEm->SetPoint(i, rho12+0.04, XI2Dmean);
g1DBPEm->SetPoint(i, rho12+0.06, XB1Dmean);
g2DBPEm->SetPoint(i, rho12+0.08, XB2Dmean);
}
TCanvas *canvas = new TCanvas("canvas","canvas",800,800);
canvas->cd();
g2D->SetMarkerStyle(20);
g1D->SetLineColor(2);
g1D->SetMarkerColor(2);
g1D->SetMarkerStyle(5);
g1DIndPE->SetLineColor(3);
g1DIndPE->SetMarkerColor(3);
g1DIndPE->SetMarkerStyle(20);
g2DIndPE->SetLineColor(4);
g2DIndPE->SetMarkerColor(4);
g2DIndPE->SetMarkerStyle(20);
g1DBPE->SetLineColor(7);
g1DBPE->SetMarkerColor(7);
g1DBPE->SetMarkerStyle(20);
g2DBPE->SetLineColor(6);
g2DBPE->SetMarkerColor(6);
g2DBPE->SetMarkerStyle(20);
g2D->Draw("APE");
g1D->Draw("P");
g1DIndPE->Draw("P");
g2DIndPE->Draw("P");
g1DBPE->Draw("P");
g2DBPE->Draw("P");
TLegend * legend = new TLegend(0.717,0.650,0.874,0.870);
legend->AddEntry( g2D, "2D fit MINUIT error", "p" );
legend->AddEntry( g1D, "1D fit MINUIT error", "p" );
legend->AddEntry( g2DIndPE, "2D fit, Ind. PE RMS", "p" );
legend->AddEntry( g1DIndPE, "1D fit, Ind. PE RMS", "p" );
legend->AddEntry( g2DBPE, "2D fit, Boot PE RMS", "p" );
legend->AddEntry( g1DBPE, "1D fit, Boot PE RMS", "p" );
legend->Draw("same");
canvas->Draw();
// plot means
TCanvas *canvasm = new TCanvas("canvasm","canvasm",800,800);
canvasm->cd();
g2Dm->SetMarkerStyle(20);
g1Dm->SetLineColor(2);
g1Dm->SetMarkerColor(2);
g1Dm->SetMarkerStyle(5);
g1DIndPEm->SetLineColor(3);
g1DIndPEm->SetMarkerColor(3);
g1DIndPEm->SetMarkerStyle(20);
g2DIndPEm->SetLineColor(4);
g2DIndPEm->SetMarkerColor(4);
g2DIndPEm->SetMarkerStyle(20);
g1DBPEm->SetLineColor(7);
//.........这里部分代码省略.........
示例4: if
//.........这里部分代码省略.........
if(iw==3||iw==7||iw==11) gPad->SetRightMargin(0.02);
char ch1[8];
sprintf(ch1,"h1_%d",iw);
h1[iw] = new TH1D(ch1,"",500,hxmin[iw],hxmax[iw]);
h1[iw]->SetMinimum(hymin[iw]); h1[iw]->SetMaximum(hymax[iw]);
h1[iw]->SetXTitle(atit[iw][0]); h1[iw]->SetYTitle(atit[iw][1]);
h1[iw]->GetXaxis()->CenterTitle(1);
h1[iw]->GetYaxis()->CenterTitle(1);
// futz with the axes
h1[iw]->GetYaxis()->SetNdivisions(606);
h1[iw]->GetXaxis()->SetNdivisions(606);
h1[iw]->GetYaxis()->SetTitleSize(textsize);
h1[iw]->GetYaxis()->SetTitleOffset(3.0);
h1[iw]->GetYaxis()->SetLabelSize(textsize);
h1[iw]->GetXaxis()->SetTitleSize(textsize);
h1[iw]->GetXaxis()->SetTitleOffset(3.0);
h1[iw]->GetXaxis()->SetLabelSize(textsize);
// h1[iw]->GetXaxis()->SetLabelOffset(1.2);
h1[iw]->Draw();
}
//
// Draw!
//
cout << "Now Draw!" << endl;
TGraphErrors *ge;
for (int iw=0;iw<nw-2;iw++)
{
can->cd(iw+1);
//
if (iw==0)
{
tex=new TLatex(1.5,8.08,"CMS PbPb #sqrt{s_{NN}}=2.76TeV");
tex->SetTextSize(textsize);
//tex->Draw();
tex=new TLatex(1.5,7.07,"|#eta|<0.8");
tex->SetTextSize(textsize);
tex->Draw();
}
if (iw < 4) tex=new TLatex(ptit[iw][0],ptit[iw][1],htit[iw]);
else tex=new TLatex(ptit[iw][0],ptit[iw][1],htit[iw]);
if ( iw == 0) tex->SetTextSize(textsize);
else if (iw == 8) tex->SetTextSize(textsize);
else tex->SetTextSize(textsize);
tex->Draw();
//
// Legend
//
TLegend *leg = new TLegend(lxmin[iw]*3.3,lymin[iw]*1.3,lxmax[iw]*2.2,lymax[iw]*1.3);
leg->SetTextSize(textsize);
//
// Read data
//
for (int im=0;im<1;im++)
{
int j=im*12+iw;
int col=1;
//if (ndp[j]==0) continue;
ge=new TGraphErrors(16,&xa[j][0],&nya[j][0],&xe[j][0],&nye[j][0]);
ge->SetTitle("");
ge->SetMarkerStyle(msty[im][1]);
// ge->SetMarkerStyle(msty[im]);
ge->SetMarkerSize(msiz[im]);
ge->SetMarkerColor(col);
ge->SetLineWidth(1.2);
ge->SetLineColor(col);
ge->Draw("pe");
leg->AddEntry(ge,"Steve/Shengquan","p");
}
if (iw==1) leg->Draw();
TLine *line = new TLine(0,1,6.8,1);
line->SetLineStyle(2);
line->Draw();
/*
for (int im=0;im<1;im++)
{
int j=im*12+iw;
int col=2;
//if (ndp[j]==0) continue;
ge=new TGraphErrors(16,&nxa[j][0],&nya[j][0],&nxe[j][0],&nye[j][0]);
ge->SetTitle("");
ge->SetMarkerStyle(25);
// ge->SetMarkerStyle(msty[im]);
ge->SetMarkerSize(msiz[im]);
ge->SetMarkerColor(col);
ge->SetLineWidth(1.2);
ge->SetLineColor(col);
ge->Draw("pe");
leg->AddEntry(ge,"Steve","p");
}
*/
}
cout << "end of process" << endl;
can->cd();
can->Print("./figures/v723_pt_12cent.png");
can->Print("./figures/v723_pt_12cent.pdf");
}
示例5: fastEfficiencyNadir
//.........这里部分代码省略.........
ca->SetGridx();
ca->SetGridy();
ca->cd();
gPad->SetLogx();
gPad->SetObjectStat(1);
frame->GetYaxis()->SetRangeUser(0,1.05);
frame->GetXaxis()->SetRangeUser(1,100.);
frame->GetYaxis()->SetTitle("Efficiency");
frame->GetXaxis()->SetTitle("E_{T} [GeV]");
frame->Draw() ;
frame2->GetYaxis()->SetRangeUser(0,1.05);
frame2->GetXaxis()->SetRangeUser(1,100.);
frame2->GetYaxis()->SetTitle("Efficiency");
frame2->GetXaxis()->SetTitle("E_{T} [GeV]");
frame2->Draw("same") ;
TH1F *SCeta1 = new TH1F("SCeta1","SCeta1",50,-2.5,2.5);
TH1F *SCeta2 = new TH1F("SCeta2","SCeta2",50,-2.5,2.5);
SCeta1->SetLineColor(color1) ;
SCeta1->SetMarkerColor(color1);
SCeta1->SetMarkerStyle(style1);
SCeta2->SetLineColor(color2) ;
SCeta2->SetMarkerColor(color2);
SCeta2->SetMarkerStyle(style2);
TLegend *leg = new TLegend(0.246,0.435,0.461,0.560,NULL,"brNDC"); // mid : x=353.5
leg->SetLineColor(1);
leg->SetTextColor(1);
leg->SetTextFont(42);
leg->SetTextSize(0.03);
leg->SetShadowColor(kWhite);
leg->SetFillColor(kWhite);
leg->SetMargin(0.25);
TLegendEntry *entry=leg->AddEntry("NULL","L1_SingleEG"+names[iEG],"h");
// leg->AddEntry(SCeta1,name_leg_ecal[iECAL1]+" "+name_leg_coll[iColl1],"p");
// leg->AddEntry(SCeta2,name_leg_ecal[iECAL2]+" "+name_leg_coll[iColl2],"p");
leg->AddEntry(SCeta1,name_leg_ecal[iECAL1],"p");
leg->AddEntry(SCeta2,name_leg_ecal[iECAL2],"p");
leg->Draw();
leg = new TLegend(0.16,0.725,0.58,0.905,NULL,"brNDC");
leg->SetBorderSize(0);
leg->SetTextFont(62);
leg->SetTextSize(0.03);
leg->SetLineColor(0);
leg->SetLineStyle(1);
leg->SetLineWidth(1);
leg->SetFillColor(0);
leg->SetFillStyle(0);
leg->AddEntry("NULL","CMS Preliminary 2012 pp #sqrt{s}=8 TeV","h");
leg->AddEntry("NULL","#int L dt = "+lumi+"^{-1}","h");
leg->AddEntry("NULL","Threshold : "+names[iEG]+" GeV","h");
leg->Draw();
TPaveText *pt2 = new TPaveText(0.220,0.605,0.487,0.685,"brNDC"); // mid : x=353.5
pt2->SetLineColor(1);
pt2->SetTextColor(1);
pt2->SetTextFont(42);
pt2->SetTextSize(0.03);
pt2->SetFillColor(kWhite);
pt2->SetShadowColor(kWhite);
pt2->AddText("L1 E/Gamma Trigger");
pt2->AddText("Electrons from Z");
pt2->Draw();
//TString name_image="eff_EG20_2012_12fb";
ca->Print(name_image+".cxx","cxx");
ca->Print(name_image+".png","png");
ca->Print(name_image+".gif","gif");
ca->Print(name_image+".pdf","pdf");
ca->Print(name_image+".ps","ps");
ca->Print(name_image+".eps","eps");
/////////////////////////////
// SAVE THE ROO FIT RESULT //
/////////////////////////////
RooWorkspace *w = new RooWorkspace("workspace","workspace") ;
w->import(dataSet);
w->import(dataSet2);
w->import(*roofitres1,"roofitres1");
w->import(*roofitres2,"roofitres2");
cout << "CREATES WORKSPACE : " << endl;
w->Print();
w->writeToFile(name_image+"_fitres.root") ;
//gDirectory->Add(w) ;
//f1->Close();
}
示例6: rpc_time_plots
void rpc_time_plots() {
TFile *data = new TFile("/phenix/spin/phnxsp01/danielj/w_asymmetry_analysis_files/run13/wness_tree/run13_data_total_wness_refrun367593.root");
TTree *temp_tree = (TTree*)data->Get("wness_tree");
TTree *data_tree = (TTree*)temp_tree->Clone("data_tree");
TFile *sim = new TFile("/phenix/spin/phnxsp01/danielj/w_asymmetry_analysis_files/run13/wness_tree/current_wness_tree_sig_sim.root");
temp_tree = (TTree*)sim->Get("wness_tree");
TTree *sim_tree = (TTree*)temp_tree->Clone("sim_tree");
TH1F *h_sim[2];
TH1F *h_data_low[2];
TH1F *h_data_hi[2];
h_sim[0] = new TH1F("h_sim_rpc1","h_sim_rpc1",44,0,44);
sim_tree->Project("h_sim_rpc1","Rpc1time","Rpc1time<100");
h_data_low[0] = new TH1F("h_data_low_rpc1","h_data_low_rpc1",44,0,44);
data_tree->Project("h_data_low_rpc1","Rpc1time","Rpc1time<100 && Wness<.92");
h_data_hi[0] = new TH1F("h_data_hi_rpc1","h_data_hi_rpc1",44,0,44);
data_tree->Project("h_data_hi_rpc1","Rpc1time","Rpc1time<100 && Wness>.92");
h_sim[1] = new TH1F("h_sim_rpc3","h_sim_rpc3",44,0,44);
sim_tree->Project("h_sim_rpc3","Rpc3time","Rpc3time<100");
h_data_low[1] = new TH1F("h_data_low_rpc3","h_data_low_rpc3",44,0,44);
data_tree->Project("h_data_low_rpc3","Rpc3time","Rpc3time<100 && Wness<.92");
h_data_hi[1] = new TH1F("h_data_hi_rpc3","h_data_hi_rpc3",44,0,44);
data_tree->Project("h_data_hi_rpc3","Rpc3time","Rpc3time<100 && Wness>.92");
TCanvas *c1;
c1= new TCanvas("Wness","Wness",800,600);
gPad->SetLogy();
gStyle->SetOptStat(0);
double data_low_integral[2];
double data_hi_integral[2];
double sim_integral[2];
//data_low_integral[0] = h_data_low[0]->Integral("width");
//data_hi_integral[0] = h_data_hi[0]->Integral("width");
//sim_integral[0] = h_sim[0]->Integral("width");
data_low_integral[0] = h_data_low[0]->GetMaximum();
data_hi_integral[0] = h_data_hi[0]->GetMaximum();
sim_integral[0] = h_sim[0]->GetMaximum();
h_data_low[0]->Scale(1.0/data_low_integral[0]);
h_data_hi[0]->Scale(1.0/data_hi_integral[0]);
h_sim[0]->Scale(1.0/sim_integral[0]);
h_data_low[0]->SetLineColor(kRed);
h_data_hi[0]->SetLineColor(kBlue);
h_sim[0]->SetLineColor(kBlack);
h_sim[0]->SetTitle("");
h_sim[0]->GetXaxis()->SetTitle("RpcTimeBin");
h_sim[0]->GetXaxis()->SetTitleSize(.06);
h_sim[0]->GetXaxis()->SetTitleOffset(0.85);
h_sim[0]->GetXaxis()->SetLabelSize(.05);
h_sim[0]->GetYaxis()->SetTitle("Normalized Yields");
h_sim[0]->GetYaxis()->SetTitleSize(.06);
h_sim[0]->GetYaxis()->SetTitleOffset(0.85);
h_sim[0]->GetYaxis()->SetLabelSize(.05);
h_sim[0]->SetTitle("RPC1");
h_sim[0]->Draw();
h_data_low[0]->Draw("SAME");
h_data_hi[0]->Draw("SAME");
TLegend * leg = new TLegend(0.5,0.75,0.9,0.9);
leg->AddEntry(h_data_low[0],"Data < .92 Wness");
leg->AddEntry(h_data_hi[0],"Data > .92 Wness");
leg->AddEntry(h_sim[0],"W->#mu Sim");
leg->Draw();
TCanvas *c2;
c2= new TCanvas("rpc3","rpc3",800,600);
//data_low_integral[1] = h_data_low[1]->Integral("width");
//data_hi_integral[1] = h_data_hi[1]->Integral("width");
//sim_integral[1] = h_sim[1]->Integral("width");
data_low_integral[1] = h_data_low[1]->GetMaximum();
data_hi_integral[1] = h_data_hi[1]->GetMaximum();
sim_integral[1] = h_sim[1]->GetMaximum();
h_data_low[1]->Scale(1.0/data_low_integral[1]);
h_data_hi[1]->Scale(1.0/data_hi_integral[1]);
h_sim[1]->Scale(1.0/sim_integral[1]);
h_data_low[1]->SetLineColor(kRed);
h_data_hi[1]->SetLineColor(kBlue);
h_sim[1]->SetLineColor(kBlack);
h_sim[1]->SetTitle("");
h_sim[1]->GetXaxis()->SetTitle("RpcTimeBin");
h_sim[1]->GetXaxis()->SetTitleSize(.06);
h_sim[1]->GetXaxis()->SetTitleOffset(0.85);
h_sim[1]->GetXaxis()->SetLabelSize(.05);
h_sim[1]->GetYaxis()->SetTitle("Normalized Yields");
h_sim[1]->GetYaxis()->SetTitleSize(.06);
h_sim[1]->GetYaxis()->SetTitleOffset(0.85);
h_sim[1]->GetYaxis()->SetLabelSize(.05);
//.........这里部分代码省略.........
示例7: Hist_Fit
//*** Main Fitting Fxn *****//
void Hist_Fit(char *Ifile){
TFile *ifile = new TFile(Ifile);
IhistEEM = (TH1F*)ifile->Get("BkgEst/my.ALL_EEM_pho_time"); // use EE- to get fit fxn and try in on EE+
IhistEEP = (TH1F*)ifile->Get("BkgEst/my.ALL_EEP_pho_time");
IhistEB = (TH1F*)ifile->Get("BkgEst/my.g_timeEB");
// gDirectory->GetObject("BkgEst/my.ALL_EEM_pho_time;1", IhistEEM);
// gDirectory->GetObject("BkgEst/my.ALL_EEP_pho_time;1", IhistEEP);
if(IhistEEM == 0){ std::cout <<"!! Histogram Does not exist!!" << std::endl; throw 1;}
if(IhistEEP == 0){ std::cout <<"!! Histogram Does not exist!!" << std::endl; throw 1;}
// fitFcn = new TF1("Totalfitfunc", "gaus(0) + gaus(3) + gaus(6) + gaus(9) + gaus(12) + gaus(15) + gaus(18) + gaus(21) + gaus(24)", -5.0 , 25.0,24);
// fitFcn = new TF1("fitFcn", fitf, -5.0, 25.0, 24);
fitFcn->SetNpx(500);
fitFcn->SetLineWidth(4);
fitFcn->SetLineColor(kBlue);
// Fit Each fxn and Add it to the List
IhistEEM->Fit(g0, "R");
IhistEEM->Fit(g1, "R+");
IhistEEM->Fit(g2, "R+");
IhistEEM->Fit(g3, "R+");
IhistEEM->Fit(g4, "R+");
IhistEEM->Fit(g5, "R+");
IhistEEM->Fit(g6, "R+");
IhistEEM->Fit(g7, "R+");
IhistEEM->Fit(g8, "R+");
// GetParameters from each fit first
g0->GetParameters(&par[0]);
g1->GetParameters(&par[3]);
g2->GetParameters(&par[6]);
g3->GetParameters(&par[9]);
g4->GetParameters(&par[12]);
g5->GetParameters(&par[15]);
g6->GetParameters(&par[18]);
g7->GetParameters(&par[21]);
g8->GetParameters(&par[24]);
//set parms as parms of Fit Fxn
fitFcn->SetParameters(par);
// Now Do the Final Fit to see How it looks on the Histogram
IhistEEM->Fit(fitFcn, "R+");
std::cout << "Printing Fit Parameters For EE- ...... " << std::endl;
fitFcn->GetParameters(par);
// Gets integral of function between fit limits
printf("Integral of function in EE- = %g\n",fitFcn->Integral(-2,2));
IhistEEP->Fit(fitFcn, "R+"); // Try Fit on EE+
std::cout << "Printing Fit Parameters For EE- ...... " << std::endl;
fitFcn->GetParameters(par);
printf("Integral of function in EE+ = %g\n",fitFcn->Integral(-2,2));
//test Fit on EB
IhistEB->Fit(fitFcn, "R+"); // Try Fit on EE+
std::cout << "Printing Fit Parameters For EB ...... " << std::endl;
fitFcn->GetParameters(par);
printf("Integral of function in EB = %g\n",fitFcn->Integral(-2,2));
TCanvas *c1 = new TCanvas("c1_fit","Fit Canvas EE-",200,10,800,900);
c1->SetGridx();
c1->SetGridy();
c1->GetFrame()->SetFillColor(21);
c1->GetFrame()->SetBorderMode(-1);
c1->GetFrame()->SetBorderSize(5);
// c1->Divide(2,1);
c1->cd();
IhistEEM->Draw();
fitFcn->Draw("sames");
// draw the legend
TLegend *leg = new TLegend(0.5,0.55,0.78,0.65);
leg->SetTextFont(72);
leg->SetTextSize(0.04);
leg->AddEntry(IhistEEM,"EE- Data","lpe");
leg->AddEntry(fitFcn,"Global Fit","l");
leg->Draw();
TCanvas *c2 = new TCanvas("c2_fit","Fit Canvas EE+",200,10,800,900);
c2->SetGridx();
c2->SetGridy();
c2->GetFrame()->SetFillColor(21);
c2->GetFrame()->SetBorderMode(-1);
c2->GetFrame()->SetBorderSize(5);
c2->cd();
IhistEEP->Draw();
fitFcn->Draw("sames");
TLegend *leg1 = new TLegend(0.5,0.55,0.78,0.65);
leg1->SetTextFont(72);
leg1->SetTextSize(0.04);
leg1->AddEntry(IhistEEP,"EE+ Data","lpe");
leg1->AddEntry(fitFcn,"Global Fit","l");
//.........这里部分代码省略.........
示例8: getEff3
//Assume h3 a ratio
void getEff3(TH1D* h1, TH1D* h2, TH1D* h3, bool isData, TString varType, TString INPUTDIR_PREFIX, double from, double to) {
gStyle->SetOptTitle(0);
gStyle->SetEndErrorSize(2);
gStyle->SetErrorX(0.5);
TLegend* leg = MakeLegend();
TPaveText* pt = MakeTPave();
TCanvas* c1 = new TCanvas("c1","c1",800,600);
c1->cd();
if (varType != "rapidity") c1->SetLogx();
h1->SetMarkerSize(0);
h1->SetLineWidth(1.2);
//range
if (varType == "pt") h1->GetXaxis()->SetRangeUser(8,180);
else if (varType == "vtx") h1->GetXaxis()->SetRangeUser(0,20.4);
else if (varType == "mass") h1->GetXaxis()->SetRangeUser(15, 999);
h1->GetYaxis()->SetRangeUser(from,to);
h1->GetXaxis()->SetMoreLogLabels();
h1->GetYaxis()->SetTitle("#epsilon");
h1->SetLineColor(kRed);
h1->SetFillColor(kRed);
if (!isData) {
h2->SetLineColor(kBlue);
h2->SetFillColor(kBlue);
} else {
h2->SetMarkerStyle(20);
h2->SetMarkerSize(1.1);
}
h3->SetLineColor(kGreen);
h3->SetFillColor(kGreen);
h3->SetFillStyle(3144);
//if you compare data to data
h1->Draw("E2");
h1->GetXaxis()->SetTitle(getTitle(varType, true));
if (!isData) {
h2->Draw("E2same");
} else {
h2->Draw("samePE");
}
h3->Draw("E2same");
leg->AddEntry(h1,"MC T&P","f");
//leg->AddEntry(h1,"MC truth","f");
if (!isData) {
leg->AddEntry(h2,"MC T&P","f");
} else {
leg->AddEntry(h2,"Data T&P","pl");
//leg->AddEntry(h2,h2->GetName(),"pl");
}
leg->AddEntry(h3,"Ratio","f");
//leg->AddEntry(h3,"T&P correction map","f");
leg->Draw("same");
//if (dataOnly && !(varType == "rrr")) pt->Draw("same");
//if (varType == "pt") c1->SetLogx();
//Save
c1->SaveAs(INPUTDIR_PREFIX+"/"+h3->GetName()+varType+".png");
c1->SaveAs(INPUTDIR_PREFIX+"/"+h3->GetName()+varType+".C");
}
示例9: getEff3Stats
//Assume heff_mct, htp, htpd, rat
void getEff3Stats(TH1D* h1, TH1D* h2, TH1D* h3, TH1D* h4, bool isData, TString varType, TString INPUTDIR_PREFIX, double from, double to) {
gStyle->SetOptTitle(0);
gStyle->SetEndErrorSize(2);
gStyle->SetErrorX(0.5);
TLegend* leg = MakeLegend();
TPaveText* pt = MakeTPave();
TCanvas* c1 = new TCanvas("c1","c1",800,600);
c1->cd();
if (varType != "rapidity") c1->SetLogx();
h1->SetMarkerSize(0);
h1->SetLineWidth(1.2);
//range
if (varType == "pt") h1->GetXaxis()->SetRangeUser(8,180);
else if (varType == "vtx") h1->GetXaxis()->SetRangeUser(0,20.4);
else if (varType == "mass") h1->GetXaxis()->SetRangeUser(15, 999);
h1->GetYaxis()->SetRangeUser(from,to);
h1->GetXaxis()->SetMoreLogLabels();
h1->GetYaxis()->SetTitle("#epsilon");
h1->SetLineColor(kRed);
h1->SetFillColor(kRed);
h2->SetLineColor(kBlue);
h2->SetFillColor(kBlue);
h4->SetLineColor(kGreen);
h4->SetFillColor(kGreen);
h4->SetFillStyle(3144);
//if you compare data to data
h1->Draw("E2");
h1->GetXaxis()->SetTitle(getTitle(varType, true));
h2->Draw("E2same");
h4->Draw("E2same");
leg->AddEntry(h1,"MC Truth","f");
leg->AddEntry(h2,"MC T&P","f");
leg->AddEntry(h4,"Ratio","f");
leg->Draw("same");
//if (dataOnly && !(varType == "rrr")) pt->Draw("same");
//if (varType == "pt") c1->SetLogx();
gROOT->ProcessLine(".L ../tools/stattools.C");
//Make TPave
ostringstream tmpstrm1;
ostringstream tmpstrm2;
ostringstream tmpstrm3;
tmpstrm3 << INPUTDIR_PREFIX << " " << h1->GetName();
tmpstrm1 << estimatorPerMassHisto1(h2,h3);
tmpstrm2 << estimatorPerMassHisto2(h2,h3,h1);
TPaveText *pt = new TPaveText(0.25,0.77,0.40,0.92,"brNDC");
pt->SetFillColor(0);
// pt->SetTextFont(72);
pt->SetTextSize(0.040);
pt->SetBorderSize(0);
pt->SetTextAlign(12);
pt->AddText(TString(tmpstrm3.str().c_str()));
pt->AddText("Simple estimator: "+TString(tmpstrm1.str().c_str()));
pt->AddText("Combined estimator: "+TString(tmpstrm2.str().c_str()));
pt->Draw("same");
//Save
c1->SaveAs(INPUTDIR_PREFIX+"/stats"+h1->GetName()+varType+".png");
}
示例10: draw_inLumi
//.........这里部分代码省略.........
hbxD_a->SetMarkerColor(2);
hbxD_eff->Divide(hbxD_dZ, hbxD_a, 1, 1, "b");
hbxD_eff->SetMaximum(1.05);
hbxD_eff->SetMinimum(0.550);
TH1F * hbxDno_eff = (TH1F*)hbxDno_dZ->Clone("hbxDno_eff");
hbxDno_eff->Sumw2();
hbxDno_eff->SetMinimum(0);
hbxDno_a->SetMarkerColor(1);
hbxDno_eff->Divide(hbxDno_dZ, hbxDno_a, 1, 1, "b");
hbxDno_eff->SetMaximum(1.05);
hbxDno_eff->SetMinimum(0.550);
TCanvas * C = new TCanvas();
TPad* fPads1 = NULL;
TPad* fPads2 = NULL;
fPads1 = new TPad("pad1","Run2", 0.00, 0.25, 0.99, 0.99);
fPads2 = new TPad("pad2","", 0.00, 0.05, 0.99, 0.25);
fPads1->SetFillColor(0);
fPads1->SetLineColor(0);
fPads2->SetFillColor(0);
fPads2->SetFillColor(0);
fPads1->Draw();
fPads2->Draw();
fPads1->cd();
hbx_eff->SetMarkerStyle(20);
hbx_eff->SetMarkerColor(4);
hbx_eff->SetTitle("dZ_eff");
hbx_eff->GetXaxis()->SetTitle("instLumi");
hbx_eff->GetYaxis()->SetTitle("eff_dZ");
hbx_eff->SetStats(0);
hbx_eff->Draw();
hbxD_eff->SetMarkerStyle(20);
hbxD_eff->SetMarkerColor(2);
hbxD_eff->Draw("same");
hbxDno_eff->SetMarkerStyle(20);
hbxDno_eff->SetMarkerColor(1);
hbxDno_eff->Draw("same");
TLegend *leg = new TLegend(0.13, 0.18, 0.28, 0.28);
leg->AddEntry(hbx_eff, "data", "f");
leg->AddEntry(hbxD_eff, "dataCCC", "f");
leg->AddEntry(hbxDno_eff, "datanoCCC", "f");
leg->Draw();
fPads2->cd();
TH1F * hbx_DM = (TH1F *)hbxD_eff->Clone("hbx_DM");
hbx_DM->Sumw2();
hbx_DM->SetMinimum(0);
hbx_DM->Divide(hbxD_eff, hbx_eff, 1, 1, "b");
hbx_DM->SetTitle("");
hbx_DM->GetXaxis()->SetTitle("");//Z pt /GeV");
hbx_DM->GetYaxis()->SetTitleSize(0.11);
hbx_DM->GetYaxis()->SetTitleOffset(0.26);
hbx_DM->GetYaxis()->SetTitle("eff DataCCC/Data");
hbx_DM->SetMaximum(1.15);
hbx_DM->SetMinimum(0.85);
hbx_DM->SetStats(kFALSE);
hbx_DM->SetLabelSize(0.09);
hbx_DM->GetYaxis()->SetLabelSize(0.09);
hbx_DM->Draw();
TH1F * hbx_DMno = (TH1F *)hbxDno_eff->Clone("hbx_DMno");
hbx_DMno->Sumw2();
hbx_DMno->SetMinimum(0);
hbx_DMno->Divide(hbxDno_eff, hbx_eff, 1, 1, "b");
hbx_DMno->Draw("same");
fPads2->Update();
TLine * lineAtZero = new TLine(0, 1.0, 3600, 1.0);
//TLine * lineAtZero = new TLine(hbx_DM->GetXaxis()->GetXmin(), 0, hbx_DM->GetXaxis()->GetXmax(), 0);
lineAtZero->SetLineColor(2);
lineAtZero->SetLineStyle(2);
lineAtZero->Draw();
C->SaveAs("dZ_bx_check.pdf");
//C->SaveAs("dZ_eff_MC.png");
/*
TCanvas *Ceff = new TCanvas();
Ceff->Draw();
Double_t abin, dZbin, eff;
for(int ibin=0; ibin<20; ibin++){
abin = abin + hmassData->GetBinContent(ibin);
dZbin = dZbin + hmassDatadZ->GetBinContent(ibin);
//eff = bbin/abin;
//hmass->SetBinContent(ibin,eff);
}
hbx->Draw();
Ceff->SaveAs("dZ_pt.png");
Ceff->SaveAs("dZ_pt.pdf");
eff = dZbin/abin;
cout << "eff " << eff << endl;
*/
}
示例11: DrawPerformCompFVTX
void DrawPerformCompFVTX(){
gStyle->SetErrorX(0);
gStyle->SetOptStat(0);
TFile *fmb = new TFile("merged_AnaMWGppmb.root","ReadOnly");
TFile *fhmand = new TFile("merged_AnaMWGppfvtxand.root","ReadOnly");
TFile *fhmor = new TFile("merged_AnaMWGppfvtxor.root","ReadOnly");
// TFile *fhmsouth = new TFile("merged_AnaMWGppfvtxsouth.root","ReadOnly");
// TFile *fhmnorth = new TFile("merged_AnaMWGppfvtxnorth.root","ReadOnly");
const int ncav = 2;
TCanvas *c1[ncav];
for(int i=0;i<ncav;i++){
c1[i] = new TCanvas();
}
TString histoname = "hnfvtxtrkbbc";//"hntracknmpc";
TString varname = "nfvtxtrack";
TString var = "# of fvtx tracks";//"# of central tracks";
bool xory = 1;
TH2F* hbbcsbbcn_mb = (TH2F*)fmb->Get(Form("%s",histoname.Data()));
TH2F* hbbcsbbcn_hmand = (TH2F*)fhmand->Get(Form("%s",histoname.Data()));
TH2F* hbbcsbbcn_hmor = (TH2F*)fhmor->Get(Form("%s",histoname.Data()));
// TH2F* hbbcsbbcn_hmsouth = (TH2F*)fhmsouth->Get(Form("%s",histoname.Data()));
// TH2F* hbbcsbbcn_hmnorth = (TH2F*)fhmnorth->Get(Form("%s",histoname.Data()));
if(xory){
TH1F* hbbc_mb = (TH1F*)hbbcsbbcn_mb->ProjectionX("hbbc_mb",0,-1);
TH1F* hbbc_hmand = (TH1F*)hbbcsbbcn_hmand->ProjectionX("hbbc_hmand",0,-1);
TH1F* hbbc_hmor = (TH1F*)hbbcsbbcn_hmor->ProjectionX("hbbc_hmor",0,-1);
// TH1F* hbbc_hmsouth = (TH1F*)hbbcsbbcn_hmsouth->ProjectionX("hbbc_hmsouth",0,-1);
// TH1F* hbbc_hmnorth = (TH1F*)hbbcsbbcn_hmnorth->ProjectionX("hbbc_hmnorth",0,-1);
}
else{
TH1F* hbbc_mb = (TH1F*)hbbcsbbcn_mb->ProjectionY("hbbc_mb",0,-1);
TH1F* hbbc_hmand = (TH1F*)hbbcsbbcn_hmand->ProjectionY("hbbc_hmand",0,-1);
TH1F* hbbc_hmor = (TH1F*)hbbcsbbcn_hmor->ProjectionY("hbbc_hmor",0,-1);
// TH1F* hbbc_hmsouth = (TH1F*)hbbcsbbcn_hmsouth->ProjectionY("hbbc_hmsouth",0,-1);
// TH1F* hbbc_hmnorth = (TH1F*)hbbcsbbcn_hmnorth->ProjectionY("hbbc_hmnorth",0,-1);
}
//hbbc_mb->GetXaxis()->SetLimits(0,200);
//hbbc_mb->Rebin(3);
//hbbc_mbcen->Rebin(10);
//hbbc_hmand->Rebin(3);
//hbbc_hmor->Rebin(3);
//hbbc_hmsouth->Rebin(3);
//hbbc_hmnorth->Rebin(3);
TH1F *hbbc_hmorScale = (TH1F*)hbbc_hmor->Clone("hbbc_hmorScale");
hbbc_hmorScale->Scale(0.06);
//hbbc_hm->Scale(1./hbbc_hm->Integral());
c1[0]->cd();
c1[0]->SetLogy();
hbbc_mb->Draw();
SetTitle(*hbbc_mb,Form("%s",var.Data()),"# of events","");
//SetTitle(*hbbc_mb,"nvtx layer 1","# of events","");
SetXRange(*hbbc_mb,0,30);
SetYRange(*hbbc_mb,1,5e9);
SetXRange(*hbbc_hmand,0,30);
SetXRange(*hbbc_hmor,0,30);
// SetXRange(*hbbc_hmsouth,0,300);
// SetXRange(*hbbc_hmnorth,0,300);
SetStyle(*hbbc_mb,1.0,1,20,0,0);
SetStyle(*hbbc_hmand,1.0,2,20,0,0);
SetStyle(*hbbc_hmor,1.0,4,34,0,0);
SetStyle(*hbbc_hmorScale,1.0,2,34,0,0);
// SetStyle(*hbbc_hmsouth,0.6,6,29,0,0);
// SetStyle(*hbbc_hmnorth,0.6,7,32,0,0);
TLegend *leg = new TLegend(0.6,0.75,0.8,0.90);
leg->SetBorderSize(0);
leg->SetFillColor(0);
leg->SetTextSize(0.045);
leg->AddEntry(hbbc_mb,"p+p minbias","pl");
// leg->AddEntry(hbbc_mb_scale,"p+p minbias * 50","pl");
leg->AddEntry(hbbc_hmor,"p+p FVTX OR","pl");
leg->AddEntry(hbbc_hmand,"p+p FVTX AND","pl");
// leg->AddEntry(hbbc_hmorScale,"p+p FVTX OR Scaled * 0.06","pl");
// leg->AddEntry(hbbc_hmand,"MWGpp high-mult AND","pl");
// leg->AddEntry(hbbc_hmor,"MWGpp high-mult OR","pl");
// leg->AddEntry(hbbc_hmsouth,"MWGpp high-mult south","pl");
// leg->AddEntry(hbbc_hmnorth,"MWGpp high-mult north","pl");
leg->Draw("same");
hbbc_hmor->Draw("same");
hbbc_hmand->Draw("same");
// hbbc_hmorScale->Draw("same");
double top5 = 7;
TLine *l = new TLine(top5,0,top5,4e8);
l->SetLineStyle(2);
l->Draw();
// hbbc_hmand->Draw("same");
// hbbc_hmor->Draw("same");
// hbbc_hmsouth->Draw("same");
// hbbc_hmnorth->Draw("same");
TLatex t;
t.SetTextSize(0.04);
t.SetNDC();
// hbbc_mb->GetXaxis()->SetRange()
t.DrawLatex(0.13,0.2,Form("MB mean:%.2f",hbbc_mb->GetMean(1)));
t.DrawLatex(0.13,0.25,Form("FVTX OR mean:%.2f",hbbc_hmor->GetMean(1)));
t.DrawLatex(0.13,0.30,Form("FVTX AND mean:%.2f",hbbc_hmand->GetMean(1)));
t.SetNDC(0);
t.DrawLatex(top5-8,5e8,Form("Top 0-5%, fvtx track >= %.1f",top5));
//t.DrawLatex(0.13,0.7,Form("mb mean:%.2f, # of events: %.1fM",hbbc_mb->GetMean(1),hbbcsbbcn_mb->Integral()/1e6));
//t.DrawLatex(0.13,0.75,Form("central mean:%.2f, # of events: %.1fM",hbbc_mbcen->GetMean(1),hbbcsbbcn_mbcen->Integral()/1e6));
//t.DrawLatex(0.13,0.80,Form("hm AND mean:%.2f, # of events: %.1fM",hbbc_hmand->GetMean(1),hbbcsbbcn_hmand->Integral()/1e6));
//.........这里部分代码省略.........
示例12: draw_comp_cent
//.........这里部分代码省略.........
tex->SetTextSize(0.04);
//Legend
TLegend *legUR = new TLegend(0.56,0.68,0.90,0.90,NULL,"brNDC");
//TLegend *legUL = new TLegend(0.17,0.68,0.51,0.90,NULL,"brNDC");
TLegend *legUL = new TLegend(0.20,0.71,0.51,0.90,NULL,"brNDC");
TLegend *legBM = new TLegend(0.40,0.20,0.75,0.35,NULL,"brNDC");
TLegend *legBR = new TLegend(0.56,0.20,0.90,0.42,NULL,"brNDC");
SetLegendStyle(legUR);
SetLegendStyle(legUL);
SetLegendStyle(legBM);
SetLegendStyle(legBR);
//////////////////////////////////////////////////////////////////
// --- Draw histograms
TCanvas* c1 = new TCanvas("c1","c1",600,600);
////// 01 Pt
c1->cd();
h1D_EffPt_01->GetXaxis()->SetTitle("p_{T} (GeV/c)");
h1D_EffPt_01->GetXaxis()->CenterTitle();
h1D_EffPt_01->GetYaxis()->SetTitle("Efficiency");
//h1D_EffPt_01->GetXaxis()->SetRangeUser(0,16);
if (isPrompt) h1D_EffPt_01->GetXaxis()->SetRangeUser(0,12);
else h1D_EffPt_01->GetXaxis()->SetRangeUser(0,22);
h1D_EffPt_01->SetMinimum(0);
h1D_EffPt_01->SetMaximum(1);
SetHistStyle(h1D_EffPt_01,3,0);
SetHistStyle(h1D_EffPt_02,4,10);
h1D_EffPt_01->Draw("");
h1D_EffPt_02->Draw("same");
if (isPair){
legUL->SetHeader(strPrompt.c_str());
legUL->AddEntry(h1D_EffPt_01,ntuple01,"lp");
legUL->AddEntry(h1D_EffPt_02,ntuple02,"lp");
legUL->Draw();
}else{
legBR->SetHeader(strPrompt.c_str());
legBR->AddEntry(h1D_EffPt_01,ntuple01,"lp");
legBR->AddEntry(h1D_EffPt_02,ntuple02,"lp");
legBR->Draw();
}
c1->SaveAs(Form("%s/comp_EffPt_%s_%s.pdf",dirName,strPrompt.c_str(),strPair.c_str()));
// c1->SaveAs(Form("%s/comp_EffPt_%s_%s.png",dirName,strPrompt.c_str(),strPair.c_str()));
legUL->Clear();
legBR->Clear();
c1->Clear();
if (isPair) hRatio_EffPt->GetXaxis()->SetTitle("p_{T}^{#mu#mu} (GeV/c)");
else hRatio_EffPt->GetXaxis()->SetTitle("p_{T}^{#mu} (GeV/c)");
hRatio_EffPt->GetXaxis()->CenterTitle();
if (isPrompt) hRatio_EffPt->GetXaxis()->SetRangeUser(0,12);
else hRatio_EffPt->GetXaxis()->SetRangeUser(0,22);
hRatio_EffPt->GetYaxis()->SetTitle(Form("Ratio = [ %s ]/[ %s ]",ntuple02,ntuple01));
hRatio_EffPt->SetMinimum(ymin);
hRatio_EffPt->SetMaximum(ymax);
hRatio_EffPt->Draw();
SetHistStyle(hRatio_EffPt,2,0);
//dashedLine(0.,1.,16.,1.,1,1);
if (isPrompt) dashedLine(0.,1.,12.,1.,1,1);
else dashedLine(0.,1.,22.,1.,1,1);
c1->SaveAs(Form("%s/compRatio_EffPt_%s_%s.pdf",dirName,strPrompt.c_str(),strPair.c_str()));
// c1->SaveAs(Form("%s/compRatio_EffPt_%s_%s.png",dirName,strPrompt.c_str(),strPair.c_str()));
c1->Clear();
////// 02 Y
示例13: overlay_RecoSmeared_ExclJetBins
TCanvas* overlay_RecoSmeared_ExclJetBins(const string& folder,
const string& htrange, const hist_t& h
)
{
TLegend *leg = new TLegend(0.6,0.65,0.9,0.9);
leg->SetTextFont(42);
TCanvas* c1 = new TCanvas("c1");
gPad->SetLogy();
gPad->SetTickx();
gPad->SetTicky();
vector<string> jetcoll;
jetcoll.push_back("reco");
jetcoll.push_back("smeared");
stringstream title;
title << htrange << ", L = 10 fb^{-1}" << ";" << h.title ;
vector< vector<TH1* > > HISTS;
for (unsigned j=0; j< jetcoll.size(); ++j)
{
stringstream histname;
histname << folder << "/" << jetcoll.at(j) << h.name;
cout << __LINE__ << ": Looking for hist: " << histname.str().c_str() << endl;
vector<TH1*> hists = GetHist(histname.str());
HISTS.push_back(hists);
}
double ymin=0, ymax = 0;
GetYRange(HISTS,ymin, ymax);
if (ymin==0) ymin = 0.0005;
for (int j=0; j<jetcoll.size(); ++j)
{
stringstream jetc;
if (j==0) jetc << "RECO";
else if (j==1) jetc << "SMEAR";
for (int bin=0; bin<nBins; ++bin)
{
HISTS.at(j).at(bin)->Rebin(h.rebin);
HISTS.at(j).at(bin)->SetTitle(title.str().c_str());
HISTS.at(j).at(bin)->SetMarkerStyle(20+j);
HISTS.at(j).at(bin)->SetStats(0);
if (j==1) //all smeared plots
{
HISTS.at(j).at(bin)->SetLineColor(kRed);
HISTS.at(j).at(bin)->SetMarkerColor(kRed);
}
int mstyle = 21+bin;
HISTS.at(j).at(bin)->SetMarkerStyle(mstyle);
stringstream legname;
if (bin==0) legname << "==2 Jets";
else if (bin==1) legname << "3-5 Jets";
else if (bin==2) legname << "6-7 Jets";
else if (bin==3) legname << "#geq 8 Jets";
if (j==0 && bin==0)
{
HISTS.at(j).at(bin)->GetYaxis()->SetRangeUser(ymin*0.5, ymax*10);
HISTS.at(j).at(bin)->Draw();
} else HISTS.at(j).at(bin)->Draw("same");
const double sum = HISTS.at(j).at(bin)->Integral(1, HISTS.at(j).at(bin)->GetNbinsX()+1);
legname << "[" << jetc.str() << "] (" << sum << ")";
leg->AddEntry(HISTS.at(j).at(bin), legname.str().c_str());
}
}
leg->Draw();
/*TH1* ratio = dynamic_cast<TH1*> (hists.at(2)->Clone("ratio"));
ratio->GetYaxis()->SetTitle("Smeared/Reco");
ratio->SetTitle("");
ratio->Divide(hists.at(0));
//ratio->GetYaxis()->SetRangeUser(-0.01,2.01);
ratio->GetYaxis()->SetRangeUser(0.49,1.51);
//ratio->SetTickLength (+0.01,"Y");
//TCanvas *c1 = new TCanvas("c1", "c1",15,60,550,600);
TCanvas *c1 = new TCanvas("c1");
c1->Range(0,0,1,1);
c1->SetBorderSize(2);
c1->SetFrameFillColor(0);
// ------------>Primitives in pad: c1_1
TPad *c1_1 = new TPad("c1_1", "c1_1",0.01,0.30,0.99,0.99);
c1_1->Draw();
c1_1->cd();
c1_1->SetBorderSize(2);
c1_1->SetTickx(1);
c1_1->SetTicky(1);
c1_1->SetTopMargin(0.1);
c1_1->SetBottomMargin(0.0);
//c1_1->SetFrameFillColor(3);
//.........这里部分代码省略.........
示例14: ptBestFit
//.........这里部分代码省略.........
double YMAX = 1.1*frame2->GetMaximum();
double YMIN = -1.1*frame2->GetMaximum();
hUnc2H->GetYaxis()->SetRangeUser(YMIN,YMAX);
hUnc2H->GetYaxis()->SetNdivisions(507);
// hUnc2H->GetXaxis()->SetTitleOffset(0.9);
// hUnc2H->GetYaxis()->SetTitleOffset(1.0);
hUnc2H->GetYaxis()->SetTickLength(0.0);
// hUnc2H->GetYaxis()->SetTitleSize(0.05);
// hUnc2H->GetYaxis()->SetLabelSize(0.04);
hUnc2H->GetYaxis()->CenterTitle(kTRUE);
hUnc2H->SetFillColor(kGreen);
hUnc2L->SetFillColor(kGreen);
hUncH->SetFillColor(kYellow);
hUncL->SetFillColor(kYellow);
hUncC->SetLineColor(kBlack);
hUncC->SetLineStyle(7);
hUnc2H->Draw("HIST");
hUnc2L->Draw("same HIST");
hUncH->Draw("same HIST");
hUncL->Draw("same HIST");
hUncC->Draw("same HIST");
frame2->GetYaxis()->SetTickLength(0.03/0.4);
frame2->Draw("same");
TList *list1 = (TList*)gPad->GetListOfPrimitives();
//list1->Print();
RooCurve *gSigFit = (RooCurve*)list1->FindObject("shapeSig_qqH_"+ds_name+"_Norm[mbbReg_"+ds_name+"]");
TLegend *leg = new TLegend(0.70,0.61,0.94,1.-gStyle->GetPadTopMargin()-0.01);
leg->SetTextFont(42);
leg->SetFillStyle(-1);
//leg->SetHeader(ds_name+" (m_{H}="+MASS+")");
leg->SetHeader(TString::Format("Category %d",atoi(ds_name(3,1).Data())+1));
leg->AddEntry(hBlind,"Data","P");
if (!BLIND) {
leg->AddEntry(gSigFit,"Fitted signal","L");
}
TLine *gEmpty = new TLine(0.0,0.0,0.0,0.0);
gEmpty->SetLineWidth(0);
TLegendEntry *l1 = leg->AddEntry(gEmpty,"(m_{H} = "+MASS+" GeV)","");
l1->SetTextSize(0.038*0.97*0.85);
leg->AddEntry(gFit,"Bkg. + signal","L");
leg->AddEntry(gBkgFit,"Bkg.","L");
leg->AddEntry(gQCDFit,"QCD","L");
leg->AddEntry(hUnc2H,"2#sigma bkg. unc.","F");
leg->AddEntry(hUncH,"1#sigma bkg. unc.","F");
leg->SetFillColor(0);
leg->SetBorderSize(0);
leg->SetTextFont(42);
leg->SetTextSize(0.038*0.98);
leg->Draw();
leg->SetY1(leg->GetY2()-leg->GetNRows()*0.045*0.96);
TPaveText *paveCMS = new TPaveText(gStyle->GetPadLeftMargin()+0.02,0.7,gStyle->GetPadLeftMargin()+0.15,1.-gStyle->GetPadTopMargin()-0.01,"NDC");
paveCMS->SetTextFont(62);
paveCMS->SetTextSize(gStyle->GetPadTopMargin()*3./4.);
paveCMS->SetBorderSize(0);
paveCMS->SetFillStyle(-1);
paveCMS->SetTextAlign(12);
paveCMS->AddText("CMS");
paveCMS->Draw();
gPad->Update();
paveCMS->SetY1NDC(paveCMS->GetY2NDC()-paveCMS->GetListOfLines()->GetSize()*gStyle->GetPadTopMargin());
TPaveText *paveLumi = new TPaveText(0.5,1.-gStyle->GetPadTopMargin(),0.98,1.00,"NDC");
paveLumi->SetTextFont(42);
示例15: getDataMC
//TString WHICHHIST1, TString WHICHHIST2, assume 2 is data
void getDataMC(TH1D* h1, TH1D* h2, bool isData2, bool drawRatio) {
gStyle->SetEndErrorSize(2);
gStyle->SetErrorX(0.5);
TCanvas* c = new TCanvas();
c->cd();
TPad *p1 = new TPad("p1", "",0.0,0.242,1.0,1.0,0,0,0);
if (drawRatio) {
p1->Draw();
p1->cd();
p1->SetBottomMargin(0.013);
//p1->SetLogx();
}
double max = h1->GetMaximum() > h2->GetMaximum() ? h1->GetMaximum() : h2->GetMaximum();
h1->SetMaximum(1.2*max);
h1->GetYaxis()->SetTitleSize(0.065);
h1->GetYaxis()->SetTitle("Events/bin");
h1->SetLineColor(kOrange+3);
h1->SetFillColor(kOrange-2);
h1->SetMarkerSize(0);
h1->SetLineWidth(1.2);
h1->Draw("E2");
h2->SetMarkerSize(1.3);
h2->SetMarkerStyle(20);
h2->Draw("EPsame");
TLegend* leg = MakeLegend();
leg->AddEntry(h1,"MC based estimation","f");
leg->AddEntry(h2,"Data-driven prediction","lp");
leg->Draw("same");
//Draw ratios
if (drawRatio) {
gStyle->SetOptTitle(0);
gStyle->SetPadGridY(false);
TH1D* ratio = (TH1D*)h1->Clone();
ratio->Divide(h2,h1);
TPad *p2 = new TPad("p2", "",0.0,0.0,1.0,0.24,0,0,0);
c->cd();
p2->Draw();
p2->cd();
//p2->SetLogx();
p2->SetTopMargin(0.005);
p2->SetBottomMargin(0.35);
//p2->SetTickx();
ratio->GetYaxis()->SetTitle("e#mu/MC");
ratio->SetStats(kFALSE);
double ranger = ratio->GetBinError(1) > ratio->GetBinError(ratio->GetXaxis()->GetNbins()-1) ? ratio->GetBinError(1) : ratio->GetBinError(ratio->GetXaxis()->GetNbins()-1);
ratio->GetYaxis()->SetRangeUser(0.01,1.2*ranger+fabs(ratio->GetMaximum()));
ratio->GetYaxis()->SetNdivisions(5);
ratio->GetYaxis()->SetTitleOffset(0.29);
ratio->GetXaxis()->SetTitle("|Y_{#mu#mu}|");
ratio->GetXaxis()->SetMoreLogLabels();
ratio->GetYaxis()->SetTitleSize(0.23);
ratio->GetXaxis()->SetTitleSize(0.18);
//control digit sizes
ratio->GetYaxis()->SetLabelSize(1.2*0.15);
ratio->GetXaxis()->SetLabelSize(0.15);
//ratio->SetTickLength(ratio->GetTickLength()*2.);
ratio->SetFillStyle(3001);
ratio->SetLineColor(kBlack);
ratio->SetFillColor(kBlack);
ratio->SetMarkerSize(0);
ratio->SetLineWidth(1.2);
ratio->Draw("E3");
}
c->SaveAs(TString(h1->GetName())+".png");
}