34 int main(
int argc,
char *argv[]){
40 vector<double> vmx, vmy, vxsec, vobs, vobsup, vobsdown, vexp, vup, vdown, vsigobs, vsigexp;
41 ReadPoints(vmx, vmy, vxsec, vobs, vobsup, vobsdown, vexp, vup, vdown, vsigobs, vsigexp);
43 vector<double> vlim(vxsec.size());
44 for(
size_t i = 0; i < vxsec.size(); ++i){
45 vlim.at(i) = vxsec.at(i) * vobs.at(i);
52 vobs, vobsup, vobsdown,
59 vector<double> &vxsec,
61 vector<double> &vobsup,
62 vector<double> &vobsdown,
65 vector<double> &vdown,
66 vector<double> &vsigobs,
67 vector<double> &vsigexp){
71 while(getline(infile, line)){
72 istringstream iss(line);
73 double pmx, pmy, pxsec, pobs, pobsup, pobsdown, pexp, pup, pdown, sigobs, sigexp;
74 iss >> pmx >> pmy >> pxsec >> pobs >> pobsup >> pobsdown >> pexp >> pup >> pdown >> sigobs >> sigexp;
84 else vxsec.push_back(pxsec);
86 vobsup.push_back(pobsup);
87 vobsdown.push_back(pobsdown);
90 vdown.push_back(pdown);
91 vsigobs.push_back(sigobs);
92 vsigexp.push_back(sigexp);
96 if(vmx.size() <= 2)
ERROR(
"Need at least 3 model_s to draw scan");
97 if(vmx.size() != vmy.size()
98 || vmx.size() != vxsec.size()
99 || vmx.size() != vobs.size()
100 || vmx.size() != vobsup.size()
101 || vmx.size() != vobsdown.size()
102 || vmx.size() != vexp.size()
103 || vmx.size() != vup.size()
104 || vmx.size() != vdown.size()
105 || vmx.size() != vsigobs.size()
106 || vmx.size() != vsigexp.size())
ERROR(
"Error parsing text file. Model_ point not fully specified");
111 vector<double> vobs){
114 string xparticle, yparticle;
116 string title =
";m_{"+xparticle+
"} [GeV];m_{"+yparticle+
"} [GeV];Observed Significance";
118 TGraph2D g(
"", title.c_str(), vobs.size(), &vmx.at(0), &vmy.at(0), &vobs.at(0));
121 for(
int i = 0; i < g.GetN(); ++i){
122 double z = fabs(g.GetZ()[i]);
123 if(z>the_max) the_max = z;
125 g.SetMinimum(-the_max);
126 g.SetMaximum(the_max);
131 g.GetHistogram()->SetTitle(title.c_str());
132 g.GetHistogram()->SetTickLength(0.,
"Z");
137 TLatex ltitle(c.GetLeftMargin(), 1.-0.5*c.GetTopMargin(),
138 "#font[62]{CMS}#scale[0.76]{#font[52]{ Supplementary}}");
139 TLatex rtitle(1.-c.GetRightMargin(), 1.-0.5*c.GetTopMargin(),
140 "#scale[0.8]{35.9 fb^{-1} (13 TeV)}");
143 ltitle.SetTextAlign(12);
144 rtitle.SetTextAlign(32);
150 for(
double z = 0.; z < the_max; z+=0.5){
151 int style = min(5, static_cast<int>(2.*fabs(z))+1);
152 double width = max(1., 3.-fabs(z));
154 double x1 = 1.-c.GetRightMargin()+0.0047;
155 double x2 = 1.-c.GetRightMargin()+0.05;
156 double ybot = c.GetBottomMargin();
157 double ytop = 1.-c.GetTopMargin();
158 double zpos = ybot+(ytop-ybot)*(the_max+z)/(2.*the_max);
159 lines.emplace_back(x1, zpos, x2, zpos);
160 lines.back().SetLineColor(1);
161 lines.back().SetLineStyle(style);
162 lines.back().SetLineWidth(width);
163 lines.back().SetNDC(
true);
166 double zneg = ybot+(ytop-ybot)*(the_max-z)/(2.*the_max);
167 lines.emplace_back(x1, zneg, x2, zneg);
168 lines.back().SetLineColor(1);
169 lines.back().SetLineStyle(style);
170 lines.back().SetLineWidth(width);
171 lines.back().SetNDC(
true);
182 c.Print((
model_+
"_sigobs.pdf").c_str());
183 c.Print((
model_+
"_sigobs.root").c_str());
185 TH2D h = *g.GetHistogram();
186 h.SetTitle(
"Observed Significance");
192 vector<double> vobs){
195 string xparticle, yparticle;
197 string title =
";m_{"+xparticle+
"} [GeV];m_{"+yparticle+
"} [GeV]; Expected Significance";
199 TGraph2D g(
"", title.c_str(), vobs.size(), &vmx.at(0), &vmy.at(0), &vobs.at(0));
202 for(
int i = 0; i < g.GetN(); ++i){
203 double z = g.GetZ()[i];
204 if(z>the_max) the_max = z;
206 if(the_max > 6.) the_max = 6.;
208 g.SetMaximum(the_max);
213 g.GetHistogram()->SetTitle(title.c_str());
218 TLatex ltitle(c.GetLeftMargin(), 1.-0.5*c.GetTopMargin(),
219 "#font[62]{CMS}#scale[0.76]{#font[52]{ Supplementary}}");
220 TLatex rtitle(1.-c.GetRightMargin(), 1.-0.5*c.GetTopMargin(),
221 "#scale[0.8]{35.9 fb^{-1} (13 TeV)}");
224 ltitle.SetTextAlign(12);
225 rtitle.SetTextAlign(32);
230 for(
double z = 0.; z < the_max; z+=1.){
231 int style = (z == 5. ? 1 : 2);
232 double width = (z == 5. ? 2. : 1.);
240 c.Print((
model_+
"_sigexp.pdf").c_str());
241 c.Print((
model_+
"_sigexp.root").c_str());
243 TH2D h = *g.GetHistogram();
244 h.SetTitle(
"Expected Significance");
252 vector<double> vobsup,
253 vector<double> vobsdown,
256 vector<double> vdown,
258 const TH2D &hsigexp){
261 string xparticle, yparticle;
263 string title =
";m_{"+xparticle+
"} [GeV];m_{"+yparticle+
"} [GeV];95% CL upper limit on cross section [pb]";
265 TGraph2D glim(
"", title.c_str(), vlim.size(), &vmx.at(0), &vmy.at(0), &vlim.at(0));
266 TGraph2D gobs(
"",
"Observed Limit", vobs.size(), &vmx.at(0), &vmy.at(0), &vobs.at(0));
267 TGraph2D gobsup(
"",
"Observed +1#sigma Limit", vobsup.size(), &vmx.at(0), &vmy.at(0), &vobsup.at(0));
268 TGraph2D gobsdown(
"",
"Observed -1#sigma Limit", vobsdown.size(), &vmx.at(0), &vmy.at(0), &vobsdown.at(0));
269 TGraph2D gexp(
"",
"Expected Limit", vexp.size(), &vmx.at(0), &vmy.at(0), &vexp.at(0));
270 TGraph2D gup(
"",
"Expected +1#sigma Limit", vup.size(), &vmx.at(0), &vmy.at(0), &vup.at(0));
271 TGraph2D gdown(
"",
"Expected -1#sigma Limit", vdown.size(), &vmx.at(0), &vmy.at(0), &vdown.at(0));
273 glim.SetMinimum(0.001);
279 glim.SetTitle(title.c_str());
281 TLegend l(gStyle->GetPadLeftMargin(), 1.-2.*gStyle->GetPadTopMargin(),
282 1.-gStyle->GetPadRightMargin(), 1.-gStyle->GetPadTopMargin());
290 TLatex ltitle(c.GetLeftMargin(), 1.-0.5*c.GetTopMargin(),
291 "#font[62]{CMS}#scale[0.76]{#font[52]{ Supplementary}}");
292 TLatex rtitle(1.-c.GetRightMargin(), 1.-0.5*c.GetTopMargin(),
293 "#scale[0.8]{35.9 fb^{-1} (13 TeV)}");
296 ltitle.SetTextAlign(12);
297 rtitle.SetTextAlign(32);
299 c.SetTopMargin(2.*c.GetTopMargin());
310 l.AddEntry(&cexp,
"Expected",
"l");
311 l.AddEntry(&cobs,
"Observed",
"l");
318 string filebase =
model_+
"_limit_scan";
320 filebase +=
"_smooth";
324 c.Print((filebase+
".pdf").c_str());
326 TFile file((filebase+
".root").c_str(),
"recreate");
327 glim.GetHistogram()->Write((
model_+
"ObservedExcludedXsec").c_str());
328 cobs.Write((
model_+
"ObservedLimit").c_str());
329 cobsup.Write((
model_+
"ObservedLimitUp").c_str());
330 cobsdown.Write((
model_+
"ObservedLimitDown").c_str());
331 cexp.Write((
model_+
"ExpectedLimit").c_str());
332 cup.Write((
model_+
"ExpectedLimitUp").c_str());
333 cdown.Write((
model_+
"ExpectedLimitDown").c_str());
335 hsigobs.Write(
"ObservedSignificance");
336 hsigexp.Write(
"ExpectedSignificance");
339 cout <<
"\nSaved limit curves in " << filebase <<
".root\n" << endl;
343 double pmin = *min_element(pts.cbegin(), pts.cend());
344 double pmax = *max_element(pts.cbegin(), pts.cend());
345 return max(1, min(500, static_cast<int>(ceil((pmax-pmin)/width))));
350 xparticle =
"#tilde{g}";
351 yparticle =
"#lower[-0.12]{#tilde{#chi}}#lower[0.2]{#scale[0.85]{^{0}}}#kern[-1.3]{#scale[0.85]{_{1}}}";
352 }
else if(
model_==
"T5tttt"){
353 xparticle =
"#tilde{g}";
354 yparticle =
"#lower[-0.12]{#tilde{#chi}}#lower[0.2]{#scale[0.85]{^{0}}}#kern[-1.3]{#scale[0.85]{_{1}}}";
356 xparticle =
"#tilde{g}";
357 yparticle =
"#lower[-0.12]{#tilde{#chi}}#lower[0.2]{#scale[0.85]{^{0}}}#kern[-1.3]{#scale[0.85]{_{1}}}";
358 }
else if(
model_==
"T6ttWW"){
359 xparticle =
"sbottom";
360 yparticle =
"chargino";
363 xparticle =
"#tilde{g}";
364 yparticle =
"#lower[-0.12]{#tilde{#chi}}#lower[0.2]{#scale[0.85]{^{0}}}#kern[-1.3]{#scale[0.85]{_{1}}}";
369 string lsp =
"#lower[-0.12]{#tilde{#chi}}#lower[0.2]{#scale[0.85]{^{0}}}#kern[-1.3]{#scale[0.85]{_{1}}}";
372 label =
"pp #rightarrow #tilde{g}#kern[0.3]{#tilde{g}}, #tilde{g} #rightarrow t#kern[0.4]{#bar{t}}#kern[0.4]{"+lsp+
"}";
373 }
else if(
model_==
"T5tttt"){
374 label =
"#splitline{pp #rightarrow #tilde{g}#kern[0.3]{#tilde{g}}, #tilde{g} #rightarrow #tilde{t}_{1}t, #tilde{t}_{1} #rightarrow #bar{t}#kern[0.4]{" 375 +lsp+
"}}{(m#kern[0.3]{_{#lower[-0.12]{#tilde{t}_{1}}}} - m#kern[0.12]{_{"+lsp+
"}} = 175 GeV)}";
380 TLatex l(x, y, label.c_str());
383 l.SetTextSize(0.032);
388 g->SetLineColor(color);
389 g->SetLineStyle(style);
390 g->SetLineWidth(width);
394 int n_smooth,
double val){
400 TH2D *histo2d = g2.GetHistogram();
402 100, histo2d->GetXaxis()->GetXmin(), histo2d->GetXaxis()->GetXmax(),
403 100, histo2d->GetYaxis()->GetXmin(), histo2d->GetYaxis()->GetXmax());
404 for(
int binx=1; binx<=htemp.GetNbinsX(); ++binx){
405 double x = htemp.GetXaxis()->GetBinCenter(binx);
406 for(
int biny=1; biny<=htemp.GetNbinsY(); ++biny){
407 double y = htemp.GetYaxis()->GetBinCenter(biny);
408 double z = g2.Interpolate(x,y);
410 htemp.SetBinContent(htemp.GetBin(binx, biny), z);
415 for(
int ind=0; ind<n_smooth; ++ind){
416 htemp.Smooth(1,
"k5b");
419 vector<double> vx, vy, vz;
420 double glu_lsp = 225;
421 for(
int binx=1; binx<=htemp.GetNbinsX(); ++binx){
422 double x = htemp.GetXaxis()->GetBinCenter(binx);
423 for(
int biny=1; biny<=htemp.GetNbinsY(); ++biny){
424 double y = htemp.GetYaxis()->GetBinCenter(biny);
425 double z = htemp.GetBinContent(htemp.GetBin(binx,biny));
429 int thresh = glu_lsp+30;
430 if (
model_==
"T5tttt") thresh = glu_lsp+85;
434 vz.push_back(g2.Interpolate(x,y));
439 TGraph2D gsmooth(
"gsmooth",
"Cross-Section Limit", vx.size(), &vx.at(0), &vy.at(0), &vz.at(0));
440 gsmooth.GetHistogram();
441 l = gsmooth.GetContourList(val);
444 l = g2.GetContourList(val);
446 if(l ==
nullptr)
return graph;
448 for(
int i = 0; i < l->GetSize(); ++i){
449 TGraph *g =
static_cast<TGraph*
>(l->At(i));
450 Style(g, color, style, width);
451 if(g ==
nullptr)
continue;
452 int n_points = g->GetN();
453 if(n_points > max_points){
456 max_points = n_points;
461 graph.SetTitle(g2.GetTitle());
466 double glu_lsp = 225;
467 if(
model_==
"T5tttt") glu_lsp = 265.;
468 int np(graph.GetN());
469 double iniglu, endglu, inilsp, endlsp;
471 graph.GetPoint(0, iniglu, inilsp);
472 graph.GetPoint(np-1, endglu, endlsp);
475 if(inilsp < endlsp) {
483 graph.SetPoint(graph.GetN(), endglu, 0);
489 for(
int point(0); point < np; point++){
491 graph.GetPoint(point, mglu, mlsp);
492 if(mlsp > mglu-glu_lsp-5){
493 while(point <= graph.GetN() && point!=0) {
494 graph.RemovePoint(graph.GetN()-1);
503 int np(graph.GetN());
505 vector<double> mglus, mlsps;
506 for(
int point(np-1); point >= 0; point--){
507 graph.GetPoint(point, mglu, mlsp);
508 mglus.push_back(mglu);
509 mlsps.push_back(mlsp);
511 for(
int point(0); point < np; point++)
512 graph.SetPoint(point, mglus[point], mlsps[point]);
516 const unsigned num = 5;
517 const int bands = 255;
519 double stops[num] = {0.00, 0.34, 0.61, 0.84, 1.00};
520 double red[num] = {0.50, 0.50, 1.00, 1.00, 1.00};
521 double green[num] = {0.50, 1.00, 1.00, 0.60, 0.50};
522 double blue[num] = {1.00, 1.00, 0.50, 0.40, 0.50};
528 int fi = TColor::CreateGradientColorTable(num,stops,red,green,blue,bands);
529 for(
int i = 0; i < bands; ++i){
532 gStyle->SetNumberContours(bands);
533 gStyle->SetPalette(bands, colors);
537 const unsigned num = 3;
538 const int bands = 255;
540 double stops[num] = {0.0, 0.5, 1.0};
541 double red[num] = {0.0, 1.0, 1.0};
542 double green[num] = {0.0, 1.0, 0.0};
543 double blue[num] = {1.0, 1.0, 0.0};
544 int fi = TColor::CreateGradientColorTable(num,stops,red,green,blue,bands);
545 for(
int i = 0; i < bands; ++i){
548 gStyle->SetNumberContours(bands);
549 gStyle->SetPalette(bands, colors);
554 static struct option long_options[] = {
555 {
"num_smooth", required_argument, 0,
's'},
556 {
"model", required_argument, 0,
'm'},
557 {
"file", required_argument, 0,
'f'},
563 opt = getopt_long(argc, argv,
"f:m:s:", long_options, &option_index);
564 if( opt == -1)
break;
578 optname = long_options[option_index].name;
580 printf(
"Bad option! Found option name %s\n", optname.c_str());
582 printf(
"Bad option! Found option name %s\n", optname.c_str());
586 printf(
"Bad option! getopt_long returned character code 0%o\n", opt);
void Style(TGraph *g, int color, int style, float width)
void GetParticleNames(string &xparticle, string &yparticle)
TH2D MakeObservedSignificancePlot(vector< double > vmx, vector< double > vmy, vector< double > vobs)
int GetNumBins(const vector< double > &pts, double width)
bool Contains(const std::string &str, const std::string &pat)
void ReverseGraph(TGraph &graph)
TLatex GetModelLabel(double x, double y)
void ReadPoints(vector< double > &vmx, vector< double > &vmy, vector< double > &vxsec, vector< double > &vobs, vector< double > &vobsup, vector< double > &vobsdown, vector< double > &vexp, vector< double > &vup, vector< double > &vdown, vector< double > &vsigobs, vector< double > &vsigexp)
void FixGraph(TGraph &graph)
void signalCrossSection(int glu_mass, float &xsec, float &xsec_unc)
def style(h, width, style, color)
void GetOptions(int argc, char *argv[])
void MakeLimitPlot(vector< double > vmx, vector< double > vmy, vector< double > vlim, vector< double > vobs, vector< double > vobsup, vector< double > vobsdown, vector< double > vexp, vector< double > vup, vector< double > vdown, const TH2D &hsigobs, const TH2D &hsigexp)
TGraph DrawContours(TGraph2D &g2, int color, int style, double width, int n_smooth, double val)
TH2D MakeExpectedSignificancePlot(vector< double > vmx, vector< double > vmy, vector< double > vobs)
int main(int argc, char *argv[])