1 |
#include "EfficiencyWeights.h"
|
2 |
#include "EfficiencyWeightsInterface.h"
|
3 |
#include "TriggerUtils.h"
|
4 |
#include "TriggerUtilsBits.h"
|
5 |
|
6 |
#include <assert.h>
|
7 |
#include <math.h>
|
8 |
#include <iostream>
|
9 |
|
10 |
#include "TFile.h"
|
11 |
#include "TH2D.h"
|
12 |
|
13 |
void initEfficiencyWeights(void) {
|
14 |
|
15 |
TFile * f;
|
16 |
|
17 |
//
|
18 |
// 2012
|
19 |
//
|
20 |
string effPath2012(CMSSW_BASE);
|
21 |
string path_mu_idiso_s12_pu2012 = (effPath2012+string("/src/MitHzz4l/data/muon_scale_factors/muonid_hcp-05.10.2012-with-tk-v2.root"));
|
22 |
string path_ele_recoidisosip_2012 =
|
23 |
(effPath2012+string("/src/MitHzz4l/data/electron_scale_factors/Electron_scale_factors_IDISOSIP_combined.root"));
|
24 |
|
25 |
// HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL
|
26 |
string path_ele_trigger_17GeV_pu2012ab =
|
27 |
(effPath2012+string("/src/MitHzz4l/data/electron_eff_scale_factors_fulltotrigger_ele17_ele8_ele17obj.2012.Z.root"));
|
28 |
string path_ele_trigger_8GeV_pu2012ab = // CHANGE ME!
|
29 |
(effPath2012+string("/src/MitHzz4l/data/electron_eff_scale_factors_fulltotrigger_ele17_ele8_ele17obj.2012.Z.root"));
|
30 |
|
31 |
// HLT_Mu17_Mu8, HLT_Mu17_Trk8
|
32 |
string path_mu_trigger_17GeV_pu2012ab =
|
33 |
(effPath2012+string("/src/MitHzz4l/data/muon_eff_scale_factors_fulltotrigger_mu17_mu8_mu17obj.2012.Z.root"));
|
34 |
string path_mu_trigger_8GeV_pu2012ab = // CHANGE ME!
|
35 |
(effPath2012+string("/src/MitHzz4l/data/muon_eff_scale_factors_fulltotrigger_mu17_mu8_mu17obj.2012.Z.root"));
|
36 |
string path_mu_trigger_8GeV_trk_pu2012ab = // CHANGE ME!
|
37 |
(effPath2012+string("/src/MitHzz4l/data/muon_eff_scale_factors_fulltotrigger_mu17_mu8_mu17obj.2012.Z.root"));
|
38 |
|
39 |
//
|
40 |
// 2012
|
41 |
//
|
42 |
// USED
|
43 |
std::cout << " going to open " << path_mu_idiso_s12_pu2012 << " ..." << std::endl;
|
44 |
f = new TFile(path_mu_idiso_s12_pu2012.c_str());
|
45 |
h_mu_effsf_idiso_s12_pu2012 = (TH2D*)(f->Get("TH2D_ALL_2012")->Clone());
|
46 |
h_mu_effsf_idiso_s12_pu2012->SetDirectory(0);
|
47 |
f->Close();
|
48 |
|
49 |
f = new TFile(path_ele_trigger_17GeV_pu2012ab.c_str());
|
50 |
h_ele_effsf_trigger_17GeV_pu2012ab = (TH2D*)(f->Get("efficiency_scale_factors")->Clone());
|
51 |
h_ele_effsf_trigger_17GeV_pu2012ab->SetDirectory(0);
|
52 |
f->Close();
|
53 |
f = new TFile(path_ele_trigger_8GeV_pu2012ab.c_str());
|
54 |
h_ele_effsf_trigger_8GeV_pu2012ab = (TH2D*)(f->Get("efficiency_scale_factors")->Clone());
|
55 |
h_ele_effsf_trigger_8GeV_pu2012ab->SetDirectory(0);
|
56 |
f->Close();
|
57 |
f = new TFile(path_mu_trigger_17GeV_pu2012ab.c_str());
|
58 |
h_mu_effsf_trigger_17GeV_pu2012ab = (TH2D*)(f->Get("efficiency_scale_factors")->Clone());
|
59 |
h_mu_effsf_trigger_17GeV_pu2012ab->SetDirectory(0);
|
60 |
f->Close();
|
61 |
f = new TFile(path_mu_trigger_8GeV_pu2012ab.c_str());
|
62 |
h_mu_effsf_trigger_8GeV_pu2012ab = (TH2D*)(f->Get("efficiency_scale_factors")->Clone());
|
63 |
h_mu_effsf_trigger_8GeV_pu2012ab->SetDirectory(0);
|
64 |
f->Close();
|
65 |
f = new TFile(path_mu_trigger_8GeV_trk_pu2012ab.c_str());
|
66 |
h_mu_effsf_trigger_8GeV_trk_pu2012ab = (TH2D*)(f->Get("efficiency_scale_factors")->Clone());
|
67 |
h_mu_effsf_trigger_8GeV_trk_pu2012ab->SetDirectory(0);
|
68 |
f->Close();
|
69 |
|
70 |
//
|
71 |
// 2011
|
72 |
//
|
73 |
string effPath("/scratch/dkralph/ksung/releases/CMSSW_4_2_3_patch2/src/");
|
74 |
if(TString(getenv("HOSTNAME")).Contains("cern.ch"))
|
75 |
effPath = "/afs/cern.ch/work/d/dkralph/ksung/releases/CMSSW_4_2_3_patch2/src/";
|
76 |
|
77 |
// muons
|
78 |
string path_mu_idiso_2011 =
|
79 |
(CMSSW_BASE + string("/src/MitHzz4l/data/muon_scale_factors/muonid_hcp-05.10.2012-with-tk-v2.root"));
|
80 |
string path_mu_trigger_doublemu7_2011a =
|
81 |
(effPath+string("/HiggsAna/HZZ4l/Efficiency/Run2011A_HLT_DoubleMu7/default/eff.root"));
|
82 |
string path_mu_trigger_doublemu_leading_2011a =
|
83 |
(effPath+string("/HiggsAna/HZZ4l/Efficiency/Run2011A_o03__HLT_Mu13_Mu8_leading/default/eff.root"));
|
84 |
string path_mu_trigger_doublemu_trailing_2011a =
|
85 |
(effPath+string("/HiggsAna/HZZ4l/Efficiency/Run2011A_o03__HLT_Mu13_Mu8_trailing/default/eff.root"));
|
86 |
string path_mu_idiso_2011b =
|
87 |
(effPath+string("/HiggsAna/HZZ4l/Efficiency/Run2011B_MuonWPEffTP/default/eff.root"));
|
88 |
string path_mu_trigger_doublemu_leading_2011b =
|
89 |
(effPath+string("/HiggsAna/HZZ4l/Efficiency/Run2011B_HLT_DoubleMu_leading/default/eff.root"));
|
90 |
string path_mu_trigger_doublemu_trailing_2011b =
|
91 |
(effPath+string("/HiggsAna/HZZ4l/Efficiency/Run2011B_HLT_DoubleMu_trailing/default/eff.root"));
|
92 |
|
93 |
// electrons
|
94 |
string path_ele_recoidisoip_2011 =
|
95 |
(CMSSW_BASE+string("/src/MitHzz4l/data/electron_scale_factors/scale_factors_ele2011.root"));
|
96 |
string path_ele_trigger_doubleele_leading_wrt_medium_2011a =
|
97 |
(effPath+string("/HiggsAna/HZZ4l/Efficiency/old2/Run2011A_HLT_DoubleEle_leading-medium/default/eff.root"));
|
98 |
string path_ele_trigger_doubleele_leading_wrt_loose_2011a =
|
99 |
(effPath+string("/HiggsAna/HZZ4l/Efficiency/old2/Run2011A_HLT_DoubleEle_leading-loose/default/eff.root"));
|
100 |
string path_ele_trigger_doubleele_trailing_wrt_medium_2011a =
|
101 |
(effPath+string("/HiggsAna/HZZ4l/Efficiency/old2/Run2011A_HLT_DoubleEle_trailing-medium/default/eff.root"));
|
102 |
string path_ele_trigger_doubleele_trailing_wrt_loose_2011a =
|
103 |
(effPath+string("/HiggsAna/HZZ4l/Efficiency/old2/Run2011A_HLT_DoubleEle_trailing-loose/default/eff.root"));
|
104 |
string path_ele_idiso_medium_2011b =
|
105 |
(effPath+string("/HiggsAna/HZZ4l/Efficiency/old2/Run2011B_EleWPEffTP-medium/default/eff.root"));
|
106 |
string path_ele_idiso_loose_2011b =
|
107 |
(effPath+string("/HiggsAna/HZZ4l/Efficiency/old2/Run2011B_EleWPEffTP-loose/default/eff.root"));
|
108 |
string path_ele_trigger_doubleele_leading_wrt_medium_2011b =
|
109 |
(effPath+string("/HiggsAna/HZZ4l/Efficiency/old2/Run2011B_HLT_DoubleEle_L1_DoubleEG_leading-medium/default/eff.root"));
|
110 |
string path_ele_trigger_doubleele_leading_wrt_loose_2011b =
|
111 |
(effPath+string("/HiggsAna/HZZ4l/Efficiency/old2/Run2011B_HLT_DoubleEle_L1_DoubleEG_leading-loose/default/eff.root"));
|
112 |
string path_ele_trigger_doubleele_trailing_wrt_medium_2011b =
|
113 |
(effPath+string("/HiggsAna/HZZ4l/Efficiency/old2/Run2011B_HLT_DoubleEle_L1_DoubleEG_trailing-loose/default/eff.root"));
|
114 |
string path_ele_trigger_doubleele_trailing_wrt_loose_2011b =
|
115 |
(effPath+string("/HiggsAna/HZZ4l/Efficiency/old2/Run2011B_HLT_DoubleEle_L1_DoubleEG_trailing-medium/default/eff.root"));
|
116 |
|
117 |
|
118 |
// electrons
|
119 |
string path_ele_trigger_doubleele_leading_wrt_medium_2011 =
|
120 |
(effPath+string("/HiggsAna/HZZ4l/Efficiency/old2/Data_HLT_DoubleEle_leading-medium/default/eff.root"));
|
121 |
string path_ele_trigger_doubleele_leading_wrt_loose_2011 =
|
122 |
(effPath+string("/HiggsAna/HZZ4l/Efficiency/old2/Data_HLT_DoubleEle_leading-loose/default/eff.root"));
|
123 |
string path_ele_trigger_doubleele_trailing_wrt_medium_2011 =
|
124 |
(effPath+string("/HiggsAna/HZZ4l/Efficiency/old2/Data_HLT_DoubleEle_trailing-medium/default/eff.root"));
|
125 |
string path_ele_trigger_doubleele_trailing_wrt_loose_2011 =
|
126 |
(effPath+string("/HiggsAna/HZZ4l/Efficiency/old2/Data_HLT_DoubleEle_trailing-loose/default/eff.root"));
|
127 |
|
128 |
|
129 |
std::cout << " initializing efficiency weights: " << endl;
|
130 |
std::cout << " opening path_mu_idiso_2011 : " << path_mu_idiso_2011.c_str() << std::endl;
|
131 |
f = new TFile(path_mu_idiso_2011.c_str());
|
132 |
h_mu_effsf_idiso_2011a = (TH2D*)(f->Get("TH2D_ALL_2011A")) ;
|
133 |
h_mu_effsf_idiso_2011a->SetDirectory(0);
|
134 |
h_mu_effsf_idiso_2011b = (TH2D*)(f->Get("TH2D_ALL_2011B")) ;
|
135 |
h_mu_effsf_idiso_2011b->SetDirectory(0);
|
136 |
f->Close();
|
137 |
|
138 |
f = new TFile(path_mu_trigger_doublemu7_2011a.c_str());
|
139 |
h_mu_effdata_trigger_doublemu7_2011a = (TH2D*)(f->Get("hEffEtaPt")->Clone());
|
140 |
h_mu_effdata_trigger_doublemu7_2011a_errlo = (TH2D*)(f->Get("hErrlEtaPt")->Clone());
|
141 |
h_mu_effdata_trigger_doublemu7_2011a_errhi = (TH2D*)(f->Get("hErrhEtaPt")->Clone());
|
142 |
h_mu_effdata_trigger_doublemu7_2011a->SetDirectory(0);
|
143 |
h_mu_effdata_trigger_doublemu7_2011a_errlo->SetDirectory(0);
|
144 |
h_mu_effdata_trigger_doublemu7_2011a_errhi->SetDirectory(0);
|
145 |
f->Close();
|
146 |
|
147 |
f = new TFile(path_mu_trigger_doublemu_leading_2011a.c_str());
|
148 |
h_mu_effdata_trigger_doublemu_leading_2011a = (TH2D*)(f->Get("hEffEtaPt")->Clone());
|
149 |
h_mu_effdata_trigger_doublemu_leading_2011a_errlo = (TH2D*)(f->Get("hErrlEtaPt")->Clone());
|
150 |
h_mu_effdata_trigger_doublemu_leading_2011a_errhi = (TH2D*)(f->Get("hErrhEtaPt")->Clone());
|
151 |
h_mu_effdata_trigger_doublemu_leading_2011a->SetDirectory(0);
|
152 |
h_mu_effdata_trigger_doublemu_leading_2011a_errlo->SetDirectory(0);
|
153 |
h_mu_effdata_trigger_doublemu_leading_2011a_errhi->SetDirectory(0);
|
154 |
f->Close();
|
155 |
|
156 |
f = new TFile(path_mu_trigger_doublemu_trailing_2011a.c_str());
|
157 |
h_mu_effdata_trigger_doublemu_trailing_2011a = (TH2D*)(f->Get("hEffEtaPt")->Clone());
|
158 |
h_mu_effdata_trigger_doublemu_trailing_2011a_errlo = (TH2D*)(f->Get("hErrlEtaPt")->Clone());
|
159 |
h_mu_effdata_trigger_doublemu_trailing_2011a_errhi = (TH2D*)(f->Get("hErrhEtaPt")->Clone());
|
160 |
h_mu_effdata_trigger_doublemu_trailing_2011a->SetDirectory(0);
|
161 |
h_mu_effdata_trigger_doublemu_trailing_2011a_errlo->SetDirectory(0);
|
162 |
h_mu_effdata_trigger_doublemu_trailing_2011a_errhi->SetDirectory(0);
|
163 |
f->Close();
|
164 |
|
165 |
|
166 |
f = new TFile(path_mu_trigger_doublemu_leading_2011b.c_str());
|
167 |
h_mu_effdata_trigger_doublemu_leading_2011b = (TH2D*)(f->Get("hEffEtaPt")->Clone());
|
168 |
h_mu_effdata_trigger_doublemu_leading_2011b_errlo = (TH2D*)(f->Get("hErrlEtaPt")->Clone());
|
169 |
h_mu_effdata_trigger_doublemu_leading_2011b_errhi = (TH2D*)(f->Get("hErrhEtaPt")->Clone());
|
170 |
h_mu_effdata_trigger_doublemu_leading_2011b->SetDirectory(0);
|
171 |
h_mu_effdata_trigger_doublemu_leading_2011b_errlo->SetDirectory(0);
|
172 |
h_mu_effdata_trigger_doublemu_leading_2011b_errhi->SetDirectory(0);
|
173 |
f->Close();
|
174 |
|
175 |
f = new TFile(path_mu_trigger_doublemu_trailing_2011b.c_str());
|
176 |
h_mu_effdata_trigger_doublemu_trailing_2011b = (TH2D*)(f->Get("hEffEtaPt")->Clone());
|
177 |
h_mu_effdata_trigger_doublemu_trailing_2011b_errlo = (TH2D*)(f->Get("hErrlEtaPt")->Clone());
|
178 |
h_mu_effdata_trigger_doublemu_trailing_2011b_errhi = (TH2D*)(f->Get("hErrhEtaPt")->Clone());
|
179 |
h_mu_effdata_trigger_doublemu_trailing_2011b->SetDirectory(0);
|
180 |
h_mu_effdata_trigger_doublemu_trailing_2011b_errlo->SetDirectory(0);
|
181 |
h_mu_effdata_trigger_doublemu_trailing_2011b_errhi->SetDirectory(0);
|
182 |
f->Close();
|
183 |
|
184 |
|
185 |
// electrons
|
186 |
|
187 |
|
188 |
f = new TFile(path_ele_recoidisoip_2011.c_str());
|
189 |
h_ele_effsf_recoidisosip_2011 = (TH2D*)(f->Get("h_electron_scale_factor_RECO_ID_ISO_SIP")) ;
|
190 |
h_ele_effsf_recoidisosip_2011->SetDirectory(0);
|
191 |
f->Close();
|
192 |
|
193 |
|
194 |
//
|
195 |
// 2012
|
196 |
//
|
197 |
std::cout << " going to open " << path_ele_recoidisosip_2012 << " ..." << std::endl;
|
198 |
f = new TFile(path_ele_recoidisosip_2012.c_str());
|
199 |
h_ele_effsf_recoidisosip_2012 = (TH2D*)(f->Get("h_electron_scale_factor_RECO_ID_ISO_SIP")->Clone());
|
200 |
h_ele_effsf_recoidisosip_2012->SetDirectory(0);
|
201 |
f->Close();
|
202 |
|
203 |
f = new TFile(path_ele_trigger_doubleele_leading_wrt_medium_2011a.c_str());
|
204 |
h_ele_effdata_trigger_doubleele_leading_wrt_medium_2011a = (TH2D*)(f->Get("hEffEtaPt")->Clone());
|
205 |
h_ele_effdata_trigger_doubleele_leading_wrt_medium_2011a_errlo = (TH2D*)(f->Get("hErrlEtaPt")->Clone());
|
206 |
h_ele_effdata_trigger_doubleele_leading_wrt_medium_2011a_errhi = (TH2D*)(f->Get("hErrhEtaPt")->Clone());
|
207 |
h_ele_effdata_trigger_doubleele_leading_wrt_medium_2011a->SetDirectory(0);
|
208 |
h_ele_effdata_trigger_doubleele_leading_wrt_medium_2011a_errlo->SetDirectory(0);
|
209 |
h_ele_effdata_trigger_doubleele_leading_wrt_medium_2011a_errhi->SetDirectory(0);
|
210 |
f->Close();
|
211 |
|
212 |
f = new TFile(path_ele_trigger_doubleele_leading_wrt_loose_2011a.c_str());
|
213 |
h_ele_effdata_trigger_doubleele_leading_wrt_loose_2011a = (TH2D*)(f->Get("hEffEtaPt")->Clone());
|
214 |
h_ele_effdata_trigger_doubleele_leading_wrt_loose_2011a_errlo = (TH2D*)(f->Get("hErrlEtaPt")->Clone());
|
215 |
h_ele_effdata_trigger_doubleele_leading_wrt_loose_2011a_errhi = (TH2D*)(f->Get("hErrhEtaPt")->Clone());
|
216 |
h_ele_effdata_trigger_doubleele_leading_wrt_loose_2011a->SetDirectory(0);
|
217 |
h_ele_effdata_trigger_doubleele_leading_wrt_loose_2011a_errlo->SetDirectory(0);
|
218 |
h_ele_effdata_trigger_doubleele_leading_wrt_loose_2011a_errhi->SetDirectory(0);
|
219 |
f->Close();
|
220 |
|
221 |
|
222 |
f = new TFile(path_ele_trigger_doubleele_trailing_wrt_medium_2011a.c_str());
|
223 |
h_ele_effdata_trigger_doubleele_trailing_wrt_medium_2011a = (TH2D*)(f->Get("hEffEtaPt")->Clone());
|
224 |
h_ele_effdata_trigger_doubleele_trailing_wrt_medium_2011a_errlo = (TH2D*)(f->Get("hErrlEtaPt")->Clone());
|
225 |
h_ele_effdata_trigger_doubleele_trailing_wrt_medium_2011a_errhi = (TH2D*)(f->Get("hErrhEtaPt")->Clone());
|
226 |
h_ele_effdata_trigger_doubleele_trailing_wrt_medium_2011a->SetDirectory(0);
|
227 |
h_ele_effdata_trigger_doubleele_trailing_wrt_medium_2011a_errlo->SetDirectory(0);
|
228 |
h_ele_effdata_trigger_doubleele_trailing_wrt_medium_2011a_errhi->SetDirectory(0);
|
229 |
f->Close();
|
230 |
|
231 |
f = new TFile(path_ele_trigger_doubleele_trailing_wrt_loose_2011a.c_str());
|
232 |
h_ele_effdata_trigger_doubleele_trailing_wrt_loose_2011a = (TH2D*)(f->Get("hEffEtaPt")->Clone());
|
233 |
h_ele_effdata_trigger_doubleele_trailing_wrt_loose_2011a_errlo = (TH2D*)(f->Get("hErrlEtaPt")->Clone());
|
234 |
h_ele_effdata_trigger_doubleele_trailing_wrt_loose_2011a_errhi = (TH2D*)(f->Get("hErrhEtaPt")->Clone());
|
235 |
h_ele_effdata_trigger_doubleele_trailing_wrt_loose_2011a->SetDirectory(0);
|
236 |
h_ele_effdata_trigger_doubleele_trailing_wrt_loose_2011a_errlo->SetDirectory(0);
|
237 |
h_ele_effdata_trigger_doubleele_trailing_wrt_loose_2011a_errhi->SetDirectory(0);
|
238 |
f->Close();
|
239 |
|
240 |
|
241 |
|
242 |
f = new TFile(path_ele_trigger_doubleele_leading_wrt_medium_2011b.c_str());
|
243 |
h_ele_effdata_trigger_doubleele_leading_wrt_medium_2011b = (TH2D*)(f->Get("hEffEtaPt")->Clone());
|
244 |
h_ele_effdata_trigger_doubleele_leading_wrt_medium_2011b_errlo = (TH2D*)(f->Get("hErrlEtaPt")->Clone());
|
245 |
h_ele_effdata_trigger_doubleele_leading_wrt_medium_2011b_errhi = (TH2D*)(f->Get("hErrhEtaPt")->Clone());
|
246 |
h_ele_effdata_trigger_doubleele_leading_wrt_medium_2011b->SetDirectory(0);
|
247 |
h_ele_effdata_trigger_doubleele_leading_wrt_medium_2011b_errlo->SetDirectory(0);
|
248 |
h_ele_effdata_trigger_doubleele_leading_wrt_medium_2011b_errhi->SetDirectory(0);
|
249 |
f->Close();
|
250 |
|
251 |
f = new TFile(path_ele_trigger_doubleele_leading_wrt_loose_2011b.c_str());
|
252 |
h_ele_effdata_trigger_doubleele_leading_wrt_loose_2011b = (TH2D*)(f->Get("hEffEtaPt")->Clone());
|
253 |
h_ele_effdata_trigger_doubleele_leading_wrt_loose_2011b_errlo = (TH2D*)(f->Get("hErrlEtaPt")->Clone());
|
254 |
h_ele_effdata_trigger_doubleele_leading_wrt_loose_2011b_errhi = (TH2D*)(f->Get("hErrhEtaPt")->Clone());
|
255 |
h_ele_effdata_trigger_doubleele_leading_wrt_loose_2011b->SetDirectory(0);
|
256 |
h_ele_effdata_trigger_doubleele_leading_wrt_loose_2011b_errlo->SetDirectory(0);
|
257 |
h_ele_effdata_trigger_doubleele_leading_wrt_loose_2011b_errhi->SetDirectory(0);
|
258 |
f->Close();
|
259 |
|
260 |
|
261 |
f = new TFile(path_ele_trigger_doubleele_trailing_wrt_medium_2011b.c_str());
|
262 |
h_ele_effdata_trigger_doubleele_trailing_wrt_medium_2011b = (TH2D*)(f->Get("hEffEtaPt")->Clone());
|
263 |
h_ele_effdata_trigger_doubleele_trailing_wrt_medium_2011b_errlo = (TH2D*)(f->Get("hErrlEtaPt")->Clone());
|
264 |
h_ele_effdata_trigger_doubleele_trailing_wrt_medium_2011b_errhi = (TH2D*)(f->Get("hErrhEtaPt")->Clone());
|
265 |
h_ele_effdata_trigger_doubleele_trailing_wrt_medium_2011b->SetDirectory(0);
|
266 |
h_ele_effdata_trigger_doubleele_trailing_wrt_medium_2011b_errlo->SetDirectory(0);
|
267 |
h_ele_effdata_trigger_doubleele_trailing_wrt_medium_2011b_errhi->SetDirectory(0);
|
268 |
f->Close();
|
269 |
|
270 |
f = new TFile(path_ele_trigger_doubleele_trailing_wrt_loose_2011b.c_str());
|
271 |
h_ele_effdata_trigger_doubleele_trailing_wrt_loose_2011b = (TH2D*)(f->Get("hEffEtaPt")->Clone());
|
272 |
h_ele_effdata_trigger_doubleele_trailing_wrt_loose_2011b_errlo = (TH2D*)(f->Get("hErrlEtaPt")->Clone());
|
273 |
h_ele_effdata_trigger_doubleele_trailing_wrt_loose_2011b_errhi = (TH2D*)(f->Get("hErrhEtaPt")->Clone());
|
274 |
h_ele_effdata_trigger_doubleele_trailing_wrt_loose_2011b->SetDirectory(0);
|
275 |
h_ele_effdata_trigger_doubleele_trailing_wrt_loose_2011b_errlo->SetDirectory(0);
|
276 |
h_ele_effdata_trigger_doubleele_trailing_wrt_loose_2011b_errhi->SetDirectory(0);
|
277 |
f->Close();
|
278 |
|
279 |
|
280 |
|
281 |
}
|
282 |
|
283 |
|
284 |
std::pair<double,double> muonPerLegOfflineEfficiencyWeight( ControlFlags &ctrl, unsigned era, float eta, float pt ) {
|
285 |
|
286 |
double w, werr;
|
287 |
|
288 |
if( era == 2011 ) {
|
289 |
|
290 |
double w_2011a = h_mu_effsf_idiso_2011a->GetBinContent( h_mu_effsf_idiso_2011a->FindBin( pt, fabs(eta)) );
|
291 |
double werr_2011a = h_mu_effsf_idiso_2011a->GetBinError( h_mu_effsf_idiso_2011a->FindBin( pt, fabs(eta)) );
|
292 |
|
293 |
double w_2011b = h_mu_effsf_idiso_2011b->GetBinContent( h_mu_effsf_idiso_2011b->FindBin( pt, fabs(eta)) );
|
294 |
double werr_2011b = h_mu_effsf_idiso_2011b->GetBinError( h_mu_effsf_idiso_2011b->FindBin( pt, fabs(eta)) );
|
295 |
|
296 |
w = (f_doublemu7+f_mu2011a)*w_2011a + f_mu2011b*w_2011b;
|
297 |
werr = (f_doublemu7+f_mu2011a)*werr_2011a + f_mu2011b*werr_2011b;
|
298 |
|
299 |
} else if ( era == 2012 ) {
|
300 |
w = h_mu_effsf_idiso_s12_pu2012->GetBinContent( h_mu_effsf_idiso_s12_pu2012->FindBin(pt, fabs(eta)) );
|
301 |
werr = h_mu_effsf_idiso_s12_pu2012->GetBinError( h_mu_effsf_idiso_s12_pu2012->FindBin(pt,fabs(eta)) );
|
302 |
if(ctrl.debug) std::cout << " muon per leg :: pt: "<< pt << "\teta: " << eta << "\tw:" << w << std::endl;
|
303 |
}
|
304 |
|
305 |
if( isnan(w) ) {
|
306 |
if(ctrl.debug)
|
307 |
std::cout << " w is nan for mu!!! pt: " << pt << "\teta: " << eta << std::endl
|
308 |
<< " returning zero ..." << std::endl;
|
309 |
return std::pair<double,double> (0,0);
|
310 |
}
|
311 |
|
312 |
return std::pair<double,double> (w,werr);
|
313 |
}
|
314 |
//----------------------------------------------------------------------------------------
|
315 |
std::pair<double,double> elePerLegOfflineEfficiencyWeight( ControlFlags &ctrl, unsigned era, float eta, float pt, bool isMedium ) {
|
316 |
|
317 |
double w, werr;
|
318 |
|
319 |
if( era == 2011 ) {
|
320 |
|
321 |
w = h_ele_effsf_recoidisosip_2011->GetBinContent( h_ele_effsf_recoidisosip_2011->FindBin( pt, fabs(eta)) );
|
322 |
werr = h_ele_effsf_recoidisosip_2011->GetBinError( h_ele_effsf_recoidisosip_2011->FindBin( pt, fabs(eta)) );
|
323 |
if(ctrl.debug) std::cout << " electron per leg :: pt: "<< pt << "\teta: " << eta << "\tw:" << w << std::endl;
|
324 |
} else if( era == 2012 ) {
|
325 |
w = h_ele_effsf_recoidisosip_2012->GetBinContent( h_ele_effsf_recoidisosip_2012->FindBin( pt, fabs(eta)) );
|
326 |
werr = h_ele_effsf_recoidisosip_2012->GetBinError( h_ele_effsf_recoidisosip_2012->FindBin( pt, fabs(eta)) );
|
327 |
if(ctrl.debug) std::cout << " electron per leg :: pt: "<< pt << "\teta: " << eta << "\tw:" << w << std::endl;
|
328 |
// cout << "w = " << w << endl;
|
329 |
// cout << "werr = " << werr << endl;
|
330 |
|
331 |
}
|
332 |
|
333 |
if( isnan(w) ) {
|
334 |
if(ctrl.debug)
|
335 |
std::cout << "w is nan for ele!!! pt: " << pt << "\teta: " << eta << std::endl
|
336 |
<< "returning zero ..." << std::endl;
|
337 |
return std::pair<double,double> (0,0);
|
338 |
}
|
339 |
|
340 |
return std::pair<double,double> (w,werr);
|
341 |
}
|
342 |
|
343 |
// just multiplies the weights and propagates the uncerts
|
344 |
std::pair<double,double> getOfflineEfficiencyWeight( std::vector<std::pair<double,double> > &v ) {
|
345 |
|
346 |
assert( v.size() == 4 );
|
347 |
|
348 |
double w=1., werr;
|
349 |
double tmperr=0.;
|
350 |
|
351 |
for( int i=0; i<v.size(); i++ ) {
|
352 |
// std::cout << "v :: i " << i << "\tfirst: " << v[i].first << "\tsecond: " << v[i].second << std::endl;
|
353 |
w *= v[i].first;
|
354 |
tmperr += (v[i].second/v[i].first)*(v[i].second/v[i].first);
|
355 |
}
|
356 |
|
357 |
werr = w*sqrt(tmperr);
|
358 |
|
359 |
return std::pair<double,double> (w,werr);
|
360 |
|
361 |
}
|
362 |
//-----------------------------------------------------------------------------------------------------------------
|
363 |
pair<double,double>
|
364 |
getOnlineEfficiencySF( std::vector<SimpleLepton> & lvec,
|
365 |
std::vector<std::pair<bool,bool> > matches,
|
366 |
TH2D * h_sf_leading,
|
367 |
TH2D * h_sf_trailing )
|
368 |
//-----------------------------------------------------------------------------------------------------------------
|
369 |
{
|
370 |
|
371 |
double sf=1., sferr=0.;
|
372 |
for( int i=0; i<lvec.size(); i++ ) {
|
373 |
double pt = lvec[i].vec.Pt();
|
374 |
double absEta = fabs(lvec[i].vec.Eta());
|
375 |
if( matches[i].first ) {
|
376 |
sf *= h_sf_leading->GetBinContent(h_sf_leading->FindBin(pt,absEta));
|
377 |
double err = h_sf_leading->GetBinError(h_sf_leading->FindBin(pt,absEta));
|
378 |
sferr += err*err;
|
379 |
}
|
380 |
if( matches[i].second ) {
|
381 |
sf *= h_sf_trailing->GetBinContent(h_sf_trailing->FindBin(pt,absEta));
|
382 |
double err = h_sf_trailing->GetBinError(h_sf_trailing->FindBin(pt,absEta));
|
383 |
sferr += err*err;
|
384 |
}
|
385 |
}
|
386 |
return pair<double,double> (sf,sqrt(sferr));
|
387 |
}
|
388 |
|
389 |
//-----------------------------------------------------------------------------------------------------------------
|
390 |
pair<double,double>
|
391 |
getOnlineEfficiencySF( std::vector<SimpleLepton> & lvec,
|
392 |
std::vector<std::pair<bool,bool> > matches,
|
393 |
TH2D * h_sf )
|
394 |
//-----------------------------------------------------------------------------------------------------------------
|
395 |
{
|
396 |
double sf=1., sferr=0.;
|
397 |
for( int i=0; i<lvec.size(); i++ ) {
|
398 |
double pt = lvec[i].vec.Pt();
|
399 |
double absEta = fabs(lvec[i].vec.Eta());
|
400 |
if( matches[i].first || matches[i].second ) {
|
401 |
sf *= h_sf->GetBinContent(h_sf->FindBin(pt,absEta));
|
402 |
double err = h_sf->GetBinError(h_sf->FindBin(pt,absEta));
|
403 |
sferr += err*err;
|
404 |
}
|
405 |
}
|
406 |
return pair<double,double> (sf,sqrt(sferr));
|
407 |
}
|
408 |
//-----------------------------------------------------------------------------------------------------------------
|
409 |
std::pair<double,double>
|
410 |
getOnlineEfficiencyWeight( ControlFlags &ctrl,
|
411 |
std::bitset<1024> triggerBits,
|
412 |
mithep::TriggerTable *hltTable,
|
413 |
mithep::Array<mithep::TriggerObject> *hltObjArr,
|
414 |
mithep::TriggerObjectsTable *fTrigObjs,
|
415 |
vector<SimpleLepton> &mvec,
|
416 |
vector<SimpleLepton> &evec )
|
417 |
//-----------------------------------------------------------------------------------------------------------------
|
418 |
{
|
419 |
if(ctrl.debug) cout << " getOnlineEfficiencyWeight:" << endl;
|
420 |
|
421 |
double won = 1.;
|
422 |
double werron=0;
|
423 |
vector< pair<bool,bool> > leg_matches;
|
424 |
|
425 |
//
|
426 |
// electron triggers
|
427 |
//
|
428 |
if ( triggerBits.test(kHLT_Ele17_CaloIdT_TrkIdVL_CaloIsoVL_TrkIsoVL_Ele8_CaloIdT_TrkIdVL_CaloIsoVL_TrkIsoVL) ) {
|
429 |
if(ctrl.debug) cout << " evt triggered HLT_Ele17_CaloIdT_TrkIdVL_CaloIsoVL_TrkIsoVL_Ele8_CaloIdT_TrkIdVL_CaloIsoVL_TrkIsoVL" << endl;
|
430 |
leg_matches.clear();
|
431 |
for( int i=0; i<evec.size(); i++ ) {
|
432 |
pair<bool,bool> this_match =
|
433 |
triggerObjectMatches( evec[i].vec.Eta(), evec[i].vec.Phi(),
|
434 |
kHLT_Ele17_CaloIdT_TrkIdVL_CaloIsoVL_TrkIsoVL_Ele8_CaloIdT_TrkIdVL_CaloIsoVL_TrkIsoVL,
|
435 |
hltTable, hltObjArr, fTrigObjs);
|
436 |
if(ctrl.debug) cout << " ele: " << i << "\tmatch1: " << this_match.first << "\tmatch2: " << this_match.second << endl;
|
437 |
leg_matches.push_back( this_match );
|
438 |
}
|
439 |
pair<double,double> tmpw
|
440 |
= getOnlineEfficiencySF( evec, leg_matches, h_ele_effsf_trigger_17GeV_pu2012ab, h_ele_effsf_trigger_8GeV_pu2012ab);
|
441 |
if(ctrl.debug) cout << " tmpw.first: " << tmpw.first << "\ttmpw.second: " << tmpw.second << endl;
|
442 |
won *= tmpw.first;
|
443 |
werron += (tmpw.second*tmpw.second);
|
444 |
}
|
445 |
string h_ele_trigger_17GeV_pu2012ab;
|
446 |
|
447 |
//
|
448 |
// muon triggers
|
449 |
//
|
450 |
if ( triggerBits.test(kHLT_Mu17_Mu8) ) {
|
451 |
if(ctrl.debug) cout << " evt triggered HLT_Mu17_Mu8" << endl;
|
452 |
leg_matches.clear();
|
453 |
for( int i=0; i<mvec.size(); i++ ) {
|
454 |
pair<bool,bool> this_match =
|
455 |
triggerObjectMatches( mvec[i].vec.Eta(), mvec[i].vec.Phi(),
|
456 |
kHLT_Mu17_Mu8,
|
457 |
hltTable, hltObjArr, fTrigObjs);
|
458 |
if(ctrl.debug) cout << " mu: " << i << "\tmatch1: " << this_match.first << "\tmatch2: " << this_match.second << endl;
|
459 |
leg_matches.push_back( this_match );
|
460 |
}
|
461 |
pair<double,double> tmpw
|
462 |
= getOnlineEfficiencySF( mvec, leg_matches, h_mu_effsf_trigger_17GeV_pu2012ab, h_mu_effsf_trigger_8GeV_pu2012ab);
|
463 |
if(ctrl.debug) cout << " tmpw.first: " << tmpw.first << "\ttmpw.second: " << tmpw.second << endl;
|
464 |
won *= tmpw.first;
|
465 |
werron += (tmpw.second*tmpw.second);
|
466 |
}
|
467 |
if ( triggerBits.test(kHLT_Mu17_TkMu8) ) {
|
468 |
if(ctrl.debug) cout << " evt triggered HLT_Mu17_TkMu8" << endl;
|
469 |
leg_matches.clear();
|
470 |
for( int i=0; i<mvec.size(); i++ ) {
|
471 |
pair<bool,bool> this_match =
|
472 |
triggerObjectMatches( mvec[i].vec.Eta(), mvec[i].vec.Phi(),
|
473 |
kHLT_Mu17_TkMu8,
|
474 |
hltTable, hltObjArr, fTrigObjs);
|
475 |
if(ctrl.debug) cout << " mu: " << i << "\tmatch1: " << this_match.first << "\tmatch2: " << this_match.second << endl;
|
476 |
leg_matches.push_back( this_match );
|
477 |
}
|
478 |
pair<double,double> tmpw
|
479 |
= getOnlineEfficiencySF( mvec, leg_matches, h_mu_effsf_trigger_17GeV_pu2012ab, h_mu_effsf_trigger_8GeV_trk_pu2012ab);
|
480 |
if(ctrl.debug) cout << " tmpw.first: " << tmpw.first << "\ttmpw.second: " << tmpw.second << endl;
|
481 |
won *= tmpw.first;
|
482 |
werron += (tmpw.second*tmpw.second);
|
483 |
}
|
484 |
|
485 |
//
|
486 |
// cross trigger
|
487 |
//
|
488 |
if ( triggerBits.test(kHLT_Mu8_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL) ) {
|
489 |
if(ctrl.debug) cout << " evt triggered HLT_Mu8_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL" << endl;
|
490 |
|
491 |
leg_matches.clear();
|
492 |
for( int i=0; i<evec.size(); i++ ) {
|
493 |
pair<bool,bool> this_match =
|
494 |
triggerObjectMatches( evec[i].vec.Eta(), evec[i].vec.Phi(),
|
495 |
kHLT_Mu8_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL,
|
496 |
hltTable, hltObjArr, fTrigObjs);
|
497 |
if(ctrl.debug) cout << " ele: " << i << "\tmatch1: " << this_match.first << "\tmatch2: " << this_match.second << endl;
|
498 |
leg_matches.push_back( this_match );
|
499 |
}
|
500 |
pair<double,double> tmpw
|
501 |
= getOnlineEfficiencySF( evec, leg_matches, h_ele_effsf_trigger_17GeV_pu2012ab);
|
502 |
if(ctrl.debug) cout << " tmpw.first: " << tmpw.first << "\ttmpw.second: " << tmpw.second << endl;
|
503 |
won *= tmpw.first;
|
504 |
werron += (tmpw.second*tmpw.second);
|
505 |
|
506 |
leg_matches.clear();
|
507 |
for( int i=0; i<mvec.size(); i++ ) {
|
508 |
pair<bool,bool> this_match =
|
509 |
triggerObjectMatches( mvec[i].vec.Eta(), mvec[i].vec.Phi(),
|
510 |
kHLT_Mu8_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL,
|
511 |
hltTable, hltObjArr, fTrigObjs);
|
512 |
if(ctrl.debug) cout << " mu: " << i << "\tmatch1: " << this_match.first << "\tmatch2: " << this_match.second << endl;
|
513 |
leg_matches.push_back( this_match );
|
514 |
}
|
515 |
tmpw
|
516 |
= getOnlineEfficiencySF( mvec, leg_matches, h_mu_effsf_trigger_8GeV_pu2012ab);
|
517 |
if(ctrl.debug) cout << " tmpw.first: " << tmpw.first << "\ttmpw.second: " << tmpw.second << endl;
|
518 |
won *= tmpw.first;
|
519 |
werron += (tmpw.second*tmpw.second);
|
520 |
}
|
521 |
|
522 |
|
523 |
if ( triggerBits.test(kHLT_Mu17_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL) ) {
|
524 |
if(ctrl.debug) cout << " evt triggered HLT_Mu17_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL" << endl;
|
525 |
|
526 |
|
527 |
leg_matches.clear();
|
528 |
for( int i=0; i<mvec.size(); i++ ) {
|
529 |
pair<bool,bool> this_match =
|
530 |
triggerObjectMatches( mvec[i].vec.Eta(), mvec[i].vec.Phi(),
|
531 |
kHLT_Mu17_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL,
|
532 |
hltTable, hltObjArr, fTrigObjs);
|
533 |
if(ctrl.debug) cout << " mu: " << i << "\tmatch1: " << this_match.first << "\tmatch2: " << this_match.second << endl;
|
534 |
leg_matches.push_back( this_match );
|
535 |
}
|
536 |
pair<double,double> tmpw
|
537 |
= getOnlineEfficiencySF( mvec, leg_matches, h_mu_effsf_trigger_17GeV_pu2012ab);
|
538 |
if(ctrl.debug) cout << " tmpw.first: " << tmpw.first << "\ttmpw.second: " << tmpw.second << endl;
|
539 |
won *= tmpw.first;
|
540 |
werron += (tmpw.second*tmpw.second);
|
541 |
|
542 |
leg_matches.clear();
|
543 |
for( int i=0; i<evec.size(); i++ ) {
|
544 |
pair<bool,bool> this_match =
|
545 |
triggerObjectMatches( evec[i].vec.Eta(), evec[i].vec.Phi(),
|
546 |
kHLT_Mu17_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL,
|
547 |
hltTable, hltObjArr, fTrigObjs);
|
548 |
if(ctrl.debug) cout << " ele: " << i << "\tmatch1: " << this_match.first << "\tmatch2: " << this_match.second << endl;
|
549 |
leg_matches.push_back( this_match );
|
550 |
}
|
551 |
tmpw
|
552 |
= getOnlineEfficiencySF( evec, leg_matches, h_ele_effsf_trigger_8GeV_pu2012ab);
|
553 |
if(ctrl.debug) cout << " tmpw.first: " << tmpw.first << "\ttmpw.second: " << tmpw.second << endl;
|
554 |
won *= tmpw.first;
|
555 |
werron += (tmpw.second*tmpw.second);
|
556 |
}
|
557 |
|
558 |
return std::pair<double,double> (won,sqrt(werron));
|
559 |
|
560 |
}
|
561 |
|