7 #include "TApplication.h" 9 #include "TRatioPlot.h" 12 #include "Analysis/Tools/interface/tdrstyle.C" 35 int main(
int argc,
char * argv[])
48 gStyle->SetOptStat(0);
49 TApplication theApp(
"App", 0, 0);
60 int color[10] = {kBlack,kRed};
69 f[0] =
new TFile(
file_.c_str(),
"old");
70 for (
int i = 0; i < 2 ; ++i )
72 if (
hn[i] ==
"" )
return -1;
73 h[i] = (TH1F*)
f[0] -> Get(
hn[i].c_str());
74 h[i] -> SetNameTitle(Form(
"%s_%d",
hn[i].c_str(),i), Form(
"%s (%s)",
leg[i].c_str(),
h[i]->GetXaxis()->GetTitle()));
75 h[i] -> GetYaxis() -> SetTitle(
"entries");
81 if (
hist_ ==
"" )
return -1;
82 for (
int i = 0; i < 2 ; ++i )
84 if (
fn[i] ==
"" )
return -1;
85 f[i] =
new TFile(
fn[i].c_str(),
"old");
86 h[i] = (TH1F*)
f[i] -> Get(
hist_.c_str());
87 h[i] -> SetNameTitle(Form(
"%s_%d",
hist_.c_str(),i), Form(
"%s (%s)",
title_.c_str(),
h[i]->GetXaxis()->GetTitle()));
92 out = TString(std::string(
h[0]->GetName()) +
"_versus_" + std::string(
h[1]->GetName()) +
".png");
93 out.ReplaceAll(
"/",
"_");
96 for (
int i = 0; i < 2 ; ++i )
98 h[i] -> SetMarkerStyle(20);
99 h[i] -> SetMarkerSize(1.2);
100 h[i] -> SetMarkerColor(color[i]);
101 h[i] -> SetLineColor(color[i]);
102 h[i] -> SetLineWidth(2);
103 h[i] -> GetYaxis() -> SetTitle(
"entries");
106 h[i] -> GetXaxis()->SetRangeUser(
min_,
max_);
108 h[i] -> SetMinimum(0);
109 if (
logy_ )
h[i] -> SetMinimum(0.8);
123 legend -> SetShadowColor(0);
128 if (
app_ ) theApp.Run();
141 c1 =
new TCanvas(
"c1",
"test",
W,
H);
142 c1 -> SetFillColor(0);
143 c1 -> SetBorderMode(0);
144 c1 -> SetFrameFillStyle(0);
145 c1 -> SetFrameBorderMode(0);
150 rp =
new TRatioPlot(
h[0],
h[1]);
152 rp -> SetH1DrawOpt(
"E");
153 rp -> SetH2DrawOpt(
"E");
154 rp -> SetGraphDrawOpt(
"P");
155 rp -> SetSeparationMargin(0.03);
157 rp -> SetLeftMargin(
L/
W );
158 rp -> SetRightMargin(
R/
W );
159 rp -> SetUpTopMargin(
T/
H );
160 rp -> SetLowBottomMargin(
B/
H );
164 rp -> GetLowYaxis() -> SetNdivisions(503);
165 rp -> GetLowerRefGraph() -> GetXaxis() -> SetTitleOffset(1.1);
166 rp -> GetLowerRefGraph() -> GetYaxis() -> SetTitle(
"ratio");
167 rp -> GetLowerRefYaxis() -> SetTitleOffset(1.2);
168 rp -> GetLowerRefYaxis() -> SetLabelSize(0.05);
169 rp -> GetLowerRefYaxis() -> SetTitleSize(0.05);
170 rp->GetLowerRefGraph()->SetMarkerStyle(20);
171 rp->GetLowerRefGraph()->SetMarkerColor(kGray+2);
172 rp->GetLowerRefGraph()->SetMarkerSize(1.2);
173 rp->GetLowerRefGraph()->SetLineWidth(2);
174 rp->GetLowerRefGraph()->SetLineColor(kGray+2);
175 rp->GetLowerRefGraph()->SetMinimum(0.);
176 rp->GetLowerRefGraph()->SetMaximum(2.4);
178 rp -> GetUpperRefXaxis() -> SetLabelSize(0.05);
179 rp -> GetUpperRefXaxis() -> SetTitleSize(0.05);
181 rp -> GetUpperRefYaxis() -> SetLabelSize(0.05);
182 rp -> GetUpperRefYaxis() -> SetTitleSize(0.05);
183 rp -> GetUpperRefYaxis() -> SetTitleOffset(1.2);
185 if (
logx_ )
rp -> GetUpperPad() -> SetLogx();
186 if (
logy_ )
rp -> GetUpperPad() -> SetLogy();
195 std::string var =
h[0]->GetName();
197 if ( TString(var).Contains(
"m_jet") || TString(var).Contains(
"pt_jet") )
198 legend =
rp -> GetUpperPad() -> BuildLegend(0.65,0.65,0.90,0.85);
199 else if ( !TString(var).Contains(
"deta_jet") && ( TString(var).Contains(
"eta_jet") || TString(var).Contains(
"phi_jet") ))
200 legend =
rp -> GetUpperPad() -> BuildLegend(0.40,0.05,0.65,0.25);
202 else if ( TString(var).Contains(
"btag_jet") )
205 legend =
rp -> GetUpperPad() -> BuildLegend(0.35,0.05,0.60,0.25);
207 legend =
rp -> GetUpperPad() -> BuildLegend(0.35,0.65,0.60,0.85);
210 legend =
rp -> GetUpperPad() -> BuildLegend(0.15,0.65,0.40,0.85);
void CMS_lumi(TPad *pad, TString mytxt="", int iPeriod=20, int iPosX=0)
int main(int argc, char *argv[])
int plotscomp_config(int argc, char *argv[])