6 #include <initializer_list> 43 int main(
int argc,
char *argv[]){
44 cout << fixed << setprecision(2);
46 string midjets(
""); midjets += to_string(atoi(
hijets.c_str())-1);
47 string minjets2l(
""); minjets2l += to_string(atoi(
minjets.c_str())-1);
48 string midjets2l(
""); midjets2l += to_string(atoi(midjets.c_str())-1);
50 string hostname =
execute(
"echo $HOSTNAME");
51 string basefolder(
"/net/cms2/cms2r0/babymaker/");
52 if(
Contains(hostname,
"lxplus")) basefolder =
"/afs/cern.ch/user/m/manuelf/work/";
53 string skim(
"skim_1lht500met200/");
54 string foldermc(basefolder+
"babies/2015_11_28/mc/"+skim);
55 string folderdata(basefolder+
"babies/2016_02_04/data/singlelep/combined/"+skim);
58 string stitch_cuts(
"stitch");
60 {foldermc+
"/*TTJets*Lept*.root/tree"},
61 {foldermc+
"/*TTJets_HT*.root/tree"}
64 {foldermc+
"/*_WJetsToLNu*.root/tree"},
65 {foldermc+
"/*_TTWJets*.root/tree"},
66 {foldermc+
"/*_TTZTo*.root/tree"},
67 {foldermc+
"/*_ST_*.root/tree"},
68 {foldermc+
"/*DYJetsToLL*.root/tree"},
69 {foldermc+
"/*QCD_HT*.root/tree"},
70 {foldermc+
"/*_WWTo*.root/tree"},
71 {foldermc+
"/*_TTGJets*.root/tree"},
72 {foldermc+
"/*_TTTT*.root/tree"},
73 {foldermc+
"/*_WZ*.root/tree"},
74 {foldermc+
"/*ttHJetTobb*.root/tree"}
77 {foldermc+
"/*T1tttt*1500*100*.root/tree"}
78 },
Cut(),
false,
true};
80 {foldermc+
"/*T1tttt*1200*800*.root/tree"}
81 },
Cut(),
false,
true};
83 string data_cuts(
"(trig[4]||trig[8])&&pass&&nonblind");
85 data_cuts =
"(trig[4]||trig[8])&&pass";
88 {folderdata+
"/*.root/tree"}
92 set<Process> backgrounds{
ttbar, other};
95 Cut baseline{
"pass&&mj>250&&ht>500&&met>200&&njets>="+
minjets+
"&&nbm>=2&&nleps==1"};
96 Cut baseline1b{
"pass&&mj>250&&ht>500&&met>200&&njets>="+
minjets+
"&&nbm>=1&&nleps==1"};
97 Cut baseline2l{
"pass&&mj>250&&ht>500&&met>200&&met<=400"};
98 Cut baseline_135{
"pass&&mj>250&&ht>450&&met>150"};
102 Bin r1_lowmet_1b{
"r1_lowmet_1b",
"mt<=140&&mj<="+
mjthresh+
"&&met<="+
himet+
"&&nbm==1",
104 Bin r1_highmet_1b{
"r1_highmet_1b",
"mt<=140&&mj<="+
mjthresh+
"&&met>"+
himet+
"&&nbm==1",
106 Bin r1_lowmet_2b{
"r1_lowmet_2b",
"mt<=140&&mj<="+
mjthresh+
"&&met<="+
himet+
"&&nbm==2",
108 Bin r1_lowmet_3b{
"r1_lowmet_3b",
"mt<=140&&mj<="+
mjthresh+
"&&met<="+
himet+
"&&nbm>2",
110 Bin r1_highmet_2b{
"r1_highmet_2b",
"mt<=140&&mj<="+
mjthresh+
"&&met>"+
himet+
"&&nbm>=2",
113 Bin r1_lowmet_allnb{
"r1_lowmet_allnb",
"mt<=140&&mj<="+
mjthresh+
"&&met<="+
himet,
115 Bin r1_highmet_allnb{
"r1_highmet_allnb",
"mt<=140&&mj<="+
mjthresh+
"&&met>"+
himet,
120 Bin r2_lowmet_lownj_1b{
"r2_lowmet_lownj_1b",
"mt<=140&&mj>"+
mjthresh+
"&&met<="+
himet+
"&&njets<="+midjets+
"&&nbm==1",
122 Bin r2_highmet_lownj_1b{
"r2_highmet_lownj_1b",
"mt<=140&&mj>"+
mjthresh+
"&&met>"+
himet+
"&&njets<="+midjets+
"&&nbm==1",
124 Bin r2_lowmet_highnj_1b{
"r2_lowmet_highnj_1b",
"mt<=140&&mj>"+
mjthresh+
"&&met<="+
himet+
"&&njets>"+midjets+
"&&nbm==1",
126 Bin r2_highmet_highnj_1b{
"r2_highmet_highnj_1b",
"mt<=140&&mj>"+
mjthresh+
"&&met>"+
himet+
"&&njets>"+midjets+
"&&nbm==1",
128 Bin r2_lowmet_lownj_2b{
"r2_lowmet_lownj_2b",
"mt<=140&&mj>"+
mjthresh+
"&&met<="+
himet+
"&&njets<="+midjets+
"&&nbm==2",
130 Bin r2_lowmet_lownj_3b{
"r2_lowmet_lownj_3b",
"mt<=140&&mj>"+
mjthresh+
"&&met<="+
himet+
"&&njets<="+midjets+
"&&nbm>2",
132 Bin r2_lowmet_highnj_2b{
"r2_lowmet_highnj_2b",
"mt<=140&&mj>"+
mjthresh+
"&&met<="+
himet+
"&&njets>"+midjets+
"&&nbm==2",
134 Bin r2_lowmet_highnj_3b{
"r2_lowmet_highnj_3b",
"mt<=140&&mj>"+
mjthresh+
"&&met<="+
himet+
"&&njets>"+midjets+
"&&nbm>2",
136 Bin r2_highmet_lownj_2b{
"r2_highmet_lownj_2b",
"mt<=140&&mj>"+
mjthresh+
"&&met>"+
himet+
"&&njets<="+midjets+
"&&nbm>=2",
138 Bin r2_highmet_highnj_2b{
"r2_highmet_highnj_2b",
"mt<=140&&mj>"+
mjthresh+
"&&met>"+
himet+
"&&njets>"+midjets+
"&&nbm>=2",
141 Bin r3_lowmet_1b{
"r3_lowmet_1b",
"mt>140&&mj<="+
mjthresh+
"&&met<="+
himet+
"&&nbm==1",
143 Bin r3_highmet_1b{
"r3_highmet_1b",
"mt>140&&mj<="+
mjthresh+
"&&met>"+
himet+
"&&nbm==1",
145 Bin r3_lowmet_2b{
"r3_lowmet_2b",
"mt>140&&mj<="+
mjthresh+
"&&met<="+
himet+
"&&nbm==2",
147 Bin r3_lowmet_3b{
"r3_lowmet_3b",
"mt>140&&mj<="+
mjthresh+
"&&met<="+
himet+
"&&nbm>2",
149 Bin r3_highmet_2b{
"r3_highmet_2b",
"mt>140&&mj<="+
mjthresh+
"&&met>"+
himet+
"&&nbm>=2",
152 Bin r3_lowmet_allnb{
"r3_lowmet_allnb",
"mt>140&&mj<="+
mjthresh+
"&&met<="+
himet,
154 Bin r3_highmet_allnb{
"r3_highmet_allnb",
"mt>140&&mj<="+
mjthresh+
"&&met>"+
himet,
159 Bin r4_lowmet_lownj_1b{
"r4_lowmet_lownj_1b",
"mt>140&&mj>"+
mjthresh+
"&&met<="+
himet+
"&&njets<="+midjets+
"&&nbm==1",
161 Bin r4_highmet_lownj_1b{
"r4_highmet_lownj_1b",
"mt>140&&mj>"+
mjthresh+
"&&met>"+
himet+
"&&njets<="+midjets+
"&&nbm==1",
163 Bin r4_lowmet_highnj_1b{
"r4_lowmet_highnj_1b",
"mt>140&&mj>"+
mjthresh+
"&&met<="+
himet+
"&&njets>"+midjets+
"&&nbm==1",
165 Bin r4_highmet_highnj_1b{
"r4_highmet_highnj_1b",
"mt>140&&mj>"+
mjthresh+
"&&met>"+
himet+
"&&njets>"+midjets+
"&&nbm==1",
168 Bin r4_lowmet_lownj_2b{
"r4_lowmet_lownj_2b",
"mt>140&&mj>"+
mjthresh+
"&&met<="+
himet+
"&&njets<="+midjets+
"&&nbm==2",
170 Bin r4_lowmet_lownj_3b{
"r4_lowmet_lownj_3b",
"mt>140&&mj>"+
mjthresh+
"&&met<="+
himet+
"&&njets<="+midjets+
"&&nbm>2",
172 Bin r4_lowmet_highnj_2b{
"r4_lowmet_highnj_2b",
"mt>140&&mj>"+
mjthresh+
"&&met<="+
himet+
"&&njets>"+midjets+
"&&nbm==2",
174 Bin r4_lowmet_highnj_3b{
"r4_lowmet_highnj_3b",
"mt>140&&mj>"+
mjthresh+
"&&met<="+
himet+
"&&njets>"+midjets+
"&&nbm>2",
176 Bin r4_highmet_lownj_2b{
"r4_highmet_lownj_2b",
"mt>140&&mj>"+
mjthresh+
"&&met>"+
himet+
"&&njets<="+midjets+
"&&nbm>=2",
178 Bin r4_highmet_highnj_2b{
"r4_highmet_highnj_2b",
"mt>140&&mj>"+
mjthresh+
"&&met>"+
himet+
"&&njets>"+midjets+
"&&nbm>=2",
182 Bin r1c_allnj{
"r1c_allnj",
"mt<=140&&mj<="+
mjthresh+
"&&nbm>=1&&njets>="+
minjets+
"&&nleps==1",
185 Bin r2c_lownj{
"r2c_lownj",
"mt<=140&&mj>"+
mjthresh+
"&&nbm>=1&&njets>="+
minjets+
"&&njets<="+midjets+
"&&nleps==1",
187 Bin r2c_highnj{
"r2c_highnj",
"mt<=140&&mj>"+
mjthresh+
"&&nbm>=1&&njets>"+midjets+
"&&nleps==1",
190 Bin d3_allnj{
"d3_allnj",
"mj<="+
mjthresh+
"&&njets>="+minjets2l+
"&&nbm<=2&&nleps==2",
193 Bin d4_lownj{
"d4_lownj",
"mj>"+
mjthresh+
"&&njets>="+minjets2l+
"&&njets<="+midjets2l+
"&&nbm<=2&&nleps==2",
195 Bin d4_highnj{
"d4_highnj",
"mj>"+
mjthresh+
"&&njets>="+minjets2l+
"&&njets>"+midjets2l+
"&&nbm<=2&&nleps==2",
207 Bin d3{
"d3",
"mj<="+
mjthresh+
"&&njets>="+minjets2l+
"&&nbm>=0&&nleps==2",
209 Bin d4{
"d4",
"mj>"+
mjthresh+
"&&njets>="+minjets2l+
"&&nbm>=0&&nleps==2",
213 set<Block> blocks_1bk{
214 {
"lowmet", {{r1_lowmet_allnb, r2_lowmet_lownj_1b, r2_lowmet_highnj_1b, r2_lowmet_lownj_2b, r2_lowmet_highnj_2b,
215 r2_lowmet_lownj_3b, r2_lowmet_highnj_3b},
216 {r3_lowmet_allnb, r4_lowmet_lownj_1b, r4_lowmet_highnj_1b, r4_lowmet_lownj_2b, r4_lowmet_highnj_2b,
217 r4_lowmet_lownj_3b, r4_lowmet_highnj_3b}}},
218 {
"highmet", {{r1_highmet_allnb, r2_highmet_lownj_1b, r2_highmet_highnj_1b, r2_highmet_lownj_2b, r2_highmet_highnj_2b},
219 {r3_highmet_allnb, r4_highmet_lownj_1b, r4_highmet_highnj_1b, r4_highmet_lownj_2b, r4_highmet_highnj_2b}}}
223 set<Block> blocks_135{
224 {
"all", {{r1, r2}, {r3, r4}}}
227 set<Block> blocks_135_2l{
228 {
"all", {{r1, r2}, {d3, d4}}}
232 set<Block> blocks_2l{
233 {
"all", {{r1c_allnj, r2c_lownj, r2c_highnj},
234 {d3_allnj, d4_lownj, d4_highnj}}}
237 Cut *pbaseline(&baseline1b);
238 set<Block> *pblocks(&blocks_1bk);
239 string sysfile(
"txt/systematics/m1bk.txt");
241 pbaseline = &baseline1b;
242 pblocks = &blocks_1bk;
243 sysfile =
"txt/systematics/m1bk_c.txt";
244 }
else if(
method ==
"m1bk_nodilep"){
245 pbaseline = &baseline1b;
246 pblocks = &blocks_1bk;
247 sysfile =
"txt/systematics/m1bk_nodilep.txt";
248 }
else if(
method ==
"m1bk_onlydilep"){
249 pbaseline = &baseline1b;
250 pblocks = &blocks_1bk;
251 sysfile =
"txt/systematics/m1bk_onlydilep.txt";
252 }
else if(
method ==
"m2l"){
253 pbaseline = &baseline2l;
254 pblocks = &blocks_2l;
255 sysfile =
"txt/systematics/m2l.txt";
256 }
else if(
method ==
"m135"){
257 pbaseline = &baseline_135;
258 pblocks = &blocks_135;
259 sysfile =
"txt/systematics/m135.txt";
260 }
else if(
method ==
"m135_2l"){
261 pbaseline = &baseline_135;
262 pblocks = &blocks_135_2l;
263 sysfile =
"txt/systematics/m135_2l.txt";
266 TString lumi_s(
"_lumi"); lumi_s +=
lumi; lumi_s.ReplaceAll(
".",
"p");
267 lumi_s.ReplaceAll(
"00000000000001",
""); lumi_s.ReplaceAll(
"39999999999999",
"4");
268 TString sig_s(
"_sig"); sig_s +=
sig_strength; sig_s.ReplaceAll(
".",
"p");
269 sig_s.ReplaceAll(
"00000000000001",
"");
270 string blind_name =
"";
272 blind_name =
"_unblinded";
274 blind_name =
"_1bunblinded";
276 blind_name =
"_r4blinded";
280 +(
no_kappa ?
"_nokappa" :
"")+
string(
"_c_met")
282 +sig_s+lumi_s.Data()+blind_name+
identifier+
".root");
288 wgc.SetLuminosity(
lumi);
289 wgc.SetDoDilepton(
false);
293 wgc.WriteToFile(outname);
310 static struct option long_options[] = {
311 {
"lumi", required_argument, 0,
'l'},
312 {
"unblind", required_argument, 0,
'u'},
313 {
"no_syst", no_argument, 0, 0},
314 {
"lowj", required_argument, 0,
'j'},
315 {
"hij", required_argument, 0,
'h'},
316 {
"himet", required_argument, 0,
'm'},
317 {
"mj", required_argument, 0,
's'},
318 {
"nokappa", no_argument, 0,
'k'},
319 {
"method", required_argument, 0,
't'},
320 {
"use_r4", no_argument, 0,
'4'},
321 {
"toys", required_argument, 0, 0},
322 {
"sig_strength", required_argument, 0,
'g'},
323 {
"identifier", required_argument, 0,
'i'},
329 opt = getopt_long(argc, argv,
"l:u:j:h:m:s:kt:4g:i:", long_options, &option_index);
330 if( opt == -1)
break;
341 if(
string(optarg)==
"all"){
343 }
else if(
string(optarg)==
"sideband"){
345 }
else if(
string(optarg)==
"1b"){
376 optname = long_options[option_index].name;
377 if(optname ==
"no_syst"){
379 }
else if(optname ==
"toys"){
382 printf(
"Bad option! Found option name %s\n", optname.c_str());
386 printf(
"Bad option! getopt_long returned character code 0%o\n", opt);
WorkspaceGenerator & SetLuminosity(double luminosity)
WorkspaceGenerator & SetDoSystematics(bool do_systematics)
void GetOptions(int argc, char *argv[])
void ReplaceAll(std::string &str, const std::string &orig, const std::string &rep)
bool Contains(const std::string &str, const std::string &pat)
std::string execute(const std::string &cmd)
WorkspaceGenerator & SetKappaCorrected(bool do_kappa_correction)
WorkspaceGenerator & SetDoDilepton(bool do_systematics)
void WriteToFile(const std::string &file_name)
SYSTEMATIC dilep PROCESSES ttbar
int main(int argc, char *argv[])
size_t AddToys(size_t num_toys=0)