ra4_macros  bede988c286599a3a84b77a4d788ac0a971e89f9
make_variations.cxx
Go to the documentation of this file.
1 // make_variations.cxx : output histograms for each variation type
2 
3 #include <stdio.h>
4 #include <iostream>
5 #include <vector>
6 #include <math.h>
7 #include "TChain.h"
8 #include "TH1D.h"
9 #include "TCanvas.h"
10 #include "TGraphErrors.h"
11 #include "TLegend.h"
12 #include "TLine.h"
13 #include "TString.h"
14 #include "TColor.h"
15 #include "TFile.h"
16 #include "TMath.h"
17 
18 #include "styles.hpp"
19 #include "utilities.hpp"
20 #include "utilities_macros.hpp"
21 #include "utilities_macros_rpv.hpp"
22 
23 void makeVariations(std::string &syst);
24 std::string cutandweightForVariations(std::string cut, std::string weight);
25 std::string cutandweightForVariationsQCD(std::string cut, std::string weight, std::string flavorWeight);
26 std::string cutandweightForVariationsdata(std::string cut, std::string weight);
27 void setOverflow(TH1F *hist);
28 void protectFromZero(TH1F* hist);
29 
30 
31 TFile *f;
32 std::map<std::string, std::string> prettySampleName;
33 
34 // this is a hack to add an additional weight
35 std::string cutandweightForVariations(std::string cut, std::string weight)
36 {
37  std::string newcut("(");
38  newcut+=weight;
39  // the default weight includes the RA4 trigger efficiency; need to exclude this
40  newcut+="*";
41  newcut+=rpv::luminosity.Data();
42  newcut+="*weight*w_pu_rpv/eff_trig)*(";
43  newcut+=cut;
44  newcut+="";
45 
46  return newcut;
47 }
48 
49 // this is a hack to add an additional weight
50 // QCD also needs to have flavor reweighted
51 std::string cutandweightForVariationsQCD(std::string cut, std::string weight, std::string flavorWeight)
52 {
53  std::string newcut("(");
54  newcut+=weight;
55  newcut+="*";
56  newcut+=rpv::luminosity.Data();
57  newcut+="*weight*w_pu_rpv/eff_trig*";
58  newcut+=flavorWeight;
59  newcut+=")*(";
60  newcut+=cut;
61  newcut+="";
62 
63  return newcut;
64 }
65 
66 // this is a hack to add an additional weight
67 std::string cutandweightForVariationsdata(std::string cut, std::string weight)
68 {
69  std::string newcut("(");
70  newcut+=weight;
71  newcut+=")*(";
72  newcut+=cut;
73  newcut+="";
74 
75  return newcut;
76 }
77 
78 void setOverflow(TH1F *hist)
79 {
80  int maxBin = hist->GetNbinsX()+1;
81  float lastBinContent = hist->GetBinContent(maxBin-1);
82  float overflow = hist->GetBinContent(maxBin);
83  hist->SetBinContent(maxBin-1, lastBinContent+overflow);
84 }
85 
86 // need to avoid negative weights from single top samples
87 void protectFromZero(TH1F *hist)
88 {
89  for(int i=0; i<hist->GetNbinsX(); i++) {
90  float bincontent = hist->GetBinContent(i);
91  float binerror = hist->GetBinError(i);
92  if(bincontent-binerror<0 || isnan(bincontent)) {
93  if(isnan(bincontent)) std::cout << "Found nan" << std::endl;
94  hist->SetBinContent(i, 0.0);
95  hist->SetBinError(i, 0.0);
96  }
97  }
98 }
99 
100 
101 void jetVariations(TString &nbm, TString &cut, const std::string &variation)
102 {
103  std::cout << "Processing variation: " << variation << std::endl;
104  // variations have index 0 (JER smearing), 1 (JES up) and 2 (JES down)
105  // only include 1-sided variations of resolution
106  if(variation.find("jerUp")!=std::string::npos) {
107  cut.ReplaceAll("ht", "sys_ht[0]");
108  cut.ReplaceAll("njets", "sys_njets[0]");
109  cut.ReplaceAll("nbm", "sys_nbm[0]");
110  cut.ReplaceAll("mj", "sys_mj[0]");
111  nbm.ReplaceAll("nbm", "sys_nbm[0]");
112  }
113  if(variation.find("jesUp")!=std::string::npos) {
114  cut.ReplaceAll("ht", "sys_ht[1]");
115  cut.ReplaceAll("njets", "sys_njets[1]");
116  cut.ReplaceAll("nbm", "sys_nbm[1]");
117  cut.ReplaceAll("mj", "sys_mj[1]");
118  nbm.ReplaceAll("nbm", "sys_nbm[1]");
119  }
120  if(variation.find("jesDown")!=std::string::npos) {
121  cut.ReplaceAll("ht", "sys_ht[2]");
122  cut.ReplaceAll("njets", "sys_njets[2]");
123  cut.ReplaceAll("nbm", "sys_nbm[2]");
124  cut.ReplaceAll("mj", "sys_mj[2]");
125  nbm.ReplaceAll("nbm", "sys_nbm[2]");
126  }
127 
128 }
129 
130 
131 void outputHistograms(std::vector<sfeats>& Samples, std::string variation)
132 {
133  std::cout << "outputHistograms(): " << variation << std::endl;
134 
135  std::string plotVar("nbm");
136 
137  std::vector<std::string> cuts = {"nbm>0&&ht>1500&&njets>=4&&njets<=5&&(nmus+nels)==0&&mj>=500&&mj<800","nbm>0&&ht>1500&&njets>=6&&njets<=7&&(nmus+nels)==0&&mj>=500&&mj<800",
138  "nbm>0&&ht>1200&&njets>=4&&njets<=5&&(nmus+nels)==1&&mj>=500&&mj<800",
139  "nbm>0&&ht>1500&&njets>=4&&njets<=5&&(nmus+nels)==0&&mj>=800","nbm>0&&ht>1500&&njets>=6&&njets<=7&&(nmus+nels)==0&&mj>=800",
140  "nbm>0&&ht>1200&&njets>=4&&njets<=5&&(nmus+nels)==1&&mj>=800",
141  // low MJ control regions
142  "nbm>0&&ht>1500&&njets>=4&&njets<=5&&(nmus+nels)==0&&mj>=300&&mj<500",
143  "nbm>0&&ht>1500&&njets>=6&&njets<=7&&(nmus+nels)==0&&mj>=300&&mj<500",
144  "nbm>0&&ht>1500&&njets>=8&&njets<=9&&(nmus+nels)==0&&mj>=300&&mj<500",
145  "nbm>0&&ht>1500&&njets>=10&&(nmus+nels)==0&&mj>=300&&mj<500",
146  // signal regions, low mj
147  "nbm>0&&ht>1500&&njets>=10&&(nmus+nels)==0&&mj>=500&&mj<800",
148  "nbm>0&&ht>1200&&njets>=6&&njets<=7&&(nmus+nels)==1&&mj>=500&&mj<800",
149  "nbm>0&&ht>1200&&njets>=8&&(nmus+nels)==1&&mj>=500&&mj<800",
150  // signal regions, high mj
151  "nbm>0&&ht>1500&&njets>=10&&(nmus+nels)==0&&mj>=800",
152  "nbm>0&&ht>1200&&njets>=6&&njets<=7&&(nmus+nels)==1&&mj>=800",
153  "nbm>0&&ht>1200&&njets>=8&&(nmus+nels)==1&&mj>=800",
154 
155  //Missing regions
156  "nbm>0&&ht>1500&&njets>=8&&njets<=9&&(nmus+nels)==0&&mj>=500&&mj<800",
157  "nbm>0&&ht>1500&&njets>=8&&njets<=9&&(nmus+nels)==0&&mj>=800",
158 
159  };
160 
161  //std::vector<std::string> cuts = {"nbm>0&&ht>1200&&njets>=8&&(nmus+nels)==1&&mj>=800"};
162 
163  // maximum number of b-tagged jets
164  int nBBins=4;
165 
166  for(unsigned int icut=0; icut<cuts.size(); icut++) {
167 
168  // FIXME: temporarily remove lowset MJ bins
169  if(icut>=6 && icut<=9) continue;
170 
171  // need to make temporary variable because some systematics can change cuts or plot variables
172  TString tempCut=cuts.at(icut).c_str();
173  TString tempPlotVar=plotVar.c_str();
174  jetVariations(tempPlotVar, tempCut, variation);
175 
176  gDirectory->cd("/");
177  TString directory(Form("bin%d", icut));
178  if(!gDirectory->GetDirectory(directory)) gDirectory->mkdir(directory);
179  gDirectory->cd(directory);
180  for(unsigned int i=0; i<Samples.size(); i++) {
181  TChain *ch = new TChain("tree");
182  for(auto files : Samples.at(i).file) ch->Add(files.Data());
183  std::string histname(prettySampleName[Samples.at(i).label.Data()]);
184  std::cout << "Processing sample type: " << histname << std::endl;
185  if(histname.find("data_obs")==std::string::npos ) {
186  if(variation.size()>0&& variation.find("nominal")==std::string::npos) {
187  histname += "_";
188  histname += variation.c_str();
189  }
190  }
191  else {
192  if(variation.find("nominal")==std::string::npos) continue;
193  }
194  // erase brackets for PDF weights
195  if(variation.find("pdf")!=std::string::npos) {
196  histname.erase(histname.find('['), 1);
197  histname.erase(histname.find(']'), 1);
198  }
199  TH1F * hist = new TH1F(histname.c_str(), histname.c_str(), nBBins+1, 0, nBBins+1);
200  TString fullCut(Form("%s&&%s)", Samples.at(i).cut.Data(), tempCut.Data()));
201 
202  std::cout << fullCut << std::endl;
203  ch->Project(histname.c_str(), tempPlotVar.Data(), fullCut.Data());
204  setOverflow(hist);
205  protectFromZero(hist);
206  hist->Write();
207  hist->Delete();
208  delete ch;
209  }
210  }
211 }
212 
213 
214 int main(int argc, char* argv[])
215 {
216  std::vector<std::string> variations;
217  std::vector<std::string> valid_variations = {"btag_bc", "btag_udsg", "gs",
218  "qcd_mur", "qcd_muf", "qcd_murf",
219  "ttbar_mur", "ttbar_muf", "ttbar_murf"
220  "wjets_mur", "wjets_muf", "wjets_murf",
221  "other_mur", "other_muf", "other_murf"};
222  if(argc<2) {
223  variations.push_back("");
224  std::cout << "Performing nominal variation" << std::endl;
225  }
226  else if(argc==2){
227  std::string nom="nominal";
228  if(argv[1]==nom) variations.push_back("");
229  else variations.push_back(argv[1]);
230  std::cout << "Performing variation " << argv[1] << std::endl;
231  }
232  else if(argc==3){
233  variations.push_back(argv[1]);
234  variations.at(0).append(argv[2]);
235  std::cout << "Performing variation " << argv[1] << std::endl;
236  }
237  else {
238  std::cout << "Too many arguments!" << std::endl;
239  }
240 
241  if(variations.at(0).size()==0) variations.at(0)="nominal";
242  f = new TFile(Form("variations/output_%s.root", variations.at(0).c_str()), "recreate");
243  std::vector<std::string> types = {"Up", "Down"};
244  // the nominal variations only have one sign
245  if(variations.size()==0) {
246  types.clear();
247  types.push_back("");
248  }
249  for(auto ivariation : variations) {
250  for(auto itype : types) {
251  std::string variationName = ivariation + itype;
252  std::cout << "Making variation " << variationName << std::endl;
253  makeVariations(variationName);
254  }
255  }
256 
257  f->Close();
258  return 0;
259 }
260 
261 void makeVariations(std::string &syst){
262 
263  std::string extraWeight("1");
264  std::string qcdWeight("1");
265  std::string ttbarWeight("1");
266  std::string wjetsWeight("1");
267  std::string otherWeight("1");
268  std::string signalWeight("1");
269 
270 
271  std::vector<double> gs_dmc={1,1,1,1};
272  std::vector<double> gs_dmc_err={0,0,0,0};
273  std::vector<double> gs_dmc_syst={0,0,0,0};
274  //Get values for GS syst
275  if(std::string::npos != syst.find("gs")){
276 
277  TFile *gs_file = TFile::Open("syst_gs.root");
278  TGraphErrors* h_gs_dmc = static_cast<TGraphErrors*>(gs_file->Get("dmc_ldrbb_allmj"));
279 
280  double temp_val;
281  for(unsigned int ibin=0; ibin<4; ibin++)
282  {
283  h_gs_dmc->GetPoint(ibin,temp_val,gs_dmc[ibin]);
284  gs_dmc_err[ibin] = h_gs_dmc->GetErrorY(ibin);
285  gs_dmc_syst[ibin] = TMath::Sqrt((1-gs_dmc[ibin])*(1-gs_dmc[ibin])+gs_dmc_err[ibin]*gs_dmc_err[ibin]);
286  }
287  }
288 
289  // weights directly affecting b-tagging in all samples
290  if(syst=="btag_bcUp") extraWeight="sys_bctag[0]";
291  if(syst=="btag_bcDown") extraWeight="sys_bctag[1]";
292  if(syst=="btag_udsgUp") extraWeight="sys_udsgtag[0]";
293  if(syst=="btag_udsgDown") extraWeight="sys_udsgtag[1]";
294  if(syst=="gsUp") extraWeight="(1+0.2*fromGS)";
295  if(syst=="gsDown") extraWeight="(1-0.2*fromGS)";
296  if(syst=="gs45Up") extraWeight="(1+"+std::to_string(gs_dmc_syst[0])+"*fromGS*(njets==4 || njets==5))";
297  if(syst=="gs45Down") extraWeight="(1-"+std::to_string(gs_dmc_syst[0])+"*fromGS*(njets==4 || njets==5))";
298  if(syst=="gs67Up") extraWeight="(1+"+std::to_string(gs_dmc_syst[1])+"*fromGS*(njets==6 || njets==7))";
299  if(syst=="gs67Down") extraWeight="(1-"+std::to_string(gs_dmc_syst[1])+"*fromGS*(njets==6 || njets==7))";
300  if(syst=="gs89Up") extraWeight="(1+"+std::to_string(gs_dmc_syst[2])+"*fromGS*(njets==8 || njets==9))";
301  if(syst=="gs89Down") extraWeight="(1-"+std::to_string(gs_dmc_syst[2])+"*fromGS*(njets==8 || njets==9))";
302  if(syst=="gs10InfUp") extraWeight="(1+"+std::to_string(gs_dmc_syst[3])+"*fromGS*(njets>=10))";
303  if(syst=="gs10InfDown") extraWeight="(1-"+std::to_string(gs_dmc_syst[3])+"*fromGS*(njets>=10))";
304 
305  // other weights affecting all samples
306  if(syst=="lep_effUp") extraWeight="w_lep";
307  if(syst=="lep_effDown") extraWeight="(2-w_lep)";
308  if(syst=="pileupUp") extraWeight="sys_pu_rpv[0]";
309  if(syst=="pileupDown") extraWeight="sys_pu_rpv[1]";
310 
311  // pdf weights
312  if(syst.find("w_pdf")!=std::string::npos) {
313  if(syst.find("Up")!=std::string::npos) {
314  size_t upLength=2;
315  syst.erase(syst.find("Up"), upLength);
316  syst.insert(5, "[");
317  syst.append("]");
318  extraWeight=syst;
319  syst.append("Up");
320  }
321  // negative PDF variations have the same difference from 1 but with opposite sign 1+(1-weight)=2-weight
322  else {
323  size_t downLength=4;
324  syst.erase(syst.find("Down"), downLength);
325  syst.insert(5, "[");
326  syst.append("]");
327  extraWeight=syst;
328  extraWeight="(2-";
329  extraWeight+=syst;
330  extraWeight+=")";
331  syst.append("Down");
332  }
333  }
334 
335  // for the variations that do not depend on sample type
336  signalWeight=qcdWeight=otherWeight=wjetsWeight=ttbarWeight=extraWeight;
337 
338  TFile *csv_weight_file = TFile::Open("data/low_njet.root");
339  TH1F *csv_weight = static_cast<TH1F*>(csv_weight_file->Get("csv_weight"));
340  float bflavorValCentral = csv_weight->GetBinContent(1);
341  float bflavorValError = csv_weight->GetBinError(1);
342  float cflavorValCentral = csv_weight->GetBinContent(2);
343  // negative sign implements anticorrelation between b and c reweightings
344  float cflavorValError = -csv_weight->GetBinError(2);
345  float lflavorValCentral = csv_weight->GetBinContent(3);
346  float lflavorValError = csv_weight->GetBinError(3);
347  csv_weight_file->Close();
348  f->cd();
349 
350  std::cout << "Reweight b jets by " << bflavorValCentral << " +/ " << bflavorValError << std::endl;
351  std::cout << "Reweight c jets by " << cflavorValCentral << " +/ " << cflavorValError << std::endl;
352  std::cout << "Reweight l jets by " << lflavorValCentral << " +/ " << lflavorValError << std::endl;
353 
354  // To provide QCD flavor reweighting
355  double bflavorValUp, bflavorValDown;
356  bflavorValUp=bflavorValCentral+bflavorValError;
357  bflavorValDown=bflavorValCentral-bflavorValError;
358  double cflavorValUp, cflavorValDown;
359  cflavorValUp=cflavorValCentral+cflavorValError;
360  cflavorValDown=cflavorValCentral-cflavorValError;
361  double lflavorValUp, lflavorValDown;
362  lflavorValUp=lflavorValCentral=lflavorValDown=1.0;
363 
364  TString bflavor("(Sum$(abs(jets_hflavor)==5)>0)");
365  TString cflavor("(Sum$(abs(jets_hflavor)==5)==0 && Sum$(abs(jets_hflavor)==4)>0)");
366  TString lflavor("(Sum$(abs(jets_hflavor)==5)==0 && Sum$(abs(jets_hflavor)==4)==0)");
367  TString flavorWeightUp(Form("(%s*%f + %s*%f + %s*%f)", bflavor.Data(), bflavorValUp, cflavor.Data(), cflavorValUp, lflavor.Data(), lflavorValUp));
368  TString flavorWeightCentral(Form("(%s*%f + %s*%f + %s*%f)", bflavor.Data(), bflavorValCentral, cflavor.Data(), cflavorValCentral, lflavor.Data(), lflavorValCentral));
369  TString flavorWeightDown(Form("(%s*%f + %s*%f + %s*%f)", bflavor.Data(), bflavorValDown, cflavor.Data(), cflavorValDown, lflavor.Data(), lflavorValDown));
370  std::string qcdFlavorWeight=flavorWeightCentral.Data();
371 
372  if(syst=="qcd_flavorUp") {
373  qcdFlavorWeight=flavorWeightUp.Data();
374  std::cout << qcdFlavorWeight << "\n" << std::endl;
375  }
376  if(syst=="qcd_flavorDown") {
377  qcdFlavorWeight=flavorWeightDown.Data();
378  std::cout << qcdFlavorWeight << "\n" << std::endl;
379  }
380  if(syst=="qcd_flavor45Up") {
381  TString tempFlavor(Form("((%s)*(njets==4 || njets==5) + (%s)*!(njets==4 || njets==5) )", flavorWeightUp.Data(), flavorWeightCentral.Data()));
382  qcdFlavorWeight=tempFlavor.Data();
383  }
384  if(syst=="qcd_flavor45Down") {
385  TString tempFlavor(Form("(1+(%s)*(njets==4 || njets==5) + (%s)*!(njets==4 || njets==5) )", flavorWeightDown.Data(), flavorWeightCentral.Data()));
386  qcdFlavorWeight=tempFlavor.Data();
387  }
388  if(syst=="qcd_flavor67Up") {
389  TString tempFlavor(Form("((%s)*(njets==6 || njets==7) + (%s)*!(njets==6 || njets==7) )", flavorWeightUp.Data(), flavorWeightCentral.Data()));
390  qcdFlavorWeight=tempFlavor.Data();
391  }
392  if(syst=="qcd_flavor67Down") {
393  TString tempFlavor(Form("((%s)*(njets==6 || njets==7) + (%s)*!(njets==6 || njets==7) )", flavorWeightDown.Data(), flavorWeightCentral.Data()));
394  qcdFlavorWeight=tempFlavor.Data();
395  }
396  if(syst=="qcd_flavor89Up") {
397  TString tempFlavor(Form("((%s)*(njets==8 || njets==9) + (%s)*!(njets==8 || njets==9) )", flavorWeightUp.Data(), flavorWeightCentral.Data()));
398  qcdFlavorWeight=tempFlavor.Data();
399  }
400  if(syst=="qcd_flavor89Down") {
401  TString tempFlavor(Form("((%s)*(njets==8 || njets==9) + (%s)*!(njets==8 || njets==9) )", flavorWeightDown.Data(), flavorWeightCentral.Data()));
402  qcdFlavorWeight=tempFlavor.Data();
403  }
404  if(syst=="qcd_flavor10InfUp") {
405  TString tempFlavor(Form("((%s)*(njets>=10) + (%s)*!(njets>=10) )", flavorWeightUp.Data(), flavorWeightCentral.Data()));
406  qcdFlavorWeight=tempFlavor.Data();
407  }
408  if(syst=="qcd_flavor10InfDown") {
409  TString tempFlavor(Form("((%s)*(njets>=10) + (%s)*!(njets>=10) )", flavorWeightDown.Data(), flavorWeightCentral.Data()));
410  qcdFlavorWeight=tempFlavor.Data();
411  }
412  if(syst=="qcd_mufUp") qcdWeight="sys_muf[0]";
413  if(syst=="qcd_mufDown") qcdWeight="sys_muf[1]";
414  if(syst=="qcd_murUp") qcdWeight="sys_mur[0]";
415  if(syst=="qcd_murDown") qcdWeight="sys_mur[1]";
416  if(syst=="qcd_murfUp") qcdWeight="sys_murf[0]";
417  if(syst=="qcd_murfDown") qcdWeight="sys_murf[1]";
418 
419  if(syst=="ttbar_mufUp") ttbarWeight="sys_muf[0]";
420  if(syst=="ttbar_mufDown") ttbarWeight="sys_muf[1]";
421  if(syst=="ttbar_murUp") ttbarWeight="sys_mur[0]";
422  if(syst=="ttbar_murDown") ttbarWeight="sys_mur[1]";
423  if(syst=="ttbar_murfUp") ttbarWeight="sys_murf[0]";
424  if(syst=="ttbar_murfDown") ttbarWeight="sys_murf[1]";
425 
426  if(syst=="ttbar_ptUp") ttbarWeight="w_toppt";
427  if(syst=="ttbar_ptDown") ttbarWeight="(2-w_toppt)";
428 
429  if(syst=="other_mufUp") otherWeight="sys_muf[0]";
430  if(syst=="other_mufDown") otherWeight="sys_muf[1]";
431  if(syst=="other_murUp") otherWeight="sys_mur[0]";
432  if(syst=="other_murDown") otherWeight="sys_mur[1]";
433  if(syst=="other_murfUp") otherWeight="sys_murf[0]";
434  if(syst=="other_murfDown") otherWeight="sys_murf[1]";
435 
436  if(syst=="signal_mufUp") signalWeight="sys_muf[0]";
437  if(syst=="signal_mufDown") signalWeight="sys_muf[1]";
438  if(syst=="signal_murUp") signalWeight="sys_mur[0]";
439  if(syst=="signal_murDown") signalWeight="sys_mur[1]";
440  if(syst=="signal_murfUp") signalWeight="sys_murf[0]";
441  if(syst=="signal_murfDown") signalWeight="sys_murf[1]";
442  // only apply ISR systematic to signal
443  if(syst=="isrUp") signalWeight="sys_isr[0]";
444  if(syst=="isrDown") signalWeight="sys_isr[1]";
445  // fastsim related systematics
446  if(syst=="fs_btag_bcUp") signalWeight="sys_fs_bctag[0]";
447  if(syst=="fs_btag_bcDown") signalWeight="sys_fs_bctag[1]";
448  if(syst=="fs_btag_udsgUp") signalWeight="sys_fs_udsgtag[0]";
449  if(syst=="fs_btag_udsgDown") signalWeight="sys_fs_udsgtag[1]";
450  if(syst=="fs_lep_effUp") signalWeight="sys_fs_lep[0]";
451  if(syst=="fs_lep_effDown") signalWeight="sys_fs_lep[1]";
452 
453  if(syst=="wjets_mufUp") wjetsWeight="sys_muf[0]";
454  if(syst=="wjets_mufDown") wjetsWeight="sys_muf[1]";
455  if(syst=="wjets_murUp") wjetsWeight="sys_mur[0]";
456  if(syst=="wjets_murDown") wjetsWeight="sys_mur[1]";
457  if(syst=="wjets_murfUp") wjetsWeight="sys_murf[0]";
458  if(syst=="wjets_murfDown") wjetsWeight="sys_murf[1]";
459 
460  TString folder_links="/homes/cawest/links/";
461 
462  std::vector<TString> s_rpv_750;
463  s_rpv_750.push_back("/net/cms9/cms9r0/rohan/babies/2016_07_13/T1tbs/split/renorm/*mGluino-750*");
464  std::vector<TString> s_rpv_1000;
465  s_rpv_1000.push_back("/net/cms9/cms9r0/rohan/babies/2016_07_13/T1tbs/split/renorm/*mGluino-1000*");
466  std::vector<TString> s_rpv_1100;
467  s_rpv_1100.push_back("/net/cms9/cms9r0/rohan/babies/2016_07_13/T1tbs/split/renorm/*mGluino-1100*");
468  std::vector<TString> s_rpv_1200;
469  s_rpv_1200.push_back("/net/cms9/cms9r0/rohan/babies/2016_07_13/T1tbs/split/renorm/*mGluino-1200*");
470  std::vector<TString> s_rpv_1300;
471  s_rpv_1300.push_back("/net/cms9/cms9r0/rohan/babies/2016_07_13/T1tbs/split/renorm/*mGluino-1300*");
472  std::vector<TString> s_rpv_1400;
473  s_rpv_1400.push_back("/net/cms9/cms9r0/rohan/babies/2016_07_13/T1tbs/split/renorm/*mGluino-1400*");
474  std::vector<TString> s_tt;
475  s_tt.push_back("/net/cms2/cms2r0/jaehyeokyoo/babies/skim_ht1200/*TTJets_TuneCUETP8M1_13TeV-madgraphMLM*");
476  // s_tt.push_back(filestring("TT_TuneCUETP8M1_13TeV-powheg-pythia8"));
477  s_tt.push_back(filestring("TTJets_DiLept_TuneCUETP8M1_13TeV-madgraphMLM-pythia8"));
478  s_tt.push_back(filestring("TTJets_DiLept_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_ext1"));
479  s_tt.push_back(filestring("TTJets_SingleLeptFromT_TuneCUETP8M1_13TeV-madgraphMLM-pythia8"));
480  s_tt.push_back(filestring("TTJets_SingleLeptFromT_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_ext1"));
481  s_tt.push_back(filestring("TTJets_SingleLeptFromTbar_TuneCUETP8M1_13TeV-madgraphMLM-pythia8"));
482  s_tt.push_back(filestring("TTJets_SingleLeptFromTbar_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_ext1"));
483 
484  std::vector<TString> s_qcd;
485  s_qcd.push_back(filestring("QCD_HT1000to1500_TuneCUETP8M1_13TeV-madgraphMLM-pythia8"));
486  s_qcd.push_back(filestring("QCD_HT1000to1500_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_ext1"));
487  s_qcd.push_back(filestring("QCD_HT1500to2000_TuneCUETP8M1_13TeV-madgraphMLM-pythia8"));
488  s_qcd.push_back(filestring("QCD_HT1500to2000_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_ext1"));
489  s_qcd.push_back(filestring("QCD_HT2000toInf_TuneCUETP8M1_13TeV-madgraphMLM-pythia8"));
490  s_qcd.push_back(filestring("QCD_HT2000toInf_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_ext1"));
491  std::vector<TString> s_wjets;
492  s_wjets.push_back(filestring("WJetsToQQ_HT-600ToInf_TuneCUETP8M1_13TeV-madgraphMLM-pythia8"));
493  s_wjets.push_back(filestring("WJetsToLNu_HT-600ToInf_TuneCUETP8M1_13TeV-madgraphMLM-pythia8"));
494  std::vector<TString> s_other;
495  s_other.push_back(filestring("ZJetsToQQ_HT600toInf_13TeV-madgraph"));
496  s_other.push_back(filestring("ST_s-channel_4f_leptonDecays_13TeV-amcatnlo-pythia8_TuneCUETP8M1"));
497  s_other.push_back(filestring("ST_t-channel_antitop_4f_leptonDecays_13TeV-powheg-pythia8_TuneCUETP8M1"));
498  s_other.push_back(filestring("ST_t-channel_top_4f_leptonDecays_13TeV-powheg-pythia8_TuneCUETP8M1"));
499  s_other.push_back(filestring("ST_tW_antitop_5f_inclusiveDecays_13TeV-powheg-pythia8_TuneCUETP8M1"));
500  s_other.push_back(filestring("ST_tW_top_5f_inclusiveDecays_13TeV-powheg-pythia8_TuneCUETP8M1"));
501  s_other.push_back(filestring("DYJetsToLL_M-50_HT-600toInf_TuneCUETP8M1_13TeV-madgraphMLM-pythia8"));
502  s_other.push_back(filestring("TTWJetsToLNu_TuneCUETP8M1_13TeV-amcatnloFXFX-madspin-pythia8"));
503  s_other.push_back(filestring("TTWJetsToQQ_TuneCUETP8M1_13TeV-amcatnloFXFX-madspin-pythia8"));
504  s_other.push_back(filestring("TTZToQQ_TuneCUETP8M1_13TeV-amcatnlo-pythia8"));
505  s_other.push_back(filestring("TTZToLLNuNu_M-10_TuneCUETP8M1_13TeV-amcatnlo-pythia8"));
506  s_other.push_back(filestring("ttHJetTobb_M125_13TeV_amcatnloFXFX_madspin_pythia8"));
507  s_other.push_back(filestring("TTTT_TuneCUETP8M1_13TeV-amcatnlo-pythia8"));
508  std::vector<TString> s_jetht;
509  s_jetht.push_back(filestring("JetHT_Run2015C_25ns-05Oct2015-v1"));
510  s_jetht.push_back(filestring("JetHT_Run2015D-05Oct2015-v1"));
511  s_jetht.push_back(filestring("JetHT_Run2015D-PromptReco-v4"));
512 
513  // Reading ntuples
514  std::string blinding("((njets<10 && (nmus+nels)==0) || (nmus+nels==1 && njets<6))");
515  std::vector<sfeats> Samples;
516  Samples.push_back(sfeats(s_rpv_750, "#tilde{g}(750)", ra4::c_t1tttt, 1,cutandweightForVariations("1",signalWeight)));
517  Samples.push_back(sfeats(s_rpv_1000, "#tilde{g}(1000)", ra4::c_t1tttt, 1,cutandweightForVariations("1",signalWeight)));
518  Samples.push_back(sfeats(s_rpv_1100, "#tilde{g}(1100)", ra4::c_t1tttt, 1,cutandweightForVariations("1",signalWeight)));
519  Samples.push_back(sfeats(s_rpv_1200, "#tilde{g}(1200)", ra4::c_t1tttt, 1,cutandweightForVariations("1",signalWeight)));
520  Samples.push_back(sfeats(s_rpv_1300, "#tilde{g}(1300)", ra4::c_t1tttt, 1,cutandweightForVariations("1",signalWeight)));
521  Samples.push_back(sfeats(s_rpv_1400, "#tilde{g}(1400)", ra4::c_t1tttt, 1,cutandweightForVariations("1",signalWeight)));
522  Samples.push_back(sfeats(s_wjets, "W+jets", kTeal, 1,cutandweightForVariations("1", wjetsWeight)));
523  Samples.push_back(sfeats(s_qcd, "QCD", kYellow, 1,cutandweightForVariationsQCD("1",qcdWeight, qcdFlavorWeight)));
524  Samples.push_back(sfeats(s_tt, "t#bar{t}", kTeal, 1,cutandweightForVariations("1", ttbarWeight)));
525  Samples.push_back(sfeats(s_other, "Other", ra4::c_other, 1, cutandweightForVariations("1", otherWeight)));
526  //Samples.push_back(sfeats(s_jetht, "Data",kBlack,1,cutandweightForVariationsdata("trig[12] && pass && " + blinding, "1")));
527  Samples.push_back(sfeats(s_jetht, "Data",kBlack,1,cutandweightForVariationsdata("trig[12] && pass", "1")));
528  Samples.back().isData = true;
529  Samples.back().doStack = false;
530 
531  // convert pretty sample name to the name used in the datacard
532  prettySampleName["Data"] = "data_obs";
533  prettySampleName["#tilde{g}(750)"] = "signal_M750";
534  prettySampleName["#tilde{g}(1000)"] = "signal_M1000";
535  prettySampleName["#tilde{g}(1100)"] = "signal_M1100";
536  prettySampleName["#tilde{g}(1200)"] = "signal_M1200";
537  prettySampleName["#tilde{g}(1300)"] = "signal_M1300";
538  prettySampleName["#tilde{g}(1400)"] = "signal_M1400";
539  prettySampleName["QCD"] = "qcd";
540  prettySampleName["W+jets"] = "wjets";
541  prettySampleName["t#bar{t}"] = "ttbar";
542  prettySampleName["Other"] = "other";
543 
544  outputHistograms(Samples, syst);
545 
546 }
547 
void makeVariations(std::string &syst)
std::string cutandweightForVariationsdata(std::string cut, std::string weight)
diff git a run rpv_bkg_syst py b run rpv_bkg_syst py index a run rpv_bkg_syst py b run rpv_bkg_syst import sys import math import ROOT from array import array import argparse histname
Definition: log.txt:11
tuple ch
if sofar>10: continue
std::string cutandweightForVariations(std::string cut, std::string weight)
std::string cutandweightForVariationsQCD(std::string cut, std::string weight, std::string flavorWeight)
TString luminosity
int main(int argc, char *argv[])
void jetVariations(TString &nbm, TString &cut, const std::string &variation)
void protectFromZero(TH1F *hist)
void setOverflow(TH1F *hist)
TString filestring(TString dataset, bool isSkimmed=true)
TFile * f
void outputHistograms(std::vector< sfeats > &Samples, std::string variation)
std::map< std::string, std::string > prettySampleName