-
Notifications
You must be signed in to change notification settings - Fork 1
/
getLumiEff.C
230 lines (175 loc) · 10.9 KB
/
getLumiEff.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
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
const float zmin = 76; // [GeV]
const float zmax = 106; // [GeV]
bool highpt = false;
int bin_zmin;
int bin_zmax;
int bin_ele_ptmin;
int bin_ele_ptmax;
int bin_muon_ptmin;
int bin_muon_ptmax;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// root -l getLumiEff.C
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void getLumiEff()
{
gInterpreter->ExecuteMacro("PaperStyle.C");
TFile* data = new TFile("results/hadd_data.root","read");
TFile* zjets = new TFile("results/hadd_zjets.root","read");
TFile* wjets = new TFile("results/hadd_wjets.root","read");
float muonjetet = 25.;
float elejetet = 35.;
TString muonsuffix = Form("_%.0fGeV", muonjetet);
TString elesuffix = Form("_%.0fGeV", elejetet);
// DATA
TH2D* h2_Ele_loose_pt_m2l_ZRegion = (TH2D*) data -> Get("FR/01_Zpeak/h_Ele_loose_pt_m2l" + elesuffix);
TH2D* h2_Ele_tight_pt_m2l_ZRegion = (TH2D*) data -> Get("FR/01_Zpeak/h_Ele_tight_pt_m2l" + elesuffix);
TH2D* h2_Muon_loose_pt_m2l_ZRegion = (TH2D*) data -> Get("FR/01_Zpeak/h_Muon_loose_pt_m2l" + muonsuffix);
TH2D* h2_Muon_tight_pt_m2l_ZRegion = (TH2D*) data -> Get("FR/01_Zpeak/h_Muon_tight_pt_m2l" + muonsuffix);
if (!highpt) {
bin_ele_ptmin = -1;
bin_ele_ptmax = h2_Ele_tight_pt_m2l_ZRegion -> ProjectionY() -> FindBin(25.) - 1;
} else {
bin_ele_ptmin = h2_Ele_tight_pt_m2l_ZRegion -> ProjectionY() -> FindBin(25.);
bin_ele_ptmax = -1;
}
if (!highpt) {
bin_muon_ptmin = -1;
bin_muon_ptmax = h2_Muon_tight_pt_m2l_ZRegion -> ProjectionY() -> FindBin(20.) - 1;
} else {
bin_muon_ptmin = h2_Muon_tight_pt_m2l_ZRegion -> ProjectionY() -> FindBin(20.);
bin_muon_ptmax = -1;
}
TH1D* h_Ele_loose_m2l_ZRegion = (TH1D*) h2_Ele_loose_pt_m2l_ZRegion -> ProjectionX("Ele loose m2l data", bin_ele_ptmin, bin_ele_ptmax);
TH1D* h_Ele_tight_m2l_ZRegion = (TH1D*) h2_Ele_tight_pt_m2l_ZRegion -> ProjectionX("Ele tight m2l data", bin_ele_ptmin, bin_ele_ptmax);
TH1D* h_Muon_loose_m2l_ZRegion = (TH1D*) h2_Muon_loose_pt_m2l_ZRegion -> ProjectionX("Muon loose m2l data", bin_muon_ptmin, bin_muon_ptmax);
TH1D* h_Muon_tight_m2l_ZRegion = (TH1D*) h2_Muon_tight_pt_m2l_ZRegion -> ProjectionX("Muon tight m2l data", bin_muon_ptmin, bin_muon_ptmax);
// ZJETS
TH2D* h2_Ele_loose_pt_m2l_ZRegion_zjets = (TH2D*) zjets -> Get("FR/01_Zpeak/h_Ele_loose_pt_m2l" + elesuffix);
TH2D* h2_Ele_tight_pt_m2l_ZRegion_zjets = (TH2D*) zjets -> Get("FR/01_Zpeak/h_Ele_tight_pt_m2l" + elesuffix);
TH2D* h2_Muon_loose_pt_m2l_ZRegion_zjets = (TH2D*) zjets -> Get("FR/01_Zpeak/h_Muon_loose_pt_m2l" + muonsuffix);
TH2D* h2_Muon_tight_pt_m2l_ZRegion_zjets = (TH2D*) zjets -> Get("FR/01_Zpeak/h_Muon_tight_pt_m2l" + muonsuffix);
if (!highpt) {
bin_ele_ptmin = -1;
bin_ele_ptmax = h2_Ele_tight_pt_m2l_ZRegion -> ProjectionY() -> FindBin(25.) - 1;
} else {
bin_ele_ptmin = h2_Ele_tight_pt_m2l_ZRegion -> ProjectionY() -> FindBin(25.);
bin_ele_ptmax = -1;
}
if (!highpt) {
bin_muon_ptmin = -1;
bin_muon_ptmax = h2_Muon_tight_pt_m2l_ZRegion -> ProjectionY() -> FindBin(20.) - 1;
} else {
bin_muon_ptmin = h2_Muon_tight_pt_m2l_ZRegion -> ProjectionY() -> FindBin(20.);
bin_muon_ptmax = -1;
}
TH1D* h_Ele_loose_m2l_ZRegion_zjets = (TH1D*) h2_Ele_loose_pt_m2l_ZRegion_zjets -> ProjectionX("Ele loose m2l zjets", bin_ele_ptmin, bin_ele_ptmax);
TH1D* h_Ele_tight_m2l_ZRegion_zjets = (TH1D*) h2_Ele_tight_pt_m2l_ZRegion_zjets -> ProjectionX("Ele tight m2l zjets", bin_ele_ptmin, bin_ele_ptmax);
TH1D* h_Muon_loose_m2l_ZRegion_zjets = (TH1D*) h2_Muon_loose_pt_m2l_ZRegion_zjets -> ProjectionX("Muon loose m2l zjets", bin_muon_ptmin, bin_muon_ptmax);
TH1D* h_Muon_tight_m2l_ZRegion_zjets = (TH1D*) h2_Muon_tight_pt_m2l_ZRegion_zjets -> ProjectionX("Muon tight m2l zjets", bin_muon_ptmin, bin_muon_ptmax);
// WJETS
TH2D* h2_Ele_loose_pt_m2l_ZRegion_wjets = (TH2D*) wjets -> Get("FR/01_Zpeak/h_Ele_loose_pt_m2l" + elesuffix);
TH2D* h2_Ele_tight_pt_m2l_ZRegion_wjets = (TH2D*) wjets -> Get("FR/01_Zpeak/h_Ele_tight_pt_m2l" + elesuffix);
TH2D* h2_Muon_loose_pt_m2l_ZRegion_wjets = (TH2D*) wjets -> Get("FR/01_Zpeak/h_Muon_loose_pt_m2l" + muonsuffix);
TH2D* h2_Muon_tight_pt_m2l_ZRegion_wjets = (TH2D*) wjets -> Get("FR/01_Zpeak/h_Muon_tight_pt_m2l" + muonsuffix);
if (!highpt) {
bin_ele_ptmin = -1;
bin_ele_ptmax = h2_Ele_tight_pt_m2l_ZRegion -> ProjectionY() -> FindBin(25.) - 1;
} else {
bin_ele_ptmin = h2_Ele_tight_pt_m2l_ZRegion -> ProjectionY() -> FindBin(25.);
bin_ele_ptmax = -1;
}
if (!highpt) {
bin_muon_ptmin = -1;
bin_muon_ptmax = h2_Muon_tight_pt_m2l_ZRegion -> ProjectionY() -> FindBin(20.) - 1;
} else {
bin_muon_ptmin = h2_Muon_tight_pt_m2l_ZRegion -> ProjectionY() -> FindBin(20.);
bin_muon_ptmax = -1;
}
TH1D* h_Ele_loose_m2l_ZRegion_wjets = (TH1D*) h2_Ele_loose_pt_m2l_ZRegion_wjets -> ProjectionX("Ele loose m2l wjets", bin_ele_ptmin, bin_ele_ptmax);
TH1D* h_Ele_tight_m2l_ZRegion_wjets = (TH1D*) h2_Ele_tight_pt_m2l_ZRegion_wjets -> ProjectionX("Ele tight m2l wjets", bin_ele_ptmin, bin_ele_ptmax);
TH1D* h_Muon_loose_m2l_ZRegion_wjets = (TH1D*) h2_Muon_loose_pt_m2l_ZRegion_wjets -> ProjectionX("Muon loose m2l wjets", bin_muon_ptmin, bin_muon_ptmax);
TH1D* h_Muon_tight_m2l_ZRegion_wjets = (TH1D*) h2_Muon_tight_pt_m2l_ZRegion_wjets -> ProjectionX("Muon tight m2l wjets", bin_muon_ptmin, bin_muon_ptmax);
bin_zmin = h_Ele_loose_m2l_ZRegion->FindBin(zmin);
bin_zmax = h_Ele_loose_m2l_ZRegion->FindBin(zmax);
// Effective luminosity calculation
printf("============ Data ============ \n \n");
float ele_loose_data = h_Ele_loose_m2l_ZRegion -> Integral(bin_zmin, bin_zmax);
float ele_tight_data = h_Ele_tight_m2l_ZRegion -> Integral(bin_zmin, bin_zmax);
float muon_loose_data = h_Muon_loose_m2l_ZRegion -> Integral(bin_zmin, bin_zmax);
float muon_tight_data = h_Muon_tight_m2l_ZRegion -> Integral(bin_zmin, bin_zmax);
printf("Loose electrons in the Z window = %.0f \n", ele_loose_data);
printf("Tight electrons in the Z window = %.0f \n", ele_tight_data);
printf("Loose muons in the Z window = %.0f \n", muon_loose_data);
printf("Tight muons in the Z window = %.0f \n \n", muon_tight_data);
float ele_loose_tt = 0.;
float ele_tight_tt = 0.;
float muon_loose_tt = 0.;
float muon_tight_tt = 0.;
/*
printf("============ TT ============ \n \n");
float ele_loose_tt = h_Ele_loose_m2l_ZRegion_tt -> Integral(bin_zmin, bin_zmax);
float ele_tight_tt = h_Ele_tight_m2l_ZRegion_tt -> Integral(bin_zmin, bin_zmax);
float muon_loose_tt = h_Muon_loose_m2l_ZRegion_tt -> Integral(bin_zmin, bin_zmax);
float muon_tight_tt = h_Muon_tight_m2l_ZRegion_tt -> Integral(bin_zmin, bin_zmax);
printf("Loose electrons in the Z window = %.0f \n", ele_loose_tt);
printf("Tight electrons in the Z window = %.0f \n", ele_tight_tt);
printf("Loose muons in the Z window = %.0f \n", muon_loose_tt);
printf("Tight muons in the Z window = %.0f \n \n", muon_tight_tt);
*/
printf("============ ZJets ============ \n \n");
float ele_loose_zjets = h_Ele_loose_m2l_ZRegion_zjets -> Integral(bin_zmin, bin_zmax);
float ele_tight_zjets = h_Ele_tight_m2l_ZRegion_zjets -> Integral(bin_zmin, bin_zmax);
float muon_loose_zjets = h_Muon_loose_m2l_ZRegion_zjets -> Integral(bin_zmin, bin_zmax);
float muon_tight_zjets = h_Muon_tight_m2l_ZRegion_zjets -> Integral(bin_zmin, bin_zmax);
printf("Loose electrons in the Z window = %.0f \n", ele_loose_zjets);
printf("Tight electrons in the Z window = %.0f \n", ele_tight_zjets);
printf("Loose muons in the Z window = %.0f \n", muon_loose_zjets);
printf("Tight muons in the Z window = %.0f \n \n", muon_tight_zjets);
printf("============ WJets ============ \n \n");
float ele_loose_wjets = max(0.0, h_Ele_loose_m2l_ZRegion_wjets -> Integral(bin_zmin, bin_zmax));
float ele_tight_wjets = max(0.0, h_Ele_tight_m2l_ZRegion_wjets -> Integral(bin_zmin, bin_zmax));
float muon_loose_wjets = max(0.0, h_Muon_loose_m2l_ZRegion_wjets -> Integral(bin_zmin, bin_zmax));
float muon_tight_wjets = max(0.0, h_Muon_tight_m2l_ZRegion_wjets -> Integral(bin_zmin, bin_zmax));
printf("Loose electrons in the Z window = %.0f \n", ele_loose_wjets);
printf("Tight electrons in the Z window = %.0f \n", ele_tight_wjets);
printf("Loose muons in the Z window = %.0f \n", muon_loose_wjets);
printf("Tight muons in the Z window = %.0f \n \n", muon_tight_wjets);
float lum_ele_loose = 0.;
float lum_ele_tight = 0.;
float lum_muon_loose = 0.;
float lum_muon_tight = 0.;
lum_ele_loose = ele_loose_data / (ele_loose_tt + ele_loose_zjets + ele_loose_wjets);
lum_ele_tight = ele_tight_data / (ele_tight_tt + ele_tight_zjets + ele_tight_wjets);
lum_muon_loose = muon_loose_data / (muon_loose_tt + muon_loose_zjets + muon_loose_wjets);
lum_muon_tight = muon_tight_data / (muon_tight_tt + muon_tight_zjets + muon_tight_wjets);
// Statistic uncertainty
float stat_ele_loose = 0.0;
float stat_ele_tight = 0.0;
float stat_muon_loose = 0.0;
float stat_muon_tight = 0.0;
float first_term = pow(1/sqrt(ele_loose_data),2);
float second_term = pow((sqrt(ele_loose_tt) + sqrt(ele_loose_zjets) + sqrt(ele_loose_wjets)) / (ele_loose_tt + ele_loose_zjets + ele_loose_wjets),2);
stat_ele_loose = lum_ele_loose * sqrt(first_term + second_term);
first_term = pow(1/sqrt(ele_tight_data),2);
second_term = pow((sqrt(ele_tight_tt) + sqrt(ele_tight_zjets) + sqrt(ele_tight_wjets)) / (ele_tight_tt + ele_tight_zjets + ele_tight_wjets),2);
stat_ele_tight = lum_ele_tight * sqrt(first_term + second_term);
first_term = pow(1/sqrt(muon_loose_data),2);
second_term = pow((sqrt(muon_loose_tt) + sqrt(muon_loose_zjets) + sqrt(muon_loose_wjets)) / (muon_loose_tt + muon_loose_zjets + muon_loose_wjets),2);
stat_muon_loose = lum_muon_loose * sqrt(first_term + second_term);
first_term = pow(1/sqrt(muon_tight_data),2);
second_term = pow((sqrt(muon_tight_tt) + sqrt(muon_tight_zjets) + sqrt(muon_tight_wjets)) / (muon_tight_tt + muon_tight_zjets + muon_tight_wjets),2);
stat_muon_tight = lum_muon_tight * sqrt(first_term + second_term);
printf("===================== Effective luminosity ===================== \n \n");
printf("Effective luminosity in electrons loose = (%.2f pm %.2f) pb\n", 1e3 * lum_ele_loose, 1e3 * stat_ele_loose);
printf("Effective luminosity in electrons tight = (%.2f pm %.2f) pb\n", 1e3 * lum_ele_tight, 1e3 * stat_ele_tight);
printf("Effective luminosity in muons loose = (%.2f pm %.2f) pb\n", 1e3 * lum_muon_loose, 1e3 * stat_muon_loose);
printf("Effective luminosity in muons tight = (%.2f pm %.2f) pb\n", 1e3 * lum_muon_tight, 1e3 * stat_muon_tight);
printf("\n");
printf(" Z-peak data/MC in electrons loose = %.3f\n", lum_ele_loose);
printf(" Z-peak data/MC in electrons tight = %.3f\n", lum_ele_tight);
printf(" Z-peak data/MC in muons loose = %.3f\n", lum_muon_loose);
printf(" Z-peak data/MC in muons tight = %.3f\n", lum_muon_tight);
printf("\n");
}