ra4_macros  bede988c286599a3a84b77a4d788ac0a971e89f9
syst_counts_v2.cxx
Go to the documentation of this file.
1 #include "syst_counts_v2.hpp"
2 
3 #include <cstdlib>
4 
5 #include <fstream>
6 #include <iostream>
7 #include <iomanip>
8 #include <vector>
9 #include <string>
10 #include "TTreeFormula.h"
11 #include "TGraphErrors.h"
12 #include "TH1F.h"
13 #include "TLegend.h"
14 #include "TLine.h"
15 #include "TLatex.h"
16 #include "TCanvas.h"
17 #include "TMath.h"
18 #include "styles.hpp"
19 #include "small_tree_quick.hpp"
20 #include "utilities.hpp"
21 #include "utilities_macros.hpp"
22 #include "timer.hpp"
23 
24 namespace ra4 {
25  std::string ntuple_date("2015_06_05");
26  int minjets(6);
27  double midjets(8);
28  double mjthresh(400.);
29  TString luminosity="10";
30 }
31 
32 using namespace ra4;
33 using namespace std;
34 
35 int main(int argc, char *argv[]){
36  //bool include_signal = false; //Include signal when mocking up data from MC?
37  //cout<<ntuple_date<<endl;
38  string folder_other="/net/cms5/cms5r0/ald77/archive/"+ntuple_date+"/skim/";
39  //string folder = "/cms7r0/heller/code/susy_cfa/out/";
40  //string folder = "/net/cms2/cms2r0/manuelf/root/archive/15-06-01/skim/";
41  string folder = "/net/cms29/cms29r0/heller/ra4_macros/rohanskim/";
42  double lumi = 10.;
43  string lumi_string = "10";
44  bool compressed = false;
45  if(argc>1){
46  lumi = strtod(argv[1], NULL);
47  lumi_string = argv[1];
48  if(argc>2 && string("1200")==argv[2]) compressed = true;
49  }
50  if(lumi <= 0.0){
51  lumi = 10.;
52  lumi_string = "10";
53  }
54 
55 
56  small_tree_quick ttbar(folder+"*TTJets*");
57  small_tree_quick other(folder_other+"*QCD_Pt*");
58  other.Add(folder_other+"*TTWJets*");
59  other.Add(folder_other+"*TTZJets*");
60  other.Add(folder_other+"*_T*-channel*");
61  other.Add(folder_other+"*WJetsToLNu_HT*");
62  other.Add(folder_other+"*ZJetsToLNu_HT*");
63  other.Add(folder_other+"*DYJets*");
64  other.Add(folder_other+"*H_HToBB*");
65  small_tree_quick sig(compressed ? folder_other+"*T1tttt*1200*800*" : folder_other+"*T1tttt*1500*100*");
66 
67  //Method2
68  vector< vector<TString> > bins_by_region2;
69  //TString method = "method2";
70  vector<TString> region1;
71  region1.push_back("met<=400");
72  region1.push_back("met>400");
73 
74  vector<TString> region2;
75  region2.push_back("njets<=8&&met<=400");
76  region2.push_back("njets<=8&&met>400");
77  region2.push_back("njets>8&&met<=400");
78  region2.push_back("njets>8&&met>400");
79 
80  vector<TString> region3;
81  //region3.push_back("njets<=8&&met<=400"); //testing FindSuperbin
82  //region3.push_back("njets>8&&met<=400");
83  region3.push_back("met<=400");
84  region3.push_back("met>400");
85 
86  vector<TString> region4;
87  region4.push_back("njets<=8&&met<=400");
88  region4.push_back("njets<=8&&met>400");
89  region4.push_back("njets>8&&met<=400");
90  region4.push_back("njets>8&&met>400");
91 
92  bins_by_region2.push_back(region1);
93  bins_by_region2.push_back(region2);
94  bins_by_region2.push_back(region3);
95  bins_by_region2.push_back(region4);
96 
97 
98  //Method 1
99  vector< vector<TString> > bins_by_region1;
100  vector<TString> method1_region;
101  method1_region.push_back("njets<=8&&met<=400");
102  method1_region.push_back("njets<=8&&met>400");
103  method1_region.push_back("njets>8&&met<=400");
104  method1_region.push_back("njets>8&&met>400");
105 
106  bins_by_region1.push_back(method1_region);
107  bins_by_region1.push_back(method1_region);
108  bins_by_region1.push_back(method1_region);
109  bins_by_region1.push_back(method1_region);
110 
111  TString baseline = "njets>=7&&nbm>=1&&(nels+nmus)==1";
112  TString dilepton = "njets>=6&&nbm>=1&&(nels+nmus)==2";
113  //GetCounts will automatically implement object counting instead of jet counting
114  // it does this by replacing "8&&" with "7&&" for dileptons. So never end another cut with 8!
115 
116  vector< vector<TString> > bins_by_region = bins_by_region1;
117  TString method = "method2";
118  // TString sysname = "nISR";
119  vector< TString> sysnames;
120  sysnames.push_back("nominal");
121  sysnames.push_back("nISR");
122  sysnames.push_back("ISRpT");
123  sysnames.push_back("ISRpTx150");
124  sysnames.push_back("toppT");
125  sysnames.push_back("1lep_frac");
126 
127 
128 
129  int nsys= static_cast<int>(sysnames.size());
130 
131 
132  vector< vector< vector<double> > > ttbar_counts, ttbar_errors; //first dimension indicates region 1 through 4. second dimension gets counts for binning in that region (binning is allowed to be different in each region), third dimension is for all variations on reweighting
133  vector< vector< vector<double> > > ttbar_counts_dilep, ttbar_errors_dilep;
134  vector< vector< vector<double> > > other_counts, other_errors;
135  vector< vector< vector<double> > > other_counts_dilep, other_errors_dilep;
136  vector< vector< vector<double> > > sig_counts, sig_errors;
137  // cout<<"about to get counts"<<endl;
138  vector<int> emptysamples;
139  vector<hfeats> hists, emptyhists;
140 
141  vector< vector<TH1F*> > h, h_dilep,emptyh;
142  //first dim is hists, second dimension is variation
143 
144 
145  hists.push_back(hfeats("ISRpT",20,0,1000, emptysamples, "ISR pT","ht>500")); //must be first right now due to hack
146  hists.push_back(hfeats("ntrumeisr",4,-0.5,3.5, emptysamples, "n ME ISR","ht>500"));
147  hists.push_back(hfeats("mj",20,0,1000, emptysamples, "M_{J} [GeV]","mt>140"));
148  hists.push_back(hfeats("mj",20,0,1000, emptysamples, "M_{J} [GeV]","mt<=140"));
149  hists.push_back(hfeats("mj",10,0,1000, emptysamples, "M_{J} [GeV]","mt>140&&met>400"));
150  hists.push_back(hfeats("mj",10,0,1000, emptysamples, "M_{J} [GeV]","mt<=140&&met>400"));
151 
152  hists.push_back(hfeats("met",30,0,600, emptysamples, "MET [GeV]","ht>500"));
153  hists.push_back(hfeats("mt",20,0,280, emptysamples, "m_{T} [GeV]","ht>500"));
154  hists.push_back(hfeats("mt",2,0,280, emptysamples, "m_{T} [GeV]","met>200"));
155  hists.push_back(hfeats("mt",20,0,280, emptysamples, "m_{T} [GeV]","mj>400"));
156  hists.push_back(hfeats("mt",2,0,280, emptysamples, "m_{T} [GeV]","mj>400&&met>200"));
157  hists.push_back(hfeats("mt",2,0,280, emptysamples, "m_{T} [GeV]","ntruleps==1"));
158  hists.push_back(hfeats("trutop1_pt",25,0,800, emptysamples, "top pT [GeV]","ht>500"));
159  hists.push_back(hfeats("trutop1_pt+trutop2_pt",32,0,1600, emptysamples, "top pT + antitop pT [GeV]","ht>500"));
160 
161 
162  int nhists = static_cast<int>(hists.size());
163  //hists.push_back(hfeats("mt",20,0,280, emptysamples, "mT [GeV]","ht>500"));
164 
165  GetCounts(lumi,sysnames, method, baseline, ttbar, ttbar_counts, ttbar_errors, bins_by_region, hists, h);
166  GetCounts(lumi,sysnames, method, dilepton, ttbar, ttbar_counts_dilep, ttbar_errors_dilep, bins_by_region, hists, h_dilep);
167  if(false) cout << sig.GetEntries() << endl;
168 
169  vector< TString> othersys;
170  for(int i=0;i<nsys; i++){
171  othersys.push_back("nominal");
172  }
173 
174  GetCounts(lumi,othersys, method, baseline, other, other_counts, other_errors, bins_by_region, emptyhists, emptyh);
175  GetCounts(lumi,othersys, method, dilepton, other, other_counts_dilep, other_errors_dilep, bins_by_region, emptyhists, emptyh);
176 
177  cout<<"got counts"<<endl;
178  //Replace vacant "low mT" regions with single-reco lepton counts
179  ttbar_counts_dilep.at(0) = ttbar_counts.at(0);
180  ttbar_counts_dilep.at(1) = ttbar_counts.at(1);
181  ttbar_errors_dilep.at(0) = ttbar_errors.at(0);
182  ttbar_errors_dilep.at(1) = ttbar_errors.at(1);
183  /*for(int is=0;is<nsys;is++){
184  ttbar_counts_dilep.at(is) = ttbar_counts.at(is);
185  ttbar_errors_dilep.at(is) = ttbar_errors.at(is);
186 
187  }*/
188 
189 
190 
191 
192 
193  vector< vector<double> > delkappas(nsys,vector<double>(4,0.0));
194  vector< vector<double> > delkappas_dilep(nsys,vector<double>(4,0.0));
195  cout<<"initialized delkappas"<<endl;
196  // MakePlots(sysname,baseline,ttbar_counts, ttbar_errors, bins_by_region, method, delkappas);
197  // MakePlots(sysname,dilepton,ttbar_counts_dilep, ttbar_errors_dilep, bins_by_region, method+"_dilep",delkappas_dilep);
198 
199  vector<int> RMJ_nums; RMJ_nums.push_back(3); RMJ_nums.push_back(1);
200  vector<int> RMJ_dens; RMJ_dens.push_back(2); RMJ_dens.push_back(0);
201  vector<int> RmT_nums; RmT_nums.push_back(3); RmT_nums.push_back(2);
202  vector<int> RmT_dens; RmT_dens.push_back(1); RmT_dens.push_back(0);
203  cout<<"making plots"<<endl;
204  for(int is=1;is<nsys; is++){
205  cout<<"is = "<<is<<endl;
206  MakePlots("R_{MJ}", RMJ_nums, RMJ_dens, ttbar_counts, ttbar_errors, bins_by_region, baseline, method, sysnames,is,delkappas[is]);
207  MakePlots("R_{mT}", RmT_nums, RmT_dens, ttbar_counts, ttbar_errors, bins_by_region, baseline, method, sysnames,is,delkappas[is]);
208  MakePlots("R_{MJ}", RMJ_nums, RMJ_dens, ttbar_counts_dilep, ttbar_errors_dilep, bins_by_region, dilepton, method, sysnames,is,delkappas_dilep[is]);
209  MakePlots("R_{mT}", RmT_nums, RmT_dens, ttbar_counts_dilep, ttbar_errors_dilep, bins_by_region, dilepton, method, sysnames,is,delkappas_dilep[is]);
210  }
211 
212  PrintTable(method,ttbar_counts,ttbar_errors,ttbar_counts_dilep, other_counts, other_counts_dilep, delkappas, bins_by_region);
213 
214  for(int ihist=0;ihist<nhists;ihist++){
215  if(ihist==2 || ihist==3 || ihist==4 || ihist==5) continue;
216  for(int isy=1;isy<nsys; isy++){
217  vector<TH1F*> temp;
218  temp.push_back(static_cast<TH1F*>(h[ihist][0]->Clone(Form("%i_%i",isy,ihist)))); //nominal
219  temp.push_back(h[ihist][isy]); //varied
220  OverlayHists(temp,hists[ihist],method,sysnames[isy],baseline);
221  }
222  }
223 
224  for(int isy=1;isy<nsys; isy++){
225  vector<TH1F*> temp;
226  temp.push_back(static_cast<TH1F*>(h[2][0]->Clone(Form("%i_%i",isy,2)))); //high mT nominal
227  temp.push_back(h[2][isy]); //high mT varied
228  temp.push_back(static_cast<TH1F*>(h[3][0]->Clone(Form("%i_%i",isy,3)))); //low mT nominal
229  temp.push_back(h[3][isy]); //low mt varied
230  OverlayHistsmT(temp,hists[2],method,sysnames[isy],baseline);
231  }
232 
233  for(int isy=1;isy<nsys; isy++){
234  vector<TH1F*> temp;
235  temp.push_back(static_cast<TH1F*>(h[4][0]->Clone(Form("%i_%i",isy,4)))); //high mT nominal
236  temp.push_back(h[4][isy]); //high mT varied
237  temp.push_back(static_cast<TH1F*>(h[5][0]->Clone(Form("%i_%i",isy,5)))); //low mT nominal
238  temp.push_back(h[5][isy]); //low mt varied
239  OverlayHistsmT(temp,hists[4],method,sysnames[isy],baseline);
240  }
241 
242 
243 }
244 
245 
246 
247 void PrintTable(TString method, vector< vector< vector<double> > > ttbar_counts, vector< vector< vector<double> > > ttbar_errors, vector< vector< vector<double> > > ttbar_counts_dilep, vector< vector< vector<double> > > other_counts,vector< vector< vector<double> > > other_counts_dilep, vector< vector<double> > delkappas, vector< vector<TString> > bins_by_region){
248  ofstream file("txt/newtable_1b_"+method+".csv");
249  for(unsigned int ibin=0;ibin<bins_by_region.at(3).size(); ibin++){
250  int bin2 = FindSuperBin(bins_by_region.at(3).at(ibin),bins_by_region.at(2));
251  int bin1 = FindSuperBin(bins_by_region.at(3).at(ibin),bins_by_region.at(1));
252  int bin0 = FindSuperBin(bins_by_region.at(3).at(ibin),bins_by_region.at(0));
253 
254  double statabcd = sqrt(1.0/(other_counts.at(0).at(bin0).at(0)+ttbar_counts.at(0).at(bin0).at(0)) + 1.0/(other_counts.at(1).at(bin1).at(0)+ttbar_counts.at(1).at(bin1).at(0)) + 1.0/(other_counts.at(2).at(bin2).at(0)+ttbar_counts.at(2).at(bin2).at(0)));
255  double mcstat = sqrt(sqr(ttbar_errors.at(3).at(ibin).at(0)/ttbar_counts.at(3).at(ibin).at(0))+sqr(ttbar_errors.at(0).at(bin0).at(0)/ttbar_counts.at(0).at(bin0).at(0)) + sqr(ttbar_errors.at(1).at(bin1).at(0)/ttbar_counts.at(1).at(bin1).at(0)) + sqr(ttbar_errors.at(2).at(bin2).at(0)/ttbar_counts.at(2).at(bin2).at(0)));
256  double closure = sqrt(1.0/(other_counts_dilep.at(3).at(ibin).at(0)+ ttbar_counts_dilep.at(3).at(ibin).at(0)));
257 
258  file << bins_by_region.at(3).at(ibin) <<","<< (other_counts.at(3).at(ibin).at(0)+ttbar_counts.at(3).at(ibin).at(0))<<","<<sqr(1.0/closure)<<","<<closure<<","<<statabcd<<","<<mcstat;
259  for(unsigned int is=1; is< delkappas.size();is++){
260  file <<"," <<delkappas.at(is).at(ibin);
261  }
262  file<<"\n";
263  }
264 
265 
266 }
267 
268 double GetWeight(small_tree_quick &tree, TString sysname, int ivar){
269  if(ivar==0) return 1.;
270  if(sysname.Contains("not_ttbar") )return 1.;
271  if(sysname.Contains("nominal") ) return 1.;
272  if(sysname.Contains("Nominal") ) return 1.;
273  double weight(1.0);
274 
275  if(sysname.Contains("1lep_frac")){
276  if(tree.ntruleps()==1 && tree.mt()>140){
277  weight = 2.0;
278  }
279  }
280 
281  if(sysname.Contains("toppT")){
282  //8 TeV Form
283  float t1pT,t2pT;
284  //if(tree.trutop1_pt()>600) t1pT=600;
285  //if(tree.trutop1_pt()<200) t1pT=200;
286  t1pT=tree.trutop1_pt();
287 
288  //if(tree.trutop2_pt()>600) t2pT=600;
289  // if(tree.trutop2_pt()<200) t2pT=200;
290  t2pT=tree.trutop2_pt();
291  float weight_top1pT = TMath::Exp(0.156-0.00137*t1pT);
292  float weight_top2pT = TMath::Exp(0.156-0.00137*t2pT);
293  weight = TMath::Sqrt(weight_top1pT*weight_top2pT);
294  }
295 
296  if(sysname.Contains("nISR")){
297  if(tree.ntrumeisr()>3) {cout<<"ERROR: n ISR = "<<tree.ntrumeisr()<<endl; weight = 1.0;}
298  else if(tree.ntrumeisr()==3) weight = 1.5;
299  else if(tree.ntrumeisr()==2) weight = 1.25;
300  else if(tree.ntrumeisr()==1) weight = 1.0;
301  else weight = 0.75;
302  }
303 
304  /* if(sysname.Contains("ISRpT")){
305  float ISRpT=0;
306  float ISRpx = tree.trutop1_pt()*TMath::Cos(tree.trutop1_phi()) + tree.trutop2_pt()*TMath::Cos(tree.trutop2_phi());
307  float ISRpy = tree.trutop1_pt()*TMath::Sin(tree.trutop1_phi()) + tree.trutop2_pt()*TMath::Sin(tree.trutop2_phi());
308  ISRpT = TMath::Sqrt(ISRpx*ISRpx+ISRpy*ISRpy);
309 
310  if( ISRpT>500) weight = 0.6;
311  else if( ISRpT>300 ) weight = 0.8;
312  else if( ISRpT>240 ) weight = 0.9;
313  else if( ISRpT>120) weight = 0.95;
314  else weight = 1.0;
315  }*/
316 
317 
318  if(sysname.Contains("ISRpT")){
319  float ISRpT=0;
320  float ISRpx = tree.trutop1_pt()*TMath::Cos(tree.trutop1_phi()) + tree.trutop2_pt()*TMath::Cos(tree.trutop2_phi());
321  float ISRpy = tree.trutop1_pt()*TMath::Sin(tree.trutop1_phi()) + tree.trutop2_pt()*TMath::Sin(tree.trutop2_phi());
322  ISRpT = TMath::Sqrt(ISRpx*ISRpx+ISRpy*ISRpy);
323 
324  if( ISRpT>800) weight = 0.2;
325  else if( ISRpT>650) weight = 0.4;
326  else if( ISRpT>500) weight = 0.6;
327  else if( ISRpT>300 ) weight = 0.8;
328  else if( ISRpT>200 ) weight = 0.9;
329  else if( ISRpT>120) weight = 0.95;
330  else weight = 1.0;
331  }
332 
333 
334  if(sysname.Contains("ISRpTx150")){
335  float ISRpT=0;
336  float ISRpx = tree.trutop1_pt()*TMath::Cos(tree.trutop1_phi()) + tree.trutop2_pt()*TMath::Cos(tree.trutop2_phi());
337  float ISRpy = tree.trutop1_pt()*TMath::Sin(tree.trutop1_phi()) + tree.trutop2_pt()*TMath::Sin(tree.trutop2_phi());
338  ISRpT = TMath::Sqrt(ISRpx*ISRpx+ISRpy*ISRpy);
339 
340  if( ISRpT>800) weight = 0.;
341  else if( ISRpT>650) weight = 0.1;
342  else if( ISRpT>500) weight = 0.4;
343  else if( ISRpT>300 ) weight = 0.7;
344  else if( ISRpT>200 ) weight = 0.85;
345  else if( ISRpT>120) weight = 0.925;
346  else weight = 1.0;
347  }
348 
349 
350 
351 
352  return weight;
353 }
354 
355 void GetCounts(double lumi, vector<TString> sysnames, TString method, TString baseline,
356  small_tree_quick &tree,
357  vector< vector< vector<double> > > &finalcounts,
358  vector< vector< vector<double> > > &errors, vector< vector<TString> > bins_by_region, vector<hfeats> hists, vector< vector<TH1F*> > &h){
359 
360  int nvar=sysnames.size();
361  //replace jet thresholds with 7 instead of 8 for dileptons
362  if(baseline.Contains("(nels+nmus)==2")){
363  for(unsigned int ir=0;ir<bins_by_region.size(); ir++){
364  for(unsigned int ib=0; ib<bins_by_region[ir].size(); ib++){
365  bins_by_region[ir][ib].ReplaceAll("8&&","7&&");
366  }
367  }
368  }
369 
370 
371  //initialize hists
372  if(hists.size()>0){
373  h.resize(0);
374 
375  for(unsigned int ihist=0;ihist<hists.size();ihist++){
376  vector<TH1F*> temp;
377  for(int is=0;is<nvar;is++){
378  TH1F * h1 = new TH1F(hists[ihist].varname+"_"+sysnames[is]+baseline+"_"+Form("%i",ihist),baseline+"&&"+hists[ihist].cuts,hists[ihist].nbins,hists[ihist].minx,hists[ihist].maxx);
379  h1->Sumw2();
380  temp.push_back(h1);
381  }
382  h.push_back(temp);
383 
384  }
385  }
386  vector< vector< vector<double> > > counts; //= vector< vector< vector<double> > >(4, vector< vector<double> >());
387 
388  for(int ireg=0;ireg<4;ireg++){
389  counts.push_back(vector<vector<double> >(bins_by_region.at(ireg).size(),vector<double>(nvar,0.)));
390  }
391  vector< vector< vector<double> > > squares = counts;
392  finalcounts = counts;
393  errors = counts;
394 
395  double sumw = 0., sumw2 = 0.; //for entire tree, to assign weights for unfilled bins
396 
397  int num_entries = tree.GetEntries();
398  // num_entries=1000;
399  Timer timer(num_entries, 1.);
400  timer.Start();
401  //cout<<"starting loop"<<endl;
402  for(int entry = 0; entry < num_entries; ++entry){
403  tree.GetEntry(entry);
404  timer.Iterate();
405 
406  if(//tree.nbm()<2
407  tree.njets()<minjets
408  //|| (tree.nmus()+tree.nels())!=1
409  || tree.met()<=200.
410  // || tree.ntks_chg_mini()>0
411  || tree.ht()<=500.) continue; //Faster to check this way than using baseline string
412 
413  if(!tree.PassString(baseline)) continue;
414 
415  double weight = lumi*tree.weight();
416  double varweight(0);
417  float ISRpT(0); float ISRpx(0); float ISRpy(0);
418  if(hists.size()>0){
419  ISRpx = tree.trutop1_pt()*TMath::Cos(tree.trutop1_phi()) + tree.trutop2_pt()*TMath::Cos(tree.trutop2_phi());
420  ISRpy = tree.trutop1_pt()*TMath::Sin(tree.trutop1_phi()) + tree.trutop2_pt()*TMath::Sin(tree.trutop2_phi());
421  ISRpT = TMath::Sqrt(ISRpx*ISRpx+ISRpy*ISRpy);
422  if(ISRpT > hists[0].maxx) ISRpT = hists[0].maxx - 0.01;
423  if(ISRpT < hists[0].minx) ISRpT = hists[0].minx + 0.01;
424  }
425 
426  // cout<<"passed baseline"<<endl;
427  int region = LookUpRegion(tree,method);
428  if(region>-1){
429  int bin = LookUpBin(tree,region,bins_by_region);
430  if(bin>-1){
431  //fill first element with nominal counts
432 
433  for(int ivar=0; ivar<nvar; ivar++){
434 
435  varweight = weight*GetWeight(tree,sysnames.at(ivar), ivar);
436  counts.at(region).at(bin).at(ivar) += varweight;
437  squares.at(region).at(bin).at(ivar) += varweight*varweight;
438 
439  //fill hists
440 
441  //first, hack to fill ISR pT which cannot be done in string yet
442 
443  if(hists.size()>0){
444  h[0][ivar]->Fill(ISRpT,varweight);
445  }
446  for(unsigned int ih=1;ih < hists.size();ih++){
447  if(tree.PassString(hists[ih].cuts)){
448  float val = tree.GetBranchValue(hists[ih].varname);
449  //overflow handling.. yes i know this ruins the mean
450  if(val > hists[ih].maxx) val = hists[ih].maxx - 0.01;
451  if(val < hists[ih].minx) val = hists[ih].minx + 0.01;
452  h[ih][ivar]->Fill(val,varweight);
453  // h[ih][1]->Fill(val,varweight);
454  }
455  }
456  }
457  }
458  }
459  sumw += weight;
460  sumw2 += weight*weight;
461 
462 
463 
464  }
465 
466  for(unsigned int ireg = 0; ireg< counts.size(); ireg++){
467  for(unsigned int ibin = 0; ibin < counts.at(ireg).size(); ++ibin){
468  for( int ifill = 0; ifill< nvar; ifill++){
469  //Hack to "add one single lepton event
470  if(sysnames[ifill].Contains("1lep_frac") && ireg==3&&ibin==3){ counts.at(ireg).at(ibin).at(ifill) += sumw2/sumw; squares.at(ireg).at(ibin).at(ifill) += sqr(sumw2/sumw); }
471 
472  if(squares.at(ireg).at(ibin).at(ifill) == 0.){
473  //Never filled
474  finalcounts.at(ireg).at(ibin).at(ifill) = 0;
475  errors.at(ireg).at(ibin).at(ifill) = sumw2/sumw; //assign average weight as error?
476  }else if(counts.at(ireg).at(ibin).at(ifill) <= 0.){
477  //Negative estimate
478  finalcounts.at(ireg).at(ibin).at(ifill) = 0;
479  errors.at(ireg).at(ibin).at(ifill) = sqrt(squares.at(ireg).at(ibin).at(ifill)+sqr(counts.at(ireg).at(ibin).at(ifill)));
480  //sqrt(squares.at(ireg).at(ibin).at(ifill)+sqr(counts.at(ireg).at(ibin).at(ifill))); //assign average weight as error?
481  }else{
482  //Normal case
483  finalcounts.at(ireg).at(ibin).at(ifill) = counts.at(ireg).at(ibin).at(ifill);//sqr(counts.at(ireg).at(ibin).at(ifill))/squares.at(ireg).at(ibin).at(ifill);
484  errors.at(ireg).at(ibin).at(ifill) = sqrt(squares.at(ireg).at(ibin).at(ifill));
485  // weight: squares.at(ireg).at(ibin).at(ifill)/counts.at(ireg).at(ibin).at(ifill);
486  }
487  }
488  }
489  }
490 
491 }
492 
493 
494 
495 void OverlayHists(vector<TH1F*> h, hfeats hist, TString method, TString sysname, TString baseline){
496  TString pname = "plots/systematics/1d/"+format_tag(hist.varname+baseline+hist.cuts+"_"+method+"_"+sysname)+".pdf";
497  if(sysname=="toppT") sysname = "top p_{T}";
498 
499  styles style("RA4"); style.setDefaultStyle();
500  TCanvas can;
501  float max(0.0);
502  for(unsigned int ih=0;ih < h.size();ih++){
503  if(h[ih]->GetMaximum() > max) max = h[ih]->GetMaximum();
504  }
505  double legX = 0.6, legY = 0.89, legSingle = 0.17;
506  double legW = 0.22, legH = legSingle;
507  TLegend leg(legX, legY-legH, legX+legW, legY);
508  leg.SetTextSize(0.057); leg.SetFillColor(0); leg.SetFillStyle(0); leg.SetBorderSize(0);
509  leg.SetTextFont(132);
510 
511  for(unsigned int ih=0;ih < h.size();ih++){
512  h[ih]->GetXaxis()->SetLabelSize(0.05);
513  h[ih]->GetYaxis()->SetLabelSize(0.05);
514  h[ih]->GetXaxis()->SetTitle(cuts2title(hist.title));
515  h[ih]->GetXaxis()->SetTitleOffset(1.15);
516  h[ih]->GetXaxis()->SetTitleSize(0.06);
517  h[ih]->GetXaxis()->SetTitle(cuts2title(hist.title));
518  h[ih]->GetYaxis()->SetTitle("Entries for 3 fb^{-1}");
519  //h[ih]->GetYaxis()->SetTitleOffset(2);
520  h[ih]->GetYaxis()->SetTitleSize(0.06);
521  h[ih]->SetLineWidth(3);
522  h[ih]->SetMaximum(1.35*max);
523  h[ih]->SetTitle(cuts2title(baseline));
524  if(ih==1) h[ih]->SetLineColor(kRed);
525  else h[ih]->SetLineColor(kBlack);
526 
527  if(ih==0) leg.AddEntry(h[ih],"Nominal t#bar{t}","l");
528  if(ih==1) leg.AddEntry(h[ih],sysname+" Variation","l");
529 
530 
531  if(ih==0) h[ih]->Draw("hist");
532  else h[ih]->Draw("hist same");
533 
534  }
535  leg.Draw("same");
536  // TString pname = "plots/systematics/1d/"+format_tag(hist.varname+baseline+hist.cuts+"_"+method+"_"+sysname)+".pdf";
537  can.SaveAs(pname);
538 
539 
540  }
541 
542 
543 void OverlayHistsmT(vector<TH1F*> h, hfeats hist, TString method, TString sysname, TString baseline){
544  TString pname = "plots/systematics/1d/mt_"+format_tag(hist.varname+baseline+hist.cuts+"_"+method+"_"+sysname)+".pdf";
545  if(sysname=="toppT") sysname = "top p_{T}";
546  styles style("RA4"); style.setDefaultStyle();
547  TCanvas can;
548  float max(0);
549 
550  for(unsigned int ih=0;ih < h.size();ih++){
551  float integral = h[ih]->Integral();
552  if(integral>0.0001) h[ih]->Scale(100./integral);
553  if(h[ih]->GetMaximum() > max) max = h[ih]->GetMaximum();
554  // cout<<"Hist Name "<<h[ih]->GetName()<<endl;
555  // cout<<"integral for this hist: "<<h[ih]->Integral()<<" float integral = "<<integral<<" Maximum and max: "<< h[ih]->GetMaximum()<<" "<<max<<endl;
556  }
557 
558  double legX = 0.45, legY = 0.89, legSingle = 0.25;
559  double legW = 0.22, legH = legSingle;
560  TLegend leg(legX, legY-legH, legX+legW, legY);
561  leg.SetTextSize(0.057); leg.SetFillColor(0); leg.SetFillStyle(0); leg.SetBorderSize(0);
562  leg.SetTextFont(132);
563 
564  // TString titles = {"High mT ttbar Nominal"};
565  for(unsigned int ih=0;ih < h.size();ih++){
566 
567  h[ih]->GetXaxis()->SetLabelSize(0.05);
568  h[ih]->GetYaxis()->SetLabelSize(0.05);
569  h[ih]->GetXaxis()->SetTitle(cuts2title(hist.title));
570  h[ih]->GetXaxis()->SetTitleOffset(1.15);
571  h[ih]->GetXaxis()->SetTitleSize(0.06);
572  h[ih]->GetYaxis()->SetTitle(cuts2title(hist.title));
573  //h[ih]->GetYaxis()->SetTitleOffset(2);
574  h[ih]->GetYaxis()->SetTitleSize(0.06);
575  h[ih]->SetLineWidth(3);
576  h[ih]->SetMaximum(1.5*max);
577  TString title = static_cast<TString>(h[ih]->GetTitle());
578  if(title.Contains("mt>140") || ih==0 || ih==1) h[ih]->SetLineColor(kRed);
579  else h[ih]->SetLineColor(9);
580 
581  title.ReplaceAll("&&mt>140",""); title.ReplaceAll("&&mt<=140","");
582  h[ih]->SetTitle(cuts2title(title));
583  if(ih==1 || ih==3) h[ih]->SetLineStyle(2);
584 
585  h[ih]->GetYaxis()->SetTitle("Entries (%)");
586  TString lege;
587  if(ih<2) lege="High m_{T} t#bar{t}, ";
588  else lege= "Low m_{T} t#bar{t}, ";
589 
590  if(ih==1 || ih ==3) {lege+= sysname;
591  lege+= " variation";}
592  else lege+= "nominal";
593 
594 
595  leg.AddEntry(h[ih], lege,"l");
596  if(ih==0) h[ih]->Draw("hist");
597  else h[ih]->Draw("hist same");
598 
599  }
600  leg.Draw("same");
601  // TString pname = "plots/systematics/1d/mt_"+format_tag(hist.varname+baseline+hist.cuts+"_"+method+"_"+sysname)+".pdf";
602  can.SaveAs(pname);
603 
604 
605  }
606 
607 
608 int FindSuperBin(TString cut, vector<TString> other_region){
609  //Find bin in region 1-3 to make relevant kappa for region 4 bin defined by "cut"
610  //The correct control region bin has a SUBSET OF THE CUTS in the signal bin (superset of events)
611  //In some cases, there may be no bin with a strict subset of cuts (for example, if the control regions use met<400 to kill contamination).
612  //In this case, use the bin nearest to being a subset (fewest number of extra cuts)
613 
614 
615  vector<int> score(other_region.size(),0);
616  int min_score=9999; int min_bin=-1;
617 
618  for(unsigned int ibin=0;ibin<score.size();ibin++){
619  TObjArray * this_bin_tokens = other_region.at(ibin).Tokenize("&&");
620  TIter this_bin_iter(this_bin_tokens);
621  TObjString* os=0;
622  while ((os=static_cast<TObjString *>(this_bin_iter()))) {
623  if(!cut.Contains(os->GetString())) score.at(ibin)++;
624  }
625  this_bin_tokens->Delete();
626  if(score.at(ibin)<min_score){min_score=score.at(ibin); min_bin=ibin;}
627  }
628  cout<<"Signal cut: "<<cut<<", Closest match: "<<other_region.at(min_bin)<<", Score: "<<min_score<<endl;
629  return min_bin;
630 }
631 
632 
633 
635  double mt_thresh = 140.;
636  double mj_thresh = mjthresh;
637  if(method.Contains("method1")) mj_thresh+=200;
638  //double njets_thresh = midjets;
639  //doublemet_thresh = 400.;
640  //double nbm_thresh = 2.5;
641  int reg = -1;
642  if(tree.mt()<=mt_thresh && (tree.nmus()+tree.nels())==1){
643  if(tree.mj()<=mj_thresh) reg=0;
644  else reg = 1;
645  }
646  else{
647  if(tree.mj()<=mj_thresh) reg=2;
648  else reg=3;
649 
650  }
651  return reg;
652 
653 }
654 
655 int LookUpBin(small_tree_quick &tree, int region, vector< vector<TString> > bins_by_region){
656  int bin = -1;
657  for(unsigned int ibin=0;ibin<bins_by_region.at(region).size();ibin++){
658 
659  if(tree.PassString(bins_by_region.at(region).at(ibin))) {
660  if(bin!= -1) {cout<<"non-orthogonal bins"<<endl;}
661  bin = ibin;
662  }
663 
664  }
665  return bin;
666 
667 }
668 
669 
670 
671 void MakePlots(TString axisname, vector<int> numerator_regions, vector<int> denominator_regions, vector< vector< vector<double> > > counts,
672  vector< vector< vector<double> > > errors, vector< vector<TString> > bins_by_region, TString baseline, TString method, vector<TString> sysnames,int sysnum, vector<double> &delkappas ){
673 
674  //Make list of pairs (Region, Bin) for seamless iteration over all points at once, without worrying about region boundaries
675  TString sysname = sysnames.at(sysnum);
676  vector<int> sysindices;
677  sysindices.push_back(0);
678  sysindices.push_back(sysnum);
679  vector< vector<int> > nums_reg_bin;
680  vector< vector<int> > dens_reg_bin;
681  cout<<"Make Plots: sysnum, syname = "<<sysnum<<" "<<sysname<<endl;
682  //Make kappa for simplest case: when same number in both numerator regions
683  bool make_kappa=false;
684  if(bins_by_region.at(numerator_regions.at(0)).size() ==bins_by_region.at(numerator_regions.at(1)).size()) make_kappa=true;
685 
686  for(unsigned int inum=0;inum<numerator_regions.size(); inum++){ //iterate over numerator regions
687  for(unsigned int ibin=0; ibin< bins_by_region.at(numerator_regions.at(inum)).size(); ibin++){ //iterate over bins within numerator region
688  vector<int> num;
689  num.push_back(numerator_regions.at(inum)); //numerator region
690  num.push_back(ibin); //numerator bin
691  nums_reg_bin.push_back(num);
692 
693  vector<int> den;
694  den.push_back(denominator_regions.at(inum)); //denominator region (Always corresponds 1-1 with numerator region)
695  int denbin = FindSuperBin(bins_by_region.at(numerator_regions.at(inum)).at(ibin),bins_by_region.at(denominator_regions.at(inum))); // find denominator bin (does NOT always correspond 1-1 with numerator bin)
696  if(denbin<0) cout<<"failed to find denominator bin"<<endl;
697  den.push_back(denbin);
698  dens_reg_bin.push_back(den);
699  }
700  }
701 
702  int npoints = static_cast<int>(nums_reg_bin.size());
703  vector<TGraphErrors*> g_Rs;
704  vector<TGraphErrors*> g_kappas;
705  int npoints_kappa = static_cast<int>(bins_by_region.at(numerator_regions.at(0)).size());
706  float maxkappa=0.;
707  float max=0.;
708  for(unsigned int is=0;is<sysindices.size();is++){
709  int isys = sysindices.at(is);
710  //initialize all values to go into TGraph
711  vector<double> R(npoints,0.);
712  vector<double> eR(npoints,0.);
713  vector<double> x(npoints,0.);
714  vector<double> ex(npoints,0.);
715 
716  vector<double> kappa(npoints_kappa,0.);
717  vector<double> ekappa(npoints_kappa,0.);
718  vector<double> xkappa(npoints_kappa,0.);
719  vector<double> exkappa(npoints_kappa,0.);
720 
721 
722  cout<<"inside MakePlots loop: isys = "<<isys<<endl;
723  for(int ipoint = 0; ipoint < npoints; ipoint++){
724 
725  double numerator(0), denominator(0), enumer(0), edenom(0);
726 
727  numerator = counts.at(nums_reg_bin[ipoint][0]).at(nums_reg_bin[ipoint][1]).at(isys);
728  enumer = errors.at(nums_reg_bin[ipoint][0]).at(nums_reg_bin[ipoint][1]).at(isys);
729  denominator = counts.at(dens_reg_bin[ipoint][0]).at(dens_reg_bin[ipoint][1]).at(isys);
730  edenom = errors.at(dens_reg_bin[ipoint][0]).at(dens_reg_bin[ipoint][1]).at(isys);
731 
732  //if denominator is 0, assign weight of 1 mc event
733  if(denominator<=0) denominator = edenom; //in the case that denominator==0, its error is assigned by GetCountsthe weight of 1 MC event.
734 
735  R[ipoint] = numerator/denominator;
736  if(R[ipoint]>max) max = R[ipoint];
737 
738  //Now that R has been captured, need to also replace 0's in numerator for relative error calculation
739  if(numerator<=0) numerator = enumer;
740  eR[ipoint] = R[ipoint] * sqrt(sqr(enumer/numerator)+sqr(edenom/denominator));
741 
742  if(make_kappa && ipoint >= npoints_kappa){
743  cout<<"making kappa"<<endl;
744  double knum = R[ipoint - npoints_kappa]; //Ok if 0
745  double kden = numerator/denominator; //Since the current Ratio is denominator for our kappa, we can use this to be safe from the case R=0, since we have already fixed a 0 in this numerator
746  double eknum = eR[ipoint - npoints_kappa];
747  double ekden = eR[ipoint];
748 
749  kappa[ipoint - npoints_kappa] = knum/kden;
750  if(kappa[ipoint - npoints_kappa]>maxkappa) maxkappa = kappa[ipoint - npoints_kappa];
751  if(knum==0) ekappa[ipoint - npoints_kappa]= 0.0;
752  else ekappa[ipoint - npoints_kappa] = kappa[ipoint - npoints_kappa]*sqrt(sqr(eknum/knum)+sqr(ekden/kden));
753 
754  xkappa[ipoint - npoints_kappa]= ipoint - npoints_kappa + 0.1*is;
755  exkappa[ipoint - npoints_kappa]=0;
756 
757  }
758 
759  //arbitary x-axis:
760  x[ipoint]=ipoint+0.1*is;
761  ex[ipoint]=0;
762 
763  }
764 
765  TGraphErrors *g1 = new TGraphErrors(npoints,&x[0],&R[0],&ex[0],&eR[0]); //awful syntax to initialize with vectors instead of arrays
766  g_Rs.push_back(g1);
767  if(make_kappa){
768  TGraphErrors *gkappa = new TGraphErrors(npoints_kappa,&xkappa[0],&kappa[0],&exkappa[0],&ekappa[0]); //awful syntax to initialize with vectors instead of arrays
769  g_kappas.push_back(gkappa);
770  }
771  }
772 
773 
774  if(make_kappa){
775  delkappas.resize(npoints_kappa);
776  if(g_kappas.size() ==2){
777  for(int ibin=0;ibin<npoints_kappa;ibin++){
778  cout<<"kappa loop ibin = "<<ibin<<endl;
779  double x1(0),y1(0),x2(0),y2(0);
780  g_kappas.at(0)->GetPoint(ibin,x1,y1);
781  g_kappas.at(1)->GetPoint(ibin,x2,y2);
782  delkappas.at(ibin) = fabs(y1-y2)/y1;
783  cout<<Form("delkappa %i = %.3f", ibin+1, delkappas.at(ibin))<<endl;
784  }
785  }
786  }
787 
788 
789  styles style("RA4"); style.setDefaultStyle();
790  TCanvas can;
791  TH1F *h;
792  h = new TH1F("for_axis_label",cuts2title(baseline),npoints,-0.5,npoints-0.5);
793 
794  for (int ih=1;ih<=npoints;ih++){
795  int ipoint = ih-1;
796  h->GetXaxis()->SetBinLabel(ih,cuts2title(bins_by_region.at(nums_reg_bin[ipoint][0]).at(nums_reg_bin[ipoint][1]))); //adjust indices by 1 for goofy bin numbering
797  }
798 
799  h->SetMaximum(1.5*max);
800  h->SetMinimum(0.0);
801  h->GetXaxis()->SetLabelSize(0.04);
802  h->GetYaxis()->SetTitle(axisname);
803  h->Draw();
804 
805  double legX = 0.65, legY = 0.89, legSingle = 0.14;
806  double legW = 0.22, legH = legSingle;
807  TLegend leg(legX, legY-legH, legX+legW, legY);
808  leg.SetTextSize(0.057); leg.SetFillColor(0); leg.SetFillStyle(0); leg.SetBorderSize(0);
809  leg.SetTextFont(132);
810 
811  //int color[2] = {8,9};
812  // int ptrstyle[2] = {20,22};
813  // TString labels[2] = {"Nominal",sysname+" Variation"};
814  vector<TString> labels;
815  labels.push_back("Nominal");
816  for(unsigned int i=1;i<sysnames.size();i++){
817  if(i!=4) labels.push_back(sysnames[i]+" Variation");
818  if(i==4) labels.push_back("top p_{T} Variation");
819  }
820  for(unsigned int ivar=0; ivar<sysindices.size(); ivar++){
821  int isys = sysindices.at(ivar);
822  // if(ivar>1) cout<<"need more colors"<<endl;
823  /* g_Rs.at(isys)->SetMarkerStyle(ptrstyle[isys]);
824  g_Rs.at(isys)->SetMarkerColor(color[isys]);
825  g_Rs.at(isys)->SetLineColor(color[isys]);*/
826  if(isys>0){
827  g_Rs.at(ivar)->SetMarkerStyle(22);
828  g_Rs.at(ivar)->SetMarkerColor(9);
829  g_Rs.at(ivar)->SetLineColor(9);
830 
831  }
832  else{
833  g_Rs.at(ivar)->SetMarkerStyle(20);
834  g_Rs.at(ivar)->SetMarkerColor(8);
835  g_Rs.at(ivar)->SetLineColor(8);
836  }
837  g_Rs.at(ivar)->SetMarkerSize(2);
838  g_Rs.at(ivar)->Draw("PZ");
839  leg.AddEntry(g_Rs.at(ivar), labels[isys],"p");
840  }
841 
842 
843  TLine line; line.SetLineColor(28); line.SetLineWidth(4); line.SetLineStyle(2);
844  line.DrawLine(3.5, 0, 3.5, 1.5*max);
845  leg.Draw("p");
846 
847  TString external_cut="";
848  if(axisname.Contains("{MJ}")) external_cut="m_{T}";
849  if(axisname.Contains("{mT}")) external_cut="M_{J}";
850 
851  TLatex *text1 = new TLatex(0.35,0.03,"high "+external_cut);
852  text1->SetNDC();
853  text1->SetTextSize(0.04);
854  text1->SetLineWidth(2);
855  text1->Draw();
856  TLatex *text2 = new TLatex(0.7,0.03,"low "+external_cut);
857  text2->SetNDC();
858  text2->SetTextSize(0.04);
859  text2->SetLineWidth(2);
860  text2->Draw();
861 
862  TString pname = "plots/systematics/"+format_tag(axisname+"_"+method+"_"+sysname+baseline)+".pdf";
863  can.SaveAs(pname);
864 
865  for(unsigned int ivar=0; ivar<g_Rs.size(); ivar++){
866  g_Rs.at(ivar)->Delete();
867  }
868  h->Delete();
869 
870 
871  if(make_kappa){
872  TCanvas can3;
873  TH1F *h3 = new TH1F("for_axis_label2",cuts2title(baseline),npoints_kappa,-0.5,npoints_kappa-0.5);
874  for (unsigned int ih=1;ih<=bins_by_region.at(3).size();ih++){
875  h3->GetXaxis()->SetBinLabel(ih,cuts2title(bins_by_region.at(3).at(ih-1)));
876  }
877 
878  h3->SetMaximum(1.5*maxkappa);
879  h3->SetMinimum(0.0);
880  h3->GetXaxis()->SetLabelSize(0.05);
881  h3->GetYaxis()->SetTitle("Kappa");
882  h3->Draw();
883 
884  TLegend leg3(legX, legY-legH, legX+legW, legY);
885  leg3.SetTextSize(0.057); leg3.SetFillColor(0); leg3.SetFillStyle(0); leg3.SetBorderSize(0);
886  leg3.SetTextFont(132);
887 
888  for(unsigned int ivar=0; ivar<sysindices.size(); ivar++){
889  int isys = sysindices.at(ivar);
890  if(isys>1) cout<<"need more colors"<<endl;
891  /* g_kappas.at(isys)->SetMarkerStyle(ptrstyle[isys]);
892  g_kappas.at(isys)->SetMarkerColor(color[isys]);
893  g_kappas.at(isys)->SetLineColor(color[isys]);*/
894 
895 
896  if(isys>0){
897  g_kappas.at(ivar)->SetMarkerStyle(22);
898  g_kappas.at(ivar)->SetMarkerColor(9);
899  g_kappas.at(ivar)->SetLineColor(9);
900 
901  }
902  else{
903  g_kappas.at(ivar)->SetMarkerStyle(20);
904  g_kappas.at(ivar)->SetMarkerColor(8);
905  g_kappas.at(ivar)->SetLineColor(8);
906  }
907 
908  g_kappas.at(ivar)->SetMarkerSize(2);
909  g_kappas.at(ivar)->Draw("PZ");
910  leg3.AddEntry(g_kappas.at(ivar), labels[isys],"p");
911  }
912  leg3.Draw("p");
913 
914  TString pname3 = "plots/systematics/kappas_"+format_tag(method+"_"+sysname+baseline)+".pdf";
915  can3.SaveAs(pname3);
916 
917  for(unsigned int ivar=0; ivar<g_kappas.size(); ivar++){
918  g_kappas.at(ivar)->Delete();
919  }
920  h3->Delete();
921 
922  }
923 }
924 
925 
926 
927 double sqr(double x){
928  return x*x;
929 }
930 
931 
932 
933 
double sqr(double x)
virtual int const & ntruleps() const
double midjets(8)
TString luminosity
Definition: timer.hpp:6
void GetCounts(double lumi, vector< TString > sysnames, TString method, TString baseline, small_tree_quick &tree, vector< vector< vector< double > > > &finalcounts, vector< vector< vector< double > > > &errors, vector< vector< TString > > bins_by_region, vector< hfeats > hists, vector< vector< TH1F * > > &h)
int minjets(6)
TString title
float const & weight() const
Definition: small_tree.cpp:506
void setDefaultStyle()
Definition: styles.cpp:36
bool Contains(const std::string &text, const std::string &pattern)
int const & nmus() const
Definition: small_tree.cpp:605
virtual float const & trutop1_phi() const
std::string ntuple_date("2015_06_05")
TString cuts2title(TString title)
int LookUpRegion(small_tree_quick &tree, TString method)
STL namespace.
virtual float const & trutop2_pt() const
int LookUpBin(small_tree_quick &tree, int region, vector< vector< TString > > bins_by_region)
virtual float const & trutop1_pt() const
virtual int const & ntrumeisr() const
int const & nels() const
Definition: small_tree.cpp:572
void OverlayHistsmT(vector< TH1F * > h, hfeats hist, TString method, TString sysname, TString baseline)
float const & met() const
Definition: small_tree.cpp:462
TString format_tag(TString tag)
float GetBranchValue(TString branch)
Definition: small_tree.cpp:388
virtual float const & mj() const
tuple kappa
Definition: parse_card.py:264
TString cuts
TString varname
void OverlayHists(vector< TH1F * > h, hfeats hist, TString method, TString sysname, TString baseline)
void MakePlots(TString axisname, vector< int > numerator_regions, vector< int > denominator_regions, vector< vector< vector< double > > > counts, vector< vector< vector< double > > > errors, vector< vector< TString > > bins_by_region, TString baseline, TString method, vector< TString > sysnames, int sysnum, vector< double > &delkappas)
double mjthresh(400.)
int FindSuperBin(TString cut, vector< TString > other_region)
float const & mt() const
Definition: small_tree.cpp:484
int main(int argc, char *argv[])
int const & njets() const
Definition: small_tree.cpp:583
virtual void GetEntry(const long entry)
tuple file
Definition: parse_card.py:238
long GetEntries() const
Definition: small_tree.cpp:400
void Iterate()
Definition: timer.cpp:28
void Start()
Definition: timer.cpp:22
double GetWeight(small_tree_quick &tree, TString sysname, int ivar)
void PrintTable(TString method, vector< vector< vector< double > > > ttbar_counts, vector< vector< vector< double > > > ttbar_errors, vector< vector< vector< double > > > ttbar_counts_dilep, vector< vector< vector< double > > > other_counts, vector< vector< vector< double > > > other_counts_dilep, vector< vector< double > > delkappas, vector< vector< TString > > bins_by_region)
virtual float const & trutop2_phi() const
int Add(const std::string &filename)
Definition: small_tree.cpp:381
float const & ht() const
Definition: small_tree.cpp:451
bool PassString(TString cut)
Definition: small_tree.cpp:394