12 #include "RooStats/NumberCountingUtils.h" 36 int color,
const set<string> &files,
const string &cut =
"1"){
37 return make_shared<Process>(process_name, type, color,
38 unique_ptr<Baby>(
new T(files)),
43 TString
Zbi(
double Nobs,
double Nbkg,
double Ebkg){
44 double Nsig = Nobs-Nbkg;
45 double zbi = RooStats::NumberCountingUtils::BinomialExpZ(Nsig, Nbkg, Ebkg/Nbkg);
46 if(Nbkg==0) zbi = RooStats::NumberCountingUtils::BinomialWithTauExpZ(Nsig, Nbkg, 1/Ebkg);
49 if(Nsig<=0) zbi_s =
"-";
54 int main(
int argc,
char *argv[]){
55 gErrorIgnoreLevel=6000;
58 time_t begtime, endtime;
63 string hostname =
execute(
"echo $HOSTNAME");
65 bfolder =
"/net/cms2";
67 string foldermc(bfolder+
"/cms2r0/babymaker/babies/2016_06_14/mc/merged_standard/");
68 string folderdata(bfolder+
"/cms2r0/babymaker/babies/2016_06_21/data/skim_standard/");
69 if(
method.Contains(
"met150")){
70 foldermc = bfolder+
"/cms2r0/babymaker/babies/2016_06_14/mc/merged_1lht500met150nj5/";
71 folderdata = bfolder+
"/cms2r0/babymaker/babies/2016_06_21/data/skim_1lmet150/";
74 if(
method.Contains(
"2015")){
75 foldermc = bfolder+
"/cms2r0/babymaker/babies/2016_04_29/mc/merged_1lht500met200/";
76 folderdata = bfolder+
"/cms2r0/babymaker/babies/2016_04_29/data/merged_1lht500met200/";
79 Palette colors(
"txt/colors.txt",
"default");
82 {foldermc+
"*_TTJets*Lept*.root", foldermc+
"*_TTJets_HT*.root",
83 foldermc+
"*_WJetsToLNu*.root",foldermc+
"*_ST_*.root",
84 foldermc+
"*_TTW*.root",foldermc+
"*_TTZ*.root",
85 foldermc+
"*DYJetsToLL*.root",foldermc+
"*QCD_HT*.root",
86 foldermc+
"*_ZJet*.root",foldermc+
"*_ttHJetTobb*.root",
87 foldermc+
"*_TTGJets*.root",foldermc+
"*_TTTT*.root",
88 foldermc+
"*_WH_HToBB*.root",foldermc+
"*_ZH_HToBB*.root",
89 foldermc+
"*_WWTo*.root",foldermc+
"*_WZ*.root",foldermc+
"*_ZZ_*.root"},
95 {foldermc+
"*_WJetsToLNu*",foldermc+
"*_ST_*.root",
96 foldermc+
"*_TTW*.root",foldermc+
"*_TTZ*.root",
97 foldermc+
"*DYJetsToLL*.root",foldermc+
"*QCD_HT*.root",
98 foldermc+
"*_ZJet*.root",foldermc+
"*_ttHJetTobb*.root",
99 foldermc+
"*_TTGJets*.root",foldermc+
"*_TTTT*.root",
100 foldermc+
"*_WH_HToBB*.root",foldermc+
"*_ZH_HToBB*.root",
101 foldermc+
"*_WWTo*.root",foldermc+
"*_WZ*.root",foldermc+
"*_ZZ_*.root"});
103 string trigs =
"(trig[4]||trig[8]||trig[13]||trig[33])";
104 if(
method.Contains(
"2015")) trigs =
"(trig[4]||trig[8]||trig[28]||trig[14])";
106 {folderdata+
"*.root"},trigs);
108 vector<shared_ptr<Process> > all_procs = {data, tt};
109 if (
do_other) all_procs.push_back(other);
113 TString base_s =
"mj14>250&&njets>=5&&stitch&&pass&&nonblind";
115 vector<TString> njbcuts_stdnob = {
"njets>=6&&njets<=8",
"njets>=9",
"njets>=6&&njets<=8",
"njets>=9"};
116 vector<TString> njbcuts_2l = {
"njets>=5&&njets<=7",
"njets>=8",
"njets>=5&&njets<=7",
"njets>=8"};
117 vector<TString> njbcuts_5j = {
"nbm==1&&njets==5",
"nbm>=2&&njets==5",
"nbm==1&&njets==5",
"nbm>=2&&njets==5"};
118 vector<TString> njbcuts_m1lmet150nb12 = {
"nbm==1&&njets>=6&&njets<=8",
"nbm==1&&njets>=9",
119 "nbm>=2&&njets>=6&&njets<=8",
"nbm>=2&&njets>=9"};
120 vector<TString> njbcuts_std = {
"nbm==1&&njets>=6&&njets<=8",
"nbm==1&&njets>=9",
121 "nbm==2&&njets>=6&&njets<=8",
"nbm==2&&njets>=9",
122 "nbm>=3&&njets>=6&&njets<=8",
"nbm>=3&&njets>=9",
123 "nbm==1&&njets>=6&&njets<=8",
"nbm==1&&njets>=9",
124 "nbm==2&&njets>=6&&njets<=8",
"nbm==2&&njets>=9",
125 "nbm>=3&&njets>=6&&njets<=8",
"nbm>=3&&njets>=9"};
126 vector<TString> njbcuts_nb1 = {
"nbm==1&&njets>=6&&njets<=8",
"nbm==1&&njets>=9",
127 "nbm==2&&njets>=6&&njets<=8",
"nbm==2&&njets>=9",
128 "nbm>=3&&njets>=6&&njets<=8",
"nbm>=3&&njets>=9"};
129 vector<TString> njbcuts_met500 = {
"nbm==1&&njets>=6&&njets<=8",
"nbm==1&&njets>=9",
130 "nbm==2&&njets>=6&&njets<=8",
"nbm==2&&njets>=9",
131 "nbm>=3&&njets>=6&&njets<=8",
"nbm>=3&&njets>=9"};
133 vector<TString> njbcuts_m1lnob = {
"njets>=6&&njets<=8",
"njets>=9"};
134 vector<TString> njbcuts_m2lnob = {
"njets>=5&&njets<=7",
"njets>=8"};
135 vector<TString> njbcuts_2lveto_lonj = {
"njets>=5",
"njets>=5"};
136 vector<TString> njbcuts_2lveto_hinj = {
"njets>=8",
"njets>=8"};
137 vector<TString> njbcuts_all = {
"njets>=6"};
138 vector<TString> njbcuts_2l_lonj = {
"njets>=5"};
139 vector<TString> njbcuts_2l_hinj = {
"njets>=8"};
143 vector<TString> metcuts = {
"met<=350",
"met>350&&met<=500"};
145 vector<TString> abcdcuts_std = {
"mt<=140&&mj14<=400",
149 vector<TString> abcdcuts_2lveto = {
"mt<=140&&mj14<=400&&nleps==1&&nveto==0&&nbm>=1&&njets>=6",
150 "mt<=140&&mj14>400&&nleps==1&&nveto==0&&nbm>=1&&njets>=6",
151 "mj14<=400&&(nleps==2&&nbm<=2&&njets>=5 || nleps==1&&nveto==1&&nbm>=1&&nbm<=2&&mt>140&&njets>=6)",
152 "mj14> 400&&(nleps==2&&nbm<=2&&njets>=5 || nleps==1&&nveto==1&&nbm>=1&&nbm<=2&&mt>140&&njets>=6)"};
154 vector<TString> abcdcuts_2lveto_el = {
"mt<=140&&mj14<=400&&nels==1&&nveto==0&&nbm>=1&&njets>=6",
155 "mt<=140&&mj14>400&&nels==1&&nveto==0&&nbm>=1&&njets>=6",
156 "mj14<=400&&(nels==2&&nbm<=2&&njets>=5 || nels==1&&nveto==1&&nbm>=1&&nbm<=2&&mt>140&&njets>=6)",
157 "mj14> 400&&(nels==2&&nbm<=2&&njets>=5 || nels==1&&nveto==1&&nbm>=1&&nbm<=2&&mt>140&&njets>=6)"};
159 vector<TString> abcdcuts_2lveto_mu = {
"mt<=140&&mj14<=400&&nmus==1&&nveto==0&&nbm>=1&&njets>=6",
160 "mt<=140&&mj14>400&&nmus==1&&nveto==0&&nbm>=1&&njets>=6",
161 "mj14<=400&&(nmus==2&&nbm<=2&&njets>=5 || nmus==1&&nveto==1&&nbm>=1&&nbm<=2&&mt>140&&njets>=6)",
162 "mj14> 400&&(nmus==2&&nbm<=2&&njets>=5 || nmus==1&&nveto==1&&nbm>=1&&nbm<=2&&mt>140&&njets>=6)"};
164 vector<TString> abcdcuts_2lveto_lonj = {
"mt<=140&&mj14<=400&&nleps==1&&nveto==0&&nbm>=1&&njets>=6",
165 "mt<=140&&mj14>400&&nleps==1&&nveto==0&&nbm>=1&&njets>=6&&njets<=8",
166 "mj14<=400&&(nleps==2&&nbm<=2&&njets>=5 || nleps==1&&nveto==1&&nbm>=1&&nbm<=2&&mt>140&&njets>=6)",
167 "mj14>400&&(nleps==2&&nbm<=2&&njets>=5&&njets<=7 || nleps==1&&nveto==1&&nbm>=1&&nbm<=2&&mt>140&&njets>=6&&njets<=8)"};
170 vector<TString> abcdcuts_2lveto_hinj = {
"mt<=140&&mj14<=400&&nleps==1&&nveto==0&&nbm>=1&&njets>=6",
171 "mt<=140&&mj14>400&&nleps==1&&nveto==0&&nbm>=1&&njets>=9",
172 "mj14<=400&&(nleps==2&&nbm<=2&&njets>=5 || nleps==1&&nveto==1&&nbm>=1&&nbm<=2&&mt>140&&njets>=6)",
173 "mj14>400&&(nleps==2&&nbm<=2&&njets>=8 || nleps==1&&nveto==1&&nbm>=1&&nbm<=2&&mt>140&&njets>=9)"};
175 vector<TString> abcdcuts_veto = {
"mt<=140&&mj14<=400&&njets>=6&&nbm>=1&&nleps==1&&nveto==0",
176 "mt<=140&&mj14>400&&nbm>=1&&nleps==1&&nveto==0",
177 "mt>140&&mj14<=400&&njets>=6&&nbm>=1&&nbm<=2&&nleps==1&&nveto==1",
178 "mt>140&&mj14>400&&njets>=6&&nbm>=1&&nbm<=2&&nleps==1&&nveto==1"};
179 vector<TString> abcdcuts_2l = {
"mt<=140&&mj14<=400&&njets>=6&&nbm>=1&&nleps==1&&nveto==0",
180 "mt<=140&&mj14>400&&nbm>=1&&nleps==1&&nveto==0",
181 "mj14<=400&&nbm<=2&&nleps==2",
182 "mj14>400&&nbm<=2&&nleps==2"};
185 vector<TString> abcdcuts, njbcuts_himt = njbcuts_stdnob;
186 vector<TString> njbcuts = njbcuts_stdnob;
187 TString region_s =
"R", method_s, base_all =
"mj14>250&&pass&&nonblind&&stitch&&";
188 TString lumi_s =
"815$ pb$^{-1}$";
192 base_all =
"mj14>250&&pass&&stitch&&";
193 if(
method.Contains(
"2015")){
195 lumi_s =
"2.3$ fb$^{-1}$";
198 lumi_s =
"2.6$ fb$^{-1}$";
204 base_s = base_all+
"njets>=5";
205 njbcuts_himt = njbcuts_2l;
206 abcdcuts = abcdcuts_2l;
208 method_s =
"D3 and D4 have $2\\ell$";
209 }
else if(
method==
"m2lveto" ||
method==
"m2lveto_2015") {
210 base_s = base_all+
"njets>=5";
211 njbcuts = njbcuts_2lveto_lonj;
212 njbcuts_himt = njbcuts_2lveto_lonj;
213 abcdcuts = abcdcuts_2lveto;
215 method_s =
"D3 and D4 have $\\ell\\ell+\\ell t_{\\rm veto}$";
217 }
else if(
method==
"m2lvetomet150" ||
method==
"m2lvetomet150_2015") {
218 base_s = base_all+
"njets>=5";
219 njbcuts = njbcuts_2lveto_lonj;
220 njbcuts_himt = njbcuts_2lveto_lonj;
221 abcdcuts = abcdcuts_2lveto;
223 method_s =
"$150<E_{\\rm T}^{\\rm miss}<200$, D3 and D4 have $\\ell\\ell+\\ell t_{\\rm veto}$";
224 ilowmet = njbcuts.size();
225 }
else if(
method==
"m2lveto_el" ||
method==
"m2lveto_el_2015") {
226 base_s = base_all+
"njets>=5&&nels>=1";
227 njbcuts = njbcuts_2lveto_lonj;
228 njbcuts_himt = njbcuts_2lveto_lonj;
229 abcdcuts = abcdcuts_2lveto_el;
231 method_s =
"D3 and D4 have $ee+e t_{\\rm veto}$";
233 }
else if(
method==
"m2lveto_mu" ||
method==
"m2lveto_mu_2015") {
234 base_s = base_all+
"njets>=5&&nmus>=1";
235 njbcuts = njbcuts_2lveto_lonj;
236 njbcuts_himt = njbcuts_2lveto_lonj;
237 abcdcuts = abcdcuts_2lveto_mu;
239 method_s =
"D3 and D4 have $\\mu\\mu+\\mu t_{\\rm veto}$";
241 }
else if(
method==
"m2lveto_lonj") {
242 base_s = base_all+
"njets>=5";
243 njbcuts = njbcuts_2lveto_lonj;
244 njbcuts_himt = njbcuts_2lveto_lonj;
245 abcdcuts = abcdcuts_2lveto_lonj;
247 method_s =
"D3 and D4 have $\\ell\\ell+\\ell t_{\\rm veto}$ - low $N_{\\rm jets}$";
249 }
else if(
method==
"m2lveto_hinj") {
250 base_s = base_all+
"njets>=5";
251 njbcuts = njbcuts_2lveto_hinj;
252 njbcuts_himt = njbcuts_2lveto_hinj;
253 abcdcuts = abcdcuts_2lveto_hinj;
255 method_s =
"D3 and D4 have $\\ell\\ell+\\ell t_{\\rm veto}$ - high $N_{\\rm jets}$";
257 }
else if(
method==
"m2lvetomet150_lonj") {
258 base_s = base_all+
"njets>=5";
259 njbcuts = njbcuts_2l_lonj;
260 njbcuts_himt = njbcuts_2l_lonj;
261 abcdcuts = abcdcuts_2lveto_lonj;
263 method_s =
"D3 and D4 have $\\ell\\ell+\\ell t_{\\rm veto}$ - low $N_{\\rm jets}$";
264 ilowmet = njbcuts.size();
265 }
else if(
method==
"m2lvetomet150_hinj") {
266 base_s = base_all+
"njets>=5";
267 njbcuts = njbcuts_2l_hinj;
268 njbcuts_himt = njbcuts_2l_hinj;
269 abcdcuts = abcdcuts_2lveto_hinj;
271 method_s =
"D3 and D4 have $\\ell\\ell+\\ell t_{\\rm veto}$ - high $N_{\\rm jets}$";
272 ilowmet = njbcuts.size();
274 base_s = base_all+
"njets>=6&&nbm>=1&&nleps==1";
275 njbcuts_himt = njbcuts_stdnob;
276 abcdcuts = abcdcuts_veto;
278 method_s =
"D3 and D4 have $\\ell t_{\\rm veto}$";
279 }
else if(
method==
"m5j") {
280 base_s = base_all+
"njets==5&&nbm>=1&&nleps==1&&nveto==0";
281 njbcuts = njbcuts_5j;
282 njbcuts_himt = njbcuts_5j;
283 abcdcuts = abcdcuts_std;
284 method_s =
"$N_{\\rm jets}=5$";
285 }
else if(
method==
"m1lmet150") {
286 base_s = base_all+
"njets>=6&&nbm>=1&&nleps==1&&nveto==0";
287 njbcuts = njbcuts_m1lmet150nb12;
288 njbcuts_himt = njbcuts_m1lmet150nb12;
289 abcdcuts = abcdcuts_std;
290 method_s =
"$1\\ell, 150<E_{\\rm T}^{\\rm miss}<200$";
291 ilowmet = njbcuts.size();
292 }
else if(
method==
"mvetomet150" ||
method==
"mvetomet150_2015") {
293 base_s = base_all+
"njets>=6&&nbm>=1&&nleps==1";
294 njbcuts = njbcuts_m1lnob;
295 njbcuts_himt = njbcuts_m1lnob;
296 abcdcuts = abcdcuts_veto;
298 method_s =
"$150<E_{\\rm T}^{\\rm miss}<200$, D3 and D4 have $\\ell t_{\\rm veto}$";
299 }
else if(
method==
"m2lmet150" ||
method==
"m2lmet150_2015") {
300 base_s = base_all+
"njets>=5";
301 njbcuts = njbcuts_m1lnob;
302 njbcuts_himt = njbcuts_m2lnob;
303 abcdcuts = abcdcuts_2l;
305 method_s =
"$150<E_{\\rm T}^{\\rm miss}<200$, D3 and D4 have $\\ell\\ell+\\ell t_{\\rm veto}$";
306 }
else if(
method==
"mall") {
307 base_s = base_all+
"njets>=6&&nbm>=1&&met>200&&nleps==1&&nveto==0";
308 njbcuts = njbcuts_all;
309 njbcuts_himt = njbcuts_all;
310 abcdcuts = abcdcuts_std;
311 method_s =
"All signal bins - $1\\ell$, $E_{\\rm T}^{\\rm miss}>200$";
312 metcuts[0] =
"met>200";
313 ilowmet = njbcuts.size();
314 }
else if(
method==
"met200") {
315 base_s = base_all+
"njets>=6&&nbm>=1&&met>200&&nleps==1&&nveto==0";
316 njbcuts = njbcuts_std;
317 njbcuts_himt = njbcuts_std;
318 abcdcuts = abcdcuts_std;
319 method_s =
"Signal bins - $1\\ell$, $200<E_{\\rm T}^{\\rm miss}\\leq500$";
321 }
else if(
method==
"met500") {
322 base_s = base_all+
"njets>=6&&nbm>=1&&met>500&&nleps==1&&nveto==0";
323 njbcuts = njbcuts_met500;
324 njbcuts_himt = njbcuts_met500;
325 abcdcuts = abcdcuts_std;
326 method_s =
"Signal bins - $1\\ell$, $E_{\\rm T}^{\\rm miss}>500$";
327 metcuts[0] =
"met>500";
328 ilowmet = njbcuts.size();
329 }
else if(
method==
"met200nb1") {
330 base_s = base_all+
"njets>=6&&nbm>=1&&met>200&&nleps==1&&nveto==0";
331 njbcuts = njbcuts_nb1;
332 njbcuts_himt = njbcuts_nb1;
333 abcdcuts = abcdcuts_std;
334 method_s =
"Signal bins - $1\\ell$, separated N_{b}=1$, $200<E_{\\rm T}^{\\rm miss}\\leq350$";
335 metcuts[0] =
"met>200&&met<=350&&nbm==1";
336 metcuts[1] =
"met>200&&met<=350&&nbm>=2";
338 }
else if(
method==
"met350nb1") {
339 base_s = base_all+
"njets>=6&&nbm>=1&&met>350&&met<=500&&nleps==1&&nveto==0";
340 njbcuts = njbcuts_nb1;
341 njbcuts_himt = njbcuts_nb1;
342 abcdcuts = abcdcuts_std;
343 method_s =
"Signal bins - $1\\ell$, separated N_{b}=1$, $350<E_{\\rm T}^{\\rm miss}\\leq500$";
344 metcuts[0] =
"met>350&&met<=500&&nbm==1";
345 metcuts[1] =
"met>350&&met<=500&&nbm>=2";
347 }
else if(
method==
"met500nb1") {
348 base_s = base_all+
"njets>=6&&nbm>=1&&met>500&&nleps==1&&nveto==0";
349 njbcuts = njbcuts_nb1;
350 njbcuts_himt = njbcuts_nb1;
351 abcdcuts = abcdcuts_std;
352 method_s =
"Signal bins - $1\\ell$, separated N_{b}=1$, $E_{\\rm T}^{\\rm miss}>500$";
353 metcuts[0] =
"met>500&&nbm==1";
354 metcuts[1] =
"met>500&&nbm>=2";
356 }
else if(
method==
"agg_himet"){
357 base_s = base_all+
"met>500&&njets>=6&&nbm>=1";
358 njbcuts = vector<TString>{
"nbm>=3&&njets>=6"};
359 njbcuts_himt = njbcuts;
360 abcdcuts = abcdcuts_std;
361 method_s =
"Agg. Bin: $1\\ell$, MET500, $N_{j}\\geq6$, $N_{b}\\geq3$";
362 metcuts = vector<TString>{
"met>500"};
364 }
else if(
method==
"agg_mixed"){
365 base_s = base_all+
"met>350&&njets>=6&&nbm>=1";
366 njbcuts = vector<TString>{
"nbm>=2&&njets>=9"};
367 njbcuts_himt = njbcuts;
368 abcdcuts = abcdcuts_std;
369 method_s =
"Agg. Bin: $1\\ell$, MET350, $N_{j}\\geq9$, $N_{b}\\geq2$";
370 metcuts = vector<TString>{
"met>350"};
372 }
else if(
method==
"agg_himult"){
373 base_s = base_all+
"met>200&&njets>=6&&nbm>=1";
374 njbcuts = vector<TString>{
"nbm>=3&&njets>=9"};
375 njbcuts_himt = njbcuts;
376 abcdcuts = abcdcuts_std;
377 method_s =
"Agg. Bin: $1\\ell$, MET200, $N_{j}\\geq9$, $N_{b}\\geq3$";
378 metcuts = vector<TString>{
"met>200"};
380 }
else if(
method==
"agg_1b"){
381 base_s = base_all+
"met>500&&njets>=6&&nbm>=1";
382 njbcuts = vector<TString>{
"nbm>=1&&njets>=9"};
383 njbcuts_himt = njbcuts;
384 abcdcuts = abcdcuts_std;
385 method_s =
"Agg. Bin: $1\\ell$, MET500, $N_{j}\\geq9$, $N_{b}\\geq1$";
386 metcuts = vector<TString>{
"met>500"};
389 cout<<
"Method "<<
method<<
" not available. Exiting"<<endl<<endl;
392 if(
method.Contains(
"2015")) method_s =
"2015 data: "+method_s;
397 vector<TableRow> bincuts;
398 for(
size_t ind(0); ind<njbcuts.size(); ind++){
399 cout<<endl<<
"New njb"<<endl;
400 for(
size_t obs(0); obs < abcdcuts.size(); obs++){
401 TString totcut(abcdcuts[obs]+
"&&"+metcuts[ind>=ilowmet]);
402 if(obs == 1) totcut += (
"&&"+njbcuts[ind]);
403 if(obs == 3) totcut += (
"&&"+njbcuts_himt[ind]);
404 cout<<base_s+
"&&"+totcut<<endl;
405 bincuts.push_back(
TableRow((base_s+
"&&"+totcut).Data(),(base_s+
"&&"+totcut).Data()));
410 pm.
Push<
Table>(
"preds", bincuts, all_procs);
416 vector<GammaParams> datayield = yield_table->
DataYield(1);
417 vector<GammaParams> otheryield;
421 vector<float> pow_pred;
422 pow_pred.push_back(-1);
423 pow_pred.push_back(1);
424 pow_pred.push_back(1);
425 vector<float> pow_tot;
426 pow_tot.push_back(-1);
427 pow_tot.push_back(1);
428 pow_tot.push_back(1);
429 pow_tot.push_back(1);
430 pow_tot.push_back(-1);
431 pow_tot.push_back(-1);
432 pow_tot.push_back(1);
439 float mSigma, pSigma, pred, pred_sys, mSigma_sys, pSigma_sys;
440 size_t nabcd(abcdcuts.size()), digits(2);
441 vector<vector<float> > preds, kappas, fractions;
442 for(
size_t ind(0); ind<njbcuts.size(); ind++){
443 bool lowjets(ind%2==0);
444 vector<vector<float> > entries;
445 vector<vector<float> > weights;
446 for(
size_t obs(0); obs < pow_pred.size(); obs++) {
447 size_t index(nabcd*ind+obs);
448 entries.push_back(vector<float>());
449 weights.push_back(vector<float>());
450 entries.back().push_back(datayield[index].Yield());
451 weights.back().push_back(1.);
455 vector<vector<float> > kn, kw;
456 float k(1.), kup(1.), kdown(1.);
457 fractions.push_back(vector<float>());
458 for(
size_t obs(0); obs < abcdcuts.size(); obs++){
459 size_t index(nabcd*ind+obs);
461 k *= pow(mcyield[index].Yield(), pow_tot[3+obs]);
462 entries.push_back(vector<float>());
463 weights.push_back(vector<float>());
464 entries.back().push_back(mcyield[index].NEffective());
465 weights.back().push_back(mcyield[index].Weight());
467 kn.push_back(vector<float>());
468 kw.push_back(vector<float>());
469 kn.back().push_back(mcyield[index].NEffective());
470 kw.back().push_back(mcyield[index].Weight());
472 k *= pow(mcyield[index].Yield()+otheryield[index].Yield(), pow_tot[3+obs]);
473 float f(otheryield[index].Yield()/(mcyield[index].Yield()+otheryield[index].Yield()));
474 fractions.back().push_back(f*100);
476 kup *= pow(mcyield[index].Yield()+exp(log(1+
syst))*otheryield[index].Yield(), pow_tot[3+obs]);
477 kdown *= pow(mcyield[index].Yield()+exp(-log(1+
syst))*otheryield[index].Yield(), pow_tot[3+obs]);
480 k =
calcKappa(kn, kw, pow_k, kdown, kup);
481 cout<<
"k = "<<k<<
" +"<<kup<<
" -"<<kdown<<endl;
484 pred =
calcKappa(entries, weights, pow_tot, mSigma, pSigma);
485 if(mSigma<0) mSigma = 0;
488 float totsys = (lowjets?0.51:1.07);
489 pred_sys =
calcKappa(entries, weights, pow_tot, mSigma_sys, pSigma_sys,
false,
false, totsys);
490 if(mSigma_sys < 0) mSigma_sys = 0;
491 preds.push_back(vector<float>({pred, pSigma, mSigma, pred_sys, pSigma_sys, mSigma_sys, k, kup, kdown}));
495 kdown = (kdown-k)/k*100;
496 kappas.push_back(vector<float>({k, kup, kdown}));
499 for(
size_t oth(0); oth<fractions[ind].size(); oth++) cout <<setw(4)<<
RoundNumber(fractions[ind][oth],1)<<
"% ";
500 cout<<
" => cuts "<<bincuts[4*ind+3].label_<<endl;
506 TString outname =
"txt/table_predictions_lumi0p815_"+
method+
".tex";
508 if(
method.Contains(
"2015")) outname.ReplaceAll(
"lumi0p815",
"lumi2p3");
509 else outname.ReplaceAll(
"lumi0p815",
"lumi2p6");
511 if(unblind) outname.ReplaceAll(
"lumi",
"unblind_lumi");
513 if(
do_other) outname.ReplaceAll(
"predictions",
"other_sys");
514 ofstream out(outname);
518 out << fixed << setprecision(digits);
519 out <<
"\\documentclass{article}\n";
520 out <<
"\\usepackage{amsmath,graphicx,rotating,geometry}\n";
521 out <<
"\\renewcommand{\\arraystretch}{1.3}\n";
522 out <<
"\\thispagestyle{empty}\n";
523 out <<
"\\begin{document}\n\n";
524 out <<
"\\begin{table}\n";
525 out <<
"\\centering\n";
528 out <<
"\\begin{tabular}[tbp!]{ l ";
529 for(
size_t ind=0; ind<Ncol-1; ind++) out<<
"c";
530 out<<
"}\\hline\\hline\n";
531 out<<
" \\multicolumn{"<<Ncol<<
"}{c}{"<<method_s<<
"} \\\\ \\hline"<<endl;
532 out<<
"${\\cal L}="<<lumi_s<<
" & $\\kappa$ & MC & Pred. & Obs. & MC/Obs & $Z_{\\rm bi}$ \\\\ \\hline\\hline\n";
533 if(
method.Contains(
"met150")) out <<
" \\multicolumn{"<<Ncol<<
"}{c}{$150<\\text{MET}\\leq 200$} \\\\ \\hline\n";
534 else if(
method.Contains(
"met500")) out <<
" \\multicolumn{"<<Ncol<<
"}{c}{$\\text{MET}> 500$} \\\\ \\hline\n";
535 else if(
method.Contains(
"met200nb1")) out <<
" \\multicolumn{"<<Ncol<<
"}{c}{$200<\\text{MET}\\leq 350, N_{b}=1$} \\\\ \\hline\n";
536 else if(
method.Contains(
"met350nb1")) out <<
" \\multicolumn{"<<Ncol<<
"}{c}{$350<\\text{MET}\\leq 500, N_{b}=1$} \\\\ \\hline\n";
537 else if(
method.Contains(
"met200nb1")) out <<
" \\multicolumn{"<<Ncol<<
"}{c}{$\\text{MET}> 500, N_{b}=1$} \\\\ \\hline\n";
538 else out <<
" \\multicolumn{"<<Ncol<<
"}{c}{$200<\\text{MET}\\leq 350$} \\\\ \\hline\n";
542 if(
method.Contains(
"nb1")) out <<
"R1: $N_b=1,\\text{all }N_j$";
543 else out <<
"R1: all $N_b,N_j$";
544 out<<
" & & "<<mcyield[index].Yield() <<
" & & " 545 << setprecision(0) <<datayield[index].Yield()<<setprecision(digits)
546 <<
" & "<<
RoundNumber(mcyield[index].Yield(), digits, datayield[index].Yield())<<
" & \\\\"<<endl;
548 for(
size_t ind(0); ind<ilowmet; ind++){
550 out<<
"R2: "<<cuts2tex(njbcuts[ind])<<
" & & "<<mcyield[index].Yield() <<
" & & " 551 << setprecision(0) <<datayield[index].Yield()<<setprecision(digits)
552 <<
" & "<<
RoundNumber(mcyield[index].Yield(), digits, datayield[index].Yield())
557 if(
method.Contains(
"nb1")) out << region_s<<
"3: $N_b=1,\\text{all }N_j$";
558 else out << region_s<<
"3: all $N_b,N_j$";
559 out <<
" & & "<<mcyield[index].Yield() <<
" & & " 560 << setprecision(0) << datayield[index].Yield() << setprecision(digits)
561 <<
" & "<<
RoundNumber(mcyield[index].Yield(), digits, datayield[index].Yield())<<
" & \\\\"<<endl;
562 out <<
"\\hline"<<endl;
564 for(
size_t ind(0); ind<ilowmet; ind++){
566 out<<region_s<<
"4: "<<cuts2tex(njbcuts_himt[ind])<<
" & $"<<preds[ind][6]
567 <<
"^{+" << preds[ind][7] <<
"}_{-" << preds[ind][8]
568 <<
"}$ & "<<mcyield[index].Yield() <<
" & $"<<preds[ind][0] <<
"^{+" << preds[ind][1]
569 <<
"}_{-" << preds[ind][2] <<
"}$ & ";
570 if(unblind) out << setprecision(0) <<datayield[index].Yield()<<setprecision(digits)
571 <<
" & "<<
RoundNumber(mcyield[index].Yield(), digits, datayield[index].Yield())
572 <<
" & "<<
Zbi(datayield[index].Yield(), preds[ind][0], preds[ind][1])<<
" \\\\"<<endl;
575 if(ilowmet<njbcuts.size()){
576 out<<
"\\hline\\hline\n ";
577 if(
method.Contains(
"met200nb1"))out<<
" \\multicolumn{"<<Ncol<<
"}{c}{$200<\\text{MET}\\leq 350, N_{b}\\geq2$} \\\\ \\hline\n";
578 else if(
method.Contains(
"met350nb1")) out <<
" \\multicolumn{"<<Ncol<<
"}{c}{$350<\\text{MET}\\leq 500, N_{b}\\geq2$} \\\\ \\hline\n";
579 else if(
method.Contains(
"met500nb1")) out <<
" \\multicolumn{"<<Ncol<<
"}{c}{$\\text{MET}> 500, N_{b}\\geq2$} \\\\ \\hline\n";
580 else out <<
" \\multicolumn{"<<Ncol<<
"}{c}{$350<\\text{MET}\\leq 500$} \\\\ \\hline\n";
582 index = nabcd*ilowmet;
583 if(
method.Contains(
"nb1")) out <<
"R1: $N_b=1,\\text{all }N_j$";
584 else out <<
"R1: all $N_b,N_j$";
585 out <<
" & & "<<mcyield[index].Yield() <<
" & & " 586 << setprecision(0) <<datayield[index].Yield()<<setprecision(digits)
587 <<
" & "<<
RoundNumber(mcyield[index].Yield(), digits, datayield[index].Yield())<<
" & \\\\"<<endl;
589 for(
size_t ind(ilowmet); ind<njbcuts.size(); ind++){
591 out<<
"R2: "<<cuts2tex(njbcuts[ind])<<
" & & "<<mcyield[index].Yield() <<
" & & " 592 << setprecision(0) <<datayield[index].Yield()<<setprecision(digits)
593 <<
" & "<<
RoundNumber(mcyield[index].Yield(), digits, datayield[index].Yield())<<
" & \\\\"<<endl;
597 index = nabcd*ilowmet+2;
598 if(
method.Contains(
"nb1")) out << region_s<<
"3: $N_b=1,\\text{all }N_j$";
599 else out << region_s<<
"3: all $N_b,N_j$";
600 out <<
" & & "<<mcyield[index].Yield() <<
" & & " 601 << setprecision(0) <<datayield[index].Yield()<<setprecision(digits)
602 <<
" & "<<
RoundNumber(mcyield[index].Yield(), digits, datayield[index].Yield())<<
" & \\\\"<<endl;
603 out <<
"\\hline"<<endl;
605 for(
size_t ind(ilowmet); ind<njbcuts.size(); ind++){
607 out<<region_s<<
"4: "<<cuts2tex(njbcuts_himt[ind])<<
" & $"<<preds[ind][6]
608 <<
"^{+" << preds[ind][7] <<
"}_{-" << preds[ind][8]
609 <<
"}$ & "<<mcyield[index].Yield() <<
" & $"<<preds[ind][0] <<
"^{+" << preds[ind][1]
610 <<
"}_{-" << preds[ind][2] <<
"}$ & ";
611 if(unblind) out<< setprecision(0) <<datayield[index].Yield() <<setprecision(digits)
612 <<
" & "<<
RoundNumber(mcyield[index].Yield(), digits, datayield[index].Yield())
613 <<
" & "<<
Zbi(datayield[index].Yield(), preds[ind][0], preds[ind][1])<<
" \\\\"<<endl;
618 out <<
"\n\\begin{tabular}[tbp!]{ l rrr |";
619 for(
size_t obs(0); obs < abcdcuts.size(); obs++) out<<
"r";
620 out <<
"}\\hline\\hline\n";
621 out <<
" & & non-$t\\bar{t}\\times"<<
RoundNumber(1+
syst,1)<<
"$ & non-$t\\bar{t}\\times" 622 <<
RoundNumber(exp(-log(1+
syst)),1)<<
"$ & \\multicolumn{4}{c}{Fraction of non-$t\\bar{t}$ bkg.} \\\\ \n";
623 out <<
"Bin & $\\kappa$ & $\\Delta\\kappa$ [\\%] & $\\Delta\\kappa$ [\\%]";
624 for(
size_t obs(0); obs < abcdcuts.size(); obs++) out<<
" & $f_{\\text{R"<<obs+1<<
"}}$ [\\%]";
625 out <<
" \\\\ \\hline\\hline\n";
626 for(
size_t ind(0); ind<njbcuts.size(); ind++){
627 out<<cuts2tex(njbcuts[ind])<<
" & "<<
RoundNumber(kappas[ind][0],2) <<
" & "<<kappas[ind][1] <<
" & "<<kappas[ind][2];
628 for(
size_t obs(0); obs < abcdcuts.size(); obs++) out<<
" & "<<fractions[ind][obs];
630 if(ind==ilowmet-1) out<<
"\\hline"<<endl;
634 out<<
"\\hline\\hline\n\\end{tabular}"<<endl;
636 out <<
"\\end{table}\n\n";
637 out <<
"\\end{document}\n";
639 TString pdfname(outname);
640 cout<<endl<<
" pdflatex "<<outname<<endl;
643 cout<<endl<<
"Calculation took "<<difftime(endtime, begtime)<<
" seconds"<<endl<<endl;
650 static struct option long_options[] = {
651 {
"method", required_argument, 0,
'm'},
652 {
"unblind", no_argument, 0,
'u'},
653 {
"full_lumi", no_argument, 0,
'f'},
659 opt = getopt_long(argc, argv,
"m:uf", long_options, &option_index);
676 printf(
"Bad option! getopt_long returned character code 0%o\n", opt);
shared_ptr< Process > Proc(const string process_name, Process::Type type, int color, const set< string > &files, const string &cut="1")
int main(int argc, char *argv[])
std::vector< GammaParams > Yield(const Process *process, double luminosity) const
void GetOptions(int argc, char *argv[])
const std::vector< std::unique_ptr< Figure > > & Figures() const
bool Contains(const std::string &str, const std::string &pat)
TString Zbi(double Nobs, double Nbkg, double Ebkg)
std::string execute(const std::string &cmd)
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
Organizes efficient production of plots with single loop over each process.
TString RoundNumber(double num, int decimals, double denom=1.)
std::vector< GammaParams > DataYield() const
void MakePlots(double luminosity, const std::string &subdir="")
Prints all added plots with given luminosity.
Loads colors from a text configuration file.