15 #include "core/baby.hpp" 34 int main(
int argc,
char *argv[]){
35 gErrorIgnoreLevel = 6000;
40 string trig_skim_mc =
"/net/cms2/cms2r0/babymaker/babies/2016_06_14/mc/skim_nleps2/";
42 Palette colors(
"txt/colors.txt",
"default");
45 {trig_skim_mc+
"*DYJetsToLL*.root"},
"stitch");
47 {trig_skim_mc+
"*_WWTo*.root",trig_skim_mc+
"*_WZTo*.root", trig_skim_mc+
"_ZZ_*.root"});
49 {trig_skim_mc+
"*_TTJets*Lept*.root", trig_skim_mc+
"*_TTJets_HT*.root"},
52 {trig_skim_mc+
"*_WJetsToLNu*.root"});
61 { trig_skim_mc+
"*_QCD_HT*.root",
62 trig_skim_mc+
"*_ZJet*.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",
66 trig_skim_mc+
"*_ZH_HToBB*.root",trig_skim_mc+
"*_ST_*.root" 67 ,trig_skim_mc+
"*_TTWJets*.root", trig_skim_mc+
"*_TTZTo*.root"});
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);
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])");
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])");
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])");
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)
89 .
YAxis(YAxisType::log)
90 .
Stack(StackType::data_norm);
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};
106 double pi = acos(-1.);
109 double phi1, eta1, phi2, eta2;
111 if(phi1 == -999 || phi2 == -999)
return -1.;
112 return fabs(TVector2::Phi_mpi_pi(phi2-phi1));
122 double phi1, eta1, phi2, eta2;
124 if(phi1 == -999 || phi2 == -999)
return -1.;
125 return hypot(TVector2::Phi_mpi_pi(phi2-phi1), eta2-eta1);
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",
136 string leps[] = {
"&&nels==1&&nmus==1",
"&&nels==2&&elel_m>60",
"&&nmus==2&&mumu_m>60"};
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);
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);
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);
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);
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);
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);
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);
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);
196 return imu<b.
mus_pt()->size()
197 && b.
mus_pt()->at(imu)>20.
198 && fabs(b.
mus_eta()->at(imu))<2.4
205 return iel<b.
els_pt()->size()
206 && b.
els_pt()->at(iel)>20.
214 if(itk >= b.
tks_pt()->size())
return false;
228 if(ijet >= b.
jets_pt()->size())
return false;
230 return b.
jets_pt()->at(ijet) > 30.
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;
242 for(
size_t iel = 0; iel < b.
els_pt()->size() && !(h1&&h2); ++iel){
255 }
else if(b.
nels()==1 && b.
nmus()==1){
256 for(
size_t iel = 0; iel < b.
els_pt()->size() && !h1; ++iel){
269 for(
size_t imu = 0; imu < b.
mus_pt()->size() && h1 && !h2; ++imu){
282 }
else if(b.
nels()==0 && b.
nmus()==2){
283 for(
size_t imu = 0; imu < b.
mus_pt()->size() && !(h1&&h2); ++imu){
297 for(
size_t iel = 0; iel < b.
els_pt()->size() && !h1; ++iel){
310 for(
size_t itk = 0; itk < b.
tks_pt()->size() && h1 && !h2; ++itk){
324 for(
size_t imu = 0; imu < b.
mus_pt()->size() && !h1; ++imu){
337 for(
size_t itk = 0; itk < b.
tks_pt()->size() && h1 && !h2; ++itk){
354 double 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){
362 }
else if(phi1 == -999 && phi2 != -999){
369 double 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){
377 }
else if(phi1 == -999 && phi2 != -999){
384 double phi1, eta1, phi2, eta2;
387 for(
size_t ijet = 0; ijet < b.
jets_pt()->size(); ++ijet){
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){
396 }
else if(phi1 == -999 && phi2 != -999){
399 if(minphi < 0. || thisdphi < minphi){
407 double phi1, eta1, phi2, eta2;
410 for(
size_t ijet = 0; ijet < b.
jets_pt()->size(); ++ijet){
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){
419 }
else if(phi1 == -999 && phi2 != -999){
422 if(maxphi < 0. || thisdphi > maxphi){
431 for(
size_t ijet = 0; ijet < b.
jets_pt()->size(); ++ijet){
433 double thisdphi = fabs(TVector2::Phi_mpi_pi(b.
met_phi()-b.
jets_phi()->at(ijet)));
434 if(minphi < 0. || thisdphi < minphi){
443 for(
size_t ijet = 0; ijet < b.
jets_pt()->size(); ++ijet){
445 double thisdphi = fabs(TVector2::Phi_mpi_pi(b.
met_phi()-b.
jets_phi()->at(ijet)));
446 if(maxphi < 0. || thisdphi > maxphi){
454 double phi1, eta1, phi2, eta2;
457 for(
size_t ijet = 0; ijet < b.
jets_pt()->size(); ++ijet){
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);
462 if(phi1 != -999 && phi2 != -999){
463 thisdr = std::min(dr1, dr2);
464 }
else if(phi1 != -999 && phi2 == -999){
466 }
else if(phi1 == -999 && phi2 != -999){
469 if(minr < 0. || thisdr < minr){
477 double phi1, eta1, phi2, eta2;
480 for(
size_t ijet = 0; ijet < b.
jets_pt()->size(); ++ijet){
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);
485 if(phi1 != -999 && phi2 != -999){
486 thisdr = std::max(dr1, dr2);
487 }
else if(phi1 != -999 && phi2 == -999){
489 }
else if(phi1 == -999 && phi2 != -999){
492 if(maxr < 0. || thisdr > maxr){
501 static struct option long_options[] = {
502 {
"single_thread", no_argument, 0,
's'},
508 opt = getopt_long(argc, argv,
"s", long_options, &option_index);
510 if( opt == -1)
break;
518 optname = long_options[option_index].name;
521 printf(
"Bad option! Found option name %s\n", optname.c_str());
525 printf(
"Bad option! getopt_long returned character code 0%o\n", opt);
std::vector< float > *const & mus_eta() const
Get mus_eta for current event and cache it.
bool IsGoodElectron(const Baby &b, size_t iel)
PlotOpt & Stack(PlotOptTypes::StackType stack_type)
PlotOpt & YAxis(PlotOptTypes::YAxisType y_axis_type)
std::vector< float > *const & els_pt() const
Get els_pt for current event and cache it.
std::vector< float > *const & mus_phi() const
Get mus_phi for current event and cache it.
std::vector< float > *const & jets_phi() const
Get jets_phi for current event and cache it.
NamedFunc::ScalarType MinDeltaPhiLepMet(const Baby &b)
Abstract base class for access to ntuple variables.
std::vector< float > *const & tks_mt2() const
Get tks_mt2 for current event and cache it.
NamedFunc::ScalarType MinDeltaPhiLepJet(const Baby &b)
std::vector< float > *const & mus_pt() const
Get mus_pt for current event and cache it.
Combines a callable function taking a Baby and returning a scalar or vector with its string represent...
float const & met_phi() const
Get met_phi for current event and cache it.
std::vector< float > *const & tks_eta() const
Get tks_eta for current event and cache it.
bool IsGoodJet(const Baby &b, size_t ijet)
bool IsGoodTrack(const Baby &b, size_t itk)
std::vector< float > *const & els_miniso() const
Get els_miniso for current event and cache it.
NamedFunc::ScalarType MinDeltaPhiMetJet(const Baby &b)
int main(int argc, char *argv[])
NamedFunc::ScalarType MaxDeltaPhiMetJet(const Baby &b)
int const & nmus() const
Get nmus for current event and cache it.
std::vector< float > *const & tks_d0() const
Get tks_d0 for current event and cache it.
FigureType & Push(Args &&...args)
std::vector< float > *const & els_phi() const
Get els_phi for current event and cache it.
bool IsGoodMuon(const Baby &b, size_t imu)
void GetOptions(int argc, char *argv[])
std::vector< float > *const & jets_eta() const
Get jets_eta for current event and cache it.
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.
std::vector< bool > *const & els_sigid() const
Get els_sigid for current event and cache it.
Organizes efficient production of plots with single loop over each process.
std::vector< float > *const & tks_miniso() const
Get tks_miniso for current event and cache it.
std::vector< float > *const & tks_pt() const
Get tks_pt for current event and cache it.
PlotOpt & Bottom(PlotOptTypes::BottomType bottom_type)
std::vector< float > *const & els_sceta() const
Get els_sceta for current event and cache it.
std::vector< float > *const & tks_phi() const
Get tks_phi for current event and cache it.
NamedFunc::ScalarType MaxDeltaPhiLepMet(const Baby &b)
PlotOpt & ShowBackgroundError(bool show_background_error)
int const & nels() const
Get nels for current event and cache it.
int const & nveto() const
Get nveto for current event and cache it.
std::vector< int > *const & tks_pdg() const
Get tks_pdg for current event and cache it.
A full 1D plot with stacked/overlayed histograms.
std::vector< float > *const & jets_pt() const
Get jets_pt for current event and cache it.
std::vector< float > *const & mus_miniso() const
Get mus_miniso for current event and cache it.
std::vector< float > *const & tks_dz() const
Get tks_dz for current event and cache it.
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.
void MakePlots(double luminosity, const std::string &subdir="")
Prints all added plots with given luminosity.
PlotOpt & Title(PlotOptTypes::TitleType title_type)
NamedFunc::ScalarType MaxDeltaRLepJet(const Baby &b)
Loads colors from a text configuration file.