17 #include "RooStats/NumberCountingUtils.h" 19 #include "TGraphAsymmErrors.h" 26 #include "core/baby.hpp" 56 vector<vector<vector<float> > > &kappas, vector<vector<vector<float> > > &preds,
57 vector<shared_ptr<Process> > &proc_sigs);
60 vector<vector<vector<float> > > &kappas, vector<vector<vector<float> > > &preds);
62 vector<vector<vector<float> > > &kappas, vector<vector<vector<float> > > &preds);
63 TString
Zbi(
double Nobs,
double Nbkg,
double Eup_bkg,
double Edown_bkg);
70 for (
const auto &pt: *(b.
leps_pt())) stvar += pt;
74 int main(
int argc,
char *argv[]){
75 gErrorIgnoreLevel=6000;
78 chrono::high_resolution_clock::time_point begTime;
79 begTime = chrono::high_resolution_clock::now();
84 string hostname =
execute(
"echo $HOSTNAME");
86 bfolder =
"/net/cms2";
91 string foldermc(bfolder+
"/cms2r0/babymaker/babies/2016_08_10/mc/merged_higmc_higtight/");
92 string foldersig(bfolder+
"/cms2r0/babymaker/babies/2016_08_10/TChiHH/merged_higmc_higtight/");
93 string folderdata(bfolder+
"/cms2r0/babymaker/babies/2016_08_10/data/merged_database_stdnj5/");
95 Palette colors(
"txt/colors.txt",
"default");
98 string baseline_s =
"hig_drmax<2.2&&ntks==0&&njets>=4&&njets<=5&&!low_dphi&&nvleps==0";
103 {foldermc+
"*_TTJets_Tune*"+ntupletag+
"*.root"},
104 baseline &&
"stitch && pass");
106 vector<string> sigMasses({
"225",
"300",
"400",
"700"});
107 vector<shared_ptr<Process> > proc_sigs;
108 for(
size_t ind=0; ind<sigMasses.size(); ind++)
109 proc_sigs.push_back(Process::MakeShared<Baby_full>(
"TChiHH("+sigMasses[ind]+
")",
Process::Type::signal, 2,
110 {foldersig+
"*mGluino-"+sigMasses[ind]+
"_*"+ntupletag+
"*.root"}, baseline &&
"stitch"));
113 {foldermc+
"*_TTJets*"+ntupletag+
"*.root"},
114 baseline &&
"stitch && pass");
116 {foldermc+
"*_ST_*"+ntupletag+
"*.root"},
117 baseline &&
"stitch && pass");
120 vector<string> vnames_other({
"_WJetsToLNu",
"_TTW",
"_TTZ",
"DYJetsToLL",
121 "_ZJet",
"_ttHJetTobb",
"_TTGJets",
"_TTTT",
122 "_WH_HToBB",
"_ZH_HToBB",
"_WWTo",
"_WZ",
"_ZZ_",
"QCD_HT*0_Tune",
"QCD_HT*Inf_Tune"});
123 set<string> names_other;
124 for(
auto name : vnames_other)
125 names_other.insert(name = foldermc +
"*" + name +
"*" + ntupletag +
"*.root");
127 names_other, baseline &&
"stitch && pass");
130 string trigs =
"trig_ra4";
131 if(
skim.Contains(
"2015")) trigs =
"(trig[4]||trig[8]||trig[28]||trig[14])";
134 string jsonCuts =
"nonblind";
135 if(
skim.Contains(
"2015"))
lumi = 2.3;
136 else if(
json==
"0p815"){
138 jsonCuts =
"nonblind";
139 }
else if(
json==
"2p6"){
141 jsonCuts =
"json2p6";
142 }
else if(
json==
"1p7"){
144 jsonCuts =
"json4p0&&!json2p6";
145 }
else if(
json==
"4p3"){
147 jsonCuts =
"json4p0";
148 }
else if(
json==
"7p65"){
150 jsonCuts =
"json7p65";
151 }
else if(
json==
"12p9"){
153 jsonCuts =
"json12p9";
158 if(
only_method.Contains(
"old")) trigs =
"(trig[4]||trig[8])";
159 if(!
skim.Contains(
"2015")) trigs +=
" && "+jsonCuts;
162 {folderdata+
"*"+ntupletag+
"*.root"},baseline && trigs &&
"pass");
164 vector<shared_ptr<Process> > all_procs = {proc_ttbar, proc_singlet, proc_other};
167 for(
size_t ind=0; ind<proc_sigs.size(); ind++)
168 all_procs.push_back(proc_sigs[ind]);
170 if(!
only_mc) all_procs.push_back(proc_data);
177 TString c_lowmet =
"met>100 && met<=200";
178 TString c_midmet =
"met>200 && met<=300";
179 TString c_higmet =
"met>300";
182 TString c_2b=
"nbt==2&&nbm==2";
183 TString c_3b=
"nbt>=2&&nbm==3&&nbl==3";
184 TString c_4b=
"nbt>=2&&nbm>=3&&nbl>=4";
187 TString c_sr=
"hig_am>100&&hig_am<140&&hig_dm<40";
188 TString c_cr=
"!("+c_sr+
")";
191 vector<TString> abcdcuts_std = {c_cr +
" && 2bcuts",
199 vector<abcd_method> abcds;
200 vector<TString> abcdcuts, metcuts, bincuts;
204 vector<TString>
methods = {
"TTML",
"MMMM"};
208 for(
size_t iabcd=0; iabcd<methods.size(); iabcd++) {
209 TString
method = methods[iabcd];
210 TString basecuts =
"", caption =
"";
212 if(method.Contains(
"TTML")){
213 c_2b=
"nbt==2&&nbm==2";
214 c_3b=
"nbt>=2&&nbm==3&&nbl==3";
215 c_4b=
"nbt>=2&&nbm>=3&&nbl>=4";
216 caption =
"TTML method: 2 tight b-tags, 1 medium, 1 loose";
218 if(method.Contains(
"MMMM")){
222 caption =
"MMMM method: all medium b-tags";
226 abcdcuts = abcdcuts_std;
227 for(
size_t ind=0; ind<abcdcuts.size(); ind++)
229 metcuts = vector<TString>{c_midmet, c_higmet};
230 bincuts = vector<TString>{c_3b, c_4b};
234 abcds.push_back(
abcd_method(method, metcuts, bincuts, abcdcuts, caption, basecuts));
235 if(method.Contains(
"noint")) abcds.back().setIntNbNj(
false);
237 vector<TableRow> table_cuts;
238 for(
size_t icut=0; icut < abcds.back().allcuts.size(); icut++)
239 table_cuts.push_back(
TableRow(abcds.back().allcuts[icut].Data(), abcds.back().allcuts[icut].Data()));
241 TString tname =
"preds"; tname += iabcd;
242 pm.
Push<
Table>(tname.Data(), table_cuts, all_procs,
true,
false);
255 vector<TString> tablenames;
256 for(
size_t imethod=0; imethod<abcds.size(); imethod++) {
260 vector<vector<GammaParams> > allyields;
265 for(
size_t ind=0; ind<proc_sigs.size(); ind++)
266 allyields.push_back(yield_table->
Yield(proc_sigs[ind].get(),
lumi));
269 allyields.push_back(yield_table->
Yield(proc_other.get(),
lumi));
270 allyields.push_back(yield_table->
Yield(proc_singlet.get(),
lumi));
271 allyields.push_back(yield_table->
Yield(proc_ttbar.get(),
lumi));
275 vector<vector<vector<float> > > kappas, preds;
276 findPreds(abcds[imethod], allyields, kappas, preds);
280 TString fullname =
printTable(abcds[imethod], allyields, kappas, preds, proc_sigs);
281 tablenames.push_back(fullname);
294 cout<<endl<<
"===== Tables to be moved to the AN/PAS/paper:"<<endl;
295 for(
size_t ind=0; ind<tablenames.size(); ind++){
296 TString name=tablenames[ind]; name.ReplaceAll(
"fulltable",
"table");
297 cout<<
" mv "<<name<<
" ${tables_folder}"<<endl;
299 cout<<endl<<
"===== Tables that can be compiled"<<endl;
300 for(
size_t ind=0; ind<tablenames.size(); ind++)
301 cout<<
" pdflatex "<<tablenames[ind]<<
" > /dev/null"<<endl;
305 double seconds = (chrono::duration<double>(chrono::high_resolution_clock::now() - begTime)).count();
307 cout<<endl<<
"Finding "<<abcds.size()<<
" tables took "<<round(seconds)<<
" seconds ("<<hhmmss<<
")"<<endl<<endl;
319 vector<vector<vector<float> > > &kappas, vector<vector<vector<float> > > &preds,
320 vector<shared_ptr<Process> > &proc_sigs){
321 cout<<endl<<
"Printing table (significance estimation can take a bit)"<<endl;
325 TString ump =
" & ",
blind_s =
"$\\spadesuit$";
327 size_t Nsig = proc_sigs.size();
342 if(
lumi < 1) digits_lumi = 3;
343 if(
lumi >= 15) digits_lumi = 0;
345 TString outname =
"tables/table_pred_lumi"+lumi_s; outname.ReplaceAll(
".",
"p");
346 if(
skim.Contains(
"2015")) outname +=
"_2015";
347 if(
unblind) outname +=
"_unblind";
348 else outname +=
"_blind";
349 outname +=
"_"+abcd.
method+
".tex";
350 ofstream out(outname);
353 if(abcd.
method.Contains(
"signal") && Ncol>7) out <<
"\\resizebox{\\textwidth}{!}{\n";
354 out <<
"\\begin{tabular}[tbp!]{ l ";
362 for(
size_t ind=0; ind<Nsig; ind++)
363 out<<
"|c"<<(do_zbi?
"c":
"");
365 out<<
"}\\hline\\hline\n";
366 out<<
"${\\cal L}="<<lumi_s<<
"$ fb$^{-1}$ ";
367 if(
split_bkg) out <<
" & Other & Single $t$ & $t\\bar{t}$ ";
368 out <<
"& $\\kappa$ & MC bkg.";
369 if(!
only_mc) out <<
" & Pred.& Obs. & Obs./MC "<<(do_zbi?
"& Signi.":
"");
371 for(
size_t ind=0; ind<Nsig; ind++) {
372 TString signame = proc_sigs[ind]->name_.c_str();
373 if(do_zbi) out <<
"& \\multicolumn{2}{c"<<(ind<Nsig-1?
"|":
"")<<
"}{" << signame <<
"}";
374 else out <<
"& " << signame;
376 out <<
" \\\\ \\hline\\hline\n";
378 vector<TString> binNames({
"SBD, 2b",
"SBD, xb",
"HIG, 2b",
"HIG, xb"});
381 for(
size_t iplane=0; iplane < abcd.
planecuts.size(); iplane++) {
382 out<<endl<<
"\\multicolumn{"<<Ncol<<
"}{c}{$"<<
CodeToLatex(abcd.
planecuts[iplane].Data())<<
"$} \\\\ \\hline\n";
383 for(
size_t iabcd=0; iabcd < abcd.
abcdcuts.size(); iabcd++){
384 for(
size_t ibin=0; ibin < abcd.
bincuts[iplane].size(); ibin++){
385 size_t index = abcd.
indexBin(iplane, ibin, iabcd);
386 if(abcd.
int_nbnj && iabcd%2==0 && ibin>0)
continue;
387 if(iabcd==3 && ibin==0) out <<
"\\hline" << endl;
389 TString binName = binNames[iabcd];
390 if(ibin==0) binName.ReplaceAll(
"xb",
"3b");
391 else binName.ReplaceAll(
"xb",
"4b");
405 out << ump <<
RoundNumber(allyields[offset+2][index].Yield(), digits)
406 << ump <<
RoundNumber(allyields[offset+3][index].Yield(), digits)
407 << ump <<
RoundNumber(allyields[offset+4][index].Yield(), digits);
411 if(iabcd==3) out <<
"$" <<
RoundNumber(kappas[iplane][ibin][0], digits)
412 <<
"^{+" <<
RoundNumber(kappas[iplane][ibin][1], digits)
413 <<
"}_{-" <<
RoundNumber(kappas[iplane][ibin][2], digits) <<
"}$ ";
415 out << ump <<
RoundNumber(allyields[1][index].Yield(), digits);
419 if(iabcd==3) out <<
"$" <<
RoundNumber(preds[iplane][ibin][0], digits)
420 <<
"^{+" <<
RoundNumber(preds[iplane][ibin][1], digits)
421 <<
"}_{-" <<
RoundNumber(preds[iplane][ibin][2], digits) <<
"}$ ";
425 out << ump <<
RoundNumber(allyields[0][index].Yield(), 0);
426 TString ratio_s =
"-";
427 double Nobs = allyields[0][index].Yield(), Nmc = allyields[1][index].Yield();
428 double Eobs = sqrt(Nobs), Emc = allyields[1][index].Uncertainty();
431 double ratio = Nobs/Nmc;
432 double Eratio = sqrt(pow(Eobs/Nmc,2) + pow(Nobs*Emc/Nmc/Nmc,2));
435 out << ump << ratio_s;
438 if(do_zbi && iabcd==3) out << ump <<
Zbi(allyields[0][index].Yield(), preds[iplane][ibin][0],
439 preds[iplane][ibin][1], preds[iplane][ibin][2]);
442 for(
size_t ind=0; ind<Nsig; ind++)
443 out<<ump<<
RoundNumber(allyields[2+ind][index].Yield(), digits);
446 for(
size_t ind=0; ind<Nsig; ind++) {
447 out<<ump<<
RoundNumber(allyields[2+ind][index].Yield(), digits);
451 out<<
Zbi(allyields[0][index].Yield()+allyields[2+ind][index].Yield(),preds[iplane][ibin][0],
452 preds[iplane][ibin][1], preds[iplane][ibin][2]);
461 out <<
"\\hline\\hline\n";
466 out<<
"\\end{tabular}"<<endl;
467 if(abcd.
method.Contains(
"signal") && Ncol>7) out <<
"}\n";
471 TString fullname = outname; fullname.ReplaceAll(
"table_",
"fulltable_");
472 ofstream full(fullname);
473 ifstream header(
"txt/header.tex");
474 full<<header.rdbuf();
476 if(!abcd.
method.Contains(
"signal")) full <<
"\\usepackage[landscape]{geometry}\n\n";
477 full <<
"\\begin{document}\n\n";
478 full <<
"\\begin{table}\n\\centering\n";
479 full <<
"\\caption{" << abcd.
caption <<
".}\\vspace{0.1in}\n\\label{tab:"<<abcd.
method<<
"}\n";
480 ifstream outtab(outname);
481 full << outtab.rdbuf();
483 full <<
"\\end{table}\n\n";
484 full <<
"\\end{document}\n";
491 TString
Zbi(
double Nobs,
double Nbkg,
double Eup_bkg,
double Edown_bkg){
494 double Nsig = Nobs-Nbkg;
495 double zbi = RooStats::NumberCountingUtils::BinomialExpZ(Nsig, Nbkg, Eup_bkg/Nbkg);
496 if(Nbkg==0) zbi = RooStats::NumberCountingUtils::BinomialWithTauExpZ(Nsig, Nbkg, 1/Eup_bkg);
499 if(zbi_s!=
"-") zbi_s =
"$"+zbi_s+
"\\sigma$";
500 if(Nsig<=0 || Eup_bkg<=0) zbi_s =
"-";
509 bool label_up =
false;
512 PlotOpt opts(
"txt/plot_styles.txt",
"Kappa");
523 vector<vector<vector<kmarker> > > k_ordered;
524 vector<kmarker> ind_bcuts;
526 vector<kmarker> bcuts({{
"nbm==1",4,20,zz}, {
"nbm==2",2,21,zz}, {
"nbm>=3",kGreen+3,22,zz}, {
"nbm>=2",kMagenta+2,23,zz}});
529 for(
size_t iplane=0; iplane < kappas.size(); iplane++) {
530 k_ordered.push_back(vector<vector<kmarker> >());
531 for(
size_t ibin=0; ibin < kappas[iplane].size(); ibin++){
532 TString bincut = abcd.
bincuts[iplane][ibin];
533 bincut.ReplaceAll(
" ",
"");
534 bincut.ReplaceAll(
"mm_",
"");
537 index = bincut.First(
'[');
538 bincut.Remove(index, bincut.First(
']')-index+1);
541 for(
size_t ib=0; ib<bcuts.size(); ib++){
542 if(bincut.Contains(bcuts[ib].cut)){
545 for(
size_t indb=0; indb<ind_bcuts.size(); indb++)
546 if(ind_bcuts[indb].color == bcuts[ib].color) cutfound =
true;
547 if(!cutfound) ind_bcuts.push_back(bcuts[ib]);
550 bincut.ReplaceAll(bcuts[ib].cut+
"&&",
"");
551 for(
size_t ik=0; ik<k_ordered[iplane].size(); ik++){
553 if(bincut==k_ordered[iplane][ik][0].cut){
554 k_ordered[iplane][ik].push_back({bincut, bcuts[ib].color, bcuts[ib].style, kappas[iplane][ibin]});
561 k_ordered[iplane].push_back(vector<kmarker>({{bincut, bcuts[ib].color, bcuts[ib].style, kappas[iplane][ibin]}}));
570 k_ordered[iplane].push_back(vector<kmarker>({{bincut, bcuts[0].color, bcuts[0].style, kappas[iplane][ibin]}}));
572 if(ind_bcuts.size()==0) ind_bcuts.push_back(bcuts[0]);
578 TCanvas can(
"can",
"");
579 can.SetFillStyle(4000);
580 TLine line; line.SetLineWidth(2); line.SetLineStyle(2);
581 TLatex label; label.SetTextSize(0.05); label.SetTextFont(42); label.SetTextAlign(23);
582 if(k_ordered.size()>3) label.SetTextSize(0.04);
585 float minx = 0.5, maxx = nbins+0.5, miny = 0, maxy = 2.4;
586 if(label_up) maxy = 2.6;
587 TH1D histo(
"histo",
"", nbins, minx, maxx);
588 histo.SetMinimum(miny);
589 histo.SetMaximum(maxy);
590 histo.GetYaxis()->CenterTitle(
true);
591 histo.GetXaxis()->SetLabelOffset(0.008);
592 histo.SetYTitle(
"#kappa");
597 vector<vector<double> > vx(ind_bcuts.size()), vexh(ind_bcuts.size()), vexl(ind_bcuts.size());
598 vector<vector<double> > vy(ind_bcuts.size()), veyh(ind_bcuts.size()), veyl(ind_bcuts.size());
599 for(
size_t iplane=0; iplane < k_ordered.size(); iplane++) {
600 for(
size_t ibin=0; ibin < k_ordered[iplane].size(); ibin++){
602 histo.GetXaxis()->SetBinLabel(bin,
CodeToRootTex(k_ordered[iplane][ibin][0].cut.Data()).c_str());
604 double xval = bin, nbs = k_ordered[iplane][ibin].size(), minxb = 0.15, binw = 0;
609 binw = 2*minxb/(nbs-1);
611 for(
size_t ib=0; ib<k_ordered[iplane][ibin].size(); ib++){
613 for(
size_t indb=0; indb<ind_bcuts.size(); indb++){
614 if(ind_bcuts[indb].color == k_ordered[iplane][ibin][ib].color){
615 vx[indb].push_back(xval);
617 vexl[indb].push_back(0);
618 vexh[indb].push_back(0);
619 vy[indb].push_back(k_ordered[iplane][ibin][ib].kappa[0]);
620 veyl[indb].push_back(k_ordered[iplane][ibin][ib].kappa[1]);
621 veyh[indb].push_back(k_ordered[iplane][ibin][ib].kappa[2]);
628 line.SetLineStyle(2); line.SetLineWidth(2);
629 if (iplane<k_ordered.size()-1) line.DrawLine(bin+0.5, miny, bin+0.5, maxy);
631 if(label_up) label.DrawLatex((2*bin-k_ordered[iplane].size()+1.)/2., maxy-0.1,
CodeToRootTex(abcd.
planecuts[iplane].Data()).c_str());
632 else label.DrawLatex((2*bin-k_ordered[iplane].size()+1.)/2., -0.26,
CodeToRootTex(abcd.
planecuts[iplane].Data()).c_str());
637 if(label_up) legY = 0.8;
638 double legW = 0.22, legH = legSingle*(ind_bcuts.size()+1)/2;
639 if(ind_bcuts.size()>3) legH = legSingle*((ind_bcuts.size()+1)/2);
640 TLegend leg(legX, legY-legH, legX+legW, legY);
642 leg.SetFillStyle(0); leg.SetBorderSize(0);
645 TGraphAsymmErrors graph[20];
646 for(
size_t indb=0; indb<ind_bcuts.size(); indb++){
647 graph[indb] = TGraphAsymmErrors(vx[indb].size(), &(vx[indb][0]), &(vy[indb][0]),
648 &(vexl[indb][0]), &(vexh[indb][0]), &(veyl[indb][0]), &(veyh[indb][0]));
649 graph[indb].SetMarkerStyle(ind_bcuts[indb].style); graph[indb].SetMarkerSize(1.1);
650 graph[indb].SetMarkerColor(ind_bcuts[indb].color);
651 graph[indb].SetLineColor(ind_bcuts[indb].color); graph[indb].SetLineWidth(2);
652 graph[indb].Draw(
"p0 same");
653 leg.AddEntry(&graph[indb],
CodeToRootTex(ind_bcuts[indb].cut.Data()).c_str(),
"p");
655 if(ind_bcuts.size()>1) leg.Draw();
659 cmslabel.SetTextSize(0.06);
660 cmslabel.SetNDC(kTRUE);
661 cmslabel.SetTextAlign(11);
662 cmslabel.DrawLatex(opts.
LeftMargin()+0.005, 1-opts.
TopMargin()+0.015,
"#font[62]{CMS} #scale[0.8]{#font[52]{Simulation}}");
663 cmslabel.SetTextAlign(31);
666 line.SetLineStyle(3); line.SetLineWidth(1);
667 line.DrawLine(minx, 1, maxx, 1);
669 TString fname=
"plots/kappa_" + abcd.
method;
672 cout<<endl<<
" open "<<fname<<endl;
679 vector<vector<vector<float> > > &kappas, vector<vector<vector<float> > > &preds){
681 vector<float> pow_kappa({ 1, -1, -1, 1});
683 vector<float> pow_totpred( {-1, 1, 1, 1, -1, -1, 1});
685 float val(1.), valup(1.), valdown(1.);
687 for(
size_t iplane=0; iplane < abcd.
planecuts.size(); iplane++) {
688 kappas.push_back(vector<vector<float> >());
689 preds.push_back(vector<vector<float> >());
690 for(
size_t ibin=0; ibin < abcd.
bincuts[iplane].size(); ibin++){
691 vector<vector<float> > entries;
692 vector<vector<float> > weights;
694 for(
size_t iabcd=0; iabcd < 3; iabcd++){
695 size_t index = abcd.
indexBin(iplane, ibin, iabcd);
696 entries.push_back(vector<float>());
697 weights.push_back(vector<float>());
698 entries.back().push_back(allyields[0][index].Yield());
699 weights.back().push_back(1.);
702 vector<vector<float> > kentries;
703 vector<vector<float> > kweights;
705 for(
size_t iabcd=0; iabcd < 4; iabcd++){
706 size_t index = abcd.
indexBin(iplane, ibin, iabcd);
708 entries.push_back(vector<float>());
709 weights.push_back(vector<float>());
710 entries.back().push_back(allyields[1][index].NEffective());
711 weights.back().push_back(allyields[1][index].Weight());
713 kentries.push_back(vector<float>());
714 kweights.push_back(vector<float>());
715 kentries.back().push_back(allyields[1][index].NEffective());
716 kweights.back().push_back(allyields[1][index].Weight());
720 val =
calcKappa(entries, weights, pow_totpred, valdown, valup);
721 if(valdown<0) valdown = 0;
722 preds[iplane].push_back(vector<float>({val, valup, valdown}));
724 val =
calcKappa(kentries, kweights, pow_kappa, valdown, valup);
725 if(valdown<0) valdown = 0;
726 kappas[iplane].push_back(vector<float>({val, valup, valdown}));
734 vector<vector<vector<float> > > &kappas, vector<vector<vector<float> > > &preds){
737 cout<<endl<<endl<<
"=================== Printing cuts for method "<<abcd.
method<<
" ==================="<<endl;
738 cout<<
"-- Baseline cuts: "<<baseline<<endl;
739 for(
size_t iplane=0; iplane < abcd.
planecuts.size(); iplane++) {
740 cout<<endl<<
" **** Plane "<<abcd.
planecuts[iplane]<<
" ***"<<endl;
741 for(
size_t ibin=0; ibin < abcd.
bincuts[iplane].size(); ibin++){
742 for(
size_t iabcd=0; iabcd < abcd.
abcdcuts.size(); iabcd++){
743 size_t index = abcd.
indexBin(iplane, ibin, iabcd);
744 cout<<
"MC: "<<setw(8)<<
RoundNumber(allyields[1][index].Yield(),digits)
745 <<
" Data: "<<setw(4)<<
RoundNumber(allyields[0][index].Yield(), 0)
746 <<
" - "<< abcd.
allcuts[index]<<endl;
748 cout<<
"Kappa = "<<
RoundNumber(kappas[iplane][ibin][0],digits)<<
"+"<<
RoundNumber(kappas[iplane][ibin][1],digits)
749 <<
"-"<<
RoundNumber(kappas[iplane][ibin][2],digits)<<
", Prediction = " 751 <<
"-"<<
RoundNumber(preds[iplane][ibin][2],digits)<<endl;
760 static struct option long_options[] = {
761 {
"method", required_argument, 0,
'm'},
762 {
"lumi", required_argument, 0,
'l'},
763 {
"skim", required_argument, 0,
's'},
764 {
"json", required_argument, 0,
'j'},
765 {
"split_bkg", no_argument, 0,
'b'},
766 {
"no_signal", no_argument, 0,
'n'},
767 {
"do_leptons", no_argument, 0,
'p'},
768 {
"unblind", no_argument, 0,
'u'},
769 {
"only_mc", no_argument, 0,
'o'},
770 {
"only_kappa", no_argument, 0,
'k'},
771 {
"debug", no_argument, 0,
'd'},
772 {
"only_dilepton", no_argument, 0,
'2'},
773 {
"ht", no_argument, 0, 0},
779 opt = getopt_long(argc, argv,
"m:s:j:udbnl:p2ok", long_options, &option_index);
823 optname = long_options[option_index].name;
827 printf(
"Bad option! Found option name %s\n", optname.c_str());
832 printf(
"Bad option! getopt_long returned character code 0%o\n", opt);
PlotOpt & TopMargin(double top)
void setPlotStyle(PlotOpt opts)
PlotOpt & LeftMargin(double left)
int main(int argc, char *argv[])
void findPreds(abcd_method &abcd, vector< vector< GammaParams > > &allyields, vector< vector< vector< float > > > &kappas, vector< vector< vector< float > > > &preds)
std::vector< GammaParams > Yield(const Process *process, double luminosity) const
TString HoursMinSec(float fseconds)
std::vector< float > *const & leps_pt() const
Get leps_pt for current event and cache it.
double Significance(double Nobs, double Nbkg, double Eup_bkg, double Edown_bkg=-1.)
const std::string & Name() const
Get the string representation of this function.
Abstract base class for access to ntuple variables.
const std::vector< std::unique_ptr< Figure > > & Figures() const
void ReplaceAll(std::string &str, const std::string &orig, const std::string &rep)
size_t indexBin(size_t iplane, size_t ibin, size_t iabcd)
Combines a callable function taking a Baby and returning a scalar or vector with its string represent...
bool Contains(const std::string &str, const std::string &pat)
TString Zbi(double Nobs, double Nbkg, double Eup_bkg, double Edown_bkg)
TString printTable(abcd_method &abcd, vector< vector< GammaParams > > &allyields, vector< vector< vector< float > > > &kappas, vector< vector< vector< float > > > &preds, vector< shared_ptr< Process > > &proc_sigs)
std::string execute(const std::string &cmd)
list methods
Aggregate bins.
std::vector< std::vector< TString > > bincuts
std::vector< TString > allcuts
std::vector< TString > abcdcuts
double calcKappa(std::vector< std::vector< float > > &entries, std::vector< std::vector< float > > &weights, std::vector< float > &powers, float &mSigma, float &pSigma, bool do_data=false, bool verbose=false, double syst=-1., bool do_plot=false, int nrep=100000)
FigureType & Push(Args &&...args)
std::vector< GammaParams > BackgroundYield(double luminosity) const
std::string CodeToRootTex(std::string code)
std::string CodeToLatex(std::string code)
void plotKappa(abcd_method &abcd, vector< vector< vector< float > > > &kappas)
void printDebug(abcd_method &abcd, vector< vector< GammaParams > > &allyields, TString baseline, vector< vector< vector< float > > > &kappas, vector< vector< vector< float > > > &preds)
TString RoundNumber(double num, int decimals, double denom=1.)
Organizes efficient production of plots with single loop over each process.
std::vector< TString > planecuts
PlotOpt & BottomMargin(double bottom)
std::vector< GammaParams > DataYield() const
const NamedFunc st("st", [](const Baby &b) -> NamedFunc::ScalarType{float stvar=b.ht();for(const auto &pt:*(b.leps_pt())) stvar+=pt;return stvar;})
PlotOpt & LegendEntryHeight(double height)
void MakePlots(double luminosity, const std::string &subdir="")
Prints all added plots with given luminosity.
float const & ht() const
Get ht for current event and cache it.
PlotOpt & RightMargin(double right)
void GetOptions(int argc, char *argv[])
Loads colors from a text configuration file.