forked from govoni/LHEActions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
macro_pdfReweight.C
100 lines (77 loc) · 2.61 KB
/
macro_pdfReweight.C
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
double mg_scale = 0.0417 / 100000 ;
double ph_scale = 0.0993 / 496500 ;
/*
void addOverflowBin (TH1F * histo)
{
TH1F * outcome = new TH1F ("tempo", histo->GetTitle (), histo->GenNbinsX () + 1,
}
*/
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
void drawTwoHistos (TFile & f_ph, TFile & f_mg, TString name, int reverse = 0)
{
TH1F * h_ph = (TH1F *) f_ph.Get (name) ;
h_ph->SetName (name + "_ph") ;
h_ph->GetXaxis ()->SetTitle (h_ph->GetTitle ()) ;
h_ph->SetTitle ("") ;
h_ph->SetStats (0) ;
TH1F * h_mg = (TH1F *) f_mg.Get (name) ;
h_mg->SetName (name + "_mg") ;
h_mg->GetXaxis ()->SetTitle (h_mg->GetTitle ()) ;
h_mg->SetTitle ("") ;
h_mg->SetStats (0) ;
h_mg->SetLineColor (kRed) ;
h_mg->Scale (mg_scale) ;
h_ph->Scale (ph_scale) ;
leg = new TLegend (0.9, 0.8, 1, 0.9) ;
leg->AddEntry (h_ph, "ph", "l") ;
leg->AddEntry (h_mg, "mg", "lf") ;
h_mg->SetFillColor (kGray) ;
TCanvas c1 ;
if (!reverse)
{
h_mg->Draw ("E2") ;
h_ph->Draw ("Esame") ;
}
else
{
h_ph->Draw ("E") ;
h_mg->Draw ("E2same") ;
h_ph->Draw ("Esame") ;
}
leg->Draw () ;
c1.Print (name + ".pdf", "pdf") ;
return ;
}
int macro_pdfReweight ()
{
TFile f_ph ("reweight_ph.root") ;
TFile f_mg ("reweight_mg.root") ;
// TFile f_ph ("reweight_unweight_ph.root") ;
// TFile f_mg ("reweight_unweight_mg.root") ;
drawTwoHistos (f_ph, f_mg, "h_scale", 1) ;
drawTwoHistos (f_ph, f_mg, "h_x", 1) ;
drawTwoHistos (f_ph, f_mg, "h_mjj", 0) ;
drawTwoHistos (f_ph, f_mg, "h_mll", 1) ;
drawTwoHistos (f_ph, f_mg, "h_ptj1", 1) ;
drawTwoHistos (f_ph, f_mg, "h_ptj2", 0) ;
drawTwoHistos (f_ph, f_mg, "h_etaj1", 1) ;
drawTwoHistos (f_ph, f_mg, "h_etaj2", 0) ;
drawTwoHistos (f_ph, f_mg, "h_weight", 1) ;
TH1F * h_mll_ph = (TH1F *) f_ph.Get ("h_mll") ;
h_mll_ph->SetName ("h_mll_ph") ;
TH1F * h_mll_mg = (TH1F *) f_mg.Get ("h_mll") ;
h_mll_mg->SetName ("h_mll_mg") ;
h_mll_mg->Scale (mg_scale) ;
h_mll_ph->Scale (ph_scale) ;
cout << " \t nocut \t mll_cut\n" ;
cout << "phantom \t" ;
cout << h_mll_ph->Integral () << "\t" ;
cout << h_mll_ph->Integral (h_mll_ph->FindBin (12), h_mll_ph->FindBin (50)) << endl ;
cout << "madgraph\t" ;
cout << h_mll_mg->Integral () << "\t" ;
cout << h_mll_mg->Integral (h_mll_mg->FindBin (12), h_mll_mg->FindBin (50)) << endl ;
cout << "ratio \t" ;
cout << h_mll_ph->Integral () / h_mll_mg->Integral () << "\t" ;
cout << h_mll_ph->Integral (h_mll_ph->FindBin (12), h_mll_ph->FindBin (50)) / h_mll_mg->Integral (h_mll_mg->FindBin (12), h_mll_mg->FindBin (50)) << endl ;
return 0 ;
}