-
Notifications
You must be signed in to change notification settings - Fork 0
/
MakeQCD.C_save
626 lines (540 loc) · 21.5 KB
/
MakeQCD.C_save
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
/* program includes */
#include "MakeQCD.h"
#include "SysHandler.C"
#include "ATLASstyle.C"
int main( int argc, char* argv[] ) {
bool useBjet = false;
bool printHelp = false;
bool isttCR = false;
bool isFFcat = false;
bool addSys = false;
bool isBlind = false;
bool isRevDphi = false;
bool scaleWjet = false;
bool isSherpa = false;
bool debug = false;
int lfvType = -1;
std::string charge = "";
for(int i = 1; i < argc; ++i){
if( !strcmp(argv[i],"--useBjet") ){ useBjet = true; }
else if( !strcmp(argv[i],"--lfvType") ){ lfvType = std::stoi(argv[i+1]); }
else if( !strcmp(argv[i],"--charge") ){ charge = argv[i+1]; }
else if( !strcmp(argv[i],"--addSys") ){ addSys = true; }
else if( !strcmp(argv[i],"--isttCR") ){ isttCR = true; }
else if( !strcmp(argv[i],"--isFFcat") ){ isFFcat = true; }
else if( !strcmp(argv[i],"--isBlind") ){ isBlind = true; }
else if( !strcmp(argv[i],"--isRevDphi") ){ isRevDphi = true; }
else if( !strcmp(argv[i],"--scaleWjet") ){ scaleWjet = true; }
else if( !strcmp(argv[i],"--isSherpa") ){ isSherpa = true; }
else if( !strcmp(argv[i],"--debug") ){ debug = true; }
else if( !strcmp(argv[i],"--help") ){ printHelp = true; }
else{
std::cout << "WARNING:: Option " << argv[i] << " not recognized: "
<< "skipping!" << std::endl;
}
}
if(printHelp){
std::cout << " MakeQCD: make qcd estimation! " << std::endl;
std::cout << " Options: " << std::endl;
std::cout << " --useBjet [Enable b-jet veto:"
<< " default is 'false'] " << std::endl;
std::cout << " --lfvType [Choose lfv channel: "
<< " options 1,2,3']" << std::endl;
std::cout << " --charge [Choose ll-charge:"
<< " default is '' (OS+SS)] " << std::endl;
std::cout << " --addSys [Add sytematics:"
<< " default is 'false'] " << std::endl;
std::cout << " --isttCR [Enable ttbar CR:"
<< " default is 'false'] " << std::endl;
std::cout << " --isFFcat [Enable double fake category:"
<< " default is 'false'] " << std::endl;
std::cout << " --isBlind [Enable Blind analysis:"
<< " default is 'false'] " << std::endl;
std::cout << " --isRevDphi [Enable revDphi analysis:"
<< " default is 'false'] " << std::endl;
std::cout << " --scaleWjet [Enable W+jets scaling:"
<< " default is 'false'] " << std::endl;
std::cout << " --isSherpa [Enable Sherpa ttbar:"
<< " default is 'false'] " << std::endl;
std::cout << " --debug [Enable debug]" << std::endl;
std::cout << " --help [Print this help]" << std::endl;
exit(0);
}
if(lfvType==-1){
std::cout << "< MakeQCD() >:: lfvType not set!"
<< " Possible options: 1,2,3" << std::endl;
exit(0);
}
std::cout << "< MakeQCD() >:: Options set " << std::endl;
std::cout << " useBjet = " << useBjet << std::endl;
std::cout << " lfvType = " << lfvType << std::endl;
std::cout << " charge = " << charge << std::endl;
std::cout << " addSys = " << addSys << std::endl;
std::cout << " isttCR = " << isttCR << std::endl;
std::cout << " isFFcat = " << isFFcat << std::endl;
std::cout << " isBlind = " << isBlind << std::endl;
std::cout << " isRevDphi = " << isRevDphi << std::endl;
std::cout << " scaleWjet = " << scaleWjet << std::endl;
std::cout << " isSherpa = " << isSherpa << std::endl;
std::cout << " debug = " << debug << std::endl;
m_debug = debug;
MakeQCD(lfvType,charge,addSys,useBjet,isttCR,
isFFcat,isBlind,isRevDphi,scaleWjet,isSherpa);
return 0;
}
void MakeQCD(int LFVtype, std::string charge, bool addSys, bool useBjet,
bool isttCR, /*bool useSmooth,*/ bool isFFcat, bool isBlind,
bool isRevDphi, bool scaleWjet, bool isSherpa){
SetATLASStyle();
TH1::SetDefaultSumw2(kTRUE);
std::string lfvType = "";
if(LFVtype==1) { lfvType="emu"; }
else if(LFVtype==2) { lfvType="etau"; }
else if(LFVtype==3) { lfvType="mutau"; }
std::cout << "< MakeQCD() >:: Deriving QCD for Channel " << LFVtype << std::endl;
std::string Dir = "";
if(useBjet){ Dir += "Bjet/"; }
else{ Dir += "NoBjet/"; }
if(isttCR) {
Dir += "ttbarCR";
if(isSherpa) Dir += "_Sherpa";
Dir += "/";
}
if(isRevDphi){ Dir += "revDphi/"; }
std::vector<std::string> sysVar = GetSysList(LFVtype,useBjet,addSys);
for(uint i=0; i<sysVar.size(); i++){
std::cout << "< MakeQCD() >:: Processing sysVar = " << sysVar.at(i) << std::endl;
if(LFVtype>1)
MakeQCD_tau(sysVar.at(i), lfvType, Dir, charge,
useBjet, isFFcat, isBlind, scaleWjet);
else
MakeQCD_emu(sysVar.at(i), Dir, useBjet,/*useSmooth*/ isBlind);
}
}
void MakeQCD_emu(std::string sysVar,
std::string Dir,
bool useBjet,
/*,bool useSmooth*/
bool isBlind){
/* open out file */
std::string fName = Dir+"Plots_"+sysVar+"_emu";
if(isBlind)
fName += "_Blind";
/* define input files */
std::string InName = "QCDemu";
if(useBjet){ InName += "_bjetVeto"; }
if(isBlind){ InName += "_Blind"; }
m_out = new TFile( (fName+".root").c_str(), "UPDATE");
/* open input distro file */
if(Dir.find("ttbar")!=std::string::npos)
m_qcdemu = new TFile( "VarInputs/QCDemu_ttbarCR.root" );
else
m_qcdemu = new TFile( ("VarInputs/"+InName+".root").c_str() );
/* Create Base Histograms */
TH1F *mll = (TH1F*)m_qcdemu->Get( "hmllqcd" );
TH1F *ptll = (TH1F*)m_qcdemu->Get( "hptllqcd" );
TH1F *etall = (TH1F*)m_qcdemu->Get( "hetallqcd" );
TH1F *phill = (TH1F*)m_qcdemu->Get( "hphillqcd" );
TH1F *met = (TH1F*)m_qcdemu->Get( "hmetqcd" );
TH1F *njet = (TH1F*)m_qcdemu->Get( "hnjetqcd" );
TH1F *mu_pt = (TH1F*)m_qcdemu->Get( "hmu_ptqcd" );
TH1F *mu_eta = (TH1F*)m_qcdemu->Get( "hmu_etaqcd" );
TH1F *mu_phi = (TH1F*)m_qcdemu->Get( "hmu_phiqcd" );
TH1F *el_pt = (TH1F*)m_qcdemu->Get( "hel_ptqcd" );
TH1F *el_eta = (TH1F*)m_qcdemu->Get( "hel_etaqcd" );
TH1F *el_phi = (TH1F*)m_qcdemu->Get( "hel_phiqcd" );
TH1F *ta_pt = (TH1F*)m_out->Get( "hta_pt_Top" ); ta_pt->Reset();
TH1F *ta_eta = (TH1F*)m_out->Get( "hta_eta_Top" ); ta_eta->Reset();
TH1F *ta_phi = (TH1F*)m_out->Get( "hta_phi_Top" ); ta_phi->Reset();
TH1F *mt = (TH1F*)m_out->Get( "hmt_Top" ); mt->Reset();
//if(useSmooth){
// mll->GetXaxis()->SetRangeUser(80.,1000.);
// double qcd=mll->Integral();
// mll->GetXaxis()->SetRangeUser(150.,1100.);
// mll->Smooth(100,"R");
// mll->Scale(qcd/mll->Integral() );
//}
m_out->cd();
/* Write Plots */
mll -> Write( "hmllCorr_qcd" );
mll -> Write( "hmll_qcd" );
ptll -> Write( "hptllCorr_qcd" );
ptll -> Write( "hptll_qcd" );
etall -> Write( "hetall_qcd" );
phill -> Write( "hphill_qcd" );
njet -> Write( "hnjet_qcd" );
met -> Write( "hmet_qcd" );
mu_pt -> Write( "hmu_pt_qcd" );
mu_eta -> Write( "hmu_eta_qcd" );
mu_phi -> Write( "hmu_phi_qcd" );
el_pt -> Write( "hel_pt_qcd" );
el_eta -> Write( "hel_eta_qcd" );
el_phi -> Write( "hel_phi_qcd" );
ta_pt -> Write( "hta_pt_qcd" );
ta_eta -> Write( "hta_eta_qcd" );
ta_phi -> Write( "hta_phi_qcd" );
mt -> Write( "hmt_qcd" );
if(m_debug){
std::cout << "< MakeQCD() >:: Checking integrals ... " << std::endl;
std::cout << " mll = " << mll->Integral() << std::endl;
std::cout << " ptll = " << ptll->Integral() << std::endl;
std::cout << " etall = " << etall->Integral() << std::endl;
std::cout << " phill = " << phill->Integral() << std::endl;
std::cout << " met = " << met->Integral() << std::endl;
std::cout << " njet = " << njet->Integral() << std::endl;
std::cout << " met = " << met->Integral() << std::endl;
std::cout << " mu_pt = " << mu_pt->Integral() << std::endl;
std::cout << " mu_eta = " << mu_eta->Integral() << std::endl;
std::cout << " mu_phi = " << mu_phi->Integral() << std::endl;
std::cout << " el_pt = " << el_pt->Integral() << std::endl;
std::cout << " el_eta = " << el_eta->Integral() << std::endl;
std::cout << " el_phi = " << el_phi->Integral() << std::endl;
std::cout << " ta_pt = " << ta_pt->Integral() << std::endl;
std::cout << " ta_eta = " << ta_eta->Integral() << std::endl;
std::cout << " ta_phi = " << ta_phi->Integral() << std::endl;
std::cout << " mt = " << mt->Integral() << std::endl;
}
/* Cleaning */
mll -> Delete();
ptll -> Delete();
etall -> Delete();
phill -> Delete();
njet -> Delete();
met -> Delete();
mu_pt -> Delete();
mu_eta -> Delete();
mu_phi -> Delete();
el_pt -> Delete();
el_eta -> Delete();
el_phi -> Delete();
ta_pt -> Delete();
ta_eta -> Delete();
ta_phi -> Delete();
mt -> Delete();
m_out->Close();
m_qcdemu->Close();
}
double WjetTranFact(TFile *SR, TFile *CR){
TH1F *wjCR = (TH1F*)CR->Get( "hmllCorr_Wjets" );
TH1F *dataCR = (TH1F*)CR->Get( "hmllCorr_data" );
TH1F *DYCR = (TH1F*)CR->Get( "hmllCorr_DY" );
TH1F *TopCR = (TH1F*)CR->Get( "hmllCorr_Top" );
TH1F *DibCR = (TH1F*)CR->Get( "hmllCorr_DiBoson" );
TH1F *wjSR = (TH1F*)SR->Get( "hmllCorr_Wjets" );
double SF = wjSR->Integral()/wjCR->Integral();
double Nd = dataCR->Integral();
double Nm = DYCR->Integral()+TopCR->Integral()+DibCR->Integral();
double Nw = (Nd-Nm)*SF;
double NwSR = wjSR->Integral();
double ScFc = Nw/NwSR;
if(m_debug){
std::cout << " WjetTranFact() --> " << std::endl;
std::cout << " Wjet SF = " << SF << " , Ndata (CR) = "
<< Nd << " , Nmc (CR) = " << Nm << " , Nw (SR) = " << NwSR
<< " , Exp. Nw = " << Nw << std::endl;
std::cout << " ---> ScaleFactor = " << ScFc << std::endl;
}
return ScFc;
}
void MakeQCD_tau(std::string sysVar, std::string lfvType,
std::string Dir, std::string charge,
bool useBjet, bool isFFcat, bool isBlind,
bool scaleWjet){
std::string fName = Dir+"Plots_"+sysVar+"_"+lfvType;
if(isBlind)
fName += "_Blind";
m_out = new TFile( (fName+".root").c_str(), "UPDATE");
if(sysVar=="TauFake_BDT_SysUp" || sysVar=="TauFake_BDT_SysDown" ||
sysVar=="TauFake_StatUp" || sysVar=="TauFake_StatDown" ||
sysVar=="TauFake_CR_Sys" || sysVar=="TopFit_Sys" ||
sysVar=="TopScale_SysUp" || sysVar=="TopScale_SysDown" ||
sysVar=="PDF_Sys" ){
CopyFromNominal(Dir,lfvType,useBjet,isBlind);
return;
}
std::string Suff1="", Suff2="", Suff3="";
if(charge==""){
Suff1="_SS"; Suff2=""; Suff3="_SS";
}
else if(charge=="SS"){
Suff1="_OS"; Suff2="_SS"; Suff3="_OS";
}
else if(charge=="OS"){
Suff1="_SS"; Suff2="_OS"; Suff3="_SS";
}
std::string reg2_Name = Dir+"QcdReg2"+Suff1+"/Plots_"+sysVar+"_"+lfvType;
std::string wjcr_Name = Dir+"WjetCR"+Suff1+"/Plots_"+sysVar+"_"+lfvType;
std::string wjsr_Name = Dir+"WjetSR"+Suff1+"/Plots_"+sysVar+"_"+lfvType;
std::string reg3_Name = Dir+"QcdReg3";
std::string reg1_Name = Dir+"QcdReg1";
if(isFFcat){
reg3_Name += Suff2+"/Plots_"+sysVar+"_"+lfvType;
reg1_Name += Suff3+"/Plots_"+sysVar+"_"+lfvType;
}
else{
reg3_Name += "/LepFake/Plots_"+sysVar+"_"+lfvType;
reg1_Name += "_SS/LepFake/Plots_"+sysVar+"_"+lfvType;
}
if(isBlind){
reg2_Name += "_Blind";
wjcr_Name += "_Blind";
wjsr_Name += "_Blind";
reg3_Name += "_Blind";
reg1_Name += "_Blind";
}
TFile *Reg2 = new TFile( (reg2_Name+".root").c_str() );
TFile *WjCR = new TFile( (wjcr_Name+".root").c_str() );
TFile *WjSR = new TFile( (wjsr_Name+".root").c_str() );
TFile *Reg3 = new TFile( (reg3_Name+".root").c_str() );
TFile *Reg1 = new TFile( (reg1_Name+".root").c_str() );
double WjTF = WjetTranFact(WjSR,WjCR);
std::vector<std::string> Names;
Names.push_back( "hmllCorr" );
Names.push_back( "hmll" );
Names.push_back( "hptll" );
Names.push_back( "hptllCorr" );
Names.push_back( "hetall" );
Names.push_back( "hphill" );
Names.push_back( "hmet" );
Names.push_back( "hnjet" );
Names.push_back( "hmt" );
Names.push_back( "hmu_pt" );
Names.push_back( "hmu_eta" );
Names.push_back( "hmu_phi" );
Names.push_back( "hel_pt" );
Names.push_back( "hel_eta" );
Names.push_back( "hel_phi" );
Names.push_back( "hta_pt" );
Names.push_back( "hta_eta" );
Names.push_back( "hta_phi" );
double QcdInt = 0;
for(uint h=0; h<Names.size(); h++){
//if(m_debug)
//std::cout<<" distro "<<Names.at(h)<<std::endl;
TH1F *wjSRSS = (TH1F*)Reg2->Get( (Names.at(h)+"_Wjets" ).c_str() );
TH1F *dataSRSS = (TH1F*)Reg2->Get( (Names.at(h)+"_data" ).c_str() );
TH1F *DYSRSS = (TH1F*)Reg2->Get( (Names.at(h)+"_DY" ).c_str() );
TH1F *TopSRSS = (TH1F*)Reg2->Get( (Names.at(h)+"_Top" ).c_str() );
TH1F *DibSRSS = (TH1F*)Reg2->Get( (Names.at(h)+"_DiBoson").c_str() );
TH1F *wjCRSS = (TH1F*)Reg1->Get( (Names.at(h)+"_Wjets" ).c_str() );
TH1F *dataCRSS = (TH1F*)Reg1->Get( (Names.at(h)+"_data" ).c_str() );
TH1F *DYCRSS = (TH1F*)Reg1->Get( (Names.at(h)+"_DY" ).c_str() );
TH1F *TopCRSS = (TH1F*)Reg1->Get( (Names.at(h)+"_Top" ).c_str() );
TH1F *DibCRSS = (TH1F*)Reg1->Get( (Names.at(h)+"_DiBoson").c_str() );
TH1F *wjCR = (TH1F*)Reg3->Get( (Names.at(h)+"_Wjets" ).c_str() );
TH1F *dataCR = (TH1F*)Reg3->Get( (Names.at(h)+"_data" ).c_str() );
TH1F *DYCR = (TH1F*)Reg3->Get( (Names.at(h)+"_DY" ).c_str() );
TH1F *TopCR = (TH1F*)Reg3->Get( (Names.at(h)+"_Top" ).c_str() );
TH1F *DibCR = (TH1F*)Reg3->Get( (Names.at(h)+"_DiBoson").c_str() );
if(scaleWjet){ wjSRSS->Scale(WjTF); }
double NqcdSR = dataSRSS->Integral()-
( DYSRSS->Integral()+TopSRSS->Integral()+
DibSRSS->Integral()+wjSRSS->Integral() );
if(h==0 && m_debug){
std::cout << " Nqcd in SR (Reg2) = " << NqcdSR << std::endl;
}
double NqcdCR = dataCRSS->Integral()-
( DYCRSS->Integral()+TopCRSS->Integral()+
DibCRSS->Integral()+wjCRSS->Integral() );
double SF = NqcdSR/NqcdCR;
double NumErr2 = ( pow( sqrt(dataSRSS->Integral()),2 ) +
pow( sqrt(DYSRSS->Integral()),2 ) +
pow( sqrt(TopSRSS->Integral()),2 ) +
pow( sqrt(DibSRSS->Integral()),2 ) +
pow( sqrt(wjSRSS->Integral()),2 ) )/pow(NqcdCR,2) ;
double DenErr2 = ( pow( sqrt(dataCRSS->Integral()),2 )+
pow( sqrt(DYCRSS->Integral()),2 ) +
pow( sqrt(TopCRSS->Integral()),2 ) +
pow( sqrt(DibCRSS->Integral()),2 ) +
pow( sqrt(wjCRSS->Integral()),2 ) )*
(NqcdSR/pow( NqcdCR,4 ));
double ErrSF = sqrt( NumErr2+DenErr2 );
if(h==0 && m_debug){
std::cout << " Nqcd in CR (Reg1) = " << NqcdCR << std::endl;
std::cout << " QCD SF = " << SF << " +- " << ErrSF << std::endl;
}
TH1F* TmpQcd = (TH1F*)dataCR->Clone( (Names.at(h)+"_tmpqcd").c_str() );
TmpQcd->Add(wjCR, -1);
TmpQcd->Add(DYCR, -1);
TmpQcd->Add(TopCR, -1);
TmpQcd->Add(DibCR, -1);
if(h==0 && m_debug)
std::cout << " Nqcd before Scaling (Reg3) = "
<< TmpQcd->Integral() << std::endl;
TmpQcd->Scale(SF);
QcdInt = TmpQcd->Integral();
if(h==0 && m_debug){
std::cout << " Nqcd from TH1F Subtraction = "
<< QcdInt << std::endl;
}
TH1F* qcd = (TH1F*)TmpQcd->Clone( (Names.at(h)+"_qcd").c_str() );
qcd->Reset();
for(int b=1; b<TmpQcd->GetNbinsX()+1; b++){
double x = TmpQcd->GetBinContent(b);
double err = TmpQcd->GetBinError(b);
if(x<0) x=0;
qcd->SetBinContent(b, x);
qcd->SetBinError(b, err);
}
//qcd->Draw();
if(h==0 && m_debug){
std::cout << " Nqcd after setting neg. bins to zero = "
<< qcd->Integral() << std::endl;
}
if(qcd->Integral()!=0) qcd->Scale( fabs(QcdInt)/qcd->Integral() );
if(h==0 && m_debug)
std::cout << " Nqcd final = " << qcd->Integral() << std::endl;
TH1F *qcdNorm=NULL;
if(Names.at(h)=="hmllCorr" || Names.at(h)=="hmll")
qcdNorm = ChangeShape(qcd);
/* Writing */
m_out->cd();
if( lfvType=="etau" && (Names.at(h)=="hmllCorr" || Names.at(h)=="hmll") ){
qcd->Write( (Names.at(h)+"_qcd_Orig").c_str() );
qcdNorm->Write( (Names.at(h)+"_qcd").c_str() );
}
else
qcd->Write();
/* Cleaning */
qcd->Delete();
if(Names.at(h)=="mllCorr" || Names.at(h)=="mll")
qcdNorm->Delete();
TmpQcd->Delete();
wjSRSS->Delete();
dataSRSS->Delete();
DYSRSS->Delete();
TopSRSS->Delete();
DibSRSS->Delete();
wjCRSS->Delete();
dataCRSS->Delete();
DYCRSS->Delete();
TopCRSS->Delete();
DibCRSS->Delete();
wjCR->Delete();
dataCR->Delete();
DYCR->Delete();
TopCR->Delete();
DibCR->Delete();
}
/* cleaning */
m_out->Close();
Reg2->Close();
WjCR->Close();
WjSR->Close();
Reg3->Close();
Reg1->Close();
if(m_debug)
std::cout<<""<<std::endl;
}
void CopyFromNominal(std::string Dir, std::string lfvType,
bool useBjet, bool isBlind){
TFile *Nom = NULL;
if(isBlind)
Nom = new TFile( (Dir+"Plots_Nominal_"+lfvType+"_Blind.root").c_str() );
else
Nom = new TFile( (Dir+"Plots_Nominal_"+lfvType+".root").c_str() );
TH1F *mllC = (TH1F*)Nom->Get( "hmllCorr_qcd" );
TH1F *mll = (TH1F*)Nom->Get( "hmll_qcd" );
TH1F *ptllC = (TH1F*)Nom->Get( "hptllCorr_qcd" );
TH1F *ptll = (TH1F*)Nom->Get( "hptll_qcd" );
TH1F *etall = (TH1F*)Nom->Get( "hetall_qcd" );
TH1F *phill = (TH1F*)Nom->Get( "hphill_qcd" );
TH1F *met = (TH1F*)Nom->Get( "hmet_qcd" );
TH1F *njet = (TH1F*)Nom->Get( "hnjet_qcd" );
TH1F *mt = (TH1F*)Nom->Get( "hmt_qcd" );
TH1F *mu_pt = (TH1F*)Nom->Get( "hmu_pt_qcd" );
TH1F *mu_eta = (TH1F*)Nom->Get( "hmu_eta_qcd" );
TH1F *mu_phi = (TH1F*)Nom->Get( "hmu_phi_qcd" );
TH1F *el_pt = (TH1F*)Nom->Get( "hel_pt_qcd" );
TH1F *el_eta = (TH1F*)Nom->Get( "hel_eta_qcd" );
TH1F *el_phi = (TH1F*)Nom->Get( "hel_phi_qcd" );
TH1F *ta_pt = (TH1F*)Nom->Get( "hta_pt_qcd" );
TH1F *ta_eta = (TH1F*)Nom->Get( "hta_eta_qcd" );
TH1F *ta_phi = (TH1F*)Nom->Get( "hta_phi_qcd" );
TH1F *mllC_Or = NULL;
if(lfvType=="etau")
mllC_Or = (TH1F*)Nom->Get( "hmllCorr_qcd_Orig" );
m_out->cd();
mllC -> Write( "hmllCorr_qcd" );
mll -> Write( "hmll_qcd" );
ptllC -> Write( "hptllCorr_qcd" );
ptll -> Write( "hptll_qcd" );
etall -> Write( "hetall_qcd" );
phill -> Write( "hphill_qcd" );
met -> Write( "hmet_qcd" );
njet -> Write( "hnjet_qcd" );
mt -> Write( "hmt_qcd" );
mu_pt -> Write( "hmu_pt_qcd" );
mu_eta -> Write( "hmu_eta_qcd" );
mu_phi -> Write( "hmu_phi_qcd" );
el_pt -> Write( "hel_pt_qcd" );
el_eta -> Write( "hel_eta_qcd" );
el_phi -> Write( "hel_phi_qcd" );
ta_pt -> Write( "hta_pt_qcd" );
ta_eta -> Write( "hta_eta_qcd" );
ta_phi -> Write( "hta_phi_qcd" );
if(lfvType=="etau")
mllC_Or -> Write( "hmllCorr_qcd_Orig" );
mllC -> Delete();
mll -> Delete();
ptllC -> Delete();
ptll -> Delete();
etall -> Delete();
phill -> Delete();
met -> Delete();
njet -> Delete();
mt -> Delete();
mu_pt -> Delete();
mu_eta -> Delete();
mu_phi -> Delete();
el_pt -> Delete();
el_eta -> Delete();
el_phi -> Delete();
ta_pt -> Delete();
ta_eta -> Delete();
ta_phi -> Delete();
if(lfvType=="etau")
mllC_Or -> Delete();
m_out->Close();
Nom->Close();
}
TH1F *ChangeShape(TH1F*qcd){
int Bins = qcd->GetNbinsX();
TH1F *qcdNew = (TH1F*)qcd->Clone("tmp");
qcdNew->Reset();
for(int i=1; i<Bins+1; i++){
double c = qcd->GetBinContent(i);
double e = qcd->GetBinError(i);
/* 60 bins */
if(i<=9){
qcdNew->SetBinContent(i,c+c*1.40);//1.10
}
else if(i>=10 && i<=12)
qcdNew->SetBinContent(i,c+c*0.80);
else if(i>=21 && i<=24)
qcdNew->SetBinContent(i,c-c*0.55);//0.55
else if(i>=25){
qcdNew->SetBinContent(i,c-c*0.65);//0.55
}
else
qcdNew->SetBinContent(i,c);
/* 80 bins -> 40 bins */
//if(i<=11){
// qcdNew->SetBinContent(i,c+c*1.40);//1.10
//}
//else if(i>=12 && i<=17){//16
// qcdNew->SetBinContent(i,c+c*0.20);
//
//}
//else if(i>=28 && i<=31){
// qcdNew->SetBinContent(i,c-c*0.40);
//}
//else if(i>=32){
// qcdNew->SetBinContent(i,c-c*0.65);//0.55
//}
//else
// qcdNew->SetBinContent(i,c);
qcdNew->SetBinError(i,e);
}
return qcdNew;
}