11 #include "core/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");
35 string folder_mc(bfolder+
"/cms2r0/babymaker/babies/2016_06_14/mc/merged_nl1st500met150nj5/");
40 set<string> files_tt({folder_mc+
"*_TTJets*Lept*"+ntupletag+
"*.root",
41 folder_mc+
"*_TTJets_HT*"+ntupletag+
"*.root"});
42 set<string> files_wjets({folder_mc+
"*_WJetsToLNu*"+ntupletag+
"*.root"});
43 set<string> files_st({folder_mc+
"*_ST_*"+ntupletag+
"*.root"});
44 set<string> files_other({
45 folder_mc+
"*DYJetsToLL*"+ntupletag+
"*.root", folder_mc+
"*_QCD_HT*"+ntupletag+
"*.root",
46 folder_mc+
"*_ZJet*"+ntupletag+
"*.root", folder_mc+
"*_WWTo*"+ntupletag+
"*.root",
47 folder_mc+
"*ggZH_HToBB*"+ntupletag+
"*.root", folder_mc+
"*ttHJetTobb*"+ntupletag+
"*.root",
48 folder_mc+
"*_TTGJets*"+ntupletag+
"*.root", folder_mc+
"*_TTTT_*"+ntupletag+
"*.root",
49 folder_mc+
"*_TTWJets*"+ntupletag+
"*.root", folder_mc+
"*_TTZTo*"+ntupletag+
"*.root",
50 folder_mc+
"*_WH_HToBB*"+ntupletag+
"*.root", folder_mc+
"*_WZTo*"+ntupletag+
"*.root",
51 folder_mc+
"*_ZH_HToBB*"+ntupletag+
"*.root", folder_mc+
"_ZZ_*"+ntupletag+
"*.root"});
53 set<string> files_nontt(files_other);
54 files_nontt.insert(files_wjets.begin(), files_wjets.end());
55 files_nontt.insert(files_st.begin(), files_st.end());
57 set<string> files_all(files_nontt);
58 files_all.insert(files_tt.begin(), files_tt.end());
60 PlotOpt log_shapes(
"txt/plot_styles.txt",
"CMSPaper");
61 log_shapes.
Title(TitleType::info)
63 .
YAxis(YAxisType::log)
64 .
Stack(StackType::shapes)
66 PlotOpt lin_shapes = log_shapes().
YAxis(YAxisType::linear);
67 vector<PlotOpt> plot_types = {lin_shapes};
69 NamedFunc baseline_1l =
"stitch && nleps==1 && nveto==0 && nbm>=1 && weight<1";
70 NamedFunc baseline_2l =
"stitch && nleps==2";
71 NamedFunc baseline_lveto =
"stitch && nleps==1 && nveto==1 && nbm>=1 && mt>140";
73 auto tt1l_lowmt = Process::MakeShared<Baby_full>(
"t#bar{t}(1l), m_{T} #leq 140",
75 auto tt1l_highmt = Process::MakeShared<Baby_full>(
"t#bar{t}(1l), m_{T} > 140",
77 auto tt2l = Process::MakeShared<Baby_full>(
"t#bar{t}(2l)",
79 auto ttlveto = Process::MakeShared<Baby_full>(
"t#bar{t}(lv), m_{T} > 140",
82 auto tt1l_highmt_2trul = Process::MakeShared<Baby_full>(
"t#bar{t}(1l), m_{T} > 140, tru: 2l",
84 baseline_1l &&
"ntruleps>=1 && ntruels+ntrumus+ntrutausl==2 && mt>140");
85 auto tt1l_highmt_1trul_1trutauh = Process::MakeShared<Baby_full>(
"t#bar{t}(1l), m_{T} > 140, tru: l#tau_{h}",
87 baseline_1l &&
"ntruleps>=1 && ntruels+ntrumus+ntrutausl==1 && ntrutaush==1 && mt>140");
88 auto tt1l_highmt_1trul = Process::MakeShared<Baby_full>(
"t#bar{t}(1l), m_{T} > 140, tru: 1l",
90 baseline_1l &&
"ntruleps>=1 && ntruels+ntrumus+ntrutausl==1 && ntrutaush==0 && mt>140");
92 auto bkg1l_lowmt = Process::MakeShared<Baby_full>(
"Tot. bkgd (1l), m_{T}#leq140",
94 bkg1l_lowmt->SetLineStyle(2);
95 auto bkg1l_highmt = Process::MakeShared<Baby_full>(
"Tot. bkgd (1l), m_{T}>140",
97 auto bkg2l = Process::MakeShared<Baby_full>(
"Tot. bkgd (2l)",
99 auto bkglveto = Process::MakeShared<Baby_full>(
"Tot. bkgd (lv), m_{T} > 140",
102 auto wjets1l_lowmt = Process::MakeShared<Baby_full>(
"W+jets (1l), m_{T}#leq140",
105 auto st1l_lowmt = Process::MakeShared<Baby_full>(
"Single t (1l), m_{T}#leq140",
108 auto other1l_lowmt = Process::MakeShared<Baby_full>(
"Other (1l), m_{T}#leq140",
111 auto nontt2l = Process::MakeShared<Baby_full>(
"Non-t#bar{t} (2l)",
113 auto nontt1l_highmt = Process::MakeShared<Baby_full>(
"Non-t#bar{t} (1l), m_{T}>140",
116 map<string, vector<shared_ptr<Process> > > procs;
117 procs[
"totbkg"] = vector<shared_ptr<Process> >({bkg1l_lowmt, bkglveto, bkg2l, bkg1l_highmt});
118 procs[
"dilep"] = vector<shared_ptr<Process> >({tt1l_lowmt, nontt2l, ttlveto, tt2l});
119 procs[
"lowmt"] = vector<shared_ptr<Process> >({tt1l_lowmt, other1l_lowmt, st1l_lowmt, wjets1l_lowmt});
120 procs[
"highmt"] = vector<shared_ptr<Process> >({tt1l_lowmt, tt1l_highmt_2trul,
121 tt1l_highmt_1trul_1trutauh, tt1l_highmt_1trul, nontt1l_highmt});
123 vector<NamedFunc> htopt;
128 for (
const auto &pt: *(b.
leps_pt())) st += pt;
149 for (
auto mj_lep: {
true}){
150 vector<string> nobj_cuts;
152 nobj_cuts.push_back(
"met>200&&njets+nleps==6");
153 nobj_cuts.push_back(
"met>200&&njets+nleps>=7 && njets+nleps<=9");
154 nobj_cuts.push_back(
"met>200&&njets+nleps>=10");
155 nobj_cuts.push_back(
"met>150&&met<=200&&njets+nleps==6");
156 nobj_cuts.push_back(
"met>150&&met<=200&&njets+nleps>=7 && njets+nleps<=9");
157 nobj_cuts.push_back(
"met>150&&met<=200&&njets+nleps>=10");
159 nobj_cuts.push_back(
"njets>=6 && njets<=8");
160 nobj_cuts.push_back(
"njets>=9");
163 string var(
"mj14"), xtitle(
"M_{J} [GeV]");
165 for (
auto &iht: htopt){
166 for (
auto &iproc:procs){
167 for (
auto inobj: nobj_cuts) {
168 if(iproc.first ==
"dilep" &&
Contains(inobj,
"==6"))
continue;
169 pm.
Push<HistoStack>(HistoDef(iproc.first+
"_"+iht.PlainName(),
170 10, 100., 850., var, xtitle, inobj && iht>500,
"weight", {250.,400.}), iproc.second, plot_types);
179 double seconds = (chrono::duration<double>(chrono::high_resolution_clock::now() - begTime)).count();
181 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.
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.