ra4_draw  4bd0201e3d922d42bd545d4b045ed44db33454a4
plot_dy_mismeasurement_study.cxx
Go to the documentation of this file.
2 
3 #include <iostream>
4 #include <string>
5 #include <vector>
6 #include <memory>
7 
8 #include <unistd.h>
9 #include <getopt.h>
10 
11 #include "TError.h"
12 #include "TColor.h"
13 #include "TVector2.h"
14 
15 #include "core/baby.hpp"
16 #include "core/process.hpp"
17 #include "core/named_func.hpp"
18 #include "core/plot_maker.hpp"
19 #include "core/plot_opt.hpp"
20 #include "core/palette.hpp"
21 #include "core/table.hpp"
22 #include "core/hist1d.hpp"
23 #include "core/event_scan.hpp"
24 
25 using namespace std;
26 using namespace PlotOptTypes;
27 
28 namespace{
29  bool single_thread = false;
30 }
31 
32 void GetOptions(int argc, char *argv[]);
33 
34 int main(int argc, char *argv[]){
35  gErrorIgnoreLevel = 6000;
36  GetOptions(argc, argv);
37 
38  double lumi = 2.7;
39 
40  string trig_skim_mc = "/net/cms2/cms2r0/babymaker/babies/2016_06_14/mc/skim_nleps2/";
41 
42  Palette colors("txt/colors.txt", "default");
43 
44  auto dy = Process::MakeShared<Baby_full>("Drell Yan", Process::Type::background, colors("wjets"),
45  {trig_skim_mc+"*DYJetsToLL*.root"},"stitch");
46  auto diboson = Process::MakeShared<Baby_full>("WW,ZZ,WZ", Process::Type::background, colors("single_t"),
47  {trig_skim_mc+"*_WWTo*.root",trig_skim_mc+"*_WZTo*.root", trig_skim_mc+"_ZZ_*.root"});
48  auto tt = Process::MakeShared<Baby_full>("t#bar{t}", Process::Type::background, colors("tt_2l"),
49  {trig_skim_mc+"*_TTJets*Lept*.root", trig_skim_mc+"*_TTJets_HT*.root"},
50  "stitch");
51  auto wjets = Process::MakeShared<Baby_full>("W+jets", Process::Type::background, colors("ttv"),
52  {trig_skim_mc+"*_WJetsToLNu*.root"});
53 
54  //auto wjets = Process::MakeShared<Baby_full>("W+jets", Process::Type::background, colors("wjets"),
55  // {trig_skim_mc+"*_WJetsToLNu*.root"});
56  //auto single_t = Process::MakeShared<Baby_full>("Single t", Process::Type::background, colors("single_t"),
57  // {trig_skim_mc+"*_ST_*.root"});
58  /* auto ttv = Process::MakeShared<Baby_full>("t#bar{t}V", Process::Type::background, colors("ttv"),
59  {trig_skim_mc+"*_TTWJets*.root", trig_skim_mc+"*_TTZTo*.root"});*/
60  auto other = Process::MakeShared<Baby_full>("Other", Process::Type::background, colors("other"),
61  {/*trig_skim_mc+"*_WJetsToLNu*.root",*/ trig_skim_mc+"*_QCD_HT*.root",
62  trig_skim_mc+"*_ZJet*.root",/* trig_skim_mc+"*_WWTo*.root",*/
63  trig_skim_mc+"*ggZH_HToBB*.root", trig_skim_mc+"*ttHJetTobb*.root",
64  trig_skim_mc+"*_TTGJets*.root", trig_skim_mc+"*_TTTT_*.root",
65  trig_skim_mc+"*_WH_HToBB*.root"/*, trig_skim_mc+"*_WZTo*.root"*/,
66  trig_skim_mc+"*_ZH_HToBB*.root",trig_skim_mc+"*_ST_*.root"/*, trig_skim_mc+"_ZZ_*.root"*/
67  ,trig_skim_mc+"*_TTWJets*.root", trig_skim_mc+"*_TTZTo*.root"});
68 
69  auto t1tttt_nc = Process::MakeShared<Baby_full>("T1tttt(1500,100)", Process::Type::signal, colors("t1tttt"),
70  {trig_skim_mc+"*SMS-T1tttt_mGluino-1500_mLSP-100*.root"});
71  auto t1tttt_c = Process::MakeShared<Baby_full>("T1tttt(1200,800)", Process::Type::signal, colors("t1tttt"),
72  {trig_skim_mc+"*SMS-T1tttt_mGluino-1200_mLSP-800*.root"});
73  t1tttt_c->SetLineStyle(2);
74 
75  auto data = Process::MakeShared<Baby_full>("Data", Process::Type::data, kBlack,
76  {"/net/cms2/cms2r0/babymaker/babies/2016_06_26/data/skim_nleps2/*.root"},"json2p6&&pass&&(trig[20]||trig[21]||trig[23]||trig[29]||trig[24]||trig[4]||trig[8]||trig[13]||trig[33])");
77 
78  auto data_ee = Process::MakeShared<Baby_full>("Data, ee", Process::Type::data, kBlack,
79  {"/net/cms2/cms2r0/babymaker/babies/2016_06_26/data/skim_nleps2/*.root"},"nels==2&&elel_m>60&&json2p6&&pass&&(trig[20]||trig[21]||trig[23]||trig[29]||trig[24]||trig[4]||trig[8]||trig[13]||trig[33])");
80 
81  auto data_mumu = Process::MakeShared<Baby_full>("Data, #mu#mu", Process::Type::background, 30,
82  {"/net/cms2/cms2r0/babymaker/babies/2016_06_26/data/skim_nleps2/*.root"},"nmus==2&&mumu_m>60&&json2p6&&pass&&(trig[20]||trig[21]||trig[23]||trig[29]||trig[24]||trig[4]||trig[8]||trig[13]||trig[33])");
83 
84  vector<shared_ptr<Process> > full_trig_skim = {data, t1tttt_nc, t1tttt_c, dy, diboson, tt, wjets, other};
85  vector<shared_ptr<Process> > ee_vs_mumu = {data_ee,data_mumu};
86  PlotOpt log_lumi("txt/plot_styles.txt", "CMSPaper");
87  log_lumi.Title(TitleType::preliminary)
88  .Bottom(BottomType::ratio)
89  .YAxis(YAxisType::log)
90  .Stack(StackType::data_norm);
91  PlotOpt lin_lumi = log_lumi().YAxis(YAxisType::linear);
92  PlotOpt log_shapes = log_lumi().Stack(StackType::shapes)
93  .Bottom(BottomType::off)
94  .ShowBackgroundError(false);
95  PlotOpt lin_shapes = log_shapes().YAxis(YAxisType::linear);
96  PlotOpt log_lumi_info = log_lumi().Title(TitleType::info);
97  PlotOpt lin_lumi_info = lin_lumi().Title(TitleType::info);
98  PlotOpt log_shapes_info = log_shapes().Title(TitleType::info).Bottom(BottomType::ratio);
99  PlotOpt lin_shapes_info = lin_shapes().Title(TitleType::info).Bottom(BottomType::ratio);
100  vector<PlotOpt> all_plot_types = {log_lumi, lin_lumi, log_shapes, lin_shapes,
101  log_lumi_info, lin_lumi_info, log_shapes_info, lin_shapes_info};
102  vector<PlotOpt> norms = {log_lumi_info, lin_lumi_info};
103  vector<PlotOpt> shapes = {lin_shapes_info,log_shapes_info};
104 
105  PlotMaker pm;
106  double pi = acos(-1.);
107 
108  NamedFunc dphi_ll("dphi_ll", [](const Baby &b) -> NamedFunc::ScalarType{
109  double phi1, eta1, phi2, eta2;
110  GetAngles(b, phi1, eta1, phi2, eta2);
111  if(phi1 == -999 || phi2 == -999) return -1.;
112  return fabs(TVector2::Phi_mpi_pi(phi2-phi1));
113  });
114  NamedFunc min_dphi_lmet("min_dphi_lmet", MinDeltaPhiLepMet);
115  NamedFunc max_dphi_lmet("max_dphi_lmet", MaxDeltaPhiLepMet);
116  NamedFunc min_dphi_lj("min_dphi_lj", MinDeltaPhiLepJet);
117  NamedFunc max_dphi_lj("max_dphi_lj", MaxDeltaPhiLepJet);
118  NamedFunc min_dphi_metj("min_dphi_metj", MinDeltaPhiMetJet);
119  NamedFunc max_dphi_metj("max_dphi_metj", MaxDeltaPhiMetJet);
120 
121  NamedFunc dr_ll("dr_ll", [](const Baby &b) -> NamedFunc::ScalarType{
122  double phi1, eta1, phi2, eta2;
123  GetAngles(b, phi1, eta1, phi2, eta2);
124  if(phi1 == -999 || phi2 == -999) return -1.;
125  return hypot(TVector2::Phi_mpi_pi(phi2-phi1), eta2-eta1);
126  });
127  NamedFunc min_dr_lj("min_dr_lj", MinDeltaRLepJet);
128  NamedFunc max_dr_lj("max_dr_lj", MaxDeltaRLepJet);
129 
130  string selections[] = {"nleps==2&&ht<200&&njets<=2&&nbl==0&&met<500&&leps_pt[0]>120",
131  "nleps==2&&ht>200&&njets<=2&&nbl==0&&met<500&&leps_pt[0]>120",
132  "nleps==2&&ht<200&&njets<=2&&nbl==0&&met<500&&leps_pt[0]>120&&met>200",
133  "nleps==2&&ht>200&&njets<=2&&nbl==0&&met<500&&leps_pt[0]>120&&met>200",
134  /*"nleps==2&&ht>200&&njets<=2&&nbl==0&&met<500&&(elel_m+mumu_m+999)>200&&leps_pt[0]>120"*/};
135 
136  string leps[] = {"&&nels==1&&nmus==1","&&nels==2&&elel_m>60","&&nmus==2&&mumu_m>60"/*,"&&nmus==2&&mumu_m>200","&&nels==2&&elel_m>200","&&nels==1&&nmus==1"*/};
137 
138  pm.Push<Hist1D>(Axis(50,0,500, "elel_m", "m_{el el} [GeV]", {60.}), "nels==2&&ht>200&&njets<=2&&nbl==0&&met<500&&leps_pt[0]>120", full_trig_skim, norms);
139  pm.Push<Hist1D>(Axis(20,0,1000, "mumu_m", "m_{mu mu} [GeV]", {60.}), "nmus==2&&ht>200&&njets<=2&&nbl==0&&met<500&&leps_pt[0]>120", full_trig_skim, norms);
140 
141  for(unsigned int ilep=0;ilep<1;ilep++){
142  pm.Push<Hist1D>(Axis(30,0,600, "leps_pt[0]", "Leading lepton p_{T}", {120.}), "nleps==2&&ht>200&&nbl==0&&njets<=2&&met<500"+leps[ilep], full_trig_skim, norms);
143  pm.Push<Hist1D>(Axis(20,0,1000, "ht", "H_{T}", {200.}), "nleps==2&&nbl==0&&njets<=2&&met<500&&leps_pt[0]>120"+leps[ilep], full_trig_skim, norms);
144  pm.Push<Hist1D>(Axis(5,-0.5,4.5, "nbl", "N_{b, loose}", {0.5}), "nleps==2&&ht>200&&njets<=2&&met<500&&leps_pt[0]>120"+leps[ilep], full_trig_skim, norms);
145  pm.Push<Hist1D>(Axis(9,-0.5,8.5, "njets", "N_{jets}", {2.5}), "nleps==2&&ht>200&&nbl==0&&met<500&&leps_pt[0]>120"+leps[ilep], full_trig_skim, norms);
146  }
147 
148  pm.Push<Hist1D>(Axis(50,0,500, "elel_m", "m_{el el} [GeV]", {60.}), "nels==2&&ht<200&&njets<=2&&nbl==0&&met<500&&leps_pt[0]>120", full_trig_skim, norms);
149  pm.Push<Hist1D>(Axis(20,0,1000, "mumu_m", "m_{mu mu} [GeV]", {60.}), "nmus==2&&ht<200&&njets<=2&&nbl==0&&met<500&&leps_pt[0]>120", full_trig_skim, norms);
150 
151  for(unsigned int ilep=0;ilep<2;ilep++){
152  pm.Push<Hist1D>(Axis(30,0,600, "leps_pt[0]", "Leading lepton p_{T}", {120.}), "nleps==2&&ht<200&&nbl==0&&njets<=2&&met<500"+leps[ilep], full_trig_skim, norms);
153  pm.Push<Hist1D>(Axis(20,0,1000, "ht", "H_{T}",{200.}),"nleps==2&&nbl==0&&njets<=2&&met<500&&leps_pt[0]>120"+leps[ilep], full_trig_skim, norms);
154  pm.Push<Hist1D>(Axis(5,-0.5,4.5, "nbl", "N_{b, loose}",{0.5}),"nleps==2&&ht<200&&njets<=2&&met<500&&leps_pt[0]>120"+leps[ilep], full_trig_skim, norms);
155  pm.Push<Hist1D>(Axis(9,-0.5,8.5, "njets", "N_{jets}",{2.5}),"nleps==2&&ht<200&&nbl==0&&met<500&&leps_pt[0]>120"+leps[ilep], full_trig_skim, norms);
156  }
157 
158  for(unsigned int isel=0;isel<2;isel++){
159  for(unsigned int ilep=0;ilep<2;ilep++){
160  pm.Push<Hist1D>(Axis(8,0,800, "mj14", "M_{J} [GeV]", {250.,400.}), selections[isel]+leps[ilep], full_trig_skim, norms);
161  pm.Push<Hist1D>(Axis(10,0,500, "met", "MET [GeV]", {350.}), selections[isel]+leps[ilep], full_trig_skim, norms);
162  pm.Push<Hist1D>(Axis(20,0,1000, "leps_pt[0]", "Leading lepton p_{T} [GeV]", {20.}), selections[isel]+leps[ilep], full_trig_skim, norms);
163  pm.Push<Hist1D>(Axis(25,0,500, "mt", "m_{T} [GeV]", {140.}), selections[isel]+leps[ilep], full_trig_skim, norms);
164  pm.Push<Hist1D>(Axis(20, 0., pi, min_dphi_lmet, "Min. #Delta#phi(l,MET)"), selections[isel]+leps[ilep], full_trig_skim, norms);
165  pm.Push<Hist1D>(Axis(20, 0., pi, max_dphi_lmet, "Max. #Delta#phi(l,MET)"), selections[isel]+leps[ilep], full_trig_skim, norms);
166  //pm.Push<Hist1D>(Axis(20,0,40, "npv", "N_{PV}", selections[isel]+leps[ilep]), full_trig_skim, norms);
167  if(ilep==1) pm.Push<Hist1D>(Axis(20,0,1000, "elel_m", "m_{el el} [GeV]", {90.}), selections[isel]+leps[ilep], full_trig_skim, norms);
168  if(ilep==0) pm.Push<Hist1D>(Axis(20,0,1000, "elmu_m", "m_{el mu} [GeV]", {90.}), selections[isel]+leps[ilep], full_trig_skim, norms);
169  if(ilep==2) pm.Push<Hist1D>(Axis(20,0,1000, "mumu_m", "m_{mu mu} [GeV]", {90.}), selections[isel]+leps[ilep], full_trig_skim, norms);
170  }
171  }
172 
173  PlotMaker pm_data;
174  for(unsigned int isel=0;isel<2;isel++){
175  pm_data.Push<Hist1D>(Axis(10,0,500, "mj14", "MJ 1.4 with leptons [GeV]", {350.}), selections[isel], ee_vs_mumu, norms);
176  pm_data.Push<Hist1D>(Axis(10,0,500, "met", "MET [GeV]", {350.}), selections[isel], ee_vs_mumu, norms);
177  pm_data.Push<Hist1D>(Axis(20,0,1000, "leps_pt[0]", "Leading lepton p_{T} [GeV]", {20.}), selections[isel], ee_vs_mumu, norms);
178  pm_data.Push<Hist1D>(Axis(25,0,500, "mt", "m_{T} [GeV]", {140.}), selections[isel], ee_vs_mumu, norms);
179  pm_data.Push<Hist1D>(Axis(20, 0., pi, min_dphi_lmet, "Min. #Delta#phi(l,MET)"), selections[isel], ee_vs_mumu, norms);
180  pm_data.Push<Hist1D>(Axis(20, 0., pi, max_dphi_lmet, "Max. #Delta#phi(l,MET)"), selections[isel], ee_vs_mumu, norms);
181  // if(ilep==0)
182  pm_data.Push<Hist1D>(Axis(20,0,1000, "elel_m+mumu_m+999", "m_{lep lep} [GeV]", {90.}), selections[isel], ee_vs_mumu, norms);
183  // if(ilep==1) pm.Push<Hist1D>(Axis(20,0,1000, "elmu_m", "m_{el mu} [GeV]", {90.}), selections[isel]+leps[ilep], ee_vs_mumu, shapes);
184  // if(ilep==2) pm.Push<Hist1D>(Axis(20,0,1000, "mumu_m", "m_{mu mu} [GeV]", {90.}), selections[isel]+leps[ilep], ee_vs_mumu, shapes);
185 
186  }
187 
188  if(single_thread) pm.multithreaded_ = false;
189  pm.MakePlots(lumi);
190  cout<<lumi<<endl;
191  if(single_thread) pm_data.multithreaded_ = false;
192  pm_data.MakePlots(1.0);
193 }
194 
195 bool IsGoodMuon(const Baby &b, size_t imu){
196  return imu<b.mus_pt()->size()
197  && b.mus_pt()->at(imu)>20.
198  && fabs(b.mus_eta()->at(imu))<2.4
199  && b.mus_sigid()->at(imu)
200  && b.mus_miniso()->at(imu) >= 0.
201  && b.mus_miniso()->at(imu) < 0.2;
202 }
203 
204 bool IsGoodElectron(const Baby &b, size_t iel){
205  return iel<b.els_pt()->size()
206  && b.els_pt()->at(iel)>20.
207  && fabs(b.els_sceta()->at(iel))<2.5
208  && b.els_sigid()->at(iel)
209  && b.els_miniso()->at(iel) >= 0.
210  && b.els_miniso()->at(iel) < 0.1;
211 }
212 
213 bool IsGoodTrack(const Baby &b, size_t itk){
214  if(itk >= b.tks_pt()->size()) return false;
215 
216  if(fabs(b.tks_pdg()->at(itk))==211 && b.tks_pt()->at(itk)>15. && b.tks_miniso()->at(itk)<0.1 && b.tks_mt2()->at(itk)<60 && b.tks_dz()->at(itk)<0.07 && b.tks_d0()->at(itk)<0.05 ){
217  return true;
218  }else if(fabs(b.tks_pdg()->at(itk))==13 && b.tks_pt()->at(itk)>10. && b.tks_miniso()->at(itk)<0.2 && b.tks_mt2()->at(itk)<80 && b.tks_dz()->at(itk)<0.07 && b.tks_d0()->at(itk)<0.05){
219  return true;
220  }else if(fabs(b.tks_pdg()->at(itk))==11 && b.tks_pt()->at(itk)>10. && b.tks_miniso()->at(itk)<0.2 && b.tks_mt2()->at(itk)<80 && b.tks_dz()->at(itk)<0.07 && b.tks_d0()->at(itk)<0.05){
221  return true;
222  }else{
223  return false;
224  }
225 }
226 
227 bool IsGoodJet(const Baby &b, size_t ijet){
228  if(ijet >= b.jets_pt()->size()) return false;
229 
230  return b.jets_pt()->at(ijet) > 30.
231  && b.jets_eta()->at(ijet) < 2.
232  && !b.jets_islep()->at(ijet);
233 }
234 
235 void GetAngles(const Baby &b,
236  double &phi1, double &eta1,
237  double &phi2, double &eta2){
238  phi1 = -999.; eta1 = -999.;
239  phi2 = -999.; eta2 = -999.;
240  bool h1=false, h2=false;
241  if(b.nels()==2 && b.nmus()==0){
242  for(size_t iel = 0; iel < b.els_pt()->size() && !(h1&&h2); ++iel){
243  if(IsGoodElectron(b, iel)){
244  if(!h1){
245  phi1 = b.els_phi()->at(iel);
246  eta1 = b.els_sceta()->at(iel);
247  h1 = true;
248  }else if(!h2){
249  phi2 = b.els_phi()->at(iel);
250  eta2 = b.els_sceta()->at(iel);
251  h2 = true;
252  }
253  }
254  }
255  }else if(b.nels()==1 && b.nmus()==1){
256  for(size_t iel = 0; iel < b.els_pt()->size() && !h1; ++iel){
257  if(IsGoodElectron(b, iel)){
258  if(!h1){
259  phi1 = b.els_phi()->at(iel);
260  eta1 = b.els_sceta()->at(iel);
261  h1 = true;
262  }else if(!h2){
263  phi2 = b.els_phi()->at(iel);
264  eta2 = b.els_sceta()->at(iel);
265  h2 = true;
266  }
267  }
268  }
269  for(size_t imu = 0; imu < b.mus_pt()->size() && h1 && !h2; ++imu){
270  if(IsGoodMuon(b, imu)){
271  if(!h1){
272  phi1 = b.mus_phi()->at(imu);
273  eta1 = b.mus_eta()->at(imu);
274  h1 = true;
275  }else if(!h2){
276  phi2 = b.mus_phi()->at(imu);
277  eta2 = b.mus_eta()->at(imu);
278  h2 = true;
279  }
280  }
281  }
282  }else if(b.nels()==0 && b.nmus()==2){
283  for(size_t imu = 0; imu < b.mus_pt()->size() && !(h1&&h2); ++imu){
284  if(IsGoodMuon(b, imu)){
285  if(!h1){
286  phi1 = b.mus_phi()->at(imu);
287  eta1 = b.mus_eta()->at(imu);
288  h1 = true;
289  }else if(!h2){
290  phi2 = b.mus_phi()->at(imu);
291  eta2 = b.mus_eta()->at(imu);
292  h2 = true;
293  }
294  }
295  }
296  }else if(b.nels()==1 && b.nmus()==0 && b.nveto()==1){
297  for(size_t iel = 0; iel < b.els_pt()->size() && !h1; ++iel){
298  if(IsGoodElectron(b, iel)){
299  if(!h1){
300  phi1 = b.els_phi()->at(iel);
301  eta1 = b.els_sceta()->at(iel);
302  h1 = true;
303  }else if(!h2){
304  phi2 = b.els_phi()->at(iel);
305  eta2 = b.els_sceta()->at(iel);
306  h2 = true;
307  }
308  }
309  }
310  for(size_t itk = 0; itk < b.tks_pt()->size() && h1 && !h2; ++itk){
311  if(IsGoodTrack(b, itk)){
312  if(!h1){
313  phi1 = b.tks_phi()->at(itk);
314  eta1 = b.tks_eta()->at(itk);
315  h1 = true;
316  }else if(!h2){
317  phi2 = b.tks_phi()->at(itk);
318  eta2 = b.tks_eta()->at(itk);
319  h2 = true;
320  }
321  }
322  }
323  }else if(b.nels()==0 && b.nmus()==1 && b.nveto()==1){
324  for(size_t imu = 0; imu < b.mus_pt()->size() && !h1; ++imu){
325  if(IsGoodMuon(b, imu)){
326  if(!h1){
327  phi1 = b.mus_phi()->at(imu);
328  eta1 = b.mus_eta()->at(imu);
329  h1 = true;
330  }else if(!h2){
331  phi2 = b.mus_phi()->at(imu);
332  eta2 = b.mus_eta()->at(imu);
333  h2 = true;
334  }
335  }
336  }
337  for(size_t itk = 0; itk < b.tks_pt()->size() && h1 && !h2; ++itk){
338  if(IsGoodTrack(b, itk)){
339  if(!h1){
340  phi1 = b.tks_phi()->at(itk);
341  eta1 = b.tks_eta()->at(itk);
342  h1 = true;
343  }else if(!h2){
344  phi2 = b.tks_phi()->at(itk);
345  eta2 = b.tks_eta()->at(itk);
346  h2 = true;
347  }
348  }
349  }
350  }
351 }
352 
354  double phi1, eta1, phi2, eta2;
355  GetAngles(b, phi1, eta1, phi2, eta2);
356  double dphi1 = fabs(TVector2::Phi_mpi_pi(phi1-b.met_phi()));
357  double dphi2 = fabs(TVector2::Phi_mpi_pi(phi2-b.met_phi()));
358  if(phi1 != -999 && phi2 != -999){
359  return std::min(dphi1,dphi2);
360  }else if(phi1 != -999 && phi2 == -999){
361  return dphi1;
362  }else if(phi1 == -999 && phi2 != -999){
363  return dphi2;
364  }
365  return -1;
366 }
367 
369  double phi1, eta1, phi2, eta2;
370  GetAngles(b, phi1, eta1, phi2, eta2);
371  double dphi1 = fabs(TVector2::Phi_mpi_pi(phi1-b.met_phi()));
372  double dphi2 = fabs(TVector2::Phi_mpi_pi(phi2-b.met_phi()));
373  if(phi1 != -999 && phi2 != -999){
374  return std::max(dphi1,dphi2);
375  }else if(phi1 != -999 && phi2 == -999){
376  return dphi1;
377  }else if(phi1 == -999 && phi2 != -999){
378  return dphi2;
379  }
380  return -1;
381 }
382 
384  double phi1, eta1, phi2, eta2;
385  GetAngles(b, phi1, eta1, phi2, eta2);
386  double minphi = -1.;
387  for(size_t ijet = 0; ijet < b.jets_pt()->size(); ++ijet){
388  if(!IsGoodJet(b,ijet)) continue;
389  double dphi1 = fabs(TVector2::Phi_mpi_pi(phi1-b.jets_phi()->at(ijet)));
390  double dphi2 = fabs(TVector2::Phi_mpi_pi(phi2-b.jets_phi()->at(ijet)));
391  double thisdphi = -1;
392  if(phi1 != -999 && phi2 != -999){
393  thisdphi = std::min(dphi1, dphi2);
394  }else if(phi1 != -999 && phi2 == -999){
395  thisdphi = dphi1;
396  }else if(phi1 == -999 && phi2 != -999){
397  thisdphi = dphi2;
398  }
399  if(minphi < 0. || thisdphi < minphi){
400  minphi = thisdphi;
401  }
402  }
403  return minphi;
404 }
405 
407  double phi1, eta1, phi2, eta2;
408  GetAngles(b, phi1, eta1, phi2, eta2);
409  double maxphi = -1.;
410  for(size_t ijet = 0; ijet < b.jets_pt()->size(); ++ijet){
411  if(!IsGoodJet(b,ijet)) continue;
412  double dphi1 = fabs(TVector2::Phi_mpi_pi(phi1-b.jets_phi()->at(ijet)));
413  double dphi2 = fabs(TVector2::Phi_mpi_pi(phi2-b.jets_phi()->at(ijet)));
414  double thisdphi = -1;
415  if(phi1 != -999 && phi2 != -999){
416  thisdphi = std::max(dphi1, dphi2);
417  }else if(phi1 != -999 && phi2 == -999){
418  thisdphi = dphi1;
419  }else if(phi1 == -999 && phi2 != -999){
420  thisdphi = dphi2;
421  }
422  if(maxphi < 0. || thisdphi > maxphi){
423  maxphi = thisdphi;
424  }
425  }
426  return maxphi;
427 }
428 
430  double minphi = -1.;
431  for(size_t ijet = 0; ijet < b.jets_pt()->size(); ++ijet){
432  if(!IsGoodJet(b,ijet)) continue;
433  double thisdphi = fabs(TVector2::Phi_mpi_pi(b.met_phi()-b.jets_phi()->at(ijet)));
434  if(minphi < 0. || thisdphi < minphi){
435  minphi = thisdphi;
436  }
437  }
438  return minphi;
439 }
440 
442  double maxphi = -1.;
443  for(size_t ijet = 0; ijet < b.jets_pt()->size(); ++ijet){
444  if(!IsGoodJet(b,ijet)) continue;
445  double thisdphi = fabs(TVector2::Phi_mpi_pi(b.met_phi()-b.jets_phi()->at(ijet)));
446  if(maxphi < 0. || thisdphi > maxphi){
447  maxphi = thisdphi;
448  }
449  }
450  return maxphi;
451 }
452 
454  double phi1, eta1, phi2, eta2;
455  GetAngles(b, phi1, eta1, phi2, eta2);
456  double minr = -1.;
457  for(size_t ijet = 0; ijet < b.jets_pt()->size(); ++ijet){
458  if(!IsGoodJet(b,ijet)) continue;
459  double dr1 = hypot(TVector2::Phi_mpi_pi(phi1-b.jets_phi()->at(ijet)), eta2-eta1);
460  double dr2 = hypot(TVector2::Phi_mpi_pi(phi2-b.jets_phi()->at(ijet)), eta2-eta1);
461  double thisdr = -1;
462  if(phi1 != -999 && phi2 != -999){
463  thisdr = std::min(dr1, dr2);
464  }else if(phi1 != -999 && phi2 == -999){
465  thisdr = dr1;
466  }else if(phi1 == -999 && phi2 != -999){
467  thisdr = dr2;
468  }
469  if(minr < 0. || thisdr < minr){
470  minr = thisdr;
471  }
472  }
473  return minr;
474 }
475 
477  double phi1, eta1, phi2, eta2;
478  GetAngles(b, phi1, eta1, phi2, eta2);
479  double maxr = -1.;
480  for(size_t ijet = 0; ijet < b.jets_pt()->size(); ++ijet){
481  if(!IsGoodJet(b,ijet)) continue;
482  double dr1 = hypot(TVector2::Phi_mpi_pi(phi1-b.jets_phi()->at(ijet)), eta2-eta1);
483  double dr2 = hypot(TVector2::Phi_mpi_pi(phi2-b.jets_phi()->at(ijet)), eta2-eta1);
484  double thisdr = -1;
485  if(phi1 != -999 && phi2 != -999){
486  thisdr = std::max(dr1, dr2);
487  }else if(phi1 != -999 && phi2 == -999){
488  thisdr = dr1;
489  }else if(phi1 == -999 && phi2 != -999){
490  thisdr = dr2;
491  }
492  if(maxr < 0. || thisdr > maxr){
493  maxr = thisdr;
494  }
495  }
496  return maxr;
497 }
498 
499 void GetOptions(int argc, char *argv[]){
500  while(true){
501  static struct option long_options[] = {
502  {"single_thread", no_argument, 0, 's'},
503  {0, 0, 0, 0}
504  };
505 
506  char opt = -1;
507  int option_index;
508  opt = getopt_long(argc, argv, "s", long_options, &option_index);
509 
510  if( opt == -1) break;
511 
512  string optname;
513  switch(opt){
514  case 's':
515  single_thread = true;
516  break;
517  case 0:
518  optname = long_options[option_index].name;
519  if(false){
520  }else{
521  printf("Bad option! Found option name %s\n", optname.c_str());
522  }
523  break;
524  default:
525  printf("Bad option! getopt_long returned character code 0%o\n", opt);
526  break;
527  }
528  }
529 }
std::vector< float > *const & mus_eta() const
Get mus_eta for current event and cache it.
Definition: baby.cpp:5525
bool IsGoodElectron(const Baby &b, size_t iel)
PlotOpt & Stack(PlotOptTypes::StackType stack_type)
Definition: plot_opt.cpp:120
PlotOpt & YAxis(PlotOptTypes::YAxisType y_axis_type)
Definition: plot_opt.cpp:102
std::vector< float > *const & els_pt() const
Get els_pt for current event and cache it.
Definition: baby.cpp:3461
std::vector< float > *const & mus_phi() const
Get mus_phi for current event and cache it.
Definition: baby.cpp:5621
std::vector< float > *const & jets_phi() const
Get jets_phi for current event and cache it.
Definition: baby.cpp:4277
NamedFunc::ScalarType MinDeltaPhiLepMet(const Baby &b)
Abstract base class for access to ntuple variables.
Definition: baby.hpp:16
std::vector< float > *const & tks_mt2() const
Get tks_mt2 for current event and cache it.
Definition: baby.cpp:7253
STL namespace.
NamedFunc::ScalarType MinDeltaPhiLepJet(const Baby &b)
std::vector< float > *const & mus_pt() const
Get mus_pt for current event and cache it.
Definition: baby.cpp:5633
Combines a callable function taking a Baby and returning a scalar or vector with its string represent...
Definition: named_func.hpp:13
float const & met_phi() const
Get met_phi for current event and cache it.
Definition: baby.cpp:4733
std::vector< float > *const & tks_eta() const
Get tks_eta for current event and cache it.
Definition: baby.cpp:7217
bool IsGoodJet(const Baby &b, size_t ijet)
bool IsGoodTrack(const Baby &b, size_t itk)
bool multithreaded_
Definition: plot_maker.hpp:43
std::vector< float > *const & els_miniso() const
Get els_miniso for current event and cache it.
Definition: baby.cpp:3437
NamedFunc::ScalarType MinDeltaPhiMetJet(const Baby &b)
double ScalarType
Definition: named_func.hpp:15
int main(int argc, char *argv[])
NamedFunc::ScalarType MaxDeltaPhiMetJet(const Baby &b)
int const & nmus() const
Get nmus for current event and cache it.
Definition: baby.cpp:6077
std::vector< float > *const & tks_d0() const
Get tks_d0 for current event and cache it.
Definition: baby.cpp:7193
FigureType & Push(Args &&...args)
Definition: plot_maker.hpp:24
std::vector< float > *const & els_phi() const
Get els_phi for current event and cache it.
Definition: baby.cpp:3449
bool IsGoodMuon(const Baby &b, size_t imu)
Definition: axis.hpp:12
void GetOptions(int argc, char *argv[])
std::vector< float > *const & jets_eta() const
Get jets_eta for current event and cache it.
Definition: baby.cpp:4121
void GetAngles(const Baby &b, double &phi1, double &eta1, double &phi2, double &eta2)
std::vector< bool > *const & mus_sigid() const
Get mus_sigid for current event and cache it.
Definition: baby.cpp:5681
std::vector< bool > *const & els_sigid() const
Get els_sigid for current event and cache it.
Definition: baby.cpp:3509
Organizes efficient production of plots with single loop over each process.
Definition: plot_maker.hpp:14
std::vector< float > *const & tks_miniso() const
Get tks_miniso for current event and cache it.
Definition: baby.cpp:7229
std::vector< float > *const & tks_pt() const
Get tks_pt for current event and cache it.
Definition: baby.cpp:7289
PlotOpt & Bottom(PlotOptTypes::BottomType bottom_type)
Definition: plot_opt.cpp:93
std::vector< float > *const & els_sceta() const
Get els_sceta for current event and cache it.
Definition: baby.cpp:3485
std::vector< float > *const & tks_phi() const
Get tks_phi for current event and cache it.
Definition: baby.cpp:7277
NamedFunc::ScalarType MaxDeltaPhiLepMet(const Baby &b)
PlotOpt & ShowBackgroundError(bool show_background_error)
Definition: plot_opt.cpp:386
int const & nels() const
Get nels for current event and cache it.
Definition: baby.cpp:5897
int const & nveto() const
Get nveto for current event and cache it.
Definition: baby.cpp:6257
std::vector< int > *const & tks_pdg() const
Get tks_pdg for current event and cache it.
Definition: baby.cpp:7265
A full 1D plot with stacked/overlayed histograms.
Definition: hist1d.hpp:23
std::vector< float > *const & jets_pt() const
Get jets_pt for current event and cache it.
Definition: baby.cpp:4289
std::vector< float > *const & mus_miniso() const
Get mus_miniso for current event and cache it.
Definition: baby.cpp:5585
std::vector< float > *const & tks_dz() const
Get tks_dz for current event and cache it.
Definition: baby.cpp:7205
NamedFunc::ScalarType MinDeltaRLepJet(const Baby &b)
NamedFunc::ScalarType MaxDeltaPhiLepJet(const Baby &b)
std::vector< bool > *const & jets_islep() const
Get jets_islep for current event and cache it.
Definition: baby.cpp:4253
void MakePlots(double luminosity, const std::string &subdir="")
Prints all added plots with given luminosity.
Definition: plot_maker.cpp:54
PlotOpt & Title(PlotOptTypes::TitleType title_type)
Definition: plot_opt.cpp:111
NamedFunc::ScalarType MaxDeltaRLepJet(const Baby &b)
Loads colors from a text configuration file.
Definition: palette.hpp:8