18 gErrorIgnoreLevel = 6000;
22 Palette colors(
"txt/colors.txt",
"default");
24 string folder_mc =
"/net/cms2/cms2r0/babymaker/babies/2016_06_14/mc/merged_standard/";
26 {folder_mc+
"*_TTJets*Lept*.root", folder_mc+
"*_TTJets_HT*.root"},
"ntruleps<=1&&stitch");
28 {folder_mc+
"*_TTJets*Lept*.root", folder_mc+
"*_TTJets_HT*.root"},
"ntruleps>=2&&stitch");
30 {folder_mc+
"*_WJetsToLNu*.root"});
32 {folder_mc+
"*_ST_*.root"});
34 {folder_mc+
"*_TTWJets*.root", folder_mc+
"*_TTZTo*.root"});
36 {folder_mc+
"*DYJetsToLL*.root", folder_mc+
"*_QCD_HT*.root",
37 folder_mc+
"*_ZJet*.root", folder_mc+
"*_WWTo*.root",
38 folder_mc+
"*ggZH_HToBB*.root", folder_mc+
"*ttHJetTobb*.root",
39 folder_mc+
"*_TTGJets*.root", folder_mc+
"*_TTTT_*.root",
40 folder_mc+
"*_WH_HToBB*.root", folder_mc+
"*_WZTo*.root",
41 folder_mc+
"*_ZH_HToBB*.root", folder_mc+
"_ZZ_*.root"});
43 {
"/net/cms2/cms2r0/babymaker/babies/2016_06_21/data/skim_standard/*.root"},
44 "pass&&(trig[4]||trig[8]||trig[13]||trig[33])");
46 {
"/net/cms2/cms2r0/babymaker/babies/2016_04_29/data/merged_1lht500met200/*.root"},
47 "pass&&(trig[4]||trig[8]||trig[13]||trig[28])");
49 vector<shared_ptr<Process> > procs = {data_2016, data_2015,
tt1l,
tt2l, wjets, single_t, ttv, other};
51 PlotOpt log_lumi(
"txt/plot_styles.txt",
"CMSPaper");
52 log_lumi.
Title(TitleType::info)
54 .
YAxis(YAxisType::log)
55 .
Stack(StackType::data_norm);
57 vector<PlotOpt> plot_types = {log_lumi, lin_lumi};
60 double pi = acos(-1.);
62 NamedFunc baseline =
"met<=500&&nbm<=2&&ht>500&&met>200";
63 NamedFunc dilep_all = baseline &&
"(nleps==2&&njets>=4) || (nleps==1&&nveto==1&&njets>=5&&nbm>=1&&mt>140)";
64 NamedFunc dilep_ee = baseline &&
"nels==2&&nmus==0&&njets>=4";
65 NamedFunc dilep_em = baseline &&
"nels==1&&nmus==1&&njets>=4";
66 NamedFunc dilep_mm = baseline &&
"nels==0&&nmus==2&&njets>=4";
67 NamedFunc dilep_ev = baseline &&
"nels==1&&nmus==0&&nveto==1&&njets>=5&&nbm>=1&&mt>140";
68 NamedFunc dilep_mv = baseline &&
"nels==0&&nmus==1&&nveto==1&&njets>=5&&nbm>=1&&mt>140";
71 double phi1, eta1, phi2, eta2;
73 if(phi1 == -999 || phi2 == -999)
return -1.;
74 return fabs(TVector2::Phi_mpi_pi(phi2-phi1));
84 double phi1, eta1, phi2, eta2;
86 if(phi1 == -999 || phi2 == -999)
return -1.;
87 return hypot(TVector2::Phi_mpi_pi(phi2-phi1), eta2-eta1);
92 vector<pair<string, NamedFunc> > categories = {{
"all", dilep_all}, {
"ee", dilep_ee}, {
"em", dilep_em},
93 {
"mm", dilep_mm}, {
"ev", dilep_ev}, {
"mv", dilep_mv}};
95 for(
const auto &cat: categories){
96 std::string
tag =
"angles_"+cat.first;
99 pm.
Push<
Hist1D>(
Axis(20, 0., pi, dphi_ll,
"#Delta#phi(l,l)"), cut, procs, plot_types).Tag(tag);
100 pm.
Push<
Hist1D>(
Axis(20, 0., pi, min_dphi_lmet,
"Min. #Delta#phi(l,MET)"), cut, procs, plot_types).Tag(tag);
101 pm.
Push<
Hist1D>(
Axis(20, 0., pi, max_dphi_lmet,
"Max. #Delta#phi(l,MET)"), cut, procs, plot_types).Tag(tag);
102 pm.
Push<
Hist1D>(
Axis(20, 0., pi, min_dphi_lj,
"Min. #Delta#phi(l,jet)"), cut, procs, plot_types).Tag(tag);
103 pm.
Push<
Hist1D>(
Axis(20, 0., pi, max_dphi_lj,
"Max. #Delta#phi(l,jet)"), cut, procs, plot_types).Tag(tag);
104 pm.
Push<
Hist1D>(
Axis(20, 0., pi, min_dphi_metj,
"Min. #Delta#phi(MET,jet)"), cut, procs, plot_types).Tag(tag);
105 pm.
Push<
Hist1D>(
Axis(20, 0., pi, max_dphi_metj,
"Max. #Delta#phi(MET,jet)"), cut, procs, plot_types).Tag(tag);
107 pm.
Push<
Hist1D>(
Axis(20, 0., 6, dr_ll,
"#Delta R(l,l)"), cut, procs, plot_types).Tag(tag);
108 pm.
Push<
Hist1D>(
Axis(20, 0., 6, min_dr_lj,
"Min. #Delta R(l,jet)"), cut, procs, plot_types).Tag(tag);
109 pm.
Push<
Hist1D>(
Axis(20, 0., 6, max_dr_lj,
"Max. #Delta R(l,jet)"), cut, procs, plot_types).Tag(tag);
112 pm.
Push<
EventScan>(
"dilep_angle", dilep_mm || dilep_em, vector<NamedFunc>{
113 "run",
"lumiblock",
"event",
"nmus",
"nels",
"nveto",
114 dphi_ll, dr_ll, min_dphi_lmet, max_dphi_lmet, min_dphi_lj,
115 max_dphi_lj, min_dr_lj, max_dr_lj, min_dphi_metj, max_dphi_metj,
116 "mj14",
"mt",
"njets",
"nbm",
"met",
"met_phi",
"leps_pt",
117 "leps_phi",
"leps_eta",
"leps_id",
"jets_pt",
"jets_phi",
"jets_eta" 125 return imu<b.
mus_pt()->size()
126 && b.
mus_pt()->at(imu)>20.
127 && fabs(b.
mus_eta()->at(imu))<2.4
134 return iel<b.
els_pt()->size()
135 && b.
els_pt()->at(iel)>20.
143 if(itk >= b.
tks_pt()->size())
return false;
157 if(ijet >= b.
jets_pt()->size())
return false;
159 return b.
jets_pt()->at(ijet) > 30.
165 double &phi1,
double &eta1,
166 double &phi2,
double &eta2){
167 phi1 = -999.; eta1 = -999.;
168 phi2 = -999.; eta2 = -999.;
169 bool h1=
false, h2=
false;
171 for(
size_t iel = 0; iel < b.
els_pt()->size() && !(h1&&h2); ++iel){
184 }
else if(b.
nels()==1 && b.
nmus()==1){
185 for(
size_t iel = 0; iel < b.
els_pt()->size() && !h1; ++iel){
198 for(
size_t imu = 0; imu < b.
mus_pt()->size() && h1 && !h2; ++imu){
211 }
else if(b.
nels()==0 && b.
nmus()==2){
212 for(
size_t imu = 0; imu < b.
mus_pt()->size() && !(h1&&h2); ++imu){
226 for(
size_t iel = 0; iel < b.
els_pt()->size() && !h1; ++iel){
239 for(
size_t itk = 0; itk < b.
tks_pt()->size() && h1 && !h2; ++itk){
253 for(
size_t imu = 0; imu < b.
mus_pt()->size() && !h1; ++imu){
266 for(
size_t itk = 0; itk < b.
tks_pt()->size() && h1 && !h2; ++itk){
283 double phi1, eta1, phi2, eta2;
285 double dphi1 = fabs(TVector2::Phi_mpi_pi(phi1-b.
met_phi()));
286 double dphi2 = fabs(TVector2::Phi_mpi_pi(phi2-b.
met_phi()));
287 if(phi1 != -999 && phi2 != -999){
288 return std::min(dphi1,dphi2);
289 }
else if(phi1 != -999 && phi2 == -999){
291 }
else if(phi1 == -999 && phi2 != -999){
298 double phi1, eta1, phi2, eta2;
300 double dphi1 = fabs(TVector2::Phi_mpi_pi(phi1-b.
met_phi()));
301 double dphi2 = fabs(TVector2::Phi_mpi_pi(phi2-b.
met_phi()));
302 if(phi1 != -999 && phi2 != -999){
303 return std::max(dphi1,dphi2);
304 }
else if(phi1 != -999 && phi2 == -999){
306 }
else if(phi1 == -999 && phi2 != -999){
313 double phi1, eta1, phi2, eta2;
316 for(
size_t ijet = 0; ijet < b.
jets_pt()->size(); ++ijet){
318 double dphi1 = fabs(TVector2::Phi_mpi_pi(phi1-b.
jets_phi()->at(ijet)));
319 double dphi2 = fabs(TVector2::Phi_mpi_pi(phi2-b.
jets_phi()->at(ijet)));
320 double thisdphi = -1;
321 if(phi1 != -999 && phi2 != -999){
322 thisdphi = std::min(dphi1, dphi2);
323 }
else if(phi1 != -999 && phi2 == -999){
325 }
else if(phi1 == -999 && phi2 != -999){
328 if(minphi < 0. || thisdphi < minphi){
336 double phi1, eta1, phi2, eta2;
339 for(
size_t ijet = 0; ijet < b.
jets_pt()->size(); ++ijet){
341 double dphi1 = fabs(TVector2::Phi_mpi_pi(phi1-b.
jets_phi()->at(ijet)));
342 double dphi2 = fabs(TVector2::Phi_mpi_pi(phi2-b.
jets_phi()->at(ijet)));
343 double thisdphi = -1;
344 if(phi1 != -999 && phi2 != -999){
345 thisdphi = std::max(dphi1, dphi2);
346 }
else if(phi1 != -999 && phi2 == -999){
348 }
else if(phi1 == -999 && phi2 != -999){
351 if(maxphi < 0. || thisdphi > maxphi){
360 for(
size_t ijet = 0; ijet < b.
jets_pt()->size(); ++ijet){
362 double thisdphi = fabs(TVector2::Phi_mpi_pi(b.
met_phi()-b.
jets_phi()->at(ijet)));
363 if(minphi < 0. || thisdphi < minphi){
372 for(
size_t ijet = 0; ijet < b.
jets_pt()->size(); ++ijet){
374 double thisdphi = fabs(TVector2::Phi_mpi_pi(b.
met_phi()-b.
jets_phi()->at(ijet)));
375 if(maxphi < 0. || thisdphi > maxphi){
383 double phi1, eta1, phi2, eta2;
386 for(
size_t ijet = 0; ijet < b.
jets_pt()->size(); ++ijet){
388 double dr1 = hypot(TVector2::Phi_mpi_pi(phi1-b.
jets_phi()->at(ijet)), eta2-eta1);
389 double dr2 = hypot(TVector2::Phi_mpi_pi(phi2-b.
jets_phi()->at(ijet)), eta2-eta1);
391 if(phi1 != -999 && phi2 != -999){
392 thisdr = std::min(dr1, dr2);
393 }
else if(phi1 != -999 && phi2 == -999){
395 }
else if(phi1 == -999 && phi2 != -999){
398 if(minr < 0. || thisdr < minr){
406 double phi1, eta1, phi2, eta2;
409 for(
size_t ijet = 0; ijet < b.
jets_pt()->size(); ++ijet){
411 double dr1 = hypot(TVector2::Phi_mpi_pi(phi1-b.
jets_phi()->at(ijet)), eta2-eta1);
412 double dr2 = hypot(TVector2::Phi_mpi_pi(phi2-b.
jets_phi()->at(ijet)), eta2-eta1);
414 if(phi1 != -999 && phi2 != -999){
415 thisdr = std::max(dr1, dr2);
416 }
else if(phi1 != -999 && phi2 == -999){
418 }
else if(phi1 == -999 && phi2 != -999){
421 if(maxr < 0. || thisdr > maxr){
std::vector< float > *const & mus_eta() const
Get mus_eta for current event and cache it.
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.
bool IsGoodTrack(const Baby &b, size_t itk)
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.
Abstract base class for access to ntuple variables.
NamedFunc::ScalarType MaxDeltaRLepJet(const Baby &b)
std::vector< float > *const & tks_mt2() const
Get tks_mt2 for current event and cache it.
NamedFunc::ScalarType MaxDeltaPhiLepJet(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...
bool IsGoodMuon(const Baby &b, size_t imu)
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.
NamedFunc::ScalarType MaxDeltaPhiMetJet(const Baby &b)
std::vector< float > *const & els_miniso() const
Get els_miniso for current event and cache it.
bool IsGoodElectron(const Baby &b, size_t iel)
NamedFunc::ScalarType MaxDeltaPhiLepMet(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.
NamedFunc::ScalarType MinDeltaRLepJet(const Baby &b)
FigureType & Push(Args &&...args)
std::vector< float > *const & els_phi() const
Get els_phi for current event and cache it.
NamedFunc::ScalarType MinDeltaPhiLepJet(const Baby &b)
std::vector< float > *const & jets_eta() const
Get jets_eta for current event and cache it.
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.
void GetAngles(const Baby &b, double &phi1, double &eta1, double &phi2, double &eta2)
bool IsGoodJet(const Baby &b, size_t ijet)
Organizes efficient production of plots with single loop over each process.
NamedFunc::ScalarType MinDeltaPhiLepMet(const Baby &b)
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.
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 MinDeltaPhiMetJet(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)
Loads colors from a text configuration file.