11 #include "histo_stack.hpp" 19 gErrorIgnoreLevel = 6000;
21 chrono::high_resolution_clock::time_point begTime;
22 begTime = chrono::high_resolution_clock::now();
26 string hostname(
execute(
"echo $HOSTNAME"));
28 bfolder =
"/net/cms2";
30 Palette colors(
"txt/colors.txt",
"default");
32 string folder_mc(bfolder+
"/cms2r0/babymaker/babies/2016_06_14/mc/merged_nl1st500met150nj5/");
34 set<string> files_tt({folder_mc+
"*_TTJets*Lept*.root", folder_mc+
"*_TTJets_HT*.root"});
35 set<string> files_wjets({folder_mc+
"*_WJetsToLNu*.root"});
36 set<string> files_st({folder_mc+
"*_ST_*.root"});
37 set<string> files_other({
38 folder_mc+
"*DYJetsToLL*.root", folder_mc+
"*_QCD_HT*.root",
39 folder_mc+
"*_ZJet*.root", folder_mc+
"*_WWTo*.root",
40 folder_mc+
"*ggZH_HToBB*.root", folder_mc+
"*ttHJetTobb*.root",
41 folder_mc+
"*_TTGJets*.root", folder_mc+
"*_TTTT_*.root",
42 folder_mc+
"*_TTWJets*.root", folder_mc+
"*_TTZTo*.root",
43 folder_mc+
"*_WH_HToBB*.root", folder_mc+
"*_WZTo*.root",
44 folder_mc+
"*_ZH_HToBB*.root", folder_mc+
"_ZZ_*.root"});
46 set<string> files_nontt(files_other);
47 files_nontt.insert(files_wjets.begin(), files_wjets.end());
48 files_nontt.insert(files_st.begin(), files_st.end());
50 set<string> files_all(files_nontt);
51 files_all.insert(files_tt.begin(), files_tt.end());
53 PlotOpt log_shapes(
"txt/plot_styles.txt",
"CMSPaper");
54 log_shapes.
Title(TitleType::info)
56 .
YAxis(YAxisType::log)
57 .
Stack(StackType::shapes)
59 PlotOpt lin_shapes = log_shapes().
YAxis(YAxisType::linear);
60 vector<PlotOpt> plot_types = {lin_shapes};
62 NamedFunc baseline_1l =
"stitch && nleps==1 && nveto==0 && nbm>=1 && weight<1";
63 NamedFunc baseline_2l =
"stitch && nleps==2";
64 NamedFunc baseline_lveto =
"stitch && nleps==1 && nveto==1 && nbm>=1 && mt>140";
66 auto tt1l_lowmt = Process::MakeShared<Baby_full>(
"t#bar{t}(1l), m_{T} #leq 140",
68 auto tt1l_highmt = Process::MakeShared<Baby_full>(
"t#bar{t}(1l), m_{T} > 140",
70 auto tt2l = Process::MakeShared<Baby_full>(
"t#bar{t}(2l)",
72 auto ttlveto = Process::MakeShared<Baby_full>(
"t#bar{t}(lv), m_{T} > 140",
75 auto tt1l_highmt_2trul = Process::MakeShared<Baby_full>(
"t#bar{t}(1l), m_{T} > 140, tru: 2l",
77 baseline_1l &&
"ntruleps>=1 && ntruels+ntrumus+ntrutausl==2 && mt>140");
78 auto tt1l_highmt_1trul_1trutauh = Process::MakeShared<Baby_full>(
"t#bar{t}(1l), m_{T} > 140, tru: l#tau_{h}",
80 baseline_1l &&
"ntruleps>=1 && ntruels+ntrumus+ntrutausl==1 && ntrutaush==1 && mt>140");
81 auto tt1l_highmt_1trul = Process::MakeShared<Baby_full>(
"t#bar{t}(1l), m_{T} > 140, tru: 1l",
83 baseline_1l &&
"ntruleps>=1 && ntruels+ntrumus+ntrutausl==1 && ntrutaush==0 && mt>140");
85 auto bkg1l_lowmt = Process::MakeShared<Baby_full>(
"Tot. bkgd (1l), m_{T}#leq140",
87 bkg1l_lowmt->SetLineStyle(2);
88 auto bkg1l_highmt = Process::MakeShared<Baby_full>(
"Tot. bkgd (1l), m_{T}>140",
90 auto bkg2l = Process::MakeShared<Baby_full>(
"Tot. bkgd (2l)",
92 auto bkglveto = Process::MakeShared<Baby_full>(
"Tot. bkgd (lv), m_{T} > 140",
95 auto wjets1l_lowmt = Process::MakeShared<Baby_full>(
"W+jets (1l), m_{T}#leq140",
98 auto st1l_lowmt = Process::MakeShared<Baby_full>(
"Single t (1l), m_{T}#leq140",
101 auto other1l_lowmt = Process::MakeShared<Baby_full>(
"Other (1l), m_{T}#leq140",
104 auto nontt2l = Process::MakeShared<Baby_full>(
"Non-t#bar{t} (2l)",
106 auto nontt1l_highmt = Process::MakeShared<Baby_full>(
"Non-t#bar{t} (1l), m_{T}>140",
109 map<string, vector<shared_ptr<Process> > > procs;
110 procs[
"totbkg"] = vector<shared_ptr<Process> >({bkg1l_lowmt, bkglveto, bkg2l, bkg1l_highmt});
111 procs[
"dilep"] = vector<shared_ptr<Process> >({tt1l_lowmt, nontt2l, ttlveto, tt2l});
112 procs[
"lowmt"] = vector<shared_ptr<Process> >({tt1l_lowmt, other1l_lowmt, st1l_lowmt, wjets1l_lowmt});
113 procs[
"highmt"] = vector<shared_ptr<Process> >({tt1l_lowmt, tt1l_highmt_2trul,
114 tt1l_highmt_1trul_1trutauh, tt1l_highmt_1trul, nontt1l_highmt});
116 vector<NamedFunc> htopt;
120 for (
const auto &pt: *(b.
leps_pt())) st += pt;
124 float ht_proxy = b.
ht();
129 float ht_proxy = b.
ht();
134 float ht_proxy = b.
ht();
141 for (
auto mj_lep: {
true}){
142 vector<string> nobj_cuts;
144 nobj_cuts.push_back(
"met>200&&njets+nleps==6");
145 nobj_cuts.push_back(
"met>200&&njets+nleps>=7 && njets+nleps<=9");
146 nobj_cuts.push_back(
"met>200&&njets+nleps>=10");
147 nobj_cuts.push_back(
"met>150&&met<=200&&njets+nleps==6");
148 nobj_cuts.push_back(
"met>150&&met<=200&&njets+nleps>=7 && njets+nleps<=9");
149 nobj_cuts.push_back(
"met>150&&met<=200&&njets+nleps>=10");
151 nobj_cuts.push_back(
"njets>=6 && njets<=8");
152 nobj_cuts.push_back(
"njets>=9");
155 string var(
"mj14"), xtitle(
"M_{J} [GeV]");
157 for (
auto &iht: htopt){
158 for (
auto &iproc:procs){
159 for (
auto inobj: nobj_cuts) {
160 if(iproc.first ==
"dilep" &&
Contains(inobj,
"==6"))
continue;
161 pm.
Push<HistoStack>(HistoDef(iproc.first+
"_"+iht.PlainName(),
162 10, 100., 850., var, xtitle, inobj && iht>500,
"weight", {250.,400.}), iproc.second, plot_types);
171 double seconds = (chrono::duration<double>(chrono::high_resolution_clock::now() - begTime)).count();
173 cout<<endl<<
"Making "<<Nplots<<
" plots took "<<round(seconds)<<
" seconds ("<<hhmmss<<
")"<<endl<<endl;
PlotOpt & Stack(PlotOptTypes::StackType stack_type)
PlotOpt & YAxis(PlotOptTypes::YAxisType y_axis_type)
TString HoursMinSec(float fseconds)
std::vector< float > *const & leps_pt() const
Get leps_pt for current event and cache it.
int const & nleps() const
Get nleps for current event and cache it.
Abstract base class for access to ntuple variables.
Combines a callable function taking a Baby and returning a scalar or vector with its string represent...
bool Contains(const std::string &str, const std::string &pat)
std::string execute(const std::string &cmd)
FigureType & Push(Args &&...args)
Organizes efficient production of plots with single loop over each process.
PlotOpt & Bottom(PlotOptTypes::BottomType bottom_type)
PlotOpt & RatioMaximum(double ratio_maximum)
const NamedFunc st("st", [](const Baby &b) -> NamedFunc::ScalarType{float stvar=b.ht();for(const auto &pt:*(b.leps_pt())) stvar+=pt;return stvar;})
void MakePlots(double luminosity, const std::string &subdir="")
Prints all added plots with given luminosity.
PlotOpt & Title(PlotOptTypes::TitleType title_type)
float const & ht() const
Get ht for current event and cache it.
Loads colors from a text configuration file.